<?php
// File to upgrade Esvon Classifieds from 3.0.777 to 3.0.786
// After use this, you can delete it
//*********************************************
define('DB_UPGRADE', 1);
if(!defined('SITE_PATH')){
if(!file_exists('./inc/application.php')) die("File Not Found: application.php");
require_once './inc/application.php';
}
// lowercase all module tables
$dir = './modules/';
$a_f = array();
$handle = opendir($dir);
while($f = readdir($handle)){
if($f[0]=='.') continue;
if(is_dir($dir.$f)) $a_f[$f] = strtolower($f);
}
closedir($handle);
$a_tables = array();
$res = $db->query('SHOW tables');
while(list($tbl) = mysql_fetch_row($res)) $a_tables[] = $tbl;
foreach($a_tables as $tbl){
foreach($a_f as $mod=>$mod_lc){
if(preg_match("/^".TBL_PREFIX."$mod/",$tbl)){
$tbl_new = str_replace($mod,$mod_lc,$tbl);
$ql = "ALTER TABLE `$tbl` RENAME `$tbl_new`";
// echo $ql.'<br>';
$db->query($ql);
}
}
}
if(hwModGetState('Coupons')){
mysql_query("ALTER TABLE ".hwModTable('Coupons','data').
" ADD utrack char(1) NOT NULL,".
" ADD price_plans text NOT NULL");
mysql_query("CREATE TABLE ".hwModTable('Coupons','track')."(
id int(11) unsigned NOT NULL auto_increment,
cp_id int(11) unsigned NOT NULL,
userid int(11) unsigned NOT NULL,
cdate DATETIME NOT NULL,
PRIMARY KEY (id))");
}
mysql_query("ALTER TABLE ".TBL_MODULES." ADD block_capable tinyint(1) DEFAULT '0' NOT NULL");
mysql_query("ALTER TABLE ".TBL_MODULES." ADD updated timestamp(14)");
mysql_query("UPDATE ".TBL_MODULES." SET block_capable=1 where dir IN ('Regions','Banner_Ads')");
echo 'Esvon Classifieds Tables Updated, Ok.. ('.basename(__FILE__).')';
?>