Location: PHPKode > scripts > SHDetect > joshf-SHDetect-f0c6c96/admin/settings.php
<?php

//SHDetect, Copyright Josh Fradley (http://github.com/joshf/SHDetect)

require_once("../config.php");

$uniquekey = UNIQUE_KEY;

session_start();
if (!isset($_SESSION["is_logged_in_" . $uniquekey . ""])) {
    header("Location: login.php");
    exit; 
}

//Get current settings
$currentadminuser = ADMIN_USER;
$currentadminemail = ADMIN_EMAIL;
$currentadminpassword = ADMIN_PASSWORD;
$currentappname = APP_NAME;
$currentappversion = APP_VERSION;
$currentappbuild = APP_BUILD;
$currentversionresponsestate = VERSION_RESPONSE_STATE;
$currentpathtoscript = PATH_TO_SCRIPT;
$currentjquerytheme = JQUERY_THEME;

if (isset($_POST["Save"])) {

//Get new settings from POST
$adminuser = $_POST["adminuser"];
if (empty($adminuser)) {
    $adminuser = $currentadminuser;
}
$adminemail = $_POST["adminemail"];
$adminpassword = $_POST["adminpassword"];
if (empty($adminpassword)) {
    $adminpassword = $currentadminpassword;
}
if ($adminpassword != $currentadminpassword) {
    $adminpassword = sha1($adminpassword);
}
$appname = $_POST["appname"];
$appversion = $_POST["appversion"];
$appbuild = $_POST["appbuild"];
$versionresponsestate = $_POST["versionresponsestate"];
$pathtoscript = $_POST["pathtoscript"];
$jquerytheme = $_POST["jquerytheme"];

$settingsstring = "<?php

//Database Settings
define(\"DB_HOST\", \"" . DB_HOST . "\");
define(\"DB_USER\", \"" . DB_USER . "\");
define(\"DB_PASSWORD\", \"" . DB_PASSWORD . "\");
define(\"DB_NAME\", \"" . DB_NAME . "\");

//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\", \"" . FIELD_1 . "\");
define(\"FIELD_2\", \"" . FIELD_2 . "\");
define(\"FIELD_3\", \"" . FIELD_3 . "\");
define(\"VERSION_RESPONSE_STATE\", \"$versionresponsestate\");

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

?>";

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

//Show updated values
header("Location: " . $_SERVER["REQUEST_URI"] . "");

}
 
?>
<html>
<head>
<title>SHDetect: Settings</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>
<h1>SHDetect: Settings</h1>
<form method="post">
<p><b>Admin Details:</b></p>
<p>User: <input type="text" name="adminuser" value="<? echo $currentadminuser; ?>" /><br />
Email: <input type="text" name="adminemail" value="<? echo $currentadminemail; ?>" /><br />
Password: <input type="password" name="adminpassword" value="<? echo $currentadminpassword; ?>" /></p>
<p><b>App Settings:</b></p>
<p>App Name: <input type="text" name="appname" value="<? echo $currentappname; ?>" /><br />
App Version: <input type="text" name="appversion" value="<? echo $currentappversion; ?>" /><br />
App Build: <input type="text" name="appbuild" value="<? echo $currentappbuild; ?>" /><br />
<p><b>Version Response:</b></p>
<p><small>BETA:</small> Rather than return logged values, return a 1 if an update is available or a 0 if app is up to date. Currently gets version from the version field.</p>
<?php
if ($currentversionresponsestate == "Enabled" ) {
    echo "<p><input type=\"radio\" name=\"versionresponsestate\" value=\"Enabled\" checked/> Enabled<br />
    <input type=\"radio\" name=\"versionresponsestate\" value=\"Disabled\" /> Disabled</p>";
} else {
    echo "<p><input type=\"radio\" name=\"versionresponsestate\" value=\"Enabled\" /> Enabled<br />
    <input type=\"radio\" name=\"versionresponsestate\" value=\"Disabled\" checked/> Disabled</p>";
}
?>
<p><b>Other Settings:</b></p>
<p>Path to Script: <input type="text" name="pathtoscript" value="<? echo $currentpathtoscript; ?>" /></p>
<p><b>jQuery Theme:</b></p>
<?php
 
echo "<p>Current theme: <b>" . ucfirst($currentjquerytheme) . "</b></p>";

$themes = array("base", "black-tie", "blitzer", "cupertino", "dark-hive", "dot-luv", "eggplant", "excite-bike", "flick", "hot-sneaks", "humanity", "le-frog", "mint-choc", "overcast", "pepper-grinder", "redmond", "smoothness", "south-street", "start", "sunny", "swanky-purse", "trontastic", "ui-darkness", "ui-lightness", "vader");

echo "<p><select name=\"jquerytheme\">";
foreach ($themes as $value) {
    echo "<option value=\"$value\">". ucfirst($value) . "</option>";
}
echo "</select></p>";

?>
<p><input type="submit" name="Save" value="Save" /></p>
</form>
<hr />
<p><a href="../admin">&larr; Go Back</a></p>
</body>
</html>
Return current item: SHDetect