= $i){ $i = $offset; $result[] = $offset; } } } $firstdot= $result[0]; $seconddot= $result[1]; $thirddot=$result[2]; $part1=substr ( $ip, 0, $firstdot); $part2=substr ( $ip, $firstdot+1, $seconddot-$firstdot-1); $part3=substr ( $ip, $seconddot+1, $thirddot-$seconddot-1); $part4=substr ( $ip, $thirddot+1, 3); $decimalip= $part1*16777216+$part2*65536+$part3*256+$part4; $sql = "SELECT * FROM `iplist` WHERE `ipfrom` <= $decimalip and `ipto` >= $decimalip"; $countrylist = mysql_query($sql) or die("$sql"); $hits=mysql_num_rows ($countrylist); $retval="Unknown"; if($hits>0){ $row = mysql_fetch_assoc($countrylist); $retval=$row['country']; } // echo ("hits: ".$hits." IP: ".$ip." Decimal IP: ".$decimalip." Retval: ".$retval); $_SESSION['country']=$retval; $rawkeyword_string = $_GET['searchval']; // In case the search value is passed between pages $referertext=$_SERVER['HTTP_REFERER']; $_SESSION['refererstring']=$referertext; $parsed_url=parse_url($referertext); $querystring=$parsed_url; $googleresult=strpos($parsed_url['host'],'google'); $yahooresult=strpos($parsed_url['host'],'yahoo'); $bingresult=strpos($parsed_url['host'],'bing'); $AOLresult=strpos($parsed_url['host'],'aol'); $askresult=strpos($parsed_url['host'],'ask.com'); $dogpileresult=strpos($parsed_url['host'],'dogpile.com'); if($googleresult !== false): parse_str($parsed_url['query'],$parsed_query_string); $rawkeyword_string=$parsed_query_string['q'].'[G]'; $_SESSION['keyword']=$rawkeyword_string; $_SESSION['engine']="Google"; elseif($yahooresult !== false): parse_str($parsed_url['query'],$parsed_query_string); $rawkeyword_string=$parsed_query_string['p'].'[Y]'; $_SESSION['keyword']=$rawkeyword_string; $_SESSION['engine']="Yahoo"; elseif($bingresult !== false): parse_str($parsed_url['query'],$parsed_query_string); $rawkeyword_string=$parsed_query_string['q'].'[B]'; $_SESSION['keyword']=$rawkeyword_string; $_SESSION['engine']="Bing"; elseif($AOLresult !== false): parse_str($parsed_url['query'],$parsed_query_string); $rawkeyword_string=$parsed_query_string['query'].'[AOL]'; $_SESSION['keyword']=$rawkeyword_string; $_SESSION['engine']="AOL"; elseif($askresult !== false): parse_str($parsed_url['query'],$parsed_query_string); $rawkeyword_string=$parsed_query_string['q'].'[Ask]'; $_SESSION['keyword']=$rawkeyword_string; $_SESSION['engine']="Ask.com"; else: $_SESSION['engine']="None"; $_SESSION['keyword']="None"; $destination="Landed"; endif; } // Session variables are now defined $keyword_string=rawurlencode($_SESSION['keyword']); // Write to Database $db = MYSQL_CONNECT($roothostname,$rootusername, $rootpassword) OR DIE("Unable to connect to database"); $db1 = mysql_select_db($dbName, $db) or die ("Couldn't select database."); $time = date("Y-m-d H:i:s"); $justdate = date("Y-m-d"); $pagename="/reward_cards"; $ip=$_SESSION['hostip']; $kw=$_SESSION['keyword']; $country=$_SESSION['country']; $engine=$_SESSION['engine']; $thissession=session_id(); $qry="INSERT INTO `clicks` (`date_clicked` , `justdate`, `ip_address` , `page`, `keyword`,`engine`,`session`, `dest_url`, `country`) VALUES ('$time', '$justdate','$ip' , '$pagename' , '$kw', '$engine', '$thissession', '$destination', '$country');"; mysql_query($qry) or die("something went wrong"); $linkbase="'; // External links $escapelink=$linkbase."Escape%20By%20Discover&searchval=".$keyword_string."'>"; $bestwesternlink=$linkbase."Best%20Western%20MasterCard&searchval=".$keyword_string."'>"; $mbnalink=$linkbase."MBNA%20PremierRewards&searchval=".$keyword_string."'>"; $mbnaworldpointslink=$linkbase."MBNA%20WorldPoints&searchval=".$keyword_string."'>"; $mbnaplatinumlink=$linkbase."MBNA%20Platinum%20Plus&searchval=".$keyword_string."'>"; $iberiaclassiclink=$linkbase."IBERIA%20Bank%20Classic&searchval=".$keyword_string."'>"; $amexpreferredlink=$linkbase."American%20Express%20Preferred%20Rewards%20Gold&searchval=".$keyword_string."'>"; $freedomlink=$linkbase."Chase Freedom Card&searchval=".$keyword_string."'>"; $zynclink=$linkbase."Zync from American Express&searchval=".$keyword_string."'>"; // $blueskylink=$linkbase."Blue Sky from American Express&searchval=".$keyword_string."'>"; // These have no keyword subid yet Use the carat to omit keyword $americandreamlink=$linkbase."American%20DreamCard%20Mastercard&searchval="."^"."'>"; $iberiavisagoldlink=$linkbase."IBERIA%20Bank%20Visa%20Gold&searchval="."^"."'>"; $iberiavisaplatinumlink=$linkbase."IBERIA%20Bank%20Visa%20Platinum&searchval="."^"."'>"; ?> Reward Cards - Search and Apply for a Credit Card at CreditScoreQuick.com
credit score quick
Featured Offer
Controlling your spending habits is really rewarding. Reward credit cards allow you to get more from every dollar you spend.

Elapsed: ".$elapsed; /* // COLIN 5/16/11 - Updated 24 to a very small value so that I can force an update an see if an error is thrown */ if($elapsed>=24){ //echo '

Update

'; //exit; $rawfile="https://www.credit.com/creditcards_xml_api/v3?af=p44532&ag=none&xpath=rewards/reward"; $newfile = "/home/httpd/vhosts/creditscorequick.com/httpdocs/credit_cards/reward_credit_cards.xml"; /* // COLIN - 5/16/11 - This is the primary focus, storing the xml */ $handle = fopen($newfile,"w+"); // Open xml file and truncate all current data //$ch = curl_init($rawfile); $ch = curl_init(); // COLIN - 5/16/11 - DO NOT NEED TO SET THE URL IN THE INITIALIZER IF WERE GOING TO set CURLOPT_URL below curl_setopt($ch, CURLOPT_URL, $rawfile); // Get the xml from credit.com curl_setopt($ch, CURLOPT_HEADER, 0); // Include the header in the output curl_setopt($ch, CURLOPT_FILE, $handle); // The file that the transfer is going to be written to, our local xml file curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); // We trust credit.com, dont worry about the cert $output = curl_exec($ch); // Execute the curl session if (curl_errno($ch)) // Check for curl errors trigger_error(curl_error($ch), E_USER_ERROR); // trigger an error if found curl_close($ch); // Close the curl session to free up resources fclose($handle); // Close our xml file /* if ($output) { echo '

cURL Good

'; } else { echo '

cURL Went Wrong

'; } exit; */ /* // COLIN - 5/16/11 - DONE WITH BUG FIX UPDATES ON CURL */ // Update Database include("../db/dataconf.php"); $db = MYSQL_CONNECT($roothostname,$rootusername, $rootpassword) OR DIE("Unable to connect to database"); $db1 = mysql_select_db($dbName, $db) or die ("Couldn't select database."); $file = "reward_credit_cards.xml"; $xml_parser = xml_parser_create(); if (!($fp = fopen($file, "r"))) { die("could not open XML input"); } $data = fread($fp, filesize($file)); fclose($fp); xml_parse_into_struct($xml_parser, $data, $vals, $index); xml_parser_free($xml_parser); $params = array(); $curid = 0; $curlink=""; $thisid="" ; $thisurl="" ; /* // COLIN 5/16/11 - FIX PROBLEMS WITH XML PARSING */ foreach ($vals as $xml_elem) { if ($xml_elem['type'] == 'complete') { if($xml_elem['tag'] == "ID") { $curid++; } $tag = $xml_elem['tag']; if ($tag == "BULLET" && isset($xml_elem['value'])) { // COLIN - 5/16/11 - HAVE TO CHECK IF VALUE IS ACTUALLY SET, IT MIGHT NOT BE if(!array_key_exists("BULLET",$params[$curid])){ $params[$curid]["BULLET"] =$xml_elem['value']; }else if(!array_key_exists("BULLET1",$params[$curid])){ $params[$curid]["BULLET1"] =$xml_elem['value']; }else if(!array_key_exists("BULLET2",$params[$curid])){ $params[$curid]["BULLET2"] =$xml_elem['value']; }else if(!array_key_exists("BULLET3",$params[$curid])){ $params[$curid]["BULLET3"] =$xml_elem['value']; }else if(!array_key_exists("BULLET4",$params[$curid])){ $params[$curid]["BULLET4"] =$xml_elem['value']; } } elseif (isset($xml_elem['value'])) { // COLIN - 5/16/11 - HAVE TO CHECK IF VALUE IS SET, IT MIGHT NOT BE $params[$curid][$tag] = $xml_elem['value']; } } } // for displaying the parsed contents in good format. foreach($params as $items){ $thisitem=$items; foreach($items as $key=>$item){ $thisitem=$key; switch ($thisitem) { case "ID": $thisid=$item; break; case "LINK": $thisurl=$item; break; default: break; } //switch if ($thisid != "" AND $thisurl != "") { $sqltext="SELECT * FROM links WHERE `description` LIKE '".$thisid."'"; $result=mysql_query($sqltext); $num_rows = mysql_num_rows($result); $thisurl=substr($thisurl,0,-4); $time = date("Y-m-d H:i:s"); if ($num_rows==0){ $qry= "INSERT INTO `links` (`offer_id`, `description`, `URL`, `appendable`, `updated`) VALUES (NULL, '$thisid', '$thisurl', 1,'$time');"; mysql_query($qry) or die("Unable to Add New Card"); }else{ $sql = 'UPDATE `links` SET `URL` = "'.$thisurl.'" WHERE `description` = "'.$thisid.'" LIMIT 1;'; $sql = 'UPDATE `links` SET `updated` = "'.$time.'" WHERE `description` = "'.$thisid.'" LIMIT 1;'; mysql_query($sql) or die("Unable to Update"); } //else numrows 0 $thisid="" ; $thisurl="" ; } // endif if thisid and url populated } //foreach items } // foreach param } // EndIf update needed. // File is up-to-date. Begin $file = "reward_credit_cards.xml"; $xml_parser = xml_parser_create(); if (!($fp = fopen($file, "r"))) { die("could not open XML input"); } $data = fread($fp, filesize($file)); fclose($fp); xml_parse_into_struct($xml_parser, $data, $vals, $index); xml_parser_free($xml_parser); $params = array(); $curid = 0; foreach ($vals as $xml_elem) { if ($xml_elem['type'] == 'complete') { if($xml_elem['tag'] == "ID"){ $curid++; } /* // COLIN 5/16/11 - FIX PROBLEMS WITH XML PARSING */ $tag = $xml_elem['tag']; if($tag=="BULLET" && isset($xml_elem['value'])){ // COLIN - 5/16/11 - HAVE TO CHECK IF VALUE IS SET, IT MIGHT NOT BE if(!array_key_exists("BULLET",$params[$curid])){ $params[$curid]["BULLET"] =$xml_elem['value']; }else if(!array_key_exists("BULLET1",$params[$curid])){ $params[$curid]["BULLET1"] =$xml_elem['value']; }else if(!array_key_exists("BULLET2",$params[$curid])){ $params[$curid]["BULLET2"] =$xml_elem['value']; }else if(!array_key_exists("BULLET3",$params[$curid])){ $params[$curid]["BULLET3"] =$xml_elem['value']; }else if(!array_key_exists("BULLET4",$params[$curid])){ $params[$curid]["BULLET4"] =$xml_elem['value']; } } elseif (isset($xml_elem['value'])) { // COLIN - 5/16/11 - HAVE TO CHECK IF VALUE IS SET, IT MIGHT NOT BE $params[$curid][$tag] =$xml_elem['value']; } } } $bullet0=""; $bullet1=""; $bullet2=""; $bullet3=""; $bullet4=""; $bullet5=""; $bullet6=""; // for displaying the parsed contents in good format. echo ""; foreach($params as $items){ foreach($items as $key=>$item){ $thisitem=$key; switch ($thisitem) { case "NAME": $thisoffer=$item; break; case "ID": $thisid=$item; $linkbase="../offer.php?offerid="; $thisurl=$linkbase.$thisid."&searchval=".$keyword_string; break; case "BULLET": $bullet0=$item; break; case "BULLET1": $bullet1=$item; break; case "BULLET2": $bullet2=$item; break; case "BULLET3": $bullet3=$item; break; case "BULLET4": $bullet4=$item; break; case "BULLET5": $bullet5=$item; break; case "BULLET6": $bullet6=$item; break; case "IMAGE-RG": $cardimage=$item; break; case "INTRO-APR-DISPLAY": $introapr=$item; break; case "INTRO-APR-PERIOD-DISPLAY": $introaprperiod=$item; break; case "ANNUAL-FEE-DISPLAY": $annualfee=$item; break; default: break; } } ?>
'.$thisoffer.'
'; echo '
  • '.$bullet0.'
  • '; echo '
  • '.$bullet1.'
  • '; echo '
  • '.$bullet2.'
  • '; if ($bullet3<>""){ echo '
  • '.$bullet3.'
  • '; } if ($bullet4<>""){ echo '
  • '.$bullet4.'
  • '; } if ($bullet5<>""){ echo '
  • '.$bullet5.'
  • '; } if ($bullet6<>""){ echo '
  • '.$bullet6.'
  • '; } echo '

    Intro APR: '.$introapr.' Intro Period: '.$introaprperiod.' Annual fee: '.$annualfee.'

    ' ; echo 'Apply Now for your '.$thisoffer.''; echo '

    '; echo '

    '; $bullet0=""; $bullet1=""; $bullet2=""; $bullet3=""; $bullet4=""; $bullet5=""; $bullet6=""; } ?>