// constantsif(!defined('UPDATE_LABEL'))define('UPDATE_LABEL','Update');if(!defined('NO_ADMIN_MESSAGE'))define('NO_ADMIN_MESSAGE','<p>Only administrators are allowed to use this function.</p>');if(!defined('PAGE_LOAD_ERROR_MESSAGE'))define('PAGE_LOAD_ERROR_MESSAGE',"<p>An error occured while loading Wikka's pages.</p>");if(!defined('UPDATE_ACTION_TEXT'))define('UPDATE_ACTION_TEXT','<p>Update the old category system using <strong>Category</strong>Name to the new category system using [[(cat)Name]].</p>'.'<p>This action uses some constants to determine what to replace. So it might easily be adapted to other uses.</p>'.'<p><strong>Warning</strong>: This action touches <strong>any</strong> page that contains categories in the '.'original Wikka way of categorizing. It might create heavy server load. It might even happen, that the script '.'times out -- as far as I know, this might be safe. But: Whenever manipulating the database it\'s a good idea to '.'make a backup of it before doing anything.</p>');if(!defined('OLD_CATEGORY_PATTERN'))define('OLD_CATEGORY_PATTERN','%s');if(!defined('NEW_CATEGORY_REPLACE_PATTERN'))define('NEW_CATEGORY_REPLACE_PATTERN','[[(cat)%s]]');if(!defined('NEW_CATEGORY_SEARCH_PATTERN'))define('NEW_CATEGORY_SEARCH_PATTERN','\[\[\(cat\)%s\]\]');if(!defined('CATEGORY_UPDATE_NOTE'))define('CATEGORY_UPDATE_NOTE','category update');

if(isset($_POST['submit'])&&$_POST['submit']== UPDATE_LABEL){if($this->isAdmin())// begin, check for access to all our pages{if($pages=$this->LoadAllPages())// load all pages{// get all categories and make one big regular expression out of them$categories=$this->LoadAll("select tag from ".$this->config["table_prefix"]."pages where latest='Y' AND body LIKE '".mysql_real_escape_string('%{{category%')."' order by time desc");foreach($categoriesas$category){$cat_array[]=$category['tag'];}$cat_regex='('.implode('|',$cat_array).')';