add("act" ,"ENUM[all|slideshow|slide]",GET);
$gd->add("id" ,"INT" ,GET);
$gd->add("name","INT" ,GET);
// Some local reconstruction
if($gd->get["name"]=="")die();
$viewerpath.='/'.$gd->get["name"];
$viewerurl .='/'.$gd->get["name"];
//$sql->query("select `name` from `articles` where `id`='".$gd->get["name"]."'");
//list($viewertitle)=$sql->fetch_row();
// Opening and reading directory content into array - this works almost like scandir(), but scandir in unsupported in PHP4
@$dh=opendir($viewerpath)or(die());
$imarray=array();
$imtype=array();
while($image=readdir($dh)){
if(preg_match('/([[:digit:]]*)_small\.(gif|jpg)/',$image,$tmp)){
array_push($imarray,intval($tmp[1]));
$imtype[intval($tmp[1])]=$tmp[2];
}
}
if(count($imarray)==0)die();
// Sorting array in correct order
sort($imarray);
/*
echo "array:";
trace($imarray);
echo "type:";
trace($imtype);
*/
// Making action choice
switch($gd->get["act"]){
// Show images sequently with timeout setted by $viewertimeout
case "slideshow":
$refresh='get["id"]+1) .'">';
// Show specified slide
case "slide":
// Getting first and last images
$firstimid=$imarray[0];
$lastimid =$imarray[count($imarray)-1];
$imid=$imarray[$gd->get["id"]];
$desc=load($gd->get["name"]."/data");
// Incorrect image id
if(
(
($imid=="")&&
($gd->get["id"]!=0)
)or(
$gd->get["id"]==""
)
)header("Location: ?name=".$gd->get["name"]."&id=0");
//$imbigcode =image($viewerpath.'/'.$imid.'_big.'.$imtype[$imarray[$imid]] ,$viewerurl .'/'.$imid.'_big.'.$imtype[$imarray[$imid]]);
$imbigcode =image($viewerpath.'/'.$imid.'_big.'.$imtype[$imid] ,$viewerurl .'/'.$imid .'_big.'.$imtype[$imid]);
$viewer='