Advertisement
ryanmcoble

Untitled

Jul 22nd, 2014
237
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.01 KB | None | 0 0
  1. <?php
  2. //main feed daemon script
  3.  
  4. //no execution limit
  5. set_time_limit(0);
  6.  
  7. //include db class
  8. require_once('classes/db_helper.class.php');
  9.  
  10. $dbClass = new DBHelper('localhost', 'datafeeds', 'vede7yvej', 'zadmin_datafeeds');
  11.  
  12. //if not enough arguments found
  13. if ($argc <= 1) {
  14. //die('usage: php feed.php <startnum> <endnum> <gr_url> <gr_webformid> <gr_uid>'."\n"); # code...
  15. die('usage: php feed.php <client id>'."\n");
  16. }
  17.  
  18.  
  19. $client_id = $argv[1];
  20.  
  21. $client = $dbClass->get_client($client_id)[0];
  22.  
  23. //arguments
  24. $start_num = $client['startnum'];
  25. $end_num = $client['endnum'];
  26. $executionTime = time() + (24 * 60 * 60);
  27. $rand_num = rand($start_num, $end_num);
  28.  
  29. $apikey="16e2404e101909b9d3c11333f902f7aa";
  30.  
  31. $gr_url = $client['grapikey'];
  32. $gr_webformid = $client['grwebform'];
  33. $gr_uid = $client['gruid'];
  34.  
  35. //create execution times, array
  36. $fmlarray = array();
  37. for ($x = 1; $x <= $rand_num; $x++)
  38. {
  39. $fml = rand(time(), $executionTime);
  40. //echo $fml."\n";
  41. $fmlarray[] = $fml;
  42. }
  43. sort($fmlarray);
  44.  
  45.  
  46. //output start and end time
  47. echo 'Start Time: '.time()."\n";
  48. echo 'End Time: '.$executionTime."\n";
  49.  
  50. //set daily executions
  51. $dbClass->set_daily($client_id, $rand_num);
  52.  
  53. $i = 0;
  54.  
  55. //loop 24 hours
  56. while(time() < $executionTime) {
  57. //if current time is execution times array
  58. if(in_array(time(), $fmlarray)){
  59.  
  60. $data = $dbClass->get_unassigned_by_api_key($apikey, 1);
  61. foreach($data as $d){
  62. $dbClass->set_assigned_by_email($d['email']);
  63.  
  64. //api request
  65. $url = 'http://offerhq.info/postrequest.php?api_key=jonAPI2014&email='.$d['email'].'&fname='.$d['firstname'].'&lname='.$d['lastname'].'&offer_url='.$d['referal_url'].'&ip='.$d['ip'].'&ar=gr&gr_webformid='.$gr_webformid.'&gr_uid='.$gr_uid.'&ref_url='.$gr_url;
  66. file_get_contents($url);
  67.  
  68. //increment total loaded by 1
  69. $dbClass->increment_total($client_id);
  70.  
  71. echo '..::[ Added Subscriber #'.$i.' with APIKEY: '.$apikey.' and Email: '.$email.' ]::..'."\n";
  72. $i++;
  73. }
  74. }
  75. sleep(1);
  76. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement