473,695 Members | 2,824 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

How to order by date desc... onload ...

30 New Member
[code=php]<?
/*
Directory Listing Script - Version 2
=============== =============== ======
Script Author: Artani <artan_p@msn.co m>. www.artxcenter.com


REQUIREMENTS
============
This script requires PHP and GD2 if you wish to use the
thumbnail functionality.

INSTRUCTIONS
============
1) Unzip all files
2) Edit this file, making sure everything is setup as required.
3) Upload to server
4) ??????
5) Profit!

CONFIGURATION
=============
Edit the variables in this section to make the script work as
you require.

Start Directory - To list the files contained within the current
directory enter '.', otherwise enter the path to the directory
you wish to list. The path must be relative to the current
directory.
*/
$startdir = '.';

/*
Show Thumbnails? - Set to true if you wish to use the
scripts auto-thumbnail generation capabilities.
This requires that GD2 is installed.
*/
$showthumbnails = true;

/*
Show Directories - Do you want to make subdirectories available?
If not set this to false
*/
$showdirs = true;

/*
Force downloads - Do you want to force people to download the files
rather than viewing them in their browser?
*/
$forcedownloads = false;

/*
Hide Files - If you wish to hide certain files or directories
then enter their details here. The values entered are matched
against the file/directory names. If any part of the name
matches what is entered below then it is now shown.
*/
$hide = array(
'dlf',
'index.php',
'Thumbs',
'.htaccess',
'.htpasswd'
);

/*
Show index files - if an index file is found in a directory
to you want to display that rather than the listing output
from this script?
*/
$displayindex = false;

/*
Allow uploads? - If enabled users will be able to upload
files to any viewable directory. You should really only enable
this if the area this script is in is already password protected.
*/
$allowuploads = false;

/*
Overwrite files - If a user uploads a file with the same
name as an existing file do you want the existing file
to be overwritten?
*/
$overwrite = false;

/*
Index files - The follow array contains all the index files
that will be used if $displayindex (above) is set to true.
Feel free to add, delete or alter these
*/

$indexfiles = array (
'index.html',
'index.htm',
'default.htm',
'default.html'
);

/*
File Icons - If you want to add your own special file icons use
this section below. Each entry relates to the extension of the
given file, in the form <extension> => <filename>.
These files must be located within the dlf directory.
*/
$filetypes = array (
'png' => 'jpg.gif',
'jpeg' => 'jpg.gif',
'bmp' => 'jpg.gif',
'jpg' => 'jpg.gif',
'gif' => 'gif.gif',
'zip' => 'archive.png',
'rar' => 'archive.png',
'exe' => 'exe.gif',
'setup' => 'setup.gif',
'txt' => 'text.png',
'htm' => 'html.gif',
'html' => 'html.gif',
'fla' => 'fla.gif',
'swf' => 'swf.gif',
'xls' => 'xls.gif',
'doc' => 'doc.gif',
'sig' => 'sig.gif',
'fh10' => 'fh10.gif',
'pdf' => 'pdf.gif',
'psd' => 'psd.gif',
'rm' => 'real.gif',
'mpg' => 'video.gif',
'mpeg' => 'video.gif',
'mov' => 'video2.gif',
'avi' => 'video.gif',
'eps' => 'eps.gif',
'gz' => 'archive.png',
'asc' => 'sig.gif',
'mp3' => 'mp3.png',
);

/*
That's it! You are now ready to upload this script to the server.

Only edit what is below this line if you are sure that you know what you
are doing!
*/
error_reporting (0);
if(!function_ex ists('imagecrea tetruecolor')) $showthumbnails = false;
$leadon = $startdir;
if($leadon=='.' ) $leadon = '';
if((substr($lea don, -1, 1)!='/') && $leadon!='') $leadon = $leadon . '/';
$startdir = $leadon;

if($_GET['dir']) {
//check this is okay.

if(substr($_GET['dir'], -1, 1)!='/') {
$_GET['dir'] = $_GET['dir'] . '/';
}

$dirok = true;
$dirnames = split('/', $_GET['dir']);
for($di=0; $di<sizeof($dir names); $di++) {

if($di<(sizeof( $dirnames)-2)) {
$dotdotdir = $dotdotdir . $dirnames[$di] . '/';
}

if($dirnames[$di] == 'Kthehu ') {
$dirok = false;
}
}

if(substr($_GET['dir'], 0, 1)=='/') {
$dirok = false;
}

if($dirok) {
$leadon = $leadon . $_GET['dir'];
}
}

if($_GET['download'] && $forcedownloads ) {
$file = str_replace('/', '', $_GET['download']);
$file = str_replace('.. ', '', $file);

if(file_exists( $leadon . $file)) {
header("Content-type: application/x-download");
header("Content-Length: ".filesize($lea don . $file));
header('Content-Disposition: attachment; filename="'.$fi le.'"');
readfile($leado n . $file);
die();
}
}

if($allowupload s && $_FILES['file']) {
$upload = true;
if(!$overwrite) {
if(file_exists( $leadon.$_FILES['file']['name'])) {
$upload = false;
}
}

if($upload) {
move_uploaded_f ile($_FILES['file']['tmp_name'], $leadon . $_FILES['file']['name']);
}
}

$opendir = $leadon;
if(!$leadon) $opendir = '.';
if(!file_exists ($opendir)) {
$opendir = '.';
$leadon = $startdir;
}

clearstatcache( );
if ($handle = opendir($opendi r)) {
while (false !== ($file = readdir($handle ))) {
//first see if this file is required in the listing
if ($file == "." || $file == "..") continue;
$discard = false;
for($hi=0;$hi<s izeof($hide);$h i++) {
if(strpos($file , $hide[$hi])!==false) {
$discard = true;
}
}

if($discard) continue;
if (@filetype($lea don.$file) == "dir") {
if(!$showdirs) continue;

$n++;
if($_GET['sort']=="date") {
$key = @filemtime($lea don.$file) . ".$n";
}
else {
$key = $n;
}
$dirs[$key] = $file . "/";
}
else {
$n++;
if($_GET['sort']=="date") {
$key = @filemtime($lea don.$file) . ".$n";
}
elseif($_GET['sort']=="size") {
$key = @filesize($lead on.$file) . ".$n";
}
else {
$key = $n;
}
$files[$key] = $file;

if($displayinde x) {
if(in_array(str tolower($file), $indexfiles)) {
header("Locatio n: $file");
die();
}
}
}
}
closedir($handl e);
}

//sort our files
if($_GET['sort']=="date") {
@ksort($dirs, SORT_NUMERIC);
@ksort($files, SORT_NUMERIC);
}
elseif($_GET['sort']=="size") {
@natcasesort($d irs);
@ksort($files, SORT_NUMERIC);
}
else {
@natcasesort($d irs);
@natcasesort($f iles);
}

//order correctly
if($_GET['order']=="desc" && $_GET['sort']!="size") {$dirs = @array_reverse( $dirs);}
if($_GET['order']=="desc") {$files = @array_reverse( $files);}
$dirs = @array_values($ dirs); $files = @array_values($ files);


?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dt d">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Muzikė pėr dėshirėn tuaj... <?=dirname($_SE RVER['PHP_SELF']).'/'.$leadon;?></title>
<link rel="stylesheet " type="text/css" href="dlf/styles.css" />
<?
if($showthumbna ils) {
?>
<script language="javas cript" type="text/javascript">
<!--
function o(n, i) {
document.images['thumb'+n].src = 'dlf/i.php?f='+i;

}

function f(n) {
document.images['thumb'+n].src = 'dlf/trans.gif';
}
//-->
</script>
<?
}
?>
</head>
<body>
<div id="container" >
<h1>Ju d&euml;shiroj mė arg&euml;tim t&euml; k&euml;ndsh&eum l;m...</h1>
<div id="breadcrumbs "> <a href="<?=$_SERV ER['PHP_SELF'];?>">Muzik&euml ;</a>
<?
$breadcrumbs = split('/', $leadon);
if(($bsize = sizeof($breadcr umbs))>0) {
$sofar = '';
for($bi=0;$bi<( $bsize-1);$bi++) {
$sofar = $sofar . $breadcrumbs[$bi] . '/';
echo ' &gt; <a href="'.$_SERVE R['PHP_SELF'].'?dir='.urlenc ode($sofar).'"> '.$breadcrumbs[$bi].'</a>';
}
}

$baseurl = $_SERVER['PHP_SELF'] . '?dir='.$_GET['date'] . '&amp;';
$dateurl = 'sort=date&amp; order=asc';
$fileurl = 'sort=name&amp; order=asc';
$sizeurl = 'sort=size&amp; order=asc';


switch ($_GET['sort']) {
case 'name':
if($_GET['order']=='asc') $fileurl = 'sort=name&amp; order=desc';
break;
case 'size':
if($_GET['order']=='asc') $sizeurl = 'sort=size&amp; order=desc';
break;

case 'date':
if($_GET['order']=='asc') $dateurl = 'sort=date&amp; order=desc';
break;
default:
$fileurl = 'sort=date&amp; order=desc';
break;
}
?>
</div>
<div id="listingcont ainer">
<div id="listinghead er">
<div id="headerfile" ><a href="<?=$baseu rl . $fileurl;?>">Sk edarėt</a></div>
<div id="headersize" ><a href="<?=$baseu rl . $sizeurl;?>"> &nbsp;&nbsp;&nb sp;&nbsp;&nbsp; &nbsp;&nbsp;&nb sp;&nbsp;&nbsp; &nbsp;&nbsp;&nb sp;&nbsp;&nbsp; &nbsp;&nbsp;Mad h&euml;sia</a></div>
<div id="headermodif ied"><a href="<?=$baseu rl . $dateurl;?>">Mo difikimi i fundit</a></div>
</div>
<div id="listing">
<?
$class = 'b';
if($dirok) {
?>
<div><a href="<?=$_SERV ER['PHP_SELF'].'?dir='.urlenc ode($dotdotdir) ;?>" class="<?=$clas s;?>"><img src="dlf/dirup.png" alt="Folder" /><strong>Kthehu ...</strong> <em>-</em><?=date ("M d Y h:i:s A", filemtime($dotd otdir));?></a></div>
<?
if($class=='b') $class='w';
else $class = 'b';
}
$arsize = sizeof($dirs);
for($i=0;$i<$ar size;$i++) {
?>
<div>
<div align="center"> <a href="<?=$_SERV ER['PHP_SELF'].'?dir='.urlenc ode($leadon.$di rs[$i]);?>" class="<?=$clas s;?>"><img src="dlf/folder.png" alt="<?=$dirs[$i];?>" /><strong>
<?=$dirs[$i];?>
</strong> <em>-</em>
<?=date ("M d Y h:i:s A", filemtime($lead on.$dirs[$i]));?>
</a></div>
</div>
<?
if($class=='b') $class='w';
else $class = 'b';
}

$arsize = sizeof($files);
for($i=0;$i<$ar size;$i++) {
$icon = 'unknown.png';
$ext = strtolower(subs tr($files[$i], strrpos($files[$i], '.')+1));
$supportedimage s = array('gif', 'png', 'jpeg', 'jpg');
$thumb = '';

if($showthumbna ils && in_array($ext, $supportedimage s)) {
$thumb = '<span><img src="dlf/trans.gif" alt="'.$files[$i].'" name="thumb'.$i .'" /></span>';
$thumb2 = ' onmouseover="o( '.$i.', \''.urlencode($ leadon . $files[$i]).'\');" onmouseout="f(' .$i.');"';

}

if($filetypes[$ext]) {
$icon = $filetypes[$ext];
}

$filename = $files[$i];
if(strlen($file name)>43) {
$filename = substr($files[$i], 0, 40) . '...';
}

$fileurl = $leadon . $files[$i];
if($forcedownlo ads) {
$fileurl = $_SESSION['PHP_SELF'] . '?dir=' . urlencode($lead on) . '&download=' . urlencode($file s[$i]);
}

?>
<div><a href="<?=$fileu rl;?>" class="<?=$clas s;?>"<?=$thumb2 ;?>><img src="dlf/<?=$icon;?>" alt="<?=$files[$i];?>" /><strong><?=$fi lename;?></strong> <em><?=round(fi lesize($leadon. $files[$i])/1024);?>KB</em> <?=date ("M d Y h:i:s A", filemtime($lead on.$files[$i]));?><?=$thumb; ?></a></div>
<?
if($class=='b') $class='w';
else $class = 'b';
}
?></div>
<?
if($allowupload s) {
$phpallowupload s = (bool) ini_get('file_u ploads');
$phpmaxsize = ini_get('upload _max_filesize') ;
$phpmaxsize = trim($phpmaxsiz e);
$last = strtolower($php maxsize{strlen( $phpmaxsize)-1});
switch($last) {
case 'g':
$phpmaxsize *= 1024;
case 'm':
$phpmaxsize *= 1024;
}

?>
<div id="upload">
<div id="uploadtitle "><strong>F ile Upload</strong> (Max Filesize: <?=$phpmaxsize; ?>KB)</div>
<div id="uploadconte nt">
<?
if($phpallowupl oads) {
?>
<form method="post" action="<?=$_SE RVER['PHP_SELF'];?>?dir=<?=urle ncode($leadon); ?>" enctype="multip art/form-data">
<input type="file" name="file" /> <input type="submit" value="Upload" />
</form>
<?
}
else {
?>
File uploads are disabled in your php.ini file. Please enable them.
<?
}
?>
</div>

</div>
<?
}
?>
</div>
</div>
<div id="copy">Copyr ight &copy; 2007 aRTx &nbsp;&nbsp;&nb sp;&nbsp;&nbsp; &nbsp; Design by: <a href="http://www.artxcenter. com" target="_blank" >aRTxCenter.com </a>. </div>
</body>
</html>[/copy]

How to order by date desc... when it loaded...
Jun 16 '07 #1
1 4142
epots9
1,351 Recognized Expert Top Contributor
i guess your connecting to a database, so in your query y don't u just again "ORDER BY date DESC;"
Jun 16 '07 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

2
1477
by: Neal | last post by:
I just made a table sortable by column headers by reading a thread posted here a while ago. Here is the code simplified: $sort_order = 'id'; if($order == 'jobtitle'){ $sort_order = 'jobtitle'; }else if($order == 'district'){ $sort_order = 'district'; } else if($order == 'date'){
4
6173
by: Bryan Harrington | last post by:
Can you use Select top 40 * from ... and ORDER BY... in the same query? I have the following 4 quearies that are.. for the most part, the same except the order by clause, all return a differnt amount of records. Thoughts? select top 40 * from q_work_list where assigned_to = 10 order by batch_date, remit_amt desc 40 records returned.
7
2746
by: JJ_377 | last post by:
Can someone tell me why SQL seems to ignore my order by clause? I tried to run through the debugger, but the debugger stops at the select statement line and then returns the result set; so, I have no idea how it is evaluating the order by clause. THANK YOU! CREATE proc sprAllBooks @SortAscend varchar(4), @SortColumn varchar(10)
2
1318
by: arthur-e | last post by:
I use a combobox to limit the records shown on a form with an event procedure: Private Sub Combo2684_AfterUpdate() If Me! = "<All>" Then DoCmd.ShowAllRecords Else DoCmd.ApplyFilter , " = Forms!!" End If
2
1227
by: Miguel Dias Moura | last post by:
Hello, i have this SQL code in my dataSet (I am working in ASP.Net / VB): SELECT Author, COUNT(Author) AS totalDocuments FROM documents GROUP BY Author ORDER BY COUNT(Author) DESC What i want to do is this:
1
1831
by: Ike | last post by:
If I have a GROUP BY statement, which groups my multiple fields, e.g.: SELECT ......GROUP BY date, store can I have multiple ORDER BY statements with that? e.g.: SELECT ......GROUP BY date, store ORDER BY date asc, store, desc Is this an acceptable syntax? Thanks, Ike
5
9985
by: Nick Weisser | last post by:
Hi there, I'm not sure how to select the last 3 items in ascending order. This does the trick in descending order: select * from user_menu_main where deleted = 0 and hidden = 0 order by date desc limit 3
0
1336
by: Burnie | last post by:
Hi, I'm wanting to order the date on a website that I'm putting together. www.onesmallstep.tv Currently I'm using the following: $query = "SELECT DATE_FORMAT(Date, '%Y.%m.%d') as Date, Story FROM News
11
9687
by: Israel | last post by:
I've trying to write a query that seems like it should be simple but for some reason my attempts are not working. This is really a general SQL quesion and doesn't pertain to MySQL but I couldn't find a generic database discussion group except on on advancement and theory and this is really a basic query construction question. Just say I have a table with three columns, name, date, score and these represent the test scores for various...
0
8640
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8582
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9001
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8860
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
7672
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6498
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5841
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4348
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
3
1984
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.