Location: PHPKode > projects > ZompLog > install/upgrade/version34.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");

// first, let's update an existing table
$query2 = "ALTER TABLE $table ADD align text NOT NULL";

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


$query3 = "ALTER TABLE $table_pages ADD image text NOT NULL, ADD imagewidth text NOT NULL, ADD imageheight text NOT NULL, ADD align text NOT NULL";

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

$query4 = "UPDATE $table_settings SET skin = 'default'";
$q4 = mysql_query($query4) or die (mysql_error());

// version 3.6

$query5 = "ALTER TABLE $table ADD teaser int (15) NOT NULL default 0";

$q5 = mysql_query($query5) or die (mysql_error());
echo "<div class='text'><img src='../images/check.gif'> $table updated</div>";

$query6 = "ALTER TABLE $table_cat ADD catorder int (15) NOT NULL default 0";

$q6 = mysql_query($query6) or die (mysql_error());
echo "<div class='text'><img src='../images/check.gif'> $table_cat updated</div>";

$query7 = "ALTER TABLE $table_settings ADD weblog_subtitle text NOT NULL, ADD use_tinymce int(50) NOT NULL default 0, ADD pages_admin int(50) NOT NULL default 0, ADD search int(50) NOT NULL default 0, ADD archive int(50) NOT NULL default 0, ADD teasers int(50) NOT NULL default 0, ADD authors int(50) NOT NULL default 0,  ADD latestentries int(50) NOT NULL default 0, ADD latestcomments int(50) NOT NULL default 0, ADD users int(50) NOT NULL default 0, ADD meta int(50) NOT NULL default 0, ADD login int(50) NOT NULL default 0, ADD powered int(50) NOT NULL default 0, ADD customfield text NOT NULL, ADD about text NOT NULL";

$q7 = mysql_query($query7) or die (mysql_error());
echo "<div class='text'><img src='../images/check.gif'> $table_settings updated</div>";
  
$query8 = "ALTER TABLE $table_pages ADD pageorder int (15) NOT NULL default 0";
$q8 = mysql_query($query8) or die (mysql_error());
echo "<div class='text'><img src='../images/check.gif'> $table_pages updated</div>";

$query9 = "UPDATE $table_settings SET use_tinymce = '1', search = '1', archive = '1', authors = '1', meta = '1', powered = '1', login = '1', pages = '1', pages_admin = '1'";

$q9 = mysql_query($query9) or die (mysql_error()); 
echo "<div class='text'><img src='../images/check.gif'> $table_settings updated</div>";

$query11 = "CREATE TABLE $table_themes (
  id int(11) NOT NULL auto_increment,
  name text NOT NULL,
  options int(50) NOT NULL default 0,
  headerimage text NOT NULL,
  color1 text NOT NULL,
  color1caption text NOT NULL,
  color2 text NOT NULL,
  color2caption text NOT NULL,
  color3 text NOT NULL,
  color3caption text NOT NULL,
  font1 text NOT NULL,
  font1color text NOT NULL,
  font1caption text NOT NULL,
  font2 text NOT NULL,
  font2color text NOT NULL,
  font2caption text NOT NULL,
  
  PRIMARY KEY  (id)
)";

$query12 = "INSERT INTO $table_themes (name, color1caption, color3caption, font1caption, font2caption) VALUES ('default', 'header background color', 'menu background color', 'title font', 'main text font')";
$query13 = "INSERT INTO $table_themes (name, color1caption, color2caption) VALUES ('kubrick', 'header background color', 'menu background color')";
$query14 = "INSERT INTO $table_themes (name, color1caption, color2caption, color3caption) VALUES ('modern', 'header background color', 'menu background color', 'description background color')";
$query15 = "INSERT INTO $table_themes (name, color1caption, color2caption, color3caption, font1caption, font2caption) VALUES ('classic', 'header background color', 'subheader background color', 'menu background color', 'title font', 'main text font')";
$query16 = "INSERT INTO $table_themes (name, color1caption, color2caption, color3caption, font1caption) VALUES ('orangeblue', 'header background color',  'menu background color', 'content background color', 'title font')";
$query17 = "INSERT INTO $table_themes (name, color1caption, color2caption) VALUES ('frozenliquid', 'header background color', 'blog background color')";

$q11 = mysql_query($query11) or die (mysql_error());
$q12 = mysql_query($query12) or die (mysql_error());
$q13 = mysql_query($query13) or die (mysql_error());
$q14 = mysql_query($query14) or die (mysql_error());
$q15 = mysql_query($query15) or die (mysql_error());
$q16 = mysql_query($query16) or die (mysql_error());
$q17 = mysql_query($query17) or die (mysql_error());
echo "<div class='text'><img src='../images/check.gif'> $table_themes created</div>";

$query10 = "ALTER TABLE $table_users CHANGE password password varchar(150) default 0";
$q10 = mysql_query($query10) or die (mysql_error());

//updating passwords to md5 encryption
$query18 = "SELECT * from $table_users";
$q18 = mysql_query($query18) or die (mysql_error());
$users = arrayMaker($q18);

foreach ($users as $user){
$password = md5($user[password]);
$query19 = "UPDATE $table_users SET password = '$password' WHERE login = '$user[login]'";
$q19 = mysql_query($query19) or die (mysql_error());
}
echo "<div class='text'><img src='../images/check.gif'> $table_users updated</div>"; 

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


$q20 = mysql_query($query20) or die ("Unable to create $table_plugins.<br /><br />"); 
echo "<div class='text'><img src='images/check.gif'> $table_plugins created</div>";  

// 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'><img src='images/check.gif'> $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'><img src='images/check.gif'> $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());	
}

}

// 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.4 to 3.9 upgrade $name", "$body", "From: hide@address.com");
		
echo "<br /> Zomplog has been succesfully upgraded!";
?>
</body>
</html>
Return current item: ZompLog