[Help] Highscores/Php problem
Hello everyone,
I have a small problem with a highscore board. The situation is this:
The game is hosted on newgrounds.com and the highscore php file ect is placed on my site. Now if i have the swf file on my site in the game folder with the php it all works fine. But when i try saving from my harddrive or newgrounds it does not save at all. All it does is send the score to the php which reads the old scores and places it in the score list and sends it back to the swf. But new scores dont get stored into the data base file from the php. To be able to read the scores from newgrounds i had to use a crossconnection.xml and load the policy in the swf. Just how can i save through the php when the swf is not in the same folder and run from anywhere else?
The score board is made after the glen rhodes tutorial you can find here on the site.
Php file:
Code:
<?php
$winscore = (int)$winscore;
// Create a Blank File if it doesn't already exist
if (!file_exists($filename))
{
$file=fopen($filename, "w");
fclose ($file);
}
// Read the file in
$oscores = file ($filename);
$numreadin = count($oscores);
// Break out the data into a new 2-d array called $tscores
for ($i = 0; $i < $numreadin; $i++)
{
$g = unserialize($oscores[$i]);
$tscores[$i][0] = $g[0];
$tscores[$i][1] = $g[1];
}
// Fill in any missing data with none/0
for ($i = $numreadin; $i < $scoresize; $i++)
{
$tscores[$i][0] = 0;
$tscores[$i][1] = "";
}
// Process the actions
// Insert a score/name
if ($action == "INSERT")
{
// Add name to end of list, and sort
$tscores[$scoresize + 1][0] = $winscore;
$tscores[$scoresize + 1][1] = $winname;
rsort ($tscores);
$file=fopen($filename, "w");
// Write them out
for ($i = 0; $i < $scoresize; $i++)
{
$st = serialize($tscores[$i]) . "\n";
fputs($file, $st);
}
fclose($file);
}
// Clear the list
if ($action == "CLEAR")
{
$k[0] = 0;
$k[1] = "no-one";
$ser = serialize($k);
$file=fopen($filename, "w");
for ($i = 0; $i < $scoresize; $i++)
{
$st = $ser . "\n";
fputs($file, $st);
}
fclose($file);
}
// Process the OUTPUT options
if ($viewtype == "HTML")
{
// HTML PAGE CREATED HERE
?>
<table cellpadding=2 cellspacing=2 border=0 width="330">
<tr align=center>
<th bgcolor="#663300" width="80"><font color="#ffff00" face="Arial, Helvetica, sans-serif" size="1">Rank</font></th>
<th bgcolor="#663300" width="126"><font color="#FFFF00" face="Arial, Helvetica, sans-serif" size="1">Name</font></th>
<th bgcolor="#663300" width="104"><font color="#FFFF00" face="Arial, Helvetica, sans-serif" size="1">Score</font></th>
</tr>
<?
for ($i = 0; $i < $scoresize; $i++)
{
echo ("<tr bgcolor='#669933' align='center'><td><font size='1' face='Arial, Helvetica, sans-serif'>");
echo ($i + 1);
echo ("</font></td><td><font size='1' face='Arial, Helvetica, sans-serif'>");
echo ($tscores[$i][1]);
echo ("</font></td><td><font size='1' face='Arial, Helvetica, sans-serif'>");
echo ($tscores[$i][0]);
echo ("</font></td></tr>");
}
?>
</table>
<?
}
// FLASH DATA CREATED HERE
if ($viewtype == "FLASH")
{
for ($i = 0; $i < $scoresize; $i++)
{
echo ("name" . $i . "=");
echo ($tscores[$i][1]);
echo ("&score" . $i . "=");
echo ($tscores[$i][0]);
echo ("&");
}
}
?>
Code in game to save/load:
Code:
System.security.loadPolicyFile("http://www.dubhdroiacht.ch/cgi-bin/novenda/crossdomain.xml");
System.security.loadPolicyFile("http://www.dubhdroiacht.ch/crossdomain.xml");
System.security.loadPolicyFile("http://dubhdroiacht.ch/cgi-bin/novenda/crossdomain.xml");
System.security.loadPolicyFile("http://dubhdroiacht.ch/crossdomain.xml");
_global.domainName = "http://dubhdroiacht.ch/cgi-bin/novenda/";
and
Code:
/************/
_root.filename = _global.domainName+"scores/highscores.sco";
_root.scoresize = 20;
_root.action = "INSERT";
_root.viewtype = "FLASH";
_root.winname = _root.name;
_root.winscore = _root.score;
_root.loadVariables(_global.domainName+"scores.php", "GET");
gotoAndStop("highScores1");
I would be glad if anyone could help me get this to work.
Edit: VengeanceMX if you read this, may be you have experience with highscores and newgrounds?
greets