File: /home/posscale/www/jts/joomla_flist.php
<?php
/**
* Joomla File List Check
* @author Russell Winter
* @copyright GNU/GPL (c) 2006 Bandhosting.nl
* @version 1.0
*
* @version $Id: joomla_flist.php 9 2006-09-16 15:06:10Z RussW $
* @package Joomla! Tools Suite
**/
// No Direct Access, Redirect To Index
if (!defined( '_VALID_JTS' )) {
$host = $_SERVER['HTTP_HOST'];
$uri = rtrim(dirname($_SERVER['PHP_SELF']), '/\\');
header("Location: http://$host$uri/");
exit;
}
define( '_VALID_MOS', 1 );
?>
<div id="ctr" align="center">
<div class="diag">
<div id="step">
</div>
<div class="clr"></div>
<table border='0' width='95%' cellspadding='1' cellspacing='0' align='left' align="center">
<tr>
<td class='advisor' width="170px" height="23px" valign="top">
<?php
echo "<b>". _VERNAME ." ". _FLIS_VERSION ." : ". _LANGUAGE ."</b><br />";
// echo "<b>". _HISA_TRANSLATEDBY.":</b><br />"._HISA_TRANSLATEDWHO ."<br />";
?>
</td>
<td> </td>
<td rowspan="2" width="250px" style="font-size: 9px;" valign="top">
<br /><b><?php echo _REF; ?>:</b><br />
<a href="http://forum.joomla.org/index.php/topic,102558.0.html" target="_new"><?php echo _REF_SECFAQ_URL; ?></a><br />
<a href="http://forum.joomla.org/index.php/topic,81058.0.html" target=_new"><?php echo _REF_SECADM_URL; ?></a><br />
<a href="http://forum.joomla.org/index.php/topic,121470.0.html" target="_new"><?php echo _REF_PERMFAQ_URL; ?></a>
</td>
</tr>
<tr>
<td> </td>
</tr>
</table>
<p>
<br clear=all />
</p>
<h1><?php echo _FLIS_TITLE ; ?></h1>
<div class="form-block">
<?php
$actualPath = dirname(__FILE__) . '/';
$actualPath = str_replace('\\', '/', $actualPath);
$upDir = substr( $actualPath, 0, strrpos( $actualPath, '/') );
$actualPath = substr( $upDir, 0, strrpos( $upDir, '/') );
echo "<table border='0' cellpadding='2' cellspacing='0' width='93%' style='font-size: 11px;'>";
echo "<tr><td><b>". _FLIS_PATH .":</b>". $actualPath ."</td><th colspan='2' align='center' style='border-left: 1px solid #C0C0C0; border-top: 1px solid #C0C0C0; border-right: 1px solid #C0C0C0;' class='vflist'><b>". _FLIS_OWN ."</b></th><td> </td><td> </td><th colspan='3' align='center' style='border-left: 1px solid #C0C0C0; border-top: 1px solid #C0C0C0; border-right: 1px solid #C0C0C0;' class='vflist'><b>". _WEBSVR ."</b></th><td> </td></tr>";
echo "<tr><th style='border-bottom: 1px solid #C0C0C0; border-left: 1px solid #C0C0C0; border-top: 1px solid #C0C0C0;' class='vflist'><b>". _DIR ."</b></th><td align='center' style='border-left: 1px solid #C0C0C0; border-bottom: 1px solid #C0C0C0; border-top: 1px solid #C0C0C0;' width='50' class='Heading'><b>". _FLIS_USR ."</b></td><td align='center' style='border-left: 1px solid #C0C0C0; border-bottom: 1px solid #C0C0C0; border-top: 1px solid #C0C0C0;' width='50' class='Heading'><b>". _FLIS_GRP ."</b></td><td align='center' style='border-left: 1px solid #C0C0C0; border-bottom: 1px solid #C0C0C0; border-top: 1px solid #C0C0C0; border-right: 1px solid #C0C0C0;' width='50' class='Heading'><b>". _MODE ."</b></td><td width='15'> </td><td align='center' style='border-left: 1px solid #C0C0C0; border-bottom: 1px solid #C0C0C0; border-top: 1px solid #C0C0C0;' width='50' class='Heading'><b>". _FLIS_USR ."</b></td><td align='center' style='border-left: 1px solid #C0C0C0; border-bottom: 1px solid #C0C0C0; border-top: 1px solid #C0C0C0;' width='50' class='Heading'><b>". _FLIS_GRP ."</b></td><td align='center' style='border: 1px solid #C0C0C0;' width='50' class='Heading'><b>". _WRITE ."</b></td></tr>";
$dir = ".";
$directories = array();
$files = array();
function recursedir($rootdir){
$directories = array();
$files = array();
$dir = (substr($rootdir, -1) == '/') ? substr($rootdir, 0, -1) : $rootdir;
if(is_dir($dir)){
if($handle = @opendir($dir)){
while(false !== ($file = readdir($handle))){
if($file != "." && $file != ".." && $file !="jts" && $file !=(substr($file, strlen($file) - 4) == '.png') && $file !=(substr($file, strlen($file) - 4) == '.gif') && $file !=(substr($file, strlen($file) - 4) == '.jpg')){
$filename = $dir.'/'.$file;
if(is_dir($filename)){
$folder = $filename;
$files = array_merge($files, recursedir($filename));
echo "<tr>";
if (substr(sprintf('%o', @fileperms($folder)), -1) == '7') {
echo "<td bgcolor='yellow' style='border-bottom: 1px solid #C0C0C0; border-left: 1px solid #C0C0C0;'><font color='red'>". $folder."</font></td>";
} else {
echo "<td style='border-bottom: 1px solid #C0C0C0; border-left: 1px solid #C0C0C0;'>". $folder."</td>";
}
echo "<td align='center' style='border-bottom: 1px solid #C0C0C0; border-left: 1px solid #C0C0C0;'>". fileowner("$folder") ."</td>";
echo "<td align='center' style='border-bottom: 1px solid #C0C0C0; border-left: 1px solid #C0C0C0;'>". filegroup("$folder") ."</td>";
if (substr(sprintf('%o', @fileperms($folder)), -1) == '7') {
echo "<td align='center' bgcolor='yellow' style='border-bottom: 1px solid #C0C0C0; border-left: 1px solid #C0C0C0; border-right: 1px solid #C0C0C0;'><font color='red'>";
} elseif (substr(sprintf('%o', @fileperms($folder)), -1) <= '4') {
echo "<td align='center' style='border-bottom: 1px solid #C0C0C0; border-left: 1px solid #C0C0C0; border-right: 1px solid #C0C0C0;'><font color='blue'>";
} else {
echo "<td align='center' style='border-bottom: 1px solid #C0C0C0; border-left: 1px solid #C0C0C0; border-right: 1px solid #C0C0C0;'><font color='green'>";
}
echo "". substr(sprintf('%o', @fileperms($folder)), -4) ."";
echo '</font>';
echo "</td>";
echo "<td> </td>";
/// $writeable = '<font color="blue">'. _WRITE .'</font>';
/// $unwriteable = '<font color="green">'. _NOWRITE .'</font>';
///
/// echo "<td align='center' style='border-bottom: 1px solid #C0C0C0; border-left: 1px solid #C0C0C0;'>";
/// echo is_writable( $folder ) ? $writeable : $unwriteable;
/// echo "</td>";
echo "<td align='center' style='border-bottom: 1px solid #C0C0C0; border-left: 1px solid #C0C0C0;'>". getmyuid() ."</td>";
echo "<td align='center' style='border-bottom: 1px solid #C0C0C0; border-left: 1px solid #C0C0C0; border-right: 1px solid #C0C0C0;'>". getmygid() ."</td>";
$writeable = '<font color="blue">'. _WRITE .'</font>';
$unwriteable = '<font color="green">'. _NOWRITE .'</font>';
echo "<td align='center' style='border-bottom: 1px solid #C0C0C0; border-right: 1px solid #C0C0C0;'>";
echo is_writable( $folder ) ? $writeable : $unwriteable;
echo "</td>";
echo "</tr>";
} else {
$files[$filename] = filemtime($filename);
}
}
}
closedir($handle);
} else {
die('Could not open directory.' .$folder);
}
} else {
die('Invalid directory.');
}
return $files;
}
$files = recursedir("../");
// if($_GET['sort'] == 'alpha'){
// if($_GET['mode'] == 'desc'){
// krsort($files);
// $highlight = 'alpha_desc';
// } else {
ksort($files);
$highlight = 'alpha_asc';
// }
// } else {
// if($_GET['mode'] == 'asc'){
// asort($files, SORT_NUMERIC);
// $highlight = 'date_asc';
// } else {
// arsort($files, SORT_NUMERIC);
// $highlight = 'date_desc';
// }
// }
// $sort_alpha_asc = ($highlight == 'alpha_asc') ? '<b>Asc</b>' : '<a href="?sort=alpha&mode=asc">Asc</a>';
// $sort_alpha_desc = ($highlight == 'alpha_desc') ? '<b>Desc</b>' : '<a href="?sort=alpha&mode=desc">Desc</a>';
// $sort_date_asc = ($highlight == 'date_asc') ? '<b>Asc</b>' : '<a href="?sort=date&mode=asc">Asc</a>';
// $sort_date_desc = ($highlight == 'date_desc') ? '<b>Desc</b>' : '<a href="?sort=date&mode=desc">Desc</a>';
// echo "Sort by: Date- $sort_date_asc | $sort_date_desc; Name- $sort_alpha_asc | $sort_alpha_desc<br />\n<br />\n";
echo "</table><br><br>";
echo "<table border='0' cellspacing='0' cellpadding='2' width='95%' style='font-size: 11px;'>";
echo "<tr><td> </td><td><img src='../includes/js/ThemeOffice/warning.png' width='15' height='15' alt='". _FLIS_SUSS."'> = ". _FLIS_SUSS ."</td><th colspan='2' align='center' style='border-left: 1px solid #C0C0C0; border-top: 1px solid #C0C0C0; border-right: 1px solid #C0C0C0;' class='vflist'><b>". _FLIS_OWN ."</b></th><td> </td><td> </td><td> </td><td> </td></tr>";
echo "<tr><td> </td><th style='border-left: 1px solid #C0C0C0; border-top: 1px solid #C0C0C0; border-bottom: 1px solid #C0C0C0;' class='vflist'><b>". _DIAG_FILENAME_TITLE ."</b></th><td width='50' align='center' style='border-bottom: 1px solid #C0C0C0; border-left: 1px solid #C0C0C0; border-top: 1px solid #C0C0C0;' class='Heading'><b>". _FLIS_USR ."</b></td><td width='50' align='center' style='border-bottom: 1px solid #C0C0C0; border-left: 1px solid #C0C0C0; border-top: 1px solid #C0C0C0;' class='Heading'><b>". _FLIS_GRP ."</b></td><td width='50' align='center' style='border-bottom: 1px solid #C0C0C0; border-left: 1px solid #C0C0C0; border-top: 1px solid #C0C0C0;' class='Heading'><b>". _MODE ."</b></td><td width='15' style='border-left: 1px solid #C0C0C0;'> </td><td width='50' align='center' style='border-bottom: 1px solid #C0C0C0; border-left: 1px solid #C0C0C0; border-top: 1px solid #C0C0C0;' class='Heading'><b>". _FLIS_SIZE ."</b></td><td style='border-bottom: 1px solid #C0C0C0; border-left: 1px solid #C0C0C0; border-top: 1px solid #C0C0C0; border-right: 1px solid #C0C0C0;' align='center' class='Heading'><b>". _FLIS_LASMOD ."</b></td></tr>";
foreach($files as $file => $timestamp){
echo "<tr><td align='center' width='16'>";
if ($file ==(substr($file, strlen($file) - 3) == '.pl') || $file ==(substr($file, strlen($file) - 4) == '.cgi') || $file ==(substr($file, strlen($file) - 4) == '.zip') || $file ==(substr($file, strlen($file) - 4) == '.tar') || $file ==(substr($file, strlen($file) - 3) == '.gz') || $file ==(substr($file, strlen($file) - 4) == 'jpeg')) {
echo "<img src='../includes/js/ThemeOffice/warning.png' width='15' height='15' alt='". _FLIS_SUSS ."'>";
} else {
echo " ";
}
echo "</td>";
if (substr(sprintf('%o', @fileperms($file)), -1) == '7') {
echo "<td bgcolor='yellow' style='border-bottom: 1px solid #C0C0C0; border-left: 1px solid #C0C0C0;'><font color='red'>". $file ."</font></td>";
} else {
echo "<td style='border-bottom: 1px solid #C0C0C0; border-left: 1px solid #C0C0C0;'>". $file ."</td>";
}
echo "<td align='center' style='border-bottom: 1px solid #C0C0C0; border-left: 1px solid #C0C0C0;'>". fileowner("$file") ."</td>";
echo "<td align='center' style='border-bottom: 1px solid #C0C0C0; border-left: 1px solid #C0C0C0;'>". filegroup("$file") ."</td>";
if (substr(sprintf('%o', @fileperms($file)), -1) == '7')
{ echo "<td align='center' bgcolor='yellow' style='border-bottom: 1px solid #C0C0C0; border-left: 1px solid #C0C0C0;'><font color='red'>"; }
elseif (substr(sprintf('%o', @fileperms($file)), -1) >= '5')
{ echo "<td align='center' style='border-bottom: 1px solid #C0C0C0; border-left: 1px solid #C0C0C0;'><font color='blue'>"; }
else { echo "<td align='center' style='border-bottom: 1px solid #C0C0C0; border-left: 1px solid #C0C0C0;'><font color='green'>"; }
echo "". substr(sprintf('%o', @fileperms($file)), -4) ."";
echo '</font>';
echo "</td><td style='border-left: 1px solid #C0C0C0;' align='center'> </td><td style='border-bottom: 1px solid #C0C0C0; border-left: 1px solid #C0C0C0;'>";
$filesize = filesize($file);
if($filesize >= 1048576){
echo round($filesize / 1048576, 1).'MB';
} else {
echo round($filesize / 1024, 1).'kb';
}
echo '</td><td style="border-bottom: 1px solid #C0C0C0; border-right: 1px solid #C0C0C0; border-left: 1px solid #C0C0C0;">'.date('d M Y H:i:s', $timestamp)."</td>";
echo "</tr>\n";
}
echo "</table><br /><br />";
?>
</div>
</div>
<div class="clr"></div>
</div>
<div class="ctr">
<center>
<div class="error" align="center" style="width: 755px; padding: 2px; font-size: 11px; font-weight: normal; background-color: yellow; text-align: center; background-image: url(../includes/js/ThemeOffice/warning.png); background-position: 4px 4px; background-repeat: no-repeat; border: 1px solid #cc0000;">
<?php echo _WARN_SECURITY; ?>
</div>
<br /><br />
<?php echo _JUST_LINK; ?><br />
<br />
<br />
<?php echo _JOOMLA_LINK; ?>
</center>
</div>
</body>
</html>