Advertisement
Guest User

svgreen

a guest
Jun 27th, 2017
57
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.14 KB | None | 0 0
  1. <?php
  2.  
  3. $LOGIN_INFORMATION = array(
  4. 'greeny',
  5. 'nada',
  6. 'smolikovi'
  7. );
  8.  
  9. // request login? true - show login and password boxes, false - password box only
  10. define('USE_USERNAME', false);
  11.  
  12. // User will be redirected to this page after logout
  13. define('LOGOUT_URL', 'http://www.example.com/');
  14.  
  15. // time out after NN minutes of inactivity. Set to 0 to not timeout
  16. define('TIMEOUT_MINUTES', 0);
  17.  
  18. // This parameter is only useful when TIMEOUT_MINUTES is not zero
  19. // true - timeout time from last activity, false - timeout time from login
  20. define('TIMEOUT_CHECK_ACTIVITY', true);
  21.  
  22. ##################################################################
  23. # SETTINGS END
  24. ##################################################################
  25.  
  26.  
  27. ///////////////////////////////////////////////////////
  28. // do not change code below
  29. ///////////////////////////////////////////////////////
  30.  
  31. // show usage example
  32. if(isset($_GET['help'])) {
  33. 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;');
  34. }
  35.  
  36. // timeout in seconds
  37. $timeout = (TIMEOUT_MINUTES == 0 ? 0 : time() + TIMEOUT_MINUTES * 60);
  38.  
  39. // logout?
  40. if(isset($_GET['logout'])) {
  41. setcookie("verify", '', $timeout, '/'); // clear password;
  42. header('Location: ' . LOGOUT_URL);
  43. exit();
  44. }
  45.  
  46. if(!function_exists('showLoginPasswordProtect')) {
  47.  
  48. // show login form
  49. function showLoginPasswordProtect($error_msg) {
  50. ?>
  51. <html>
  52. <head>
  53. <title>Please enter password to access this page</title>
  54. <META HTTP-EQUIV="CACHE-CONTROL" CONTENT="NO-CACHE">
  55. <META HTTP-EQUIV="PRAGMA" CONTENT="NO-CACHE">
  56. </head>
  57. <body>
  58. <style>
  59. input { border: 1px solid black; }
  60. </style>
  61. <div style="width:500px; margin-left:auto; margin-right:auto; text-align:center">
  62. <form method="post">
  63. <h2>Vložte heslo pro přístup</h2>
  64. <font color="red"><?php echo $error_msg; ?></font><br />
  65. <?php if (USE_USERNAME) echo 'Login:<br /><input type="input" name="access_login" /><br />Heslo:<br />'; ?>
  66. <input style="font-size:24px; width:200px" type="password" name="access_password" /><p></p><input type="submit" style="font-size:24px; width:100px" name="Submit" value="Submit" />
  67. </form>
  68.  
  69. </div>
  70. </body>
  71. </html>
  72.  
  73. <?php
  74. // stop at this point
  75. die();
  76. }
  77. }
  78.  
  79. // user provided password
  80. if (isset($_POST['access_password'])) {
  81.  
  82. $login = isset($_POST['access_login']) ? $_POST['access_login'] : '';
  83. $pass = $_POST['access_password'];
  84. if (!USE_USERNAME && !in_array($pass, $LOGIN_INFORMATION)
  85. || (USE_USERNAME && ( !array_key_exists($login, $LOGIN_INFORMATION) || $LOGIN_INFORMATION[$login] != $pass ) )
  86. ) {
  87. showLoginPasswordProtect("Incorrect password.");
  88. }
  89. else {
  90. // set cookie if password was validated
  91. setcookie("verify", md5($login.'%'.$pass), $timeout, '/');
  92.  
  93. // Some programs (like Form1 Bilder) check $_POST array to see if parameters passed
  94. // So need to clear password protector variables
  95. unset($_POST['access_login']);
  96. unset($_POST['access_password']);
  97. unset($_POST['Submit']);
  98. }
  99.  
  100. }
  101.  
  102. else {
  103.  
  104. // check if password cookie is set
  105. if (!isset($_COOKIE['verify'])) {
  106. showLoginPasswordProtect("");
  107. }
  108.  
  109. // check if cookie is good
  110. $found = false;
  111. foreach($LOGIN_INFORMATION as $key=>$val) {
  112. $lp = (USE_USERNAME ? $key : '') .'%'.$val;
  113. if ($_COOKIE['verify'] == md5($lp)) {
  114. $found = true;
  115. // prolong timeout
  116. if (TIMEOUT_CHECK_ACTIVITY) {
  117. setcookie("verify", md5($lp), $timeout, '/');
  118. }
  119. break;
  120. }
  121. }
  122. if (!$found) {
  123. showLoginPasswordProtect("");
  124. }
  125.  
  126. }
  127.  
  128. ?>
  129.  
  130.  
  131. <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
  132. <html>
  133. <head>
  134. <meta http-equiv="Content-Type" content="text/html; charset=windows-1250">
  135. <title>Svatba video</title>
  136. </head>
  137.  
  138. <body bgcolor="#444">
  139. <center>
  140. <br>
  141. <br>
  142.  
  143. <!-- videotag heeeere -->
  144.  
  145.  
  146. <br>
  147. <br>
  148. <br>
  149. <br>
  150. <br>
  151. <br>
  152. <br>
  153. <br>
  154. <br>
  155. <br>
  156. <br>
  157. <br>
  158. <br>
  159. <br>
  160. <br>
  161. <br>
  162. <br>
  163. <br>
  164. <br>
  165. <br>
  166. <br>
  167. <br>
  168. <br>
  169. </center>
  170. </body>
  171. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement