Advertisement
Guest User

Untitled

a guest
Jul 24th, 2019
921
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 6.58 KB | None | 0 0
  1.  
  2. <?php
  3. $user='taras.ktl';
  4. $password='12345';
  5. $user_url='admin/chat_ktl/';
  6. $mail_ok=0; //0- отключить ; 1-включить потврездение на почту token
  7. //-- задержка IP----
  8. $file_i='admin/ip.bd';    
  9. if (file_exists($file_i)){}else{file_put_contents($file_i, $_SERVER['REMOTE_ADDR'].date("YmdHis"));chmod($file_i, 0777);}    
  10. $date_i=file_get_contents($file_i);
  11. if($date_i==$_SERVER['REMOTE_ADDR'].date("YmdHis")){die(); exit();}else{file_put_contents($file_i, $_SERVER['REMOTE_ADDR'].date("YmdHis"));}
  12. //-- задержка IP---
  13. $HOST_OK=''; if(isset($_SERVER['HTTP_REFERER'])){$HOST_OK=$_SERVER['HTTP_REFERER'];}
  14. if($HOST_OK==$_SERVER['REQUEST_SCHEME']."://".$_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI']){$HOST_OK='OK';}else{$HOST_OK='STOP';}
  15. $token=''; if(isset($_POST["token"])){$token=htmlspecialchars(trim($_POST["token"]));}
  16. $username=''; if(isset($_POST["username"])){$username=htmlspecialchars(trim($_POST["username"]));}
  17. $userpassword=''; if(isset($_POST["userpassword"])){$userpassword=htmlspecialchars(trim($_POST["userpassword"]));}
  18. $token_i=time()-$token;
  19. ?><!doctype html>
  20. <html>
  21. <head>
  22. <meta charset="utf-8">
  23. <title>Админ-панель</title>
  24. <style>
  25. body {text-align:center}
  26. input{ display:block; width:300px; margin:10px auto; padding:7px 20px;}
  27. input{border:1px solid #aaa; box-shadow: 0px 0px 3px #ccc, 0 10px 15px #eee inset;border-radius:2px;}
  28. input:focus{background: #fff;border:1px solid #555;box-shadow: 0 0 3px #aaa;}
  29. /* Button Style */
  30. input[type='submit']{
  31.  width:340px;
  32.  background-color: #68b12f;
  33.  background: gradient(linear, left top, left bottom, from(#68b12f), to(#50911e));
  34.  background: linear-gradient(top, #68b12f, #50911e);
  35.  border: 1px solid #509111;
  36.  border-bottom: 1px solid #5b992b;
  37.  border-radius: 3px;
  38.  box-shadow: inset 0 1px 0 0 #9fd574;
  39.  color: white;
  40.  font-weight: bold;
  41.  padding: 7px 40px;
  42.  text-align: center;
  43.  text-shadow: 0 -1px 0 #396715;
  44. }
  45. input[type='submit']:hover {opacity:.85;cursor: pointer;}
  46. input[type='submit']:active { border: 1px solid #20911e;box-shadow: 0 0 10px 5px #356b0b inset;}
  47. .help input[type='submit']{ background-color:inherit; color:#009; border:0;box-shadow:none;}
  48. </style>
  49. </head>
  50. <body>
  51. <?php
  52.  if(!$username){?>
  53. <form action="./" method="post">
  54.     <p>Кто вы?</p>
  55.   <input type="text" name="username" />
  56.   <input type="submit" value="Отправь!" />
  57. </form>
  58. <?php }?>
  59.  
  60. <?php
  61.  
  62. if($username==$user&&0<=$token_i&&$token_i<=100&&$userpassword==$password&&$HOST_OK=='OK'){
  63. $HOST_OK='STOP';
  64. $plainpasswd=$password;
  65. //function crypt_apr1_md5($plainpasswd) {
  66.     $salt = substr(str_shuffle("abcdefghijklmnopqrstuvwxyz0123456789"), 0, 8);
  67.     $len = strlen($plainpasswd);
  68.     $text = $plainpasswd.'$apr1$'.$salt;
  69.     $bin = pack("H32", md5($plainpasswd.$salt.$plainpasswd));
  70.     for($i = $len; $i > 0; $i -= 16) { $text .= substr($bin, 0, min(16, $i)); }
  71.     for($i = $len; $i > 0; $i >>= 1) { $text .= ($i & 1) ? chr(0) : $plainpasswd{0}; }
  72.     $bin = pack("H32", md5($text));
  73.     for($i = 0; $i < 1000; $i++) {
  74.         $new = ($i & 1) ? $plainpasswd : $bin;
  75.         if ($i % 3) $new .= $salt;
  76.         if ($i % 7) $new .= $plainpasswd;
  77.         $new .= ($i & 1) ? $bin : $plainpasswd;
  78.         $bin = pack("H32", md5($new));
  79.     }
  80.     $tmp='';
  81.     for ($i = 0; $i < 5; $i++) {
  82.         $k = $i + 6;
  83.         $j = $i + 12;
  84.         if ($j == 16) $j = 5;
  85.         $tmp = $bin[$i].$bin[$k].$bin[$j].$tmp;
  86.     }
  87.     $tmp = chr(0).chr(0).$bin[11].$tmp;
  88.     $tmp = strtr(strrev(substr(base64_encode($tmp), 2)),
  89.     "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",
  90.     "./0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz");
  91.     $htpasswd="$"."apr1"."$".$salt."$".$tmp;
  92.  
  93. $htpasswd=$user.':'.$htpasswd;
  94. file_put_contents($_SERVER['DOCUMENT_ROOT'].$user_url.'.htpasswd', $htpasswd);
  95.  
  96. $htaccess='
  97. deny from all
  98. allow from '.$_SERVER['REMOTE_ADDR'].'
  99.  
  100. AuthType Basic
  101. AuthName "'.$username.'"
  102. AuthUserFile '.$_SERVER['DOCUMENT_ROOT'].$user_url.'.htpasswd
  103. Require valid-user
  104. ';
  105. file_put_contents($_SERVER['DOCUMENT_ROOT'].$user_url.'.htaccess', $htaccess);
  106.  
  107. $port=$_SERVER['REQUEST_SCHEME'];//http;
  108. $host=$_SERVER['HTTP_HOST'];//http://webkiev.com/;
  109. $path='/'.$user_url;
  110. $fp='';$errno='stop';
  111. if($port=='https'){$fp  = @fsockopen('ssl://'.$host, 443, $errno, $errstr, 2);/*@fclose($fp);*/}
  112. if($port=='http'){$fp  = @fsockopen($host, 80, $errno, $errstr, 2);/*@fclose($fp);*/}
  113. $buf = '';
  114.        if ($fp) {
  115.            $Authorization=base64_encode($user.':'.$password);
  116.            $fputs=''.
  117.             "GET ".$path." HTTP/1.1\r\n".
  118.             "Host: ".$host."\r\n".
  119.             "Content-type: application/x-www-form-urlencoded\r\n".
  120.             "Authorization: Bearer ".$Authorization."\r\n".    
  121.             "Connection: close\r\n\r\n".
  122.             "";
  123.             fputs($fp,$fputs);    
  124.             while (!feof($fp)){$buf.= fgets($fp, 4096);}
  125.         }
  126. @fclose($fp);
  127. echo '<meta http-equiv="refresh" content="0; URL='.$path.'">';
  128.  }
  129.  if($username==$user&&$HOST_OK=='OK'){?>
  130. <form action="./" method="post">
  131. <p>Ваш IP <?php echo $_SERVER['REMOTE_ADDR']; ?> </p>
  132. <p>Дата <?php echo date("Y-m-d H:i:s"); ?></p>
  133. <?php
  134. if(!$mail_ok){
  135.     echo '<p>token <b>'.time().'</b> (ограничен во времени)</p>';
  136.     }else{
  137.     $text=time()."\n".
  138.     $_SERVER['REMOTE_ADDR']."\n".
  139.     $_SERVER['HTTP_USER_AGENT']."\n".
  140.     $password;
  141.     mail($mail,'Tokin to the site '.$HOST_OK,$text );
  142.     echo '<p><b>Token отправелен на почту</b> <br>(Token ограничен во времени!)</p>';//<------------ Отправка почты    
  143.     }
  144.   ?>
  145. <input type="text" name="token"  placeholder="<?php echo time(); ?>(Token)" required />
  146. <input type="text" name="username" placeholder="<?php echo $username; ?>" required />
  147. <input type="text" name="userpassword" placeholder="Ваш пароль" required />
  148. <input type="submit" value="Войти в аккаунт!" />
  149. <?php
  150. $help=''; if(isset($_POST["help"])){$help=htmlspecialchars(trim($_POST["help"]));
  151. if($help=="Восстановить пароль"){
  152.     $text=time()."\n".
  153.     $_SERVER['REMOTE_ADDR']."\n".
  154.     $_SERVER['HTTP_USER_AGENT']."\n".
  155.     $password;
  156.     mail($mail,'Password to the site '.$HOST_OK,$text );
  157.     echo '<p><b>Password отправелен на почту</b></p>';    
  158.     }
  159. } ?>
  160. <p class="help"><input type="submit" name="help" value="Восстановить пароль" /></p>
  161. </form>
  162. <?php }?>
  163. <p><a href="./">Обновить</a></p>
  164. </body>
  165. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement