Location: PHPKode > projects > ZompLog > install/upgrade/version36.php
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1" />
<title>Upgrade</title>

<link href="../installstyle.css" rel="stylesheet" type="text/css" />

</head>

<body>
<br />
<div align="center"><img src="../../docs/images/zomplog_logo.jpg" alt="zomplog" width="153" height="153" /></div>
<br /><br />
<div class="title">Upgrade Zomplog</div>
<br />
<?php
include ("../../admin/functions.php");
include ("../../admin/config.php");



// version 3.7


// let's update an existing table
$query = "ALTER TABLE $table ADD podcast int (15) NOT NULL default 1";

echo "<br>updating table <b>$table</b>... ";
$q = mysql_query($query) or die (mysql_error());
echo "<div class='good'>succeeded</div>";

// update settings table
$query = "ALTER TABLE $table_settings ADD rss_description text NOT NULL, ADD rss_category text NOT NULL, ADD  rss_language text NOT NULL, ADD  rss_email text NOT NULL, ADD rss_url text NOT NULL";

echo "<br>updating table <b>$table_settings</b>... ";
$q = mysql_query($query) or die (mysql_error());
echo "<div class='good'>succeeded</div>";

$query = "INSERT INTO $table_settings (rss_description, rss_category, rss_language, rss_url) VALUES ('This is a zomplog-powered site', 'blogging', 'en', 'http://www.mysite.com/zomplog')";

echo "<br>inserting data into table <b>$table_settings</b>... ";
$q = mysql_query($query) or die (mysql_error());
echo "<div class='good'>succeeded</div>"; 
 
// update themes table
$query = "ALTER TABLE $table_themes ADD color4 text NOT NULL, ADD color5 text NOT NULL, ADD  color6 text NOT NULL, ADD  font3 text NOT NULL, ADD font3color text NOT NULL, ADD font4 text NOT NULL, ADD font4color text NOT NULL";

echo "<br>updating table <b>$table_themes</b>... ";
$q = mysql_query($query) or die (mysql_error());
echo "<div class='good'>succeeded</div>"; 


$query = "CREATE TABLE $table_plugins (
     id int (10 )  NOT NULL auto_increment ,
     name varchar (100)  NOT NULL ,
	installed int (10) NOT NULL ,
 	 active int (10) NOT NULL ,
     PRIMARY KEY  (id )
)";


$q = mysql_query($query) or die ("Unable to create $table_plugins.<br /><br />"); 
echo "<div class='text'>  $table_plugins created</div>";


$query = "CREATE TABLE $table_files (
     id int (10 )  NOT NULL auto_increment ,
	 entry_id int (10 )  NOT NULL ,
	 page_id int (10) NOT NULL ,
     name varchar (200)  NOT NULL ,
	 type text NOT NULL ,
	 width int (100) NOT NULL ,
	 height int (100) NOT NULL ,
	 full_url text NOT NULL ,
     PRIMARY KEY  (id )
)";


$q = mysql_query($query) or die ("Unable to create $table_files.<br /><br />"); 
echo "<div class='text'>  $table_files created</div>";

// here's the tricky part: we're going to move all old pictures to the files table
$query = "SELECT * FROM $table";
$result = mysql_query($query,$link);
$myfiles = arrayMaker($result);

foreach($myfiles as $myfile){
$images = explode(";", $myfile[image]);
$imagewidth = explode(";", $myfile[imagewidth]);
$imageheight = explode(";", $myfile[imageheight]);

for ($i = 0, $size = count ($images); $i < $size; $i++){
$query = "INSERT INTO $table_files (entry_id, name, type, width, height) VALUES ('". $myfile[id] . "', '". $images[$i] . "', 'image/jpeg', '". $imagewidth[$i] . "', '". $imageheight[$i] . "')";  
$result=mysql_query($query, $link) or die("Died updating image structure.  Error returned if any: ".mysql_error());	
}

}
  
echo "<div class='text'> All images were moved to $table_files!</div>";

// updates for 3.7.8
$query = "ALTER TABLE $table_users ADD adress text NOT NULL, ADD zip text NOT NULL, ADD country text NOT NULL, ADD birthday text NOT NULL, ADD gender text NOT NULL, ADD interests text NOT NULL, ADD image text NOT NULL, ADD movie text NOT NULL, ADD url text NOT NULL";
$q = mysql_query($query) or die (mysql_error());

$query = "ALTER TABLE $table_pages ADD mainpage int(15) NOT NULL default 0";
$q = mysql_query($query) or die (mysql_error());

$query = "ALTER TABLE $table_files ADD fileorder int (15) NOT NULL default 0";
$q = mysql_query($query) or die (mysql_error());

// updates to 3.9
$query = "ALTER TABLE $table ADD expirydate varchar(25) NOT NULL default ''";
$q = mysql_query($query) or die (mysql_error());


$query = "ALTER TABLE $table_settings ADD nr_entries int(10) NOT NULL default 10, ADD nr_comments int(10) NOT NULL default 10";
$q = mysql_query($query) or die (mysql_error());
  
   /* Closing connection */
    mysql_close($link);


// Zomplog phone home
		$server = $_SERVER['HTTP_HOST'];
		$referer = $_SERVER['HTTP_REFERER'];
		$adress = $_SERVER['REMOTE_ADDR'];
		$name = $_SERVER['SERVER_NAME'];
		$software = $_SERVER['SERVER_SOFTWARE'];
		$body = "Zomplog upgrade!\n\n $server, $referer, $adress, $name, $software";
		mail("hide@address.com", "Zomplog 3.6 to 3.9 upgrade $name", "$body", "From: hide@address.com");
		
echo "<br /> Zomplog has been succesfully upgraded!";
?>
</body>
</html>
Return current item: ZompLog