Advertisement
Guest User

Untitled

a guest
Dec 28th, 2018
348
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 3.22 KB | None | 0 0
  1. <?php
  2. require __DIR__ . '/twilio-php-master/Twilio/autoload.php';
  3. use Twilio\Rest\Client;
  4.  
  5. $messagefault = "Change Machine Fault";
  6.  
  7. $servername = "localhost";
  8. $username = "root";
  9. $password = "password";
  10. $dbname = "fix";
  11.  
  12. $conn = new mysqli($servername, $username, $password, $dbname);
  13. // Check connection
  14. if ($conn->connect_error)
  15. {
  16.   die("Connection failed: " . $conn->connect_error);
  17. }
  18.  
  19. $sql = "SELECT id, serial, twillonumber, account_sid, auth_token, messagecount, vaild, banned FROM devices";
  20. $result = $conn->query($sql);
  21.  
  22. if ($result->num_rows > 0)
  23. {
  24.   while ($row = $result->fetch_assoc())
  25.   {
  26.     $id = $row["id"];
  27.     $serial = $row["serial"];
  28.     $twillonumber = $row["twillonumber"];
  29.     $account_sid = $row["account_sid"];
  30.     $auth_token = $row["auth_token"];
  31.     $messagecount = $row["messagecount"];
  32.     $vaild = $row["vaild"];
  33.     $banned = $row["banned"];
  34.   }
  35. }
  36.  
  37. echo $id;
  38. echo $serial;
  39. echo $banned;
  40.  
  41. $conn->close();
  42.  
  43. if ($banned == "0")
  44. {
  45.   echo "666";
  46.   exit;
  47. }
  48.  
  49. if ($_GET["pass"] == null || $_GET["code"] == null)
  50. {
  51.   echo "nope";
  52.   exit;
  53. }
  54.  
  55. if ($_GET["pass"] == $pass and $_GET["code"] == '3')
  56. {
  57.   echo "1";
  58. }
  59.  
  60. if ($_GET["pass"] == $pass and $_GET["code"] == '4')
  61. {
  62.   // Updated file to 1 when online check compleates
  63.   echo "Ping - Pong";
  64.   exit;
  65. }
  66.  
  67. if ($_GET["pass"] == $pass and $_GET["code"] == '5' and $status == '1')
  68. {
  69.   echo "Var set to 0 to check next uptime.";
  70.   exit;
  71. }
  72.  
  73. if ($_GET["pass"] == $pass and $_GET["code"] == '5' and $status == '0')
  74. {
  75.   $client = new Client($account_sid, $auth_token);
  76.   $client
  77.     ->messages
  78.     ->create($number, array(
  79.       'from' => $twilio_number,
  80.       'body' => 'Device Offline, Reset or check internet connection. Device will automaticly reconect if it is an internet outage.'
  81.   ));
  82.  
  83.   echo "Check has failed. Sending SMS messages. Var set so no new messages will send until device comes back online.";
  84. }
  85.  
  86. if ($_GET["pass"] == $pass and $_GET["code"] == '5' and $status == '0')
  87. {
  88.   //
  89. }
  90.  
  91. if ($_GET["pass"] == $pass and $_GET["code"] == '5' and $status == '2')
  92. {
  93.   echo "SMS Blocked because it was aready sent.";
  94. }
  95.  
  96. if ($_GET["pass"] == $pass and $_GET["code"] == '1')
  97. {
  98.   $client = new Client($account_sid, $auth_token);
  99.   $client
  100.     ->messages
  101.     ->create($number, array(
  102.       'from' => $twilio_number,
  103.       'body' => $messagefault
  104.   ));
  105.  
  106.   echo "Alert Sent!";
  107. }
  108.  
  109. if ($_GET["pass"] == $pass and $_GET["code"] == '2')
  110. {
  111.   $client = new Client($account_sid, $auth_token);
  112.   $client
  113.     ->messages
  114.     ->create($number, array(
  115.       'from' => $twilio_number,
  116.       'body' => 'Device Test'
  117.   ));
  118.  
  119.   echo "Test Message Sent.";
  120. }
  121.  
  122. if ($_GET["pass"] == $pass and $_GET["code"] == '2')
  123. {
  124.   $client = new Client($account_sid, $auth_token);
  125.   $client
  126.     ->messages
  127.     ->create($number, array(
  128.       'from' => $twilio_number,
  129.       'body' => ' Device Test'
  130.   ));
  131.  
  132.   echo "Test Message Sent.";
  133. }
  134.  
  135. if ($_GET["pass"] == $pass and $_GET["code"] == '6')
  136. {
  137.   $client = new Client($account_sid, $auth_token);
  138.   $client
  139.     ->messages
  140.     ->create($number, array(
  141.       'from' => $twilio_number,
  142.       'body' => 'Change Machine Fault Resolved!'
  143.   ));
  144.   echo "Change Machine Fault Resolved";
  145. }
  146.  
  147. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement