" . $u_timestamp . ")"))) { if (SQL_SHOW_ERRORS) checkerror("mysql_select", $sql_id); } $sql_numrows = @mysql_result($sql_result, 0); if ($sql_numrows > 0) { dbDisconnect($sql_id, $sql_result); return $sql_result; exit; } if (!($sql_result = dbRunQuery($sql_id, "UPDATE " . SQL_TABLE_COUNTER . " SET hits=(hits+1) WHERE rowid=1"))) { if (SQL_SHOW_ERRORS) checkerror("mysql_update", $sql_id); } if (!($sql_result = dbRunQuery($sql_id, "INSERT INTO " . SQL_TABLE_LOG . " (ip,host,browser,language,referrer,page,tstamp) VALUES (\"$u_ip\",\"$u_host\",\"$u_browser\",\"$u_lang\",\"$u_referrer\",\"$u_page\",\"$u_timestamp\")"))) { if (SQL_SHOW_ERRORS) checkerror("mysql_insert", $sql_id); } if (SQL_LOG_HITS <> "0") { $sql_result = dbRunQuery($sql_id, "SELECT rowid FROM " . SQL_TABLE_LOG . " ORDER BY rowid desc LIMIT 1"); if (!($sql_result = dbRunQuery($sql_id, "DELETE FROM " . SQL_TABLE_LOG . " WHERE rowid <= (" . @mysql_result($sql_result, 0) . " - " . SQL_LOG_HITS . ")"))) { if (SQL_SHOW_ERRORS) checkerror("mysql_delete", $sql_id); } } // ~~~~~ Free memory, close connection to MySQL server ~~~~~ dbDisconnect($sql_id, $sql_result); return $sql_result; } // ********************************************************************** function checklog($sortby, $mode) { if ($mode == "desc") { $mode_link = "asc"; } else { $mode_link = "desc"; } if (!($sql_id = dbConnect())) { if (SQL_SHOW_ERRORS) checkerror("mysql_connect", $sql_id); } $sql_query = "SELECT rowid,ip,host,browser,language,referrer,page,tstamp FROM " . SQL_TABLE_LOG . " ORDER BY " . $sortby . " " . $mode; if (LOG_NUM_HITS <> 0) { $sql_query .= " LIMIT " . LOG_NUM_HITS; } if (!($sql_result = dbRunQuery($sql_id, $sql_query))) { if (SQL_SHOW_ERRORS) checkerror("mysql_select", $sql_id); } $sql_numrows = @mysql_num_rows($sql_result); echo "$sql_numrows hits stored

"; echo "\n"; echo "\n"; echo "\t\n"; echo "\t\n"; echo "\t\n"; echo "\t\n"; echo "\t\n"; echo "\t\n"; echo "\n"; while ($sql_row = @mysql_fetch_array($sql_result)) { if ((time() - $sql_row["tstamp"]) <= (LOG_HIGHLIGHT_TIME * 3600)) { echo "\n"; } else { echo "\n"; } echo "\t\n"; echo "\t\n"; echo "\t\n"; $althost = $sql_row["host"]; if (@strlen($sql_row["host"]) > 15){ echo "\t"; }else{ echo "\t"; } $altttitle = $sql_row["page"]; if (@strlen($sql_row["page"]) > 30) { echo "\t"; }else{ echo "\t"; } echo ""; } echo "
Nr.DateIPHostReferrerPage
" . $sql_row["rowid"] ."" . date("d.m.y|H:i", $sql_row["tstamp"]) . "" . $sql_row["ip"] . "" . @substr($sql_row["host"], 0, 15) . "\n"; }else{ echo "\t" . $sql_row["host"] . "\n"; } $altrefferer = $sql_row["referrer"]; if ($sql_row['referrer'] == ''){ $sql_row['referrer'] = "-"; }else{ $sql_row['referrer'] = "$sql_row[referrer]"; } /* $sqlcheck = substr($sql_row['referrer'], 25); if ($sqlcheck == "$xmainurl"){ $sqlcheck = str_replace("$xmainurl/", "", $sqlcheck); $sql_row['referrer'] = $sqlcheck; }else{ $sql_row['referrer'] = $sql_row['referrer']; } */ /*$sql_row['referrer'] = str_replace("$xmainurl/", "index ", $sql_row['referrer']);*/ $sql_row['referrer'] = str_replace("http://www.", "", $sql_row['referrer']); if (@strlen($sql_row["referrer"]) > 30) { echo "\t" . @substr($sql_row["referrer"], 0, 30) . "..." . "" . $sql_row["referrer"] . "" . @substr($sql_row["page"], 0, 30) . "..." . "" . $sql_row["page"] . "
"; dbDisconnect($sql_id, $sql_result); return $sql_result; } function checkactive(){ if (!($sql_id = dbConnect())){ if (SQL_SHOW_ERRORS) checkerror("mysql_connect", $sql_id); } if (!($sql_result = dbRunQuery($sql_id, "SELECT COUNT(*) FROM " . SQL_TABLE_LOG . " WHERE (tstamp + " . (COUNTER_USERONLINE_TIME * 60) . " >= " . time() . ")"))){ if (SQL_SHOW_ERRORS) checkerror("mysql_select", $sql_id); } $users_online = @mysql_result($sql_result, 0); dbDisconnect($sql_id, $sql_result); // ~~~~~ Return number of users online (text/images) ~~~~~ if (COUNTER_MODE == 2) { $imghtml = ""; for ($i = 0; $i < @strlen($users_online); $i++) { $imghtml .= ""; } return $imghtml; } else { return $users_online; } } // ********************************************************************** function checkbunker($c_time) { // ~~~~~ Connect to MySQL server, activate database ~~~~~ if (!($sql_id = dbConnect())) { if (SQL_SHOW_ERRORS) checkerror("mysql_connect", $sql_id); } if ($c_time == 0) { if (!($sql_result = dbRunQuery($sql_id, "SELECT hits FROM " . SQL_TABLE_COUNTER . " WHERE (rowid=1) LIMIT 1"))) { if (SQL_SHOW_ERRORS) checkerror("mysql_select", $sql_id); } $sql_row = @mysql_fetch_array($sql_result); $hits = $sql_row["hits"] + COUNTER_HITS_OFFSET; } else { $c_time = @abs($c_time * 3600); if (!($sql_result = dbRunQuery($sql_id, "SELECT COUNT(*) FROM " . SQL_TABLE_LOG . " WHERE (tstamp + " . $c_time . " >= " . time() . ")"))) { if (SQL_SHOW_ERRORS) checkerror("mysql_select", $sql_id); } $hits = @mysql_result($sql_result, 0); } dbDisconnect($sql_id, $sql_result); if (@strlen($hits) < COUNTER_DIGITS) { while ((@strlen($hits)) < COUNTER_DIGITS) { $hits = "0" . $hits; } } if (COUNTER_MODE == 2) { $imghtml = ""; for ($i = 0; $i < @strlen($hits); $i++) { $imghtml .= ""; } return $imghtml; } else { return $hits; } } // ********************************************************************** function checkten($sql_field) { if (!($sql_id = dbConnect())) { if (SQL_SHOW_ERRORS) checkerror("mysql_connect", $sql_id); } if (!($sql_result = dbRunQuery($sql_id, "SELECT DISTINCT $sql_field, COUNT($sql_field) AS c FROM " . SQL_TABLE_LOG . " GROUP BY $sql_field ORDER BY c DESC LIMIT 10"))) { if (SQL_SHOW_ERRORS) checkerror("mysql_select", $sql_id); } echo "\n\n"; echo "\t\n"; echo "\t\t\n"; echo "\t\t\n"; echo "\t\n"; while ($sql_row = @mysql_fetch_array($sql_result)) { echo "\t\n"; echo "\t\t\n"; if (($sql_field == "referrer") || ($sql_field == "page")) { $sql_row["$sql_field"] = "" . $sql_row["$sql_field"] . ""; } echo "\t\t\n"; echo "\t\n"; } echo "
Hits" . @ucfirst($sql_field) . "
" . $sql_row["c"] . "" . $sql_row["$sql_field"] . "
\n"; dbDisconnect($sql_id, $sql_result); } function checkerror($err, $id) { switch ($err) { case "mysql_connect": $msg[1] = "CMDB"; $msg[3] = "Temp offline. Check back soon!"; break; case "mysql_create_db": $msg[1] = "CCMDB"; $msg[3] = "Temp offline. Check back soon!"; break; case "mysql_create_table": $msg[1] = "CTMDB"; $msg[3] = "Temp offline. Check back soon!"; break; case "mysql_select": $msg[1] = "QMDB"; $msg[3] = "Temp offline. Check back soon!"; break; case "mysql_insert": $msg[1] = "CIRMDB"; $msg[3] = "Temp offline. Check back soon!"; break; case "mysql_update": $msg[1] = "CURMDB"; $msg[3] = "Temp offline. Check back soon!"; break; case "mysql_delete": $msg[1] = "CDRMDB"; $msg[3] = "Temp offline. Check back soon!"; break; default: $msg[1] = "MDBE"; $msg[3] = "Temp offline. Check back soon!"; break; } if (@mysql_error($id) <> "") { $msg[2] = @mysql_error($id); } else { $msg[2] = "Unknown"; } /* die("



" . $msg[1] . "
" . $msg[3] . "

Click here to visit the index page of this site.

Thank you.
"); */ } ?>