initial commit of file from CVS for smeserver-webshare on Sat Sep 7 21:15:27 AEST 2024

This commit is contained in:
Trevor Batley
2024-09-07 21:15:27 +10:00
parent 609e015cb7
commit e4661a6aa1
90 changed files with 5344 additions and 2 deletions

View File

@@ -0,0 +1,15 @@
<?php
if (!@include_once("./conf/config.inc.php"))
include_once("../conf/config.inc.php");
ini_set('magic_quotes_gpc', 1);
ini_set('session.use_trans_sid', 0);
if (isset($session_save_path)) session_save_path($session_save_path);
session_start();
if (isset($_SESSION['session_username']) && $_SESSION['session_username'] == $username && isset($_SESSION['session_password']) && $_SESSION['session_password'] == md5($password) || !$phpfm_auth);
else exit("<font color='#CC0000'>Access Denied!</font>");
?>

View File

@@ -0,0 +1,73 @@
<?php
if (!@include_once("./incl/auth.inc.php"))
include_once("../incl/auth.inc.php");
if ($AllowCreateFolder && isset($_GET['create']) && isset($_POST['directory_name']))
{
$umask = umask(0);
if (!is_valid_name(stripslashes($_POST['directory_name'])))
print "<font color='#CC0000'>$StrFolderInvalidName</font>";
else if (file_exists($home_directory.$path.stripslashes($_POST['directory_name']."/")))
print "<font color='#CC0000'>$StrAlreadyExists</font>";
else if (@mkdir($home_directory.$path.stripslashes($_POST['directory_name']), 0777))
print "<font color='#009900'>$StrCreateFolderSuccess</font>";
else
{
print "<font color='#CC0000'>$StrCreateFolderFail</font><br /><br />";
print $StrCreateFolderFailHelp;
}
umask($umask);
}
else if ($AllowCreateFile && isset($_GET['create']) && isset($_POST['filename']))
{
if (!is_valid_name(stripslashes($_POST['filename'])))
print "<font color='#CC0000'>$StrFileInvalidName</font>";
else if (file_exists($home_directory.$path.stripslashes($_POST['filename'])))
print "<font color='#CC0000'>$StrAlreadyExists</font>";
else if (@fopen($home_directory.$path.stripslashes($_POST['filename']), "w+"))
print "<font color='#009900'>$StrCreateFileSuccess</font>";
else
{
print "<font color='#CC0000'>$StrCreateFileFail</font><br /><br />";
print $StrCreateFileFailHelp;
}
}
else if ($AllowCreateFolder || $AllowCreateFile)
{
print "<table class='index' width=500 cellpadding=0 cellspacing=0>";
print "<tr>";
print "<td class='iheadline' height=21>";
if ($_GET['type'] == "directory") print "<font class='iheadline'>&nbsp;$StrCreateFolder</font>";
else if ($_GET['type'] == "file") print "<font class='iheadline'>&nbsp;$StrCreateFile</font>";
print "</td>";
print "<td class='iheadline' align='right' height=21>";
print "<font class='iheadline'><a href='$base_url&amp;path=".htmlentities(rawurlencode($path))."'><img src='icon/back.gif' border=0 alt='$StrBack'></a></font>";
print "</td>";
print "</tr>";
print "<tr>";
print "<td valign='top' colspan=2>";
print "<center><br />";
if ($_GET['type'] == "directory") print "$StrCreateFolderQuestion<br /><br />";
else if ($_GET['type'] == "file") print "$StrCreateFileQuestion<br /><br />";
print "<form action='$base_url&amp;output=create&amp;create=true' method='post'>";
if ($_GET['type'] == "directory") print "<input name='directory_name' size=40>&nbsp;";
else if ($_GET['type'] == "file") print "<input name='filename' size=40>&nbsp;";
print "<input class='bigbutton' type='submit' value='$StrCreate'>";
print "<input type='hidden' name=path value=\"".htmlentities($path)."\">";
print "</form>";
print "<br /><br /></center>";
print "</td>";
print "</tr>";
print "</table>";
}
else
print "<font color='#CC0000'>$StrAccessDenied</font>";
?>

View File

@@ -0,0 +1,83 @@
<?php
if (!@include_once("./incl/auth.inc.php"))
include_once("../incl/auth.inc.php");
if ($AllowDelete && isset($_GET['directory_name']) || $AllowDelete && isset($_GET['filename']))
{
if (isset($_GET['delete']) && isset($_GET['directory_name']))
{
if ($_GET['directory_name'] == "../" || ($_GET['directory_name'] == "./"))
print "<font color='#CC0000'>$StrFolderInvalidName</font>";
else if (!file_exists($home_directory.$path.$directory_name))
print "<font color='#CC0000'>$StrDeleteFolderNotFound</font>";
else if (remove_directory($home_directory.$path.$directory_name) && @rmdir($home_directory.$path.$directory_name))
print "<font color='#009900'>$StrDeleteFolderSuccess</font>";
else
{
print "<font color='#CC0000'>$StrDeleteFolderFail</font><br /><br />";
print $StrDeleteFolderFailHelp;
}
}
else if (isset($_GET['delete']) && isset($_GET['filename']))
{
if ($_GET['filename'] == ".." || ($_GET['filename'] == "."))
print "<font color='#CC0000'>$StrFileInvalidName</font>";
else if (!file_exists($home_directory.$path.$filename))
print "<font color='#CC0000'>$StrDeleteFileNotFound</font>";
else if (@unlink($home_directory.$path.$filename))
print "<font color='#009900'>$StrDeleteFileSuccess</font>";
else
{
print "<font color='#CC0000'>$StrDeleteFileFail</font><br /><br />";
print $StrDeleteFileFailHelp;
}
}
else
{
print "<table class='index' width=500 cellpadding=0 cellspacing=0>";
print "<tr>";
print "<td class='iheadline' height=21>";
if (isset($_GET['directory_name'])) print "<font class='iheadline'>&nbsp;$StrDeleteFolder \"".htmlentities(basename($directory_name))."\"?</font>";
else if (isset($_GET['filename'])) print "<font class='iheadline'>&nbsp;$StrDeleteFile \"".htmlentities($filename)."\"?</font>";
print "</td>";
print "<td class='iheadline' align='right' height=21>";
print "<font class='iheadline'><a href='$base_url&amp;path=".htmlentities(rawurlencode($path))."'><img src='icon/back.gif' border=0 alt='$StrBack'></a></font>";
print "</td>";
print "</tr>";
print "<tr>";
print "<td valign='top' colspan=2>";
print "<center><br />";
if (isset($_GET['directory_name']))
{
print "$StrDeleteFolderQuestion<br /><br />";
print "/".htmlentities($path.$directory_name);
}
else if (isset($_GET['filename']))
{
print "$StrDeleteFileQuestion<br /><br />";
print "/".htmlentities($path.$filename);
}
print "<br /><br />";
if (isset($_GET['directory_name'])) print "<a href='$base_url&amp;path=".htmlentities(rawurlencode($path))."&amp;directory_name=".htmlentities(rawurlencode($directory_name))."&amp;output=delete&amp;delete=true'>$StrYes</a>";
else if (isset($_GET['filename'])) print "<a href='$base_url&amp;path=".htmlentities(rawurlencode($path))."&amp;filename=".htmlentities(rawurlencode($filename))."&amp;output=delete&amp;delete=true'>$StrYes</a>";
print "&nbsp;$StrOr&nbsp;";
print "<a href='$base_url&amp;path=".htmlentities(rawurlencode($path))."'>$StrCancel</a>";
print "<br /><br /></center>";
print "</td>";
print "</tr>";
print "</table>";
}
}
else
print "<font color='#CC0000'>$StrAccessDenied</font>";
?>

View File

@@ -0,0 +1,30 @@
<?php
if (!@include_once("./incl/auth.inc.php"))
include_once("../incl/auth.inc.php");
if ($AllowDownload)
{
print "<table class='index' width=500 cellpadding=0 cellspacing=0>";
print "<tr>";
print "<td class='iheadline' height=21>";
print "<font class='iheadline'>&nbsp;$StrDownload \"".htmlentities($filename)."\"</font>";
print "</td>";
print "<td class='iheadline' align='right' height=21>";
print "<font class='iheadline'><a href='$base_url&amp;path=".htmlentities(rawurlencode($path))."'><img src='icon/back.gif' border=0 alt='$StrBack'></a></font>";
print "</td>";
print "</tr>";
print "<tr>";
print "<td valign='top' colspan=2>";
print "<center><br />";
print "$StrDownloadClickLink<br /><br />";
print "<a href='incl/libfile.php?".SID."&amp;path=".htmlentities(rawurlencode($path))."&amp;filename=".htmlentities(rawurlencode($filename))."&amp;action=download'>$StrDownloadClickHere <i>\"".htmlentities($filename)."\"</i></a>";
print "<br /><br /></center>";
print "</td>";
print "</tr>";
print "</table>";
}
else
print "<font color='#CC0000'>$StrAccessDenied</font>";
?>

View File

@@ -0,0 +1,69 @@
<?php
if (!@include_once("./incl/auth.inc.php"))
include_once("../incl/auth.inc.php");
if ($AllowEdit && isset($_GET['save']) && isset($_POST['filename']))
{
$text = stripslashes($_POST['text']);
if (!is_valid_name(stripslashes($_POST['filename'])))
print "<font color='#CC0000'>$StrFileInvalidName</font>";
else if ($fp = @fopen ($home_directory.$path.stripslashes($_POST['filename']), "wb"))
{
fwrite($fp, $text);
fclose($fp);
print "<font color='#009900'>$StrSaveFileSuccess</font>";
}
else
print "<font color='#CC0000'>$StrSaveFileFail</font>";
}
else if ($AllowEdit && isset($_GET['filename']))
{
print "<table class='index' width=800 cellpadding=0 cellspacing=0>";
print "<tr>";
print "<td class='iheadline' height=21>";
print "<font class='iheadline'>&nbsp;$StrEditing \"".htmlentities($filename)."\"</font>";
print "</td>";
print "<td class='iheadline' align='right' height=21>";
print "<font class='iheadline'><a href='$base_url&amp;path=".htmlentities(rawurlencode($path))."'><img src='icon/back.gif' border=0 alt='$StrBack'></a></font>";
print "</td>";
print "</tr>";
print "<tr>";
print "<td valign='top' colspan=2>";
print "<center><br />";
if ($fp = @fopen($home_directory.$path.$filename, "rb"))
{
print "<form action='$base_url&amp;output=edit&amp;save=true' method='post'>";
print "<textarea cols=120 rows=20 name='text'>";
print htmlentities(fread($fp, filesize($home_directory.$path.$filename)));
fclose ($fp);
print "</textarea>";
print "<br /><br />";
print "$StrFilename <input size=40 name='filename' value=\"".htmlentities($filename)."\">";
print "<br /><br />";
print "<input class='bigbutton' type='reset' value='$StrRestoreOriginal'>&nbsp;<input class='bigbutton' type='submit' value='$StrSaveAndExit'>";
print "<input type='hidden' name='path' value=\"".htmlentities($path)."\">";
print "</form>";
}
else
print "<font color='#CC0000'>$StrErrorOpeningFile</font>";
print "<br /><br /></center>";
print "</td>";
print "</tr>";
print "</table>";
}
else
print "<font color='#CC0000'>$StrAccessDenied</font>";
?>

View File

@@ -0,0 +1,151 @@
<?php
if (!@include_once("./incl/auth.inc.php"))
include_once("../incl/auth.inc.php");
if (!isset($_GET['sortby'])) $_GET['sortby'] = "filename";
if (!isset($_GET['order'])) $_GET['order'] = "asc";
print "<table class='menu' cellpadding=2 cellspacing=0>";
print "<tr>";
if ($AllowCreateFolder) print "<td align='center' valign='bottom'><a href='$base_url&amp;path=".htmlentities(rawurlencode($path))."&amp;action=create&amp;type=directory'><img src='icon/newfolder.gif' width=20 height=22 alt='$StrMenuCreateFolder' border=0>&nbsp;$StrMenuCreateFolder</a></td>";
if ($AllowCreateFile) print "<td align='center' valign='bottom'><a href='$base_url&amp;path=".htmlentities(rawurlencode($path))."&amp;action=create&amp;type=file'><img src='icon/newfile.gif' width=20 height=22 alt='$StrMenuCreateFile' border=0>&nbsp;$StrMenuCreateFile</a></td>";
if ($AllowUpload) print "<td align='center' valign='bottom'><a href='$base_url&amp;path=".htmlentities(rawurlencode($path))."&amp;action=upload'><img src='icon/upload.gif' width=20 height=22 alt='$StrMenuUploadFiles' border=0>&nbsp;$StrMenuUploadFiles</a></td>";
if ($phpfm_auth) print "<td align='center' valign='bottom'><a href='$base_url&amp;action=logout'><img src='icon/logout.gif' width=20 height=22 alt='$StrMenuLogOut' border=0>&nbsp;$StrMenuLogOut</a></td>";
print "</tr>";
print "</table><br />";
print "<table class='index' cellpadding=0 cellspacing=0>";
print "<tr>";
print "<td class='iheadline' colspan=4 align='center' height=21>";
print "<font class='iheadline'>$StrIndexOf&nbsp;".get_linked_path($path,$base_url)."</font>";
print "</td>";
print "</tr>";
print "<tr>";
print "<td>&nbsp;</td>";
print "<td class='fbborder' valign='top'>";
if ($open = @opendir($home_directory.$path))
{
for($i=0;($directory = readdir($open)) != FALSE;$i++)
if (is_dir($home_directory.$path.$directory) && $directory != "." && $directory != ".." && !is_hidden_directory($home_directory.$path.$directory))
$directories[$i] = array($directory,$directory);
closedir($open);
if (isset($directories))
{
sort($directories);
reset($directories);
}
}
print "<table class='directories' width=300 cellpadding=1 cellspacing=0>";
print "<tr>";
print "<td class='bold' width=20>&nbsp;</td>";
print "<td class='bold'>&nbsp;$StrFolderNameShort</td>";
if ($AllowRename) print "<td class='bold' width=20 align='center'>$StrRenameShort</td>";
if ($AllowDelete) print "<td class='bold' width=20 align='center'>$StrDeleteShort</td>";
print "</tr>";
print "<tr>";
print "<td width=20><a href='$base_url&amp;path=".htmlentities(rawurlencode($path))."'><img src='icon/folder.gif' width=20 height=22 alt='$StrOpenFolder' border=0></a></td>";
print "<td>&nbsp;<a href='$base_url'>.</a></td>";
print "<td width=20>&nbsp;</td>";
print "<td width=20>&nbsp;</td>";
print "</tr>";
print "<tr>";
print "<td width=20><a href='$base_url&amp;path=".htmlentities(rawurlencode(dirname($path)))."/'><img src='icon/folder.gif' width=20 height=22 alt='$StrOpenFolder' border=0></a></td>";
print "<td>&nbsp;<a href='$base_url&amp;path=".htmlentities(rawurlencode(dirname($path)))."/'>..</a></td>";
print "<td width=20>&nbsp;</td>";
print "<td width=20>&nbsp;</td>";
print "</tr>";
if (isset($directories)) foreach($directories as $directory)
{
print "<tr>";
print "<td width=20><a href='$base_url&amp;path=".htmlentities(rawurlencode($path.$directory[0]))."/'><img src='icon/folder.gif' width=20 height=22 alt='$StrOpenFolder' border=0></a></td>";
print "<td>&nbsp;<a href='$base_url&amp;path=".htmlentities(rawurlencode($path.$directory[0]))."/'>".htmlentities($directory[0])."</a></td>";
if ($AllowRename) print "<td width=20><a href='$base_url&amp;path=".htmlentities(rawurlencode($path))."&amp;directory_name=".htmlentities(rawurlencode($directory[0]))."/&amp;action=rename'><img src='icon/rename.gif' width=20 height=22 alt='$StrRenameFolder' border=0></a></td>";
if ($AllowDelete) print "<td width=20><a href='$base_url&amp;path=".htmlentities(rawurlencode($path))."&amp;directory_name=".htmlentities(rawurlencode($directory[0]))."/&amp;action=delete'><img src='icon/delete.gif' width=20 height=22 alt='$StrDeleteFolder' border=0></a></td>";
print "</tr>";
}
print "<tr><td colspan=4>&nbsp;</td></tr>";
print "</table>";
print "</td>";
print "<td>&nbsp;</td>";
print "<td valign='top'>";
if ($open = @opendir($home_directory.$path))
{
for($i=0;($file = readdir($open)) != FALSE;$i++)
if (is_file($home_directory.$path.$file) && !is_hidden_file($home_directory.$path.$file))
{
$icon = get_icon($file);
$filesize = filesize($home_directory.$path.$file);
$permissions = decoct(fileperms($home_directory.$path.$file)%01000);
$modified = filemtime($home_directory.$path.$file);
$extension = "";
$files[$i] = array(
"icon" => $icon,
"filename" => $file,
"filesize" => $filesize,
"permissions" => $permissions,
"modified" => $modified,
"extension" => $extension,
);
}
closedir($open);
if (isset($files))
{
usort($files, "compare_filedata");
reset($files);
}
}
print "<table class='files' width=500 cellpadding=1 cellspacing=0>";
print "<tr>";
print "<td class='bold' width=20>&nbsp;</td>";
print "<td class='bold'>&nbsp;<a href='$base_url&amp;path=".htmlentities(rawurlencode($path))."&amp;sortby=filename&amp;order=".get_opposite_order("filename", $_GET['order'])."'>$StrFileNameShort</a></td>";
print "<td class='bold' width=60 align='center'><a href='$base_url&amp;path=".htmlentities(rawurlencode($path))."&amp;sortby=filesize&amp;order=".get_opposite_order("filesize", $_GET['order'])."'>$StrFileSizeShort</a></td>";
print "<td class='bold' width=35 align='center'><a href='$base_url&amp;path=".htmlentities(rawurlencode($path))."&amp;sortby=permissions&amp;order=".get_opposite_order("permissions", $_GET['order'])."'>$StrPermissionsShort</a></td>";
print "<td class='bold' width=110 align='center'><a href='$base_url&amp;path=".htmlentities(rawurlencode($path))."&amp;sortby=modified&amp;order=".get_opposite_order("modified", $_GET['order'])."'>$StrLastModifiedShort</a></td>";
if ($AllowView) print "<td class='bold' width=20 align='center'>$StrViewShort</td>";
if ($AllowEdit) print "<td class='bold' width=20 align='center'>$StrEditShort</td>";
if ($AllowRename) print "<td class='bold' width=20 align='center'>$StrRenameShort</td>";
if ($AllowDownload) print "<td class='bold' width=20 align='center'>$StrDownloadShort</td>";
if ($AllowDelete) print "<td class='bold' width=20 align='center'>$StrDeleteShort</td>";
print "</tr>";
if (isset($files)) foreach($files as $file)
{
$file['filesize'] = get_better_filesize($file['filesize']);
$file['modified'] = date($ModifiedFormat, $file['modified']);
print "<tr>";
print "<td width=20><img src='icon/".$file['icon']."' width=20 height=22 border=0 alt='$StrFile'></td>";
print "<td>&nbsp;".htmlentities($file['filename'])."</td>";
print "<td width=60 align='right'>".$file['filesize']."</td>";
print "<td width=35 align='center'>".$file['permissions']."</td>";
print "<td width=110 align='right'>".$file['modified']."</td>";
if ($AllowView && is_viewable_file($file['filename'])) print "<td width=20><a href='$base_url&amp;path=".htmlentities(rawurlencode($path))."&amp;filename=".htmlentities(rawurlencode($file['filename']))."&amp;action=view&amp;size=100'><img src='icon/view.gif' width=20 height=22 alt='$StrViewFile' border=0></a></td>";
else if ($AllowView) print "<td width=20>&nbsp;</td>";
if ($AllowEdit && is_editable_file($file['filename'])) print "<td width=20><a href='$base_url&amp;path=".htmlentities(rawurlencode($path))."&amp;filename=".htmlentities(rawurlencode($file['filename']))."&amp;action=edit'><img src='icon/edit.gif' width=20 height=22 alt='$StrEditFile' border=0></a></td>";
else if ($AllowEdit) print "<td width=20>&nbsp;</td>";
if ($AllowRename) print "<td width=20><a href='$base_url&amp;path=".htmlentities(rawurlencode($path))."&amp;filename=".htmlentities(rawurlencode($file['filename']))."&amp;action=rename'><img src='icon/rename.gif' width=20 height=22 alt='$StrRenameFile' border=0></a></td>";
if ($AllowDownload) print "<td width=20><a href='$base_url&amp;path=".htmlentities(rawurlencode($path))."&amp;filename=".htmlentities(rawurlencode($file['filename']))."&amp;action=download'><img src='icon/download.gif' width=20 height=22 alt='$StrDownloadFile' border=0></a></td>";
if ($AllowEdit) print "<td width=20><a href='$base_url&amp;path=".htmlentities(rawurlencode($path))."&amp;filename=".htmlentities(rawurlencode($file['filename']))."&amp;action=delete'><img src='icon/delete.gif' width=20 height=22 alt='$StrDeleteFile' border=0></a></td>";
print "</tr>";
}
print "<tr><td colspan=9>&nbsp;</td></tr>";
print "</table>";
print "</td>";
print "</tr>";
print "</table>";
?>

View File

@@ -0,0 +1,19 @@
<?php
list($seconds, $microseconds) = explode(" ", microtime());
$time_end = $seconds + $microseconds;
$total_time = round($time_end-$time_start, 4);
print "<br /><br />";
print "<table class='bottom' cellpadding=0 cellspacing=0>";
print "<tr><td>&nbsp;</td></tr>";
print "<tr><td align='center'>This page was produced in $total_time seconds.</td></tr>";
print "</table>";
print "<br /><br />";
print "</center>";
print "</body>";
print "</html>";
?>

View File

@@ -0,0 +1,26 @@
<?php
list($seconds, $microseconds) = explode(" ", microtime());
$time_end = $seconds + $microseconds;
$total_time = round($time_end-$time_start, 4);
print "<br /><br />";
print "<table class='bottom' cellpadding=0 cellspacing=0>";
print "<tr><td align='center'>Powered by <a href='http://phpfm.zalon.dk/' target='_new' class='bottom'>PHPFM</a> ".VERSION."</td></tr>";
print "<tr><td align='center'>Copyright <20> 2002 Morten Bojsen-Hansen</td></tr>";
print "<tr><td>&nbsp;</td></tr>";
print "<tr><td align='center'>";
print "<a href='http://validator.w3.org/check/referer'><img border='0' src='icon/valid-html401.jpg' alt='Valid HTML 4.01!' height='31' width='88'></a>";
print "<a href='http://jigsaw.w3.org/css-validator/'><img style='border:0;width:88px;height:31px' src='icon/valid-css.jpg' alt='Valid CSS!'></a>";
print "</td></tr>";
print "<tr><td>&nbsp;</td></tr>";
print "<tr><td align='center'>This page was produced in $total_time seconds.</td></tr>";
print "</table>";
print "<br /><br />";
print "</center>";
print "</body>";
print "</html>";
?>

View File

@@ -0,0 +1,258 @@
<?php
function remove_directory($directory) ## Remove a directory recursively
{
$list_sub = array();
$list_files = array();
if (!($open = opendir($directory)))
return FALSE;
while(($index = readdir($open)) != FALSE)
{
if (is_dir($directory.$index) && $index != "." && $index != "..")
$list_sub[] = $index."/";
else if (is_file($directory.$index))
$list_files[] = $index;
}
closedir($open);
foreach($list_files as $file)
if (!unlink($directory.$file))
return FALSE;
foreach($list_sub as $sub)
{
remove_directory($directory.$sub);
if (!rmdir($directory.$sub))
return FALSE;
}
return TRUE;
}
function get_icon($filename) ## Get the icon from the filename
{
global $IconArray;
reset($IconArray);
$extension = strtolower(substr(strrchr($filename, "."),1));
if ($extension == "")
return "unknown.gif";
while (list($icon, $types) = each($IconArray))
foreach (explode(" ", $types) as $type)
if ($extension == $type)
return $icon;
return "unknown.gif";
}
function compare_filedata ($a, $b) ## Compare filedata (used to sort)
{
if (is_int($a[$_GET['sortby']]) && is_int($b[$_GET['sortby']]))
{
if ($a[$_GET['sortby']]==$b[$_GET['sortby']]) return 0;
if ($_GET['order'] == "asc")
{
if ($a[$_GET['sortby']] > $b[$_GET['sortby']]) return 1;
else return -1;
}
else if ($_GET['order'] == "desc")
{
if ($a[$_GET['sortby']] < $b[$_GET['sortby']]) return 1;
else return -1;
}
}
else if (is_string($a[$_GET['sortby']]) && is_string($b[$_GET['sortby']]) && $_GET['order'] == "asc")
return strcmp($a[$_GET['sortby']], $b[$_GET['sortby']]);
else if (is_string($a[$_GET['sortby']]) && is_string($b[$_GET['sortby']]) && $_GET['order'] == "desc")
return -strcmp($a[$_GET['sortby']], $b[$_GET['sortby']]);
}
function get_opposite_order($input, $order) ## Get opposite order
{
if ($_GET['sortby'] == $input)
{
if ($order == "asc")
return "desc";
else if ($order == "desc")
return "asc";
}
else
return "asc";
}
function is_editable_file($filename) ## Checks whether a file is editable
{
global $EditableFiles;
$extension = strtolower(substr(strrchr($filename, "."),1));
foreach(explode(" ", $EditableFiles) as $type)
if ($extension == $type)
return TRUE;
return FALSE;
}
function is_viewable_file($filename) ## Checks whether a file is viewable
{
global $ViewableFiles;
$extension = strtolower(substr(strrchr($filename, "."),1));
foreach(explode(" ", $ViewableFiles) as $type)
if ($extension == $type)
return TRUE;
return FALSE;
}
function is_valid_name($input) ## Checks whether the directory- or filename is valid
{
if (strstr($input, "\\"))
return FALSE;
else if (strstr($input, "/"))
return FALSE;
else if (strstr($input, ":"))
return FALSE;
else if (strstr($input, "?"))
return FALSE;
else if (strstr($input, "*"))
return FALSE;
else if (strstr($input, "\""))
return FALSE;
else if (strstr($input, "<"))
return FALSE;
else if (strstr($input, ">"))
return FALSE;
else if (strstr($input, "|"))
return FALSE;
else
return TRUE;
}
function get_better_filesize($filesize) ## Converts filesize to KB/MB/GB/TB
{
$kilobyte = 1024;
$megabyte = 1048576;
$gigabyte = 1073741824;
$terabyte = 1099511627776;
if ($filesize >= $terabyte)
return number_format($filesize/$terabyte, 2, ',', '.')."&nbsp;TB";
else if ($filesize >= $gigabyte)
return number_format($filesize/$gigabyte, 2, ',', '.')."&nbsp;GB";
else if ($filesize >= $megabyte)
return number_format($filesize/$megabyte, 2, ',', '.')."&nbsp;MB";
else if ($filesize >= $kilobyte)
return number_format($filesize/$kilobyte, 2, ',', '.')."&nbsp;KB";
else
return number_format($filesize, 0, ',', '.')."&nbsp;B";
}
function get_current_zoom_level($current_zoom_level, $zoom) ## Get current zoom level
{
global $ZoomArray;
reset($ZoomArray);
while(list($number, $zoom_level) = each($ZoomArray))
if ($zoom_level == $current_zoom_level)
if (($number+$zoom) < 0) return $number;
else if (($number+$zoom) >= count($ZoomArray)) return $number;
else return $number+$zoom;
}
function validate_path($path) ## Validate path
{
global $StrAccessDenied;
if (stristr($path, "../") || stristr($path, "..\\"))
return TRUE;
else
return stripslashes($path);
}
function authenticate_user() ## Authenticate user using cookies
{
global $username, $password;
if (isset($_COOKIE['cookie_username']) && $_COOKIE['cookie_username'] == $username && isset($_COOKIE['cookie_password']) && $_COOKIE['cookie_password'] == md5($password))
return TRUE;
else
return FALSE;
}
function is_hidden_file($path) ## Checks whether the file is hidden.
{
global $hide_file_extension, $hide_file_string, $hide_directory_string;
$extension = strtolower(substr(strrchr($path, "."),1));
foreach ($hide_file_extension as $hidden_extension)
if ($hidden_extension == $extension)
return TRUE;
foreach ($hide_file_string as $hidden_string)
if (stristr(basename($path), $hidden_string))
return TRUE;
foreach ($hide_directory_string as $hidden_string)
if (stristr(dirname($path), $hidden_string))
return TRUE;
return FALSE;
}
function is_hidden_directory($path) ## Checks whether the directory is hidden.
{
global $hide_directory_string;
foreach ($hide_directory_string as $hidden_string)
if (stristr($path, $hidden_string))
return TRUE;
return FALSE;
}
function get_mimetype($filename) ## Get MIME-type for file
{
global $MIMEtypes;
reset($MIMEtypes);
$extension = strtolower(substr(strrchr($filename, "."),1));
if ($extension == "")
return "Unknown/Unknown";
while (list($mimetype, $file_extensions) = each($MIMEtypes))
foreach (explode(" ", $file_extensions) as $file_extension)
if ($extension == $file_extension)
return $mimetype;
return "Unknown/Unknown";
}
function get_linked_path($path,$base_url) ## Get path with links to each folder
{
$string = "<a href='$base_url'>.</a> / ";
$array = explode("/",htmlentities($path));
unset($array[count($array)-1]);
foreach ($array as $entry)
{
@$temppath .= $entry."/";
$string .= "<a href='$base_url&amp;path=".htmlentities(rawurlencode($temppath))."'>$entry</a> / ";
}
return $string;
}
?>

View File

@@ -0,0 +1,34 @@
<?php
list($seconds, $microseconds) = explode(" ", microtime());
$time_start = $seconds + $microseconds;
header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");
header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT");
header("Cache-Control: no-store, no-cache, must-revalidate");
header("Cache-Control: post-check=0, pre-check=0", false);
header("Pragma: no-cache");
header("Content-Type: text/html; charset=$StrLanguageCharset");
if (isset($session_save_path)) session_save_path($session_save_path);
ini_set('magic_quotes_gpc', 1);
ini_set('session.use_trans_sid', 0);
error_reporting(E_ALL);
clearstatcache();
session_start();
$base_url = "?".SID."&amp;";
if (isset($_POST['input_username']) && isset($_POST['input_password']) && $_POST['input_username'] == $username && md5($_POST['input_password']) == md5($password))
{
$_SESSION['session_username'] = $_POST['input_username'];
$_SESSION['session_password'] = md5($_POST['input_password']);
}
else if (isset($_GET['action']) && $_GET['action'] == "logout")
{
$_SESSION = array();
session_destroy();
setcookie(session_name(),"",0,"/");
}
?>

View File

@@ -0,0 +1,17 @@
<?php
print "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\">";
print "<html>";
print "<head>";
print "<link rel='stylesheet' href='incl/phpfm.css' type='text/css'>";
print "</head>";
print "<body link='#0000FF' alink='#0000FF' vlink='#0000FF' bgcolor='#FFFFFF'>";
print "<center>";
print "<table class='top' cellpadding=0 cellspacing=0>";
print "<tr>";
print "<td align='center'><font class='headline'></font></td>";
print "</tr>";
print "</table><br />";
?>

View File

@@ -0,0 +1,18 @@
<?php
print "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\">";
print "<html>";
print "<head>";
print "<title>PHPFM ".VERSION." - a file manager written in PHP</title>";
print "<link rel='stylesheet' href='incl/phpfm.css' type='text/css'>";
print "</head>";
print "<body link='#0000FF' alink='#0000FF' vlink='#0000FF' bgcolor='#FFFFFF'>";
print "<center>";
print "<table class='top' cellpadding=0 cellspacing=0>";
print "<tr>";
print "<td align='center'><font class='headline'>PHPFM ".VERSION."</font></td>";
print "</tr>";
print "</table><br />";
?>

View File

@@ -0,0 +1,50 @@
<?php
if (!@include_once("./incl/auth.inc.php"))
include_once("../incl/auth.inc.php");
include("../conf/config.inc.php");
include("../incl/functions.inc.php");
include("../lang/$language.inc.php");
if (isset($_GET['action']) && $_GET['action'] == "download")
{
session_cache_limiter("public, post-check=50");
header("Cache-Control: private");
}
if (isset($session_save_path)) session_save_path($session_save_path);
if (isset($_GET['path'])) $path = validate_path($_GET['path']);
if (!isset($path)) $path = FALSE;
if ($path == "./" || $path == ".\\" || $path == "/" || $path == "\\") $path = FALSE;
if (isset($_GET['filename'])) $filename = basename(stripslashes($_GET['filename']));
if ($AllowDownload || $AllowView)
{
if (isset($_GET['filename']) && isset($_GET['action']) && is_file($home_directory.$path.$filename) || is_file("../".$home_directory.$path.$filename))
{
if (is_file($home_directory.$path.$filename) && !strstr($home_directory, "./") && !strstr($home_directory, ".\\"))
$fullpath = $home_directory.$path.$filename;
else if (is_file("../".$home_directory.$path.$filename))
$fullpath = "../".$home_directory.$path.$filename;
if (!$AllowDownload && $AllowView && !is_viewable_file($filename))
{
print "<font color='#CC0000'>$StrAccessDenied</font>";
exit();
}
header("Pragma:");
header("Content-Type: ".get_mimetype($filename));
header("Content-Length: ".filesize($fullpath));
if ($_GET['action'] == "download");
header("Content-Disposition: attachment; filename=\"$filename\"");
readfile($fullpath);
}
else
print "<font color='#CC0000'>$StrDownloadFail</font>";
}
?>

View File

@@ -0,0 +1,32 @@
<?php
print "<table class='index' width=500 cellpadding=0 cellspacing=0>";
print "<tr>";
print "<td class='iheadline' align='center' height=21>";
print "<font class='iheadline'>$StrLoginSystem</font>";
print "</td>";
print "</tr>";
print "<tr>";
print "<td valign='top'>";
print "<center><br />";
print "$StrLoginInfo<br />";
print "<form action='".$_SERVER['PHP_SELF']."' method='post' enctype='multipart/form-data'>";
print "<table class='upload'>";
print "<tr><td>$StrUsername</td><td><input name='input_username' size=20></td></tr>";
print "<tr><td>$StrPassword</td><td><input type='password' name='input_password' size=20></td></tr>";
print "<tr><td>&nbsp;</td><td><input class='button' type='submit' value='$StrLogIn'></td></tr>";
print "</table>";
print "<input type='hidden' name=path value=\"".htmlentities($path)."\">";
print "</form>";
print "<br /><br /></center>";
print "</td>";
print "</tr>";
print "</table>";
?>

View File

@@ -0,0 +1,31 @@
body { margin : 0px; font-family : Tahoma, serif; font-size : 8pt; color : #000000; background-color: transparent; }
font.headline { font-family : Tahoma, serif; font-size : 25pt; color : #000000; font-weight : bold; background-color: transparent; }
font.iheadline { font-family : Tahoma, serif; font-size : 10pt; color : #FFFFFF; font-weight : bold; background-color: transparent; }
table.top { width: 100%; border-bottom : 1px solid #000000; background-color: transparent; }
table.bottom { width: 100%; border-top : 1px solid #000000; font-family : Tahoma, serif; font-size : 8pt; background-color: transparent; }
table.index { background-color : #EEEEEE; color : #000000; border : 1px solid #000000; font-family : Tahoma, serif; font-size : 8pt; }
table.directories { font-family : Tahoma, serif; font-size : 10pt; background-color: transparent; }
table.files { font-family : Tahoma, serif; font-size : 10pt; background-color: transparent; }
table.menu { font-family : Tahoma, serif; font-size : 10pt; background-color: transparent; }
table.upload { font-family : Tahoma, serif; font-size : 8pt; background-color: transparent; }
table.output { font-family : Tahoma, serif; font-size : 8pt; background-color : #EEEEEE; color : #000000; }
td.iheadline { background-color : #5485C9; color : #000000; border-bottom : 1px solid #000000; }
td.fbborder { border-right : 1px solid #000000; background-color: transparent; }
a:link { text-decoration : none; color : #000000; background-color: transparent; }
a:visited { text-decoration : none; color : #000000; background-color: transparent; }
a:hover { text-decoration : underline; color : #000000; background-color: transparent; }
a.bottom:link { text-decoration : none; color : #000088; background-color: transparent; }
a.bottom:visited { text-decoration : none; color : #000088; background-color: transparent; }
a.bottom:hover { text-decoration : underline; color : #000088; background-color: transparent; }
input { background-color : #DDDDDD; border : 1px solid #000000; font-family : Tahoma, serif; font-size : 8pt; color : #000000; }
input.button { width : 50px; }
input.bigbutton { width : 100px; }
textarea { background-color : #FFFFFF; color : #000000; border : 1px solid #000000; font-family : Tahoma, serif; font-size : 10pt; }
.bold { font-weight : bold; background-color: transparent; }

View File

@@ -0,0 +1,76 @@
<?php
if (!@include_once("./incl/auth.inc.php"))
include_once("../incl/auth.inc.php");
if ($AllowRename && isset($_GET['directory_name']) || $AllowRename && isset($_GET['filename']) || $AllowRename && isset($_POST['directory_name']) || $AllowRename && isset($_POST['filename']))
{
if (isset($_GET['rename']) && isset($_POST['directory_name']))
{
if (!is_valid_name(substr($new_directory_name, 0, -1)))
print "<font color='#CC0000'>$StrFolderInvalidName</font>";
else if (@file_exists($home_directory.$path.$new_directory_name))
print "<font color='#CC0000'>$StrAlreadyExists</font>";
else if (@rename($home_directory.$path.$directory_name, $home_directory.$path.$new_directory_name))
print "<font color='#009900'>$StrRenameFolderSuccess</font>";
else
{
print "<font color='#CC0000'>$StrRenameFolderFail</font><br /><br />";
print $StrRenameFolderFailHelp;
}
}
else if (isset($_GET['rename']) && isset($_POST['filename']))
{
if (!is_valid_name($new_filename))
print "<font color='#CC0000'>$StrFileInvalidName</font>";
else if (@file_exists($home_directory.$path.$new_filename))
print "<font color='#CC0000'>$StrAlreadyExists</font>";
else if (@rename($home_directory.$path.$filename, $home_directory.$path.$new_filename))
print "<font color='#009900'>$StrRenameFileSuccess</font>";
else
{
print "<font color='#CC0000'>$StrRenameFileFail</font><br /><br />";
print $StrRenameFileFailHelp;
}
}
else
{
print "<table class='index' width=500 cellpadding=0 cellspacing=0>";
print "<tr>";
print "<td class='iheadline' height=21>";
if (isset($_GET['directory_name'])) print "<font class='iheadline'>&nbsp;$StrRenameFolder \"".htmlentities(basename($directory_name))."\"</font>";
else if (isset($_GET['filename'])) print "<font class='iheadline'>&nbsp;$StrRenameFile \"".htmlentities($filename)."\"</font>";
print "</td>";
print "<td class='iheadline' align='right' height=21>";
print "<font class='iheadline'><a href='$base_url&amp;path=".htmlentities(rawurlencode($path))."'><img src='icon/back.gif' border=0 alt='$StrBack'></a></font>";
print "</td>";
print "</tr>";
print "<tr>";
print "<td valign='top' colspan=2>";
print "<center><br />";
if (isset($_GET['directory_name'])) print "$StrRenameFolderQuestion<br /><br />";
else if (isset($_GET['filename'])) print "$StrRenameFileQuestion<br /><br />";
print "<form action='$base_url&amp;output=rename&amp;rename=true' method='post'>";
if (isset($_GET['directory_name'])) print "<input name='new_directory_name' value=\"".htmlentities(basename($directory_name))."\" size=40>&nbsp;";
else if (isset($_GET['filename'])) print "<input name='new_filename' value=\"".htmlentities($filename)."\" size=40>&nbsp;";
print "<input class='bigbutton' type='submit' value='$StrRename'>";
if (isset($_GET['directory_name'])) print "<input type='hidden' name=directory_name value=\"".htmlentities($directory_name)."\">";
else if (isset($_GET['filename'])) print "<input type='hidden' name=filename value=\"".htmlentities($filename)."\">";
print "<input type='hidden' name=path value=\"".htmlentities($path)."\">";
print "</form>";
print "<br /><br /></center>";
print "</td>";
print "</tr>";
print "</table>";
}
}
else
print "<font color='#CC0000'>$StrAccessDenied</font>";
?>

View File

@@ -0,0 +1,66 @@
<?php
if (!@include_once("./incl/auth.inc.php"))
include_once("../incl/auth.inc.php");
if ($AllowUpload && isset($_GET['upload']))
{
print "<table cellspacing=0 cellpadding=0 class='upload'>";
if (!isset($_FILES['userfile']))
// maximum post size reached
print $StrUploadFailPost;
else
{
for($i=0;$i<=3;$i++)
{
$_FILES['userfile']['name'][$i] = stripslashes($_FILES['userfile']['name'][$i]);
if (@move_uploaded_file($_FILES['userfile']['tmp_name'][$i], realpath($home_directory.$path)."/".$_FILES['userfile']['name'][$i]))
print "<tr><td width='250'>$StrUploading ".$_FILES['userfile']['name'][$i]."</td><td width='50' align='center'>[<font color='#009900'>$StrUploadSuccess</font>]</td></tr>";
else if ($_FILES['userfile']['name'][$i])
print "<tr><td width='250'>$StrUploading ".$_FILES['userfile']['name'][$i]."</td><td width='50' align='center'>[<font color='#CC0000'>$StrUploadFail</font>]</td></tr>";
}
}
print "</table>";
}
else if ($AllowUpload)
{
print "<table class='index' width=500 cellpadding=0 cellspacing=0>";
print "<tr>";
print "<td class='iheadline' height=21>";
print "<font class='iheadline'>&nbsp;$StrUploadFilesTo \"/".htmlentities($path)."\"</font>";
print "</td>";
print "<td class='iheadline' align='right' height=21>";
print "<font class='iheadline'><a href='$base_url&amp;path=".htmlentities(rawurlencode($path))."'><img src='icon/back.gif' border=0 alt='$StrBack'></a></font>";
print "</td>";
print "</tr>";
print "<tr>";
print "<td valign='top' colspan=2>";
print "<center><br />";
print "$StrUploadQuestion<br />";
print "<form action='$base_url&amp;output=upload&amp;upload=true' method='post' enctype='multipart/form-data'>";
print "<table class='upload'>";
print "<tr><td>$StrFirstFile</td><td><input type='file' name='userfile[]' size=30></td></tr>";
print "<tr><td>$StrSecondFile</td><td><input type='file' name='userfile[]' size=30></td></tr>";
print "<tr><td>$StrThirdFile</td><td><input type='file' name='userfile[]' size=30></td></tr>";
print "<tr><td>$StrFourthFile</td><td><input type='file' name='userfile[]' size=30></td></tr>";
print "</table>";
print "<input class='bigbutton' type='submit' value='$StrUpload'>";
print "<input type='hidden' name=path value=\"".htmlentities($path)."\">";
print "</form>";
print "<br /><br /></center>";
print "</td>";
print "</tr>";
print "</table>";
}
else
print "<font color='#CC0000'>$StrAccessDenied</font>";
?>

View File

@@ -0,0 +1,85 @@
<?php
if (!@include_once("./incl/auth.inc.php"))
include_once("../incl/auth.inc.php");
if ($AllowView && isset($_GET['filename']))
{
$filename = stripslashes($_GET['filename']);
print "<table class='index' width=800 cellpadding=0 cellspacing=0>";
print "<tr>";
print "<td class='iheadline' height=21>";
print "<font class='iheadline'>&nbsp;$StrViewing \"".htmlentities($filename)."\" $StrAt ".$_GET['size']."%</font>";
print "</td>";
print "<td class='iheadline' align='right' height=21>";
print "<font class='iheadline'><a href='$base_url&amp;path=".htmlentities(rawurlencode($path))."'><img src='icon/back.gif' border=0 alt='$StrBack'></a></font>";
print "</td>";
print "</tr>";
print "<tr>";
print "<td valign='top' colspan=2>";
print "<center><br />";
if (is_file($home_directory.$path.$filename) && is_viewable_file($filename))
{
$image_info = GetImageSize($home_directory.$path.$filename);
$size = $_GET['size'];
$zoom_in = $ZoomArray[get_current_zoom_level($size, 1)];
$zoom_out = $ZoomArray[get_current_zoom_level($size, -1)];
$width = $image_info[0] * $size / 100;
$height = $image_info[1] * $size / 100;
$files = array();
if ($open = opendir($home_directory.$path))
{
while ($file = readdir($open))
if (is_file($home_directory.$path.$file) && is_viewable_file($file))
$files[] = $file;
closedir($open);
sort($files);
if (count($files)>1)
{
for($i=0;$files[$i]!=$filename;$i++);
if ($i==0) $prev = $files[$i+count($files)-1];
else $prev = $files[$i-1];
if ($i==(count($files)-1)) $next = $files[$i-count($files)+1];
else $next = $files[$i+1];
}
else
{
$prev = $filename;
$next = $filename;
}
}
print "<table class='menu' cellpadding=2 cellspacing=0>";
print "<tr>";
print "<td align='center' valign='bottom'><a href='$base_url&amp;path=".htmlentities(rawurlencode($path))."&amp;filename=".htmlentities(rawurlencode($filename))."&amp;action=view&amp;size=$zoom_in'><img src='icon/plus.gif' width=11 height=11 border=0 alt='$StrZoomIn'>&nbsp;$StrZoomIn</a></td>";
print "<td align='center' valign='bottom'><a href='$base_url&amp;path=".htmlentities(rawurlencode($path))."&amp;filename=".htmlentities(rawurlencode($filename))."&amp;action=view&amp;size=$zoom_out'><img src='icon/minus.gif' width=11 height=11 border=0 alt='$StrZoomOut'>&nbsp;$StrZoomOut</a></td>";
print "<td align='center' valign='bottom'><a href='$base_url&amp;path=".htmlentities(rawurlencode($path))."&amp;filename=".htmlentities(rawurlencode($filename))."&amp;action=view&amp;size=100'><img src='icon/original.gif' width=11 height=11 border=0 alt='$StrOriginalSize'>&nbsp;$StrOriginalSize</a></td>";
print "<td align='center' valign='bottom'><a href='$base_url&amp;path=".htmlentities(rawurlencode($path))."&amp;filename=".htmlentities(rawurlencode($prev))."&amp;action=view&amp;size=$size'><img src='icon/previous.gif' width=11 height=11 border=0 alt='$StrPrevious'>&nbsp;$StrPrevious</a></td>";
print "<td align='center' valign='bottom'><a href='$base_url&amp;path=".htmlentities(rawurlencode($path))."&amp;filename=".htmlentities(rawurlencode($next))."&amp;action=view&amp;size=$size'><img src='icon/next.gif' width=11 height=11 border=0 alt='$StrNext'>&nbsp;$StrNext</a></td>";
print "</tr>";
print "</table><br />";
print "<img src='incl/libfile.php?path=".htmlentities(rawurlencode($path))."&amp;filename=".htmlentities(rawurlencode($filename))."&amp;action=view' width='$width' height='$height' alt='$StrImage'>";
}
else
{
print "<font color='#CC0000'>$StrViewFail</font><br /><br />";
print "$StrViewFailHelp";
}
print "<br /><br /></center>";
print "</td>";
print "</tr>";
print "</table>";
print "<input type='hidden' name='path' value=\"".htmlentities($path)."\">";
}
else
print "<font color='#CC0000'>$StrAccessDenied</font>";
?>