index.php 9.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151
  1. <?php
  2. header('Last-Modified: ' . gmdate('r'));
  3. header('Content-Type: text/html; charset=utf-8');
  4. header("Cache-Control: no-store, no-cache, must-revalidate"); // HTTP/1.1
  5. header("Pragma: no-cache");
  6. include("libs/api.mysql.php");
  7. include("libs/api.uhw.php");
  8. $uconf = uhw_LoadConfig();
  9. ?>
  10. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
  11. <html xmlns="http://www.w3.org/1999/xhtml">
  12. <head>
  13. <meta http-equiv="content-type" content="text/html; charset=utf-8" />
  14. <title><?= $uconf['TITLE']; ?></title>
  15. <link href="style.css" rel="stylesheet" type="text/css" media="screen" />
  16. <link type="text/css" href="jui/css/smoothness/jquery-ui-1.8.23.custom.css" rel="stylesheet" />
  17. <script type="text/javascript" src="jui/js/jquery-1.8.0.min.js"></script>
  18. <script type="text/javascript" src="jui/js/jquery-ui-1.8.23.custom.min.js"></script>
  19. </head>
  20. <body>
  21. <div id="wrapper">
  22. <div id="header" class="container">
  23. <div id="logo">
  24. <h1><a href="<?= $uconf['ISP_URL']; ?>"><img src="<?= $uconf['ISP_LOGO']; ?>" width="80" border="0"></a> <?= $uconf['ISP_NAME']; ?></h1>
  25. </div>
  26. <div id="menu">
  27. </div>
  28. </div>
  29. <div id="page" class="container">
  30. <div id="content">
  31. <div class="post">
  32. <h3 class="title"> <font color="#000000"><?= $uconf['SUB_TITLE']; ?></font></h3>
  33. <div style="clear: both;">&nbsp;</div>
  34. <div class="entry">
  35. <h3><?= $uconf['CALL_US']; ?> <?= $uconf['SUP_PHONES']; ?> <?= $uconf['SUP_ACTIVATE']; ?>
  36. <?= $uconf['SUP_REQUIRE']; ?>
  37. <?php
  38. // debug
  39. //$remote_ip='172.32.0.118';
  40. $remote_ip = $_SERVER['REMOTE_ADDR'];
  41. if (ispos($remote_ip, $uconf['UNKNOWN_MASK'])) {
  42. $usermac = uhw_FindMac($remote_ip);
  43. if ($usermac) {
  44. //show user mac
  45. uhw_MacDisplay($usermac);
  46. if ($uconf['SELFACT_ENABLED']) {
  47. //is all passwords unique?
  48. if (uhw_IsAllPasswordsUnique() or $uconf['USE_LOGIN']) {
  49. $brute_attempts = uhw_GetBrute($usermac);
  50. if ($brute_attempts < $uconf['SELFACT_BRUTE']) {
  51. if (uhw_IsMacUnique($usermac)) {
  52. //catch actiivation request
  53. if ((!$uconf['USE_LOGIN'] and isset($_POST['password'])) or ( $uconf['USE_LOGIN'] and isset($_POST['login']) and isset($_POST['password']))) {
  54. if ((!$uconf['USE_LOGIN'] and ! empty($_POST['password'])) or ( $uconf['USE_LOGIN'] and ! empty($_POST['login']) and ! empty($_POST['password']))) {
  55. $trylogin = (isset($_POST['login']) and ! empty($_POST['login'])) ? $_POST['login'] : '';
  56. $trypassword = $_POST['password'];
  57. $userlogin = uhw_FindUserByPassword($trypassword, $trylogin);
  58. if ($userlogin) {
  59. //password ok, we know user login
  60. // lets detect his ip
  61. $tryip = uhw_UserGetIp($userlogin);
  62. if ($tryip) {
  63. //get nethost id
  64. $nethost_id = uhw_NethostGetID($tryip);
  65. if ($nethost_id) {
  66. //almost done, now we need too change mac in nethosts
  67. //and call rebuild handlers and user reset API calls
  68. $oldmac = uhw_NethostGetMac($nethost_id);
  69. uhw_ChangeMac($nethost_id, $usermac);
  70. uhw_LogSelfact($trypassword, $userlogin, $tryip, $nethost_id, $oldmac, $usermac);
  71. uhw_RemoteApiPush($uconf['UBILLING_REMOTE'], $uconf['UBILLING_SERIAL'], 'reset', $userlogin);
  72. uhw_RemoteApiPush($uconf['UBILLING_REMOTE'], $uconf['UBILLING_SERIAL'], 'handlersrebuild');
  73. print(uhw_modal_open($uconf['SUP_SELFACT'], $uconf['SUP_SELFACTDONE'], '400', '300'));
  74. } else {
  75. print(uhw_modal_open($uconf['SUP_ERROR'], $uconf['SUP_STRANGE'] . ' NO_NHID', '400', '300'));
  76. }
  77. } else {
  78. print(uhw_modal_open($uconf['SUP_ERROR'], $uconf['SUP_STRANGE'] . ' NO_IP', '400', '300'));
  79. }
  80. } else {
  81. //wrong password action
  82. uhw_LogBrute($trypassword, $usermac, $trylogin);
  83. print(uhw_modal_open($uconf['SUP_ERROR'], $uconf['SUP_WRONGPASS'], '400', '300'));
  84. }
  85. }
  86. }
  87. //
  88. //show selfact form
  89. //
  90. uhw_PasswordForm($uconf);
  91. } else {
  92. print($uconf['SUP_MACEXISTS']);
  93. }
  94. } else {
  95. //bruteforce prevention
  96. print('<br><br><br>' . uhw_modal($uconf['SUP_SELFACT'], $uconf['SUP_SELFACT'], $uconf['SUP_BRUTEERROR'], 'ubButton', '400', '300'));
  97. }
  98. } else {
  99. print('DEBUG: EXEPTION_PASS_UNIQ ');
  100. }
  101. }
  102. } else {
  103. print($uconf['SUP_NOMAC']);
  104. }
  105. } else {
  106. //not unknown user network
  107. uhw_redirect($uconf['ISP_URL']);
  108. }
  109. ?>
  110. </h3>
  111. </div>
  112. </div>
  113. <div style="clear: both;">&nbsp;</div>
  114. </div>
  115. <div id="sidebar">
  116. <ul>
  117. </ul>
  118. </div>
  119. <div style="clear: both;">&nbsp;</div>
  120. </div>
  121. </div>
  122. <div id="footer-content" class="container">
  123. <div id="footer-bg">
  124. <div id="column1">
  125. <p>&copy; <?= date("Y"); ?> <a href="<?= $uconf['ISP_URL']; ?>"><?= $uconf['ISP_NAME']; ?></a></p>
  126. </div>
  127. <div id="column2">
  128. <?= $uconf['SUP_DESC']; ?><br>
  129. <i><?= $uconf['SUP_DAYS']; ?><br>
  130. <?= $uconf['SUP_TIME']; ?></i>
  131. </div>
  132. <div id="column3">
  133. Powered by <a href="https://ubilling.net.ua">Ubilling</a>
  134. <br>
  135. QC:<?= $query_counter; ?>
  136. </div>
  137. </div>
  138. </div>
  139. <div id="footer">
  140. </div>
  141. </body>
  142. </html>