View difference between Paste ID: SXeQFNXA and wazdjsyQ
SHOW: | | - or go back to the newest paste.
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-
    	{
5+
        {
6-
      		$sql = "SELECT name, api_url FROM affiliates WHERE id = {$aff}";
6+
              $sql = "SELECT name, api_url FROM affiliates WHERE id = {$aff}";
7-
      		$query = $db->query($sql);
7+
              $query = $db->query($sql);
8-
      		if ($query)
8+
              if ($query)
9-
      		{
9+
              {
10-
        		$go = $db->fetch($query);
10+
                $go = $db->fetch($query);
11-
				$url = str_ireplace("@@code@@",$_POST["promo_code"],$go["api_url"]);
11+
                $url = str_ireplace("@@code@@",$_POST["promo_code"],$go["api_url"]);
12-
        		//$header .= "Content-Type: application/x-www-form-urlencoded\r\n";
12+
                //$header .= "Content-Type: application/x-www-form-urlencoded\r\n";
13-
        		//$header .= "Content-Length: " . strlen($req) . "\r\n\r\n";
13+
                //$header .= "Content-Length: " . strlen($req) . "\r\n\r\n";
14-
        		$fp = file_get_contents($url, false, NULL, -1, 1024);
14+
                $fp = file_get_contents($url, false, NULL, -1, 1024);
15-
        		if (!fp)
15+
                if (!fp)
16-
        		{
16+
                {
17-
        			$msg_error[] = "Something went wrong trying to validate your Promo Code";
17+
                    $msg_error[] = "Something went wrong trying to validate your Promo Code";
18-
        		}
18+
                }
19-
        		else
19+
                else
20-
        		{
20+
                {
21-
            		if (strcmp($fp, "Valid") !== 0)
21+
                    if (strcmp($fp, "Valid") !== 0)
22-
            		{
22+
                    {
23-
              			$msg_error[] = "The Promo Code you have provided seems to be invalid";
23+
                          $msg_error[] = "The Promo Code you have provided seems to be invalid";
24-
              			$msg_error[] = $fp;
24+
                          $msg_error[] = $fp;
25-
              		}
25+
                      }
26-
            		if (strcmp($fp, "Valid") === 0)
26+
                    if (strcmp($fp, "Valid") === 0)
27-
            		{
27+
                    {
28-
              			$this->creditClicks($_POST["id"], 200);
28+
                          $this->creditClicks($_POST["id"], 200);
29-
              			$prem = $this->getSite($_POST["id"]);
29+
                          $prem = $this->getSite($_POST["id"]);
30-
              			if ($prem["site_premium"] > time())
30+
                          if ($prem["site_premium"] > time())
31-
                			$premium = $site['site_premium'] + (5 * 86400);
31+
                            $premium = $site['site_premium'] + (5 * 86400);
32-
              			else
32+
                          else
33-
                			$premium = time() + (5 * 86400);
33+
                            $premium = time() + (5 * 86400);
34-
              			if (empty($msg_error))
34+
                          if (empty($msg_error))
35-
              			{
35+
                          {
36-
                			$data = array("site_premium" => $premium);
36+
                            $data = array("site_premium" => $premium);
37-
                			return $db->update("sites", $data, "site_id=" . $_POST["id"]);
37+
                            return $db->update("sites", $data, "site_id=" . $_POST["id"]);
38-
              			}
38+
                          }
39-
             		}
39+
                     }
40-
            	}
40+
                }
41-
        	}
41+
            }
42-
    	}
42+
        }
43-
    	return false;
43+
        return false;
44
}