connect_error ) { err(true,"002"); } //adserver -> product_name | product_url | program | timestamp //adserver_stats -> id | referer | product_name | url | program | ip | timestamp // SPECIAL FUNCTIONS $isAdmin = false; $viewProgram = ""; if ( $product_name=="admin-links" ) { require 'admin.links.php'; } else if ( $product_name=="links-generator" ) { require 'links.generator.php'; } else if ( $product_name=="_admin-links" ) { $isAdmin = true; require 'admin.links.php'; } else if ( $product_name=="_admin" ) { $isAdmin = true; require 'admin.stats.php'; } else if ( $product_name==md5("lucanasoft-saggiamente") ) { $viewProgram = "lucanasoft"; require 'admin.stats.php'; } else if ( $product_name==md5("macshop-saggiamente") ) { $viewProgram = "macshop"; require 'admin.stats.php'; } else if ( $product_name==md5("pixmania-saggiamente") ) { $viewProgram = "pixmania"; require 'admin.stats.php'; } else if ( $product_name==md5("apmshop-saggiamente") ) { // 990c40317e4473adbd80f0ee87f8b55d $viewProgram = "apmshop"; require 'admin.stats.php'; } else if ( $product_name==md5("buydifferent-saggiamente") ) { // af038c26496937ccacf46377b54a2d2b $viewProgram = "buydifferent"; require 'admin.stats.php'; } else if ( $product_name==md5("serverplan-saggiamente") ) { // 0e4f3df9d5a22313915153cf05842d6e $viewProgram = "serverplan"; require 'admin.stats.php'; } //003. find product $sql = "SELECT * FROM adserver WHERE product_name = '$product_name'"; $result = $db->query($sql); if ( $result->num_rows == 0 ) { err(true,"003"); } $product_row = $result->fetch_assoc(); $result->free_result(); //004. save stats if ( !in_array($ip,$skip_ips) ) { // salto i boot dei motori di ricerca if ( stripos($_SERVER['HTTP_USER_AGENT'], "googlebot")===false && stripos($_SERVER['HTTP_USER_AGENT'], "IstellaBot")===false && stripos($_SERVER['HTTP_USER_AGENT'], "bingbot")===false && stripos($_SERVER['HTTP_USER_AGENT'], "bitlybot")===false && stripos($_SERVER['HTTP_USER_AGENT'], "RockMeltEmbedService")===false && stripos($_SERVER['HTTP_USER_AGENT'], "ShowyouBot")===false && stripos($_SERVER['HTTP_USER_AGENT'], "MetaURI")===false && stripos($_SERVER['HTTP_USER_AGENT'], "UnwindFetchor")===false && stripos($_SERVER['HTTP_USER_AGENT'], "ShowyouBot")===false && stripos($_SERVER['HTTP_USER_AGENT'], "EventMachine")===false && stripos($_SERVER['HTTP_USER_AGENT'], "InAGist")===false && stripos($_SERVER['HTTP_USER_AGENT'], "UnwindFetchor")===false && stripos($_SERVER['HTTP_USER_AGENT'], "facebookexternalhit")===false ) { if ( $source_defined!='' ) { $referer = $source_defined; } else { if ( stripos($_SERVER['HTTP_USER_AGENT'],"FeedBurner")!==false ) { $referer = "FeedBurner ".$referer; } } $sql = sprintf('INSERT INTO adserver_stats (referer, product_name, url, program, ip, info) VALUES ("%s","%s","%s","%s","%s","%s")', $referer, $product_name, $product_row['product_url'], $product_row['program'], $ip, $db->real_escape_string(var_export($_SERVER,true)) ); $result_save = $db->query($sql); if ( $db->affected_rows == -1 ) { err(true,"004"); } else { // b $sql2 = " UPDATE adserver SET clic=clic+1 WHERE product_name='".$product_name."'"; $result_update = $db->query($sql2); if ( $db->affected_rows == -1 ) { err(true,"004b"); } } } } $db->close(); header('Location: '.$product_row['product_url']); function err($break,$cod,$desc=""){ global $error_sentence,$product_name,$referer,$ip; $fp = @fopen('error_log', 'a'); if ( $fp ) { fwrite($fp, date("Y-m-d H:i:s")."\t[$cod]\t$ip\t$product_name\t$referer\t$desc\n"); fclose($fp); } if ( $break ) { printf("

".$error_sentence."

",$cod); if ( $desc ) print("

".$desc."

"); exit; } } function getLink($product_name){ global $base_url; return $base_url.$product_name; } function italianTimestamp($d) { list($Year,$Month,$Day) = split('-',$d); $Time=""; list($Day,$Time) = split(' ',$Day); $Time = " ". $Time ; //Remove the '-' from the standar MySQL sate format $stampeddate = mktime(12,0,0,$Month,$Day,$Year); //Create a UNIX style timestamp from the result $datevariable = date("d/m/Y",$stampeddate); return $datevariable . $Time ; } ?>