index.php 10 KB

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