From: wbudic Date: Tue, 21 Aug 2018 06:10:58 +0000 (+1000) Subject: Initial commit of htdocs X-Git-Url: https://lifelog.hopto.org/gitweb/?a=commitdiff_plain;h=0ea36edae29d8c70b83d646a49bcdc7066c8789e;p=LifeLog.git Initial commit of htdocs --- 0ea36edae29d8c70b83d646a49bcdc7066c8789e diff --git a/README.md b/README.md new file mode 100644 index 0000000..610f07c --- /dev/null +++ b/README.md @@ -0,0 +1 @@ +# LifeLog diff --git a/htdocs/cgi-bin/.main.cgi.swo b/htdocs/cgi-bin/.main.cgi.swo new file mode 100644 index 0000000..2dcb35b Binary files /dev/null and b/htdocs/cgi-bin/.main.cgi.swo differ diff --git a/htdocs/cgi-bin/.main.cgi.swp b/htdocs/cgi-bin/.main.cgi.swp new file mode 100644 index 0000000..f15b2e0 Binary files /dev/null and b/htdocs/cgi-bin/.main.cgi.swp differ diff --git a/htdocs/cgi-bin/hello.cgi b/htdocs/cgi-bin/hello.cgi new file mode 100755 index 0000000..805abba --- /dev/null +++ b/htdocs/cgi-bin/hello.cgi @@ -0,0 +1,10 @@ +#!/usr/bin/env python +print "Content-Type: text/html" # HTML is following +print # blank line, end of headers +print "CGI script output" +print "

This is my first CGI script

" +print "Hello, world!
" +for i in range(10): + print i, '
' +print 'Just to show that some stuff is "dynamically" generated server side
' + diff --git a/htdocs/cgi-bin/main.cgi b/htdocs/cgi-bin/main.cgi new file mode 100755 index 0000000..4588661 --- /dev/null +++ b/htdocs/cgi-bin/main.cgi @@ -0,0 +1,179 @@ +#!/usr/bin/perl + +use strict; +use warnings; + +use CGI; +use DBI; + +use DateTime; +use DateTime::Format::SQLite; + +my $q = CGI->new; + +my $driver = "SQLite"; +my $database = "../../dbLifeLog/data_log.db"; +my $dsn = "DBI:$driver:dbname=$database"; +my $userid = ""; +my $password = ""; +my $dbh = DBI->connect($dsn, $userid, $password, { RaiseError => 1 }) + or die "

Error->"& $DBI::errstri &"

"; + + + +print $q->header(-expires=>"+6os"); + +print $q->start_html(-title => "Personal Log", + -script=>{-type => 'text/javascript', -src => 'wsrc/main.js'}, + -style =>{-type => 'text/css', -src => 'wsrc/main.css'} + + ); + + +my $rv; +my $today = DateTime->now; +$today->set_time_zone( 'Australia/Sydney' ); + +my $sth = $dbh->prepare("SELECT name FROM sqlite_master WHERE type='table' AND name='LOG';"); +$sth->execute(); + +if(!$sth->fetchrow_array()) { + my $stmt = qq( + + CREATE TABLE LOG ( + ID INT PRIMARY KEY NOT NULL, + ID_CAT TINY, + DATE DATETIME NOT NULL, + LOG VCHAR(60) + ); + + ); + + $rv = $dbh->do($stmt); + + if($rv < 0) { + print "

Error->"& $DBI::errstri &"

"; + } + + $sth = $dbh->prepare('INSERT INTO LOG VALUES (?,?,?,?)'); + + $sth->execute(1, 3, $today, "DB Created!"); + + + $stmt = qq( + + CREATE TABLE CAT( + ID INT PRIMARY KEY NOT NULL, + NAME VCHAR(16) + ); + + ); + + $rv = $dbh->do($stmt); + + if($rv < 0) { + print "

Error->"& $DBI::errstri &"

"; + } + + $sth = $dbh->prepare('INSERT INTO CAT VALUES (?,?)'); + + $sth->execute(1,"Unspecified"); + $sth->execute(3,"File System"); + $sth->execute(6,"System Log"); + $sth->execute(9,"Event"); + $sth->execute(28,"Personal"); + $sth->execute(32, "Expense"); +} +my $stmtCat = "SELECT * FROM CAT;"; +my $stmt = "SELECT * from LOG;"; + + +$sth = $dbh->prepare( $stmtCat ); +$rv = $sth->execute() or die or die "

Error->"& $DBI::errstri &"

"; + +my $cats = ''; + + +my $tbl = ''; +my $tbl_rc = 0; + +################################## +&processSubmit($q, %hshCats); +################################## + +#Fetch entries! +# +$sth = $dbh->prepare( $stmt ); +$rv = $sth->execute() or die or die "

Error->"& $DBI::errstri &"

"; +if($rv < 0) { + print "

Error->"& $DBI::errstri &"

"; +} + + + + while(my @row = $sth->fetchrow_array()) { + + my $ct = $hshCats{@row[1]}; + my $dt = DateTime::Format::SQLite->parse_datetime( $row[2] ); + + $tbl = $tbl . "" . + "" . "". + "\n"; + $tbl_rc +=1; + } + + if($tbl_rc==1){ + $tbl = $tbl . "\n"; + } + $tbl = $tbl . "
DateTimeLogCategory
". $dt->ymd . "" . $dt->hms . "" . $row[3] . "" . $ct ."
Table is Empty!
"; + +my $frm = qq( +
+ + + + + + +
Date
Log: ).$cats.qq(
+
+ ); + + + +print "
\n" . $tbl ."
"; +print "
\n" . $frm ."
"; + +print $q->end_html; + +$dbh->disconnect(); + +sub processSubmit { + + + my $date = $q->param('date'); + my $log = $q->param('log'); + my $cat = $q->param('cat'); + + + if($log){ + print "

Received!". $log. "

"; + + } + if($date){ + print "

Received!". $date. "

"; + + } + if($cat){ + print "

Received!". $hshCats{$cat}. "

"; + + } +} diff --git a/htdocs/cgi-bin/perl_env.cgi b/htdocs/cgi-bin/perl_env.cgi new file mode 100755 index 0000000..b61d708 --- /dev/null +++ b/htdocs/cgi-bin/perl_env.cgi @@ -0,0 +1,10 @@ +#!/usr/bin/perl + +use strict; +use warnings; + +use CGI; +my $q = CGI->new; +print $q->header; + +print "Hello World!"; diff --git a/htdocs/cgi-bin/wsrc/main.css b/htdocs/cgi-bin/wsrc/main.css new file mode 100644 index 0000000..3f97381 --- /dev/null +++ b/htdocs/cgi-bin/wsrc/main.css @@ -0,0 +1,11 @@ +[type="submit"] { + clear: left; + margin: 10px 0 0 30px; + font-size:12px +} + +p { + margin-left: 70px; + font-weight: bold; +} + diff --git a/htdocs/cgi-bin/wsrc/main.js b/htdocs/cgi-bin/wsrc/main.js new file mode 100644 index 0000000..2d8460b --- /dev/null +++ b/htdocs/cgi-bin/wsrc/main.js @@ -0,0 +1,25 @@ +function formValidation(){ + +var date = document.frm_log.date; +var log = document.frm_log.log; + +return validDate(date.value) && validLog(log.value); + +} + +function validDate(dt){ + if(!Date.parse(dt)){ + alert("Date -> '" + dt +"' is Invalid can't submit!"); + return false; + } +return true; +} + +function validLog(log){ + if(log==""){ + + alert("Log -> entry can't be empty, can't submit!"); + return false; + } +return true; +} diff --git a/htdocs/data b/htdocs/data new file mode 120000 index 0000000..fa3d85b --- /dev/null +++ b/htdocs/data @@ -0,0 +1 @@ +/usr/local/www/data \ No newline at end of file diff --git a/htdocs/test.html b/htdocs/test.html new file mode 100644 index 0000000..eebbb0e --- /dev/null +++ b/htdocs/test.html @@ -0,0 +1 @@ +

Hello thttpd