pName = 'open_12182'; $this->rootPath = 'GAMES/'; $this->wmlTemplatePath = 'templates/wap/wml/wml.template.php'; $this->xhtmlTemplatePath = 'templates/wap/xhtml/xhtml.template.php'; $this->searchResLimit = 33; $this->recordsPerPage = 5; $this->pageRange = 5; $this->title = 'Java Games Download | Top Java Games for Mobile Cell Phone!'; $this->keyWords = 'java games, java games download, j2me games, mobile downloads, download games'; $this->description = 'Java Games Download. Best Java Games to play on your mobile cell phone.'; $this->domainRoot = "http://java-games.mobi/"; $this->searchCard = false; $this->userData = new USER_DATA; $this->arrUserData = $this->userData->GetUserData(); $this->mysqlServer = "localhost"; $this->mysqlLogin = "dgcore"; $this->mysqlPassword = "chaparal13"; $this->mysqlDB = "pokerpwr"; $this->db = mysql_connect ($this->mysqlServer, $this->mysqlLogin, $this->mysqlPassword); mysql_select_db ($this->mysqlDB, $this->db); //$this->Pointer();//redirect for selected countries $this->Request(); $this->headerCard = $this->HeaderCard(); $this->navigationCard = $this->NavigationCard(); $this->menuCard = $this->MenuCard(); $this->listingCard = $this->ListingCard(); $this->gameCard = $this->GameCard(); $this->finalPrintOut = $this->RenderTemplate(); echo $this->finalPrintOut; mysql_close ($this->db); } private function Pointer(){ if($this->arrUserData['country_name'] == 'Australia' || $this->arrUserData['country_name'] == ''){ $redirUrl = 'http://games.au.dgcore.com'; header('Location: '.$redirUrl); } } private function Request(){ $this->gameTitle = (isset($_GET['gttl']))? $this->SanitizeDBInput($_GET['gttl']) : false; if(isset($_GET['path'])){ $this->path = $this->rootPath.$this->SanitizeDBInput($_GET['path']); $this->pathToUse = $this->SanitizeDBInput($_GET['path']); $this->pid = str_replace('/', "", $this->path); $this->pid = str_replace(' ', "", $this->path); $this->pid = (int) ereg_replace("[^0-9]", "", $this->pid); }else{ $this->path = $this->rootPath; $this->pathToUse = ''; } if(isset($_POST['q'])){ $this->q = $this->SanitizeDBInput($_POST['q']); if(($this->q != '') && ($this->q != ' ') && (strlen($this->q) > 2)){ $this->searchCard = $this->SearchCard(); } } } private function HeaderCard(){ $out = ''; $resolutionWidth = (isset($this->arrUserData['reolution_width']))? $this->arrUserData['reolution_width'] : '176' ; $imagePath = 'images/'.$resolutionWidth.'/logo.gif'; $arrImageProp = $this->GetImageProperties($imagePath); if(isset($this->arrUserData['is_wml'])){ $out .= 'java mobile games'; }else{ $out .= '
java mobile games
'; } return $out; } private function SearchCard(){ $out = ''; $result = mysql_query('SELECT id, cid, title, description FROM listings WHERE listings.title LIKE "%'.$this->q.'%"'); $numRes = mysql_num_rows ($result); while ($row = mysql_fetch_assoc ($result)){ $this->arrQ[] = array( 'id' => $row['id'], 'cid' => $row['cid'], 'title' => $row['title'], 'description' => $row['description'] ); } if($numRes > 0){ if(isset($this->arrUserData['is_wml'])){ $out .= ($numRes >= $this->searchResLimit)? '

Showing '.$this->searchResLimit.' games from top '.$this->searchResLimit.' results' : '

Found '.$numRes.' '.($game = ($numRes < 2)? 'game' : 'games' ).' for query: '.$this->q.'

' ; }else{ $out .= ($numRes >= $this->searchResLimit)? '
Showing '.$this->searchResLimit.' games from top '.$this->searchResLimit.' results
' : '
Found '.$numRes.' '.($game = ($numRes < 2)? 'game' : 'games' ).' for query: '.$this->q.'
' ; } $i = 0; while(isset($this->arrQ[$i])){ $this->gameSearch = str_replace(" ", "_", stripslashes ($this->arrQ[$i]['title'])); $result = mysql_query('SELECT id, cid, title, description, category FROM listings WHERE listings.title LIKE "'.$this->gameSearch.'" '); if(mysql_num_rows($result) > 0){ $this->arrGameCard = mysql_fetch_assoc ($result); } $result = mysql_query('SELECT id, name, parent FROM cats WHERE id ='.$this->arrGameCard['category']); if(mysql_num_rows($result) > 0){ $this->category = mysql_fetch_assoc ($result); } $result = mysql_query('SELECT id, name FROM cats WHERE id ='.$this->category['parent']); if(mysql_num_rows($result) > 0){ $this->parentCategoryId = mysql_fetch_assoc ($result); } $result = mysql_query('SELECT name FROM cats WHERE id ='.$this->parentCategoryId['id']); if(mysql_num_rows($result) > 0){ $this->parentCategory = mysql_fetch_assoc ($result); } if(isset($this->arrQ[$i]['id']) && ($i < $this->searchResLimit)){ if(isset($this->arrUserData['is_wml'])){ $out .= ''.($i+1).'. '.stripslashes ($this->arrQ[$i]['title']).' '.'('.$this->parentCategory['name'].' / '.$this->category['name'].')'.'
'; }else{ $out .= '
'.'
'; } $this->title = (isset($this->q))? $this->q : 'Mobile Phone Game Search Results: '; $this->keyWords = 'mobile java games'; } $i++; } }else{ if(isset($this->arrUserData['is_wml'])){ $out .= '

No results where found for query '.$this->q.'

'; }else{ $out .= '
No results where found for query '.$this->q.'
'; } } return $out; } private function GameCard(){ $out = ''; if($this->gameTitle != false){ $this->gameTitle = str_replace("_", " ", stripslashes($this->gameTitle)); $result = mysql_query('SELECT id, cid, title, description, category FROM listings WHERE listings.title LIKE "'.$this->gameTitle.'" '); if(mysql_num_rows($result) > 0){ $this->arrGameCard = mysql_fetch_assoc ($result); } $result = mysql_query('SELECT id, name, parent FROM cats WHERE id ='.$this->arrGameCard['category']); if(mysql_num_rows($result) > 0){ $this->category = mysql_fetch_assoc ($result); } $result = mysql_query('SELECT id, name FROM cats WHERE id ='.$this->category['parent']); if(mysql_num_rows($result) > 0){ $this->parentCategoryId = mysql_fetch_assoc ($result); } $result = mysql_query('SELECT name FROM cats WHERE id ='.$this->parentCategoryId['id']); if(mysql_num_rows($result) > 0){ $this->parentCategory = mysql_fetch_assoc ($result); } $rslt = mysql_query('SELECT title FROM listings WHERE title LIKE "%'.$this->arrGameCard['title'].'%"'); $numRslts = mysql_num_rows ($rslt); if($numRslts > 0){ while ($row = mysql_fetch_assoc ($rslt)){ $fileName = str_replace( array(') ', ' (', '_', ' ', '(', ')', '!', '-', '`', '~', '@', '#', '$', '%', '^', '&', '*', '[', ']', '\'', '\"', '.', ',', '<', '>', '?', '=', '+', '|', '\/'), array('', '', '_', '_', '_', '_', '_', '', '_', '_', '_', '_', '_', '_', '_', '_', '_', '_', '_', '_', '_', '_', '_', '_', '_', '_', '_', '_', '_', '_'), $row['title'] ); $fileName = 'java_game_'.(strtolower($fileName)).'.jpg'; } if(isset($this->arrGameCard['id'])){ if(isset($this->arrUserData['is_wml'])){ $out .= '

'.stripslashes ($this->arrGameCard['title']).'

'; $out .= '

'; $out .= '

'.stripslashes ($this->arrGameCard['title']).' '.'('.$this->parentCategory['name'].' / '.$this->category['name'].')'.'
'.html_entity_decode(stripslashes($this->arrGameCard['description'])).'

'; //$out .= '

'; $out .= '

'; $this->title = 'Mobile Cell Phone '.$this->parentCategory['name'].' | '.$this->category['name'].' | Play '.stripslashes ($this->arrGameCard['title']).' Game Now!'; $this->keyWords = 'mobile java games, '.strtolower($this->parentCategory['name']).', '.strtolower($this->category['name']); }else{ $out .= '

'.stripslashes ($this->arrGameCard['title']).'

'; $out .= '
'.stripslashes ($this->arrGameCard['title']).' game for mobile phone'.'
'; $out .= '

'.stripslashes ($this->arrGameCard['title']).' '.'('.$this->parentCategory['name'].' / '.$this->category['name'].')'.'


'.html_entity_decode(stripslashes($this->arrGameCard['description'])).'
'; //$out .= '
Games Download
'; $out .= '
Games Download
'; $this->title = $this->parentCategory['name'].' for Mobile Phone'.' | '.$this->category['name'].' | Download & Play '.stripslashes ($this->arrGameCard['title']).' Game Now!'; $this->keyWords = 'game mobile phone, mobile java games, '.strtolower($this->parentCategory['name']).', '.strtolower($this->category['name']); $this->description = $this->category['name'].' Download! Download & Play '.stripslashes ($this->arrGameCard['title']).' game!('.strtolower($this->category['name']).') '.html_entity_decode(stripslashes($this->arrGameCard['description'])); } } }else{ echo 'Error, can not get Image file Names'; die(); } } return $out; } private function NavigationCard(){ $out = ''; $arIds = array (); $arSubPath = array (); $arPath = explode ('/', $this->path); for ($i = 0; $i < count ($arPath); $i++){ array_push ($arSubPath, $arPath[$i]); $parent = ($i == 0)? 0 : ($arIds[count ($arIds) - 1]); $thisCat = mysql_query ("SELECT id, name, tname, jname FROM cats WHERE jname LIKE '$arPath[$i]' AND parent = $parent "); if (mysql_num_rows ($thisCat) > 0){ $this->row = mysql_fetch_assoc ($thisCat); $this->arrCats[$i] = $this->row['tname']; $arSubPath = str_replace(" ", "", $arSubPath); array_push ($arIds, $this->row['id']); $this->subPath = substr_replace(implode ('/', $arSubPath),'',0,strlen($this->rootPath)); if(isset($this->arrUserData['is_wml'])){ if(stripslashes($this->subPath) == ''){ $out .= ''.$this->row['jname']."\n"; }else{ $out .= ''.$this->row['jname']."\n"; } }else{ if(stripslashes($this->subPath) == ''){ $out .= ''.$this->row['jname']."\n"; }else{ $out .= ''.$this->row['jname']."\n"; } } } } return $out; } private function MenuCard(){ $out = ''; if(!isset($this->pid) || ($this->pid == 0)){ $kids = mysql_query ("SELECT id, jname, children FROM cats WHERE parent = '".$this->row['id']."' ORDER BY jname"); if (mysql_num_rows ($kids) > 0){ while ($kidRow = mysql_fetch_assoc ($kids)){ $this->linkTitle = $kidRow['jname']; $this->linkId = $kidRow['id']; if(($this->linkId == 2) || ($this->linkId == 8) || ($this->linkId == 10) || ($this->linkId == 12) || ($this->linkId == 13) || ($this->linkId == 14) || ($this->linkId == 15) || ($this->linkId == 9) || ($this->linkId == 16) || ($this->linkId == 11)){ if(isset($this->arrUserData['is_wml'])){ $out .= ''.$kidRow['jname']."
\n"; }else{ $out .= '\n"; } } } } } $out .= '';//ads return $out; } private function ListingCard(){ $out = ''; $this->pid = (isset($this->pid))? $this->pid : 0; $q = mysql_query('SELECT id, title, description, url FROM listings WHERE category = "'.$this->row['id'].'" ORDER BY title '); $numRes = mysql_num_rows ($q); $q = mysql_query('SELECT id, cid, title, description, url FROM listings WHERE category = "'.$this->row['id'].'" ORDER BY id LIMIT '.($this->pid).', '.($this->recordsPerPage * $this->pageRange)); $numRows = mysql_num_rows ($q); if ($numRows > 0){ while($row = mysql_fetch_array($q, MYSQL_ASSOC)){ $listRow[] = array( 'id' => $row['id'], 'cid' => $row['cid'], 'title' => $row['title'], 'description' => $row['description'], 'url' => $row['url'] ); } for ( $a = 0; $a < $this->recordsPerPage; $a++) { if(isset($listRow[$a]['cid'])){ $rslt = mysql_query('SELECT title FROM listings WHERE title LIKE "%'.$listRow[$a]['title'].'%"'); $numRslts = mysql_num_rows ($rslt); if($numRslts > 0){ while ($row = mysql_fetch_assoc ($rslt)){ $fileName = str_replace( array(') ', ' (', '_', ' ', '(', ')', '!', '-', '`', '~', '@', '#', '$', '%', '^', '&', '*', '[', ']', '\'', '\"', '.', ',', '<', '>', '?', '=', '+', '|', '\/'), array('', '', '_', '_', '_', '_', '_', '', '_', '_', '_', '_', '_', '_', '_', '_', '_', '_', '_', '_', '_', '_', '_', '_', '_', '_', '_', '_', '_', '_'), $row['title'] ); $fileName = 'java_game_'.(strtolower($fileName)).'.jpg'; } }else{ echo 'Error, can not get Image file Names'; die(); } $pageName = str_replace(" ", "_", stripslashes($listRow[$a]['title'])); if(isset($this->arrUserData['is_wml'])){ $out .= '


'.stripslashes ($listRow[$a]['title']).'

'; $out .= 'more info about
'.stripslashes($listRow[$a]['title']).'
game

'."\n"; $out .= '

'; }else{ $out .= '

'.stripslashes ($listRow[$a]['title']).'(java games)


java game - '.stripslashes($listRow[$a]['title']).'
'; $out .= 'more info about
'.stripslashes($listRow[$a]['title']).'
game
'."\n"; $out .= '
Games Download
'; } } } $type = (isset($this->arrUserData['is_wml']))? 'wml' : 'html'; $paginate = new Paginate($this->recordsPerPage, $numRes, $this->domainRoot.stripslashes($this->subPath).'/', 2, $this->pid, $type); if(isset($this->arrUserData['is_wml'])){ $out .= '

'.$paginate->displayTable().'

'; }else{ $out .= '
'.$paginate->displayTable().'
'; } } $catName = (isset($this->arrCats[2])) ? $this->arrCats[1].' '.$this->row['name'] : $catName = $this->row['name'] ; $this->title = ($this->row['id'] != 1)? $catName.' Download | Download '.$this->arrCats[1].' Games for Mobile Phone' : $this->title; $this->keyWords = ($this->row['id'] != 1)? (strtolower($this->row['name'])).', mobile java games, cell phone games, download games, mobile downloads' : $this->keyWords; return $out; } private function RenderTemplate(){ $wapTemplate = (isset($this->arrUserData['is_wml']))? file_get_contents($this->wmlTemplatePath) : file_get_contents($this->xhtmlTemplatePath) ; $wapTemplate = str_replace(array( '###DOCTYPE###', '###TITLE###', '###HEAD###', '###NAVIGATION###', '###MENU###', '###LISTING###', '###GAME_LISTING###', '###KEYWORDS###', '###DESCRIPTION###', '###SEARCH_CARD###', '###FORM_ACTION###' ), array( $this->arrUserData['doctype'], $this->title, $this->headerCard, $this->navigationCard, $this->menuCard, $this->listingCard, $this->gameCard, $this->keyWords, $this->description, $this->searchCard, $this->domainRoot ), $wapTemplate); return $wapTemplate; } private function SanitizeDBInput($string){ if(function_exists('mysql_real_escape_string')){ if(get_magic_quotes_gpc()){ $string = stripslashes($string); } $string = mysql_real_escape_string($string); }elseif(function_exists('mysql_escape_string')){ if(get_magic_quotes_gpc()){ $string = stripslashes($string); } $string = mysql_escape_string($string); }else{ $string = addslashes($string); } return $string; } private function GetImageProperties($imagePath){ $size = @getimagesize($imagePath); return array('width' => $size[0], 'height' => $size[1]); } private function ADS(){ $admob_params = array( 'PUBLISHER_ID' => 'a14a41337e2be0b', // Required to request ads. To find your Publisher ID, log in to your AdMob account and click on the "Sites & Apps" tab. 'ANALYTICS_ID' => 'a14a41374423a42', // Required to collect Analytics data. To find your Analytics ID, log in to your Analytics account and click on the "Edit" link next to the name of your site. 'AD_REQUEST' => true, // To request an ad, set to TRUE. 'ANALYTICS_REQUEST' => true, // To enable the collection of analytics data, set to TRUE. 'TEST_MODE' => false, // While testing, set to TRUE. When you are ready to make live requests, set to FALSE. // Additional optional parameters are available at: http://developer.admob.com/wiki/AdCodeDocumentation 'OPTIONAL' => array() ); return $this->admob_request($admob_params); } private function admob_request($admob_params) { static $pixel_sent = false; $ad_mode = false; if (!empty($admob_params['AD_REQUEST']) && !empty($admob_params['PUBLISHER_ID'])) $ad_mode = true; $analytics_mode = false; if (!empty($admob_params['ANALYTICS_REQUEST']) && !empty($admob_params['ANALYTICS_ID']) && !$pixel_sent) $analytics_mode = true; $protocol = 'http'; if (!empty($_SERVER['HTTPS']) && strtolower($_SERVER['HTTPS']) != 'off') $protocol = 'https'; $rt = $ad_mode ? ($analytics_mode ? 2 : 0) : ($analytics_mode ? 1 : -1); if ($rt == -1) return ''; list($usec, $sec) = explode(' ', microtime()); $params = array('rt=' . $rt, 'z=' . ($sec + $usec), 'u=' . urlencode($_SERVER['HTTP_USER_AGENT']), 'i=' . urlencode($_SERVER['REMOTE_ADDR']), 'p=' . urlencode("$protocol://" . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI']), 'v=' . urlencode('20081105-PHPCURL-acda0040bcdea222')); $sid = empty($admob_params['SID']) ? session_id() : $admob_params['SID']; if (!empty($sid)) $params[] = 't=' . md5($sid); if ($ad_mode) $params[] = 's=' . $admob_params['PUBLISHER_ID']; if ($analytics_mode) $params[] = 'a=' . $admob_params['ANALYTICS_ID']; if (!empty($_COOKIE['admobuu'])) $params[] = 'o=' . $_COOKIE['admobuu']; if (!empty($admob_params['TEST_MODE'])) $params[] = 'm=test'; if (!empty($admob_params['OPTIONAL'])) { foreach ($admob_params['OPTIONAL'] as $k => $v) { $params[] = urlencode($k) . '=' . urlencode($v); } } $ignore = array('HTTP_PRAGMA' => true, 'HTTP_CACHE_CONTROL' => true, 'HTTP_CONNECTION' => true, 'HTTP_USER_AGENT' => true, 'HTTP_COOKIE' => true); foreach ($_SERVER as $k => $v) { if (substr($k, 0, 4) == 'HTTP' && empty($ignore[$k]) && isset($v)) { $params[] = urlencode('h[' . $k . ']') . '=' . urlencode($v); } } $post = implode('&', $params); $request = curl_init(); $request_timeout = 1; // 1 second timeout curl_setopt($request, CURLOPT_URL, 'http://r.admob.com/ad_source.php'); curl_setopt($request, CURLOPT_RETURNTRANSFER, 1); curl_setopt($request, CURLOPT_TIMEOUT, $request_timeout); curl_setopt($request, CURLOPT_CONNECTTIMEOUT, $request_timeout); curl_setopt($request, CURLOPT_HTTPHEADER, array('Content-Type: application/x-www-form-urlencoded', 'Connection: Close')); curl_setopt($request, CURLOPT_POSTFIELDS, $post); list($usec_start, $sec_start) = explode(' ', microtime()); $contents = curl_exec($request); list($usec_end, $sec_end) = explode(' ', microtime()); curl_close($request); if ($contents === true || $contents === false) $contents = ''; if (!$pixel_sent) { $pixel_sent = true; $contents .= "'; } return $contents; } } $CATALOG = new CATALOG; ?>