function get_vascogames_feed() { $Start = getTime(); $mem_limit = substr(ini_get("memory_limit"), 0, -1); global $mysqli; global $setting; set_time_limit(0); @ini_set("max_execution_time", 1000); @ini_set("default_socket_timeout", 240); $query = yasDB_select("SELECT `vasco_id` FROM vascogames", false); $tags = array(); $i = 0; $no_errors = 0; $new_games = 0; // create array of game tags for duplicate checking while ($alltags = $query->fetch_array(MYSQLI_ASSOC)) { $tags[$i] = $alltags['vasco_id']; $i++; } unset($alltags); $query->close(); $feedUrl = 'http://4v4.com/xml.php?format=xml'; $xmlfile = get_content_of_url($feedUrl); $xml = new SimpleXMLElement($xmlfile); foreach ($xml->entry as $game) { $gameid = intval(basename((string) $game->player->url, '.swf')); if (!in_array($gameid, $tags)) { $gamename = yasDB_clean((string) $game->title); $gamedesc = yasDB_clean((string) $game->children('http://search.yahoo.com/mrss/')->description); $gamecat = yasDB_clean((string) $game->children('http://search.yahoo.com/mrss/')->category); $gameurl = yasDB_clean((string) $game->player->url); $gamewidth = intval($game->player->width); $gameheight = intval($game->player->height); $thumburl1 = yasDB_clean((string) $game->thumbnail[0]->url); $thumburl2 = yasDB_clean((string) $game->thumbnail[1]->url); $sql = "INSERT INTO vascogames (`id`, `vasco_id`, `title`, `file`, `thumbnail`, `width`, `height`, `category`, `description`, `installed`, `hidden`) \n\t\t\tVALUES (NULL, {$gameid}, '{$gamename}', '{$gameurl}', '{$thumburl1}', {$gamewidth}, {$gameheight}, '{$gamecat}', '{$gamedesc}', 0, 0)"; $return = yasDB_insert($sql, false); if ($return === false) { $no_errors++; } else { $new_games++; } } } unset($game); echo 'Available script memory: ' . $mem_limit . ' MB<br/>'; echo 'Peak memory usage: ' . memory_get_peak_usage(true) / 1024 / 1024 . ' MB<br/>'; $End = getTime(); echo "Time taken = " . number_format($End - $Start, 2) . " secs<br/>"; echo "Errors encountered: " . $no_errors . "<br/>"; echo "New games added: " . $new_games . "<br/>Finished!"; return true; }
function get_playtomicfeed() { global $mysqli; set_time_limit(0); @ini_set("max_execution_time", 600); @ini_set("default_socket_timeout", 240); // create array of game tags for duplicate checking $query = yasDB_select("SELECT `gametagid` FROM `playtomicfeed`", false); $tags = array(); $i = 0; while ($alltags = $query->fetch_array(MYSQLI_ASSOC)) { $tags[$i] = $alltags['gametagid']; $i++; } unset($alltags); $query->close(); // This is the Playtomic feed url. For more info go here: http://playtomic.com/games/feed 671 $feedUrl = 'https://playtomic.com/games/feed/mochi?format=json&category=1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19&language=1&audience=0,1,2'; $data = get_content_of_url($feedUrl); //$data = file_get_contents($feedUrl); $json_data = json_decode($data, true); unset($data); $json_count = count($json_data['games']); foreach ($json_data['games'] as $json) { if ($json['name'] == NULL) { break; } if (!in_array($json['game_tag'], $tags)) { $gamename = yasDB_clean($json['name']); $gametagkey = yasDB_clean($json['game_tag']); $gameurl = yasDB_clean($json['swf_url']); $gamewidth = yasDB_clean($json['width']); $gameheight = yasDB_clean($json['height']); $gamedesc = yasDB_clean($json['description']); $gamekeywords_array = $json['tags']; $gamekeywords = yasDB_clean(implode(", ", $gamekeywords_array)); // Game keywords comma delimited i.e. "dressup,makeover,barbie" unset($gamekeywords_array); $thumburl = yasDB_clean($json['thumbnail_url']); if (empty($gameurl)) { $gameurl = str_replace('.' . GetFileExtension($thumburl), '.swf', $thumburl); } $gamecat_array = $json['categories']; $gamecats = yasDB_clean(implode(", ", $gamecat_array)); // All categories comma delimited unset($gamecat_array); $instructions = yasDB_clean($json['instructions']); $rating = yasDB_clean($json['rating']); $leaderboard = yasDB_clean($json['leaderboard_enabled']); $coinsenabled = yasDB_clean($json['coins_enabled']); $coins_rev_enabled = yasDB_clean($json['coins_revshare_enabled']); $recommended = yasDB_clean($json['recommended']); $controls = yasDB_clean($json['control_scheme']); $slug = yasDB_clean($json['slug']); $thumburl_200x200 = yasDB_clean($json['thumbnail_large_url']); $screen_thumb_url = yasDB_clean($json['screen1_thumb']); $screen_thumb_url2 = yasDB_clean($json['screen2_thumb']); $screen_thumb_url3 = yasDB_clean($json['screen3_thumb']); $screen_thumb_url4 = yasDB_clean($json['screen4_thumb']); $uuid = yasDB_clean($json['uuid']); $author = yasDB_clean($json['author']); $sql = "INSERT INTO `playtomicfeed` (`id`, `name`, `gameurl`, `width`, `height`, `description`, `keywords`, `thumburl`, `categories`, `gametagid`, `screenthumburl1`, `instructions`, `rating`, `leaderboard`, `coinsenabled`, `revshareenabled`, `recommended`, `isinstalled`, `slug`, `thumbnail_200x200`, `screenthumburl2`, `screenthumburl3`, `screenthumburl4`, `uuid`, `author`) \n\t\t\tVALUES (NULL, '{$gamename}', '{$gameurl}', '{$gamewidth}', '{$gameheight}', '{$gamedesc}', '{$gamekeywords}', '{$thumburl}', '{$gamecats}', '{$gametagkey}', '{$screen_thumb_url}', '{$instructions}', '{$rating}', '{$leaderboard}', '{$coinsenabled}', '{$coins_rev_enabled}', '{$recommended}', 0, '{$slug}', '{$thumburl_200x200}', '{$screen_thumb_url2}', '{$screen_thumb_url3}', '{$screen_thumb_url4}', '{$uuid}', '{$author}')"; $return = yasDB_insert($sql, false); if (!$return) { break; } // if there is a db insert error just keep going. A duplicate may have snuck in as the limit/offset of the feed is not 100% accurate } } unset($json); unset($json_data); return true; }
function get_mgffeed() { global $mysqli; error_reporting(E_ALL ^ E_NOTICE); @ini_set("max_execution_time", 600); @ini_set("default_socket_timeout", 240); // create array of game tags for duplicate checking $query = yasDB_select("SELECT `uid` FROM `mgffeed`", false); $tags = array(); $i = 0; while ($alltags = $query->fetch_array(MYSQLI_ASSOC)) { $tags[$i] = $alltags['uid']; $i++; } unset($alltags); $query->close(); // This is the MGF feed url. For more info go here: http://www.mochigamefeed.com/feed.php $feedUrl = 'http://mochigamefeed.com/updatedfeed.php'; $data = get_content_of_url($feedUrl); $json_data = json_decode($data, true); unset($data); $json_count = count($json_data); //$cat_array = array("puzzle", "action", "adventure", "sports", "shooter", "casino", "other", "girls", "education", "strategy", "jigsaw", "coloring", "driving", "fighting", "rhythm", "board game", "customize"); $cat_array = array("puzzle", "action", "adventure", "sports", "shooter", "casino", "other", "dressup", "arcade", "strategy", "cartoon", "coloring"); foreach ($json_data as $json) { if ($json['title'] == NULL) { break; } if (!in_array($json['id'], $tags)) { $cat = strtolower(yasDB_clean($json['category'])); if (in_array($cat, $cat_array)) { $category = array_search($cat, $cat_array) + 1; } else { $category = 7; // if not found set category to other } $title = yasDB_clean($json['title']); $uid = intval($json['id']); $game_file = yasDB_clean($json['file']); $game_url = "http://www.mochigamefeed.com/view/" . intval($json['id']) . "/" . prepGame($title) . ".html"; $width = intval($json['width']); $height = intval($json['height']); $description = yasDB_clean($json['description']); $instructions = yasDB_clean($json['instructions']); $small_thumburl = yasDB_clean($json['thumbnail']); $medium_thumburl = yasDB_clean($json['medthumb']); $large_thumburl = yasDB_clean($json['lgthumb']); $screen1 = yasDB_clean($json['screen1']); $screen1 = yasDB_clean($json['screen2']); $zip = yasDB_clean($json['zip']); $controls = yasDB_clean(stripslashes($json['controls'])); $created = yasDB_clean($json['installdate']); $review = yasDB_clean($json['review']); $rating = yasDB_clean($json['rating']); $ads = yasDB_clean($json['ads']); $hsapi = yasDB_clean($json['hsapi']); $keywords = yasDB_clean($json['keywords']); $sql = "INSERT INTO mgffeed (`id`, `uid`, `title`, `controls`, `installdate`, `game_url`, `description`, `instructions`, `category`, `thumbnail`, `medthumb`, `lgthumb`, `file`, `zip`, `screen1`, `screen2`, `width`, `height`, `review`, `rating`, `ads`, `hsapi`, `keywords`,`installed`, `hidden`)\n VALUES (NULL, {$uid}, '{$title}', '{$controls}', '{$created}', '{$game_url}', '{$description}', '{$instructions}', {$category}, '{$small_thumburl}', '{$medium_thumburl}', '{$large_thumburl}', '{$game_file}', '{$zip}', '{$screen1}', '{$screen2}', {$width}, {$height}, '{$review}', '{$rating}', '{$ads}', '{$hsapi}', '{$keywords}', '0', '0')"; $return = yasDB_insert($sql, false); if (!$return) { break; } // if there is a db insert error just keep going. } } unset($json); unset($json_data); return true; }
function get_kongregate_feed() { $Start = getTime(); $mem_limit = substr(ini_get("memory_limit"), 0, -1); global $mysqli; global $setting; set_time_limit(0); @ini_set("max_execution_time", 1000); @ini_set("default_socket_timeout", 240); $query = yasDB_select("SELECT `kong_id` FROM kongregate", false); $tags = array(); $i = 0; $no_errors = 0; $new_games = 0; // create array of game tags for duplicate checking while ($alltags = $query->fetch_array(MYSQLI_ASSOC)) { $tags[$i] = $alltags['kong_id']; $i++; } unset($alltags); $query->close(); $feedUrl = 'http://www.kongregate.com/games_for_your_site.xml'; $xmlfile = get_content_of_url($feedUrl); $data = new SimpleXMLElement($xmlfile); foreach ($data->game as $game) { if ($game->id == NULL) { break; } if (!in_array($game->id, $tags)) { $gamename = yasDB_clean($game->title); $gameid = intval($game->id); $gameurl = yasDB_clean($game->flash_file); $gamewidth = intval($game->width); $gameheight = intval($game->height); $gamedesc = yasDB_clean($game->description); $thumburl = yasDB_clean($game->thumbnail); $gamecat = yasDB_clean($game->category); $rating = $game->rating; settype($rating, "float"); $author = yasDB_clean($game->developer_name); $sql = "INSERT INTO kongregate (`id`, `kong_id`, `title`, `file`, `thumbnail`, `width`, `height`, `category`, `description`, `rating`, `developer`, `installed`, `hidden`) \n\t\t\tVALUES (NULL, {$gameid}, '{$gamename}', '{$gameurl}', '{$thumburl}', {$gamewidth}, {$gameheight}, '{$gamecat}', '{$gamedesc}', '{$rating}', '{$author}', 0, 0)"; $return = yasDB_insert($sql, false); if ($return === false) { $no_errors++; } else { $new_games++; } } } unset($game); echo 'Available script memory: ' . $mem_limit . ' MB<br/>'; echo 'Peak memory usage: ' . memory_get_peak_usage(true) / 1024 / 1024 . ' MB<br/>'; $End = getTime(); echo "Time taken = " . number_format($End - $Start, 2) . " secs<br/>"; echo "Errors encountered: " . $no_errors . "<br/>"; echo "New games added: " . $new_games . "<br/>Finished!"; return true; }
function get_fgdfeed() { global $mysqli; //error_reporting(E_ALL ^ E_NOTICE); set_time_limit(0); @ini_set("max_execution_time", 600); @ini_set("default_socket_timeout", 240); $limit = 200; $start = 0; $totaltags = array(); // create array of game tags for duplicate checking $query = yasDB_select("SELECT `uuid` FROM `fgdfeed`", false); $tags = array(); while ($alltags = $query->fetch_array(MYSQLI_ASSOC)) { $totaltags[] = $alltags['uuid']; } unset($alltags); $query->close(); if (count($totaltags) == 0) { $totaltags[0] = '0'; } do { // This is the Flashgamedistribution.com feed url. For more info go here: http://flashgamedistribution.com/feeds.php $feedUrl = 'http://flashgamedistribution.com/feed.php?start=' . $start . '&gpp=' . $limit . '&feed=json'; $data = get_content_of_url($feedUrl); $json_data = json_decode($data, true); unset($data); $json_count = count($json_data); foreach ($json_data as $json) { if (!in_array($json['game_id'], $totaltags)) { $uuid = $json['game_id']; $title = yasDB_clean(stripslashes($json['title'])); $gameurl = yasDB_clean($json['swf_filename']); $width = yasDB_clean($json['width']); $height = yasDB_clean($json['height']); $gamedesc = yasDB_clean(stripslashes($json['short_description'])); $tags = yasDB_clean($json['tags']); $thumburl = yasDB_clean($json['thumb_filename']); $categories = $json['genres']; $highscores = yasDB_clean($json['highscores']); $mobile = yasDB_clean($json['is_mobileready']); $hasads = yasDB_clean($json['has_ads']); $featured = yasDB_clean($json['featured']); $multiplayer = yasDB_clean($json['multiplayer']); $sql = "INSERT INTO `fgdfeed` (`id`, `uuid`, `title`, `description`, `tags`, `gamefile`, `thumbfile`, `width`, `height`, `categories`, `hasads`, `multiplayer`, `featured`, `highscores`, `mobileready`, `installed`) \n\t\t\t\tVALUES (NULL, '{$uuid}', '{$title}', '{$gamedesc}', '{$tags}', '{$gameurl}', '{$thumburl}', {$width}, {$height}, '{$categories}', {$hasads}, {$multiplayer}, {$featured}, {$highscores}, {$mobile}, 0)"; $return = yasDB_insert($sql, false); if (!$return) { return false; } } } if ($start >= 15400) { $limit = 20; } $start = $start + $limit; unset($json); unset($json_data); } while ($json_count > 0); return true; }
echo 'Log file was not found.'; } break; case 'jobs': if (file_exists('../jobs_log.txt')) { if (isset($_GET['d']) && $_GET['d'] == 't') { $f = @fopen($setting['sitepath'] . "/jobs_log.txt", "r+"); if ($f !== false) { ftruncate($f, 0); fclose($f); echo 'Log file successfully cleared.'; } else { echo "There was an error while attempting to clear the log file."; } } else { $data = get_content_of_url($setting['siteurl'] . 'jobs_log.txt'); $data = nl2br($data); ?> <h3><a href="<?php echo $setting['siteurl'] . 'admin/index.php?act=managelogs&f=jobs&d=t'; ?> " onclick="return confirm('Do you really want to clear the log file?')">Clear the log file</a></h3> <?php echo preg_replace($search, $replace, $data); } } else { echo 'Log file was not found.'; } break; } }
function get_fogfeed() { global $mysqli; error_reporting(E_ALL ^ E_NOTICE); @ini_set("max_execution_time", 600); @ini_set("default_socket_timeout", 240); // create array of game tags for duplicate checking $query = yasDB_select("SELECT `uid` FROM `fogfeed`", false); $tags = array(); $i = 0; while ($alltags = $query->fetch_array(MYSQLI_ASSOC)) { $tags[$i] = $alltags['uid']; $i++; } unset($alltags); $query->close(); // This is the FOG feed url. For more info go here: http://www.freegamesforyourwebsite.com/feeds.php $feedUrl = 'http://freegamesforyourwebsite.com/feeds/games/?format=json&category=all&limit=all'; $data = get_content_of_url($feedUrl); $json_data = json_decode($data, true); unset($data); $json_count = count($json_data); foreach ($json_data as $json) { if ($json['title'] == NULL) { break; } if (!in_array($json['id'], $tags)) { // little voodo to extract a category from game text as the feed has no game categories $data = $json['title'] . ' ' . $json['description'] . ' ' . $json['tags']; $category = getCategory(wordsArray($data)); // end category voodoo $title = yasDB_clean($json['title']); $uid = yasDB_clean($json['id']); $game_file = yasDB_clean($json['swf_file']); $game_url = yasDB_clean($json['game_url']); $resolution = explode("x", $json['resolution']); $width = $resolution[0]; $height = $resolution[1]; $description = yasDB_clean($json['description']); $small_thumburl = yasDB_clean($json['small_thumbnail_url']); $medium_thumburl = yasDB_clean($json['med_thumbnail_url']); $large_thumburl = yasDB_clean($json['large_thumbnail_url']); $controls = yasDB_clean(stripslashes($json['controls'])); $created = yasDB_clean($json['created']); $updated = yasDB_clean($json['updated']); $sql = "INSERT INTO fogfeed (`id`, `uid`, `title`, `controls`, `updated`, `game_url`, `description`, `category`, `small_thumbnail_url`, `med_thumbnail_url`, `large_thumbnail_url`, `created`, `swf_file`, `width`, `height`, `installed`) \n\t\t\tVALUES (NULL, {$uid}, '{$title}', '{$controls}', '{$updated}', '{$game_url}', '{$description}', {$category}, '{$small_thumburl}', '{$medium_thumburl}', '{$large_thumburl}', '{$created}', '{$game_file}', {$width}, {$height}, '0')"; $return = yasDB_insert($sql, false); if (!$return) { break; } // if there is a db insert error just keep going. } } unset($json); unset($json_data); return true; }
function get_mochifeed() { $Start = getTime(); $mem_limit = substr(ini_get("memory_limit"), 0, -1); global $mysqli; global $setting; error_reporting(E_ALL ^ E_NOTICE); set_time_limit(0); @ini_set("max_execution_time", 1000); @ini_set("default_socket_timeout", 240); $mochipubid = $setting['mochi_pub_key']; // Retrieve our Mochi key if (!$mochipubid) { echo 'You need a Mochimedia Publisher ID to continue.'; return false; } $limit = '1500'; $offset = $setting['mochi_offset'] >= 0 ? $setting['mochi_offset'] : 0; $no_errors = 0; $new_games = 0; //$feedUrl = 'http://www.mochimedia.com/feeds/games/'.$mochipubid.'/all/all?limit='.$limit.'&offset='.$offset.'&format=json'; $query = yasDB_select("SELECT `gametagid`, `uuid` FROM mochigames", false); $tags = array(); //$uid_array = array(); $i = 0; // create array of game tags for duplicate checking while ($alltags = $query->fetch_array(MYSQLI_ASSOC)) { $tags[$i] = $alltags['gametagid']; //$uid_array[$i] = $alltags['uuid']; $i++; } unset($alltags); $query->close(); do { // This is the Mochiads feed url. For more info go here: https://www.mochimedia.com/support/pub_docs#feed_3 ...when signed in $feedUrl = 'http://catalog.mochimedia.com/feeds/query/?partner_id=' . $mochipubid . '&limit=' . $limit . '&offset=' . $offset; $data = get_content_of_url($feedUrl); $json_data = json_decode($data, true); unset($data); $json_count = count($json_data["games"]); if ($json_count < 1) { break; } foreach ($json_data["games"] as $json) { if ($json['name'] == NULL) { break; } if (!in_array($json['game_tag'], $tags)) { // && !in_array($json['uuid'],$uid_array)) { $gamename = yasDB_clean($json['name']); $gametagkey = yasDB_clean($json['game_tag']); $gameurl = yasDB_clean($json['swf_url']); $gamewidth = yasDB_clean($json['width']); $gameheight = yasDB_clean($json['height']); $gamedesc = yasDB_clean($json['description']); $gamekeywords_array = $json['tags']; $gamekeywords = yasDB_clean(implode(", ", $gamekeywords_array)); // Game keywords comma delimited i.e. "dressup,makeover,barbie" unset($gamekeywords_array); $thumburl = yasDB_clean($json['thumbnail_url']); $gamecat_array = $json['categories']; $gamecats = yasDB_clean(implode(", ", $gamecat_array)); // All categories comma delimited unset($gamecat_array); $instructions = yasDB_clean($json['instructions']); $rating = yasDB_clean($json['rating']); $leaderboard = yasDB_clean($json['leaderboard_enabled']); $coinsenabled = yasDB_clean($json['coins_enabled']); $coins_rev_enabled = yasDB_clean($json['coins_revshare_enabled']); $recommended = yasDB_clean($json['recommended']); $controls = yasDB_clean($json['control_scheme']); $slug = yasDB_clean($json['slug']); $thumburl_200x200 = yasDB_clean($json['thumbnail_large_url']); $screen_thumb_url = yasDB_clean($json['screen1_thumb']); $screen_thumb_url2 = yasDB_clean($json['screen2_thumb']); $screen_thumb_url3 = yasDB_clean($json['screen3_thumb']); $screen_thumb_url4 = yasDB_clean($json['screen4_thumb']); $uuid = yasDB_clean($json['uuid']); $author = yasDB_clean($json['author']); // As of now we do not need all these fields. But this will allow for future script growth, ie : Building a leaderboard mod. $sql = "INSERT INTO mochigames (`id`, `name`, `gameurl`, `width`, `height`, `description`, `keywords`, `thumburl`, `categories`, `gametagid`, `screenthumburl1`, `instructions`, `rating`, `leaderboard`, `coinsenabled`, `revshareenabled`, `recommended`, `isinstalled`, `slug`, `thumbnail_200x200`, `screenthumburl2`, `screenthumburl3`, `screenthumburl4`, `uuid`, `author`) \n\t\t\t\tVALUES (NULL, '{$gamename}', '{$gameurl}', '{$gamewidth}', '{$gameheight}', '{$gamedesc}', '{$gamekeywords}', '{$thumburl}', '{$gamecats}', '{$gametagkey}', '{$screen_thumb_url}', '{$instructions}', '{$rating}', '{$leaderboard}', '{$coinsenabled}', '{$coins_rev_enabled}', '{$recommended}', 0, '{$slug}', '{$thumburl_200x200}', '{$screen_thumb_url2}', '{$screen_thumb_url3}', '{$screen_thumb_url4}', '{$uuid}', '{$author}')"; $return = yasDB_insert($sql, false); if ($return === false) { $no_errors++; // if there is a db insert error just keep going. A duplicate may have snuck in as the limit/offset of the feed is not 100% accurate } else { $new_games++; } } } unset($json); unset($json_data); $offset = $offset + $limit; } while ($json_count > 0); echo 'Available script memory: ' . $mem_limit . ' MB<br/>'; echo 'Peak memory usage: ' . memory_get_peak_usage(true) / 1024 / 1024 . ' MB<br/>'; $End = getTime(); echo "Time taken = " . number_format($End - $Start, 2) . " secs<br/>"; echo "Errors encountered: " . $no_errors . "<br/>"; echo "New games added: " . $new_games . "<br/>Finished!"; $offset = intval($offset - 2 * $limit); $offset = $offset > 0 ? $offset : 0; if ($offset != $setting['mochi_offset']) { yasDB_update("UPDATE `settings` SET `mochi_offset` = {$offset} WHERE `id` = 1"); include "../includes/settings_function.inc.php"; createConfigFile(); } return true; }