summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEudyptula <eitan@mosenkis.net>2009-06-17 16:13:25 -0400
committerEudyptula <eitan@mosenkis.net>2009-06-17 16:13:25 -0400
commitc738a941f9fae797bcddf78849f2cfdbe4e490c2 (patch)
tree39e5bf7e5baddf18d483a6a1c1547ec7e1d14ff6 /frontend
parentSetup basics of frontend (diff)
downloadingenue-c738a941f9fae797bcddf78849f2cfdbe4e490c2.tar.gz
ingenue-c738a941f9fae797bcddf78849f2cfdbe4e490c2.tar.bz2
ingenue-c738a941f9fae797bcddf78849f2cfdbe4e490c2.zip
Got frontend debug working, added basic images, fixed files to not be executable
Diffstat (limited to 'frontend')
-rw-r--r--[-rwxr-xr-x]frontend/config.php2
-rw-r--r--frontend/css/debug.css51
-rw-r--r--frontend/css/general.css107
-rw-r--r--frontend/css/messageboxes.css65
-rw-r--r--[-rwxr-xr-x]frontend/functions/contenttype.php4
-rw-r--r--[-rwxr-xr-x]frontend/functions/debug.php5
-rw-r--r--[-rwxr-xr-x]frontend/functions/genPass.php0
-rw-r--r--[-rwxr-xr-x]frontend/functions/messageboxes.php (renamed from frontend/functions/printmessage.php)2
-rw-r--r--[-rwxr-xr-x]frontend/functions/onshutdown.php8
-rw-r--r--[-rwxr-xr-x]frontend/functions/sql.php0
-rw-r--r--[-rwxr-xr-x]frontend/functions/timetosecs.php0
-rw-r--r--[-rwxr-xr-x]frontend/functions/url.php0
-rw-r--r--[-rwxr-xr-x]frontend/functions/xhtmlemail.php0
-rw-r--r--[-rwxr-xr-x]frontend/functions/xmlheader.php0
-rw-r--r--frontend/images/error.gifbin0 -> 696 bytes
-rw-r--r--frontend/images/error_small.gifbin0 -> 343 bytes
-rwxr-xr-xfrontend/images/minusbox.gifbin0 -> 59 bytes
-rwxr-xr-xfrontend/images/plusbox.gifbin0 -> 61 bytes
-rwxr-xr-xfrontend/images/search.gifbin0 -> 213 bytes
-rw-r--r--frontend/images/success.gifbin0 -> 703 bytes
-rw-r--r--frontend/images/success_small.gifbin0 -> 346 bytes
-rw-r--r--frontend/images/warning.gifbin0 -> 698 bytes
-rw-r--r--frontend/images/warning_small.gifbin0 -> 336 bytes
-rw-r--r--[-rwxr-xr-x]frontend/include/constants.php0
-rw-r--r--frontend/include/dbinit.php4
-rw-r--r--[-rwxr-xr-x]frontend/include/error_handling.php0
-rw-r--r--[-rwxr-xr-x]frontend/include/footer.php13
-rw-r--r--frontend/include/header.php5
-rw-r--r--frontend/include/setup.php1
-rwxr-xr-xfrontend/js/GetXmlHttpObject.js10
-rw-r--r--frontend/js/ajax.js.php122
-rw-r--r--frontend/js/debug.js.php82
-rw-r--r--frontend/js/url.js.php5
-rw-r--r--[-rwxr-xr-x]frontend/pages/404.php0
-rw-r--r--[-rwxr-xr-x]frontend/pages/passthrough.php8
-rw-r--r--frontend/pages/stylesheet.php12
-rw-r--r--frontend/pages/welcome.php15
-rw-r--r--[-rwxr-xr-x]frontend/routing.csv2
38 files changed, 497 insertions, 26 deletions
diff --git a/frontend/config.php b/frontend/config.php
index 4003a12..6a0ec38 100755..100644
--- a/frontend/config.php
+++ b/frontend/config.php
@@ -4,7 +4,7 @@ $conf['sqlhost']='localhost'; // MySQL server
$conf['sqluser']='soc'; // MySQL username
$conf['sqlpass']='socpassword'; // MySQL password
$conf['sqldb']='soc'; // MySQL database
-$conf['debug']=false; // Whether to print debugging information
+$conf['debug']=true; // Whether to print debugging information
$conf['cache']=true; // Whether to enable built-in caching
$conf['cookiename']='ingenueid'; // Name of the cookie to send for keeping sessions
$conf['sessionlength']=1814400; // Time in seconds before sessions are purged
diff --git a/frontend/css/debug.css b/frontend/css/debug.css
new file mode 100644
index 0000000..38c6774
--- /dev/null
+++ b/frontend/css/debug.css
@@ -0,0 +1,51 @@
+<?php if ($conf['debug']) { ?>
+div#debug {
+ font-family: monospace;
+ background-color: white;
+ border: 1px solid black;
+ color: black;
+ position: fixed;
+ bottom: 0px;
+ left: 0px;
+ width: 100%;
+}
+div#debug div.heading {
+ width: 100%;
+ background-color: black;
+ color: white;
+ font-family: serif;
+ font-weight: bold;
+ font-size: 120%;
+ cursor: pointer;
+}
+div #debugbox {
+ max-height: 25em;
+ overflow: auto;
+}
+div.debug {
+ overflow: hidden;
+ padding-left: 50px;
+ text-indent: -50px;
+ z-index: 999;
+}
+div.debug * {
+ text-indent: 0px;
+}
+div.debug span.type {
+ font-weight: bold;
+}
+div.debug pre {
+ white-space: normal;
+}
+#debugactions {
+ position: fixed;
+ right: 5px;
+}
+#debugactions a {
+ color: red;
+}
+table.sqldebug {
+ text-align: center;
+ background-color: black;
+}
+<?php } ?>
diff --git a/frontend/css/general.css b/frontend/css/general.css
new file mode 100644
index 0000000..3496cf3
--- /dev/null
+++ b/frontend/css/general.css
@@ -0,0 +1,107 @@
+body {
+ padding: 0px;
+ margin: 0px;
+ border: 0px;
+}
+input {
+ border: 1px solid teal;
+}
+.odd {
+ background-color: rgb(230,230,230);
+}
+.even {
+ background-color: rgb(220,220,255);
+}
+.invisible {
+ display: none;
+}
+.centered {
+ text-align: center;
+}
+.box {
+ border: 1px solid rgb(0,0,200);
+ margin: 0.4% 0 0 0.4%;
+ padding: 1%;
+}
+#left {
+ float: left;
+ width: 18%;
+}
+#left select {
+ max-width: 100%;
+}
+#top {
+ padding: 5px;
+ float: left;
+ width: 77%;
+ text-align: right;
+}
+#welcome {
+ float: left;
+}
+#top a, #left a {
+ color: blue;
+}
+#main {
+ padding: 5px;
+ float: left;
+ width: 77%;
+}
+#bottom {
+ float: left;
+ width: 97%;
+}
+#logo {
+ width: 100%;
+ border: 0;
+}
+h1, h2, h3, h4, h5, h6 {
+ margin: 0px;
+}
+div .editlink, div.links {
+ float: right;
+ clear: both;
+ color: blue;
+ margin-bottom: 1em;
+}
+div.links {
+ width: 32px;
+}
+div.links img {
+ border: 0;
+ float: left;
+ width: 16px;
+ height: 16px;
+}
+.nonbreaking {
+ white-space: nowrap;
+}
+.hebrew {
+ direction: rtl;
+}
+#left .title {
+ font-size: 200%;
+ color: black;
+ text-decoration: none;
+}
+input.day {
+ width: 2em;
+}
+input.year {
+ width: 3em;
+}
+input.time {
+ width: 5em;
+}
+hr {
+ height: 0px;
+ border-top: 1px dashed blue;
+}
+.pointer {
+ cursor: pointer;
+}
+<?php if ($conf['debug']) { ?>
+html {
+ margin-bottom: 2em;
+}
+<?php } ?>
diff --git a/frontend/css/messageboxes.css b/frontend/css/messageboxes.css
new file mode 100644
index 0000000..7d168f5
--- /dev/null
+++ b/frontend/css/messageboxes.css
@@ -0,0 +1,65 @@
+.messagebox {
+ background-repeat: no-repeat;
+ background-position: center left;
+ border-width: 5px;
+ border-style: outset;
+ position: relative;
+ left: 10%;
+ width: 70%;
+ padding: 1em;
+ padding-left: 70px;
+ min-height: 64px;
+ margin: 1em;
+}
+.messagebox.short {
+ left: 5%;
+ width: 25%;
+ padding: 0.5em;
+ padding-left: 32px;
+ min-height: 32px;
+ vertical-align: middle;
+}
+.error {
+ border-color: rgb(255,0,0);
+ background-color: rgb(255,200,200);
+ background-image: <?php echo 'url("'.url('images/error.gif').'")' ?>;
+}
+.error.short {
+ background-image: <?php echo 'url("'.url('images/error_small.gif').'")' ?>;
+}
+.warning {
+ border-color: rgb(255,255,0);
+ background-color: rgb(255,255,200);
+ background-image: <?php echo 'url("'.url('images/warning.gif').'")' ?>;
+}
+.warning.short {
+ background-image: <?php echo 'url("'.url('images/warning_small.gif').'")' ?>;
+}
+.success {
+ border-color: rgb(0,255,0);
+ background-color: rgb(200,255,200);
+ background-image: <?php echo 'url("'.url('images/success.gif').'")' ?>;
+}
+.success.short {
+ background-image: <?php echo 'url("'.url('images/success_small.gif').'")' ?>;
+}
+/* Causes height to stick to 64px min.
+.messagebox .title, .messagebox .message {
+ float: left;
+ clear: both;
+}
+.messagebox * .title, .messagebox * .message {
+ float: none;
+ clear: none;
+}
+*/
+.messagebox .title {
+ font-weight: bold;
+ font-size: 120%;
+}
+.messagebox .message {
+ font-style: italic;
+}
+.messagebox .message i {
+ font-style: normal;
+}
diff --git a/frontend/functions/contenttype.php b/frontend/functions/contenttype.php
index ab546be..640f3e4 100755..100644
--- a/frontend/functions/contenttype.php
+++ b/frontend/functions/contenttype.php
@@ -1,7 +1,7 @@
<?php
function contenttype($type) {
- global $state;
+ global $S;
header('Content-type: '.$type);
- $state->notemplates=true;
+ $S['notemplates']=true;
}
?>
diff --git a/frontend/functions/debug.php b/frontend/functions/debug.php
index 397a95d..8487916 100755..100644
--- a/frontend/functions/debug.php
+++ b/frontend/functions/debug.php
@@ -1,13 +1,12 @@
<?php
function debug ($type, $text=null) {
- global $state;
- global $conf;
+ global $conf, $S;
if ($conf['debug']) {
if ($text===null) {
$text=$type;
$type=null;
}
- $state->debug[]=array($type, $text);
+ $S['debug'][]=array($type, $text);
}
}
?>
diff --git a/frontend/functions/genPass.php b/frontend/functions/genPass.php
index b2eeda3..b2eeda3 100755..100644
--- a/frontend/functions/genPass.php
+++ b/frontend/functions/genPass.php
diff --git a/frontend/functions/printmessage.php b/frontend/functions/messageboxes.php
index 7410ef5..e3270ae 100755..100644
--- a/frontend/functions/printmessage.php
+++ b/frontend/functions/messageboxes.php
@@ -1,6 +1,6 @@
<?php
function print_message_long($type, $title, $message) {
- return '<div class="messagebox '.$type.'"><span class="title">'.$title.'</span><span class="message">'.$message.'</span></div>';
+ return '<div class="messagebox '.$type.'"><span class="title">'.$title.'</span><br/><span class="message">'.$message.'</span></div>';
}
function print_message_short($type, $message) {
return '<div class="messagebox '.$type.' short"><span class="message">'.$message.'</span></div>';
diff --git a/frontend/functions/onshutdown.php b/frontend/functions/onshutdown.php
index f0299fa..60c2cb4 100755..100644
--- a/frontend/functions/onshutdown.php
+++ b/frontend/functions/onshutdown.php
@@ -1,18 +1,18 @@
<?php
function onshutdown($footerloc, $headerloc) {
- global $state, $request, $conf, $death;
- if (isset($state) && is_object($state) && !$state->notemplates) {
+ global $S, $request, $conf, $death;
+ if (isset($S) && is_array($S) && !$S['notemplates']) {
require_once($headerloc);
if ($death) {
echo $death;
}
require_once($footerloc);
- } elseif (isset($conf) && isset($state) && is_object($state) && isset($request) && isset($request['ajax'])) {
+ } elseif (isset($conf) && isset($S) && is_array($S) && isset($request) && isset($request['ajax'])) {
if (isset($death)) {
echo '<death_message>'.$death.'</death_message>';
}
if ($conf['debug']) {
- foreach ($state->debug as $row) {
+ foreach ($S['debug'] as $row) {
list($type, $text)=$row;
echo '<debug>';
if ($type !== null) {
diff --git a/frontend/functions/sql.php b/frontend/functions/sql.php
index f100413..f100413 100755..100644
--- a/frontend/functions/sql.php
+++ b/frontend/functions/sql.php
diff --git a/frontend/functions/timetosecs.php b/frontend/functions/timetosecs.php
index 7cc278b..7cc278b 100755..100644
--- a/frontend/functions/timetosecs.php
+++ b/frontend/functions/timetosecs.php
diff --git a/frontend/functions/url.php b/frontend/functions/url.php
index 2cac083..2cac083 100755..100644
--- a/frontend/functions/url.php
+++ b/frontend/functions/url.php
diff --git a/frontend/functions/xhtmlemail.php b/frontend/functions/xhtmlemail.php
index 753a6dc..753a6dc 100755..100644
--- a/frontend/functions/xhtmlemail.php
+++ b/frontend/functions/xhtmlemail.php
diff --git a/frontend/functions/xmlheader.php b/frontend/functions/xmlheader.php
index d52164d..d52164d 100755..100644
--- a/frontend/functions/xmlheader.php
+++ b/frontend/functions/xmlheader.php
diff --git a/frontend/images/error.gif b/frontend/images/error.gif
new file mode 100644
index 0000000..0a9338e
--- /dev/null
+++ b/frontend/images/error.gif
Binary files differ
diff --git a/frontend/images/error_small.gif b/frontend/images/error_small.gif
new file mode 100644
index 0000000..ee7575f
--- /dev/null
+++ b/frontend/images/error_small.gif
Binary files differ
diff --git a/frontend/images/minusbox.gif b/frontend/images/minusbox.gif
new file mode 100755
index 0000000..57a804b
--- /dev/null
+++ b/frontend/images/minusbox.gif
Binary files differ
diff --git a/frontend/images/plusbox.gif b/frontend/images/plusbox.gif
new file mode 100755
index 0000000..0ade955
--- /dev/null
+++ b/frontend/images/plusbox.gif
Binary files differ
diff --git a/frontend/images/search.gif b/frontend/images/search.gif
new file mode 100755
index 0000000..fbdc31d
--- /dev/null
+++ b/frontend/images/search.gif
Binary files differ
diff --git a/frontend/images/success.gif b/frontend/images/success.gif
new file mode 100644
index 0000000..258ff8e
--- /dev/null
+++ b/frontend/images/success.gif
Binary files differ
diff --git a/frontend/images/success_small.gif b/frontend/images/success_small.gif
new file mode 100644
index 0000000..38e8c64
--- /dev/null
+++ b/frontend/images/success_small.gif
Binary files differ
diff --git a/frontend/images/warning.gif b/frontend/images/warning.gif
new file mode 100644
index 0000000..a250989
--- /dev/null
+++ b/frontend/images/warning.gif
Binary files differ
diff --git a/frontend/images/warning_small.gif b/frontend/images/warning_small.gif
new file mode 100644
index 0000000..45cb43b
--- /dev/null
+++ b/frontend/images/warning_small.gif
Binary files differ
diff --git a/frontend/include/constants.php b/frontend/include/constants.php
index fb16d89..fb16d89 100755..100644
--- a/frontend/include/constants.php
+++ b/frontend/include/constants.php
diff --git a/frontend/include/dbinit.php b/frontend/include/dbinit.php
new file mode 100644
index 0000000..1d76ea4
--- /dev/null
+++ b/frontend/include/dbinit.php
@@ -0,0 +1,4 @@
+<?php
+$S['pdo']=new PDO('mysql:dbname='.$conf['sqldb'].';host='.$conf['sqlhost'], $conf['sqluser'], $conf['sqlpass']);
+sql_row_obj::set_pdo_obj($S['pdo']);
+?>
diff --git a/frontend/include/error_handling.php b/frontend/include/error_handling.php
index 82f6122..82f6122 100755..100644
--- a/frontend/include/error_handling.php
+++ b/frontend/include/error_handling.php
diff --git a/frontend/include/footer.php b/frontend/include/footer.php
index 8f1b1f1..fd904af 100755..100644
--- a/frontend/include/footer.php
+++ b/frontend/include/footer.php
@@ -1,20 +1,17 @@
</div><div id="bottom" class="box">
<?php
-global $conf, $state, $rerunscripts;
-if (isset($state->start)) {
- $diff=round(microtime(true)-$state->start, 3);
+global $conf, $S;
+if (isset($S['start'])) {
+ $diff=round(microtime(true)-$S['start'], 3);
echo 'Execution took '.$diff.' seconds.<br/>'."\n";
}
echo '&#169; Eitan Mosenkis '.date('Y').'</div>';
if ($conf['debug']) {
- if (isset($rerunscripts) && $rerunscripts) {
- echo '<div id="rerunscripts">You need to rerun scripts/gensqlrowobjects.pl</div>';
- }
- echo '<br/><div id="debug"><div class="heading" onclick="toggledebugbox()">Debug (<span id="debugcount">'.$state->debugrow.'</span>) <span id="debugactions">[<a href="javascript:cleardebug()" id="debugclear">Clear</a>] [<a href="javascript:closedebug()" id="debugclose">X</a>]</span></div><div id="debugbox">'./*$state->debug.*/'</div></div>'."\n";
+ echo '<br/><div id="debug"><div class="heading" onclick="toggledebugbox()">Debug (<span id="debugcount">'.$S['debugrow'].'</span>) <span id="debugactions">[<a href="javascript:cleardebug()" id="debugclear">Clear</a>] [<a href="javascript:closedebug()" id="debugclose">X</a>]</span></div><div id="debugbox">'./*$state->debug.*/'</div></div>'."\n";
echo '<script type="text/javascript">
<!--
toggledebugbox();'."\n";
- foreach ($state->debug as $row) {
+ foreach ($S['debug'] as $row) {
list($type, $text)=$row;
$text=str_replace('"', '\"', str_replace("\r", '\\r', str_replace("\n",'\\n',$text)));
// $text used to have htmlentities() run on it, but that killed the SQL output tables
diff --git a/frontend/include/header.php b/frontend/include/header.php
index 22c9809..ae6f118 100644
--- a/frontend/include/header.php
+++ b/frontend/include/header.php
@@ -12,8 +12,7 @@
echo ($S['title'] != null?$S['title'].' | ':'').$conf['title'];
?></title>
<?php
-# $scripts=array('GetXmlHttpObject', 'class', 'ajax', 'login', 'findpos', 'suggest', 'favorites');
- $scripts=array('GetXmlHttpObject', 'ajax', 'login', 'recordings', 'search');
+ $scripts=array('GetXmlHttpObject', 'url', 'ajax');
if ($conf['debug']) {
array_unshift($scripts, 'debug');
}
@@ -27,7 +26,7 @@
</head>
<body>
<div id="left" class="box">
-<h2>SoC</h2>
+<h1>Ingenue</h1>
</div>
<div id="top" class="box">
Top stuff
diff --git a/frontend/include/setup.php b/frontend/include/setup.php
index 481037c..dbbf8e7 100644
--- a/frontend/include/setup.php
+++ b/frontend/include/setup.php
@@ -24,5 +24,6 @@ if (isset($conf['rootDir'])) { // What on Earth is going on here?
$S['cookie_dir']=$cDir;
$S['root']=rtrim('http://'.$_SERVER['HTTP_HOST'].($_SERVER['SERVER_PORT']==(isset($_SERVER['HTTPS']) && $_SERVER['HTTPS']?443:80)?'':':'.$_SERVER['SERVER_PORT']).$cDir, '/');
}
+require_once('include/dbinit.php');
// TODO DB init and sql_row_obj::set_pdo_obj
?>
diff --git a/frontend/js/GetXmlHttpObject.js b/frontend/js/GetXmlHttpObject.js
new file mode 100755
index 0000000..b4d5560
--- /dev/null
+++ b/frontend/js/GetXmlHttpObject.js
@@ -0,0 +1,10 @@
+/* Function GetXmlHttpObject is from http://www.w3schools.com/ajax/ajax_browsers.asp - it is used to get the right object, whichever browser you use */
+function GetXmlHttpObject(handler) {
+ var objXMLHttp=null
+ if (window.XMLHttpRequest) {
+ objXMLHttp=new XMLHttpRequest()
+ } else if (window.ActiveXObject) {
+ objXMLHttp=new ActiveXObject("Microsoft.XMLHTTP")
+ }
+ return objXMLHttp
+}
diff --git a/frontend/js/ajax.js.php b/frontend/js/ajax.js.php
new file mode 100644
index 0000000..b34af86
--- /dev/null
+++ b/frontend/js/ajax.js.php
@@ -0,0 +1,122 @@
+var ajaxrequestnum=0;
+var boundarylength=30;
+// Returns a 30-character random alphanumeric string
+function makemultipartboundary () {
+ var boundary='';
+ var chars='abcdefghijklmnopqrstuvwxyz0123456789';
+ var i;
+ while (boundary.length < boundarylength) {
+ i=Math.floor(Math.random()*chars.length);
+ boundary+=chars.substring(i,i+1);
+ }
+ return boundary;
+}
+// Given a two-dimensional array where the first
+function makepostdata(data) {
+ boundary=makemultipartboundary();
+ output='';
+ data[data.length]=['ajax', 'yes'];
+ for(var i=0; i<data.length; i++) {
+ output+='--'+boundary+"\r\n"+'Content-disposition: form-data; name="'+data[i][0]+'"'+"\r\n\r\n"+data[i][1]+"\r\n";
+ }
+ output+="--"+boundary+"--\r\n";
+ return output;
+}
+// Do a full AJAX request
+function doajaxrequest(page,data,callback) {
+ requestnum=ajaxrequestnum++;
+ content=makepostdata(data);
+<?php if ($conf['debug']) { ?>
+ debug('ajax:'+requestnum,'Sending to '+url(page)+':<br/>'+content);
+<?php } ?>
+ httpobj=GetXmlHttpObject();
+ httpobj.open("POST", url(page), true);
+ httpobj.setRequestHeader("Content-type", "multipart/form-data; boundary="+content.substring(2,boundarylength+2));
+ httpobj.setRequestHeader("Content-length", content.length);
+ httpobj.setRequestHeader("Connection", "close");
+ httpobj.onreadystatechange=function () {
+ if (this.readyState==4 || this.readyState=="complete") {
+ if (this.responseXML != null && this.responseXML.documentElement.nodeName==page.replace('/','')+'response') {
+ xml=this.responseXML.documentElement;
+ <?php if ($conf['debug']) { ?>
+ debug('ajax:'+requestnum, 'Got response:<br/><pre>'+this.responseText.replace(/</g, '&lt;').replace(/>/g, '&gt;')+'</pre>');
+ if (debugenabled) {
+ for (var i=0; i<xml.getElementsByTagName('debug').length; i++) {
+ row=xml.getElementsByTagName('debug')[i];
+ var type=row.getElementsByTagName('type').length!=0?row.getElementsByTagName('type')[0].childNodes[0].nodeValue:null;
+ text=row.getElementsByTagName('text')[0].childNodes[0].nodeValue;
+ if (type == null) {
+ debug(page, text);
+ } else {
+ debug(page+":"+type, text);
+ }
+ }
+ }
+ <?php } ?>
+ callback(xml);
+ <?php if ($conf['debug']) { ?>
+ } else {
+ if (this.responseText.length == 0) {
+ debug('ajax'+requestnum, 'zero-length response received');
+ } else {
+ debug('ajax'+requestnum, 'Non-XML response received:<br/><pre>'+this.responseText.replace(/</g, '&lt;').replace(/>/g, '&gt;')+'</pre>');
+ }
+ <?php } ?>
+ }
+ }
+ };
+ httpobj.send(content);
+ return httpobj;
+}
+// Takes an XML node and returns the equivalent HTML node
+// (so you can take stuff from the XML DOM in an AJAX response and insert it directly into the document)
+function XMLtoHTML(xml, notrecursive) {
+ switch(xml.nodeType) {
+ case 1: // Element Node
+ var i;
+ var html=document.createElement(xml.nodeName);
+ for (i=0; i<xml.attributes.length; i++) {
+ attr=xml.attributes.item(i);
+ if (attr.name == 'class') {
+ html.className=attr.value;
+ } else if (attr.name.match(/^on/)) {
+ var handlerfunc=new Function('event', attr.value);
+ <?php if ($conf['debug']) { ?>
+ debug('XMLtoHTML', 'setting '+xml.nodeName+(xml.id?'#'+xml.id:'')+'.'+attr.name+':'+"\r\n"+handlerfunc);
+ <?php } ?>
+ html[attr.name]=handlerfunc;
+ } else {
+ <?php if ($conf['debug']) { ?>
+ debug('XMLtoHTML', 'setting '+xml.nodeName+(xml.attributes.getNamedItem('id')?'#'+xml.attributes.getNamedItem('id').value:'')+'.'+attr.name+'='+attr.value);
+ <?php } ?>
+ html.setAttribute(attr.name, attr.value);
+ }
+ }
+ if (!notrecursive) {
+ for (i=0; i<xml.childNodes.length; i++) {
+ html.appendChild(XMLtoHTML(xml.childNodes[i]));
+ }
+ }
+ return html;
+ case 3: // Text Node
+ return document.createTextNode(xml.nodeValue);
+ }
+}
+function FormToArray(form) {
+ var data=[];
+ for (var i=0; i<form.elements.length; i++) {
+ element=form.elements[i];
+ switch(element.tagName) {
+ case 'INPUT':
+ if ((element.type == 'radio' || element.type == 'checkbox') && !element.checked) {
+ break;
+ } else if (element.type == 'button' || element.type == 'submit' || element.type == 'reset') {
+ break;
+ }
+ case 'SELECT':
+ case 'TEXTAREA':
+ data[data.length]=[element.name, element.value]
+ }
+ }
+ return data;
+}
diff --git a/frontend/js/debug.js.php b/frontend/js/debug.js.php
new file mode 100644
index 0000000..f8956c5
--- /dev/null
+++ b/frontend/js/debug.js.php
@@ -0,0 +1,82 @@
+<?php // vim:filetype=javascript
+if ($conf['debug']) { ?>
+var debugrow=0;
+var debugenabled=1;
+var debug_queue=[];
+// Print debug info
+function debug (subtype, text) {
+ if (debugenabled==0) {
+ return;
+ }
+ if (text==null) {
+ text=subtype;
+ subtype=null;
+ }
+ text+="";
+ text=text.replace(/(\r\n|\r|\n)/g,'<br/>');
+ if (debugrow > 0) {
+ hidedebug(debugrow);
+ }
+ div=document.createElement('div');
+ div.className='debug '+(++debugrow%2?'odd':'even');
+ div.id='debug'+debugrow;
+ big=text.match('<br/>') || text.length > 60;
+ div.innerHTML='<span class="type'+(big?' pointer" onclick="toggledebug('+debugrow+')':'')+'">'+(big?'<img id="debugmanager'+debugrow+'" src="'+url('images/minusbox.gif')+'" alt="[Hide]" /> ':'')+(subtype!=null?subtype+':':'')+(big?'</span>':'')+'<span> '+text+'</span>';
+ document.getElementById("debugbox").appendChild(div);
+ document.getElementById("debugcount").childNodes[0].nodeValue=debugrow;
+}
+function toggledebugbox () {
+ if(document.getElementById('debugbox').style.display=="none") {
+ document.getElementById('debugbox').style.display="";
+ document.getElementById("debugbox").scrollTop = document.getElementById("debugbox").scrollHeight;
+ } else {
+ document.getElementById('debugbox').style.display="none"
+ }
+}
+function toggledebug(row) {
+ if (document.getElementById('debug'+row).style.maxHeight=="1.3em") {
+ showdebug(row);
+ } else {
+ hidedebug(row);
+ }
+}
+function showdebug(row) {
+ document.getElementById('debug'+row).style.maxHeight="";
+ document.getElementById('debugmanager'+row).src=url('images/minusbox.gif');
+ document.getElementById('debugmanager'+row).alt='[Hide]';
+}
+function hidedebug(row) {
+ if (document.getElementById('debugmanager'+row)) {
+ document.getElementById('debug'+row).style.maxHeight="1.3em";
+ document.getElementById('debugmanager'+row).src=url('images/plusbox.gif');
+ document.getElementById('debugmanager'+row).alt='[Show]';
+ }
+}
+function errordebug(message,script,line) {
+ subcat='<span style="color: red">ERROR: '+script.replace(/.*[/]/g,"")+':'+line+'</span>';
+ text='<span style="color: red">'+message+'</span>';
+ if (document.getElementById("debugbox")) {
+ debug(subcat, text);
+ } else {
+ debug_queue[debug_queue.length]=[subcat, text];
+ }
+}
+function cleardebug() {
+ document.getElementById('debugbox').innerHTML='';
+ document.getElementById('debugcount').childNodes[0].nodeValue=0;
+ debugrow=0;
+}
+function closedebug() {
+ document.getElementById('debug').style.display="none";
+ debugenabled=0;
+}
+function queueddebugs() {
+ for (var i=0; i<debug_queue.length; i++) {
+ debug(debug_queue[i][0], debug_queue[i][1]);
+ }
+}
+window.onerror=errordebug;
+window.onload=queueddebugs;
+<?php } else { ?>
+function debug() {}
+<?php } ?>
diff --git a/frontend/js/url.js.php b/frontend/js/url.js.php
new file mode 100644
index 0000000..358a0df
--- /dev/null
+++ b/frontend/js/url.js.php
@@ -0,0 +1,5 @@
+<?php // vim:filetype=javascript
+// Equivalent to php function of the same name ?>
+function url (relative) {
+ return "<?php echo $S['root'] ?>/"+relative;
+}
diff --git a/frontend/pages/404.php b/frontend/pages/404.php
index c81af31..c81af31 100755..100644
--- a/frontend/pages/404.php
+++ b/frontend/pages/404.php
diff --git a/frontend/pages/passthrough.php b/frontend/pages/passthrough.php
index 22b49bb..b8f0268 100755..100644
--- a/frontend/pages/passthrough.php
+++ b/frontend/pages/passthrough.php
@@ -1,6 +1,6 @@
<?php
function init_passthrough() {
- global $state, $request;
+ global $S, $request;
if (strpos('../',$request['dir'].'/'.$request['file']) !== false || !file_exists($request['dir'].'/'.$request['file']) && !file_exists($request['dir'].'/'.$request['file'].'.php')) {
debug('passthrough','File not found '.$request['dir'].'/'.$request['file']);
return '404';
@@ -32,7 +32,7 @@ function init_passthrough() {
contenttype('text/html');
break;
case 'php':
- $state->notemplates=true;
+ $S['notemplates']=true;
break;
default:
debug('passthrough', 'Unknown extension '.$request['ext']);
@@ -52,13 +52,13 @@ function init_passthrough() {
header('Content-Disposition: attachment');
}
}
- $state->notemplates=true;
+ $S['notemplates']=true;
}
function body_passthrough() {
global $request;
if (strtolower($request['ext']) == 'php') {
$_SERVER['PHP_SELF']=substr($_SERVER['PHP_SELF'],0,strlen($_SERVER['PHP_SELF'])-strlen('main.php')).$request['dir'].'/'.$request['file'];
- unset($GLOBALS['state'], $GLOBALS['request'], $GLOBALS['conf']);
+ unset($GLOBALS['S'], $GLOBALS['request'], $GLOBALS['conf']);
chdir($request['dir']);
error_reporting(E_DEFAULT);
return $request['file'];
diff --git a/frontend/pages/stylesheet.php b/frontend/pages/stylesheet.php
new file mode 100644
index 0000000..82a7f68
--- /dev/null
+++ b/frontend/pages/stylesheet.php
@@ -0,0 +1,12 @@
+<?php
+function init_stylesheet() {
+ global $state;
+ contenttype('text/css');
+}
+function body_stylesheet() {
+ global $conf;
+ foreach (glob('css/*.css') as $file) {
+ require($file);
+ }
+}
+?>
diff --git a/frontend/pages/welcome.php b/frontend/pages/welcome.php
new file mode 100644
index 0000000..f024a27
--- /dev/null
+++ b/frontend/pages/welcome.php
@@ -0,0 +1,15 @@
+<?php
+function init_welcome() {
+ global $S;
+ $S['title']='Welcome';
+}
+function body_welcome() {
+ echo '<h2>Welcome</h2>';
+ $e=new sql_buildlog_entry();
+ echo '<pre>'.$e->to_php().'</pre>';
+ debug('CREATE', $e->create_table());
+}
+class sql_buildlog_entry extends sql_row_obj {
+ var $table='buildlogs';
+}
+?>
diff --git a/frontend/routing.csv b/frontend/routing.csv
index 69f2e1c..ff7b516 100755..100644
--- a/frontend/routing.csv
+++ b/frontend/routing.csv
@@ -9,6 +9,8 @@
# Something like the following line should always be last to catch unrecognized URLs
# ^ 404
+# Home
+^$ welcome
# Session
^login$ login
^logout$ logout