KyleMassacre

lame

Jul 12th, 2013
69
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. public function checkPromo($aff, $code)
  2. {
  3.     global $db, $msg_error, $msg_ok;
  4.     if (isset($_POST["affilID"]) && !is_null($_POST["affilID"]) && isset($_POST["promo_code"]) && !is_null($_POST["promo_code"]))
  5.         {
  6.               $sql = "SELECT name, api_url FROM affiliates WHERE id = {$aff}";
  7.               $query = $db->query($sql);
  8.               if ($query)
  9.               {
  10.                 $go = $db->fetch($query);
  11.                 $url = str_ireplace("@@code@@",$_POST["promo_code"],$go["api_url"]);
  12.                 //$header .= "Content-Type: application/x-www-form-urlencoded\r\n";
  13.                 //$header .= "Content-Length: " . strlen($req) . "\r\n\r\n";
  14.                 $fp = file_get_contents($url, false, NULL, -1, 1024);
  15.                 if (!fp)
  16.                 {
  17.                     $msg_error[] = "Something went wrong trying to validate your Promo Code";
  18.                 }
  19.                 else
  20.                 {
  21.                     if (strcmp($fp, "Valid") !== 0)
  22.                     {
  23.                           $msg_error[] = "The Promo Code you have provided seems to be invalid";
  24.                           $msg_error[] = $fp;
  25.                       }
  26.                     if (strcmp($fp, "Valid") === 0)
  27.                     {
  28.                           $this->creditClicks($_POST["id"], 200);
  29.                           $prem = $this->getSite($_POST["id"]);
  30.                           if ($prem["site_premium"] > time())
  31.                             $premium = $site['site_premium'] + (5 * 86400);
  32.                           else
  33.                             $premium = time() + (5 * 86400);
  34.                           if (empty($msg_error))
  35.                           {
  36.                             $data = array("site_premium" => $premium);
  37.                             return $db->update("sites", $data, "site_id=" . $_POST["id"]);
  38.                           }
  39.                      }
  40.                 }
  41.             }
  42.         }
  43.         return false;
  44. }
Advertisement
Add Comment
Please, Sign In to add comment