Explorar el Código

Minor Fixes, Pagination Improvements, Check DB Connection.

Home and Index attempt to execute as normal if there's no connection to
the database. There's a language translation in global.php
`no_db_connection` which can be used if there's no connection, we just
need to check for an instance of OGPDatabase.

As noted
[here](http://opengamepanel.org/forum/viewthread.php?thread_id=5329#post_25965)
with the pagination limits applying to the menu, that's been fixed.

A try/catch block was added to update/update.php and extras/extras.php
in order to prevent what happened
[here](http://opengamepanel.org/forum/viewthread.php?thread_id=5328)

A function was added to functions.php due to the excessive code reuse to
render the pagination page numbers. Additionally, the previous
pagination pages were a bit bugged - i.e, if you've got 3 items, set
$limit to 2, you'd see 4 pages.

The new function also allows each page number to be styled in themes, as
it's possible to pass a customClasses array to it (as in, for CSS)
Adjokip hace 9 años
padre
commit
5eaf5b868b

+ 12 - 16
home.php

@@ -35,12 +35,20 @@ define("IMAGES", "images/");
 define("INCLUDES", "includes/");
 define("MODULES", "modules/");
 
+// Load languages.
+include_once("includes/lang.php");
+ogpLang();
+
 define("CONFIG_FILE","includes/config.inc.php");
 
 require_once CONFIG_FILE;
 // Connect to the database server and select database.
 $db = createDatabaseConnection($db_type, $db_host, $db_user, $db_pass, $db_name, $table_prefix);
 
+if (!$db instanceof OGPDatabase) {
+	die(get_lang('no_db_connection'));
+}
+
 // Logged in user settings - access this global variable where needed
 if(hasValue($_SESSION['user_id'])){
 	$loggedInUserInfo = $db->getUserById($_SESSION['user_id']);
@@ -49,10 +57,6 @@ if(hasValue($_SESSION['user_id'])){
 $settings = $db->getSettings();
 @$GLOBALS['panel_language'] = $settings['panel_language'];
 
-// Load languages.
-include_once("includes/lang.php");
-ogpLang();
-
 require_once("includes/view.php");
 $view = new OGPView();
 $view->setCharset(get_lang('lang_charset'));
@@ -136,15 +140,7 @@ function heading()
 
 function ogpHome()
 {
-    global $db,$view,$settings, $loggedInUserInfo;
-
-	$page_user = (isset($_GET['page']) && (int)$_GET['page'] > 0) ? (int)$_GET['page'] : 1; // thanks for Adjokip
-  	$limit_user = isset($_GET['limit']) ? $_GET['limit'] : 10;
-	
-	if(hasValue($loggedInUserInfo) && is_array($loggedInUserInfo) && $loggedInUserInfo["users_page_limit"] && !hasValue($_GET['limit'])){
-		$limit_user = $loggedInUserInfo["users_page_limit"];
- 	}
-	
+    global $db,$view,$settings;
 	?>
 	%top%
 	<?php
@@ -153,9 +149,9 @@ function ogpHome()
 		$isAdmin = $db->isAdmin($_SESSION['user_id']);
 			
 		if ( $isAdmin )
-			$server_homes = $db->getHomesFor_limit('admin', $_SESSION['user_id'],$page_user,$limit_user);
+			$server_homes = $db->getHomesFor('admin', $_SESSION['user_id']);
 		else
-			$server_homes = $db->getHomesFor_limit('user_and_group', $_SESSION['user_id'],$page_user,$limit_user);
+			$server_homes = $db->getHomesFor('user_and_group', $_SESSION['user_id']);
 				
 		if(!empty($server_homes))
 		{
@@ -373,4 +369,4 @@ function ogpHome()
 	%bottom%
 <?php
 }
-?>
+?>

+ 30 - 1
includes/functions.php

@@ -657,4 +657,33 @@ function hasValue($val, $zeroAllowed = false){
 		}
 	}
 }
-?>
+
+function paginationPages($pageResults, $currentPage, $perPage, $pageUri, $customClasses) {
+	$pagination = '';
+
+	if ($pageResults > $perPage) {
+		if ($currentPage > 1) {
+			$pagination .= '<a href="'.$pageUri . ($currentPage-1) .'" class="'.$customClasses['previousLink'].'">Previous</a> ';
+		}
+
+		$totalPages = ceil($pageResults/$perPage);
+
+		for ($i=1; $i<=$totalPages;++$i) {
+			if ($currentPage == $i) {
+				$pagination .= '<span class="'.$customClasses['currentPage'].'">'.$i.'</span>';
+			} else {
+				$pagination .= '<a href="'.$pageUri . $i .'" class="'.$customClasses['pageLinks'].'">'.$i.'</a>';
+			}
+
+			$pagination .= ($i < $totalPages) ? ', ' : ' ';
+		}
+
+		if ($currentPage < $totalPages) {
+			$pagination .= '<a href="'.$pageUri . ($currentPage+1) .'" class="'.$customClasses['nextLink'].'">Next</a>';
+		}
+	}
+
+	return $pagination;
+}
+
+?>

+ 9 - 5
index.php

@@ -36,6 +36,10 @@ require_once("includes/functions.php");
 require_once("includes/helpers.php");
 require_once("includes/html_functions.php");
 
+// Load languages.
+include_once("includes/lang.php");
+ogpLang();
+
 // Start the session valid for opengamepanel_web only
 startSession();
 
@@ -58,6 +62,10 @@ require_once CONFIG_FILE;
 // Connect to the database server and select database.
 $db = createDatabaseConnection($db_type, $db_host, $db_user, $db_pass, $db_name, $table_prefix);
 
+if (!$db instanceof OGPDatabase) {
+	die(get_lang('no_db_connection'));
+}
+
 // Logged in user settings - access this global variable where needed
 if(hasValue($_SESSION['user_id'])){
 	$loggedInUserInfo = $db->getUserById($_SESSION['user_id']);
@@ -66,10 +74,6 @@ if(hasValue($_SESSION['user_id'])){
 $settings = $db->getSettings();
 @$GLOBALS['panel_language'] = $settings['panel_language'];
 
-// Load languages.
-include_once("includes/lang.php");
-ogpLang();
-
 require_once("includes/view.php");
 $view = new OGPView();
 $view->setCharset( lang_charset );
@@ -372,4 +376,4 @@ function ogpHome()
 	%bottom%
 <?php
 }
-?>
+?>

+ 13 - 23
modules/administration/watch_logger.php

@@ -65,8 +65,8 @@ function exec_ogp_module() {
 	if( isset( $_POST['empty_logger'] ) )
 		$db->empty_logger();
 	
-	$p = isset($_GET['page']) ? $_GET['page'] : 1;
-	$l = isset($_GET['limit']) ? $_GET['limit'] : 10;
+	$p = (isset($_GET['page']) && (int)$_GET['page'] > 0) ? (int)$_GET['page'] : 1;
+	$l = (isset($_GET['limit']) && (int)$_GET['limit'] > 0) ? (int)$_GET['limit'] : 10;
 	
 	if(hasValue($loggedInUserInfo) && is_array($loggedInUserInfo) && $loggedInUserInfo["users_page_limit"] && !hasValue($_GET['limit'])){
 		$l = $loggedInUserInfo["users_page_limit"];
@@ -119,25 +119,15 @@ function exec_ogp_module() {
 	echo "<tfoot style='border:1px solid grey;'></tfoot>\n";
 	echo "</table>\n";
 	$count_logs = $db->get_logger_count();
-	if($count_logs > $l)
-	{
-		$total_pages = $count_logs[0]['total'] / $l;
-		$pagination = "";
-		for($page=1; $page <= $total_pages+1; $page++)
-		{
-			if($page == $p){
-				$pagination .= " <b>$page</b>, ";
-			}else{
-				if(isset($l)){
-					$limits = $l;
-					$pagination .= "<a href='?m=administration&p=watch_logger&page=$page&limit=$limits'>$page</a>, ";
-				}else{
-					$pagination .= "<a href='?m=administration&p=watch_logger&page=$page' >$page</a>, ";
-				}
-			}
-		}
-		echo rtrim($pagination, ", ");
-	}
-}
-?>
 
+	$uri = '?m=administration&p=watch_logger&limit='.$l.'&page=';
+	echo paginationPages($count_logs[0]['total'], $p, $l, $uri,
+		array(
+			'previousLink' => 'watchLogger_previousPageLink',
+			'pageLinks' => 'watchLogger_pageLinks',
+			'nextLink' => 'watchLogger_nextPageLink',
+			'currentPage' => 'watchLogger_currentPageLink',
+		)
+	);
+}
+?>

+ 26 - 36
modules/dashboard/dashboard.php

@@ -55,7 +55,7 @@ function exec_ogp_module()
 	
 	if ( $isAdmin )
 	{
-		$server_homes = $db->getIpPorts_limit($ip_id,$page_user,$limit_user);
+		$server_homes = $db->getIpPorts_limit(0, $page_user, $limit_user);
 	}
 	else
 	{
@@ -102,44 +102,34 @@ function exec_ogp_module()
 					$player_list .= $refresh->getdiv($refresh->add("home.php?m=dashboard&p=query_ref&show=players&type=cleared&ip=".$server_home['ip']."&port=".$server_home['port']));
 				}
 			}
+
 			$OnlineServers .= "</table><br>";
 			
-if ($isAdmin){			
-	$count_homes = $db->getIpPorts_count('admin',$_SESSION['user_id']);
-	}
-	else{
-	$isSubUser = $db->isSubUser($_SESSION['user_id']);
-	if($isSubUser){
-	$count_homes = $db->getIpPorts_count('subuser',$_SESSION['user_id']);
-	}else{
-	$count_homes = $db->getIpPorts_count('user_and_group',$_SESSION['user_id']);
-		}
-	}
-	if($count_homes > $limit_user)
- 	{
- 		$total_pages = $count_homes[0]['total'] / $limit_user;
- 		$pagination = "";
- 		for($page=1; $page <= $total_pages+1; $page++)
- 		{
- 			if($page == $page_user){
- 				$pagination .= " <b>$page</b>,";
-				if($total_pages <= 1){$pagination = "";}
- 			}else{
-				if(isset($limit_user)){
- 					$limits = $limit_user;
-					
- 					$pagination .= "<a href='?m=dashboard&p=dashboard&page=$page&limit=$limits'>$page</a>,";
- 				}else{
- 					$pagination .= "<a href='?m=dashboard&p=dashboard&page=$page' >$page</a>,";
- 				}
- 			}
- 		}
- 		$OnlineServers .= rtrim($pagination, ",");
- 	}
+			if ($isAdmin) {			
+				$count_homes = $db->getIpPorts_count('admin',$_SESSION['user_id']);
+			} else {
+				$isSubUser = $db->isSubUser($_SESSION['user_id']);
+				
+				if ($isSubUser) {
+					$count_homes = $db->getIpPorts_count('subuser',$_SESSION['user_id']);
+				} else {
+					$count_homes = $db->getIpPorts_count('user_and_group',$_SESSION['user_id']);
+				}
+			}
+
+			$uri = '?m=dashboard&p=dashboard&limit='.$limit_user.'&page=';
+			$OnlineServers .= paginationPages($count_homes[0]['total'], $page_user, $limit_user, $uri,
+				array(
+					'previousLink' => 'dashboardHomes_previousPageLink',
+					'pageLinks' => 'dashboardHomes_pageLinks',
+					'nextLink' => 'dashboardHomes_nextPageLink',
+					'currentPage' => 'dashboardHomes_currentPageLink',
+				)
+			);
 	
 			$OnlineServers .= "<center>" . statistics . ":<br>$stats_servers_online/$stats_servers " . servers . "<br>" . 
-							  $refresh->getdiv($refresh->add("home.php?m=dashboard&p=query_ref&show=player_statistics&type=cleared&ip=" .
-							  $server_home['ip']."&port=".$server_home['port'])) . "</center>";
+						  $refresh->getdiv($refresh->add("home.php?m=dashboard&p=query_ref&show=player_statistics&type=cleared&ip=" .
+						  $server_home['ip']."&port=".$server_home['port'])) . "</center>";
 		}
 		else
 		{
@@ -364,4 +354,4 @@ $(document).ready(function(){
 </script>
 <?php
 }
-?>
+?>

+ 63 - 33
modules/extras/extras.php

@@ -314,11 +314,14 @@ function exec_ogp_module()
 		
 		return;
 	}
-	
-	$m = 0;
+
 	$modules = array();
-	$t = 0;
 	$themes = array();
+	$moduleErrors = array();
+
+	$m = 0;
+	$t = 0;
+
 	foreach($repos_info_array as $key => $repository)
 	{
 		if(preg_match('/^(OGP-Website|OGP-Agent-Linux|OGP-Agent-Windows)$/',$repository['name']))
@@ -344,40 +347,53 @@ function exec_ogp_module()
 			print_failure('Unable to get contents from : ' . $used_file);
 			continue;
 		}
-		$feedXml = new SimpleXMLElement($contents, LIBXML_NOCDATA);
-		$seed = basename(  (string) $feedXml->entry[0]->link['href'] );
-		/* echo "<xmp>";
-		print_r($feedXml);
-		echo "</xmp>"; */
-		if($seed)
-		{
-			if(preg_match("/^Module-/",$repository['name']))
+
+		try {
+			$feedXml = new SimpleXMLElement($contents, LIBXML_NOCDATA);
+			$seed = basename(  (string) $feedXml->entry[0]->link['href'] );
+			/* echo "<xmp>";
+			print_r($feedXml);
+			echo "</xmp>"; */
+			if($seed)
 			{
-				$module_title = preg_replace(array("/^Module-/i","/_/"),array(""," "),$repository['name']);
-				$modules[$m]['title'] = $module_title;
-				$modules[$m]['reponame'] = $repository['name'];
-				$modules[$m]['file'] = $seed.'.zip';
-				$modules[$m]['link'] = 'https://github.com/OpenGamePanel/'.$repository['name'].'/archive/'.$seed.'.zip';
-				$modules[$m]['date'] = (string) $feedXml->entry[0]->updated;
-				$modules[$m]['timestamp'] = strtotime((string) $feedXml->entry[0]->updated);
-				$modules[$m]['remove_path'] = $repository['name']."-".$seed;
-				$m++;
+				if(preg_match("/^Module-/",$repository['name']))
+				{
+					$module_title = preg_replace(array("/^Module-/i","/_/"),array(""," "),$repository['name']);
+					$modules[$m]['title'] = $module_title;
+					$modules[$m]['reponame'] = $repository['name'];
+					$modules[$m]['file'] = $seed.'.zip';
+					$modules[$m]['link'] = 'https://github.com/OpenGamePanel/'.$repository['name'].'/archive/'.$seed.'.zip';
+					$modules[$m]['date'] = (string) $feedXml->entry[0]->updated;
+					$modules[$m]['timestamp'] = strtotime((string) $feedXml->entry[0]->updated);
+					$modules[$m]['remove_path'] = $repository['name']."-".$seed;
+					$m++;
+				}
+				
+				if(preg_match("/^Theme-/",$repository['name']))
+				{
+					$theme_title = preg_replace("/Theme-/i","",$repository['name']);
+					$themes[$t]['title'] = $theme_title;
+					$themes[$t]['reponame'] = $repository['name'];
+					$themes[$t]['file'] = $seed.'.zip';
+					$themes[$t]['link'] = 'https://github.com/OpenGamePanel/'.$repository['name'].'/archive/'.$seed.'.zip';
+					$themes[$t]['date'] = (string) $feedXml->entry[0]->updated;
+					$themes[$t]['timestamp'] = strtotime((string) $feedXml->entry[0]->updated);
+					$themes[$t]['remove_path'] = $repository['name']."-".$seed;
+					$t++;
+				}
 			}
-			if(preg_match("/^Theme-/",$repository['name']))
-			{
-				$theme_title = preg_replace("/Theme-/i","",$repository['name']);
-				$themes[$t]['title'] = $theme_title;
-				$themes[$t]['reponame'] = $repository['name'];
-				$themes[$t]['file'] = $seed.'.zip';
-				$themes[$t]['link'] = 'https://github.com/OpenGamePanel/'.$repository['name'].'/archive/'.$seed.'.zip';
-				$themes[$t]['date'] = (string) $feedXml->entry[0]->updated;
-				$themes[$t]['timestamp'] = strtotime((string) $feedXml->entry[0]->updated);
-				$themes[$t]['remove_path'] = $repository['name']."-".$seed;
-				$t++;
+		} catch (Exception $e) {
+			if (preg_match("/^Module-/", $repository['name'])) {
+				$moduleErrors['modules'][] = preg_replace(array("/^Module-/i","/_/"),array(""," "),$repository['name']);
+			}
+
+			if(preg_match("/^Theme-/", $repository['name']) && !empty($repository['name'])) {
+				$moduleErrors['themes'][] = preg_replace("/Theme-/i","",$repository['name']);
 			}
 		}
+
 	}
-		
+
 	global $db;
 	$installed_modules = $db->getInstalledModules();
 	
@@ -441,6 +457,12 @@ function exec_ogp_module()
 	echo "<div class=\"dragbox bloc rounded\" style=\"margin:1%;\">".
 		 "<h4>".extra_modules."</h4>".
 		 "<div class=\"dragbox-content\" >";
+
+	if (!empty($moduleErrors['modules'])) {
+		foreach($moduleErrors['modules'] as $module) {
+			echo '<input type="checkbox" disabled><b>',$module,'</b> - <b style="color:red;">Unable to retrieve XML data.</b><br>';
+		}
+	}
 	
 	foreach ( $installed_modules as $installed_module )
 	{
@@ -487,6 +509,13 @@ function exec_ogp_module()
 	echo "<div class=\"dragbox bloc rounded\" style=\"margin:1%;\">".
 		 "<h4>".extra_themes."</h4>".
 		 "<div class=\"dragbox-content\" >";
+
+	if (!empty($moduleErrors['themes'])) {
+		foreach($moduleErrors['themes'] as $theme) {
+			echo '<input type="checkbox" disabled><b>',$theme,'</b> - <b style="color:red;">Unable to retrieve XML data.</b><br>';
+		}
+	}
+
 	foreach($themes as $key => $theme)
 	{
 		$local_repo_file = DATA_PATH . $theme['reponame'] . '.atom';
@@ -526,5 +555,6 @@ function exec_ogp_module()
 		 "' data-confirm='".confirm.
 		 "' data-cancel='".cancel.
 		 "' ></div>";
+
 }
-?>
+?>

+ 20 - 30
modules/gamemanager/server_monitor.php

@@ -129,7 +129,7 @@ function exec_ogp_module() {
 	$stats_maxplayers = 0;
 	
 	$home_page = (isset($_GET['page']) && (int)$_GET['page'] > 0) ? (int)$_GET['page'] : 1;
-	$home_limit = isset($_GET['limit']) ? (int)$_GET['limit'] : 10;
+	$home_limit = (isset($_GET['limit']) && (int)$_GET['limit'] > 0) ? (int)$_GET['limit'] : 10;
 	
 	if(hasValue($loggedInUserInfo) && is_array($loggedInUserInfo) && $loggedInUserInfo["users_page_limit"] && !hasValue($_GET['limit'])){
 		$home_limit = $loggedInUserInfo["users_page_limit"];
@@ -632,39 +632,29 @@ function exec_ogp_module() {
 
 	echo "</table>";
 
-	if($isAdmin)
-	{	
-		$homes_count = $db->getHomesFor_count('admin',$_SESSION['user_id']);
-	}
-	else
-	{
+	if ($isAdmin) {	
+		$homes_count = $db->getHomesFor_count('admin', $_SESSION['user_id']);
+	} else {
 		$isSubUser = $db->isSubUser($_SESSION['user_id']);
-		if($isSubUser)
-		{
+
+		if ($isSubUser) {
 			$homes_count = $db->getHomesFor_count('subuser',$_SESSION['user_id']);
-		}else{$homes_count = $db->getHomesFor_count('user_and_group',$_SESSION['user_id']);}	
-	}
-	if($homes_count > $home_limit)
-	{
-		$total_pages = $homes_count[0]['total'] / $home_limit;
-		$pagination = "";
-		for($page=1; $page <= $total_pages+1; $page++)
-		{
-			if($page == $home_page){
-				$pagination .= " <b>$page</b>,";
-				if($total_pages <= 1){$pagination = "";}
-			}else{
-				if(isset($home_limit)){
-					$limits = $home_limit;
-					$pagination .= "<a href='?m=gamemanager&p=game_monitor&page=$page&limit=$limits'>$page</a>,";
-				}else{
-					$pagination .= " <a href='?m=gamemanager&p=game_monitor&page=$page' >$page</a>,";
-				}
-			}
-		}
-		echo rtrim($pagination, ",");
+		} else {
+			$homes_count = $db->getHomesFor_count('user_and_group',$_SESSION['user_id']);
+		}	
 	}
 
+
+	$uri = '?m=gamemanager&p=game_monitor&limit='.$home_limit.'&page=';
+	echo paginationPages($homes_count[0]['total'], $home_page, $home_limit, $uri,
+		array(
+			'previousLink' => 'serverMonitor_previousPageLink',
+			'pageLinks' => 'serverMonitor_pageLinks',
+			'nextLink' => 'serverMonitor_nextPageLink',
+			'currentPage' => 'serverMonitor_currentPageLink',
+		)
+	);
+
 	echo "<div id=translation data-title='". upload_map_image .
 		 "' data-upload_button='". upload_image .
 		 "' data-bad_file='". jpg_gif_png_less_than_1mb .

+ 9 - 4
modules/update/update.php

@@ -71,9 +71,14 @@ function exec_ogp_module()
 	
 	if( file_exists(RSS_LOCAL_PATH) )
 	{
-		$feedXml = new SimpleXMLElement(file_get_contents(RSS_LOCAL_PATH), LIBXML_NOCDATA);
-		$seed = basename(  (string) $feedXml->entry[0]->link['href'] );
-		unlink(RSS_LOCAL_PATH);
+		try {
+			$feedXml = new SimpleXMLElement(file_get_contents(RSS_LOCAL_PATH), LIBXML_NOCDATA);
+			$seed = basename(  (string) $feedXml->entry[0]->link['href'] );
+			unlink(RSS_LOCAL_PATH);
+		} catch (Exception $e) {
+			print_failure('Unable to update: '.$e->getMessage());
+			return;
+		}
 	}
 	else
 	{
@@ -132,4 +137,4 @@ function exec_ogp_module()
 		}
 	}
 }
-?>
+?>

+ 13 - 21
modules/user_admin/show_users.php

@@ -48,7 +48,7 @@ function exec_ogp_module() {
     global $db, $loggedInUserInfo;
 	
 	$page_user = (isset($_GET['page']) && (int)$_GET['page'] > 0) ? (int)$_GET['page'] : 1;
-	$limit_user = isset($_GET['limit']) ? (int)$_GET['limit'] : 10;
+	$limit_user = (isset($_GET['limit']) && (int)$_GET['limit'] > 0) ? (int)$_GET['limit'] : 10;
 	
 	if(hasValue($loggedInUserInfo) && is_array($loggedInUserInfo) && $loggedInUserInfo["users_page_limit"] && !hasValue($_GET['limit'])){
 		$limit_user = $loggedInUserInfo["users_page_limit"];
@@ -99,26 +99,18 @@ function exec_ogp_module() {
         print "</tr>";
     }
     echo '</table><br>';
-	
+
 	$count_users = $db->get_user_count();
-	if($count_users > $limit_user)
-	{
-		$total_pages = $count_users[0]['total'] / $limit_user;
-		$pagination = "";
-		for($page=1; $page <= $total_pages+1; $page++)
-		{
-			if($page == $page_user){
-				$pagination .= " <b>$page</b>,";
-			}else{
-				if(isset($limit_user)){
-					$limits = $limit_user;
-					$pagination .= "<a href='?m=user_admin&page=$page&limit=$limits'>$page</a>,";
-				}else{
-					$pagination .= " <a href='?m=user_admin&page=$page' >$page</a>,";
-				}
-			}
-		}
-		echo rtrim($pagination, ",");
-	}
+	
+	$uri = '?m=user_admin&limit='.$limit_user.'&page=';
+	echo paginationPages($count_users[0]['total'], $page_user, $limit_user, $uri,
+		array(
+			'previousLink' => 'userManager_previousPageLink',
+			'pageLinks' => 'userManager_pageLinks',
+			'nextLink' => 'userManager_nextPageLink',
+			'currentPage' => 'userManager_currentPageLink',
+		)
+	);
+
 }
 ?>

+ 11 - 21
modules/user_games/show_homes.php

@@ -28,7 +28,7 @@ function exec_ogp_module()
 	global $db, $loggedInUserInfo;
 
 	$page_GameHomes = (isset($_GET['page']) && (int)$_GET['page'] > 0) ? (int)$_GET['page'] : 1;
-	$limit_GameHomes = isset($_GET['limit']) ? (int)$_GET['limit'] : 10;
+	$limit_GameHomes = (isset($_GET['limit']) && (int)$_GET['limit'] > 0) ? (int)$_GET['limit'] : 10;
 	
 	if(hasValue($loggedInUserInfo) && is_array($loggedInUserInfo) && $loggedInUserInfo["users_page_limit"] && !hasValue($_GET['limit'])){
 		$limit_GameHomes = $loggedInUserInfo["users_page_limit"];
@@ -76,26 +76,16 @@ function exec_ogp_module()
 	echo "</table>";
 
 	$count_GameHomes = $db->get_GameHomes_count();
-	if($count_GameHomes > $limit_GameHomes)
-	{
-		$total_pages = $count_GameHomes[0]['total'] / $limit_GameHomes;
-		$pagination = "";
-		for($page=1; $page <= $total_pages+1; $page++)
-		{
-			if($page == $page_GameHomes){
-				$pagination .= " <b>$page</b>,";
-				if($total_pages <= 1){$pagination = "";}
-			}else{
-				if(isset($limit_GameHomes)){
-					$limits = $limit_GameHomes;
-					$pagination .= "<a href='?m=user_games&page=$page&limit=$limits'>$page</a>,";
-				}else{
-					$pagination .= " <a href='?m=user_games&page=$page' >$page</a>,";
-				}
-			}
-		}
-		echo rtrim($pagination, ",");
-	}
+
+	$uri = '?m=user_games&limit='.$limit_GameHomes.'&page=';
+	echo paginationPages($count_GameHomes[0]['total'], $page_GameHomes, $limit_GameHomes, $uri,
+		array(
+			'previousLink' => 'userGames_previousPageLink',
+			'pageLinks' => 'userGames_pageLinks',
+			'nextLink' => 'userGames_nextPageLink',
+			'currentPage' => 'userGames_currentPageLink',
+		)
+	);
 
 	?>
 	<script type="text/javascript">