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

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

mysql_query("ALTER TABLE ".TBL_IP." CHANGE ip ip int(11) unsigned NOT NULL");

mysql_query("CREATE TABLE ".TBL_USER_ON." (
   id mediumint(8) unsigned NOT NULL auto_increment,
   accessdate datetime NOT NULL,
   last_pg varchar(255) NOT NULL,
   PRIMARY KEY (id)
)");

mysql_query("ALTER TABLE ".TBL_USER." DROP last_pg");
mysql_query("ALTER TABLE ".TBL_USER." DROP accessdate");

mysql_query("DELETE FROM ".TBL_FIELD." WHERE fset='{user_fields}' AND id='last_pg'");

mysql_query("ALTER TABLE ".TBL_SESSION." DROP INDEX expires");

mysql_query("ALTER TABLE ".TBL_AD." ADD v_descr text NOT NULL");

mysql_query("ALTER TABLE ".TBL_AD." ADD search_txt text NOT NULL");
mysql_query("INSERT INTO ".TBL_RESERV_FLD." VALUES ('search_txt', 'A')");

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

mysql_query("ALTER TABLE ".TBL_AD." ADD FULLTEXT search_txt (v_title,v_descr,search_txt)");
mysql_query("ALTER TABLE ".TBL_USER." ADD FULLTEXT search_txt (search_txt)");

mysql_query("ALTER TABLE ".TBL_CAT." ADD KEY pid (pid)");
mysql_query("ALTER TABLE ".TBL_CAT." ADD KEY fset (fset)");

mysql_query("ALTER TABLE ".TBL_SESSION." ADD ip char(15) NOT NULL");
mysql_query("ALTER TABLE ".TBL_PREFIX."banned_ip RENAME ".TBL_IP);

if(hwModGetState('Private_Messages')){
  mysql_query("ALTER TABLE ".hwModTable('Private_Messages','data')." ADD approved char(1) NOT NULL");
}

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)");
  mysql_query("ALTER TABLE ".TBL_USER." ADD hw_region_id smallint(5) unsigned NOT NULL");
}

if(hwModGetState('Multi_Lang')){

  mysql_query("ALTER TABLE ".TBL_USER." ADD hw_lang_id varchar(10) NOT NULL");

  mysql_query("CREATE TABLE ".hwModTable('Multi_Lang','extra_page')." (
    id varchar(60) NOT NULL default '',
    lang_id varchar(10) NOT NULL default '',
    ptitle varchar(255) default NULL,
    content text NOT NULL,
    PRIMARY KEY (id,lang_id)
  )");

  mysql_query("CREATE TABLE ".hwModTable('Multi_Lang','region')." (
  id smallint(5) unsigned NOT NULL,
  lang_id varchar(10) NOT NULL,
  name varchar(100) NOT NULL,
  PRIMARY KEY (id,lang_id)
  )");

}

if(hwModGetState('Cron_General')){

  mysql_query("CREATE TABLE ".hwModTable('Cron_General','remind')." (
   id mediumint(8) unsigned NOT NULL auto_increment,
   type char(5) NOT NULL,
   plan varchar(10) NOT NULL,
   days smallint(5) unsigned NOT NULL,
   mail_subj varchar(255) NOT NULL,
   mail_body text,
   enabled tinyint(3) unsigned NOT NULL,
   PRIMARY KEY (id))");

  mysql_query("ALTER TABLE ".hwModTable('Cron_General','remind')." CHANGE type type char(5) NOT NULL");

  mysql_query("CREATE TABLE ".hwModTable('Cron_General','extra_remind')." (
   id int unsigned NOT NULL auto_increment,
   ad_id mediumint(8) unsigned NOT NULL,
   opt_id varchar(10) NOT NULL,
   opt_val varchar(10) NOT NULL,
   exp_date DATETIME NOT NULL,
   hw_remind smallint(5) DEFAULT '-1' NOT NULL,
   UNIQUE (ad_id,opt_id),
   PRIMARY KEY (id)
  )");

  mysql_query("ALTER TABLE ".TBL_AD." CHANGE hw_remind hw_remind SMALLINT(5) NOT NULL DEFAULT '-1'");
  mysql_query("ALTER TABLE ".TBL_USER." CHANGE hw_remind hw_remind SMALLINT(5) NOT NULL DEFAULT '-1'");

  mysql_query("UPDATE ".TBL_AD." SET hw_remind=-1 WHERE hw_remind=0");
  mysql_query("UPDATE ".TBL_USER." SET hw_remind=-1 WHERE hw_remind=0");
  
  $ex_inserted = $db->one_data('SELECT COUNT(*) FROM '.hwModTable('Cron_General','remind').' WHERE type="EXTRA"');
  if(!$ex_inserted) mysql_query("INSERT INTO ".hwModTable('Cron_General','remind')." VALUES 
(NULL, 'EXTRA', '', 14, 'Listing Extra Option Expiration Warning (14 days left)', 'Dear Member!\n\nWe''d like to remind you that your listing extra option (##extra_opt_descr## - ##extra_opt_val##) will expire in ##hw_days_rem## days.\n\n--- Listing details ---\n\nURL : ##SITE_URL####ad_url##\nID : ##link_id##\nCategory : ##cname##\n##email_rows##\n\n\nRegards,\n\n##COMPANY##\n##SITE_URL##', 1),
(NULL, 'EXTRA', '', 7, 'Listing Extra Option Expiration Warning (7 days left)', 'Dear Member!\n\nWe''d like to remind you that your listing extra option (##extra_opt_descr## - ##extra_opt_val##) will expire in ##hw_days_rem## days.\n\n--- Listing details ---\n\nURL : ##SITE_URL####ad_url##\nID : ##link_id##\nCategory : ##cname##\n##email_rows##\n\n\nRegards,\n\n##COMPANY##\n##SITE_URL##', 1),
(NULL, 'EXTRA', '', 0, 'Listing Extra Option Expired', 'Dear Member!\n\nYour listing extra option (##extra_opt_descr## - ##extra_opt_val##) has expired.\n\nTo renew please use the following url :\n##SITE_URL##index.php?page=order&id=##link_id##&cid=##catid##\n\n--- Listing details ---\n\nURL : ##SITE_URL####ad_url##\nID : ##link_id##\nCategory : ##cname##\n##email_rows##\n\n\nRegards,\n\n##COMPANY##\n##SITE_URL##', 1)");

}

if(hwModGetState('Banner_Ads')){
  $tbl = hwModTable('Banner_Ads','banner');
  mysql_query("ALTER TABLE $tbl CHANGE `default` default_b tinyint(4) unsigned DEFAULT '0' NOT NULL");
  mysql_query("ALTER TABLE $tbl ADD weight smallint(6) unsigned DEFAULT '0' NOT NULL");
  mysql_query("ALTER TABLE $tbl ADD max_clicks int(11) unsigned DEFAULT '0' NOT NULL");
  mysql_query("ALTER TABLE $tbl ADD max_imp int(11) unsigned DEFAULT '0' NOT NULL");
}

if(hwModGetState('Chat')){
  mysql_query("ALTER TABLE ".hwModTable('Chat','rooms')." ADD pwd varchar(32) NOT NULL");
}

if(hwModGetState('Extra_Pages')){
  mysql_query("ALTER TABLE ".hwModTable('Extra_Pages','data')." MODIFY content MEDIUMTEXT");
}

mysql_query("CREATE TABLE ".TBL_CAT_EXTRA." (
   cid smallint(5) unsigned NOT NULL,
   type char(1) NOT NULL,
   PRIMARY KEY (cid, type)
)");

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


?>
Return current item: Esvon Personals