xAdz
04-18-2010, 12:12 PM
Could somebody PLEASE alter this script to not use allow_url_fopen (which is blocked on my host, 3ix) to use cURL (which they reccomend).
I have absaloutley NO idea whatsoever, any help would be enormously appreciated.
The code is below.
<?php
// Mochiads RSS Game Grabber
// Developed by Scott Lewis at www.worksafegames.com
// To work with phpArcadeScript v3.0
set_time_limit(8000);
$category['Action']="1";
$category['Adventure']="33";
$category['Board Game']="34";
$category['Casino']="28";
$category['Dress-Up']="40";
$category['Driving']="41";
$category['Fighting']="42";
$category['Other']="7";
$category['Puzzles']="4";
$category['Shooting']="38";
$category['Sports']="2";
$defaultcategory="no";
include_once("../includes/config.php");
if(empty($mochifeedurl)){
echo "The Mochiads RSS Feed is not listed in your config.php file.<br/><br/>Please login to your <a href=\"https://www.mochiads.com/r/06b1921204bda96b\">Mochiads</a> account and grab your customerid number.
Then go to you admin panel to input it:<br/><br/>
If you haven't signed up for a <a href=\"https://www.mochiads.com/r/06b1921204bda96b\">Mochiads</a> account, head over to <a href=\"https://www.mochiads.com/r/06b1921204bda96b\">Mochiads</a> and signup for a publisher account.<br/>";
return;
}
$feedurl=$mochifeedurl;
// Now that we selected a feed, its time to grab it!
$feed = $feedurl;
$data = implode("", file($feed));
preg_match_all ("/<entry>([^`]*?)<\/entry>/", $data, $matches);
foreach ($matches[0] as $match) {
// First Get The Game Title
preg_match ("/<title>([^`]*?)<\/title>/", $match, $temp);
$title = ucwords(strtolower(stripslashes($temp[1])));
preg_match ("/<media:description>([^`]*?)<\/media:description>/", $match, $temp);
$description = stripslashes($temp[1]);
preg_match ("/<media:keywords>([^`]*?)<\/media:keywords>/", $match, $temp);
$tags = stripslashes($temp[1]);
preg_match ("/<media:thumbnail([^`]*?)url=\"([^`]*?)\"/", $match, $temp);
$image = stripslashes($temp[2]);
preg_match ("/<media:player([^`]*?)url=\"([^`]*?)\"/", $match, $temp);
$filename = stripslashes($temp[2]);
preg_match ("/<category term=\"([^`]*?)\"/", $match, $temp);
$categoryname = stripslashes($temp[1]);
if($category[''.$categoryname.'']=="no")
$cat="";
elseif(!empty($category[''.$categoryname.'']))
$cat=$category[''.$categoryname.''];
else
$cat=$defaultcategory;
preg_match ("/<id>urn:uuid:([^`]*?)<\/id>/", $match, $temp);
$mochi = stripslashes($temp[1]);
echo "$title<br/>$image<br/>$filename<br/>$description<br/>$tags<br/>$categoryname<br/>$cat<br/>$mochi<br/><br/>";
if(!empty($title) && !empty($image) && !empty($filename) && !empty($mochi) && !empty($cat)){
// Check to see if url is already in system.
$query2 = "SELECT gameid from games WHERE mochi = '$mochi'";
$result2 = mysql_query($query2);
if (mysql_num_rows($result2)>0)
{
}else{
$alphanum = "APBHCPDEFGHIJKLILNKMDRNOPPERQRSTUVWXYZ123456789";
// generate a random 3 character code to play in front of a duplicate file name that
// has been transferred.
$rand = substr(str_shuffle($alphanum), 0, 3);
$filedirectory = "../games/files/";
if ($auto_chmod ==1)
chmod("$filedirectory",0777);
$name = $filename;
while(strstr($name,"/")){
$name = substr($name,strpos($name,"/")+1,999);
}
$newname = $filedirectory.$name;
// End -- Get the file name. (Dont Edit)
// Make sure that filename isn't already in the directory ... if it is, rename it
if (file_exists($newname))
{
$name = $rand.'_'.$name;
$newname = $filedirectory.$name;
}
// End the renaming
if ($transfer_type == 1){
copy($filename, $newname);
}else{
$ch = curl_init ($filename);
$fp = fopen ($newname, "w");
curl_setopt ($ch, CURLOPT_FILE, $fp);
curl_setopt ($ch, CURLOPT_HEADER, 0);
curl_exec ($ch);
curl_close ($ch);
fclose ($fp);
}
if ($auto_chmod ==1)
chmod("$filedirectory",0755);
$alphanum = "APBHCPDEFGHIJKLILNKMDRNOPPERQRSTUVWXYZ123456789";
// generate a random 3 character code to play in front of a duplicate file name that
// has been transferred.
$rand = substr(str_shuffle($alphanum), 0, 3);
$imagedirectory = "../games/images/";
if ($auto_chmod ==1)
chmod("$imagedirectory",0777);
$name2 = $image;
while(strstr($name2,"/")){
$name2 = substr($name2,strpos($name2,"/")+1,999);
}
$newname2 = $imagedirectory.$name2;
// End -- Get the file name. (Dont Edit)
// Make sure that filename isn't already in the directory ... if it is, rename it
if (file_exists($newname2))
{
$name2 = $rand.'_'.$name2;
$newname2 = $imagedirectory.$name2;
}
// End the renaming
if ($transfer_type == 1){
copy($image, $newname2);
}else{
$ch = curl_init ($image);
$fp = fopen ($newname2, "w");
curl_setopt ($ch, CURLOPT_FILE, $fp);
curl_setopt ($ch, CURLOPT_HEADER, 0);
curl_exec ($ch);
curl_close ($ch);
fclose ($fp);
}
if ($auto_chmod ==1)
chmod("$imagedirectory",0755);
$now = time();
$title=addslashes($title);
$description=addslashes($description);
$update_item = mysql_query("INSERT INTO games
set gametitle = '$title',
gamedesc = '$description',
gamefile = '$name',
gameicon = '$name2',
gamekeywords='$tags',
gamestatus = '1',
category = '$cat',
mochi='$mochi',
dateadded = '$now'");
echo "Just Added <b>$title</b><br/>";
}
}
}
?>
I have absaloutley NO idea whatsoever, any help would be enormously appreciated.
The code is below.
<?php
// Mochiads RSS Game Grabber
// Developed by Scott Lewis at www.worksafegames.com
// To work with phpArcadeScript v3.0
set_time_limit(8000);
$category['Action']="1";
$category['Adventure']="33";
$category['Board Game']="34";
$category['Casino']="28";
$category['Dress-Up']="40";
$category['Driving']="41";
$category['Fighting']="42";
$category['Other']="7";
$category['Puzzles']="4";
$category['Shooting']="38";
$category['Sports']="2";
$defaultcategory="no";
include_once("../includes/config.php");
if(empty($mochifeedurl)){
echo "The Mochiads RSS Feed is not listed in your config.php file.<br/><br/>Please login to your <a href=\"https://www.mochiads.com/r/06b1921204bda96b\">Mochiads</a> account and grab your customerid number.
Then go to you admin panel to input it:<br/><br/>
If you haven't signed up for a <a href=\"https://www.mochiads.com/r/06b1921204bda96b\">Mochiads</a> account, head over to <a href=\"https://www.mochiads.com/r/06b1921204bda96b\">Mochiads</a> and signup for a publisher account.<br/>";
return;
}
$feedurl=$mochifeedurl;
// Now that we selected a feed, its time to grab it!
$feed = $feedurl;
$data = implode("", file($feed));
preg_match_all ("/<entry>([^`]*?)<\/entry>/", $data, $matches);
foreach ($matches[0] as $match) {
// First Get The Game Title
preg_match ("/<title>([^`]*?)<\/title>/", $match, $temp);
$title = ucwords(strtolower(stripslashes($temp[1])));
preg_match ("/<media:description>([^`]*?)<\/media:description>/", $match, $temp);
$description = stripslashes($temp[1]);
preg_match ("/<media:keywords>([^`]*?)<\/media:keywords>/", $match, $temp);
$tags = stripslashes($temp[1]);
preg_match ("/<media:thumbnail([^`]*?)url=\"([^`]*?)\"/", $match, $temp);
$image = stripslashes($temp[2]);
preg_match ("/<media:player([^`]*?)url=\"([^`]*?)\"/", $match, $temp);
$filename = stripslashes($temp[2]);
preg_match ("/<category term=\"([^`]*?)\"/", $match, $temp);
$categoryname = stripslashes($temp[1]);
if($category[''.$categoryname.'']=="no")
$cat="";
elseif(!empty($category[''.$categoryname.'']))
$cat=$category[''.$categoryname.''];
else
$cat=$defaultcategory;
preg_match ("/<id>urn:uuid:([^`]*?)<\/id>/", $match, $temp);
$mochi = stripslashes($temp[1]);
echo "$title<br/>$image<br/>$filename<br/>$description<br/>$tags<br/>$categoryname<br/>$cat<br/>$mochi<br/><br/>";
if(!empty($title) && !empty($image) && !empty($filename) && !empty($mochi) && !empty($cat)){
// Check to see if url is already in system.
$query2 = "SELECT gameid from games WHERE mochi = '$mochi'";
$result2 = mysql_query($query2);
if (mysql_num_rows($result2)>0)
{
}else{
$alphanum = "APBHCPDEFGHIJKLILNKMDRNOPPERQRSTUVWXYZ123456789";
// generate a random 3 character code to play in front of a duplicate file name that
// has been transferred.
$rand = substr(str_shuffle($alphanum), 0, 3);
$filedirectory = "../games/files/";
if ($auto_chmod ==1)
chmod("$filedirectory",0777);
$name = $filename;
while(strstr($name,"/")){
$name = substr($name,strpos($name,"/")+1,999);
}
$newname = $filedirectory.$name;
// End -- Get the file name. (Dont Edit)
// Make sure that filename isn't already in the directory ... if it is, rename it
if (file_exists($newname))
{
$name = $rand.'_'.$name;
$newname = $filedirectory.$name;
}
// End the renaming
if ($transfer_type == 1){
copy($filename, $newname);
}else{
$ch = curl_init ($filename);
$fp = fopen ($newname, "w");
curl_setopt ($ch, CURLOPT_FILE, $fp);
curl_setopt ($ch, CURLOPT_HEADER, 0);
curl_exec ($ch);
curl_close ($ch);
fclose ($fp);
}
if ($auto_chmod ==1)
chmod("$filedirectory",0755);
$alphanum = "APBHCPDEFGHIJKLILNKMDRNOPPERQRSTUVWXYZ123456789";
// generate a random 3 character code to play in front of a duplicate file name that
// has been transferred.
$rand = substr(str_shuffle($alphanum), 0, 3);
$imagedirectory = "../games/images/";
if ($auto_chmod ==1)
chmod("$imagedirectory",0777);
$name2 = $image;
while(strstr($name2,"/")){
$name2 = substr($name2,strpos($name2,"/")+1,999);
}
$newname2 = $imagedirectory.$name2;
// End -- Get the file name. (Dont Edit)
// Make sure that filename isn't already in the directory ... if it is, rename it
if (file_exists($newname2))
{
$name2 = $rand.'_'.$name2;
$newname2 = $imagedirectory.$name2;
}
// End the renaming
if ($transfer_type == 1){
copy($image, $newname2);
}else{
$ch = curl_init ($image);
$fp = fopen ($newname2, "w");
curl_setopt ($ch, CURLOPT_FILE, $fp);
curl_setopt ($ch, CURLOPT_HEADER, 0);
curl_exec ($ch);
curl_close ($ch);
fclose ($fp);
}
if ($auto_chmod ==1)
chmod("$imagedirectory",0755);
$now = time();
$title=addslashes($title);
$description=addslashes($description);
$update_item = mysql_query("INSERT INTO games
set gametitle = '$title',
gamedesc = '$description',
gamefile = '$name',
gameicon = '$name2',
gamekeywords='$tags',
gamestatus = '1',
category = '$cat',
mochi='$mochi',
dateadded = '$now'");
echo "Just Added <b>$title</b><br/>";
}
}
}
?>
