Location: PHPKode > scripts > SHDetect > joshf-SHDetect-f0c6c96/installer/install.php
<!-- SHDetect, Copyright Josh Fradley (http://github.com/joshf/SHDetect) -->
<html>
<head>
<title>SHDetect: Installer</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta name="robots" content="noindex, nofollow">
<link rel="stylesheet" type="text/css" href="../style.css" />
</head>
<body>
<?php

if (!isset($_POST["doinstall"])) {
    die("<h1>SHTracker: Error</h1><p>This installer can not be called directly!</p><hr /><p><a href=\"../installer\">Go To Installer</a></p></body></html>");
}

//Get new settings from POST
$dbhost = $_POST["dbhost"];
$dbuser = $_POST["dbuser"];
$dbpassword = $_POST["dbpassword"];
$dbname = $_POST["dbname"];
$adminuser = $_POST["adminuser"];
$adminemail= $_POST["adminemail"];
$adminpassword = sha1($_POST["adminpassword"]);
$appname = $_POST["appname"];
$appversion = $_POST["appversion"];
$appbuild = $_POST["appbuild"];
$field1 = strtolower($_POST["field1"]);
$field2 = strtolower($_POST["field2"]);
$field3 = strtolower($_POST["field3"]);
$pathtoscript = $_POST["pathtoscript"];
$uniquekey = str_shuffle("abcdefghijklmnopqrstuvwxyz123456789");

$installstring = "<?php

//Database Settings
define(\"DB_HOST\", \"$dbhost\");
define(\"DB_USER\", \"$dbuser\");
define(\"DB_PASSWORD\", \"$dbpassword\");
define(\"DB_NAME\", \"$dbname\");

//Admin Details
define(\"ADMIN_USER\", \"$adminuser\");
define(\"ADMIN_EMAIL\", \"$adminemail\");
define(\"ADMIN_PASSWORD\", \"$adminpassword\");

//App Settings
define(\"APP_NAME\", \"$appname\");
define(\"APP_VERSION\", \"$appversion\");
define(\"APP_BUILD\", \"$appbuild\");
define(\"FIELD_1\", \"$field1\");
define(\"FIELD_2\", \"$field2\");
define(\"FIELD_3\", \"$field3\");
define(\"VERSION_RESPONSE_STATE\", \"Disabled\");

//Other Settings
define(\"PATH_TO_SCRIPT\", \"$pathtoscript\");
define(\"UNIQUE_KEY\", \"$uniquekey\");
define(\"JQUERY_THEME\", \"base\");

?>";

//Check if we can connect
$con = mysql_connect($dbhost, $dbuser, $dbpassword);
if (!$con) {
    die("<h1>SHDetect: Install Failed</h1><p>Could not connect to database: " . mysql_error() . ". Please go back and try again.</p><hr /><p><a href=\"javascript:history.go(-1)\">&larr; Go Back</a></p></body></html>");
}

//Check if database exists
$does_db_exist = mysql_select_db($dbname, $con);
if (!$does_db_exist) {
    die("<h1>SHDetect: Install Failed</h1><p>Database does not exist: " . mysql_error() . ". Please go back and try again.</p><hr /><p><a href=\"javascript:history.go(-1)\">&larr; Go Back</a></p></body></html>");
}

//Create Data table
$createtable = "CREATE TABLE Data (
Version VARCHAR(10) NOT NULL,
Field1 VARCHAR(10) NOT NULL,
Field2 VARCHAR(10) NOT NULL,
Date VARCHAR(10) NOT NULL,  	
Field3 VARCHAR(10) NOT NULL,
Count INT(10) NOT NULL default \"0\"
) ENGINE = MYISAM;";

//Run query
mysql_query($createtable);

//Write Config
$configfile = fopen("../config.php", "w");
fwrite($configfile, $installstring);
fclose($configfile);

mysql_close($con);
 
?>
<h1>SHDetect: Install Complete</h1>
<p>SHDetect has been successfully installed. Please delete the "installer" folder from your server, as it poses a potential security risk!</p>
<p><a href="../admin">Go To Login</a></p>
</body>
</html>
Return current item: SHDetect