Este es el codigo donde capturo el $_GET
Código PHP:
$pag = (int) mysql_real_escape_string($_GET['pag']);
//En que pagina estoy?
if(!empty($pag)){
$RegistrosAEmpezar=($pag-1)*$limit_posts;
$PagAct=$pag;
}
else{
$RegistrosAEmpezar=0;
$PagAct=1;
}
$NroRegistros=3000;
$PagAnt=$PagAct-1;
$PagSig=$PagAct+1;
$PagUlt=$NroRegistros/$limit_posts;
//Consulta Posts Recientes
if (($data=$cache->get('posts_recent',8)) === FALSE || !empty($id))
{
//Consulta de posts normales
$request=db_query("
SELECT m.ID_MEMBER, m.ID_TOPIC, m.body, m.imgport, c.ID_CAT, subject, c.name, t.ID_BOARD, posterName, puntos, m.hiddenOption, posterTime, denuncias
FROM {$db_prefix}messages as m, {$db_prefix}boards as c, {$db_prefix}topics as t
WHERE c.ID_BOARD=m.ID_BOARD AND t.ID_TOPIC=m.ID_TOPIC AND t.isSticky = 0 {$cat_condition}
AND c.ID_CAT != 12 " . (!empty($modSettings['recycle_enable']) && $modSettings['recycle_board'] > 0 ? "
AND c.ID_BOARD != $modSettings[recycle_board]" : '') . "
ORDER BY m.ID_TOPIC DESC
LIMIT $RegistrosAEmpezar,$limit_posts", __FILE__, __LINE__);
while($posts = mysql_fetch_array($request))
{
$context['normal_posts'][] = array(
'ID_MEMBER' => $posts['ID_MEMBER'],
'id' => $posts['ID_TOPIC'],
'body' => $posts['body'],
'imgport' => $posts['imgport'],
'title' => $posts['subject'],
'category' => $posts['name'],
'id_category' => $posts['ID_BOARD'],
'user' => $posts['posterName'],
'date' => $posts['posterTime'],
'puntos' => $posts['puntos'],
'denuncias' => $posts['denuncias'],
);
}
mysql_free_result($request);
if (empty($id))
$cache->set('posts_recent', $context['normal_posts']);
}else{
$context['normal_posts'] = $data;
}
Código PHP:
<div id="pg" class="floatR">';
$comienza=1;
$termina=$PagUlt;
$pag_string='';
$medio=4;
if($PagUlt>2*$medio){
$topesup=$PagUlt-$medio;
$topeinf=$medio;
if ($PagAct>$topeinf)
$comienza=$PagAct-$medio;
if($PagAct>$topesup){
$termina=$PagUlt;
$comienza=$PagUlt-2*$medio;}
else
if ($PagAct>$topeinf)
$termina=$PagAct+$medio;
else
$termina=2*$medio;}
$id = $_GET['id'];
if (empty($id))
{
if ($PagUlt>1){
for ($i=$comienza;$i<=$termina;$i++){
if ($i!=$PagAct)
$pag_string.='<a class="numeronew" id="pag_$i" href="/pagina/'. $i.'/">'.$i.'</a>';
else
$pag_string .='<a href="/pagina/'. $i.'/" class="numero active">'.$i.'</a>';}
}
if($id == ''){
if($PagAct>1) echo "<a id='btn' class='numeronew' title='Atras' href='/index.php?pag=$PagAnt'>< Atras</a>";
echo $pag_string;
if($PagAct<$PagUlt) echo "<a id='btn' class='numeronew' title='Siguiente' href='/index.php?pag=$PagSig'>Siguiente ></a>";
}else
{
if($PagAct>1) echo "<a id='btn' class='numeronew' title='Atras' href='/index.php?pag=$PagAnt'>< Atras</a>";
echo $pag_string;
if($PagAct<$PagUlt) echo "<a id='btn' class='numeronew' title='Siguiente' href='/index.php?pag=$PagSig'>Siguiente ></a>";
}
}else{
if ($PagUlt>1){
for ($i=$comienza;$i<=$termina;$i++){
if ($i!=$PagAct)
$pag_string.="<a class='numeronew' id='pag_$i' href='/".$_GET['id']."/". $i."/'>".$i."</a>";
else
$pag_string .="<a class='numero active'>".$i."</a>";}
}
if($id == ''){
if($PagAct>1) echo "<a id='btn' class='numeronew' title='Atras' href='/index.php?pag=$PagAnt'>< Atras</a>";
echo $pag_string;
if($PagAct<$PagUlt) echo "<a id='btn' class='numeronew' title='Siguiente' href='/index.php?pag=$PagSig'>Siguiente ></a>";
}else
{
if($PagAct>1) echo "<a id='btn' class='numeronew' title='Atras' href='/index.php?pag=$PagAnt'>< Atras</a>";
echo $pag_string;
if($PagAct<$PagUlt) echo "<a id='btn' class='numeronew' title='Siguiente' href='/index.php?pag=$PagSig'>Siguiente ></a>";
}
}
echo'</div>;