config tool creation

This commit is contained in:
Karl Hudgell 2015-07-28 09:11:06 +01:00
parent 1a279ce0aa
commit 3e2552d5ec
7 changed files with 232 additions and 79 deletions

View File

@ -1,3 +1 @@
git.exe stash
git.exe pull
git.exe stash pop
git.exe pull

8
config/index.php Normal file
View File

@ -0,0 +1,8 @@
<html>
<head>
<meta HTTP-EQUIV="REFRESH" content="3; url=/config/redirect.html">
</head>
<body>
Your config has been updated, the page will reload with new entries..
</body>
</html>

8
config/redirect.html Normal file
View File

@ -0,0 +1,8 @@
<html>
<head>
<meta HTTP-EQUIV="REFRESH" content="2; url=/config/set.php">
</head>
<body>
Your config is being loaded, please wait..
</body>
</html>

31
config/set.php Normal file
View File

@ -0,0 +1,31 @@
<?php include '../config.php';?>
<form action="write.php" method="post">
Your Name: <input type="text" value="<?php echo $yourname ?>" name="YN" /><br />
Server Address: <input type="text" value="<?php echo $base ?>" name="YB" /><br />
<br />
Username: <input type="text" value="<?php echo $user ?>" name="user" /><br />
Password: <input type="text" value="<?php echo $pass ?>" name="pass" /><br />
<br />
SAB Enabled: <input name="sabvisible" id="id" type="checkbox" <?php if($sabvisible > "0") echo "checked=checked; "; ?> /><br />
SAB Port: <input type="text" value="<?php echo $sabport ?>" name="sabport" /><br />
SAB Name: <input type="text" value="<?php echo $sabname ?>" name="sabname" /><br />
SAB Pic: <input type="text" value="<?php echo $sabpicname ?>" name="sabpicname" /><br />
<br />
Sick Enabled: <input name="sickvisible" id="id" type="checkbox" <?php if($sickvisible > "0") echo "checked=checked; "; ?> /><br />
Sick Type : <input type="radio" name="sicktype" value="1" <?php if($sicktype < "2") echo "checked=checked; "; ?>>SickBeard / <input type="radio" name="sicktype" value="2" <?php if($sicktype > "1") echo "checked=checked; "; ?>>SickRage<br />
Sick Port: <input type="text" value="<?php echo $sickport ?>" name="sickport" /><br />
Sick Name: <input type="text" value="<?php echo $sickname ?>" name="sickname" /><br />
Sick Pic: <input type="text" value="<?php echo $sickpicname ?>" name="sickpicname" /><br />
<br />
Couch Enabled: <input name="couchvisible" id="id" type="checkbox" <?php if($couchvisible > "0") echo "checked=checked; "; ?> /><br />
Couch Adults : <input type="radio" name="cpadultsvisible" value="1" <?php if($cpadultsvisible > "0") echo "checked=checked; "; ?>>Enabled / <input type="radio" name="cpadultsvisible" value="2" <?php if($cpadultsvisible < "1") echo "checked=checked; "; ?>>Disabled<br />
Couch Adults Port: <input type="text" value="<?php echo $cpadults ?>" name="cpadults" /><br />
Couch Adults Name: <input type="text" value="<?php echo $cpadultsname ?>" name="cpadultsname" /><br />
Couch Adults Pic: <input type="text" value="<?php echo $cpadultspicname ?>" name="cpadultspicname" /><br />
Couch Kids : <input type="radio" name="cpkidsvisible" value="1" <?php if($cpkidsvisible > "0") echo "checked=checked; "; ?>>Enabled / <input type="radio" name="cpkidsvisible" value="2" <?php if($cpkidsvisible < "1") echo "checked=checked; "; ?>>Disabled<br />
Couch Kids Port: <input type="text" value="<?php echo $cpkids ?>" name="cpkids" /><br />
Couch Kids Name: <input type="text" value="<?php echo $cpkidsname ?>" name="cpkidsname" /><br />
Couch Kids Pic: <input type="text" value="<?php echo $cpkidspicname ?>" name="cpkidspicname" /><br />
<input type="submit" name="submit" value="Update" />
</form>

100
config/write.php Normal file
View File

@ -0,0 +1,100 @@
<?php
$yn = $_POST['YN'];
$yb = $_POST['YB'];
$user1 = $_POST['user'];
$pass1 = $_POST['pass'];
$sabvis1 = $_POST['sabvisible'];
$sabport1 = $_POST['sabport'];
$sabname1 = $_POST['sabname'];
$sabpicname1 = $_POST['sabpicname'];
$sickvis1 = $_POST['sickvisible'];
$sicktype1 = $_POST['sicktype'];
$sickname1 = $_POST['sickname'];
$sickpicname1 = $_POST['sickpicname'];
$sickport1 = $_POST['sickport'];
$couchvisible1 = $_POST['couchvisible'];
$cpadultsvisible1 = $_POST['cpadultsvisible'];
$cpadultsname1 = $_POST['cpadultsname'];
$cpadultspicname1 = $_POST['cpadultspicname'];
$cpadults1 = $_POST['cpadults'];
$cpkidsvisible1 = $_POST['cpkidsvisible'];
$cpkidsname1 = $_POST['cpkidsname'];
$cpkidspicname1 = $_POST['cpkidspicname'];
$cpkids1 = $_POST['cpkids'];
//
$fl='../config.php';
/*read operation ->*/ $tmp = fopen($fl, "r"); $content=fread($tmp,filesize($fl)); fclose($tmp);
// here goes your update
// Server Updates
$content = preg_replace( '/\$yourname = \"(.*?)\";/', '$yourname = "'.$yn.'";', $content);
$content = preg_replace( '/\$base = \"(.*?)\";/', '$base = "'.$yb.'";', $content);
// User/Pass Update
$content = preg_replace( '/\$user = \"(.*?)\";/', '$user = "'.$user1.'";', $content);
$content = preg_replace( '/\$pass = \"(.*?)\";/', '$pass = "'.$pass1.'";', $content);
// SAB Settings
// SAB Visible Update
if (empty($sabvis1)) {
$content = preg_replace( '/\$sabvisible = \"(.*?)\";/', '$sabvisible = "0";', $content);
} else {
$content = preg_replace( '/\$sabvisible = \"(.*?)\";/', '$sabvisible = "1";', $content);
}
$content = preg_replace( '/\$sabport = \"(.*?)\";/', '$sabport = "'.$sabport1.'";', $content);
$content = preg_replace( '/\$sabname = \"(.*?)\";/', '$sabname = "'.$sabname1.'";', $content);
$content = preg_replace( '/\$sabpicname = \"(.*?)\";/', '$sabpicname = "'.$sabpicname1.'";', $content);
// End of SAB Settings
// Sick Settings
// Sick Visible Update
if (empty($sickvis1)) {
$content = preg_replace( '/\$sickvisible = \"(.*?)\";/', '$sickvisible = "0";', $content);
} else {
$content = preg_replace( '/\$sickvisible = \"(.*?)\";/', '$sickvisible = "1";', $content);
}
// Sick Type Update
if ($sicktype1 > "1") {
$content = preg_replace( '/\$sicktype = \"(.*?)\";/', '$sicktype = "2";', $content);
} else {
$content = preg_replace( '/\$sicktype = \"(.*?)\";/', '$sicktype = "1";', $content);
}
$content = preg_replace( '/\$sickport = \"(.*?)\";/', '$sickport = "'.$sickport1.'";', $content);
$content = preg_replace( '/\$sickname = \"(.*?)\";/', '$sickname = "'.$sickname1.'";', $content);
$content = preg_replace( '/\$sickpicname = \"(.*?)\";/', '$sickpicname = "'.$sickpicname1.'";', $content);
// End of Sick Settigns
// Couch Settings
// CPAdults Visible Update
if (empty($couchvisible1)) {
$content = preg_replace( '/\$couchvisible = \"(.*?)\";/', '$couchvisible = "0";', $content);
} else {
$content = preg_replace( '/\$couchvisible = \"(.*?)\";/', '$couchvisible = "1";', $content);
}
// CPAdults Update
if ($cpadultsvisible1 > "1") {
$content = preg_replace( '/\$cpadultsvisible = \"(.*?)\";/', '$cpadultsvisible = "0";', $content);
} else {
$content = preg_replace( '/\$cpadultsvisible = \"(.*?)\";/', '$cpadultsvisible = "1";', $content);
}
$content = preg_replace( '/\$cpadultsname = \"(.*?)\";/', '$cpadultsname = "'.$cpadultsname1.'";', $content);
$content = preg_replace( '/\$cpadultspicname = \"(.*?)\";/', '$cpadultspicname = "'.$cpadultspicname1.'";', $content);
$content = preg_replace( '/\$cpadults = \"(.*?)\";/', '$cpadults = "'.$cpadults1.'";', $content);
// CPKids Visible Update
if ($cpkidsvisible1 > "1") {
$content = preg_replace( '/\$cpkidsvisible = \"(.*?)\";/', '$cpkidsvisible = "0";', $content);
} else {
$content = preg_replace( '/\$cpkidsvisible = \"(.*?)\";/', '$cpkidsvisible = "1";', $content);
}
$content = preg_replace( '/\$cpkidsname = \"(.*?)\";/', '$cpkidsname = "'.$cpkidsname1.'";', $content);
$content = preg_replace( '/\$cpkidspicname = \"(.*?)\";/', '$cpkidspicname = "'.$cpkidspicname1.'";', $content);
$content = preg_replace( '/\$cpkids = \"(.*?)\";/', '$cpkids = "'.$cpkids1.'";', $content);
// End of Couch Settigns
/*write operation ->*/ $tmp =fopen($fl, "w"); fwrite($tmp, $content); fclose($tmp);
//sleep for 5 seconds
header("Location: index.php");
die();
?>

View File

@ -1,78 +1,8 @@
<!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" />
<script type="text/javascript" src="//ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>
<link rel="stylesheet" type="text/css" href="css/white.css" />
<link rel="alternate stylesheet" type="text/css" media="screen" title="black" href="css/black.css" />
<link rel="alternate stylesheet" type="text/css" media="screen" title="white" href="css/white.css" />
<link rel="alternate stylesheet" type="text/css" media="screen" title="blue" href="css/blue.css" />
<script type="text/javascript">
window.onload=function(){
var formref=document.getElementById("switchform")
indicateSelected(formref.switchcontrol)
}
</script>
<!--This script should appear below your LINK stylesheet tags -->
<script src="styleswitch.js" type="text/javascript">
/***********************************************
* Style Sheet Switcher v1.1- © Dynamic Drive DHTML code library (www.dynamicdrive.com)
* This notice MUST stay intact for legal use
* Visit Dynamic Drive at http://www.dynamicdrive.com/ for this script and 100s more
***********************************************/
</script>
<?php include 'config.php';?>
<?php echo "<title>$yourname's Server Access</title>";?>
</head>
<?php
$username = "$user";
$password = "$pass";
$nonsense = "superkey";
if (isset($_COOKIE['PrivatePageLogin'])) {
if ($_COOKIE['PrivatePageLogin'] == md5($password.$nonsense)) {
?>
<frameset cols="200,*,300" frameborder="0" border="0" framespacing="0">
<frame src="left.php" name="left" >
<frame src="main.php" name="main" >
<frame src="right.php" name="right" >
</frameset>
<?php
exit;
} else {
echo "Bad Cookie.";
exit;
}
include 'config.php';
if (empty($base)) {
require "/config/index.php";
} else {
require "index2.php";
}
if (isset($_GET['p']) && $_GET['p'] == "login") {
if ($_POST['user'] != $username) {
echo "Sorry, that username does not match.";
exit;
} else if ($_POST['keypass'] != $password) {
echo "Sorry, that password does not match.";
exit;
} else if ($_POST['user'] == $username && $_POST['keypass'] == $password) {
setcookie('PrivatePageLogin', md5($_POST['keypass'].$nonsense));
header("Location: $_SERVER[PHP_SELF]");
} else {
echo "Sorry, you could not be logged in at this time.";
}
}
?>
Home Server Logon.
<form action="<?php echo $_SERVER['PHP_SELF']; ?>?p=login" method="post">
<label><input type="text" name="user" id="user" /> Name</label><br />
<label><input type="password" name="keypass" id="keypass" /> Password</label><br />
<input type="submit" id="submit" value="Login" />
</form>
<body>
</body>
</html>
?>

78
index2.php Normal file
View File

@ -0,0 +1,78 @@
<!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" />
<script type="text/javascript" src="//ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>
<link rel="stylesheet" type="text/css" href="css/white.css" />
<link rel="alternate stylesheet" type="text/css" media="screen" title="black" href="css/black.css" />
<link rel="alternate stylesheet" type="text/css" media="screen" title="white" href="css/white.css" />
<link rel="alternate stylesheet" type="text/css" media="screen" title="blue" href="css/blue.css" />
<script type="text/javascript">
window.onload=function(){
var formref=document.getElementById("switchform")
indicateSelected(formref.switchcontrol)
}
</script>
<!--This script should appear below your LINK stylesheet tags -->
<script src="styleswitch.js" type="text/javascript">
/***********************************************
* Style Sheet Switcher v1.1- © Dynamic Drive DHTML code library (www.dynamicdrive.com)
* This notice MUST stay intact for legal use
* Visit Dynamic Drive at http://www.dynamicdrive.com/ for this script and 100s more
***********************************************/
</script>
<?php include 'config.php';?>
<?php echo "<title>$yourname's Server Access</title>";?>
</head>
<?php
$username = "$user";
$password = "$pass";
$nonsense = "superkey";
if (isset($_COOKIE['PrivatePageLogin'])) {
if ($_COOKIE['PrivatePageLogin'] == md5($password.$nonsense)) {
?>
<frameset cols="200,*,300" frameborder="0" border="0" framespacing="0">
<frame src="left.php" name="left" >
<frame src="main.php" name="main" >
<frame src="right.php" name="right" >
</frameset>
<?php
exit;
} else {
echo "Bad Cookie.";
exit;
}
}
if (isset($_GET['p']) && $_GET['p'] == "login") {
if ($_POST['user'] != $username) {
echo "Sorry, that username does not match.";
exit;
} else if ($_POST['keypass'] != $password) {
echo "Sorry, that password does not match.";
exit;
} else if ($_POST['user'] == $username && $_POST['keypass'] == $password) {
setcookie('PrivatePageLogin', md5($_POST['keypass'].$nonsense));
header("Location: $_SERVER[PHP_SELF]");
} else {
echo "Sorry, you could not be logged in at this time.";
}
}
?>
Home Server Logon.
<form action="<?php echo $_SERVER['PHP_SELF']; ?>?p=login" method="post">
<label><input type="text" name="user" id="user" /> Name</label><br />
<label><input type="password" name="keypass" id="keypass" /> Password</label><br />
<input type="submit" id="submit" value="Login" />
</form>
<body>
</body>
</html>