Salve, vorrei modificare questo script che vi allego ..
vorrei di dirgli di non andare in su..esempio:
.. <-- qua non ci deve andare..
/
pages
template
css
vi posto il codice:
lo preso da qua: http://tomicki.net/dir.php
Mi date una mano per risolvere il piccolo problema?
grazie mille.
vorrei di dirgli di non andare in su..esempio:
.. <-- qua non ci deve andare..
/
pages
template
css
vi posto il codice:
lo preso da qua: http://tomicki.net/dir.php
PHP:
<?php
/* */
/* File: dir.php */
/* (c) 2004 by £ukasz Tomicki <tomicki(at)o2(dot)pl> */
/* Most recent version available @ : http://tomicki.net/ */
/* Version: 0.8 */
/*
/* This program is free software; you can redistribute it and/or modify
/* it under the terms of the GNU General Public License as published by
/* the Free Software Foundation; either version 2 of the License, or
/* (at your option) any later version.
/*
/* This program is distributed in the hope that it will be useful,
/* but WITHOUT ANY WARRANTY; without even the implied warranty of
/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
/* GNU Library General Public License for more details.
/*
/* You should have received a copy of the GNU General Public License
/* along with this program; if not, write to the Free Software
/* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
/* */
?>
<style TYPE="text/css">
<!--
* { font-family: courier new; font-size: 10pt;
}
A { text-decoration: none;
}
A:HOVER { text-decoration: underline;
}
-->
</style>
<pre>
<?php
function sortRows($data)
{
$size = count($data);
for ($i = 0; $i < $size; ++$i) {
$row_num = findSmallest($i, $size, $data);
$tmp = $data[$row_num];
$data[$row_num] = $data[$i];
$data[$i] = $tmp;
}
return ( $data );
}
function findSmallest($i, $end, $data)
{
$min['pos'] = $i;
$min['value'] = $data[$i]['data'];
$min['dir'] = $data[$i]['dir'];
for (; $i < $end; ++$i) {
if ($data[$i]['dir']) {
if ($min['dir']) {
if ($data[$i]['data'] < $min['value']) {
$min['value'] = $data[$i]['data'];
$min['dir'] = $data[$i]['dir'];
$min['pos'] = $i;
}
} else {
$min['value'] = $data[$i]['data'];
$min['dir'] = $data[$i]['dir'];
$min['pos'] = $i;
}
} else {
if (!$min['dir'] && $data[$i]['data'] < $min['value']) {
$min['value'] = $data[$i]['data'];
$min['dir'] = $data[$i]['dir'];
$min['pos'] = $i;
}
}
}
return ( $min['pos'] );
}
$self = $_SERVER['PHP_SELF'];
if (isset($_GET['dir'])) {
$dir = $_GET['dir'];
$size = strlen($dir);
while ($dir[$size - 1] == '/') {
$dir = substr($dir, 0, $size - 1);
$size = strlen($dir);
}
} else {
$dir = $_SERVER["SCRIPT_FILENAME"];
$size = strlen($dir);
while ($dir[$size - 1] != '/') {
$dir = substr($dir, 0, $size - 1);
$size = strlen($dir);
}
$dir = substr($dir, 0, $size - 1);
}
echo "DIR : ", $dir;
echo "\n\n";
if (is_dir($dir)) {
if ($handle = opendir($dir)) {
$size_document_root = strlen($_SERVER['DOCUMENT_ROOT']);
$pos = strrpos($dir, "/");
$topdir = substr($dir, 0, $pos + 1);
$i = 0;
while (false !== ($file = readdir($handle))) {
if ($file != "." && $file != "..") {
$rows[$i]['data'] = $file;
$rows[$i]['dir'] = is_dir($dir . "/" . $file);
$i++;
}
}
closedir($handle);
}
$size = count($rows);
$rows = sortRows($rows);
echo "<table style=\"white-space:pre;\">";
echo "<tr>";
echo "<td>[UP]";
echo "</td>";
echo "<td> ";
echo "<a href='", $self, "?dir=", $topdir, "'>..</a>\n";
echo "</td>";
echo "<td>size (bytes)";
echo "</td>";
echo "<td> ";
echo "</td>";
echo "</tr>";
for ($i = 0; $i < $size; ++$i) {
$topdir = $dir . "/" . $rows[$i]['data'];
echo "<tr>";
echo "<td>";
if ($rows[$i]['dir']) {
echo "[DIR]";
$file_type = "dir";
} else {
echo "[FILE]";
$file_type = "file";
}
echo "</td>";
echo "<td> ";
echo "<a href='", $self, "?dir=", $topdir, "'>", $rows[$i]['data'], "</a>\n";
echo "</td>";
echo "<td>";
echo filesize($topdir);
echo "</td>";
echo "<td> ";
echo "<a href='", substr($topdir, $size_document_root, strlen($topdir) - $size_document_root), "'>open ", $file_type, "</a>\n";
echo "</td>";
echo "</tr>";
}
echo "</table>";
} else if (is_file($dir)) {
$pos = strrpos($dir, "/");
$topdir = substr($dir, 0, $pos);
echo "<a href='", $self, "?dir=", $topdir, "'>", $topdir, "</a>\n\n";
$file = file($dir);
$size = count($file);
for ($i = 0; $i < $size; ++$i)
echo htmlentities($file[$i], ENT_QUOTES);
} else {
echo "bad file or unable to open";
}
?>
</pre>
grazie mille.