cvs: bugtracker /htdocs/elements/js admin.js /includes cache_generate.php functions.php /template/generic/admin index.php purge.php
/template/generic/admin/cache alter.php index.php purge.php

From: Date: Thu, 14 Aug 2008 12:27:25 +0000
Subject: cvs: bugtracker /htdocs/elements/js admin.js /includes cache_generate.php functions.php /template/generic/admin index.php purge.php
/template/generic/admin/cache alter.php index.php purge.php
Groups: php.webmaster 
Request: Send a blank email to php-webmaster+get-2426@lists.php.net to get a copy of this message
bcarlyon Thu Aug 14 12:27:25 2008 UTC Added files: /bugtracker/template/generic/admin/cache alter.php Removed files: /bugtracker/template/generic/admin purge.php Modified files: /bugtracker/htdocs/elements/js admin.js /bugtracker/includes cache_generate.php functions.php /bugtracker/template/generic/admin index.php /bugtracker/template/generic/admin/cache index.php purge.php Log: Added the ability for admins to alter the contents of caches database tables Which then push to the file cache

http://cvs.php.net/viewvc.cgi/bugtracker/htdocs/elements/js/admin.js?r1=1.2&r2=1.3&diff_format=u Index: bugtracker/htdocs/elements/js/admin.js diff -u bugtracker/htdocs/elements/js/admin.js:1.2 bugtracker/htdocs/elements/js/admin.js:1.3 --- bugtracker/htdocs/elements/js/admin.js:1.2 Thu Aug 14 01:06:01 2008 +++ bugtracker/htdocs/elements/js/admin.js Thu Aug 14 12:27:25 2008 @@ -9,3 +9,8 @@ var newstate = document.getElementById('newstate').value; window.location = '/admin/state/' + document.getElementById('bug_id').value + '/' + newstate; } + +function selectCache() { + var selected = document.getElementById('cache_to_edit').value; + window.location = '/admin/cache/alter/' + selected; +} http://cvs.php.net/viewvc.cgi/bugtracker/includes/cache_generate.php?r1=1.13&r2=1.14&diff_format=u Index: bugtracker/includes/cache_generate.php diff -u bugtracker/includes/cache_generate.php:1.13 bugtracker/includes/cache_generate.php:1.14 --- bugtracker/includes/cache_generate.php:1.13 Thu Aug 14 11:27:23 2008 +++ bugtracker/includes/cache_generate.php Thu Aug 14 12:27:25 2008 @@ -37,14 +37,10 @@ * @author Barry Carlyon <bcarlyon@php.net> * @copyright 2008-2008 Barry Carlyon * @license http://www.opensource.org/licenses/bsd-license.php BSD License -* @version CVS: $Id: cache_generate.php,v 1.13 2008/08/14 11:27:23 bcarlyon Exp $ +* @version CVS: $Id: cache_generate.php,v 1.14 2008/08/14 12:27:25 bcarlyon Exp $ * @link http://gsoc.barrycarlyon.servegame.org/ */ -//$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 @@ -84,22 +80,15 @@ fwrite($timetowrite,$users); fclose($timetowrite); } -if ($cache == 'types' || $cache == 'all') +if ($cache == 'types' || $cache == 'all' || in_array($cache, $tocache)) { + if (in_array($cache, $tocache)) { + //single cache only + unset($tocache); + $tocache = array($cache); + } + //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) { @@ -123,12 +112,6 @@ '; } -// -// else -// { -//// $cachetext .= '\?\>'; -// } - if (is_file($_SERVER['DOCUMENT_ROOT'] . '../includes/cache/' . $data . '.php')) { unlink($_SERVER['DOCUMENT_ROOT'] . '../includes/cache/' . $data . '.php'); } http://cvs.php.net/viewvc.cgi/bugtracker/includes/functions.php?r1=1.28&r2=1.29&diff_format=u Index: bugtracker/includes/functions.php diff -u bugtracker/includes/functions.php:1.28 bugtracker/includes/functions.php:1.29 --- bugtracker/includes/functions.php:1.28 Wed Aug 13 22:33:33 2008 +++ bugtracker/includes/functions.php Thu Aug 14 12:27:25 2008 @@ -37,7 +37,7 @@ * @author Barry Carlyon <bcarlyon@php.net> * @copyright 2008-2008 Barry Carlyon * @license http://www.opensource.org/licenses/bsd-license.php BSD License -* @version CVS: $Id: functions.php,v 1.28 2008/08/13 22:33:33 bcarlyon Exp $ +* @version CVS: $Id: functions.php,v 1.29 2008/08/14 12:27:25 bcarlyon Exp $ * @link http://gsoc.barrycarlyon.servegame.org/ */ @@ -227,6 +227,10 @@ break; case E_WARNING: $fail = "<b>Warning:</b> $errstr - $errfile, $errline<br />\n"; + global $db; + if ($db->query) { + $fail .= 'Last Query:<br />' . $db->query . '<br />' . "\n"; + } $backtrace .= '<strong>' . $fail . '</strong>'; $backtrace .= 'Ref:<br /><table>'; foreach ($context as $ref => $data) http://cvs.php.net/viewvc.cgi/bugtracker/template/generic/admin/index.php?r1=1.8&r2=1.9&diff_format=u Index: bugtracker/template/generic/admin/index.php diff -u bugtracker/template/generic/admin/index.php:1.8 bugtracker/template/generic/admin/index.php:1.9 --- bugtracker/template/generic/admin/index.php:1.8 Thu Aug 14 11:27:23 2008 +++ bugtracker/template/generic/admin/index.php Thu Aug 14 12:27:25 2008 @@ -37,7 +37,7 @@ * @author Barry Carlyon <bcarlyon@php.net> * @copyright 2008-2008 Barry Carlyon * @license http://www.opensource.org/licenses/bsd-license.php BSD License -* @version CVS: $Id: index.php,v 1.8 2008/08/14 11:27:23 bcarlyon Exp $ +* @version CVS: $Id: index.php,v 1.9 2008/08/14 12:27:25 bcarlyon Exp $ * @link http://gsoc.barrycarlyon.servegame.org/ */ @@ -53,7 +53,7 @@ $content .= '<ul> <li>Update Karma</li> <li>Edit User</li> -<li>Change Cache</li> +<li><a href="/admin/cache/alter/" title="Change">Change Cache</a></li> <li><a href="/admin/cache/purge/" title="Purge">Purge and Regenerate the Cache</a></li> </ul>'; http://cvs.php.net/viewvc.cgi/bugtracker/template/generic/admin/cache/index.php?r1=1.1&r2=1.2&diff_format=u Index: bugtracker/template/generic/admin/cache/index.php diff -u bugtracker/template/generic/admin/cache/index.php:1.1 bugtracker/template/generic/admin/cache/index.php:1.2 --- bugtracker/template/generic/admin/cache/index.php:1.1 Thu Aug 14 11:27:23 2008 +++ bugtracker/template/generic/admin/cache/index.php Thu Aug 14 12:27:25 2008 @@ -37,10 +37,18 @@ * @author Barry Carlyon <bcarlyon@php.net> * @copyright 2008-2008 Barry Carlyon * @license http://www.opensource.org/licenses/bsd-license.php BSD License -* @version CVS: $Id: index.php,v 1.1 2008/08/14 11:27:23 bcarlyon Exp $ +* @version CVS: $Id: index.php,v 1.2 2008/08/14 12:27:25 bcarlyon Exp $ * @link http://gsoc.barrycarlyon.servegame.org/ */ +$tocache = array(); +$tocache[] = 'status'; +$tocache[] = 'bug_type'; +$tocache[] = 'php_version'; +$tocache[] = 'os_version'; +$tocache[] = 'account_type'; +$tocache[] = 'comment_type'; + $method = loadvar('method'); $method = str_replace('/','',$method); if (empty($method)) { http://cvs.php.net/viewvc.cgi/bugtracker/template/generic/admin/cache/purge.php?r1=1.1&r2=1.2&diff_format=u Index: bugtracker/template/generic/admin/cache/purge.php diff -u bugtracker/template/generic/admin/cache/purge.php:1.1 bugtracker/template/generic/admin/cache/purge.php:1.2 --- bugtracker/template/generic/admin/cache/purge.php:1.1 Thu Aug 14 11:27:23 2008 +++ bugtracker/template/generic/admin/cache/purge.php Thu Aug 14 12:27:25 2008 @@ -3,7 +3,7 @@ /* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4:*/ /** -* template/generic/admin/purgephp +* template/generic/admin/cache/purge.php * Regenerate the cache * * Copyright (c) 2008, Barry Carlyon <bcarlyon@php.net> @@ -37,7 +37,7 @@ * @author Barry Carlyon <bcarlyon@php.net> * @copyright 2008-2008 Barry Carlyon * @license http://www.opensource.org/licenses/bsd-license.php BSD License -* @version CVS: $Id: purge.php,v 1.1 2008/08/14 11:27:23 bcarlyon Exp $ +* @version CVS: $Id: purge.php,v 1.2 2008/08/14 12:27:25 bcarlyon Exp $ * @link http://gsoc.barrycarlyon.servegame.org/ */ http://cvs.php.net/viewvc.cgi/bugtracker/template/generic/admin/cache/alter.php?view=markup&rev=1.1 Index: bugtracker/template/generic/admin/cache/alter.php +++ bugtracker/template/generic/admin/cache/alter.php <?php /* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4:*/ /** * template/generic/admin/alter.php * Regenerate the cache * * Copyright (c) 2008, Barry Carlyon <bcarlyon@php.net> * All rights reserved. * * PHP versions 5 * * LICENSE: Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * 3. The name of the author may not be used to endorse or promote products * derived from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE AUTHOR "AS IS" AND ANY EXPRESS OR IMPLIED * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. * IN NO EVENT SHALL THE FREEBSD PROJECT OR CONTRIBUTORS BE LIABLE FOR ANY * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * * @category BugTracking * @package GSoC Bugtracker * @author Barry Carlyon <bcarlyon@php.net> * @copyright 2008-2008 Barry Carlyon * @license http://www.opensource.org/licenses/bsd-license.php BSD License * @version CVS: $Id: alter.php,v 1.1 2008/08/14 12:27:25 bcarlyon Exp $ * @link http://gsoc.barrycarlyon.servegame.org/ */ $template->page_title .= 'Altering the Cache'; $template->content_title = 'Altering the Cache'; $resource = loadvar('resource'); $resource = str_replace('/','',$resource); $content = ''; if ($resource) { $basequery = 'SELECT * FROM ' . $resource . ' ORDER BY ordering ASC'; $updates = array(); //check for updates if (loadvar('submitted')) { //form has been submitted lets push the new data to the database // once pushed we need to know if anything has changed //if anything has changed we will need to recache :-) $result = $db->get_data($basequery); if ($db->total_rows) { while ($row = $db->fetch_row($result)) { //to delete? if (loadvar('delete_' . $row[$resource . '_id'])) { $query = 'DELETE FROM ' . $resource . ' WHERE ' . $resource . '_id = ' . $row[$resource . '_id']; $db->get_data($query); } else { //data to update? $query = 'UPDATE ' . $resource . ' SET ' . $resource . '_text = \'' . $db->protect_data(loadvar('edit_' . $row[$resource . '_id'] . '_text')) . '\', ordering = \'' . $db->protect_data(loadvar('edit_' . $row[$resource . '_id'] . '_ordering')) . '\' WHERE ' . $resource . '_id = ' . $row[$resource . '_id']; $db->get_data($query); if ($db->affected_rows) { $updates[$row[$resource . '_id']] = 'TRUE'; } } } } $new_text = loadvar('new_text'); $new_ordering = loadvar('new_ordering'); if (!empty($new_text)) { $query = 'INSERT INTO ' . $resource . '(' . $resource . '_text, ordering) VALUES (\'' . $db->protect_data($new_text) . '\',\'' . $db->protect_data($new_ordering) . '\')'; $db->get_data($query); } if (sizeof($updates) || !empty($db->insert_id)) { //update cache! $cache = $resource; $content .= '<div id="success">Calling Update of ' . $resource . ' Cache</div><br />'; include('cache_generate.php'); } } $db->get_data($basequery); if ($db->total_rows) { $content .= 'You seleceted the ' . $resource . ' cache/table<br /><br />'; $content .= '<form action="/admin/cache/alter/' . $resource . '/" method="post">'; $content .= '<input type="hidden" name="submitted" value="true" />'; $content .= '<table>'; while ($row = $db->fetch_row()) { $content .= '<tr>'; $content .= '<td>' . $row[$resource . '_id'] . '</td>'; $content .= '<td><input type="text" name="edit_' . $row[$resource . '_id'] . '_text" value="' . $row[$resource . '_text'] . '" /></td>'; $content .= '<td><input type="text" name="edit_' . $row[$resource . '_id'] . '_ordering" value="' . $row['ordering'] . '" /></td>'; $content .= '<td><label for="delete_' . $row[$resource . '_id'] . '">Delete:&nbsp;&nbsp;</label> <input type="checkbox" name="delete_' . $row[$resource . '_id'] . '" id="delete_' . $row[$resource . '_id'] . '" /></td>'; $content .= '<td>'; if (isset($updates[$row[$resource . '_id']])) $content .= 'Updated'; $content .= '</td></tr>'; } $content .= '<tr><td>New</td><td><input type="text" name="new_text" id="new_text" value="" /></td><td><input type="text" name="new_ordering" id="new_ordering" value="'; $content .= $db->total_rows + 1; $content .= '" /></td><td><input type="submit" value="Update All" /></td></tr>'; $content .= '</table>'; $content .= '</form>'; } } $content .= 'Which cache would you like to edit?<br /><br />'; $content .= '<select name="cache_to_edit" id="cache_to_edit"><option value="">--Select--</option>'; foreach ($tocache as $ref => $data) { $content .= '<option '; if ($data == $resource) $content .= 'selected="selected"'; $content .= '>' . $data . '</option>' . "\n"; } $content .= '</select>'; $content .= '<input type="button" name="go" value="Go" onclick="selectCache();" />'; $template->prehtml = $content;
« previous php.webmaster (#2426) next »