pName = 'open_9704'; $this->rootPath = 'GAMES/'; $this->wmlTemplatePath = 'templates/wap/wml/wml.template.php'; $this->xhtmlTemplatePath = 'templates/wap/xhtml/xhtml.template.php'; $this->searchResLimit = 33; $this->recordsPerPage = 2; $this->pageRange = 5; $this->title = 'Windows Mobile Games Download | The Best Windows Mobile Games for your Cell Phone!'; $this->keyWords = 'windows games, windows games download, windows downloads, mobile downloads, download games, bb games'; $this->description = 'windows Downloads. Best windows Games to play on your smartphone. Join the FUN!'; $this->domainRoot = "http://windows-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 .= 'windows games, bb games'; }else{ $out .= '
windows games, bb 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 = 'windows 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 .= '

'; $this->title = 'Mobile Cell Phone '.$this->parentCategory['name'].' | '.$this->category['name'].' | Play '.stripslashes ($this->arrGameCard['title']).' Game Now!'; $this->keyWords = 'windows games, smartphones, '.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
'; $this->title = $this->parentCategory['name'].' for Mobile Phone'.' | '.$this->category['name'].' | Download & Play '.stripslashes ($this->arrGameCard['title']).' Game Now!'; $this->keyWords = 'game mobile phone, windows games, smartphone, '.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 == 6) || ($this->linkId == 18) || ($this->linkId == 23) || ($this->linkId == 20) || ($this->linkId == 22) || ($this->linkId == 21) || ($this->linkId == 19) || ($this->linkId == 17)){ if(isset($this->arrUserData['is_wml'])){ $out .= ''.$kidRow['jname']."
\n"; }else{ $out .= '\n"; } } } } } 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"; }else{ $out .= '

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


game mobile phone
'; $out .= 'more info about
'.stripslashes($listRow[$a]['title']).'
game
'."\n"; } } } $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 your windows smartphone ' : $this->title; $this->keyWords = ($this->row['id'] != 1)? (strtolower($this->row['name'])).', windows games, windows downloads, 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]); } } $CATALOG = new CATALOG; ?>