Advertisement
Guest User

Untitled

a guest
Jul 8th, 2016
97
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 3.72 KB | None | 0 0
  1. <?php
  2.  
  3. $server = '127.0.0.1:1500';
  4.  
  5. $session_lifetime = 1800;
  6.  
  7.  
  8. error_reporting(E_ALL);
  9. ini_set('display_errors', true);
  10.  
  11. ini_set('arg_separator.output', '&');
  12.  
  13. if (isset($_SERVER['HTTP_ACCEPT_ENCODING'])) {
  14.     $accept_encoding = $_SERVER['HTTP_ACCEPT_ENCODING'];
  15. } elseif (isset($_SERVER['HTTP_TE'])) {
  16.     $accept_encoding = $_SERVER['HTTP_TE'];
  17. } else {
  18.     $accept_encoding = '';
  19. }
  20.  
  21. if (strpos($accept_encoding, 'gzip')) {
  22.     header('Content-Encoding: gzip');
  23.     function gzencode5($data)
  24.     {
  25.         return gzencode($data, 5);
  26.     }
  27.     ob_start('gzencode5');
  28. } elseif (strpos($accept_encoding, 'deflate')) {
  29.     header('Content-Encoding: deflate');
  30.     function gzdeflate5($output)
  31.     {
  32.         return gzdeflate($output, 5);
  33.     }
  34.     ob_start('gzdeflate5');
  35. } else {
  36.     ob_start();
  37. }
  38. function api_query($query)
  39. {
  40. $content = @file_get_contents($query);
  41. if (strpos($content, 'Authorization required') or $content == '') {
  42.         session_unset();
  43.         session_destroy();
  44.         #header('Location: ?error=logon');
  45.        exit();
  46.     } else {
  47.         return $content;
  48.     }
  49. }
  50. $func = isset($_GET['func']) ? $_GET['func'] : '';
  51.  
  52. $title="ISP WAP";
  53.  
  54. include_once '../sys/fnc.php';
  55. include_once '../sys/head.php';
  56.  
  57.  
  58. if ($func == '') {
  59.  
  60.  
  61. if (empty($_POST['submit']) and (empty($_GET['username']) or empty($_GET['password']))) {
  62.         if (isset($_GET['error'])) {
  63.             if ($_GET['error'] == 'logon') {
  64.                echo '<div class="err">Ошибка входа!</div>';
  65.                  } elseif ($_GET['error'] == 'authfail') {
  66.                echo '<div class="err">Ошибка входа!</div>';
  67.                  } elseif ($_GET['error'] == 'expire') {
  68.                echo '<div class="err">Ошибка входа!</div>';
  69.         }
  70. }
  71.  
  72.      
  73. echo '<center><form class="menu" method="post">
  74. Логин: <br><input type="text" name="login" />
  75. <br>Пароль: <br>
  76. <input type="password" name="pass" />
  77. <br><input type="submit" name="submit" value="Войти" />
  78. </form></center>';
  79.  
  80. } else {
  81. print_r($content);
  82.         $content = api_query('https://' . $server . '/manager/ispmgr?func=auth&out=xml&username=' . urlencode($_POST['username']) . '&password=' . urlencode($_POST['password']));
  83.         $parse_xml = simplexml_load_string($content);
  84.         if (isset($parse_xml->auth)) {
  85.             $_SESSION['lifetime'] = $_SERVER['REQUEST_TIME'];
  86.             $_SESSION['auth'] = (string)$parse_xml->auth;
  87.             $_SESSION['username'] = $_POST['username'];
  88.             $_SESSION['password'] = $_POST['password'];
  89.             $content = api_query('https://' .$server. '/manager/ispmgr?func=usrparam&out=xml&authinfo=' . urlencode($_SESSION['username']) . ':' . urlencode($_SESSION['password']));
  90.             $parse_xml_usrparam = simplexml_load_string($content);
  91.             $_SESSION['rows'] = (int)$parse_xml_usrparam->rows;
  92.  
  93.             if (isset($_GET['username']) and isset($_GET['password'])) {
  94.                 #header('Location: ?func=menu&' . SID);
  95.                ob_end_flush();
  96.                 exit;
  97.             }
  98.           echo '<div class="menu">Успешная Авторизация!';
  99.           echo '<a href="?func=menu">Перейти в меню</a>';
  100.             } else {
  101.             session_unset();
  102.             session_destroy();
  103.             #header('Location: ?error=authfail');
  104.            ob_end_flush();
  105.             exit();
  106.         }
  107.     }
  108.     echo '</div>';
  109.    } elseif (file_exists('./func/' . $func . '.php')) {
  110.     require('./func/' . $func . '.php');
  111.     } else {
  112.     session_unset();
  113.     session_destroy();
  114.     #header('Location: ?error=logon');
  115.    ob_end_flush();
  116.     exit();
  117. }
  118.  
  119. include_once '../sys/foot.php';
  120. ob_end_flush();
  121. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement