[ PHPXref.com ] [ Generated: Sun Jul 20 17:09:03 2008 ] [ CuteSITE 1.2.3 ]
[ Index ]     [ Variables ]     [ Functions ]     [ Classes ]     [ Constants ]     [ Statistics ]

title

Body

[close]

/ -> upgrade-1_2_2-to-1_2_3.php (source)

   1  <HTML>
   2  <HEAD>
   3  <STYLE type="text/css">
   4  <!--
   5  body {font-family: monospace}
   6  -->
   7  </STYLE>
   8  </HEAD>
   9  <BODY>
  10  <?php
  11  
  12  echo "<B>Preparing to upgrade CuteSITE version 1.2.2 to 1.2.3</B><BR><BR>";
  13  
  14  require_once(dirname(__FILE__)."/includes.php");
  15  
  16  set_error_handler("cs_error_handler");
  17  error_reporting(15);
  18  
  19  $errors = array();
  20  
  21  echo "Let's see on cutesite.ini file:<BR><BR>";
  22  
  23  if (!ini_get('register_globals')) {
  24      $errors[] = "Warning: register_globals is disabled. Turn it on in your php.ini file!";
  25  }
  26  
  27  if (!is_dir($conf['common']['site_root'])) {
  28      $errors[] = "site_root is invalid!";
  29  }
  30  
  31  if (!is_dir($conf['common']['site_root'].$conf['common']['images_dir'])) {
  32      $errors[] = "images_dir is invalid!";
  33  }
  34  
  35  if (!is_dir($conf['common']['var_dir'])) {
  36      $errors[] = "var_dir is invalid!";
  37  }
  38  
  39  if (!is_dir($conf['common']['files_dir'])) {
  40      $errors[] = "files_dir is invalid!";
  41  }
  42  
  43  if (!is_resource($DB_LINK)) {
  44      $errors[] = "We not connected to MySQL database. HELP!
  45                  Check if cutesite.ini database section.";
  46  }
  47  
  48  if (!array_key_exists("error_level", $conf['common'])) {
  49      $errors[] = "error_level parameter not exists, check it in cutesite.ini";
  50  }
  51  
  52  if (!array_key_exists("max_undo", $conf['common'])) {
  53      $errors[] = "max_undo parameter not exists, check it in cutesite.ini";
  54  }
  55  
  56  if (!array_key_exists("use_db_session", $conf['common'])) {
  57      $errors[] = "use_db_session parameter not exists, check it in cutesite.ini";
  58  }
  59  
  60  
  61  $result = mysql_list_tables($conf["database"]["DB_NAME"]);
  62  
  63  if (!$result) {
  64      $errors[] =  "DB Error, could not list tables. MySQL Error: " . mysql_error();
  65  }
  66  
  67  $tables = array();
  68  while ($row = mysql_fetch_row($result)) {
  69      $tables[$row[0]] = $row[0];
  70  }
  71  
  72  if (sizeof($errors) != 0) {
  73      echo "Houston, we have problems!<BR><PRE>";
  74      $c = 1;
  75      foreach ($errors as $e) {
  76          echo "   <B>".$c.". ".$e."</B>\n";
  77          $c++;
  78      }
  79      echo "</PRE>Install failed.";
  80      exit;
  81  }
  82  
  83  echo "Looking good.<BR><BR>";
  84  
  85  echo "<B>Preparing to upgrade MySQL database:</B><BR>";
  86  
  87  sql("ALTER TABLE `cs_users` ADD `drafts` LONGTEXT NOT NULL;");
  88  
  89  if (!array_key_exists("cs_session", $tables)) {
  90      sql("DROP TABLE IF EXISTS cs_session");
  91      sql("CREATE TABLE cs_session (
  92        session_id varchar(32) NOT NULL default '',
  93        value longtext NOT NULL,
  94        dt datetime NOT NULL default '0000-00-00 00:00:00',
  95        PRIMARY KEY  (session_id),
  96        KEY dt (dt)
  97      ) TYPE=MyISAM;");
  98  }
  99  
 100  if (!array_key_exists("cs_catalog", $tables)) {
 101      sql("DROP TABLE IF EXISTS cs_catalog");
 102      sql("CREATE TABLE cs_catalog (
 103        rec_id int(10) unsigned NOT NULL auto_increment,
 104        cat_id int(10) unsigned NOT NULL default '0',
 105        `left` int(10) unsigned NOT NULL default '0',
 106        `right` int(10) unsigned NOT NULL default '0',
 107        `level` int(10) unsigned NOT NULL default '0',
 108        name varchar(255) NOT NULL default '',
 109        title int(10) unsigned NOT NULL default '0',
 110        meta longtext NOT NULL,
 111        PRIMARY KEY  (rec_id),
 112        KEY `left` (`left`,`right`,`level`),
 113        KEY cat_id (cat_id)
 114      ) TYPE=MyISAM;");
 115  }
 116  
 117  if (!array_key_exists("cs_catalog_relations", $tables)) {
 118      sql("DROP TABLE IF EXISTS cs_catalog_relations");
 119      sql("CREATE TABLE cs_catalog_relations (
 120        item_id int(11) NOT NULL default '0',
 121        rec_id int(11) NOT NULL default '0',
 122        PRIMARY KEY  (item_id,rec_id)
 123      ) TYPE=MyISAM;");
 124  }
 125  
 126  
 127  $site = new _site();
 128  Persistent::checkout($site, $cs_config["store_file"]);
 129  
 130  if (is_object($site)) {
 131      echo "<B>200 ok.</B><BR><BR>";
 132      echo "<BR><B>All systems go!</B>"
 133      cs_history("Site <I>upgraded to version 1.2.3</I>. Good luck!", 'warn');
 134  } else {
 135      echo "<B>Install failed, site object is invalid. Try to install version 1.2.3.</B><BR><BR>";
 136  }
 137  
 138  ?>
 139  </HTML>


[ Powered by PHPXref - Served by Debian GNU/Linux ]