Location: PHPKode > projects > Esvon Personals > esvon-personals/upgrades/v3_to_v4/upgrade317-400.php
<?php

// File to upgrade Esvon Classifieds from 3.0.797 to 4.0
// 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';
}

if(!file_exists(SITE_PATH.'upgrades/v3_to_v4/upgrade316-317.php')) die("File Not Found: upgrades/v3_to_v4/upgrade316-317.php");
require_once SITE_PATH.'upgrades/v3_to_v4/upgrade316-317.php';

mysql_query("ALTER TABLE ".TBL_USER." ADD lastlogin_failure datetime NOT NULL");
mysql_query("INSERT INTO ".TBL_RESERV_FLD." VALUES ('lastlogin_failure', 'U')");

mysql_query("ALTER TABLE ".TBL_USER." ADD lastlogin_token varchar(32) NOT NULL");
mysql_query("INSERT INTO ".TBL_RESERV_FLD." VALUES ('lastlogin_token', 'U')");

mysql_query("ALTER TABLE ".TBL_SETTINGS." ADD lastlogin_failure datetime NOT NULL");
mysql_query("ALTER TABLE ".TBL_SETTINGS." ADD lastlogin_date datetime NOT NULL");
mysql_query("ALTER TABLE ".TBL_SETTINGS." ADD lastlogin_token varchar(32) NOT NULL");

if(hwModGetState('Editors')){
  mysql_query("ALTER TABLE ".hwModTable('Editors','user')." ADD lastlogin_failure datetime NOT NULL");
  mysql_query("ALTER TABLE ".hwModTable('Editors','user')." ADD lastlogin_token varchar(32) NOT NULL");
}

if(hwModGetState('Affiliates')){
  mysql_query("ALTER TABLE ".hwModTable('Affiliates','user')." ADD lastlogin_failure datetime NOT NULL");
  mysql_query("ALTER TABLE ".hwModTable('Affiliates','user')." ADD lastlogin_token varchar(32) NOT NULL");
  mysql_query("ALTER TABLE ".hwModTable('Affiliates','user')." ADD urls varchar(255) NOT NULL");
}

if(hwModGetState('Multi_Lang')){
  mysql_query("ALTER TABLE ".hwModTable('Multi_Lang','category')." ADD meta_k text NOT NULL");
  mysql_query("ALTER TABLE ".hwModTable('Multi_Lang','category')." ADD meta_d text NOT NULL");
  mysql_query("ALTER TABLE ".hwModTable('Multi_Lang','language')." ADD meta_k text NOT NULL");
  mysql_query("ALTER TABLE ".hwModTable('Multi_Lang','language')." ADD meta_d text NOT NULL");
}

if(hwModGetState('Shopping_Cart')){
  
  $tbl = hwModTable('Shopping_Cart','transaction');
  
  mysql_query("ALTER TABLE $tbl ADD bname varchar(255) NOT NULL");
  mysql_query("ALTER TABLE $tbl ADD baddress_line1 varchar(255) NOT NULL");
  mysql_query("ALTER TABLE $tbl ADD baddress_line2 varchar(255) NOT NULL");
  mysql_query("ALTER TABLE $tbl ADD bcity varchar(255) NOT NULL");
  mysql_query("ALTER TABLE $tbl ADD bstate varchar(255) NOT NULL");
  mysql_query("ALTER TABLE $tbl ADD bzip varchar(30) NOT NULL");
  mysql_query("ALTER TABLE $tbl ADD bcountry varchar(255) NOT NULL");

  mysql_query("ALTER TABLE $tbl MODIFY sname varchar(255) NOT NULL");
  mysql_query("ALTER TABLE $tbl MODIFY saddress_line1 varchar(255) NOT NULL");
  mysql_query("ALTER TABLE $tbl MODIFY saddress_line2 varchar(255) NOT NULL");
  mysql_query("ALTER TABLE $tbl MODIFY scity varchar(255) NOT NULL");
  mysql_query("ALTER TABLE $tbl MODIFY sstate varchar(255) NOT NULL");
  mysql_query("ALTER TABLE $tbl MODIFY scountry varchar(255) NOT NULL");

  mysql_query("ALTER TABLE ".TBL_AD." ADD hw_shipping_type CHAR(1) NOT NULL");

}

mysql_query("ALTER TABLE ".TBL_FIELD." MODIFY value text NOT NULL"); 

if(hwModGetState('Auto_Rebilling')){
  mysql_query("ALTER TABLE ".TBL_USER." ADD hw_rb_cc_cvv2 varchar(255) NOT NULL");
}

if(hwModGetState('Cron_General')){

  mysql_query("CREATE TABLE ".hwModTable('Cron_General','log')." (
   id int unsigned NOT NULL auto_increment,
   entry varchar(255) NOT NULL,
   added DATETIME NOT NULL,
   KEY (added),
   PRIMARY KEY (id))");
  
}

mysql_query("ALTER TABLE ".TBL_SESSION." ADD userid mediumint(8) unsigned NOT NULL");
mysql_query("ALTER TABLE ".TBL_SESSION." ADD x_forw varchar(255) NOT NULL");

if(hwModGetState('Stock_Photo_Gallery')){
  mysql_query("ALTER TABLE ".hwModTable('Stock_Photo_Gallery','category')." CHANGE image images text NOT NULL");
}

if(hwModGetState('Private_Messages')){
  $tbl = hwModTable('Private_Messages','data');
  mysql_query("UPDATE ".$tbl.' SET msg=TRIM(REPLACE(msg,"<br>","\n"))');
  mysql_query("ALTER TABLE $tbl ADD approved char(1) NOT NULL");
  mysql_query("ALTER TABLE $tbl ADD ip varchar(255) NOT NULL");
  mysql_query("ALTER TABLE $tbl ADD attach varchar(255) NOT NULL");
  mysql_query("ALTER TABLE $tbl ADD msg_alt text NOT NULL");
  mysql_query("ALTER TABLE $tbl ADD KEY approved (approved)");

  mysql_query("ALTER TABLE ".TBL_USER." ADD hw_priv_msg_notify char(1) NOT NULL");
  mysql_query("ALTER TABLE ".TBL_USER." ADD hw_priv_msg_reply char(1) NOT NULL");
  mysql_query("ALTER TABLE ".TBL_USER." ADD hw_priv_msg_boxsize mediumint(8) unsigned NOT NULL");
}

if(hwModGetState('Reviews')){
  mysql_query("UPDATE ".hwModTable('Reviews','data').' SET review=TRIM(REPLACE(review,"<br>","\n"))');
}

function _TemplatesDBLoad(){
global $db;
  include SITE_PATH.'inc/class.perms.php';
  $o_hp = new HawkPerms;
  $o_hp->DIR = SITE_PATH;
  $o_hp->LoadLocalPerms();
  foreach(array_keys($o_hp->A_LOCAL) as $f){
    if(substr($f,-1)=='/' || !is_file(SITE_PATH.$f)) continue;
    $a_f = explode('/', str_replace('tpl/','',$f) );
    $mod = $fset = '';
    if($a_f[0] == 'modules'){ $fname = $a_f[2]; $mod = $a_f[1]; }
    elseif($a_f[0] == FS_DIR){ $fname = $a_f[2]; $fset = $a_f[1]; }
    else $fname = $a_f[0];
    $db->query('INSERT INTO '.TBL_TPL.' (fname,`mod`,fset,data) VALUES (?,?,?,?)',
      array( $fname, $mod, $fset, file_get_contents(SITE_PATH.$f) ) );
  }
}

mysql_query("CREATE TABLE ".TBL_TPL." (
   id smallint(5) unsigned NOT NULL auto_increment,
   fname varchar(40) NOT NULL,
   `mod` varchar(64) NOT NULL,
   `fset` varchar(40) NOT NULL,
   `data` text NOT NULL,
   PRIMARY KEY (id),
   UNIQUE (`fname`,`mod`,`fset`))");

$cnt = $db->one_data('SELECT count(*) FROM '.TBL_TPL.' WHERE fname="media_files.htm" AND `mod`="" AND fset=""');
if($cnt==0){
  $db->query('TRUNCATE '.TBL_TPL);
  _TemplatesDBLoad();
}

if(hwModGetState('Regions')){
  mysql_query("ALTER TABLE ".hwModTable('Regions','category')." ADD weight smallint(5) unsigned NOT NULL");
  mysql_query("ALTER TABLE ".hwModTable('Regions','category')." ADD KEY weight (weight)");
}

echo 'Esvon Classifieds Tables Updated, Ok.. ('.basename(__FILE__).')';


?>
Return current item: Esvon Personals