Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- $server = '127.0.0.1:1500';
- $session_lifetime = 1800;
- error_reporting(E_ALL);
- ini_set('display_errors', true);
- ini_set('arg_separator.output', '&');
- if (isset($_SERVER['HTTP_ACCEPT_ENCODING'])) {
- $accept_encoding = $_SERVER['HTTP_ACCEPT_ENCODING'];
- } elseif (isset($_SERVER['HTTP_TE'])) {
- $accept_encoding = $_SERVER['HTTP_TE'];
- } else {
- $accept_encoding = '';
- }
- if (strpos($accept_encoding, 'gzip')) {
- header('Content-Encoding: gzip');
- function gzencode5($data)
- {
- return gzencode($data, 5);
- }
- ob_start('gzencode5');
- } elseif (strpos($accept_encoding, 'deflate')) {
- header('Content-Encoding: deflate');
- function gzdeflate5($output)
- {
- return gzdeflate($output, 5);
- }
- ob_start('gzdeflate5');
- } else {
- ob_start();
- }
- function api_query($query)
- {
- $content = @file_get_contents($query);
- if (strpos($content, 'Authorization required') or $content == '') {
- session_unset();
- session_destroy();
- #header('Location: ?error=logon');
- exit();
- } else {
- return $content;
- }
- }
- $func = isset($_GET['func']) ? $_GET['func'] : '';
- $title="ISP WAP";
- include_once '../sys/fnc.php';
- include_once '../sys/head.php';
- if ($func == '') {
- if (empty($_POST['submit']) and (empty($_GET['username']) or empty($_GET['password']))) {
- if (isset($_GET['error'])) {
- if ($_GET['error'] == 'logon') {
- echo '<div class="err">Ошибка входа!</div>';
- } elseif ($_GET['error'] == 'authfail') {
- echo '<div class="err">Ошибка входа!</div>';
- } elseif ($_GET['error'] == 'expire') {
- echo '<div class="err">Ошибка входа!</div>';
- }
- }
- echo '<center><form class="menu" method="post">
- Логин: <br><input type="text" name="login" />
- <br>Пароль: <br>
- <input type="password" name="pass" />
- <br><input type="submit" name="submit" value="Войти" />
- </form></center>';
- } else {
- print_r($content);
- $content = api_query('https://' . $server . '/manager/ispmgr?func=auth&out=xml&username=' . urlencode($_POST['username']) . '&password=' . urlencode($_POST['password']));
- $parse_xml = simplexml_load_string($content);
- if (isset($parse_xml->auth)) {
- $_SESSION['lifetime'] = $_SERVER['REQUEST_TIME'];
- $_SESSION['auth'] = (string)$parse_xml->auth;
- $_SESSION['username'] = $_POST['username'];
- $_SESSION['password'] = $_POST['password'];
- $content = api_query('https://' .$server. '/manager/ispmgr?func=usrparam&out=xml&authinfo=' . urlencode($_SESSION['username']) . ':' . urlencode($_SESSION['password']));
- $parse_xml_usrparam = simplexml_load_string($content);
- $_SESSION['rows'] = (int)$parse_xml_usrparam->rows;
- if (isset($_GET['username']) and isset($_GET['password'])) {
- #header('Location: ?func=menu&' . SID);
- ob_end_flush();
- exit;
- }
- echo '<div class="menu">Успешная Авторизация!';
- echo '<a href="?func=menu">Перейти в меню</a>';
- } else {
- session_unset();
- session_destroy();
- #header('Location: ?error=authfail');
- ob_end_flush();
- exit();
- }
- }
- echo '</div>';
- } elseif (file_exists('./func/' . $func . '.php')) {
- require('./func/' . $func . '.php');
- } else {
- session_unset();
- session_destroy();
- #header('Location: ?error=logon');
- ob_end_flush();
- exit();
- }
- include_once '../sys/foot.php';
- ob_end_flush();
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement