Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- require __DIR__ . '/twilio-php-master/Twilio/autoload.php';
- use Twilio\Rest\Client;
- $messagefault = "Change Machine Fault";
- $servername = "localhost";
- $username = "root";
- $password = "password";
- $dbname = "fix";
- $conn = new mysqli($servername, $username, $password, $dbname);
- // Check connection
- if ($conn->connect_error)
- {
- die("Connection failed: " . $conn->connect_error);
- }
- $sql = "SELECT id, serial, twillonumber, account_sid, auth_token, messagecount, vaild, banned FROM devices";
- $result = $conn->query($sql);
- if ($result->num_rows > 0)
- {
- while ($row = $result->fetch_assoc())
- {
- $id = $row["id"];
- $serial = $row["serial"];
- $twillonumber = $row["twillonumber"];
- $account_sid = $row["account_sid"];
- $auth_token = $row["auth_token"];
- $messagecount = $row["messagecount"];
- $vaild = $row["vaild"];
- $banned = $row["banned"];
- }
- }
- echo $id;
- echo $serial;
- echo $banned;
- $conn->close();
- if ($banned == "0")
- {
- echo "666";
- exit;
- }
- if ($_GET["pass"] == null || $_GET["code"] == null)
- {
- echo "nope";
- exit;
- }
- if ($_GET["pass"] == $pass and $_GET["code"] == '3')
- {
- echo "1";
- }
- if ($_GET["pass"] == $pass and $_GET["code"] == '4')
- {
- // Updated file to 1 when online check compleates
- echo "Ping - Pong";
- exit;
- }
- if ($_GET["pass"] == $pass and $_GET["code"] == '5' and $status == '1')
- {
- echo "Var set to 0 to check next uptime.";
- exit;
- }
- if ($_GET["pass"] == $pass and $_GET["code"] == '5' and $status == '0')
- {
- $client = new Client($account_sid, $auth_token);
- $client
- ->messages
- ->create($number, array(
- 'from' => $twilio_number,
- 'body' => 'Device Offline, Reset or check internet connection. Device will automaticly reconect if it is an internet outage.'
- ));
- echo "Check has failed. Sending SMS messages. Var set so no new messages will send until device comes back online.";
- }
- if ($_GET["pass"] == $pass and $_GET["code"] == '5' and $status == '0')
- {
- //
- }
- if ($_GET["pass"] == $pass and $_GET["code"] == '5' and $status == '2')
- {
- echo "SMS Blocked because it was aready sent.";
- }
- if ($_GET["pass"] == $pass and $_GET["code"] == '1')
- {
- $client = new Client($account_sid, $auth_token);
- $client
- ->messages
- ->create($number, array(
- 'from' => $twilio_number,
- 'body' => $messagefault
- ));
- echo "Alert Sent!";
- }
- if ($_GET["pass"] == $pass and $_GET["code"] == '2')
- {
- $client = new Client($account_sid, $auth_token);
- $client
- ->messages
- ->create($number, array(
- 'from' => $twilio_number,
- 'body' => 'Device Test'
- ));
- echo "Test Message Sent.";
- }
- if ($_GET["pass"] == $pass and $_GET["code"] == '2')
- {
- $client = new Client($account_sid, $auth_token);
- $client
- ->messages
- ->create($number, array(
- 'from' => $twilio_number,
- 'body' => ' Device Test'
- ));
- echo "Test Message Sent.";
- }
- if ($_GET["pass"] == $pass and $_GET["code"] == '6')
- {
- $client = new Client($account_sid, $auth_token);
- $client
- ->messages
- ->create($number, array(
- 'from' => $twilio_number,
- 'body' => 'Change Machine Fault Resolved!'
- ));
- echo "Change Machine Fault Resolved";
- }
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement