Location: PHPKode > projects > phpSC > install/install4.php
<?PHP
session_start();
$conn = mysql_connect($_SESSION['mysql_host'],$_SESSION['mysql_user'],$_SESSION['mysql_pass']);
if(!isset($_SESSION['u_name'])) {
$u_name = $_POST['user_name'];
$u_pass = $_POST['user_pass'];
$_SESSION['u_name'] = $u_name;
$_SESSION['u_pass'] = $u_pass;
$_SESSION['pass_check'] = $_POST['pass_check'];
}
if($_SESSION['u_pass'] != $_SESSION['pass_check']) {
header("Location:install3.php?password");
}
$enc_pass = sha1($user_pass);
$sql_0 = "DROP TABLE IF EXISTS `dnas_settings`";
$sql_1 = "
CREATE TABLE `dnas_settings` (
  `id` int(11) NOT NULL auto_increment,
  `host` varchar(225) NOT NULL default '',
  `port` int(11) NOT NULL default '0',
  `password` varchar(255) NOT NULL default '',
  `name` text NOT NULL,
  `owner` int(11) NOT NULL default '0',
  PRIMARY KEY  (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=3";
$sql_2 = "
DROP TABLE IF EXISTS `users`";
$sql_3 = "
CREATE TABLE `users` (
  `id` int(11) NOT NULL auto_increment,
  `username` varchar(255) NOT NULL default '',
  `password` varchar(255) NOT NULL default '',
  `level` int(11) NOT NULL default '0',
  `email` varchar(255) NOT NULL default '',
  `ip` varchar(255) default NULL,
  PRIMARY KEY  (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=2";
$sql_4 = "
INSERT INTO `users` (`id`, `username`, `password`, `level`, `email`, `ip`) VALUES 
(1, '".$_SESSION['u_name']."', '".sha1($_SESSION['u_pass'])."', 101, 'NOT USED YET', NULL)";

$sql_5 ="
DROP TABLE IF EXISTS `servers`";

$sql_6="
CREATE TABLE IF NOT EXISTS `servers` (
  `id` int(11) NOT NULL auto_increment,
  `name` varchar(255) NOT NULL default '',
  `pid` varchar(255) NULL default '',
  `conf` text NOT NULL default '',
   `ip` varchar(255) NULL default '',
   `port` varchar(255) NULL default '',
  `status` int(11) NOT NULL default '0',
  PRIMARY KEY  (`id`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=3";

$sql_7 ="
INSERT INTO `servers` (`id`, `name`, `pid`, `conf`,  `status`) VALUES 
(1, 'Default Server', '', 'default.conf', 0)";

$sql_8 ="
DROP TABLE IF EXISTS `plus`";

$sql_9 ="
CREATE TABLE `plus` (
`id` INT NOT NULL AUTO_INCREMENT PRIMARY KEY ,
`package` VARCHAR( 255 ) NOT NULL ,
`version` VARCHAR( 255 ) NOT NULL ,
`date_installed` VARCHAR( 255 ) NOT NULL
) ENGINE = MYISAM";

if(isset($_GET['execute'])) {
mysql_select_db($_POST['database'],$conn);
$_SESSION['mysql_db'] = $_POST['database'];
$result = mysql_query($sql_0,$conn) or die(mysql_error());
$result = mysql_query($sql_1,$conn) or die(mysql_error());
$result = mysql_query($sql_2,$conn) or die(mysql_error());
$result = mysql_query($sql_3,$conn) or die(mysql_error());
$result = mysql_query($sql_4,$conn) or die(mysql_error());
$result = mysql_query($sql_5,$conn) or die(mysql_error());
$result = mysql_query($sql_6,$conn) or die(mysql_error());
$result = mysql_query($sql_7,$conn) or die(mysql_error());
$result = mysql_query($sql_8,$conn) or die(mysql_error());
$result = mysql_query($sql_9,$conn) or die(mysql_error());
header("Location:install5.php?auto");
}
$sql = $sql_0.";\n";
$sql .= $sql_1.";\n";
$sql .= $sql_2.";\n";
$sql .= $sql_3.";\n";
$sql .= $sql_4.";\n";
$sql .= $sql_5.";\n";
$sql .= $sql_6.";\n";
$sql .= $sql_7.";\n";
$sql .= $sql_8.";\n";
$sql .= $sql_9.";\n";
?>
<!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>Untitled Document</title>
<script language=javascript>
<!--
function OnButton1()
{
	document.Form1.action = "install4.php?execute"
		// Open in a new window
	document.Form1.submit();			// Submit the page
	return true;
}

function OnButton2()
{
	document.Form1.action = "install5.php?manual"
	alert('You should now install the MySQL database. \n Please click "OK" when you are done.');	// Open in a new window
	document.Form1.submit();			// Submit the page
	return true;
}
-->
</script>
</head>

<body>
<div align="center">
  <p><strong>Step 4: Insert MySQL </strong><br />
    <br />
    Below is the exact MySQL entry that we will attempt to run on your database.<br />
    If you'd like to change any of this, or would like to manually inject it into the database,<br />
  please click the button below marked &quot;Manual Install &quot;.</p>
  <p>Username: <?= $_SESSION['u_name'] ?><br />
  Password: 
    <?= $_SESSION['u_pass'] ?>
  </p>
  <p>WARNING: If these aren't what you entered, please click <a href="install.php?clearcache">here</a>. </p>
  <textarea name="textarea" cols="100" rows="35"><?= $sql ?></textarea>
<br />
<form name=Form1 method=post>
  <p>Select Which Database you'd like to install ShoutCONTROL to:
    <select name=database>
      <?PHP
		$db_list = mysql_list_dbs($conn);

		while ($row = mysql_fetch_object($db_list)) {
    	 echo "<option value=\"".$row->Database."\">".$row->Database."</option>";
		}
	?>
      </select>
    </p>
  <p>
    <INPUT type="button" value="Automatic Install" name=button1 onClick="return OnButton1();">
      <INPUT type="button" value="Manual Install" name=button2 onClick="return OnButton2();">
    
      <!-- close the form -->
    </p>
</form>
<p>&nbsp;</p>
</div>
Return current item: phpSC