Beruflich Dokumente
Kultur Dokumente
php
error_reporting(0);
# Start a new session, regenerate a session id if needed.
session_start();
if (!isset($_SESSION['INIT'])) {
session_regenerate_id();
$_SESSION['INIT'] = TRUE;
}
class JC_fsl {
public static $_init;
protected $_users = array();
# Script configuration
protected static $_script_name;
protected static $_admin_email;
protected static $_admin_name;
private static $_version = '{Version 2.0.1}';
protected function __construct() {
if (!isset($_SESSION['LOGIN_ATTEMPTS']))
$_SESSION['LOGIN_ATTEMPTS'] = 0;
// Default user admin added.
$this->_users = array(
array(
'USERNAME' => 'BR3',
'PASSWORD' => 'starbr3',
'EMAIL' => 'admin@nos.starffi.com',
'LOCATION' => 'index2.php')
);
}
public function __toString() {
return 'SCRIPT NAME :: ' . self::$_script_name . "<br />" .
' ADMIN EMAIL :: ' . self::$_admin_email . "<br />" .
' ADMIN NAME :: ' . self::$_admin_name . "<br />" .
' FSL VERSION :: ' . self::$_version;
}
/**
* This method allows you to peek inside the users list, so you can view
their information.
**/
public function peek() {
var_dump($this->_users);
}
protected function ready_array($username, $password, $email, $location =
'index2.php', $access = false) {
return array('USERNAME' => $username, 'PASSWORD' => $password, '
EMAIL' => $email, 'LOCATION' => $location);
}
public function add($username, $password, $email, $location = 'index2.ph
p') {
* and the user will be sent a password reminder. Please note that not o
f these passwords
* are hashed meaning this is not a good idea to store personal informat
ion behind this script!
* @param <string> The users email address.
* @return <bool> Returns true upon success.
*/
public function forgot($email) {
for ($i=0;$i<count($this->_users);$i++) {
if (array_key_exists('EMAIL', $this->_users[$i])) {
if ($this->_users[$i]['EMAIL'] == $email)
$info = $this->_users[$i];
} else return false;
}
if (isset($info) && is_array($info)) {
# Send the user their password
$to = $info['EMAIL'];
$subject = 'You recently forgot your password | ' . self
::$_script_name;
$message = 'Hi ' . $info['USERNAME'] . ', ' . "\n\n";
$message .= 'You recently requested your password for '
. self::$_script_name . ' if you didn\'t not to worry just ignore this ';
$message .= 'email. Anyway you can find your email below
, should you require anymore assistance then please contact us ';
$message .= 'at ' . self::$_admin_email . ".\n\n";
$message .= 'Username: ' . $info['USERNAME'] . "\n";
$message .= 'Password: ' . $info['PASSWORD'];
$message .= "\n\n" . 'Best Regards, ' . "\n" . self::$_a
dmin_name;
$headers = 'From: ' . self::$_admin_email . "\r\n" .
'Reply-To: ' . self::$_admin_email . "\r\n" .
'X-Mailer: PHP/' . phpversion();
# Uncomment for final version
if (mail($to, $subject, $message, $headers)) return true
;
}
}
/**
* The secure method, simply call this to lock any page down it's as sim
ple as that.
* @param <string> Name of the script EG: John's Script
* @param <string> Email of the administrator EG: john@suburbanarctic.co
m
* @param <string> Admin name EG: John Crossley
* @return <object> Returns an instanciated object of this class.
*/
public static function secure($s_name = 'EDGE FUN FOR KIDS 2014', $a_ema
il = 'admin@nos.starffi.com', $a_name = 'DFM MOBILE') {
self::$_script_name = $s_name;
self::$_admin_email = $a_email;
self::$_admin_name = $a_name;
if (!self::$_init instanceof JC_fsl) {
self::$_init = new JC_fsl();
}
return self::$_init;
}
}
# You may edit me
$secure = JC_fsl::secure();
##########################################################################
########################## YOUR EDITING BLOCK ###########################
$secure->add('star', 'landmark2014', 'admin@starffi.com', 'starffi.com');
##########################################################################
##########################################################################
############ FORM PROCESSING ############
if (isset($_POST['username']) && isset($_POST['password'])) {
$secure->validate($_POST['username'], $_POST['password']);
}
if (isset($_GET['logout'])) $secure->logout();
if (isset($_POST['forgot_password_button']) && isset($_POST['email'])) {
// We need to send the user their password.
if ($secure->forgot($_POST['email'])) {
echo '<h2 class=\'success\'>Your password has been sent to your
email address!</h2>';
} else {
echo '<h2 class=\'error\'>I\'m sorry but that email address has
no record on this site.</h2>';
}
}
?>
<?php if(!isset($_SESSION['LOGGED_IN'])): ?>
<style type='text/css'>
#fslv2-main{
font-family:HelveticaNeue-Light, "Helvetica Neue Light",
"Helvetica Neue", Helvetica, Arial, "Lucida Grande", sans-serif;font-weight:300
;font-size:14px;line-height:1.6;
width: 300px;
margin: 2em auto;
border: 1px solid #e5e5e5;
background-color: #f5f5f5;
border-radius: 3px;
padding: 10px 10px 5px 10px;
}
fieldset { border: none; margin: 0; padding: 0;}
.fslv2 .input {
border: 1px solid #b9b9b9;
padding: 5px;
width: 225px;
outline: none;
font-size: 13px;
}
.fslv2 label {
float: left;
width: 72px;
line-height: 28px;
}
h3 { font-weight: normal; }
a { color: #b0281a; text-decoration: none; }
padding: 5px;
background-color: #ea7e7e;
width: 400px;
text-align: center;
-webkit-border-radius: 5px;
-moz-border-radius: 5px;
border-radius: 5px;
font-weight: normal;
font-family:HelveticaNeue-Light, "Helvetica Neue Light",
"Helvetica Neue", Helvetica, Arial, "Lucida Grande", sans-serif;font-weight:300
;font-size:14px;line-height:1.6;
}
</style>
<div id="fslv2-main">
<?php if($secure->attempts() > 3): ?>
<!-- Show the login form -->
<p>Too many failed attempts, please try again later.</p>
<?php elseif(isset($_GET['forgot_password'])): ?>
<fieldset class="fslv2">
<form method="post" action="#">
<p>
<label for='email'>Email: </label>
<input type='text' name='email' class='input'/>
</p>
<p><input type='submit' name='forgot_password_button' cl
ass='button' value='Send!' /></p>
</form>
</fieldset>
<small><a href="index.php">Cancel</a></small>
<?php else: ?>
<fieldset class="fslv2">
<legend><?php echo $secure->site_name(); ?></legend>
<form method="post" action="#">
<p>
<label for='username'>Username: </label>
<input type='text' name='username' class='input'
/>
</p>
<p>
<label for='password'>Password: </label>
<input type='password' name='password' class='in
put'/>
</p>
<p><input type='submit' name='login' class='button' valu
e='Login' /></p>
</form>
</fieldset>
<small><a href="?forgot_password">Forgot Password</a></small>
<?php endif; ?>
</div><!-- #fslv2-main -->
<?php exit(); endif; ?>