[Comoblog-commit] comoblog/modules/mod_contentextra/include mod_contentextra.inc.php, NONE, 1.1
Status: Inactive
Brought to you by:
markwallis
|
From: iamdecal <iam...@us...> - 2006-10-22 11:44:23
|
Update of /cvsroot/comoblog/comoblog/modules/mod_contentextra/include In directory sc8-pr-cvs4.sourceforge.net:/tmp/cvs-serv27709/modules/mod_contentextra/include Added Files: mod_contentextra.inc.php Log Message: work in progress, ditching this server cos its borked ;( --- NEW FILE: mod_contentextra.inc.php --- <?php // stops the twats getting into the referer list function getBlocklist(){ $BLOCKLIST = "contentextra2_http_referer not like '%igor.office.sift.co.uk%' and contentextra2_http_referer not like '%iamdecal.co.uk%' and contentextra2_http_referer not like '' and contentextra2_http_referer not like ' ' and contentextra2_request_uri not like '%page=stats' and contentextra2_remote_host not like '213.25.42.64' and contentextra2_remote_host not like '95.225.177.131' and contentextra2_remote_host not like '%iamdecal.plus.net' and contentextra2_remote_host not like '%.plus.net%' and contentextra2_remote_host not like '%.sift.co.uk' and contentextra2_remote_host not like '%.sift.com' and contentextra2_http_referer not like '%tramadol%' and contentextra2_http_referer not like '%vicodin%' and contentextra2_http_referer not like '%adipex%' and contentextra2_http_referer not like '%buy-ambien%' and contentextra2_http_referer not like '%phentermine%' and contentextra2_http_referer not like '%valium%' and contentextra2_http_referer not like '%tamiflu%' and contentextra2_http_referer not like '%genaholincorporated.com%' and contentextra2_http_referer not like '%firsthorizonmtg.com%' and contentextra2_http_referer not like '%andrewsaluk.com%' and contentextra2_http_referer not like '%poker%' and contentextra2_http_referer not like '%ma.gnolia%' and contentextra2_remote_host not like '%layeredtech.com' and contentextra2_http_referer not like '%.info/' and contentextra2_http_referer not like '%4dspots.com%'"; return $BLOCKLIST; } function mod_contentextra_init () { $query = "insert into comoblog_mod_contentextra (contentextra_url,contentextra_firsthit) values ('" . $_SERVER['REQUEST_URI'] ."',now()) "; // #echo $query; $res = mysql_query($query); # #echo $res; if (!$res) return (false); $item['id'] = mysql_insert_id(); return ($item); } function mod_contentextra_rate () { $score ="0"; $votes ="+0" ; if(isset($_GET['score'])) { $score= $_GET['score']; $votes = "+1"; } $url = $_GET['url'] ; //$url = $_SERVER['HTTP_REFERER']; $query = "update comoblog_mod_contentextra set contentextra_votes = contentextra_votes ".$votes.", contentextra_score = contentextra_score + ".$score." where contentextra_url = '". urldecode($url) ."' "; $res = mysql_query($query); $rows=mysql_affected_rows(); $info =mysql_info(); //#echo "<BR><BR>.." . $res; // if (!$res) // return (false); /* define_syslog_variables(); openlog("mod_contentextra_rate", LOG_NDELAY, LOG_LOCAL0); syslog(LOG_ALERT,"query " . $query); syslog(LOG_ALERT,"res (" . $res . ")"); syslog(LOG_ALERT,"rows (" . $rows . ")"); syslog(LOG_ALERT,"info (" . $info . ")"); syslog(LOG_ALERT,"url " . $url); syslog(LOG_ALERT,"url urlencode" . urlencode($url)); syslog(LOG_ALERT,"url urldecode" . urldecode($url)); #echo $query; */ return ($url); } // once we have done the init, we can update as required function mod_contentextra_process () { $query = " update comoblog_mod_contentextra set contentextra_hits =contentextra_hits +1, contentextra_lasthit =contentextra_thishit , contentextra_thishit =now() where contentextra_url = '". $_SERVER['REQUEST_URI'] ."' "; // #echo $query; $res = mysql_query($query); // define_syslog_variables(); // openlog("mod_contentextra_process", LOG_NDELAY, LOG_LOCAL0); // syslog(LOG_ALERT,"query " . $query); // syslog(LOG_ALERT,"res " . $res); if (!$res) return (false); return ($item); } function mod_contentextra_display () { $query = "select ".CFG_MYSQL_TABPREFIX."mod_contentextra.* ,DATE_FORMAT(contentextra_thishit,'%d %m %y <br> at %T') as thishit_nice, DATE_FORMAT(contentextra_lasthit,'%d %m %y <br> at %T')as lasthit_nice, DATE_FORMAT(contentextra_firsthit,'%d %m %y <br> at %T') as firsthit_nice, ( contentextra_score/ contentextra_votes ) as contentextra_rating from ".CFG_MYSQL_TABPREFIX."mod_contentextra where contentextra_url = '".$_SERVER['REQUEST_URI']."' limit 1"; //#echo $query; $res = mysql_query($query); if (!$res || !mysql_num_rows($res)) return (false); $items = array(); while ($row = mysql_fetch_assoc($res)) { $items[] = $row; } return ($items); } function mod_contentextra2_display () { $query = "select count(*) from ".CFG_MYSQL_TABPREFIX."mod_contentextra2 where contentextra2_request_uri = '".$_SERVER['REQUEST_URI']."'"; // #echo $query; $res = mysql_query($query); if (!$res || !mysql_num_rows($res)) return (false); $items = array(); while ($row = mysql_fetch_assoc($res)) { $items[] = $row; } return ($items); } function mod_contentextra2_init () { $hostname = $_SERVER['REMOTE_HOST']; if ($hostname == "") { $hostname = gethostbyaddr($_SERVER['REMOTE_ADDR']); } $query = "insert into comoblog_mod_contentextra2 ( contentextra2_php_self, contentextra2_server_name, contentextra2_request_method, contentextra2_query_string, contentextra2_http_accept, contentextra2_http_referer, contentextra2_http_user_agent, contentextra2_remote_addr, contentextra2_remote_host, contentextra2_script_filename, contentextra2_path_translated, contentextra2_script_name, contentextra2_request_uri, contentextra2_php_auth_user, contentextra2_added, contentextra2_addeddate, contentextra2_skin) values ( '" . $_SERVER['PHP_SELF'] ."', '" . $_SERVER['SERVER_NAME'] ."', '" . $_SERVER['REQUEST_METHOD'] ."', '" . $_SERVER['QUERY_STRING'] ."', '" . $_SERVER['HTTP_ACCEPT'] ."', '" . $_SERVER['HTTP_REFERER'] ."', '" . $_SERVER['HTTP_USER_AGENT'] ."', '" . $_SERVER['REMOTE_ADDR'] ."', '" . $hostname ."', '" . $_SERVER['SCRIPT_FILENAME'] ."', '" . $_SERVER['PATH_TRANSLATED'] ."', '" . $_SERVER['SCRIPT_NAME'] ."', '" . $_SERVER['REQUEST_URI'] ."', '" . $_SERVER['PHP_AUTH_USER'] ."', '" . time ."', now(), 'phpdefault' );"; //#echo $query; $res = mysql_query($query); if (!$res) return (false); $item['id'] = mysql_insert_id(); return ($item); } ################################################################################ #static page stuff $BLOCKLIST = getBlocklist(); function mod_contentextra_top_referers () { $BLOCKLIST = getBlocklist(); $query =" select contentextra2_http_referer as column1, count(*) as column2, concat(substring(contentextra2_http_referer,1,30),' ' ,substring(contentextra2_http_referer,31,30)) as column3 from comoblog_mod_contentextra2 where $BLOCKLIST group by column1, column3 order by column2 desc limit 20;"; echo "start details for mod_contentextra_top_referers"; echo "query" . $query; $res = mysql_query($query); #echo "error " . mysql_errno($res) . ": " . mysql_error($res) . "\n"; #echo "num rows " . mysql_num_rows($res); echo "res" . $res; if (!$res || !mysql_num_rows($res)) return (false); $items = array(); while ($row = mysql_fetch_assoc($res)) { $items[] = $row; } # echo mysql_num_rows($res); return ($items); } ################################################################################ #static page stuff function mod_contentextra_top_visitors () { $BLOCKLIST = getBlocklist(); $query =" select contentextra2_remote_addr as column1 , concat(substring(contentextra2_remote_host,1,30),' ' ,substring(contentextra2_remote_host,31,30)) as column2 , count(*) as column3 from comoblog_mod_contentextra2 where $BLOCKLIST group by column1, column2 order by column3 desc limit 20;"; echo "q" . $query; $res = mysql_query($query); echo "r" . $res; if (!$res || !mysql_num_rows($res)) return (false); $items = array(); while ($row = mysql_fetch_assoc($res)) { $items[] = $row; } #echo mysql_num_rows($res); return ($items); } ################################################################################ #static page stuff function mod_contentextra_top_browsers () { $BLOCKLIST = getBlocklist(); $query = " select contentextra2_http_user_agent as column1, count(*) as column2 from comoblog_mod_contentextra2 where $BLOCKLIST group by column1 order by column2 desc limit 20;"; echo $query; $res = mysql_query($query); echo "r" . $res; if (!$res || !mysql_num_rows($res)) return (false); $items = array(); while ($row = mysql_fetch_assoc($res)) { $items[] = $row; } #echo mysql_num_rows($res); return ($items); } ################################################################################ #static page stuff function mod_contentextra_top_pages () { $BLOCKLIST = getBlocklist(); $query = " select contentextra2_request_uri as column1, count(*) as column2 from comoblog_mod_contentextra2 where $BLOCKLIST group by column1 order by column2 desc limit 20;"; echo $query; $res = mysql_query($query); echo "r" . $res; if (!$res || !mysql_num_rows($res)) return (false); $items = array(); while ($row = mysql_fetch_assoc($res)) { $items[] = $row; } echo "rows" . mysql_num_rows($res); return ($items); } function mod_contentextra_last_visitors () { $BLOCKLIST = getBlocklist(); $query =" select contentextra2_remote_addr as column1 , concat(substring(contentextra2_remote_host,1,30),' ' ,substring(contentextra2_remote_host,31,30)) as column2 , contentextra2_addeddate as column3 , contentextra2_http_referer as column4 , concat(substring(contentextra2_http_referer,1,30),' ' ,substring(contentextra2_http_referer,31,30),' ' ,substring(contentextra2_http_referer,61,30),' ' ,substring(contentextra2_http_referer,91,30)) as column5 , contentextra2_request_uri as column6 from comoblog_mod_contentextra2 where $BLOCKLIST order by column3 desc limit 20;"; #,' ' ,substring(contentextra2_http_referer,31,30),' ' #,substring(contentextra2_http_referer,61,30),' ' #,substring(contentextra2_http_referer,91,30)) as column5 , echo $query; $res = mysql_query($query); echo "r" . $res; if (!$res || !mysql_num_rows($res)) return (false); $items = array(); while ($row = mysql_fetch_assoc($res)) { $items[] = $row; } #echo mysql_num_rows($res); return ($items); } function mod_contentextra_top_skins () { $query =" select ss.skinselect_description, ss.skinselect_title,ce2.contentextra2_skin, count(ce2.contentextra2_skin) as count from comoblog_mod_contentextra2 ce2 , comoblog_mod_skinselect ss where ce2.contentextra2_skin = ss.skinselect_nav_link and ss.skinselect_visible ='Y' group by ce2.contentextra2_skin order by count desc "; echo $query; $res = mysql_query($query); echo "r" . $res; if (!$res || !mysql_num_rows($res)) return (false); $items = array(); while ($row = mysql_fetch_assoc($res)) { $items[] = $row; } #echo mysql_num_rows($res); return ($items); } function mod_contentextra_showpage_stuffer($item_text) { $query = "update ".CFG_MYSQL_TABPREFIX."mod_showpage set showpage_url = '', showpage_description = '". addslashes($item_text) ."' where lower(showpage_nav_text) = 'stats'"; #echo $query; $res = mysql_query($query); if (!$res) return (false); return ($res); } function update_missing_hosts () { $query = " SELECT DISTINCT contentextra2_remote_addr, contentextra2_remote_host FROM comoblog_mod_contentextra2 WHERE contentextra2_remote_host = ''"; # echo $query; $res = mysql_query($query); # echo "r" . $res; if (!$res || !mysql_num_rows($res)) return (false); $items = array(); while ($row = mysql_fetch_assoc($res)) { $query ="update comoblog_mod_contentextra2 set contentextra2_remote_host = '" . gethostbyaddr($row['contentextra2_remote_addr']) ."' where contentextra2_remote_host ='' and contentextra2_remote_addr = '" .$row['contentextra2_remote_addr'] ."';" ; echo $query . "\n <br />"; $res2= mysql_query($query); } #echo mysql_num_rows($res); return ($items); } ?> |