Paginazione file evitare di inserire questi \ o altro nella get

luigi777

Utente Attivo
14 Feb 2008
1.086
1
38
43
Massa, Italy
Salve, volevo sapere come faccio ad evitare che uno può scrivere page.php?page=\
perché se metto cosi. mi da errori
Notice: Undefined offset: dove faccio visualizzare a video i dati.
ecco il codice.. che questo mi nasconde l'htaccess dalla visualizzazione dei file.

PHP:
<?php
//The directory to your images folder, with trailing slash
$dir = "".$cfg_page_dir_admin."";

//Set the extensions you want to load, seperate by a comma.
$extensions = "htm";

//Set the number of images you want to display per page
$PerPage = $cfg_page_list;


//Set the $page variable
if(!isset($_GET["page"])){
	$page = 1;
}else{
	$page = $_GET["page"];
}

//Load all images into an array
$images = glob($dir."*.{".$extensions."}", GLOB_BRACE);

//Count the number of images
$totalImages = count($images);

//Get the total pages
$totalPages = ceil($totalImages / $PerPage);

//Make sure the page you are on is not greater then the total pages available.
if($page > $totalPages){
	//Set the currnet page to the total pages.
	$page = $totalPages;
}

//Now find where to start the loading from
$from = ($page * $PerPage) - $PerPage;
		echo '<table width="100%" border="0" cellspacing="2" cellpadding="2">
  <tr>
    <td align="center" valign="middle"><font color="red">Pagina</font></td>
    <td align="center" valign="middle"><font color="red">Modifica</font></td>
	<td align="center" valign="middle"><font color="red">Cancella</font></td>
  </tr>';
//Now start looping
for($i = $from; $i < ($from + $PerPage); $i++){
	//We need to make sure that its within the range of totalImages.
	if($i < $totalImages){
		//Now we can display the image!
		?>
	<tr>
    <td align="center" valign="middle"><?php echo basename($images[$i]); ?></td>
    <td align="center" valign="middle"><a href="index.php?m=pagine&action=modifica&url=<?php echo basename($images[$i]); ?>" onClick="return confirm('Sicuro di editare  <?php echo basename($images[$i]); ?>?');"><?php echo basename($images[$i]); ?></a></td>
   <td align="center" valign="middle"><a href="index.php?m=pagine&action=del&url=<?php echo basename($images[$i]); ?>" onClick="return confirm('Sicuro di cancellare <?php echo basename($images[$i]); ?>?');"><?php echo basename($images[$i]); ?></a></td>
  </tr>
		<?php
	}
}
	echo '</table>';
//Now to display the page numbers!
for($p = 1; $p <= $totalPages; $p++){
	if($p == $page){
		$tmp_pages[] = "<strong>{$p}</strong>";
	}else{
		$tmp_pages[] = "<a href='index.php?m=pagine&page={$p}'>{$p}</a>";
	}
}

//Now display pages, seperated by a hyphon.
echo "<br />" . implode(" - ", $tmp_pages);

mi date una mano..

grazie mille.
 
Ultima modifica:

Discussioni simili