<?php if (!defined('EZGP')) { die('Access denied.'); } if (empty($_sys['segments'][2])) { header('Location: ' . $_sys['dispatcher']); exit; } $gameid = any2dec($_sys['segments'][2]); connsql(); $sql = 'SELECT * FROM ' . $config['db_table_name'] . ' WHERE id=' . $gameid; $result = mysql_query($sql); $game = mysql_fetch_assoc($result); if (!empty($config['swf_domain_name'])) { $game['swf_url'] = get_swf_url($config['swf_domain_name'], $game['swf_url']); } $data['game'] = $game; $page['contents'] = load_view('game', $data); $page['script'][] = 'http://static.flowplayer.org/js/tools/tools.flashembed-1.0.4.min.js'; $page['script'][] = 'js/game.js'; $page['custom_footer'] = '<script type="text/javascript"> flashembed("game_swf", {src: "' . $game['swf_url'] . '", width: ' . $game['width'] . ', height: ' . $game['height'] . '}); </script>'; $page['title'] = $game['name'] . ' - ' . $game['category'] . ' - ' . $config['site_name']; $page['description'] = mb_substr($game['description'], 0, 80, 'UTF-8'); $page['selected_menu'] = get_default_menu('game', strtolower($game['category'])); require $_sys['base_path'] . '/pages/_template.php';
function load_cache($cache_file, $expires = 3600) { global $_sys, $config; $fullentry = $_sys['base_path'] . '/caches/' . $cache_file . '.php'; $renew = TRUE; if (file_exists($fullentry)) { $mtime = filemtime($fullentry); if ($mtime > time() - $expires) { $renew = FALSE; } } if ($renew) { //echo $cache_file, " renew!\n"; connsql(); switch ($cache_file) { case 'newest': $sql = 'SELECT id, name, slug, thumbnail_url, swf_url FROM ' . $config['db_table_name'] . ' WHERE recommendation>=2 ORDER BY updated DESC LIMIT 60'; break; case 'popular': $sql = 'SELECT id, name, slug, thumbnail_url, swf_url FROM ' . $config['db_table_name'] . ' WHERE recommendation>=4 ORDER BY updated DESC LIMIT 60'; break; case 'index_top': $sql = 'SELECT id, name, slug, thumbnail_url, swf_url FROM ' . $config['db_table_name'] . ' WHERE recommendation>=5 ORDER BY updated DESC LIMIT 30'; break; case 'index_action': $sql = 'SELECT id, name, slug, thumbnail_url, swf_url FROM ' . $config['db_table_name'] . ' WHERE recommendation>=1 AND category="Action" ORDER BY updated DESC LIMIT 30'; break; case 'index_adventure': $sql = 'SELECT id, name, slug, thumbnail_url, swf_url FROM ' . $config['db_table_name'] . ' WHERE recommendation>=1 AND category="Adventure" ORDER BY updated DESC LIMIT 30'; break; case 'index_board': $sql = 'SELECT id, name, slug, thumbnail_url, swf_url FROM ' . $config['db_table_name'] . ' WHERE recommendation>=1 AND category="Board Game" ORDER BY updated DESC LIMIT 30'; break; case 'index_casino': $sql = 'SELECT id, name, slug, thumbnail_url, swf_url FROM ' . $config['db_table_name'] . ' WHERE recommendation>=1 AND category="Casino" ORDER BY updated DESC LIMIT 30'; break; case 'index_customize': $sql = 'SELECT id, name, slug, thumbnail_url, swf_url FROM ' . $config['db_table_name'] . ' WHERE recommendation>=1 AND category="Customize" ORDER BY updated DESC LIMIT 30'; break; case 'index_dressup': $sql = 'SELECT id, name, slug, thumbnail_url, swf_url FROM ' . $config['db_table_name'] . ' WHERE recommendation>=1 AND category="Dress-Up" ORDER BY updated DESC LIMIT 30'; break; case 'index_driving': $sql = 'SELECT id, name, slug, thumbnail_url, swf_url FROM ' . $config['db_table_name'] . ' WHERE recommendation>=1 AND category="Driving" ORDER BY updated DESC LIMIT 30'; break; case 'index_education': $sql = 'SELECT id, name, slug, thumbnail_url, swf_url FROM ' . $config['db_table_name'] . ' WHERE recommendation>=1 AND category="Education" ORDER BY updated DESC LIMIT 30'; break; case 'index_fighting': $sql = 'SELECT id, name, slug, thumbnail_url, swf_url FROM ' . $config['db_table_name'] . ' WHERE recommendation>=1 AND category="Fighting" ORDER BY updated DESC LIMIT 30'; break; case 'index_puzzles': $sql = 'SELECT id, name, slug, thumbnail_url, swf_url FROM ' . $config['db_table_name'] . ' WHERE recommendation>=1 AND category="Puzzles" ORDER BY updated DESC LIMIT 30'; break; case 'index_rhythm': $sql = 'SELECT id, name, slug, thumbnail_url, swf_url FROM ' . $config['db_table_name'] . ' WHERE recommendation>=1 AND category="Rhythm" ORDER BY updated DESC LIMIT 30'; break; case 'index_shooting': $sql = 'SELECT id, name, slug, thumbnail_url, swf_url FROM ' . $config['db_table_name'] . ' WHERE recommendation>=1 AND category="Shooting" ORDER BY updated DESC LIMIT 30'; break; case 'index_sports': $sql = 'SELECT id, name, slug, thumbnail_url, swf_url FROM ' . $config['db_table_name'] . ' WHERE recommendation>=1 AND category="Sports" ORDER BY updated DESC LIMIT 30'; break; case 'index_strategy': $sql = 'SELECT id, name, slug, thumbnail_url, swf_url FROM ' . $config['db_table_name'] . ' WHERE recommendation>=1 AND category="Strategy" ORDER BY updated DESC LIMIT 30'; break; case 'index_other': $sql = 'SELECT id, name, slug, thumbnail_url, swf_url FROM ' . $config['db_table_name'] . ' WHERE recommendation>=1 AND category="Other" ORDER BY updated DESC LIMIT 30'; break; } $result = mysql_query($sql); $data = array(); while ($row = mysql_fetch_assoc($result)) { $data[] = $row; } file_put_contents($fullentry, "<?php\n" . "global \${$cache_file};\n" . "\${$cache_file} = " . var_export($data, TRUE) . ";\n" . "?>"); } require $fullentry; }