Advertisement
Guest User

Untitled

a guest
Feb 3rd, 2016
93
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.  
  3. // Configuration Start
  4. //
  5.  
  6. // manual or automatic
  7. $automatic_mode = true;
  8.  
  9. // Voodoo Logins
  10. $url = "http://pak-localhost-34Dw";
  11. $username = "falcon";
  12. $password = "07vt3mg";
  13.  
  14. // Automated for scheduled runs
  15. $automated_sender_id = "447581072856";
  16.  
  17. // Manual runs
  18. $manual_sender_id = "";
  19. $manual_destination_id = "";
  20. $manual_text = "";
  21.  
  22. //
  23. // Configuration End
  24.  
  25. $now = time();
  26.  
  27. if($automatic_mode !== false){
  28.  
  29.     $db = mysql_connect("127.0.0.1", "root", "redpheonix") or die("ded");
  30.     mysql_select_db("dontforget", $db);
  31.  
  32.     // Retreive all runs
  33.     $myquery = mysql_query("SELECT * FROM runs WHERE active = 1");
  34.  
  35.     while($myrow = mysql_fetch_assoc($myquery)){
  36.  
  37.         $runid = $myrow["runid"];
  38.         $label = $myrow["label"];
  39.         $number = $myrow["number"];
  40.         $text = $myrow["text"];
  41.         $date_to_run = $myrow["date_to_run"];
  42.         $recurring = $myrow["recurring"];
  43.  
  44.         if($now > $date_to_run){
  45.  
  46.             // Send the Text
  47.  
  48.             //Post variable names should be same as mentioned below example and its case sensitive as well
  49.             $getString .= "?destin=$number&";
  50.             $getString .= "origin=$automated_sender_id&";
  51.             $getString .= "msg=" . urlencode($text) . "&";
  52.             $getString .= "userid=$username&";
  53.             $getString .= "password=$password&";
  54.             $ch = curl_init();
  55.  
  56.             //set the url, GET data
  57.             curl_setopt($ch,CURLOPT_URL, $url.$getString);
  58.             curl_setopt($ch,CURLOPT_HTTPGET,1); //default
  59.             curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
  60.             curl_setopt($ch, CURLOPT_HEADER, 0);
  61.             curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 30);
  62.             curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
  63.             curl_setopt($ch, CURLOPT_TIMEOUT, 60);
  64.  
  65.             //execute post
  66.             $result = curl_exec($ch);
  67.             echo($result);
  68.  
  69.             //close connection
  70.             curl_close($ch);
  71.  
  72.             // Set the next run
  73.             $now = "@" . $date_to_run;
  74.             $dt = new DateTime($now);
  75.  
  76.             if($recurring == "yearly"){
  77.  
  78.                 $dt->modify('+1 year');
  79.                 $date_next_year = $dt->format('m/d/Y');
  80.                 $next_year = strtotime($date_next_year);
  81.  
  82.                 mysql_query("UPDATE runs SET date_to_run = '$next_year' WHERE runid = '$runid'");
  83.  
  84.             }elseif($recurring == "monthly"){
  85.  
  86.                 $dt->modify('+1 month');
  87.                 $date_next_month = $dt->format('m/d/Y');
  88.                 $next_month = strtotime($date_next_month);
  89.  
  90.                 mysql_query("UPDATE runs SET date_to_run = '$next_month' WHERE runid = '$runid'");
  91.  
  92.             }else{
  93.  
  94.                 // One-time email, set it to be unactive
  95.                 mysql_query("UPDATE runs SET active = 0 WHERE runid = '$runid'");
  96.  
  97.             }
  98.  
  99.         }
  100.  
  101.     }
  102.  
  103. }else{
  104.  
  105.     // Manual
  106.  
  107.     //Post variable names should be same as mentioned below example and its case sensitive as well
  108.     $getString .= "?destin=$manual_destination_id&";
  109.     $getString .= "origin=$manual_sender_id&";
  110.     $getString .= "msg=" . urlencode($manual_text) . "&";
  111.     $getString .= "userid=$username&";
  112.     $ch = curl_init();
  113.  
  114.     //set the url, GET data
  115.     curl_setopt($ch,CURLOPT_URL, $url.$getString);
  116.     curl_setopt($ch,CURLOPT_HTTPGET,1); //default
  117.     curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
  118.     curl_setopt($ch, CURLOPT_HEADER, 0);
  119.     curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 30);
  120.     curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
  121.     curl_setopt($ch, CURLOPT_TIMEOUT, 60);
  122.  
  123.     //execute post
  124.     $result = curl_exec($ch);
  125.     echo($result);
  126.  
  127.     //close connection
  128.     curl_close($ch);
  129.  
  130. }
  131.  
  132. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement