Could the file operations make a difference?
Here is a function I put your code into. Perhaps I am not doing it correctly.
PHP Code:
function install_mochigame($gameid) {
$result = yas_query("SELECT * FROM `mochigames` WHERE `id` = '$gameid'");
$gamename = $result[1];
$thumburl = $result[7];
$gameurl = $result[2];
echo str_repeat(" ", 1024); // needed for chrome, I think IE is 256
flush();
for($x=0; $x<5; $x++)
{
sleep(1);
echo 'working ...<br>'; // <br> needed for chrome, \n might be needed for some browsers
flush();
}
set_time_limit(0);
$fileurl = str_replace("..", "", $thumburl); // Download thumbnail
$thumb = get_content_of_url($fileurl); // uses cURL functions to get file
$fileurl = str_replace("..", "", $gameurl);
$swf = get_content_of_url($fileurl); // Download game file
$fconfig = fopen("../img/" . $gamename . ".png", 'wb'); // Save thumbnail
fwrite($fconfig, $thumb);
fclose($fconfig);
empty($thumb);
$fconfig = fopen("../swf/" . $gamename . ".swf", 'wb'); // Save game file
fwrite($fconfig, $swf);
fclose($fconfig);
empty($swf);
$gamefile = 'swf/' . $gamename . '.swf';
$gamethumb = 'img/' . $gamename . '.png';
$category = explode(",", $result[8]); // Remove comma delimiter and seperate categories into array
$category = convert_category($category[0]);
$desc = clean($result[5]); //clean() sanitizes data for query
$instructions = clean($result['instructions']);
$keywords = clean($result[6]);
$gamename = clean($gamename);
$gamefile = clean($gamefile);
$gamethumb = clean($gamethumb);
$height = $result[4];
$width = $result[3];
$query = mysql_query("INSERT INTO `games` (`id`, `title`, `description`, `instructions`, `keywords`, `file`, `height`, `width`, `category`, `plays`, `code`, `type`, `thumbnail`, `ismochi`) VALUES (NULL, '$gamename', '$desc', '$instructions', '$keywords', '$gamefile', '$height', '$width', '$category', 0, '', 'SWF', '$gamethumb', 1)");
if (!$query) {
echo 'Error updating Games database';
return false;
}
$query = mysql_query("UPDATE mochigames SET isinstalled = 1 WHERE id = '{$result[0]}'");
if (!query) {
echo 'Error updating mochigame database';
return false;
}
return true;
}
Bookmarks