Location: PHPKode > projects > MGB OpenSource Guestbook > mgb-0.6.9.1/install/mysql.php
<?php
	/*
	MGB 0.6.x - OpenSource PHP and MySql Guestbook
	Copyright (C) 2004 - 2011 Juergen Grueneisl - http://www.m-gb.org/

	This program is free software; you can redistribute it and/or modify
	it under the terms of the GNU General Public License as published by
	the Free Software Foundation; either version 2 of the License, or
	(at your option) any later version.

	This program is distributed in the hope that it will be useful,
	but WITHOUT ANY WARRANTY; without even the implied warranty of
	MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
	GNU General Public License for more details.

	You should have received a copy of the GNU General Public License
	along with this program; if not, write to the Free Software
	Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
	*/

	// =============== //
	// mysql.php - 0.4 //
	// =============== //
	//
	// ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ //

	// make sure nobody has direct access to this script
	if (!defined('INSTALL'))
		{
		echo "Error! Start installation with <a href=\"install.php\">install.php</a>";
		die();
		}

	$db_hostname = $_SESSION['db_hostname'];
	$db_dbname = $_SESSION['db_dbname'];
	$db_username = $_SESSION['db_username'];
	$db_password = $_SESSION['db_password'];
	$db_prefix = $_SESSION['db_prefix'];

	$admin_name = $_SESSION['admin_name'];
	$admin_username = $_SESSION['admin_username'];
	$admin_password = md5($_SESSION['admin_password']);
	$admin_email = $_SESSION['admin_email'];
	$admin_gbemail = $_SESSION['admin_gbemail'];

	$server_name = $_SERVER["SERVER_NAME"];
	$gb_path = $_SERVER["SCRIPT_NAME"];
	$gb_path = str_replace("install/install.php", "", $gb_path);

	$h_domain = "www.".$_SERVER["SERVER_NAME"];

	// ++++++++++++++++++++++++++++++++++ //

	require ("../language/".$_SESSION['install_language']."/lang_admin.php");

	$sql = array();

	$sql[1] = "CREATE TABLE ".$db_prefix."captcha (
		  `code` VARCHAR( 11 ) NOT NULL ,
		  PRIMARY KEY ( `code` )
		  )";

	$sql[2] = "INSERT INTO ".$db_prefix."captcha ( `code` ) VALUES ( 'ABCDEF' );";

	$sql[3] = "CREATE TABLE ".$db_prefix."captcha_math (
		  `math` VARCHAR( 20 ) NOT NULL ,
		  `sum` INT NOT NULL ,
		  PRIMARY KEY ( `math` )
		  )";

	$sql[4] = "INSERT INTO ".$db_prefix."captcha_math (
			`math` ,
			`sum`
		) VALUES (
			'1+2+3' ,
			'6'
			);";

	$sql[5] = "CREATE TABLE ".$db_prefix."entries (
		  `ID` INT NOT NULL AUTO_INCREMENT PRIMARY KEY ,
		  `name` VARCHAR( 255 ) NOT NULL ,
		  `city` VARCHAR( 255 ) NOT NULL ,
		  `email` VARCHAR( 255 ) NOT NULL ,
		  `icq` VARCHAR( 255 ) NOT NULL ,
		  `aim` VARCHAR( 255 ) NOT NULL ,
		  `msn` VARCHAR( 255 ) NOT NULL ,
		  `hp` VARCHAR( 255 ) NOT NULL ,
		  `message` MEDIUMTEXT NOT NULL ,
		  `comment` MEDIUMTEXT NOT NULL ,
		  `ip` VARCHAR( 15 ) NOT NULL ,
		  `timestamp` VARCHAR( 255 ) NOT NULL ,
		  `user_notification` TINYINT( 1 ) NOT NULL ,
		  `user_show_email` TINYINT( 1 ) NOT NULL ,
		  `checked` TINYINT( 1 ) NOT NULL ,
		  `isspam` TINYINT( 1 ) NOT NULL
		  )";


	$sql[6] = "CREATE TABLE ".$db_prefix."lastip (
		  `lastIP` VARCHAR( 15 ) NOT NULL ,
		  PRIMARY KEY ( `lastIP` )
		  )";


	$sql[7] = "CREATE TABLE ".$db_prefix."settings (
		  `title` VARCHAR(255) NOT NULL DEFAULT 'MGB 0.6.x OpenSource Guestbook',
		  `h_author` VARCHAR(255) NOT NULL DEFAULT '".$admin_name."', 
		  `h_domain` VARCHAR(255) NOT NULL DEFAULT '".$server_name."', 
		  `gb_path` VARCHAR(255) NOT NULL DEFAULT '".$gb_path."', 
		  `h_keywords` VARCHAR(255) NOT NULL, 
		  `h_description` VARCHAR(255) NOT NULL, 
		  `admin_name` VARCHAR(255) NOT NULL DEFAULT '".$admin_name."', 
		  `admin_email` VARCHAR(255) NOT NULL DEFAULT '".$admin_email."', 
		  `admin_gbemail` VARCHAR(255) NOT NULL DEFAULT '".$admin_gbemail."', 
		  `sendmail_admin` TINYINT(1) NOT NULL, 
		  `sendmail_admin_text` MEDIUMTEXT NOT NULL, 
		  `sendmail_user` TINYINT(1) NOT NULL, 
		  `sendmail_user_text` MEDIUMTEXT NOT NULL, 
		  `sendmail_user_notification_text` MEDIUMTEXT NOT NULL, 
		  `sendmail_comment_text` MEDIUMTEXT NOT NULL, 
		  `sendmail_contactmail_text` MEDIUMTEXT NOT NULL, 
		  `template_path` VARCHAR(255) NOT NULL DEFAULT 'mgbModern',
		  `template_style_path` VARCHAR(255) NOT NULL DEFAULT 'blue',
		  `iconset_path` VARCHAR(255) NOT NULL DEFAULT 'default', 
		  `language_path` VARCHAR(255) NOT NULL DEFAULT 'lang_english_utf8', 
		  `badwords` MEDIUMTEXT NOT NULL, 
		  `bbcode` TINYINT(1) NOT NULL DEFAULT '1', 
		  `allow_img_tag` TINYINT(1) NOT NULL DEFAULT '0', 
		  `max_img_width` INT(4) NOT NULL DEFAULT '400', 
		  `max_img_height` INT(4) NOT NULL DEFAULT '400', 
		  `center_img` TINYINT(1) NOT NULL DEFAULT '1', 
		  `allow_flash_tag` TINYINT(1) NOT NULL DEFAULT '0', 
		  `max_flash_width` INT(4) NOT NULL DEFAULT '400', 
		  `max_flash_height` INT(4) NOT NULL DEFAULT '400', 
		  `center_flash` TINYINT(1) NOT NULL DEFAULT '1', 
		  `smileys` TINYINT(1) NOT NULL DEFAULT '1', 
		  `smileys_break` TINYINT(2) NOT NULL DEFAULT '11', 
		  `smileys_order` VARCHAR(4) NOT NULL DEFAULT 'ASC', 
		  `captcha` TINYINT(1) NOT NULL DEFAULT '1', 
		  `captcha_method` TINYINT(1) NOT NULL DEFAULT '0', 
		  `captcha_coords_x` INT( 3 ) NOT NULL DEFAULT '20', 
		  `captcha_coords_y` INT( 3 ) NOT NULL DEFAULT '25', 
		  `captcha_color` VARCHAR( 6 ) NOT NULL DEFAULT '505050' ,
		  `captcha_angle_1` INT( 4 ) NOT NULL DEFAULT '-10' ,
		  `captcha_angle_2` INT( 4 ) NOT NULL DEFAULT '5' ,
		  `akismet_plugin` TINYINT(1) NOT NULL DEFAULT '1', 
		  `akismet_api` VARCHAR(50) NOT NULL, 
		  `akismet_mark_as_spam` TINYINT(1) NOT NULL,
		  `time_lock` TINYINT(1) NOT NULL DEFAULT '1',
		  `time_lock_value` INT(3) NOT NULL DEFAULT '30',
		  `time_lock_maxtime` INT NOT NULL DEFAULT '180',
		  `user_notification` TINYINT(1) NOT NULL DEFAULT '1', 
		  `user_show_email` TINYINT(1) NOT NULL DEFAULT '1', 
		  `session_timeout` INT(4) NOT NULL DEFAULT '900', 
		  `password_min_length` TINYINT(2) NOT NULL DEFAULT '8', 
		  `moderated` TINYINT(1) NOT NULL DEFAULT '1', 
		  `entries_per_page` TINYINT(2) NOT NULL DEFAULT '10',
		  `entries_order` VARCHAR(11) NOT NULL DEFAULT 'ID', 
		  `entries_order_asc_desc` VARCHAR(4) NOT NULL DEFAULT 'DESC', 
		  `entries_numbering` TINYINT(1) NOT NULL DEFAULT '1', 
		  `spam_protection` TINYINT(1) NOT NULL DEFAULT '1', 
		  `ipblocker` TINYINT(1) NOT NULL DEFAULT '0', 
		  `wordwrap` TINYINT(2) NOT NULL DEFAULT '60',
		  `dateform` VARCHAR(5) NOT NULL DEFAULT 'd.m.Y', 
		  `gravatar_show` TINYINT(1) NOT NULL DEFAULT '0',
		  `gravatar_rating` TINYINT(1) NOT NULL DEFAULT '0', 
		  `gravatar_type` TINYINT(1) NOT NULL DEFAULT '1', 
		  `gravatar_size` INT(3) NOT NULL DEFAULT '50', 
		  `gravatar_position` TINYINT(1) NOT NULL DEFAULT '1', 
		  `version` VARCHAR(20) NOT NULL,
		  PRIMARY KEY (`title`) 
		 )";

	$sql[8] = "INSERT INTO ".$db_prefix."settings (
		  `title` ,
		  `h_author` , 
		  `h_domain` , 
		  `gb_path` , 
		  `h_keywords` , 
		  `h_description` , 
		  `admin_name` , 
		  `admin_email` ,
		  `admin_gbemail` ,
		  `sendmail_admin` , 
		  `sendmail_admin_text` , 
		  `sendmail_user` , 
		  `sendmail_user_text` , 
		  `sendmail_user_notification_text` , 
		  `sendmail_comment_text` , 
		  `sendmail_contactmail_text` , 
		  `template_path` ,
		  `template_style_path` ,
		  `iconset_path` , 
		  `language_path` , 
		  `badwords` , 
		  `bbcode` , 
		  `allow_img_tag` , 
		  `max_img_width` , 
		  `max_img_height` , 
		  `center_img` , 
		  `allow_flash_tag` , 
		  `max_flash_width` , 
		  `max_flash_height` , 
		  `center_flash` , 
		  `smileys` , 
		  `smileys_break` , 
		  `smileys_order` , 
		  `captcha` , 
		  `captcha_method` , 
		  `captcha_coords_x` , 
		  `captcha_coords_y` , 
		  `captcha_color` , 
		  `captcha_angle_1` , 
		  `captcha_angle_2` , 
		  `akismet_plugin` , 
		  `akismet_api` , 
		  `akismet_mark_as_spam` , 
		  `time_lock` , 
		  `time_lock_value` , 
		  `time_lock_maxtime` , 
		  `user_notification` , 
		  `user_show_email` , 
		  `session_timeout` , 
		  `password_min_length` , 
		  `moderated` , 
		  `entries_per_page` ,
		  `entries_order` , 
		  `entries_order_asc_desc` , 
		  `entries_numbering` , 
		  `spam_protection` , 
		  `ipblocker` , 
		  `wordwrap` ,
		  `dateform` ,
		  `gravatar_show` ,
		  `gravatar_rating` , 
		  `gravatar_type` ,
		  `gravatar_size` , 
		  `gravatar_position` , 
		  `version`
		  ) VALUES (
		  'MGB ".MGB_VERSION."', 
		  '".$admin_name."', 
		  '".$h_domain."', 
		  '".$gb_path."', 
		  '', 
		  '', 
		  '".$admin_name."', 
		  '".$admin_email."',
		  '".$admin_gbemail."',
		  '1',
		  '".$lang['sendmail_admin_text']."',
		  '1',
		  '".$lang['sendmail_user_text']."',
		  '".$lang['sendmail_user_notification_text']."',
		  '".$lang['sendmail_comment_text']."',
		  '".$lang['sendmail_contactmail_text']."',
		  'mgbModern',
		  'blue',
		  'default', 
		  '".$_SESSION['install_language']."', 
		  '', 
		  '1', 
		  '0', 
		  '400', 
		  '400', 
		  '1', 
		  '0', 
		  '400', 
		  '400', 
		  '1', 
		  '1', 
		  '11', 
		  'ASC', 
		  '1', 
		  '0', 
		  '20', 
		  '25', 
		  '505050', 
		  '-10', 
		  '5', 
		  '0', 
		  '', 
		  '1',
		  '1',
		  '30',
		  '180',
		  '1',
		  '1',
		  '900', 
		  '8', 
		  '1', 
		  '10',
		  'ID',
		  'DESC',
		  '1',
		  '1', 
		  '0', 
		  '60',
		  'd.m.Y',
		  '0',
		  '0', 
		  '1',
		  '50', 
		  '1', 
		  '".MGB_VERSION."'
		  );";


	$sql[9] = "CREATE TABLE ".$db_prefix."user (
		  `ID` INT NOT NULL AUTO_INCREMENT PRIMARY KEY ,
		  `user_name` VARCHAR( 255 ) NOT NULL ,
		  `user_password` VARCHAR( 255 ) NOT NULL ,
		  `user_key` VARCHAR( 16 ) NOT NULL ,
		  `user_email` VARCHAR( 255 ) NOT NULL ,
		  `user_is_active` TINYINT( 1 ) NOT NULL ,
		  `user_level` TINYINT( 1 ) NOT NULL ,
		  `r_settings` TINYINT( 1 ) NOT NULL ,
		  `r_activate` TINYINT( 1 ) NOT NULL ,
		  `r_deactivate` TINYINT( 1 ) NOT NULL ,
		  `r_delete` TINYINT( 1 ) NOT NULL ,
		  `r_edit` TINYINT( 1 ) NOT NULL ,
		  `r_spam` TINYINT( 1 ) NOT NULL ,
		  `r_edit_smilies` TINYINT( 1 ) NOT NULL ,
		  `logged_in` INT( 255 ) NOT NULL ,
		  `logged_out` TINYINT( 1 ) NOT NULL ,
		  `np_key` VARCHAR( 16 ) NOT NULL ,
		  `np_expiration` VARCHAR( 255 ) NOT NULL
		  )";

	$sql[10] = "INSERT INTO ".$db_prefix."user ( 
		  `ID` ,
		  `user_name` ,
		  `user_password` ,
		  `user_key` ,
		  `user_email` ,
		  `user_is_active` ,
		  `user_level` ,
		  `r_settings` ,
		  `r_activate` ,
		  `r_deactivate` ,
		  `r_delete` ,
		  `r_edit`,
		  `r_spam`,
		  `r_edit_smilies`,
		  `logged_in` ,
		  `logged_out`,
		  `np_key` ,
		  `np_expiration` 
		  ) VALUES (
		  NULL,
		  '".$admin_username."',
		  '".$admin_password."',
		  '0',
		  '".$admin_email."',
		  '1',
		  '0',
		  '1',
		  '1',
		  '1',
		  '1',
		  '1',
		  '1',
		  '1',
		  '".time()."',
		  '1',
		  '',
		  ''
		  );";

	$sql[11] = "CREATE TABLE ".$db_prefix."smilies (
		  `ID` INT NOT NULL AUTO_INCREMENT PRIMARY KEY ,
		  `path` VARCHAR( 255 ) NOT NULL ,
		  `replacement` VARCHAR( 255 ) NOT NULL ,
		  `height` TINYINT( 4 ) NOT NULL ,
		  `width` TINYINT( 4 ) NOT NULL
		  )";

	$sql[12] = "INSERT INTO ".$db_prefix."smilies ( 
	  `ID` ,
	  `path` ,
	  `replacement` ,
	  `height` ,
	  `width`
	  ) VALUES 	( NULL , 'smiley_smile.gif', ':smile:, :), :-)', '15', '15' ),
				( NULL , 'smiley_wink.gif', ':wink:, ;), ;-)', '15', '15' ),
				( NULL , 'smiley_lol.gif', ':lol:', '15', '15' ),
				( NULL , 'smiley_biggrin.gif', ':biggrin:, :D, :-D', '15', '15' ),
				( NULL , 'smiley_cool.gif', ':cool:, B), B-)', '15', '15' ),
				( NULL , 'smiley_fun.gif', ':fun:, ^^', '15', '15' ),
				( NULL , 'smiley_surprised.gif', ':surprised:, :O, :-O', '15', '15' ),
				( NULL , 'smiley_tongue.gif', ':tongue:, :P, :-P', '15', '15' ),
				( NULL , 'smiley_confused.gif', ':confused:, :/, :-/', '15', '15' ),
				( NULL , 'smiley_eek.gif', ':eek:, 8O, 8-O', '15', '15' ),
				( NULL , 'smiley_doubt.gif', ':doubt:', '15', '15' ),
				( NULL , 'smiley_neutral.gif', ':neutral:, :|, :-|', '15', '15' ),
				( NULL , 'smiley_redface.gif', ':redface:', '15', '15' ),
				( NULL , 'smiley_rolleyes.gif', ':rolleyes:', '15', '15' ),
				( NULL , 'smiley_silenced.gif', ':silenced:', '15', '15' ),
				( NULL , 'smiley_sad.gif', ':sad:, :(, :-(', '15', '15' ),
				( NULL , 'smiley_cry.gif', ':cry:, :\'(, :\'-(', '15', '15' ),
				( NULL , 'smiley_doh.gif', ':doh:', '15', '15' ),
				( NULL , 'smiley_angry.gif', ':angry:', '15', '15' ),
				( NULL , 'icon_arrow.gif', ':arrow:, ->', '15', '15' ),
				( NULL , 'icon_exclaim.gif', ':exclaim:', '15', '15' ),
				( NULL , 'icon_question.gif', ':question:', '15', '15' );";
	$to = 12;

	if(!isset($success)) { $success = 0; }
	
	for($i = 1; $i <= $to; $i++)
		{
		$sqlcommand = $sql[$i];
		$link = @mysql_connect($db_hostname, $db_username, $db_password) or die ("(mysql.php) Error: ".mysql_error());
		@mysql_select_db($db_dbname, $link) or die ("(mysql.php) Error: ".mysql_error());
		if(@mysql_query($sqlcommand, $link) === TRUE)
			{
			$success++;
			}
		else
			{
			echo mysql_error();
			echo "<br><br>";
			}
		}
?>
Return current item: MGB OpenSource Guestbook