Skip to content

Commit

Permalink
first commit
Browse files Browse the repository at this point in the history
stable version 1.0
  • Loading branch information
deepwather committed Apr 27, 2016
1 parent 5fe9a46 commit cad1e05
Show file tree
Hide file tree
Showing 82 changed files with 15,211 additions and 0 deletions.
166 changes: 166 additions & 0 deletions config/login.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,166 @@
<?php
###############################################################
# Page Password Protect 1.1
###############################################################
# By Michael Reber - swiss
###############################################################
#
# Usage:
# Set usernames / passwords below between SETTINGS START and SETTINGS END.
#
###############################################################

/*
-------------------------------------------------------------------
SAMPLE if you only want to request login and password on login form.
Each row represents different user.
$LOGIN_INFORMATION = array(
'michael' => 'ro5otj57',
'test' => 'samplepass',
'admin' => 'passwd'
);
--------------------------------------------------------------------
SAMPLE if you only want to request only password on login form.
Note: only passwords are listed
$LOGIN_INFORMATION = array(
'ro5otj57',
'samplepass',
'passwd'
);
--------------------------------------------------------------------
*/

##################################################################
# SETTINGS START
##################################################################

// Add login/password pairs below, like described above
// NOTE: all rows except last must have comma "," at the end of line
$LOGIN_INFORMATION = array(
'plexDash'
);

// request login? true - show login and password boxes, false - password box only
define('USE_USERNAME', false);

// User will be redirected to this page after logout
define('LOGOUT_URL', 'index.php');

// time out after NN minutes of inactivity. Set to 0 to not timeout
define('TIMEOUT_MINUTES', 0);

// This parameter is only useful when TIMEOUT_MINUTES is not zero
// true - timeout time from last activity, false - timeout time from login
define('TIMEOUT_CHECK_ACTIVITY', true);

##################################################################
# SETTINGS END
##################################################################


///////////////////////////////////////////////////////
// do not change code below
///////////////////////////////////////////////////////

// show usage example
if(isset($_GET['help'])) {
die('Include following code into every page you would like to protect, at the very beginning (first line):<br>&lt;?php include("' . str_replace('\\','\\\\',__FILE__) . '"); ?&gt;');
}

// timeout in seconds
$timeout = (TIMEOUT_MINUTES == 0 ? 0 : time() + TIMEOUT_MINUTES * 60);

// logout?
if(isset($_GET['logout'])) {
setcookie("verify", '', $timeout, '/'); // clear password;
header('Location: ' . LOGOUT_URL);
exit();
}

if(!function_exists('showLoginPasswordProtect')) {

// show login form
function showLoginPasswordProtect($error_msg) {
?>
<html>
<head>
<title>Welcome to plexDash!</title>
<META HTTP-EQUIV="CACHE-CONTROL" CONTENT="NO-CACHE">
<META HTTP-EQUIV="PRAGMA" CONTENT="NO-CACHE">
<link href="css/bootstrap.css" type="text/css" rel="stylesheet">
<link href="css/login.css" type="text/css" rel="stylesheet">

<link rel="shortcut icon" href="img/favicon.ico">
</head>
<body onLoad="document.getElementsByTagName('input')[0].focus();">
<div class="container">
<div class="row">
<form method="post">
<font color="red"><?php echo $error_msg; ?></font><br />
<?php if (USE_USERNAME) echo 'login:<br /><input type="input" name="access_login" /><br />password:<br />'; ?>
<label><span>Passwort:</span><input type="password" name="access_password" /><label><p></p><input type="submit" name="Submit" value="Submit" />
</form>
</div>
</div>
<br />
<script src="js/bootstrap.min.js"></script>
</body>
</html>

<?php
// stop at this point
die();
}
}

// user provided password
if (isset($_POST['access_password'])) {

$login = isset($_POST['access_login']) ? $_POST['access_login'] : '';
$pass = $_POST['access_password'];
if (!USE_USERNAME && !in_array($pass, $LOGIN_INFORMATION)
|| (USE_USERNAME && ( !array_key_exists($login, $LOGIN_INFORMATION) || $LOGIN_INFORMATION[$login] != $pass ) )
) {
showLoginPasswordProtect("wrong password!");
}
else {
// set cookie if password was validated
setcookie("verify", md5($login.'%'.$pass), $timeout, '/');

// Some programs (like Form1 Bilder) check $_POST array to see if parameters passed
// So need to clear password protector variables
unset($_POST['access_login']);
unset($_POST['access_password']);
unset($_POST['Submit']);
}
}

else {
// check if password cookie is set
if (!isset($_COOKIE['verify'])) {
showLoginPasswordProtect("");
}

// check if cookie is good
$found = false;
foreach($LOGIN_INFORMATION as $key=>$val) {
$lp = (USE_USERNAME ? $key : '') .'%'.$val;
if ($_COOKIE['verify'] == md5($lp)) {
$found = true;
// prolong timeout
if (TIMEOUT_CHECK_ACTIVITY) {
setcookie("verify", md5($lp), $timeout, '/');
}
break;
}
}
if (!$found) {
showLoginPasswordProtect("");
}
}

?>
6 changes: 6 additions & 0 deletions css/animate.css

Large diffs are not rendered by default.

Loading

0 comments on commit cad1e05

Please sign in to comment.