A fatal MySQL error occured\n\n".mysql_error()."\nQuery:\n------------\n".$bo."\n-----------\nURL: http://".$_SERVER["HTTP_HOST"].$_SERVER["REQUEST_URI"]."\nDate: ".date("Y-m-d H:i:s"));}die("A fatal MySQL error occured:

\n\n".mysql_error($af)."

\n\n ".$bo);}}return($c);}function z($af){GLOBAL$COUNTER;$s=mysql_fetch_array(a("SELECT language FROM cns_config",$af));include"lang/lang_".$s["language"].".php";$ch=mysql_fetch_array(a("SELECT mail_day, mail_email, mail_subject, mail_content FROM cns_config",$af));if(!empty($ch["mail_email"])){$go=0;$jn=1;if($ch["mail_day"]==0){$go=1;$ji=$LANG["yesterday"];}else{$gt=date("w",time()+$COUNTER["timeoffset"]);if($gt==0)$gt=7;if($ch["mail_day"]==$gt){$go=1;$jn=7;$ji=$LANG["last7dayes"];}}if($go==1){$dh="";if(($ch["mail_content"]&1)!=0){$dh.=$LANG["attendanceper"]." $ji\n\n";$dh.=sprintf("%10s %10s %10s %10s",$LANG["date"],$LANG["hostss"],$LANG["sessionss"],$LANG["hitss"]);$dh.="\n-------------------------------------------\n";$c=a("select LEFT(date,10) as dt,hits,hosts,users from cns_counter_total ORDER BY date desc LIMIT $jn",$af);while(($b=mysql_fetch_array($c))){$ap=sprintf("%s %10d %10d %10d\n",$b["dt"],$b["hosts"],$b["users"],$b["hits"]);$dh.=$ap;}}if(($ch["mail_content"]&2)!=0){$dh.="\n>------------------------------------------\n\n".$LANG["yesterdayreferers"]."\n\n".$LANG["count"]." ".$LANG["Ppage"]."\n----------+--------------------------------\n";$h1=date("Y-m-d H:i:s",mktime(0,0,0,date("m"),date("d")-1,date("Y"))+$COUNTER["timeoffset"]);$h2=date("Y-m-d H:i:s",mktime(23,59,59,date("m"),date("d")-1,date("Y"))+$COUNTER["timeoffset"]);$c=a("select referer,count(referer) as cnt from cns_log WHERE type=1 AND referer!='' AND date>='$h1' AND date<'$h2' group by referer order by 2 desc LIMIT 20",$af);while(($b=mysql_fetch_array($c))){$b["referer"]=str_replace(" ","%20",$b["referer"]);while(strlen($b["cnt"])<10)$b["cnt"]=".".$b["cnt"];$ap=sprintf("%s|%s\n",$b["cnt"],$b["referer"]);$dh.=$ap;}}if(($ch["mail_content"]&4)!=0){$dh.="\n>------------------------------------------\n\n".$LANG["Sspages"]."\n\n".$LANG["count"]." ".$LANG["Ppage"]."\n----------+--------------------------------\n";$c=a("select page,count(page) as cnt from cns_log WHERE page!='' AND date>='$h1' AND date<'$h2' group by page order by 2 desc LIMIT 20",$af);while(($b=mysql_fetch_array($c))){while(strlen($b["cnt"])<10)$b["cnt"]=".".$b["cnt"];$b["page"]=str_replace(" ","%20",urldecode($b["page"]));$ap=sprintf("%s|%s\n",$b["cnt"],$b["page"]);$dh.=$ap;}$dh=$dh."\n\nhttp://".$_SERVER["HTTP_HOST"]."/cnstats/\n(c) CN-Software.com (www.cnstats.com)\n\n".date("Y-m-d H:i:s",time()+$COUNTER["timeoffset"])."\n";}$ch["mail_subject"]=str_replace("%Y",date("Y",time()+$COUNTER["timeoffset"]),$ch["mail_subject"]);$ch["mail_subject"]=str_replace("%d",date("d",time()+$COUNTER["timeoffset"]),$ch["mail_subject"]);$ch["mail_subject"]=str_replace("%m",date("m",time()+$COUNTER["timeoffset"]),$ch["mail_subject"]);if(empty($LANG["charset"]))$LANG["charset"]="windows-1251";if(!mail($ch["mail_email"],$ch["mail_subject"],$dh,"From: \"CNStats\" <".$ch["mail_email"].">\nContent-type: text/plain; charset=".$LANG["charset"],"-f".$ch["mail_email"])){mail($ch["mail_email"],$ch["mail_subject"],$dh,"From: \"CNStats\" <".$ch["mail_email"].">\nContent-type: text/plain; charset=".$LANG["charset"]);}}}}function aa(){global$COUNTER;$c=a("SHOW TABLE STATUS",$COUNTER["CONN"]);$cv=0;while($b=mysql_fetch_array($c,MYSQL_ASSOC)){while(list($y,$ad)=each($b)){if($y=="Data_length"&&(substr($fd,0,4)=="cns_"))$cv+=$ad;if($y=="Index_length"&&(substr($fd,0,4)=="cns_"))$cv+=$ad;if($y=="Name")$fd=$ad;}}a("INSERT IGNORE INTO cns_size SET date=NOW(), size='".$cv."';",$COUNTER["CONN"]);$gh=intval($COUNTER["savelog"]);if($gh<1||$gh>300)$gh=300;a("DELETE FROM cns_today",$COUNTER["CONN"]);a("DELETE FROM cns_log WHERE date<'".date("Y-m-d H:i:s",mktime(0,0,0,date("m"),date("d")-$gh,date("Y"))+$COUNTER["timeoffset"])."'",$COUNTER["CONN"]);z($COUNTER["CONN"]);mysql_close($COUNTER["CONN"]);}function y($ml,$mm,$mk,$mj){GLOBAL$STATS_CONF,$COUNTER,$cq,$CNSTATS_TITLE;$jm=false;if(!is_array($COUNTER["excludeip"])){$gp1=$COUNTER["excludeip"];$gp2=$COUNTER["excludemask"];$COUNTER["excludemask"]=$COUNTER["excludeip"]=Array();$COUNTER["excludeip"][]=$gp1;$COUNTER["excludemask"][]=$gp2;}$ef=false;while(list($y,$ad)=each($COUNTER["excludeip"])){$kc=ip2long($ad);$jj=ip2long($COUNTER["excludemask"][$y]);if((ip2long($_SERVER["REMOTE_ADDR"])&$jj)==($kc&$jj)){$ef=true;break;}}if(version_compare(phpversion(),"4.2.0",">="))$af=@mysql_connect($STATS_CONF["sqlhost"],$STATS_CONF["sqluser"],$STATS_CONF["sqlpassword"],TRUE);else$af=@mysql_connect($STATS_CONF["sqlhost"],$STATS_CONF["sqluser"],$STATS_CONF["sqlpassword"]);if(!$af)return;if(!@mysql_select_db($STATS_CONF["dbname"],$af))return;if($ef){$c=a("SELECT t_hits,hits,hosts FROM cns_counter;",$af);$STATS_CONF=mysql_fetch_array($c,MYSQL_ASSOC);mysql_close($af);return;}if(is_array($STATS_CONF["sqlinstructions"]))foreach($STATS_CONF["sqlinstructions"]as$bs)a($bs,$af);$c=a("UPDATE cns_counter SET last='".date("d",time()+$COUNTER["timeoffset"])."';",$af);if(mysql_affected_rows()==1){ignore_user_abort(1);@set_time_limit(0);$au=date("Y-m-d H:i:s",mktime(0,0,0,date("m"),date("d")-1,date("Y"))+$COUNTER["timeoffset"]);$c=a("SELECT hits,hosts,users FROM cns_counter",$af);a("UPDATE cns_counter SET hits=0, hosts=0, users=0;",$af);for($a=0;$a";$ab=intval($ab);if($STATS_CONF["graph"]==1){$co=$STATS_CONF["page"];$gv=$STATS_CONF["referer"];$ak=mysql_escape_string($STATS_CONF["title"]);$cs=$STATS_CONF["res"];$ga=$STATS_CONF["depth"];}else{if(isset($STATS_CONF["page"]))$co=urlencode(htmlspecialchars($STATS_CONF["page"]));else$co=urlencode(htmlspecialchars("http://".$_SERVER["HTTP_HOST"].$_SERVER["REQUEST_URI"]));if(isset($STATS_CONF["referer"]))$gv=htmlspecialchars($STATS_CONF["referer"]);else$gv=htmlspecialchars($_SERVER["HTTP_REFERER"]);$ak=mysql_escape_string($CNSTATS_TITLE);$cs=$ga=0;}$au=date("Y-m-d H:i:s",time()+$COUNTER["timeoffset"]);$du=htmlspecialchars($_SERVER["HTTP_ACCEPT_LANGUAGE"]);if($STATS_CONF["is_cookie"]==1){$cf=intval($_COOKIE["cnsuid"]);a("SELECT GET_LOCK('cnstatslock',60);",$af);if($cf!=0)$aw1=0;else{$c=a("select max(uid) from cns_log",$af);$cf=mysql_result($c,0,0)+1;$aw1=1;@setcookie("cnsuid",$cf,mktime(23,59,59,date("m"),date("d"),date("Y")),"/");}$c=a("SELECT UNIX_TIMESTAMP(date) as date,hid FROM cns_today WHERE ip='$aa' AND proxy='$bj';",$af);if(mysql_num_rows($c)==0){$c1=a("SELECT max(hid) FROM cns_log;",$af);$dw=mysql_result($c1,0,0)+1;$fa=1;mysql_free_result($c1);a("INSERT IGNORE INTO cns_today (ip,proxy,date, uid, hid) VALUES ('$aa','$bj',NOW(),'$cf','$dw')",$af);}else{$fa=0;$dw=mysql_result($c,0,1);a("UPDATE cns_today SET date=NOW()".$gw." WHERE ip='$aa' AND proxy='$bj';",$af);}a("SELECT RELEASE_LOCK('cnstatslock');",$af);}else{a("SELECT GET_LOCK('cnstatslock',60);",$af);$c=a("SELECT UNIX_TIMESTAMP(date) as date,uid,hid FROM cns_today WHERE ip='$aa' AND proxy='$bj';",$af);if(mysql_num_rows($c)==0){$fa=1;$aw1=1;$c1=a("SELECT max(hid), max(uid) FROM cns_log;",$af);$dw=mysql_result($c1,0,0)+1;$cf=mysql_result($c1,0,1)+1;mysql_free_result($c1);a("INSERT IGNORE INTO cns_today (ip,proxy,date, uid, hid) VALUES ('$aa','$bj',NOW(),'$cf','$dw')",$af);}else{$dw=mysql_result($c,0,2);$fa=0;if(mysql_result($c,0,0)+3600country_code;$di=mysql_escape_string($ej->city."|".intval($ej->latitude*10)."|".intval($ej->longitude*10));}elseif(is_file($cq."cnstats/geoip/GeoIP.dat")){include($cq."cnstats/geoip/geoip.inc");$dx=geoip_open($cq."cnstats/geoip/GeoIP.dat",GEOIP_STANDARD);$bg=geoip_country_code_by_addr($dx,$gk);geoip_close($dx);}else{$bg="";$di="";}if($bg!="")$bg=(ord($bg[0])<<8)+ord($bg[1]);else$bg=0;}a("INSERT ".$COUNTER["sqlwritelog"]." INTO cns_log (date,ip,type,proxy,page,agent,referer,language,type1,uid,hid,res,depth,cookie,country,city,title) VALUES ('".$au."','".$aa."',".$fa.",'".$bj."','".mysql_escape_string($co)."','".$kd."','".mysql_escape_string($gv)."','".$du."','".$aw1."','".$cf."','".$dw."','".$cs."','".$ga."','".$ab."','".$bg."','".$di."','".$ak."')",$af);if($COUNTER["type"]==3){if(empty($COUNTER["domain"])){$COUNTER["domain"]="http://".$_SERVER["HTTP_HOST"];while(substr($COUNTER["domain"],-1)=="/")$COUNTER["domain"]=substr($COUNTER["domain"],0,-1);}print"";}$c=a("SELECT hits,hosts,t_hits,t_hosts,users,t_users FROM cns_counter",$af);if(mysql_num_rows($c)!=1){a("INSERT INTO cns_counter SET hits='1', hosts='1', t_hits='1', t_hosts='1', users='1', t_users='1'",$af);$bd=1;$bb=1;$gn=1;$gr=1;}else{$bd=mysql_result($c,0,0)+1;$gn=mysql_result($c,0,2)+1;$bb=mysql_result($c,0,1);$gr=mysql_result($c,0,3);$bh=mysql_result($c,0,4);$jq=mysql_result($c,0,5);if($fa==1){$bb++;$gr++;}if($aw1==1){$bh++;$jq++;}a("UPDATE cns_counter SET hits='$bd', hosts='$bb', t_hits='$gn', t_hosts='$gr', users='$bh', t_users='$jq';",$af);}$STATS_CONF["hits"]=$bd;$STATS_CONF["hosts"]=$bb;$STATS_CONF["t_hits"]=$gn;if(!$jm)mysql_close($af);}y($STATS_CONF["sqlhost"],$STATS_CONF["sqluser"],$STATS_CONF["sqlpassword"],$STATS_CONF["dbname"]);error_reporting($mc);?>