mam skrypt do galerii, przerobilem go zeby wyswietlal zawartość katalogu z uploadu,
ale wyswietla on alfabetycznie co jest b. duzym utrudnieniem w znajdowaniu zeczy dodanych.
Czy wie ktos moze co jest odpowiedzialne za kolejnosc wedlug daty dodania ?
Jakby ktos mial pomysl co tutaj zmienic to z gory bardzo dziekuje, niestety nie wiem nawet w ktorej czesci teg szukac.
Kod
//directory with original pics
$img_dir = "../wap/tap/";
//directory for thumbnail files
$thumbs_dir = "../wap/tap/";
//thumbnail template
$borderpic = "animacje/$pic.gif";
//spacing between template size and thumbnail size
$thumbsborder = 40;
//thumbnails in one row
$columns = 2;
//thumbnails on one page
$maxperpage = 18;
//htmlcode around
$templatefile = "template.php";
//save generated thumbnails? faster!
$save = true;
//regular expression for filemask
// ".+\.png$|.+\.jpg$" = all .png and .jpg
// ".+\.jp[e]{0,1}g$" = all .jpeg and .jpg
// ".+\.gif" = all .gif
$ext_pattern = ".+\.gi{0,1}f$";
//caption of thumbnail table
if($start){
$infocaption = "<br>Kliknij na obrazek aby pobrac <b>darmowa</b> tapete na telefon<br> <a href=\"http://meganet.pl/~netbuspl/wap/tap/\" target=\"_blank\"><b>Kliknij tutaj</b></a> aby dodać własna taptę !";
}
else
{
$infocaption = "<br>Tutaj możesz dodać tapete o dokladnym wymiarze Twojego wyswietlacza, dowolne zdjęcie które posiadasz (format .gif) <a href=\"http://meganet.pl/~netbuspl/wap/tap/\" target=\"_blank\"><b>Kliknij tutaj</b></a> aby dodać własna taptę ! <br>Kliknij na obrazek aby pobrac <b>darmowa</b> tapete na teleton<br>";
}
//link to previous page
$prevcaption = "Poprzednie";
//link to next page
$nextcaption = "Nastepne";
function thumb_getsize($thumb_width,$thumb_height,$original_width,$original_height,$border=0) {
$min_width = $thumb_width - $border - $border;
$min_height = $thumb_height - $border - $border;
$div_width = $original_width / $min_width;
$div_height = $original_height / $min_height;
if ($div_width >= $div_height) {
$res_width = $min_width;
$res_height = round($original_height / $div_width);
$res_left = $border;
$res_top = round(($min_height / 5) - ($res_height / 5) + $border);
} else {
$res_height = $min_height;
$res_width = round($original_width / $div_height);
$res_top = $border;
$res_left = round(($min_width / 5) - ($res_width / 5) + $border);
}
$result = array($res_left,$res_top,$res_width,$res_height);
return $result;
}
function thumb_create($original_img,$img_border,$rect,$original_width,$original_height,$border_width,$border_height) {
$thumbnail = imagecreate($border_width,$border_height);
imagecopyresized($thumbnail,$img_border,0,0,0,0,$border_width,$border_height,$border_width,$border_height);
imagecopyresized($thumbnail,$original_img,$rect[0],$rect[1],0,0,$rect[2],$rect[3],$original_width,$original_height);
return $thumbnail;
}
function thumb_print($dir,$file_thumb,$file_border,$s,$f,$mdir) {
if ($f or (!(file_exists($mdir.$file_thumb)))) {
list($width,$height,$pictype) = getimagesize($dir.$file_thumb);
switch ($pictype) {
case 1 : $img = imagecreatefromgif($dir.$file_thumb); break;
case 2 : $img = imagecreatefromjpeg($dir.$file_thumb); break;
case 3 : $img = imagecreatefrompng($dir.$file_thumb); break;
}
list($b_width,$b_height,$b_pictype) = getimagesize($file_border);
switch ($b_pictype) {
case 1 : $imgborder = imagecreatefromgif($file_border); break;
case 2 : $imgborder = imagecreatefromjpeg($file_border); break;
case 3 : $imgborder = imagecreatefrompng($file_border); break;
}
if (($img) && ($imgborder)) {
$rect = thumb_getsize($b_width,$b_height,$width,$height,$GLOBALS["thumbsborder"]);
$thumbnail = thumb_create($img,$imgborder,$rect,$width,$height,$b_width,$b_height);
if ($s) {
switch ($pictype) {
case 1 : imagegif($thumbnail,$mdir.$file_thumb); break;
case 2 : imagejpeg($thumbnail,$mdir.$file_thumb); break;
case 3 : imagepng($thumbnail,$mdir.$file_thumb); break;
}
}
switch ($pictype) {
case 1 : imagegif($thumbnail); break;
case 2 : imagejpeg($thumbnail); break;
case 3 : imagepng($thumbnail); break;
}
}
} else {
list(,,$pictype) = getimagesize($mdir.$file_thumb);
switch ($pictype) {
case 1 : $img = imagecreatefromgif($mdir.$file_thumb); break;
case 2 : $img = imagecreatefromjpeg($mdir.$file_thumb); break;
case 3 : $img = imagecreatefrompng($mdir.$file_thumb); break;
}
switch ($pictype) {
case 1 : imagegif($img); break;
case 2 : imagejpeg($img); break;
case 3 : imagepng($img); break;
}
}
}
function read_data($data_dir,$ext) {
$dir_handle = @opendir($data_dir);
if ($dir_handle) {
while ($file = readdir($dir_handle)) {
if (eregi($ext,$file)) {
$files[] = $file;
}
}
closedir($dir_handle);
}
if (gettype($files) == "array") {
sort($files);
} else {
$files = false;
}
return $files;
}
function index_print($dir,$ext,$template,$dia,$cols,$f,$maxperpage,$start) {
$lines = file($template);
$line = implode("",$lines);
$selflink = $GLOBALS["PHP_SELF"];
$images = read_data($dir,$ext);
if ($images) {
// list(,,,$sizestr) = getimagesize($dia);
$table = $GLOBALS["infocaption"]."<br><br><table border=\"0\" cellpadding=\"2\">\r\n<tr>";
$max = count($images)-1;
$end = $start+$maxperpage-1;
$counter = 0;
while (list($key,$image) = each($images)) {
if (($key >= $start) && ($key <= $end)) {
$piclink = $PHP_SELF."".$image;
if ($f) {$piclink .= "&f=1"; }
/*TUTAJ TRZEBA WPISAC ID*/
$id = "ttap";
/*TUTAJ TRZEBA WPISAC ID*/
$biglink = $PHP_SELF."$id.php?cmd=max&start=".$start."&pic=".$image;
$table .= "<td><a href=\"$biglink\"><img src=\"http://meganet.pl/~netbuspl/wap/tap/$piclink\" border=\"0\" $sizestr></a></td>";
$counter++;
if (((($counter) % $cols) == 0) && ($key < $end)) {
$table .= "</tr><tr>";
}
}
}
$table .= "</tr></table><br>";
if ($start > 0) {
$prevstart = $start - $maxperpage;
$table .= "<a href=\"$selflink?id=$id&start=$prevstart\">".$GLOBALS["prevcaption"]."</a> ";
}
if ($end < $max) {
$nextstart = $end+1;
$table .= " <a href=\"$selflink?id=$id&start=$nextstart\">".$GLOBALS["nextcaption"]."</a>";
}
} else {
$table = "No files in <b>$dir</b>";
}
$line = str_replace("###pictable###",$table,$line);
return $line;
}
function image_print($pic,$template,$start) {
$lines = file($template);
$line = implode("",$lines);
$selflink = $GLOBALS["PHP_SELF"];
list(,,,$sizestr) = getimagesize($pic);
require("tban.php");
$piclink = "$banner<br><br><br><img src=\"http://serwer.pl/tap/$pic\" border=\"0\"><br><br>";
$pica=$pic;
$pica=str_replace("../wap/tap/","",$pica);
$pica=str_replace(".gif","",$pica);
$piclink .= "</p>";
$line = str_replace("###pictable###",$piclink,$line);
return $line;
}
function main($cmd,$dir,$pic,$dia,$template,$cols,$s,$f,$mdir,$maxperpage,$start,$ext=".png") {
switch ($cmd) {
case "min" :
thumb_print($dir,$pic,$dia,$s,$f,$mdir);
break;
case "max" :
echo image_print($dir.$pic,$template,$start);
break;
default :
echo index_print($dir,$ext,$template,$dia,$cols,$f,$maxperpage,$start);
}
}
main($cmd,$img_dir,$pic,$borderpic,$templatefile,$columns,$save,$f,$thumbs_dir,$maxperpage,$start,$ext_pattern);
$img_dir = "../wap/tap/";
//directory for thumbnail files
$thumbs_dir = "../wap/tap/";
//thumbnail template
$borderpic = "animacje/$pic.gif";
//spacing between template size and thumbnail size
$thumbsborder = 40;
//thumbnails in one row
$columns = 2;
//thumbnails on one page
$maxperpage = 18;
//htmlcode around
$templatefile = "template.php";
//save generated thumbnails? faster!
$save = true;
//regular expression for filemask
// ".+\.png$|.+\.jpg$" = all .png and .jpg
// ".+\.jp[e]{0,1}g$" = all .jpeg and .jpg
// ".+\.gif" = all .gif
$ext_pattern = ".+\.gi{0,1}f$";
//caption of thumbnail table
if($start){
$infocaption = "<br>Kliknij na obrazek aby pobrac <b>darmowa</b> tapete na telefon<br> <a href=\"http://meganet.pl/~netbuspl/wap/tap/\" target=\"_blank\"><b>Kliknij tutaj</b></a> aby dodać własna taptę !";
}
else
{
$infocaption = "<br>Tutaj możesz dodać tapete o dokladnym wymiarze Twojego wyswietlacza, dowolne zdjęcie które posiadasz (format .gif) <a href=\"http://meganet.pl/~netbuspl/wap/tap/\" target=\"_blank\"><b>Kliknij tutaj</b></a> aby dodać własna taptę ! <br>Kliknij na obrazek aby pobrac <b>darmowa</b> tapete na teleton<br>";
}
//link to previous page
$prevcaption = "Poprzednie";
//link to next page
$nextcaption = "Nastepne";
function thumb_getsize($thumb_width,$thumb_height,$original_width,$original_height,$border=0) {
$min_width = $thumb_width - $border - $border;
$min_height = $thumb_height - $border - $border;
$div_width = $original_width / $min_width;
$div_height = $original_height / $min_height;
if ($div_width >= $div_height) {
$res_width = $min_width;
$res_height = round($original_height / $div_width);
$res_left = $border;
$res_top = round(($min_height / 5) - ($res_height / 5) + $border);
} else {
$res_height = $min_height;
$res_width = round($original_width / $div_height);
$res_top = $border;
$res_left = round(($min_width / 5) - ($res_width / 5) + $border);
}
$result = array($res_left,$res_top,$res_width,$res_height);
return $result;
}
function thumb_create($original_img,$img_border,$rect,$original_width,$original_height,$border_width,$border_height) {
$thumbnail = imagecreate($border_width,$border_height);
imagecopyresized($thumbnail,$img_border,0,0,0,0,$border_width,$border_height,$border_width,$border_height);
imagecopyresized($thumbnail,$original_img,$rect[0],$rect[1],0,0,$rect[2],$rect[3],$original_width,$original_height);
return $thumbnail;
}
function thumb_print($dir,$file_thumb,$file_border,$s,$f,$mdir) {
if ($f or (!(file_exists($mdir.$file_thumb)))) {
list($width,$height,$pictype) = getimagesize($dir.$file_thumb);
switch ($pictype) {
case 1 : $img = imagecreatefromgif($dir.$file_thumb); break;
case 2 : $img = imagecreatefromjpeg($dir.$file_thumb); break;
case 3 : $img = imagecreatefrompng($dir.$file_thumb); break;
}
list($b_width,$b_height,$b_pictype) = getimagesize($file_border);
switch ($b_pictype) {
case 1 : $imgborder = imagecreatefromgif($file_border); break;
case 2 : $imgborder = imagecreatefromjpeg($file_border); break;
case 3 : $imgborder = imagecreatefrompng($file_border); break;
}
if (($img) && ($imgborder)) {
$rect = thumb_getsize($b_width,$b_height,$width,$height,$GLOBALS["thumbsborder"]);
$thumbnail = thumb_create($img,$imgborder,$rect,$width,$height,$b_width,$b_height);
if ($s) {
switch ($pictype) {
case 1 : imagegif($thumbnail,$mdir.$file_thumb); break;
case 2 : imagejpeg($thumbnail,$mdir.$file_thumb); break;
case 3 : imagepng($thumbnail,$mdir.$file_thumb); break;
}
}
switch ($pictype) {
case 1 : imagegif($thumbnail); break;
case 2 : imagejpeg($thumbnail); break;
case 3 : imagepng($thumbnail); break;
}
}
} else {
list(,,$pictype) = getimagesize($mdir.$file_thumb);
switch ($pictype) {
case 1 : $img = imagecreatefromgif($mdir.$file_thumb); break;
case 2 : $img = imagecreatefromjpeg($mdir.$file_thumb); break;
case 3 : $img = imagecreatefrompng($mdir.$file_thumb); break;
}
switch ($pictype) {
case 1 : imagegif($img); break;
case 2 : imagejpeg($img); break;
case 3 : imagepng($img); break;
}
}
}
function read_data($data_dir,$ext) {
$dir_handle = @opendir($data_dir);
if ($dir_handle) {
while ($file = readdir($dir_handle)) {
if (eregi($ext,$file)) {
$files[] = $file;
}
}
closedir($dir_handle);
}
if (gettype($files) == "array") {
sort($files);
} else {
$files = false;
}
return $files;
}
function index_print($dir,$ext,$template,$dia,$cols,$f,$maxperpage,$start) {
$lines = file($template);
$line = implode("",$lines);
$selflink = $GLOBALS["PHP_SELF"];
$images = read_data($dir,$ext);
if ($images) {
// list(,,,$sizestr) = getimagesize($dia);
$table = $GLOBALS["infocaption"]."<br><br><table border=\"0\" cellpadding=\"2\">\r\n<tr>";
$max = count($images)-1;
$end = $start+$maxperpage-1;
$counter = 0;
while (list($key,$image) = each($images)) {
if (($key >= $start) && ($key <= $end)) {
$piclink = $PHP_SELF."".$image;
if ($f) {$piclink .= "&f=1"; }
/*TUTAJ TRZEBA WPISAC ID*/
$id = "ttap";
/*TUTAJ TRZEBA WPISAC ID*/
$biglink = $PHP_SELF."$id.php?cmd=max&start=".$start."&pic=".$image;
$table .= "<td><a href=\"$biglink\"><img src=\"http://meganet.pl/~netbuspl/wap/tap/$piclink\" border=\"0\" $sizestr></a></td>";
$counter++;
if (((($counter) % $cols) == 0) && ($key < $end)) {
$table .= "</tr><tr>";
}
}
}
$table .= "</tr></table><br>";
if ($start > 0) {
$prevstart = $start - $maxperpage;
$table .= "<a href=\"$selflink?id=$id&start=$prevstart\">".$GLOBALS["prevcaption"]."</a> ";
}
if ($end < $max) {
$nextstart = $end+1;
$table .= " <a href=\"$selflink?id=$id&start=$nextstart\">".$GLOBALS["nextcaption"]."</a>";
}
} else {
$table = "No files in <b>$dir</b>";
}
$line = str_replace("###pictable###",$table,$line);
return $line;
}
function image_print($pic,$template,$start) {
$lines = file($template);
$line = implode("",$lines);
$selflink = $GLOBALS["PHP_SELF"];
list(,,,$sizestr) = getimagesize($pic);
require("tban.php");
$piclink = "$banner<br><br><br><img src=\"http://serwer.pl/tap/$pic\" border=\"0\"><br><br>";
$pica=$pic;
$pica=str_replace("../wap/tap/","",$pica);
$pica=str_replace(".gif","",$pica);
$piclink .= "</p>";
$line = str_replace("###pictable###",$piclink,$line);
return $line;
}
function main($cmd,$dir,$pic,$dia,$template,$cols,$s,$f,$mdir,$maxperpage,$start,$ext=".png") {
switch ($cmd) {
case "min" :
thumb_print($dir,$pic,$dia,$s,$f,$mdir);
break;
case "max" :
echo image_print($dir.$pic,$template,$start);
break;
default :
echo index_print($dir,$ext,$template,$dia,$cols,$f,$maxperpage,$start);
}
}
main($cmd,$img_dir,$pic,$borderpic,$templatefile,$columns,$save,$f,$thumbs_dir,$maxperpage,$start,$ext_pattern);