Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public function checkPromo($aff, $code)
- {
- global $db, $msg_error, $msg_ok;
- if (isset($_POST["affilID"]) && !is_null($_POST["affilID"]) && isset($_POST["promo_code"]) && !is_null($_POST["promo_code"]))
- {
- $sql = "SELECT name, api_url FROM affiliates WHERE id = {$aff}";
- $query = $db->query($sql);
- if ($query)
- {
- $go = $db->fetch($query);
- $url = str_ireplace("@@code@@",$_POST["promo_code"],$go["api_url"]);
- //$header .= "Content-Type: application/x-www-form-urlencoded\r\n";
- //$header .= "Content-Length: " . strlen($req) . "\r\n\r\n";
- $fp = file_get_contents($url, false, NULL, -1, 1024);
- if (!fp)
- {
- $msg_error[] = "Something went wrong trying to validate your Promo Code";
- }
- else
- {
- if (strcmp($fp, "Valid") !== 0)
- {
- $msg_error[] = "The Promo Code you have provided seems to be invalid";
- $msg_error[] = $fp;
- }
- if (strcmp($fp, "Valid") === 0)
- {
- $this->creditClicks($_POST["id"], 200);
- $prem = $this->getSite($_POST["id"]);
- if ($prem["site_premium"] > time())
- $premium = $site['site_premium'] + (5 * 86400);
- else
- $premium = time() + (5 * 86400);
- if (empty($msg_error))
- {
- $data = array("site_premium" => $premium);
- return $db->update("sites", $data, "site_id=" . $_POST["id"]);
- }
- }
- }
- }
- }
- return false;
- }
Advertisement
Add Comment
Please, Sign In to add comment