Advertisement
Guest User

Untitled

a guest
Oct 4th, 2018
345
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.25 KB | None | 0 0
  1. function send_sms($code)
  2. {
  3.  
  4. $sch=0; global $tel; global $mac; global $code;global $ip;
  5. $host = 'localhost';
  6. $database = 'datausers';
  7. $user = 'root';
  8. $pass = 'toor';
  9. $link = mysqli_connect($host,$user,$pass,$database);
  10. if(!$link)
  11. {
  12. die("Database connection failed: " . mysqli_error());
  13.  
  14. }
  15.  
  16. $db_secelect = mysqli_select_db($link,$database);
  17. if(!$db_secelect)
  18. {
  19. die("Database connection failed: " .mysqli_error($link));
  20. }
  21. $dbtel = mysqli_query($link,"SELECT phone FROM `dataconnection`");
  22. $dbip = mysqli_query($link,"SELECT ip FROM `dataconnection`");
  23. $dbmac = mysqli_query($link,"SELECT mac FROM `dataconnection`");
  24. $dbdate = mysqli_query($link,"SELECT date FROM `dataconnection`");
  25. $dbenable = mysqli_query($link,"SELECT enable FROM `dataconnection`");
  26. $rows_db = mysqli_num_rows($dbtel);
  27. for ($i=0;$i<$rows_db;$i++)
  28. {
  29. $dbmac_i = mysqli_result($dbmac, $i);
  30. if ($dbmac_i == $mac)
  31. { $sch++; $time = mysqli_result($dbdate, $i); $time_los = date("U") - $time;
  32. if ($time_los < 60)
  33. {
  34. {echo ("<p align='center' style='font-size:24px; color: #666;'>Повторно выслать смс можно через 1 минуту...</p>
  35. <form method='POST' name='user_code'>
  36. <p align='center' style='font-size:24px; color: #666;'>
  37. Введите код, полученный в смс<br>
  38. <input type='text' name='access_code' maxlength='6' autofocus='autofocus'
  39. style='2px solid; background:#fff; width:90px; font-size:24px; color: #666;'>
  40. <input type='submit' name='submit' value='Отправить' style='2px solid; background:#aefedf;
  41. width:150px; font-size:24px; color: #666;'>
  42. </p></form>"); break;}
  43.  
  44. }
  45. else
  46. {
  47. $col = mysqli_result($dbenable, $i);
  48. if ($col > 1) {
  49. {
  50. echo("<p align='center' style='font-size:24px; color: #666;'>Возможно, какие-то проблемы на стороне оператора.
  51. <br> Для получения доступа обратитесь к администратору.</p> <form method='POST' name='user_code'>
  52. <p align='center' style='font-size:24px; color: #666;'>
  53. Введите код, полученный в смс</p>
  54. <p align='center' style='font-size:24px; color: #666;'>
  55. <input type='text' name='access_code' maxlength='6' autofocus='autofocus'
  56. style='2px solid; background:#fff; width:90px; font-size:24px; color: #666;'>
  57. <input type='submit' name='submit' value='Отправить' style='2px solid; background:#aefedf; width:150px; font-size:24px; color: #666;'>
  58. </p></form>");
  59. break;
  60. }
  61. }
  62. else
  63. {
  64. echo ("<p align='center' style='font-size:24px; color: #666;'><b>Смс с кодом выслано</b>.</p>
  65. <form method='POST' name='user_code'>
  66. <p align='center' style='font-size:24px; color: #666;'>
  67. Введите код, полученный в смс:</p>
  68. <p align='center' style='font-size:24px; color: #666;'>
  69. <input type='text' name='access_code' maxlength='6' autofocus='autofocus' style='2px solid; background:#fff; width:90px;
  70. font-size:24px; color: #666;'>
  71. <input type='submit' name='submit' value='Отправить' style='2px solid; background:#aefedf; width:150px; font-size:24px; color: #666;'>
  72. </p></form> ");break; }}}}
  73. #т.е. в базе такого macа нет, тогда записываем и шлем смс
  74. if ($sch == 0){$time = date("U");
  75. mysqli_query($link,"INSERT INTO dataconnection(phone,ip,mac,enable) VALUE ('$tel'.'$ip','$mac',1)");
  76. $sms_token = new SMSRU('09B77005-27A7-18B8-F53E-4DFFAA153CEA');
  77. $data = new stdClass();
  78. $data->to = $_POST['tel'];
  79. $data->text = $code;
  80. $sms = $sms_token->send_one($data);
  81. echo ("<p align='center' style='font-size:24px; color: #666;'>Смс с кодом выслано.</p>
  82. <form method='POST' name='user_code'>
  83. <p align='center' style='font-size:24px; color: #666;'>
  84. Введите код, полученный в смс<br>
  85. <input type='text' name='access_code' maxlength='6' autofocus='autofocus'
  86. style='2px solid; background:#fff; width:90px; font-size:24px; color: #666;'>
  87. <input type='submit' name='submit' value='Отправить' style='2px solid; background:#aefedf; width:150px; font-size:24px; color: #666;'>
  88. </p></form>");}
  89.  
  90. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement