Location: PHPKode > scripts > Dynapic SE > dynapic-se/index_newst_first.php
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//EN">
<HTML>
<HEAD>
<?
INCLUDE "conf.php";
if ((!isset($gal))||(!isset($title[$gal]))){
print "<TITLE>Categories</TITLE>";
include "banner.php";
print "<h1>Categories</h1>";
$categories=0;
while (isset($title[$categories])){
print "<h2><a href=$PHP_SELF?gal=$categories>$title[$categories]</a></h2>";
$categories++;
};
}else{
?>
<TITLE><? print $title[$gal]; ?></TITLE>
</HEAD>
<body bgcolor="#000000" text="#FFFFFF" link="#FFC800" vlink="#FFFFFF" alink="#FFFFFF">
<?
error_reporting(63);
include "banner.php";
?>
<center>
<h1><? print $title[$gal] ?></h1>
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<?
if (!isset($pg)){
$pg=0;
};

##########################################
#    Old Method of getting file names    #
##########################################

#$handle=opendir($dir[$gal]);
#$i=0;
#while ($file = readdir($handle)) {
#if (eregi("jpg$",$file)){
#$folder[$i]=$file;
#$i=$i+1;
#};
#};


##########################################
#    New Method of getting file names    #
##########################################
$dir_name=$dir[0];


$dir = opendir($dir_name); 
$basename = basename($dir_name); 
$fileArr = array(); 

while ($file_name = readdir($dir)) 
{ 
if (($file_name !=".") && ($file_name != "..")) 
{ 
#Get file modification date... 
# 
$fName = "$dir_name/$file_name"; 
$fTime = filemtime($fName); 
$fileArr[$file_name] = $fTime; 
} 
} 

# Use arsort to get most recent first 
# and asort to get oldest first 
arsort($fileArr); 


# Now put the ordered files into a new array for display
$numberOfFiles = sizeOf($fileArr); 
for($i=0;$i<$numberOfFiles;$i++) 
{ 
$thisFile = each($fileArr); 
$thisName = $thisFile[0]; 
$thisTime = $thisFile[1]; 
$thisTime = date("d M y", $thisTime); 
$folder[$i]=$thisName;
 

} 


closedir($dir);

$a=0;
$count=$row*$col*$pg;
for ($r=1; $r<=$row; $r++) {
print "<tr>";
if ($count>$i-1) {break;};
for ($c=1; $c<=$col; $c++) {
$tnpath=$tndir[$gal]."/small_".$folder[$count];
print "<td valign=\"center\" align=\"center\"><a href=\"view.php?id=$folder[$count]&gal=$gal&pg=$pg&count=$count\"><img src=\"$tnpath\" BORDER=0></a><td valign=\"center\">"; $count++;
if ($count>$i-1) {break;};
} ;
print "</tr>";
}  ;
print "</table><br><br>";
if ($pg>0) {
$tmp=$pg-1;;
print "<a href=\"$PHP_SELF?pg=$tmp&gal=$gal\"><img src=\"prev.gif\" alt=\"prev\" width=\"30\" height=\"20\" border=\"0\"></a>" ;
};
$tmp=$pg+1;
print "&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp";
if ($tmp*$row*$col<$i) {
$tmp=$pg+1;
print "<a href=\"$PHP_SELF?pg=$tmp&gal=$gal\"><img src=\"next.gif\" alt=\"prev\" width=\"30\" height=\"20\" border=\"0\"></a>" ;
};
$pages=floor($i/($row*$col));
$locstring="<center>";
for($i=0;$i<=$pages;$i++){
$pnum=$i+1;
$locstring.="<a href=\"$PHP_SELF?gal=$gal&pg=$i\">$pnum</a> ";
};
$locstring.="</center>";
print $locstring;

};
include "bannerbot.php";
?>
<center>
</BODY>

</HTML>
Return current item: Dynapic SE