great hack. thx sasq.
i use the nodblocal method, but changed it to store the data in th db instead of writing a local file. post it here, perhaps someone finds this useful.
here's the code for call.php:
PHP Code:
$accessip = "255.255.255.255"; //accepts wildcards so '255.255.255.*' is ok
$ip = getenv("REMOTE_ADDR");
$accesscode = "passwd";
if (($HTTP_POST_VARS[access] == $accesscode)&&(ereg($accessip, $ip))&&(!empty($HTTP_POST_VARS)))
{
include("./admin/config.php");
include('./admin/db_mysql.php');
$DB_site=new DB_Sql_vb;
$DB_site->database=$dbname;
$DB_site->server=$servername;
$DB_site->user=$dbusername;
$DB_site->password=$dbpassword;
$DB_site->connect();
$dbpassword="";
$DB_site->password="";
unset ($HTTP_POST_VARS[access]);
$posuf = $HTTP_POST_VARS[users];
$posuf = str_replace(" ", "%20", $posuf);
$DB_site->query("UPDATE irconline SET data='".addslashes($posuf)."', timestamp='".time()."' WHERE id=1");
}
2 changes for index.php (no matter if db or nodb):
replace:
PHP Code:
if ((!file_exists($onlinefile))||(filemtime($onlinefile)<(time()-($ircfaulttime*60)))) { //check the existance and time out of the file
with
PHP Code:
$checkdate = time()-($ircfaulttime*60);
if (!($users = $DB_site->query_first("SELECT * FROM irconline WHERE id=1 AND timestamp>='$checkdate'"))) {
replace
PHP Code:
$file = fopen($onlinefile, "r");
while (!feof($file)) {
$buffer .= fgets($file, 4096);
}
fclose($file);
$buffer = strip_tags ($buffer); //get rid of any php or html tags etc
$buffer = chop($buffer); //get rid of the white space
/// routine for placeing the user details into an array and getting online numbers
$temparray = explode ("%20", $buffer);
with
PHP Code:
$temparray = explode ("%20", $users[data]);
the sql:
PHP Code:
CREATE TABLE irconline (
id int(10) unsigned NOT NULL auto_increment,
data text NOT NULL,
timestamp int(10) unsigned NOT NULL default '0',
PRIMARY KEY (id)
) TYPE=MyISAM;
INSERT INTO irconline VALUES (1,'empty',0)
that's all, everything else stays the same.