Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- $user='taras.ktl';
- $password='12345';
- $user_url='admin/chat_ktl/';
- $mail_ok=0; //0- отключить ; 1-включить потврездение на почту token
- //-- задержка IP----
- $file_i='admin/ip.bd';
- if (file_exists($file_i)){}else{file_put_contents($file_i, $_SERVER['REMOTE_ADDR'].date("YmdHis"));chmod($file_i, 0777);}
- $date_i=file_get_contents($file_i);
- if($date_i==$_SERVER['REMOTE_ADDR'].date("YmdHis")){die(); exit();}else{file_put_contents($file_i, $_SERVER['REMOTE_ADDR'].date("YmdHis"));}
- //-- задержка IP---
- $HOST_OK=''; if(isset($_SERVER['HTTP_REFERER'])){$HOST_OK=$_SERVER['HTTP_REFERER'];}
- if($HOST_OK==$_SERVER['REQUEST_SCHEME']."://".$_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI']){$HOST_OK='OK';}else{$HOST_OK='STOP';}
- $token=''; if(isset($_POST["token"])){$token=htmlspecialchars(trim($_POST["token"]));}
- $username=''; if(isset($_POST["username"])){$username=htmlspecialchars(trim($_POST["username"]));}
- $userpassword=''; if(isset($_POST["userpassword"])){$userpassword=htmlspecialchars(trim($_POST["userpassword"]));}
- $token_i=time()-$token;
- ?><!doctype html>
- <html>
- <head>
- <meta charset="utf-8">
- <title>Админ-панель</title>
- <style>
- body {text-align:center}
- input{ display:block; width:300px; margin:10px auto; padding:7px 20px;}
- input{border:1px solid #aaa; box-shadow: 0px 0px 3px #ccc, 0 10px 15px #eee inset;border-radius:2px;}
- input:focus{background: #fff;border:1px solid #555;box-shadow: 0 0 3px #aaa;}
- /* Button Style */
- input[type='submit']{
- width:340px;
- background-color: #68b12f;
- background: gradient(linear, left top, left bottom, from(#68b12f), to(#50911e));
- background: linear-gradient(top, #68b12f, #50911e);
- border: 1px solid #509111;
- border-bottom: 1px solid #5b992b;
- border-radius: 3px;
- box-shadow: inset 0 1px 0 0 #9fd574;
- color: white;
- font-weight: bold;
- padding: 7px 40px;
- text-align: center;
- text-shadow: 0 -1px 0 #396715;
- }
- input[type='submit']:hover {opacity:.85;cursor: pointer;}
- input[type='submit']:active { border: 1px solid #20911e;box-shadow: 0 0 10px 5px #356b0b inset;}
- .help input[type='submit']{ background-color:inherit; color:#009; border:0;box-shadow:none;}
- </style>
- </head>
- <body>
- <?php
- if(!$username){?>
- <form action="./" method="post">
- <p>Кто вы?</p>
- <input type="text" name="username" />
- <input type="submit" value="Отправь!" />
- </form>
- <?php }?>
- <?php
- if($username==$user&&0<=$token_i&&$token_i<=100&&$userpassword==$password&&$HOST_OK=='OK'){
- $HOST_OK='STOP';
- $plainpasswd=$password;
- //function crypt_apr1_md5($plainpasswd) {
- $salt = substr(str_shuffle("abcdefghijklmnopqrstuvwxyz0123456789"), 0, 8);
- $len = strlen($plainpasswd);
- $text = $plainpasswd.'$apr1$'.$salt;
- $bin = pack("H32", md5($plainpasswd.$salt.$plainpasswd));
- for($i = $len; $i > 0; $i -= 16) { $text .= substr($bin, 0, min(16, $i)); }
- for($i = $len; $i > 0; $i >>= 1) { $text .= ($i & 1) ? chr(0) : $plainpasswd{0}; }
- $bin = pack("H32", md5($text));
- for($i = 0; $i < 1000; $i++) {
- $new = ($i & 1) ? $plainpasswd : $bin;
- if ($i % 3) $new .= $salt;
- if ($i % 7) $new .= $plainpasswd;
- $new .= ($i & 1) ? $bin : $plainpasswd;
- $bin = pack("H32", md5($new));
- }
- $tmp='';
- for ($i = 0; $i < 5; $i++) {
- $k = $i + 6;
- $j = $i + 12;
- if ($j == 16) $j = 5;
- $tmp = $bin[$i].$bin[$k].$bin[$j].$tmp;
- }
- $tmp = chr(0).chr(0).$bin[11].$tmp;
- $tmp = strtr(strrev(substr(base64_encode($tmp), 2)),
- "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",
- "./0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz");
- $htpasswd="$"."apr1"."$".$salt."$".$tmp;
- $htpasswd=$user.':'.$htpasswd;
- file_put_contents($_SERVER['DOCUMENT_ROOT'].$user_url.'.htpasswd', $htpasswd);
- $htaccess='
- deny from all
- allow from '.$_SERVER['REMOTE_ADDR'].'
- AuthType Basic
- AuthName "'.$username.'"
- AuthUserFile '.$_SERVER['DOCUMENT_ROOT'].$user_url.'.htpasswd
- Require valid-user
- ';
- file_put_contents($_SERVER['DOCUMENT_ROOT'].$user_url.'.htaccess', $htaccess);
- $port=$_SERVER['REQUEST_SCHEME'];//http;
- $host=$_SERVER['HTTP_HOST'];//http://webkiev.com/;
- $path='/'.$user_url;
- $fp='';$errno='stop';
- if($port=='https'){$fp = @fsockopen('ssl://'.$host, 443, $errno, $errstr, 2);/*@fclose($fp);*/}
- if($port=='http'){$fp = @fsockopen($host, 80, $errno, $errstr, 2);/*@fclose($fp);*/}
- $buf = '';
- if ($fp) {
- $Authorization=base64_encode($user.':'.$password);
- $fputs=''.
- "GET ".$path." HTTP/1.1\r\n".
- "Host: ".$host."\r\n".
- "Content-type: application/x-www-form-urlencoded\r\n".
- "Authorization: Bearer ".$Authorization."\r\n".
- "Connection: close\r\n\r\n".
- "";
- fputs($fp,$fputs);
- while (!feof($fp)){$buf.= fgets($fp, 4096);}
- }
- @fclose($fp);
- echo '<meta http-equiv="refresh" content="0; URL='.$path.'">';
- }
- if($username==$user&&$HOST_OK=='OK'){?>
- <form action="./" method="post">
- <p>Ваш IP <?php echo $_SERVER['REMOTE_ADDR']; ?> </p>
- <p>Дата <?php echo date("Y-m-d H:i:s"); ?></p>
- <?php
- if(!$mail_ok){
- echo '<p>token <b>'.time().'</b> (ограничен во времени)</p>';
- }else{
- $text=time()."\n".
- $_SERVER['REMOTE_ADDR']."\n".
- $_SERVER['HTTP_USER_AGENT']."\n".
- $password;
- mail($mail,'Tokin to the site '.$HOST_OK,$text );
- echo '<p><b>Token отправелен на почту</b> <br>(Token ограничен во времени!)</p>';//<------------ Отправка почты
- }
- ?>
- <input type="text" name="token" placeholder="<?php echo time(); ?>(Token)" required />
- <input type="text" name="username" placeholder="<?php echo $username; ?>" required />
- <input type="text" name="userpassword" placeholder="Ваш пароль" required />
- <input type="submit" value="Войти в аккаунт!" />
- <?php
- $help=''; if(isset($_POST["help"])){$help=htmlspecialchars(trim($_POST["help"]));
- if($help=="Восстановить пароль"){
- $text=time()."\n".
- $_SERVER['REMOTE_ADDR']."\n".
- $_SERVER['HTTP_USER_AGENT']."\n".
- $password;
- mail($mail,'Password to the site '.$HOST_OK,$text );
- echo '<p><b>Password отправелен на почту</b></p>';
- }
- } ?>
- <p class="help"><input type="submit" name="help" value="Восстановить пароль" /></p>
- </form>
- <?php }?>
- <p><a href="./">Обновить</a></p>
- </body>
- </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement