"; } if (isset($_POST['submit']) && !empty($_POST['username']) && !empty($_POST['password'])) { $user = string_clean($_POST['username']); $pass = string_clean($_POST['password']); //echo $user; $lines= file($filename); foreach ($lines as $line){ $data = json_decode($line, true); $data=array_map('decrypt', $data); $i=0; //var_dump($data); foreach ($data as $k=>$v){ if($data['username']== $user && $data['password']==$pass){ $ok='1'; } $i=0; } } if($ok){ $username=$user; $password=$pass; if(empty($username) || empty($password)){//show the form $error='1'; } $_SESSION["USERNAME"] = $username; $_SESSION["PASSWORD"] = $password; $_SESSION["TIMESTAMP"] = time(); } } $isLoginNeeded = true; if (!empty($_SESSION["USERNAME"]) && !empty($_SESSION["PASSWORD"] && !empty($_SESSION["TIMESTAMP"])) { $isLoginNeeded = false; if (time() - $_SESSION["TIMESTAMP"] > $timeout) $isLoginNeeded = true; if (!$isLoginNeeded) { $_SESSION["TIMESTAMP"] = time(); } } if ($isLoginNeeded){ $error='1'; // a logout link to add to protected pages
LogOut
/// end logout link ///////////////////////////////////////////////////////////// the registration page Register.php Success you are registered.

'; echo ""; exit; }else{ echo '

Houston! We have a problem here.

'; echo ""; exit; } } ?> Deny from all with cmxprotex register area the cool simple php login script with the cmx girl
HALT! Register
Username:(alpha num min8 max20)
Password:(alpha num min8 max20)
Protected by
CMXproTex©
Login
/// end register.php /////////////////////////////////// //this is the denyinc.php include. to the end of the page //settings $message

"; echo ""; echo "

"; exit; } // change this it is depreciated function encrypt($decrypted) { global $password; global $salt; $key = hash('SHA256', $salt . $password, true); srand(); $iv = mcrypt_create_iv(mcrypt_get_iv_size(MCRYPT_RIJNDAEL_128, MCRYPT_MODE_CBC), MCRYPT_RAND); if (strlen($iv_base64 = rtrim(base64_encode($iv), '=')) != 22) return false; $encrypted = base64_encode(mcrypt_encrypt(MCRYPT_RIJNDAEL_128, $key, $decrypted . md5($decrypted), MCRYPT_MODE_CBC, $iv)); return $iv_base64 . $encrypted; } //checks post function values_check($array) { $array=is_array($array) ? $array : array($array); foreach($array as $k => $v) { if(!empty($v) && strlen($v)>7 && strlen($v)<21 && !preg_match("/[^A-Za-z0-9\s]/",$v)){ return true; } else{ return false; } }} //alpha numeric only function string_clean($c1){ $c1=trim(preg_replace('/(\s)\s+/', ' ', $c1)); return trim(preg_replace("/[^A-Za-z0-9\s]/", "",$c1)); } //multiple array map callbacks at one time function array_maps($callbacks, $array) { if (!$callbacks) { return $array; } if (!is_array($callbacks) && is_string($callbacks) && function_exists($callbacks)) { return array_map($callbacks, $array); } foreach($callbacks as $callback) { if (function_exists($callback)) { $array = array_map($callback, $array); } } return $array; } // file get contents with lock function lock_get_contents($filename){ $return = FALSE; if(!empty($filename) and file_exists($filename) && is_readable($filename)){ if($handle = @fopen($filename, 'r')){ while(!$return){ if(flock($handle, LOCK_SH)){ if($return = file_get_contents($filename)){ flock($handle, LOCK_UN); }}} fclose($handle); }} return $return; } function decrypt($encrypted) { global $password; global $salt; $key = hash('SHA256', $salt . $password, true); $iv = base64_decode(substr($encrypted, 0, 22) . '=='); $encrypted = substr($encrypted, 22); $decrypted = rtrim(mcrypt_decrypt(MCRYPT_RIJNDAEL_128, $key, base64_decode($encrypted), MCRYPT_MODE_CBC, $iv), "\0\4"); $hash = substr($decrypted, -32); $decrypted = substr($decrypted, 0, -32); if (md5($decrypted) != $hash) return false; return $decrypted; } /// denyinc.php include end ?>