Code: Select all
$files = glob($dir . 'Docs/files/*');Moderator: General Moderators
Code: Select all
$files = glob($dir . 'Docs/files/*');Code: Select all
function toArray(&$item, $key)
{
$item = array($item => filemtime($item));
}
array_walk($files, 'toArray');Thanks Jcart, that's what i was looking for. When i included that code into my script, the following error is returned:Jcart wrote:Code: Select all
function toArray(&$item, $key) { $item = array($item => filemtime($item)); } array_walk($files, 'toArray');
That could convert all your filesnames to an array with their filemtime(), I believe that is what your after?
Code: Select all
Warning: basename() expects parameter 1 to be string, array given in /host/localhost/htdocs/dir/index.php on line 55Code: Select all
<?php
echo "<table width=\"100%\" border=\"0\" cellspacing=\"1\" cellpadding=\"0\">";
$location = "Docs/files/";
$thispage = "modules.php?name=Dir&file=index&";
$dir = getcwd().'/';
$difference = 30;
$start = isset($_GET['start']) ? (int)$_GET['start'] : 0;
$end = isset($_GET['end']) ? (int)$_GET['end'] : 0;
if($end <= $start) {
$end = $start+30;
}
function smart_filemtime($filename) {
$time = @filemtime($filename);
if ($time) return $time;
else return time();
}
if (is_dir($dir)) {
$i = 1;
$files = glob($dir . 'Docs/files/*');
function toArray(&$item, $key)
{
$item = array($item => filemtime($item));
}
array_walk($files, 'toArray');
foreach ($files as $path) {
$filename = basename($path);
if($i >= $start && $i != $end ) {
echo "<tr style='border:1px solid #cfcfcf;background:#fcfcfc; cursor:hand\' onMouseOver=\"this.style.background='#EEEEEE'\" onMouseOut=\"this.style.background='#FFFFFF'\" onClick=\"window.location.href='modules.php?name=Dir&file=file&page=Docs/files/$filename'\">
<td><img src=\"modules/Dir/images/document.jpg\" width=\"16\" height=\"16\" /> <a href=\"modules.php?name=Dir&file=file&page=Docs/files/$filename\">$filename</a>
</td>
<td align=right><a href=\"docs/files/$filename\">Plaintext</a> | <i>$time". date ("F d Y H:i:s.", filemtime($location . $filename));
echo "</i></td>";
}
if($i == $end) break;
$i++;
}
}
$back = (($i-$difference) < 0) ? 0 : ($i-$difference);
$forward = (($i+$difference) > $i) ? $_GET['forward'] : ($i+$difference);
echo "<b><div align=\"right\"><a href=\"\" onclick=\"history.go(-1); return false;\">Back</a>\n";
echo " | ";
echo "<a href='".$thispage."start=".$i."&end=".$i."'>Forward</a></div></b>\n";
echo "</table>";
echo "<b><div align=\"right\"><a href=\"\" onclick=\"history.go(-1); return false;\">Back</a>\n";
echo " | ";
echo "<a href='".$thispage."start=".$i."&end=".$i."'>Forward</a></div><br></b>\n";
?>Code: Select all
$files = glob($dir . 'Docs/files/*');
function toArray(&$item, $key)
{
$item = array($item => filemtime($item));
}
array_walk($files, 'toArray');
foreach ($files as $path) {Code: Select all
$files = glob($dir . 'Docs/files/*');
function toArray(&$item, $key)
{
$item = date("F d Y H:i:s.", filemtime($key));
}
$files = array_flip($files);
array_walk($files, 'toArray');
foreach ($files as $path => $filetime) {Code: Select all
date ("F d Y H:i:s.", filemtime($location . $filename))Code: Select all
$filetimeCode: Select all
<table width='100%' border=0 cellspacing=1 cellpadding=0>
<?php
$location = "Docs/files/";
$thispage = "modules.php?name=Dir&";
$dir = getcwd().'/';
$difference = 30;
$start = isset($_GET['start']) ? (int)$_GET['start'] : 0;
$end = isset($_GET['end']) ? (int)$_GET['end'] : 0;
if($end <= $start) {
$end = $start+30;
}
function smart_filemtime($filename) {
$time = @filemtime($filename);
if ($time) return $time;
else return time();
}
if (is_dir($dir)) {
$i = 1;
$files = glob($dir . 'Docs/files/*');
function toArray(&$item, $key)
{
$item = date("F d Y H:i:s.", filemtime($key));
}
$files = array_flip($files);
array_walk($files, 'toArray');
foreach ($files as $path => $filetime) {
$filename = basename($path);
if($i >= $start && $i != $end ) {
echo "<tr style='border:1px solid #cfcfcf;background:#fcfcfc; cursor:hand\' onMouseOver=\"this.style.background='#EEEEEE'\" onMouseOut=\"this.style.background='#FFFFFF'\" onClick=\"window.location.href='modules.php?name=Dir&file=file&page=Docs/files/$filename'\">
<td><a href=\"modules.php?name=Dir&file=file&page=Docs/files/$filename\">$filename</a>
</td>
<td align=right><a href=\"Docs/files/$filename\">Plaintext</a> | <i>$time". $filetime;
echo "</i></td>";
}
if($i == $end) break;
$i++;
}
}
$back = (($i-$difference) < 0) ? 0 : ($i-$difference);
$forward = (($i+$difference) > $i) ? $_GET['forward'] : ($i+$difference);
echo "<b><div align=\"right\"><a href=\"\" onclick=\"history.go(-1); return false;\">Back</a>\n";
echo " | ";
echo "<a href='".$thispage."start=".$i."&end=".$i."'>Forward</a></div></b>\n";
?>
</table>I was thinking...Jcart wrote:arsort()
Code: Select all
foreach($files as $file)
{
$file_array["name"][] = $file;
$file_array["date"][] = filemtime($file);
}
asort($file_array, SORT_NUMERIC);Code: Select all
location = "Docs/files/";
$thispage = "modules.php?name=Dir&file=indexxx2&";
$dir = getcwd().'/';
$difference = 30;
$start = isset($_GET['start']) ? (int)$_GET['start'] : 0;
$end = isset($_GET['end']) ? (int)$_GET['end'] : 0;
if($end <= $start) {
$end = $start+30;
}
function smart_filemtime($filename) {
$time = @filemtime($filename);
if ($time) return $time;
else return time();
}
if (is_dir($dir))
{
$i = 1;
$files = glob($dir . 'Docs/files/*');
foreach($files as $file)
{
$file_array[]["name"] = basename($file);
$file_array[]["date"] = filemtime($file);
}
asort($file_array, SORT_NUMERIC);
foreach ($file_array as $file_info)
{
if($i >= $start && $i != $end )
{
echo "<tr style='border:1px solid #cfcfcf;background:#fcfcfc; cursor:hand\' onMouseOver="this.style.background='#EEEEEE'" onMouseOut="this.style.background='#FFFFFF'" onClick="window.location.href='modules.php?name=Dir&file=file&page=vuns/files/".$file_info["name"]."'">
<td><a href="modules.php?name=Dir&file=file&page=Docs/files/".$file_info["name"]."">".$file_info["name"]."</a>
</td>
<td align=right><a href="Docs/files/".$file_info["name"]."">Plaintext</a> | <i>".$time.date ("F d Y H:i:s.", $file_info[date]);
echo "</i></td>";
}
if($i == $end) break;
$i++;
}
}
$back = (($i-$difference) < 0) ? 0 : ($i-$difference);
$forward = (($i+$difference) > $i) ? $_GET['forward'] : ($i+$difference);
echo "<b><div align="right"><a href="" onclick="history.go(-1); return false;">Back</a>\n";
echo " | ";
echo "<a href='".$thispage."start=".$i."&end=".$i."'>Forward</a></div></b>\n";April 01 2006 17:21:12.
December 31 1969 19:00:00.
April 01 2006 17:21:11.
April 01 2006 17:21:23.
December 31 1969 19:00:00.
April 01 2006 17:21:36.
December 31 1969 19:00:00.
December 31 1969 19:00:00.
April 01 2006 17:21:36.
December 31 1969 19:00:00.
April 01 2006 17:21:39