<?php
Error_Reporting(E_ALL& ~E_NOTICE);
header("Chace-Control: no-chace");
header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");
header("Last-Modified: " . gmdate("D, dMYH:i:s") . " GMT");
header("Content-Type: text/html; charset=utf-8");
echo '<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">';
$displaylist = "bmp jpg gif jpeg png bmp";
$fpp = "5"; // files per page
$linkbackURL = "index.php";
$linkbackNAME = "Quay lại";
include("../../header.php");
echo '<html><head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<style type="text/css">a.pagenav {
border: 1px solid #c0c0d5;
padding: 0px 3px 0px 3px;
text-decoration: none;
}
a.pagenav:hover {
background-color: #f7f7f7;
border: 1px solid #dedede;
</style>
</head>
<div class=quang><center><b><small>Danh sách hình ảnh</b></center></div>';
if ((!$sortorder1) && (!$sortorder2)){
$sortorder = "Alphabetical";
$so = "&so=Alphabetical";
}
# Get current page to be displayed.
#----------------------------------
if ($pagego == "")
{
$currentpage = $_GET["page"];
if ($currentpage < 1 | $currentpage == "")
{
$currentpage = 1;
}
}
else
{
$currentpage = "$pagego";
}
# If no records per page is selected, set the default.
#-----------------------------------------------------
if ($rpp == "") $rpp = "$fpp";
if ((!$rpp1) && (!$rpp2)){
$records_per_page = $rpp;
$rpp3 = "&rpp=$records_per_page";
}
$pmax = "$rpp";
# Read current directory.
#------------------------
$d = dir(".");
while (false !== ($file = $d->read())) {
# Get all the file attributes.
#-----------------------------
$size = filesize($file);
$type = filetype($file);
$ext = strrchr($file,'.');
$modified = stat("$file");
$displayname = str_replace (strrchr ($file, "."), "", $file);
$display_list = "$displaylist";
if (($type == file) && (preg_match ("/$ext/i", $display_list))) {
# Format the Dispayed filename.. replace underscore with a space
# and Change each word to start with an upper case letter.
#---------------------------------------------------------------
$displayname = str_replace("_"," ",$displayname);
$displayname = strtolower($displayname);
$displayname = ucwords($displayname);
$filedate = date("m-d-y",$modified[9]);
# Format the output depending on sort order and search criteria.
#---------------------------------------------------------------
if ((!$search) && ($sortorder == "Alphabetical")){
$filename[$totalfiles] = "$displayname|$displayname|$file|$ext|$size|$filedate|$content|$upload_date";
}
$totalbytes = $totalbytes + $size;
$totalfiles++;
}
}
# Sort by filename.
#------------------
if (($filename) && ($sortorder == "Alphabetical")){
sort ($filename,SORT_REGULAR);
reset ($filename);
$select1 = "selected";
$select2 = "";
$select3 = "";
$select4 = "";
$match = 1;
}
# Pagination Start.
#------------------
if ($records_per_page < 1){
$records_per_page = $totalfiles + 1;
}
If ($totalfiles > $records_per_page){
$totalpages = ceil($totalfiles/$records_per_page);
$flag = 0;
if ($currentpage > $totalpages){
$currentpage = 1;
}
}ELSE{
$flag = 1;
}
# Print out the top of the form and search criteria boxes.
#---------------------------------------------------------
?>
<?
# Start main loop.
#-----------------
if ($match > 0){
while (list ($key, $val) = each ($filename)) {
if ($key >= ($records_per_page-$records_per_page)+(($currentpage-1)*$records_per_page) && $key <= ($records_per_page-1)+(($currentpage-1)*$records_per_page)){
$fileattr = explode("|", $val);
# Fix and format Byte Length
#---------------------------
if ($fileattr[4] < pow(2,10)){
$size = "$fileattr[4]B";
}
if ($fileattr[4] >= pow(2,10) && $fileattr[4] < pow(2,20)) {
$size = round($fileattr[4] / pow(2,10), 2)."KB";
}
if ($fileattr[4] >= pow(2,20) && $fileattr[4] < pow(2,30)) {
$size = round($fileattr[4] / pow(2,20), 2)."MB";
}
if ($fileattr[3] > pow(2,30)) {
$size = round($fileattr[4] / pow(2,30), 2)."GB";
}
$thisfile = "$fileattr[2]";
$thatfile = str_replace(".jpg","","$thisfile");
print "<div class=cool><img border=\"2\"src=\"./$thisfile\"height=\"62\"weight=\"110\"></img></div><div class=cool>Kích cỡ : $size</div><div class=cool><a href=\"./$thisfile\"><small>Tải về Hình ảnh</small></a></div>";
}
}
}
#-------------------------------------------------------------------------------------
# End main loop.
# Generate page number links.
#----------------------------
if ($flag == 0){
$previouspage = $currentpage-1;
if ($previouspage < 1){
$previouspage = 1;
}
$nextpage = $currentpage+1;
if ($nextpage > $totalpages){
$nextpage = $totalpages;
}
if ($currentpage > 1) print "<a class=\"ads\" href=\"./index.php?page=$previouspage&rpp=$rpp&so=alphabetical&act=$act&stringy=$stringy&ses=$ses\"><b>«</a></b>";
for($lui=$previouspage-5;$lui<=$previouspage;$lui++)if($lui>0)echo "<a class=\"pagenav\" href='index.php?page=$lui'> $lui </a>";
for($tien=$nextpage;$tien<$nextpage+5;$tien++)if($tien<=$totalpages) echo "<a class=\"ads\" href='index.php?page=$tien'> $tien </a>";
if ($currentpage != $totalpages ) print "<a class=\"ads\" href=\"./index.php?page=$nextpage&rpp=$rpp&so=alphabetical&act=$act&stringy=$stringy&ses=$ses\"><b>»</b></a></div>";
}
$z = 1;
while ($z <= $totalpages){
if ($z == $currentpage){
$size = $display_selected_size;
}ELSE{
$size = $display_pagination_size;
}
$z++;
}
#----------------------------
if ($totalbytes < pow(2,10)){
$totalsize = "$totalbytes<small>B</small>";
}
if ($totalbytes >= pow(2,10) && $totalbytes < pow(2,20)) {
$totalsize = round($totalbytes / pow(2,10), 0)."<small>KB</small>";
}
if ($totalbytes >= pow(2,20) && $totalbytes < pow(2,30)) {
$totalsize = round($totalbytes / pow(2,20), 0)."<small>MB</small>";
}
echo"<div class=viet>Đi tới:<form action=\"index.php?\" method=\"get\"><input type=\"text\" name=\"page\" size=\"3\" value=\"$nextpage\"><input type=\"submit\" class=\"quang\" value=\"GO\"></form></div>";
echo "</div></div>";
Include("../../footer.php")?>