KyleMassacre

output.php

Jul 6th, 2013
39
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.59 KB | None | 0 0
  1. public function checkPromo()
  2. {
  3. global $db, $msg_error, $msg_ok;
  4. if(isset($_POST["afillID"]) && !empty($_POST["afillID"]) && isset($_POST["promo_code"]) && !empty($_POST["promo_code"]))
  5. {
  6. $sql = "SELECT name, api_url FROM affiliates WHERE id = ".$_POST["afillID"]." LIMIT 1";
  7. if($db->numrows($sql))
  8. {
  9. $go = $db->fetch($sql);
  10. $data = urlencode($_POST["afillID"].'&site_id='.$_POST["id"]);
  11. $req = 'cmd=_verify-promo&license='.$data;
  12. $header .= "Content-Type: application/x-www-form-urlencoded\r\n";
  13. $header .= "Content-Length: " . strlen($req) . "\r\n\r\n";
  14. $fp = fsockopen ($go["api_url"], 443, $errno, $errstr, 30);
  15. if(!fp)
  16. {
  17. $msg_error[] = "Something went wrong trying to validate your Promo Code";
  18. }
  19. else
  20. {
  21. fputs ($fp, $header . $req);
  22. while (!feof($fp))
  23. {
  24. $res = fgets ($fp, 1024);
  25. if(strcmp($res,"VERIFIED") != 0)
  26. $msg_error[] = "The Promo Code you have provided seems to be invalid";
  27. if (strcmp ($res, "VERIFIED") == 0)
  28. {
  29. $this->creditClicks($_POST["id"],200);
  30. $prem = $this->getSite($_POST["id"]);
  31. if($prem["site_premium"] > time())
  32. $premium = $site['site_premium'] + (5 * 86400);
  33. else
  34. $premium = time() + (5 * 86400);
  35. if(empty($msg_error))
  36. {
  37. $data = array("site_premium" => $premium);
  38. return $db->update("sites", $data, "site_id=".$_POST["id"]);
  39.  
  40.  
  41. }
  42. }
  43. }
  44. }
  45. }
  46. }
  47. }
  48.  
  49. ?>
Advertisement
Add Comment
Please, Sign In to add comment