Added theme support. Oh yeah, you can customize graphs using graph_{line,bar}.def.
authorDan
Mon, 05 Jan 2009 22:29:36 -0500
changeset 44 73f74d395f95
parent 43 ce2e9caf2dfa
child 46 186507f67064
Added theme support. Oh yeah, you can customize graphs using graph_{line,bar}.def.
graphing/class.graph.php
htdocs/changetz.php
htdocs/graph.php
htdocs/index.php
htdocs/news.php
htdocs/privacy.php
htdocs/themes/generic/footer.php
htdocs/themes/generic/header.php
stats-fe.php
--- a/graphing/class.graph.php	Sun Jan 04 16:40:36 2009 -0500
+++ b/graphing/class.graph.php	Mon Jan 05 22:29:36 2009 -0500
@@ -766,7 +766,7 @@
           $this->$func($settings);
         }
       }
-      if (is_array($data['data'])) {
+      if (isset($data['data']) && is_array($data['data'])) {
         $this->data = $data['data'];
       }
     }
--- a/htdocs/changetz.php	Sun Jan 04 16:40:36 2009 -0500
+++ b/htdocs/changetz.php	Mon Jan 05 22:29:36 2009 -0500
@@ -1,5 +1,6 @@
 <?php
 require('../timezone.php');
+require('../stats-fe.php');
 $set_zone = false;
 if ( isset($_POST['tz']) )
 {
@@ -11,46 +12,12 @@
     $set_zone = str_replace('_', ' ', str_replace('/', ': ', $tz));
   }
 }
-?><html>
-  <head>
-    <title>Change time zone</title>
-    <style type="text/css">
-    select, option {
-      background-color: white;
-    }
-    option.other {
-      color: black;
-      font-weight: normal;
-    }
-    option.region {
-      color: black;
-      font-weight: bold;
-    }
-    option.area {
-      color: black;
-      font-weight: normal;
-      padding-left: 1em;
-    }
-    option.country {
-      color: black;
-      font-weight: bold;
-      padding-left: 1em;
-    }
-    option.city {
-      color: black;
-      font-weight: normal;
-      padding-left: 2em;
-    }
-    div.success {
-      border: 1px solid #006300;
-      background-color: #d3ffd3;
-      padding: 10px;
-      margin: 10px 0;
-    }
-    </style>
-  </head>
-  <body>
-    <?php
+
+$title = "$nick - set time zone";
+require("./themes/$webtheme/header.php");
+
+echo '<br />';
+
     if ( $set_zone )
     {
       $target = rtrim(dirname($_SERVER['REQUEST_URI']), '/') . '/';
@@ -95,5 +62,7 @@
     <input type="submit" value="Save" /><br />
     <small>Make sure you have cookies enabled.</small>
     </form>
-  </body>
-</html>
+  
+<?php
+require("./themes/$webtheme/footer.php");
+?>
--- a/htdocs/graph.php	Sun Jan 04 16:40:36 2009 -0500
+++ b/htdocs/graph.php	Mon Jan 05 22:29:36 2009 -0500
@@ -9,6 +9,8 @@
 
 function makeGraph($type = 'bar')
 {
+  global $webtheme;
+  
   $class = ( $type == 'line' ) ? 'LineGraph' : 'BarGraph';
   $g = new $class(); // _Compat();
   
@@ -33,6 +35,10 @@
   $g->SetScaleRoundY(0);
   $g->SetScaleRoundX(0);
   $g->SetAxisStepSize(7);
+  
+  if ( file_exists("./themes/$webtheme/graph_$type.def") )
+    $g->LoadGraph(realpath("./themes/$webtheme/graph_$type.def"));
+  
   return $g;
 }
 
--- a/htdocs/index.php	Sun Jan 04 16:40:36 2009 -0500
+++ b/htdocs/index.php	Mon Jan 05 22:29:36 2009 -0500
@@ -5,21 +5,10 @@
 $channel_list = stats_channel_list();
 $first_channel = $channel_list[0];
 $channel = ( isset($_REQUEST['channel']) && in_array($_REQUEST['channel'], $channel_list) ) ? $_REQUEST['channel'] : $first_channel;
+
+$title = "$nick - Statistics";
+require("./themes/$webtheme/header.php");
 ?>
-
-<html>
-  <head>
-    <title><?php echo $nick; ?> - Statistics</title>
-    <style type="text/css">
-    div.footer {
-      font-size: smaller;
-      padding-top: 10px;
-      margin-top: 10px;
-      border-top: 1px solid #aaa;
-    }
-    </style>
-  </head>
-  <body>
     <div style="float: right;">
       <p>
         <?php
@@ -82,13 +71,12 @@
       }
       ?>
     </ul>
+    <h1>Last 60 minutes</h1>
+    <img alt="Graph image" src="graph.php?mode=lasthour&amp;channel=<?php echo urlencode($channel); ?>" />
     <h1>Last 24 hours</h1>
     <img alt="Graph image" src="graph.php?mode=lastday&amp;channel=<?php echo urlencode($channel); ?>" />
     <h1>Last 2 weeks</h1>
     <img alt="Graph image" src="graph.php?mode=lastweek&amp;channel=<?php echo urlencode($channel); ?>" />
-    
-    <div class="footer">
-    <b><?php echo $nick; ?> is a privacy-respecting bot.</b> <a href="privacy.php">Read about what information <?php echo $nick; ?> collects</a>
-    </div>
-  </body>
-</head>
+<?php
+require("./themes/$webtheme/footer.php");
+
--- a/htdocs/news.php	Sun Jan 04 16:40:36 2009 -0500
+++ b/htdocs/news.php	Mon Jan 05 22:29:36 2009 -0500
@@ -1,18 +1,18 @@
 <?php
 require('../config.php');
+require('../stats-fe.php');
 
-?><html>
-  <head>
-    <title><?php echo $nick; ?> - updates</title>
-    <style type="text/css">
+$title = "$nick - updates";
+require("./themes/$webtheme/header.php");
+?>  <style type="text/css">
     p.code {
       font-family: monospace;
       margin-left: 1.5em;
     }
     </style>
-  </head>
-  <body>
     <h1>Updates and changes</h1>
+    <h3>2009-01-04</h3>
+    <p>Added a last 60 minutes graph.</p>
     <h3>2008-12-24</h3>
     <p><?php echo $nick; ?> now has modular graph support and thus is able to show different graphs. Included now are options for the last
        24 hours as before, plus the last two weeks and the last 30 days. More, of course, can be added if needed.</p>
@@ -23,5 +23,6 @@
        records after the import of the existing flat file database. It makes for a more portable programming technique and it means it can
        be easily expanded in the future to include more data. The table's indexed so it should be decently fast.</p>
     <p>In addition, smarter functionality is being included, plus a few bugs here and there have been fixed.</p>
-  </body>
-</head>
+<?php
+require("./themes/$webtheme/footer.php");
+?>
--- a/htdocs/privacy.php	Sun Jan 04 16:40:36 2009 -0500
+++ b/htdocs/privacy.php	Mon Jan 05 22:29:36 2009 -0500
@@ -1,17 +1,16 @@
 <?php
 require('../config.php');
+require('../stats-fe.php');
 
-?><html>
-  <head>
-    <title><?php echo $nick; ?> - privacy info</title>
-    <style type="text/css">
+$title = "$nick - privacy info";
+require("./themes/$webtheme/header.php");
+
+?>  <style type="text/css">
     p.code {
       font-family: monospace;
       margin-left: 1.5em;
     }
     </style>
-  </head>
-  <body>
     <h1>Privacy information</h1>
     <p><?php echo $nick; ?> is designed to collect IRC statistics. It does this by recording raw data and then letting the frontend (index.php and the
        backend access abstraction in stats-fe.php) look at the data and draw graphs and measurements based on it.</p>
@@ -32,5 +31,5 @@
     <p>Remove yourself from the anonymization list with:</p>
     <p class="code">/msg <?php echo $nick; ?> denonymize</p>
     <p>Want to know more about the numbers <?php echo $nick; ?> collects? <a href="datafile.php">Download a dump of <?php echo $nick; ?>'s database yourself</a>.</p>
-  </body>
-</head>
+<?php
+require("./themes/$webtheme/footer.php");
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/htdocs/themes/generic/footer.php	Mon Jan 05 22:29:36 2009 -0500
@@ -0,0 +1,5 @@
+    <div class="footer">
+    <b><?php echo $nick; ?> is a privacy-respecting bot.</b> <a href="privacy.php">Read about what information <?php echo $nick; ?> collects</a>
+    </div>
+  </body>
+</html>
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/htdocs/themes/generic/header.php	Mon Jan 05 22:29:36 2009 -0500
@@ -0,0 +1,45 @@
+<html>
+  <head>
+    <title><?php echo $title; ?></title>
+    <style type="text/css">
+    div.footer {
+      font-size: smaller;
+      padding-top: 10px;
+      margin-top: 10px;
+      border-top: 1px solid #aaa;
+    }
+    select, option {
+      background-color: white;
+    }
+    option.other {
+      color: black;
+      font-weight: normal;
+    }
+    option.region {
+      color: black;
+      font-weight: bold;
+    }
+    option.area {
+      color: black;
+      font-weight: normal;
+      padding-left: 1em;
+    }
+    option.country {
+      color: black;
+      font-weight: bold;
+      padding-left: 1em;
+    }
+    option.city {
+      color: black;
+      font-weight: normal;
+      padding-left: 2em;
+    }
+    div.success {
+      border: 1px solid #006300;
+      background-color: #d3ffd3;
+      padding: 10px;
+      margin: 10px 0;
+    }
+    </style>
+  </head>
+  <body>
--- a/stats-fe.php	Sun Jan 04 16:40:36 2009 -0500
+++ b/stats-fe.php	Mon Jan 05 22:29:36 2009 -0500
@@ -14,6 +14,8 @@
 require(ENANOBOT_ROOT . '/hooks.php');
 require(ENANOBOT_ROOT . '/database.php');
 
+$webtheme = ( isset($webtheme) && is_dir(ENANOBOT_ROOT . "/htdocs/themes/$webtheme") ) ? $webtheme : 'generic';
+
 mysql_reconnect();
 
 /**