This is an odd one for me. I’m missing something obvious, but it’s passing me. I can run the swf “offline” and the following script posts the correct information. However, if I run the swf “online” (ie. on my server).
NOTE: website url and security usernames were removed for security reasons.
System.security.allowDomain("http://www.############.com");
System.security.allowInsecureDomain("http://www.########.com");
// the above is just here just for testing reasons
//------------------------------site name removed
var baseMC:MovieClip = this;
//================================
// XML Data
//================================
var theXML:XML = new XML();
theXML.ignoreWhite = true;
theXML.onLoad = function(success:Boolean) {
xmlStatus.text += "success: "+success +"
";
xmlStatus.text += "loaded: "+theXML.loaded +"
";
xmlStatus.text += "status: "+theXML.status +"
";
xmlStatus.text += this.statusMsg +"
";
if (success){
//var nodes = this.firstChild.childNodes; // will be used later
//usersonline_TXT.text = nodes[0].firstChild.nodeValue; // will be used later
var nodes = this.firstChild;
usersonline_TXT.text = nodes.attributes.userscount;
}else{
usersonline_TXT.text = "not loaded";
}
xmlStatus.text += " " +"
";
}
//===================================
//===================================
// XML Load/Loop
//===================================
// This is here in order to repull the user count every 1second (1000ms)
var intervalId:Number;
var duration:Number = 1000;
function executeCallback():Void {
theXML.load("http://www.#######.com/getUsers.php");
//------------------------------site name removed
}
intervalId = setInterval(this, "executeCallback", duration);
<?php
//fill in some basic info
$server = "#############.com";
$db_user = "########";
$db_pass = "########";
$database = "usersonline";
$timeoutseconds = 300;
//get the time
$timestamp = time();
$timeout = $timestamp-$timeoutseconds;
$ip1 = $_SERVER['REMOTE_ADDR'];
$file1 = $_SERVER['PHP_SELF'];
//connect to database
mysql_connect($server, $db_user, $db_pass) or die('statusMsg=Could not select database');
//insert the values
$insert = mysql_db_query($database, "INSERT INTO useronline VALUES
('$timestamp','$ip1','$file1')") ;
if(!($insert)) {
print "statusMsg=Useronline Insert Failed > ";
}
//delete values when they leave
$delete = mysql_db_query($database, "DELETE FROM useronline WHERE timestamp<$timeout");
if(!($delete)) {
print "statusMsg=Useronline Delete Failed > ";
}
//grab the results
$result = mysql_db_query($database, "SELECT DISTINCT ip FROM useronline WHERE file='$file1'");
if(!($result)) {
print "statusMsg=Useronline Select Error > ";
}
//number of rows = the number of people online
$usercount = mysql_num_rows($result);
//spit out the results
mysql_close();
echo "<?xml version=\"1.0\"?>
";
echo "<users userscount= '" . $usercount . "'>
";
echo "</userscount>
";
echo "statusMsg=complete";
?>