Codice PHP:
<?
$now=explode('&',$_SERVER['QUERY_STRING'])[1];
if($now==''||empty($now)){
$now=0;
}
if($now<25&&is_numeric($now)){
$max='150';
$range=range(1,$max);
$indietro=$now-1;
if($indietro=='-1'||$indietro=='0'){
$indietro='';
}
if($indietro==''){
$domanda='';
}else{
$domanda='?';
}
$cuc=array_chunk($range,6);
$to=$cuc[$now];
?>
<div class=cont>
<h1>All Barack's World pictures</h1>
From <?=$to[0]?> to <?=$to[5]?>.
</div>
<br><br>
<table class=table>
<tr>
<td><a href="/image/?<?=$to[0]?>"><img src="/img/obama/<?=$to[0]?>.jpg" alt="one obama"></a></td>
<td><a href="/image/?<?=$to[1]?>"><img src="/img/obama/<?=$to[1]?>.jpg" alt="four obama"></a></td>
</tr>
<tr>
<td><a href="/image/?<?=$to[2]?>"><img src="/img/obama/<?=$to[2]?>.jpg" alt="seven obama"></a></td>
<td><a href="/image/?<?=$to[3]?>"><img src="/img/obama/<?=$to[3]?>.jpg" alt="ten obama"></a></td>
</tr>
<tr>
<td><a href="/image/?<?=$to[4]?>"><img src="/img/obama/<?=$to[4]?>.jpg" alt="two obama"></a></td>
<td><a href="/image/?<?=$to[5]?>"><img src="/img/obama/<?=$to[5]?>.jpg" alt="five obama"></a></td>
</tr>
</table>
<div class=cont>
<a href="./">start</a> <a href="./?24">end</a><br>
<a rel=prev href="./<?=$domanda.$indietro?>">previous</a> <a rel=next href="./?<?=$now+1?>">next</a>
</div>
<?}elseif($now!=='end'){
header('location:./?end');
}else{?>
<div class=cont>
<h1>Gallery has ended!</h1>
Terrible, right?<br>
<h2>Write two words about this sad moment:</h2>
<?comment()?>
<br><br>
And now please go back:<br>
<a href="./?24">24th page of the gallery</a>
</div>
<?}?>