Location: PHPKode > projects > Wordlog > htdocs/include/install.php
<?php 
	if (!$_POST[DO_IT]) { ?>
<HTML>
<BODY>
<TABLE ALIGN="CENTER" STYLE="HEIGHT:100%">
<TR>
<TD VALIGN="MIDDLE" ALIGN="CENTER" WIDTH="100%" STYLE="HEIGHT:100%">
<B><I>Wordlog Database Installer</I></B>
<FORM ACTION="install.php" METHOD="POST">
<INPUT TYPE="HIDDEN" NAME="DO_IT" VALUE="1">
SQL Username: <BR><INPUT TYPE="TEXT" NAME="SQLUSER"><BR><BR>
SQL Password: <BR><INPUT TYPE="PASSWORD" NAME="SQLPASS"><BR><BR>
SQL Host: <BR><INPUT TYPE="TEXT" NAME="SQLHOST" VALUE="localhost"><BR><BR>
SQL Database: <BR><INPUT TYPE="TEXT" NAME="SQLDATABASE"><BR><BR>
<SELECT NAME="TYPE">
<OPTION VALUE="UPGRADE10">Upgrade from 1.0</OPTION>
<OPTION VALUE="UPGRADE12">Upgrade from 1.1/1.2</OPTION>
<OPTION VALUE="UPGRADE13">Upgrade from 1.3</OPTION>
<OPTION VALUE="NEW" SELECTED>New Installation</OPTION>
</SELECT>

<BR><BR><INPUT TYPE="SUBMIT" NAME="SUBMIT" VALUE="Set Up the Database!">

</FORM>
</TD>
</TABLE>
</BODY>
</HTML>
<? 
	} else {
		$conn = mysql_connect($_POST[SQLHOST],$_POST[SQLUSER],$_POST[SQLPASS]);
		if (mysql_select_db($_POST[SQLDATABASE])) ;
		else {
			echo "<h1>Could not connect to database</h1>";
			exit();
		}

		if ($_POST[TYPE] == 'UPGRADE12') {
			mysql_query("ALTER TABLE `users` RENAME `wordlog_users`");
			mysql_query("ALTER TABLE `image_categories` RENAME `wordlog_image_categories`");
			mysql_query("ALTER TABLE `image_image` RENAME `wordlog_image_image`");
			mysql_query("ALTER TABLE `link_categories` RENAME `wordlog_link_categories`");
			mysql_query("ALTER TABLE `link_link` RENAME `wordlog_link_link`");
			mysql_query("ALTER TABLE `replies` RENAME `wordlog_replies`");
			mysql_query("ALTER TABLE `userprefs` RENAME `wordlog_userprefs`");
			mysql_query("ALTER TABLE `journal` RENAME `wordlog_journal`");
			mysql_query("CREATE TABLE wordlog_sessions ( sesskey char(32) not null, expiry int(11) unsigned not null, value text not null, PRIMARY KEY (sesskey) );"); 
		}	elseif ($_POST[TYPE] == 'UPGRADE10') {
			mysql_query("CREATE TABLE userprefs (user text NOT NULL,field text NOT NULL,value text NOT NULL) TYPE=MyISAM;");
			mysql_query("ALTER TABLE `users` RENAME `wordlog_users`");
			mysql_query("ALTER TABLE `image_categories` RENAME `wordlog_image_categories`");
			mysql_query("ALTER TABLE `image_image` RENAME `wordlog_image_image`");
			mysql_query("ALTER TABLE `link_categories` RENAME `wordlog_link_categories`");
			mysql_query("ALTER TABLE `link_link` RENAME `wordlog_link_link`");
			mysql_query("ALTER TABLE `replies` RENAME `wordlog_replies`");
			mysql_query("ALTER TABLE `userprefs` RENAME `wordlog_userprefs`");
			mysql_query("ALTER TABLE `journal` RENAME `wordlog_journal`");
			mysql_query("CREATE TABLE wordlog_sessions ( sesskey char(32) not null, expiry int(11) unsigned not null, value text not null, PRIMARY KEY (sesskey) );"); 
		}	elseif ($_POST[TYPE] == 'NEW') {
			mysql_query("CREATE TABLE image_categories (category text NOT NULL) TYPE=MyISAM;");
			mysql_query("CREATE TABLE image_image ( category text NOT NULL, link text NOT NULL, text text NOT NULL, id mediumint(10) unsigned zerofill NOT NULL auto_increment, PRIMARY KEY  (id) ) TYPE=MyISAM;");
			mysql_query("CREATE TABLE journal ( id mediumint(10) unsigned zerofill NOT NULL auto_increment, date timestamp(14) NOT NULL, message text NOT NULL, mood text NOT NULL, music text NOT NULL, posted text NOT NULL, PRIMARY KEY  (id) ) TYPE=MyISAM;");
			mysql_query("CREATE TABLE link_categories ( category text NOT NULL ) TYPE=MyISAM;");
			mysql_query("CREATE TABLE link_link ( category text NOT NULL, link text NOT NULL, text text NOT NULL, id mediumint(10) unsigned zerofill NOT NULL auto_increment, PRIMARY KEY  (id) ) TYPE=MyISAM;");
			mysql_query("CREATE TABLE replies ( id mediumint(10) unsigned zerofill NOT NULL auto_increment, pid mediumint(10) unsigned zerofill NOT NULL default '0000000000', cid mediumint(9) NOT NULL default '0', sourcet text NOT NULL, from_user text NOT NULL, host text NOT NULL, date timestamp(14) NOT NULL, message text NOT NULL, PRIMARY KEY  (id) ) TYPE=MyISAM;");
			mysql_query("CREATE TABLE userprefs ( user text NOT NULL, field text NOT NULL, value text NOT NULL ) TYPE=MyISAM;");
			mysql_query("CREATE TABLE users ( username text NOT NULL, password text NOT NULL ) TYPE=MyISAM;");

			mysql_query("ALTER TABLE `users` RENAME `wordlog_users`");
			mysql_query("ALTER TABLE `image_categories` RENAME `wordlog_image_categories`");
			mysql_query("ALTER TABLE `image_image` RENAME `wordlog_image_image`");
			mysql_query("ALTER TABLE `link_categories` RENAME `wordlog_link_categories`");
			mysql_query("ALTER TABLE `link_link` RENAME `wordlog_link_link`");
			mysql_query("ALTER TABLE `replies` RENAME `wordlog_replies`");
			mysql_query("ALTER TABLE `userprefs` RENAME `wordlog_userprefs`");
			mysql_query("ALTER TABLE `journal` RENAME `wordlog_journal`");
			mysql_query("CREATE TABLE wordlog_sessions ( sesskey char(32) not null, expiry int(11) unsigned not null, value text not null, PRIMARY KEY (sesskey) );");
		}	elseif ($_POST[TYPE] == 'UPGRADE13') {
			mysql_query("CREATE TABLE wordlog_sessions ( sesskey char(32) not null, expiry int(11) unsigned not null, value text not null, PRIMARY KEY (sesskey) );");
		}

		mysql_close($conn);
?>
<HTML>
<BODY>
<TABLE ALIGN="CENTER" STYLE="HEIGHT:100%">
<TR>
<TD VALIGN="MIDDLE" ALIGN="CENTER" WIDTH="100%" STYLE="HEIGHT:100%">
	<B>Step 1: Database Modification... complete.</B>
	<BR>
	<BR>Step 2: Edit the file include/config.php
	<BR>Step 3: <B>Important:</B> create the user(s) that you assigned as admin(s) in step 2.
	<BR>Step 4: Delete this file (include/install.php)
</TD>
</TR>
</TABLE>
</BODY>
</HTML>
<?	} ?>
Return current item: Wordlog