cvs: bugtracker /htdocs cache.php /htdocs/index index.php /includes cache.php cache_generate.php functions.php /includes/cache account_type.php
bug_type.php comment_type.php os_version.php php_version.php status.php users.php /template/generic/bug index.php
| From: | Barry Carlyon | Date: | Thu, 31 Jul 2008 12:34:21 +0000 |
| Subject: | cvs: bugtracker /htdocs cache.php /htdocs/index index.php /includes cache.php cache_generate.php functions.php /includes/cache account_type.php bug_type.php comment_type.php os_version.php php_version.php status.php users.php /template/generic/bug index.php |
||
| Groups: | php.webmaster | ||
| Request: | Send a blank email to php-webmaster+get-2255@lists.php.net to get a copy of this message | ||
bcarlyon Thu Jul 31 12:34:21 2008 UTC
Added files:
/bugtracker/includes cache_generate.php
/bugtracker/includes/cache users.php
Modified files:
/bugtracker/htdocs cache.php
/bugtracker/htdocs/index index.php
/bugtracker/includes cache.php functions.php
/bugtracker/includes/cache account_type.php bug_type.php
comment_type.php os_version.php
php_version.php status.php
/bugtracker/template/generic/bug index.php
Log:
Created and implemented the cache class as planned
http://cvs.php.net/viewvc.cgi/bugtracker/htdocs/cache.php?r1=1.3&r2=1.4&diff_format=u Index: bugtracker/htdocs/cache.php diff -u bugtracker/htdocs/cache.php:1.3 bugtracker/htdocs/cache.php:1.4 --- bugtracker/htdocs/cache.php:1.3 Fri Jul 11 13:14:18 2008 +++ bugtracker/htdocs/cache.php Thu Jul 31 12:34:20 2008 @@ -19,7 +19,7 @@ $cache = 'all'; -include($_SERVER['DOCUMENT_ROOT'] . '../includes/cache.php'); +include($_SERVER['DOCUMENT_ROOT'] . '../includes/cache_generate.php'); header("Location: /"); http://cvs.php.net/viewvc.cgi/bugtracker/htdocs/index/index.php?r1=1.12&r2=1.13&diff_format=u Index: bugtracker/htdocs/index/index.php diff -u bugtracker/htdocs/index/index.php:1.12 bugtracker/htdocs/index/index.php:1.13 --- bugtracker/htdocs/index/index.php:1.12 Thu Jul 31 02:38:33 2008 +++ bugtracker/htdocs/index/index.php Thu Jul 31 12:34:20 2008 @@ -32,10 +32,15 @@ include($_SERVER['DOCUMENT_ROOT'] . '../includes/email.php'); include($_SERVER['DOCUMENT_ROOT'] . '../includes/bug.php'); include($_SERVER['DOCUMENT_ROOT'] . '../includes/comment.php'); +include($_SERVER['DOCUMENT_ROOT'] . '../includes/cache.php'); $user = new user(); $email = new email(); $bug = new bug(); $comment = new comment(); +$cache = new cache(); + +//cahce! +$cache->load_cache(); //email set up $email_data = array(); @@ -46,6 +51,7 @@ //lets check to see if those templates exist $template = is_dir($_SERVER['DOCUMENT_ROOT'] . '../template/' . $bugtracker) ? $bugtracker : 'php'; +/* //lets generate some useful template varibles //however first lets include the caches include($_SERVER['DOCUMENT_ROOT'] . '../includes/cachelist.php'); @@ -68,6 +74,7 @@ } //hack in a version of php $php_version[0] = 'Irrelevant'; +*/ $form_data = array();//array for holding the data in forms $display_data = array();// array for holding all the display data that users could of entered @@ -84,7 +91,10 @@ ) ); //$template_data['cvs_version'] = substr( $php_version[sizeof($php_version)] ,0,4); -$template_data['cvs_version'] = substr( $php_version[sizeof($php_version)-1] ,0,4); +//$template_data['cvs_version'] = substr( $php_version[sizeof($php_version)-1] ,0,4); +$cache->add_to_cache('php_version', 'Irrelevant', '0'); +$template_data['cvs_version'] = substr( $cache->obtain('php_version',-1), 0, 4 ); + if ($template != 'php') { $template_data['page_title'] .= ' ' . titleit($bugtracker); http://cvs.php.net/viewvc.cgi/bugtracker/includes/cache.php?r1=1.3&r2=1.4&diff_format=u Index: bugtracker/includes/cache.php diff -u bugtracker/includes/cache.php:1.3 bugtracker/includes/cache.php:1.4 --- bugtracker/includes/cache.php:1.3 Thu Jul 10 20:56:41 2008 +++ bugtracker/includes/cache.php Thu Jul 31 12:34:20 2008 @@ -1,90 +1,73 @@ <?php -//cache creator -//$cache = $_REQUEST['cache']; -$cache = 'all'; -//$mode = $_REQUEST['mode']; - -//acceptable modes -//check - check cache is up to date, if $cache check that one only -//create - create $cache - -if ($cache == 'user' || $cache == 'all') -{ - $query = 'SELECT * FROM user'; - $db->get_data($query); +class cache{ - $users = '<?php' . "\n"; - while ($row = $db->fetch_row()) - { - $users .= ' - $users["' . $row['handle'] . '"]["handle"] = "' . $row['handle'] . '"; - $users["' . $row['handle'] . '"]["email"] = "' . $row['email'] . '"; -'; - } - - $query = 'SELECT * FROM temp_account'; - $db->get_data($query); - while ($row = $db->fetch_row()) - { - $users .= ' - $users["' . $row['handle'] . '"]["handle"] = "' . $row['handle'] . '"; - $users["' . $row['handle'] . '"]["email"] = "' . $row['email'] . '"; -'; - } - - $users .= "\n"; +/* +public $status = array(); +public $php_version = array(); +public $bug_type = array(); +public $os_version = array(); +public $comment_type = array(); + +public $account_type = array(); +public $user_data = array(); +*/ - $timetowrite = fopen($_SERVER['DOCUMENT_ROOT'] . '../includes/cache/user.php',"w+"); - fwrite($timetowrite,$users); - fclose($timetowrite); -} -if ($cache == 'types' || $cache == 'all') -{ - //will regenerate all types - //bug_status - //php_version - //bug_type - //os_version - //comment_type - - $tocache = array(); - $tocache[] = 'status'; - $tocache[] = 'bug_type'; - $tocache[] = 'php_version'; - $tocache[] = 'os_version'; - $tocache[] = 'account_type'; - $tocache[] = 'comment_type'; - - foreach($tocache as $ref => $data) - { - $query = 'SELECT * FROM ' . $data . ' ORDER BY ordering ASC'; - $db->get_data($query); - $cachetext = '<?php' . "\n"; - if ($db->total_rows) + function load_cache() { + if ($handle = opendir($_SERVER['DOCUMENT_ROOT'] . '../includes/cache/')) { - while ($row = $db->fetch_row()) + while (FALSE !== ($file = readdir($handle))) { - $cachetext .= ' - $' . $data . '[' . $row['ordering'] .'] = "' . $row[1]. '";'; + if ($file != "." && $file != "..") + { + $ref = explode(".",$file); + if ($ref[1] == 'php') + { + $thiscache = $ref[0]; + $cacher = array(); + + trace('loading cache: ' . $file); + include($_SERVER['DOCUMENT_ROOT'] . '../includes/cache/' . $file); + + $generated_cache = array(); + foreach ($cacher as $ref => $data) + { + // $ref == $file (well $ref[0]) + $generated_cache = $data; + } + $this->$thiscache = $generated_cache; + } + } } - $cachetext .= ' + closedir($handle); + } -foreach($' . $data . ' as $ref => $data) -{ - define(strtoupper(str_replace(\' \',\'_\',$data)),$ref); -} + return; + } -?>'; - } - else + function obtain($thecache, $ref) + { + $thiscache = $this->$thecache; + + if ($ref < 0) { - $cachetext .= '?>'; + //$ref is negative + $ref = sizeof($thiscache) + $ref; } - $timetowrite = fopen($_SERVER['DOCUMENT_ROOT'] . '../includes/cache/' . $data . '.php',"w+"); - fwrite($timetowrite,$cachetext); - fclose($timetowrite); + + return $thiscache[$ref]; } + //add to cache extend replced + function add_to_cache($thecache, $data, $ref = '') + { + $thiscache = $this->$thecache; + + $thiscache[$ref] = $data; + + $this->$thecache = $thiscache; + + return; + } } http://cvs.php.net/viewvc.cgi/bugtracker/includes/functions.php?r1=1.12&r2=1.13&diff_format=u Index: bugtracker/includes/functions.php diff -u bugtracker/includes/functions.php:1.12 bugtracker/includes/functions.php:1.13 --- bugtracker/includes/functions.php:1.12 Thu Jul 31 02:38:33 2008 +++ bugtracker/includes/functions.php Thu Jul 31 12:34:20 2008 @@ -67,8 +67,25 @@ // $html = api_helpers_html::renderTemplate($file,$display_data,'html'); foreach ($display_data as $ref => $replace) { - $display_data[$ref] = htmlentities($display_data[$ref], ENT_QUOTES, 'UTF-8'); - $html = str_replace('{' . strtoupper($ref) . '}',$replace,$html); +trace($$ref); + if (is_array($ref)) + { + $replace = $$ref; + $replace = $replace[$ref]; + } + if ($ref == 'time') + { + // time ref!!! + foreach ($display_data['time'] as $tref => $treplace) + { + $html = str_replace('{DSP_' . strtoupper($tref) . '}', date('d/m/Y H:i O', $treplace), $html); + } + } else { +// this line is utter rubbish +// $display_data[$ref] = htmlentities($display_data[$ref], ENT_QUOTES, 'UTF-8'); + $replace = htmlentities($display_data[$ref], ENT_QUOTES, 'UTF-8'); + $html = str_replace('{DSP_' . strtoupper($ref) . '}',$replace,$html); + } } foreach ($template_data as $ref => $replace) @@ -235,7 +252,6 @@ } function trace($message) { -return; global $trace; $trace .= $message . "\n"; return; http://cvs.php.net/viewvc.cgi/bugtracker/includes/cache/account_type.php?r1=1.4&r2=1.5&diff_format=u Index: bugtracker/includes/cache/account_type.php diff -u bugtracker/includes/cache/account_type.php:1.4 bugtracker/includes/cache/account_type.php:1.5 --- bugtracker/includes/cache/account_type.php:1.4 Fri Jul 11 13:14:18 2008 +++ bugtracker/includes/cache/account_type.php Thu Jul 31 12:34:21 2008 @@ -1,11 +1,11 @@ <?php $account_type[1] = "Temp Account"; + $cacher['account_type'][1] = "Temp Account"; $account_type[2] = "User"; + $cacher['account_type'][2] = "User"; foreach($account_type as $ref => $data) { define(strtoupper(str_replace(' ','_',$data)),$ref); } - -?> \ No newline at end of file http://cvs.php.net/viewvc.cgi/bugtracker/includes/cache/bug_type.php?r1=1.4&r2=1.5&diff_format=u Index: bugtracker/includes/cache/bug_type.php diff -u bugtracker/includes/cache/bug_type.php:1.4 bugtracker/includes/cache/bug_type.php:1.5 --- bugtracker/includes/cache/bug_type.php:1.4 Fri Jul 11 13:14:18 2008 +++ bugtracker/includes/cache/bug_type.php Thu Jul 31 12:34:21 2008 @@ -1,11 +1,11 @@ <?php $bug_type[1] = "Bug System"; + $cacher['bug_type'][1] = "Bug System"; $bug_type[2] = "Doc"; + $cacher['bug_type'][2] = "Doc"; foreach($bug_type as $ref => $data) { define(strtoupper(str_replace(' ','_',$data)),$ref); } - -?> \ No newline at end of file http://cvs.php.net/viewvc.cgi/bugtracker/includes/cache/comment_type.php?r1=1.4&r2=1.5&diff_format=u Index: bugtracker/includes/cache/comment_type.php diff -u bugtracker/includes/cache/comment_type.php:1.4 bugtracker/includes/cache/comment_type.php:1.5 --- bugtracker/includes/cache/comment_type.php:1.4 Fri Jul 11 13:14:18 2008 +++ bugtracker/includes/cache/comment_type.php Thu Jul 31 12:34:21 2008 @@ -1,13 +1,15 @@ <?php $comment_type[1] = "description"; + $cacher['comment_type'][1] = "description"; $comment_type[2] = "reproduce"; + $cacher['comment_type'][2] = "reproduce"; $comment_type[3] = "expected"; + $cacher['comment_type'][3] = "expected"; $comment_type[4] = "actual"; + $cacher['comment_type'][4] = "actual"; foreach($comment_type as $ref => $data) { define(strtoupper(str_replace(' ','_',$data)),$ref); } - -?> \ No newline at end of file http://cvs.php.net/viewvc.cgi/bugtracker/includes/cache/os_version.php?r1=1.4&r2=1.5&diff_format=u Index: bugtracker/includes/cache/os_version.php diff -u bugtracker/includes/cache/os_version.php:1.4 bugtracker/includes/cache/os_version.php:1.5 --- bugtracker/includes/cache/os_version.php:1.4 Fri Jul 11 13:14:18 2008 +++ bugtracker/includes/cache/os_version.php Thu Jul 31 12:34:21 2008 @@ -1,11 +1,11 @@ <?php $os_version[1] = "Linux"; + $cacher['os_version'][1] = "Linux"; $os_version[2] = "W1nd0w5"; + $cacher['os_version'][2] = "W1nd0w5"; foreach($os_version as $ref => $data) { define(strtoupper(str_replace(' ','_',$data)),$ref); } - -?> \ No newline at end of file http://cvs.php.net/viewvc.cgi/bugtracker/includes/cache/php_version.php?r1=1.6&r2=1.7&diff_format=u Index: bugtracker/includes/cache/php_version.php diff -u bugtracker/includes/cache/php_version.php:1.6 bugtracker/includes/cache/php_version.php:1.7 --- bugtracker/includes/cache/php_version.php:1.6 Thu Jul 17 09:48:05 2008 +++ bugtracker/includes/cache/php_version.php Thu Jul 31 12:34:21 2008 @@ -1,17 +1,23 @@ <?php $php_version[1] = "5.2.6"; + $cacher['php_version'][1] = "5.2.6"; $php_version[2] = "4.4.8"; + $cacher['php_version'][2] = "4.4.8"; $php_version[3] = "4CVS-2008-06-27 (snap)"; + $cacher['php_version'][3] = "4CVS-2008-06-27 (snap)"; $php_version[4] = "4CVS-2008-06-27 (CVS)"; + $cacher['php_version'][4] = "4CVS-2008-06-27 (CVS)"; $php_version[5] = "5.2CVS-2008-06-27 (CVS)"; + $cacher['php_version'][5] = "5.2CVS-2008-06-27 (CVS)"; $php_version[6] = "5.3CVS-2008-06-27 (snap)"; + $cacher['php_version'][6] = "5.3CVS-2008-06-27 (snap)"; $php_version[7] = "6CVS-2008-06-27 (snap)"; + $cacher['php_version'][7] = "6CVS-2008-06-27 (snap)"; $php_version[8] = "6CVS-2008-06-27 (CVS)"; + $cacher['php_version'][8] = "6CVS-2008-06-27 (CVS)"; foreach($php_version as $ref => $data) { define(strtoupper(str_replace(' ','_',$data)),$ref); } - -?> \ No newline at end of file http://cvs.php.net/viewvc.cgi/bugtracker/includes/cache/status.php?r1=1.6&r2=1.7&diff_format=u Index: bugtracker/includes/cache/status.php diff -u bugtracker/includes/cache/status.php:1.6 bugtracker/includes/cache/status.php:1.7 --- bugtracker/includes/cache/status.php:1.6 Thu Jul 17 09:48:05 2008 +++ bugtracker/includes/cache/status.php Thu Jul 31 12:34:21 2008 @@ -1,13 +1,15 @@ <?php $status[0] = "Pending"; + $cacher['status'][0] = "Pending"; $status[1] = "Bogus"; + $cacher['status'][1] = "Bogus"; $status[2] = "Is Bug"; + $cacher['status'][2] = "Is Bug"; $status[3] = "Fixed"; + $cacher['status'][3] = "Fixed"; foreach($status as $ref => $data) { define(strtoupper(str_replace(' ','_',$data)),$ref); } - -?> \ No newline at end of file http://cvs.php.net/viewvc.cgi/bugtracker/template/generic/bug/index.php?r1=1.14&r2=1.15&diff_format=u Index: bugtracker/template/generic/bug/index.php diff -u bugtracker/template/generic/bug/index.php:1.14 bugtracker/template/generic/bug/index.php:1.15 --- bugtracker/template/generic/bug/index.php:1.14 Thu Jul 31 02:38:33 2008 +++ bugtracker/template/generic/bug/index.php Thu Jul 31 12:34:21 2008 @@ -58,7 +58,16 @@ $template_data['page_title'] .= ' - #' . $bug->bug_id . ' ' . $bug_row['summary']; //shunt to dispplay -$display_data['dsp_summary'] = $bug_row['summary']; +$display_data['bug_id'] = $bug_row['bug_id']; +$display_data['summary'] = $bug_row['summary']; +$display_data['status'] = $bug_row['status']; + +$display_data['reported_by'] = $bug_row['reported_by']; +// this is to get switched to a profile pref +// 'd/m/Y H:i O' +$display_data['time']['reported_on'] = $bug_row['UNIX_TIMESTAMP(reported_on)']; +$display_data['time']['updated'] = $bug_row['UNIX_TIMESTAMP(updated)']; + $display_data['dsp_description'] = $bug_row['description']; $content .= '<h2>Bug Display</h2>'; @@ -73,12 +82,12 @@ <table id="bug"> <tr> <td style="width: 100px;"> </td> <td style="width: 80px;"> </td> <td style="width: 180px;"> </td> <td style="width: 150px;"> </td></tr> -<tr> <td>Bug: #' . $bug_row['bug_id'] . '</td> <td colspan="2" style="width: 220px;">{DSP_SUMMARY}</td> <td>Reported By:<br /><strong>' . $bug_row['reported_by'] . '</strong></td> </tr> -<tr> <td><h4>' . $status[$bug_row['status']] . '</h4></td> <td>Opened:</td> <td colspan="2">' . date('d/m/Y H:i O',$bug_row['UNIX_TIMESTAMP(reported_on)']) . '</td> </tr> +<tr> <td>Bug: #{DSP_BUG_ID}</td> <td colspan="2" style="width: 220px;">{DSP_SUMMARY}</td> <td>Reported By:<br /><strong>{DSP_REPORTED_BY}</strong></td> </tr> +<tr> <td><h4>{DSP_STATUS}</h4></td> <td>Opened:</td> <td colspan="2">{DSP_REPORTED_ON}</td> </tr> '; if ($bug_row['UNIX_TIMESTAMP(updated)'] != $bug_row['UNIX_TIMESTAMP(reported_on)']) { - $content .= '<tr> <td></td> <td>Last Updated:</td> <td colspan="2">' . date('d/m/Y H:i O',$bug_row['UNIX_TIMESTAMP(updated)']) . '</td> </tr>'; + $content .= '<tr> <td></td> <td>Last Updated:</td> <td colspan="2">{DSP_UPDATED}</td> </tr>'; } if ($bug_row['assigned_to']) { http://cvs.php.net/viewvc.cgi/bugtracker/includes/cache_generate.php?view=markup&rev=1.1 Index: bugtracker/includes/cache_generate.php +++ bugtracker/includes/cache_generate.php <?php //cache creator //$cache = $_REQUEST['cache']; $cache = 'all'; //$mode = $_REQUEST['mode']; //acceptable modes //check - check cache is up to date, if $cache check that one only //create - create $cache if ($cache == 'user' || $cache == 'all') { $query = 'SELECT * FROM user'; $db->get_data($query); $users = '<?php' . "\n"; while ($row = $db->fetch_row()) { $users .= ' $users["' . $row['handle'] . '"]["handle"] = "' . $row['handle'] . '"; $users["' . $row['handle'] . '"]["email"] = "' . $row['email'] . '"; '; } $query = 'SELECT * FROM temp_account'; $db->get_data($query); while ($row = $db->fetch_row()) { $users .= ' $users["' . $row['handle'] . '"]["handle"] = "' . $row['handle'] . '"; $users["' . $row['handle'] . '"]["email"] = "' . $row['email'] . '"; '; } $users .= "\n"; $timetowrite = fopen($_SERVER['DOCUMENT_ROOT'] . '../includes/cache/users.php',"w+"); fwrite($timetowrite,$users); fclose($timetowrite); } if ($cache == 'types' || $cache == 'all') { //will regenerate all types //bug_status //php_version //bug_type //os_version //comment_type $tocache = array(); $tocache[] = 'status'; $tocache[] = 'bug_type'; $tocache[] = 'php_version'; $tocache[] = 'os_version'; $tocache[] = 'account_type'; $tocache[] = 'comment_type'; foreach($tocache as $ref => $data) { $query = 'SELECT * FROM ' . $data . ' ORDER BY ordering ASC'; $db->get_data($query); $cachetext = '<?php' . "\n"; if ($db->total_rows) { while ($row = $db->fetch_row()) { $cachetext .= ' $' . $data . '[' . $row['ordering'] .'] = "' . $row[1]. '"; $cacher[\'' . $data . '\'][' . $row['ordering'] .'] = "' . $row[1]. '";'; } $cachetext .= ' foreach($' . $data . ' as $ref => $data) { define(strtoupper(str_replace(\' \',\'_\',$data)),$ref); } '; } // // else // { //// $cachetext .= '\?\>'; // } $timetowrite = fopen($_SERVER['DOCUMENT_ROOT'] . '../includes/cache/' . $data . '.php',"w+"); fwrite($timetowrite,$cachetext); fclose($timetowrite); } } http://cvs.php.net/viewvc.cgi/bugtracker/includes/cache/users.php?view=markup&rev=1.1 Index: bugtracker/includes/cache/users.php +++ bugtracker/includes/cache/users.php <?php $users["barrycarlyon"]["handle"] = "barrycarlyon"; $users["barrycarlyon"]["email"] = "barry@barrycarlyon.co.uk"; $users["Tlars_strojny"]["handle"] = "Tlars_strojny"; $users["Tlars_strojny"]["email"] = "lars@strojny.net";
http://cvs.php.net/viewvc.cgi/bugtracker/htdocs/cache.php?r1=1.3&r2=1.4&diff_format=u Index: bugtracker/htdocs/cache.php diff -u bugtracker/htdocs/cache.php:1.3 bugtracker/htdocs/cache.php:1.4 --- bugtracker/htdocs/cache.php:1.3 Fri Jul 11 13:14:18 2008 +++ bugtracker/htdocs/cache.php Thu Jul 31 12:34:20 2008 @@ -19,7 +19,7 @@ $cache = 'all'; -include($_SERVER['DOCUMENT_ROOT'] . '../includes/cache.php'); +include($_SERVER['DOCUMENT_ROOT'] . '../includes/cache_generate.php'); header("Location: /"); http://cvs.php.net/viewvc.cgi/bugtracker/htdocs/index/index.php?r1=1.12&r2=1.13&diff_format=u Index: bugtracker/htdocs/index/index.php diff -u bugtracker/htdocs/index/index.php:1.12 bugtracker/htdocs/index/index.php:1.13 --- bugtracker/htdocs/index/index.php:1.12 Thu Jul 31 02:38:33 2008 +++ bugtracker/htdocs/index/index.php Thu Jul 31 12:34:20 2008 @@ -32,10 +32,15 @@ include($_SERVER['DOCUMENT_ROOT'] . '../includes/email.php'); include($_SERVER['DOCUMENT_ROOT'] . '../includes/bug.php'); include($_SERVER['DOCUMENT_ROOT'] . '../includes/comment.php'); +include($_SERVER['DOCUMENT_ROOT'] . '../includes/cache.php'); $user = new user(); $email = new email(); $bug = new bug(); $comment = new comment(); +$cache = new cache(); + +//cahce! +$cache->load_cache(); //email set up $email_data = array(); @@ -46,6 +51,7 @@ //lets check to see if those templates exist $template = is_dir($_SERVER['DOCUMENT_ROOT'] . '../template/' . $bugtracker) ? $bugtracker : 'php'; +/* //lets generate some useful template varibles //however first lets include the caches include($_SERVER['DOCUMENT_ROOT'] . '../includes/cachelist.php'); @@ -68,6 +74,7 @@ } //hack in a version of php $php_version[0] = 'Irrelevant'; +*/ $form_data = array();//array for holding the data in forms $display_data = array();// array for holding all the display data that users could of entered @@ -84,7 +91,10 @@ ) ); //$template_data['cvs_version'] = substr( $php_version[sizeof($php_version)] ,0,4); -$template_data['cvs_version'] = substr( $php_version[sizeof($php_version)-1] ,0,4); +//$template_data['cvs_version'] = substr( $php_version[sizeof($php_version)-1] ,0,4); +$cache->add_to_cache('php_version', 'Irrelevant', '0'); +$template_data['cvs_version'] = substr( $cache->obtain('php_version',-1), 0, 4 ); + if ($template != 'php') { $template_data['page_title'] .= ' ' . titleit($bugtracker); http://cvs.php.net/viewvc.cgi/bugtracker/includes/cache.php?r1=1.3&r2=1.4&diff_format=u Index: bugtracker/includes/cache.php diff -u bugtracker/includes/cache.php:1.3 bugtracker/includes/cache.php:1.4 --- bugtracker/includes/cache.php:1.3 Thu Jul 10 20:56:41 2008 +++ bugtracker/includes/cache.php Thu Jul 31 12:34:20 2008 @@ -1,90 +1,73 @@ <?php -//cache creator -//$cache = $_REQUEST['cache']; -$cache = 'all'; -//$mode = $_REQUEST['mode']; - -//acceptable modes -//check - check cache is up to date, if $cache check that one only -//create - create $cache - -if ($cache == 'user' || $cache == 'all') -{ - $query = 'SELECT * FROM user'; - $db->get_data($query); +class cache{ - $users = '<?php' . "\n"; - while ($row = $db->fetch_row()) - { - $users .= ' - $users["' . $row['handle'] . '"]["handle"] = "' . $row['handle'] . '"; - $users["' . $row['handle'] . '"]["email"] = "' . $row['email'] . '"; -'; - } - - $query = 'SELECT * FROM temp_account'; - $db->get_data($query); - while ($row = $db->fetch_row()) - { - $users .= ' - $users["' . $row['handle'] . '"]["handle"] = "' . $row['handle'] . '"; - $users["' . $row['handle'] . '"]["email"] = "' . $row['email'] . '"; -'; - } - - $users .= "\n"; +/* +public $status = array(); +public $php_version = array(); +public $bug_type = array(); +public $os_version = array(); +public $comment_type = array(); + +public $account_type = array(); +public $user_data = array(); +*/ - $timetowrite = fopen($_SERVER['DOCUMENT_ROOT'] . '../includes/cache/user.php',"w+"); - fwrite($timetowrite,$users); - fclose($timetowrite); -} -if ($cache == 'types' || $cache == 'all') -{ - //will regenerate all types - //bug_status - //php_version - //bug_type - //os_version - //comment_type - - $tocache = array(); - $tocache[] = 'status'; - $tocache[] = 'bug_type'; - $tocache[] = 'php_version'; - $tocache[] = 'os_version'; - $tocache[] = 'account_type'; - $tocache[] = 'comment_type'; - - foreach($tocache as $ref => $data) - { - $query = 'SELECT * FROM ' . $data . ' ORDER BY ordering ASC'; - $db->get_data($query); - $cachetext = '<?php' . "\n"; - if ($db->total_rows) + function load_cache() { + if ($handle = opendir($_SERVER['DOCUMENT_ROOT'] . '../includes/cache/')) { - while ($row = $db->fetch_row()) + while (FALSE !== ($file = readdir($handle))) { - $cachetext .= ' - $' . $data . '[' . $row['ordering'] .'] = "' . $row[1]. '";'; + if ($file != "." && $file != "..") + { + $ref = explode(".",$file); + if ($ref[1] == 'php') + { + $thiscache = $ref[0]; + $cacher = array(); + + trace('loading cache: ' . $file); + include($_SERVER['DOCUMENT_ROOT'] . '../includes/cache/' . $file); + + $generated_cache = array(); + foreach ($cacher as $ref => $data) + { + // $ref == $file (well $ref[0]) + $generated_cache = $data; + } + $this->$thiscache = $generated_cache; + } + } } - $cachetext .= ' + closedir($handle); + } -foreach($' . $data . ' as $ref => $data) -{ - define(strtoupper(str_replace(\' \',\'_\',$data)),$ref); -} + return; + } -?>'; - } - else + function obtain($thecache, $ref) + { + $thiscache = $this->$thecache; + + if ($ref < 0) { - $cachetext .= '?>'; + //$ref is negative + $ref = sizeof($thiscache) + $ref; } - $timetowrite = fopen($_SERVER['DOCUMENT_ROOT'] . '../includes/cache/' . $data . '.php',"w+"); - fwrite($timetowrite,$cachetext); - fclose($timetowrite); + + return $thiscache[$ref]; } + //add to cache extend replced + function add_to_cache($thecache, $data, $ref = '') + { + $thiscache = $this->$thecache; + + $thiscache[$ref] = $data; + + $this->$thecache = $thiscache; + + return; + } } http://cvs.php.net/viewvc.cgi/bugtracker/includes/functions.php?r1=1.12&r2=1.13&diff_format=u Index: bugtracker/includes/functions.php diff -u bugtracker/includes/functions.php:1.12 bugtracker/includes/functions.php:1.13 --- bugtracker/includes/functions.php:1.12 Thu Jul 31 02:38:33 2008 +++ bugtracker/includes/functions.php Thu Jul 31 12:34:20 2008 @@ -67,8 +67,25 @@ // $html = api_helpers_html::renderTemplate($file,$display_data,'html'); foreach ($display_data as $ref => $replace) { - $display_data[$ref] = htmlentities($display_data[$ref], ENT_QUOTES, 'UTF-8'); - $html = str_replace('{' . strtoupper($ref) . '}',$replace,$html); +trace($$ref); + if (is_array($ref)) + { + $replace = $$ref; + $replace = $replace[$ref]; + } + if ($ref == 'time') + { + // time ref!!! + foreach ($display_data['time'] as $tref => $treplace) + { + $html = str_replace('{DSP_' . strtoupper($tref) . '}', date('d/m/Y H:i O', $treplace), $html); + } + } else { +// this line is utter rubbish +// $display_data[$ref] = htmlentities($display_data[$ref], ENT_QUOTES, 'UTF-8'); + $replace = htmlentities($display_data[$ref], ENT_QUOTES, 'UTF-8'); + $html = str_replace('{DSP_' . strtoupper($ref) . '}',$replace,$html); + } } foreach ($template_data as $ref => $replace) @@ -235,7 +252,6 @@ } function trace($message) { -return; global $trace; $trace .= $message . "\n"; return; http://cvs.php.net/viewvc.cgi/bugtracker/includes/cache/account_type.php?r1=1.4&r2=1.5&diff_format=u Index: bugtracker/includes/cache/account_type.php diff -u bugtracker/includes/cache/account_type.php:1.4 bugtracker/includes/cache/account_type.php:1.5 --- bugtracker/includes/cache/account_type.php:1.4 Fri Jul 11 13:14:18 2008 +++ bugtracker/includes/cache/account_type.php Thu Jul 31 12:34:21 2008 @@ -1,11 +1,11 @@ <?php $account_type[1] = "Temp Account"; + $cacher['account_type'][1] = "Temp Account"; $account_type[2] = "User"; + $cacher['account_type'][2] = "User"; foreach($account_type as $ref => $data) { define(strtoupper(str_replace(' ','_',$data)),$ref); } - -?> \ No newline at end of file http://cvs.php.net/viewvc.cgi/bugtracker/includes/cache/bug_type.php?r1=1.4&r2=1.5&diff_format=u Index: bugtracker/includes/cache/bug_type.php diff -u bugtracker/includes/cache/bug_type.php:1.4 bugtracker/includes/cache/bug_type.php:1.5 --- bugtracker/includes/cache/bug_type.php:1.4 Fri Jul 11 13:14:18 2008 +++ bugtracker/includes/cache/bug_type.php Thu Jul 31 12:34:21 2008 @@ -1,11 +1,11 @@ <?php $bug_type[1] = "Bug System"; + $cacher['bug_type'][1] = "Bug System"; $bug_type[2] = "Doc"; + $cacher['bug_type'][2] = "Doc"; foreach($bug_type as $ref => $data) { define(strtoupper(str_replace(' ','_',$data)),$ref); } - -?> \ No newline at end of file http://cvs.php.net/viewvc.cgi/bugtracker/includes/cache/comment_type.php?r1=1.4&r2=1.5&diff_format=u Index: bugtracker/includes/cache/comment_type.php diff -u bugtracker/includes/cache/comment_type.php:1.4 bugtracker/includes/cache/comment_type.php:1.5 --- bugtracker/includes/cache/comment_type.php:1.4 Fri Jul 11 13:14:18 2008 +++ bugtracker/includes/cache/comment_type.php Thu Jul 31 12:34:21 2008 @@ -1,13 +1,15 @@ <?php $comment_type[1] = "description"; + $cacher['comment_type'][1] = "description"; $comment_type[2] = "reproduce"; + $cacher['comment_type'][2] = "reproduce"; $comment_type[3] = "expected"; + $cacher['comment_type'][3] = "expected"; $comment_type[4] = "actual"; + $cacher['comment_type'][4] = "actual"; foreach($comment_type as $ref => $data) { define(strtoupper(str_replace(' ','_',$data)),$ref); } - -?> \ No newline at end of file http://cvs.php.net/viewvc.cgi/bugtracker/includes/cache/os_version.php?r1=1.4&r2=1.5&diff_format=u Index: bugtracker/includes/cache/os_version.php diff -u bugtracker/includes/cache/os_version.php:1.4 bugtracker/includes/cache/os_version.php:1.5 --- bugtracker/includes/cache/os_version.php:1.4 Fri Jul 11 13:14:18 2008 +++ bugtracker/includes/cache/os_version.php Thu Jul 31 12:34:21 2008 @@ -1,11 +1,11 @@ <?php $os_version[1] = "Linux"; + $cacher['os_version'][1] = "Linux"; $os_version[2] = "W1nd0w5"; + $cacher['os_version'][2] = "W1nd0w5"; foreach($os_version as $ref => $data) { define(strtoupper(str_replace(' ','_',$data)),$ref); } - -?> \ No newline at end of file http://cvs.php.net/viewvc.cgi/bugtracker/includes/cache/php_version.php?r1=1.6&r2=1.7&diff_format=u Index: bugtracker/includes/cache/php_version.php diff -u bugtracker/includes/cache/php_version.php:1.6 bugtracker/includes/cache/php_version.php:1.7 --- bugtracker/includes/cache/php_version.php:1.6 Thu Jul 17 09:48:05 2008 +++ bugtracker/includes/cache/php_version.php Thu Jul 31 12:34:21 2008 @@ -1,17 +1,23 @@ <?php $php_version[1] = "5.2.6"; + $cacher['php_version'][1] = "5.2.6"; $php_version[2] = "4.4.8"; + $cacher['php_version'][2] = "4.4.8"; $php_version[3] = "4CVS-2008-06-27 (snap)"; + $cacher['php_version'][3] = "4CVS-2008-06-27 (snap)"; $php_version[4] = "4CVS-2008-06-27 (CVS)"; + $cacher['php_version'][4] = "4CVS-2008-06-27 (CVS)"; $php_version[5] = "5.2CVS-2008-06-27 (CVS)"; + $cacher['php_version'][5] = "5.2CVS-2008-06-27 (CVS)"; $php_version[6] = "5.3CVS-2008-06-27 (snap)"; + $cacher['php_version'][6] = "5.3CVS-2008-06-27 (snap)"; $php_version[7] = "6CVS-2008-06-27 (snap)"; + $cacher['php_version'][7] = "6CVS-2008-06-27 (snap)"; $php_version[8] = "6CVS-2008-06-27 (CVS)"; + $cacher['php_version'][8] = "6CVS-2008-06-27 (CVS)"; foreach($php_version as $ref => $data) { define(strtoupper(str_replace(' ','_',$data)),$ref); } - -?> \ No newline at end of file http://cvs.php.net/viewvc.cgi/bugtracker/includes/cache/status.php?r1=1.6&r2=1.7&diff_format=u Index: bugtracker/includes/cache/status.php diff -u bugtracker/includes/cache/status.php:1.6 bugtracker/includes/cache/status.php:1.7 --- bugtracker/includes/cache/status.php:1.6 Thu Jul 17 09:48:05 2008 +++ bugtracker/includes/cache/status.php Thu Jul 31 12:34:21 2008 @@ -1,13 +1,15 @@ <?php $status[0] = "Pending"; + $cacher['status'][0] = "Pending"; $status[1] = "Bogus"; + $cacher['status'][1] = "Bogus"; $status[2] = "Is Bug"; + $cacher['status'][2] = "Is Bug"; $status[3] = "Fixed"; + $cacher['status'][3] = "Fixed"; foreach($status as $ref => $data) { define(strtoupper(str_replace(' ','_',$data)),$ref); } - -?> \ No newline at end of file http://cvs.php.net/viewvc.cgi/bugtracker/template/generic/bug/index.php?r1=1.14&r2=1.15&diff_format=u Index: bugtracker/template/generic/bug/index.php diff -u bugtracker/template/generic/bug/index.php:1.14 bugtracker/template/generic/bug/index.php:1.15 --- bugtracker/template/generic/bug/index.php:1.14 Thu Jul 31 02:38:33 2008 +++ bugtracker/template/generic/bug/index.php Thu Jul 31 12:34:21 2008 @@ -58,7 +58,16 @@ $template_data['page_title'] .= ' - #' . $bug->bug_id . ' ' . $bug_row['summary']; //shunt to dispplay -$display_data['dsp_summary'] = $bug_row['summary']; +$display_data['bug_id'] = $bug_row['bug_id']; +$display_data['summary'] = $bug_row['summary']; +$display_data['status'] = $bug_row['status']; + +$display_data['reported_by'] = $bug_row['reported_by']; +// this is to get switched to a profile pref +// 'd/m/Y H:i O' +$display_data['time']['reported_on'] = $bug_row['UNIX_TIMESTAMP(reported_on)']; +$display_data['time']['updated'] = $bug_row['UNIX_TIMESTAMP(updated)']; + $display_data['dsp_description'] = $bug_row['description']; $content .= '<h2>Bug Display</h2>'; @@ -73,12 +82,12 @@ <table id="bug"> <tr> <td style="width: 100px;"> </td> <td style="width: 80px;"> </td> <td style="width: 180px;"> </td> <td style="width: 150px;"> </td></tr> -<tr> <td>Bug: #' . $bug_row['bug_id'] . '</td> <td colspan="2" style="width: 220px;">{DSP_SUMMARY}</td> <td>Reported By:<br /><strong>' . $bug_row['reported_by'] . '</strong></td> </tr> -<tr> <td><h4>' . $status[$bug_row['status']] . '</h4></td> <td>Opened:</td> <td colspan="2">' . date('d/m/Y H:i O',$bug_row['UNIX_TIMESTAMP(reported_on)']) . '</td> </tr> +<tr> <td>Bug: #{DSP_BUG_ID}</td> <td colspan="2" style="width: 220px;">{DSP_SUMMARY}</td> <td>Reported By:<br /><strong>{DSP_REPORTED_BY}</strong></td> </tr> +<tr> <td><h4>{DSP_STATUS}</h4></td> <td>Opened:</td> <td colspan="2">{DSP_REPORTED_ON}</td> </tr> '; if ($bug_row['UNIX_TIMESTAMP(updated)'] != $bug_row['UNIX_TIMESTAMP(reported_on)']) { - $content .= '<tr> <td></td> <td>Last Updated:</td> <td colspan="2">' . date('d/m/Y H:i O',$bug_row['UNIX_TIMESTAMP(updated)']) . '</td> </tr>'; + $content .= '<tr> <td></td> <td>Last Updated:</td> <td colspan="2">{DSP_UPDATED}</td> </tr>'; } if ($bug_row['assigned_to']) { http://cvs.php.net/viewvc.cgi/bugtracker/includes/cache_generate.php?view=markup&rev=1.1 Index: bugtracker/includes/cache_generate.php +++ bugtracker/includes/cache_generate.php <?php //cache creator //$cache = $_REQUEST['cache']; $cache = 'all'; //$mode = $_REQUEST['mode']; //acceptable modes //check - check cache is up to date, if $cache check that one only //create - create $cache if ($cache == 'user' || $cache == 'all') { $query = 'SELECT * FROM user'; $db->get_data($query); $users = '<?php' . "\n"; while ($row = $db->fetch_row()) { $users .= ' $users["' . $row['handle'] . '"]["handle"] = "' . $row['handle'] . '"; $users["' . $row['handle'] . '"]["email"] = "' . $row['email'] . '"; '; } $query = 'SELECT * FROM temp_account'; $db->get_data($query); while ($row = $db->fetch_row()) { $users .= ' $users["' . $row['handle'] . '"]["handle"] = "' . $row['handle'] . '"; $users["' . $row['handle'] . '"]["email"] = "' . $row['email'] . '"; '; } $users .= "\n"; $timetowrite = fopen($_SERVER['DOCUMENT_ROOT'] . '../includes/cache/users.php',"w+"); fwrite($timetowrite,$users); fclose($timetowrite); } if ($cache == 'types' || $cache == 'all') { //will regenerate all types //bug_status //php_version //bug_type //os_version //comment_type $tocache = array(); $tocache[] = 'status'; $tocache[] = 'bug_type'; $tocache[] = 'php_version'; $tocache[] = 'os_version'; $tocache[] = 'account_type'; $tocache[] = 'comment_type'; foreach($tocache as $ref => $data) { $query = 'SELECT * FROM ' . $data . ' ORDER BY ordering ASC'; $db->get_data($query); $cachetext = '<?php' . "\n"; if ($db->total_rows) { while ($row = $db->fetch_row()) { $cachetext .= ' $' . $data . '[' . $row['ordering'] .'] = "' . $row[1]. '"; $cacher[\'' . $data . '\'][' . $row['ordering'] .'] = "' . $row[1]. '";'; } $cachetext .= ' foreach($' . $data . ' as $ref => $data) { define(strtoupper(str_replace(\' \',\'_\',$data)),$ref); } '; } // // else // { //// $cachetext .= '\?\>'; // } $timetowrite = fopen($_SERVER['DOCUMENT_ROOT'] . '../includes/cache/' . $data . '.php',"w+"); fwrite($timetowrite,$cachetext); fclose($timetowrite); } } http://cvs.php.net/viewvc.cgi/bugtracker/includes/cache/users.php?view=markup&rev=1.1 Index: bugtracker/includes/cache/users.php +++ bugtracker/includes/cache/users.php <?php $users["barrycarlyon"]["handle"] = "barrycarlyon"; $users["barrycarlyon"]["email"] = "barry@barrycarlyon.co.uk"; $users["Tlars_strojny"]["handle"] = "Tlars_strojny"; $users["Tlars_strojny"]["email"] = "lars@strojny.net";