<?php
/****************************************
****** BKWORKS PRO PHP INTALL FILE ******
*LAST UPDATED DEC 18, 2007, 11:05 PM EST*
****************************************/
?>
<!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=utf-8" />
<title>Install Process - Step 1</title>
</head>
<body>
<?php
if($_POST) {
@unlink('../include/db_info.php');
$filehandle = fopen('../include/db_info.php','w');
$fwrite = "<?php\n";
$fwrite .= "// ProPHP by BKWorks Products\n";
$fwrite .= "// This page has been automatically created by the install script.\n";
$fwrite .= "// Do not delete it. Only change the information if the data has changed.\n";
$fwrite .= '$dbhost = "' . $_POST['db_host'] . "\";\n";
$fwrite .= '$dbuser = "' . $_POST['db_user'] . "\";\n";
$fwrite .= '$dbpass = "' . $_POST['db_pass'] . "\";\n";
$fwrite .= '$dbname = "' . $_POST['db_name'] . "\";\n";
$fwrite .= '$db = @mysql_connect($dbhost,$dbuser,$dbpass) or $error = mysql_error();
if(! $error) {
@mysql_select_db($dbname) or $error = mysql_error();
}';
$fwrite .= "\n?>";
fwrite($filehandle,$fwrite);
?>
<h3>Please wait while BKWorks ProPHP is installed.</h3>
<b>Starting the DB Connection</b><br />
<?php
include_once('../include/db_info.php');
if($error) {
echo "<font color=\"red\"><b>DB Connection Failed. Please check your include/db_info.php file.<br />
$error <br />
Installation has been halted.</b></font><br />";
} else {
echo "<font color=\"green\"><b>DB Connection Successful</b></font><br />";
$continue = 1;
}
$error = "";
?>
<b>Ending DB Connection</b><br /><br />
<b>Starting to Create DB Tables</b><br />
<?php
echo "<b>Table 'Ads'</b><br />";
if($continue) {
$query = "CREATE TABLE IF NOT EXISTS ads (
ad_number int(12) NOT NULL AUTO_INCREMENT PRIMARY KEY,
site_number int(12) NOT NULL,
width int(4) NOT NULL,
height int(4) NOT NULL,
image text NOT NULL,
alt_text text NOT NULL,
ad_goto text NOT NULL,
clicks int(12) NOT NULL
)";
@mysql_query($query) or $error = mysql_error();
if($error) {
echo "<font color=\"red\"><b>An Error has Occured: " . $error . "<br>
Installation has been halted.</b></font><br />";
$continue = 0;
} else {
echo "<font color=\"green\"><b>Table 'Ads' created successfully.</b></font><br />";
}
} else {
echo "Due to previous failure, we're not eveing going to attempt this. <br />";
}
$error = "";
echo "<b>Table 'Settings'</b><br />";
if($continue) {
$query = "CREATE TABLE IF NOT EXISTS settings (
always_one tinyint(1) NOT NULL,
install_url varchar(37000) NOT NULL,
reg_success_msg text NOT NULL
)";
@mysql_query($query) or $error = mysql_error();
if($error) {
echo "<font color=\"red\"><b>An error has occured: " . $error . "<br />Installation has been halted.</b></font><br />";
$continue = 0;
} else {
echo "<font color=\"green\"><b>Table 'Settings' created successfully.</b></font><br />";
$continue = 1;
}
} else {
echo "Due to a previous failure, we're not even going to attempt this. <br />";
}
$error = "";
echo "<b>Table 'Sites'</b><br />";
if($continue) {
$query = "CREATE TABLE IF NOT EXISTS sites (
site_url varchar(255) NOT NULL,
site_number int(6) NOT NULL AUTO_INCREMENT PRIMARY KEY,
password varchar(255) NOT NULL,
acct_status tinyint(1) NOT NULL DEFAULT 0,
ad_servs int(10) NOT NULL DEFAULT 0
)";
@mysql_query($query) or $error = mysql_error();
if($error) {
echo "<font color=\"red\"><b>An error has occured: " . $error . "<br />Installation has been halted.</b></font><br />";
$continue = 0;
} else {
echo "<font color=\"green\"><b>Table 'Sites' created successfully.</b></font><br />";
$continue = 1;
}
} else {
echo "Due to a previous failure, we're not even going to attempt this. <br />";
}
$error = "";
?>
<b>End Table Creation</b><br /><br />
<b>Starting to Add Data to Database</b><br />
<?php
if($continue) {
$query = "INSERT INTO sites (
site_url,
site_number,
password,
acct_status,
ad_servs
) VALUES (
'admin',
'1',
'" . md5("bkworks") . "',
'0',
'0'
)";
@mysql_query($query) or $error = mysql_error();
$query = "INSERT INTO settings (
always_one
) VALUES (
'1'
)";
@mysql_query($query) or $error .= mysql_error();
$error = "";
$query = "UPDATE settings SET
reg_success_msg = 'Welcome to our ad-swap!<br />Please remember that with all ad-swap networks, you must add ad scripts to your web site, else your account will be deleted.'
WHERE always_one = '1'";
@mysql_query($query) or $error .= mysql_error();
if($error) {
echo ("<font color=\"red\"><b>An error has occured: " . $error . "<br />Installation has been halted.</b></font><br />");
$continue = 0;
} else {
echo "<font color=\"green\"><b>Data has been inserted correctly.<br />Your username is 'admin' and your password is 'bkworks'.</b></font><br />";
$continue = 1;
}
} else {
echo "Due to a previous failure, we're not even going to attempt this.<br />";
}
?>
<b>End Adding Data</b><br /><br />
<?php
if($continue) {
echo "Installation has completed succesfully.<br />
<a href=\"../?view=logon\">Click here to go to the logon page.</a>";
@mkdir('../ads/1/');
@unlink('install.php');
} else {
echo "<font color=\"red\">Installation has failed.<br />Make sure to look at the error mesages above to figure out what went wrong.<br />
<a href=\"\">Click here to try installation again.</a>";
}
} else {
?>
<h3>Installing ProPHP</h3>
To continue, we need your database information.<br />
Please insert your database name, username, password, and host into the boxes below.<br />
<form action="" method="post">
Database Username:<br />
<input type="text" name="db_user" /><br />
Database Password:<br />
<input type="password" name="db_pass" /><br />
Database Name:<br />
<input type="text" name="db_name" /><br />
Database Host (normally left localhost):<br />
<input type="text" name="db_host" value="localhost" /><br />
<input type="submit" value="Use these values" />
</form>
<?php } ?>
</p>
</body>
</html>