| version 1.27, 2002/07/23 20:22:22 |
version 1.28, 2002/08/03 23:41:49 |
|
|
| /* |
/* |
| * phpWebFileManager - simple file management PHP script |
* phpWebFileManager - simple file management PHP script |
| * |
* |
| * phpWebFileManager.php - main script file |
* index.php - main script file |
| * ____________________________________________________________ |
* ____________________________________________________________ |
| * |
* |
| * Developed by Ondrej Jombik <nepto@pobox.sk> |
* Developed by Ondrej Jombik <nepto@pobox.sk> |
|
|
| * Config file is read from init.inc.php file. |
* Config file is read from init.inc.php file. |
| */ |
*/ |
| |
|
| $phpWebFileManager_INIT_FILE = dirname(__FILE__) |
$fm_init_file = dirname(__FILE__) |
| . (strlen(dirname(__FILE__)) > 0 ? '/' : '') |
. (strlen(dirname(__FILE__)) > 0 ? '/' : '') |
| . 'init.inc.php'; |
. 'init.inc.php'; |
| |
|
| if (! @file_exists($phpWebFileManager_INIT_FILE)) { |
if (! @file_exists($fm_init_file)) { |
| exit; |
exit; |
| } |
} |
| |
|
| require_once $phpWebFileManager_INIT_FILE; |
require_once $fm_init_file; |
| |
|
| /* |
/* |
| * Libraries function inclusion |
* Libraries function inclusion |
| Line 55 function fm_echo_message($message) |
|
| Line 55 function fm_echo_message($message) |
|
| echo "<small>$message</small>"; |
echo "<small>$message</small>"; |
| } |
} |
| |
|
| |
function fm_get_cgi_var($name, $default_value = null) |
| |
{ |
| |
global $HTTP_GET_VARS; |
| |
$var = $HTTP_GET_VARS[$name]; |
| |
|
| /* |
if (! isset($var)) { |
| * Main job |
global $HTTP_POST_VARS; |
| */ |
$var = $HTTP_POST_VARS[$name]; |
| |
} |
| |
|
| |
if (isset($var)) { |
| |
$var = stripslashes($var); |
| |
} else { |
| |
$var = $default_value; |
| |
} |
| |
|
| /* Hidden parameters */ |
return $var; |
| $fm_origvars = append_slash($fm_cfg['origvars'], '&'); |
|
| $fm_cfg['url'] = append_slash($fm_cfg['url']); |
|
| $fm_cfg['dir']['root'] = append_slash($fm_cfg['dir']['root']); |
|
| if (strlen($fm_cfg['format']['date']) <= 0) { |
|
| $fm_cfg['format']['date'] = _FM_DATE_FORMAT; |
|
| } |
} |
| |
|
| |
|
| /* |
/* |
| * Striping slashes. |
* Main phpWebFileManager function |
| */ |
*/ |
| |
|
| $fm_action = isset($fm_action) ? stripslashes($fm_action) : ''; |
function fm_main() |
| $submit = isset($submit) ? stripslashes($submit) : ''; |
{ |
| $fm_dir = isset($fm_dir) ? stripslashes($fm_dir) : ''; |
global $fm_cfg; |
| $fm_filename = isset($fm_filename) ? stripslashes($fm_filename) : ''; |
global $HTTP_SERVER_VARS; |
| $fm_new_filename = isset($fm_new_filename) |
|
| ? stripslashes($fm_new_filename) : ''; |
|
| |
|
| /* |
/* Hidden parameters */ |
| * Symlink detection (must be before following directory modifying). |
$fm_origvars = append_slash($fm_cfg['origvars'], '&'); |
| */ |
$fm_cfg['url'] = append_slash($fm_cfg['url']); |
| |
$fm_cfg['dir']['root'] = append_slash($fm_cfg['dir']['root']); |
| |
if (strlen($fm_cfg['format']['date']) <= 0) { |
| |
$fm_cfg['format']['date'] = _FM_DATE_FORMAT; |
| |
} |
| |
|
| if (! $fm_cfg['perm']['dir']['follow_symlinks']) { |
/* |
| $fm_test_symlink = $fm_dir; |
* Getting CGI variables |
| |
*/ |
| |
$fm_action = fm_get_cgi_var('fm_action', ''); |
| |
$submit = fm_get_cgi_var('submit', ''); |
| |
$fm_dir = fm_get_cgi_var('fm_dir', ''); |
| |
$fm_filename = fm_get_cgi_var('fm_filename', ''); |
| |
$fm_new_filename = fm_get_cgi_var('fm_new_filename', ''); |
| |
$fm_file_data = fm_get_cgi_var('fm_file_data', ''); |
| |
$PHP_SELF = $HTTP_SERVER_VARS['PHP_SELF']; |
| |
|
| while ($fm_test_symlink != '') { |
/* |
| if ((@file_exists($fm_test_symlink) && @is_link($fm_test_symlink)) |
* Debugging CGI varaibles |
| || (@file_exists($fm_test_symlink) && @is_link("$fm_test_symlink/"))) { |
*/ |
| $fm_dir = $fm_cfg['dir']['start']; |
if (0) { |
| break; |
echo '<hr><pre>'; |
| |
foreach (array('fm_action', 'submit', 'fm_dir', 'fm_filename', 'fm_new_filename', 'fm_file_data') as $var_name) { |
| |
echo htmlspecialchars(str_pad($var_name, 15).' = '.$$var_name)."\n"; |
| } |
} |
| |
echo '</pre><hr>'; |
| $fm_test_symlink = substr($fm_test_symlink, |
|
| 0, intval(strrpos($fm_test_symlink, '/'))); |
|
| } |
} |
| } |
|
| |
|
| if (! isset($fm_dir) || ! $fm_cfg['perm']['dir']['enter']) { |
/* |
| $fm_dir = $fm_cfg['dir']['start']; |
* Symlink detection (must be before following directory modifying) |
| } |
*/ |
| |
|
| /* |
if (! $fm_cfg['perm']['dir']['follow_symlinks']) { |
| * Directory modifying. Dirty, but safe. |
$fm_test_symlink = $fm_dir; |
| */ |
|
| |
|
| $fm_dir = preg_replace('/\/\/+/','/', "$fm_dir/"); |
while ($fm_test_symlink != '') { |
| $fm_dir = preg_replace("/^(|.*\/)\.\.\/([^\.\/][^\.\/]|[^\/][^\.\/]|[^\/][^\.\/]|[^\/]{3,})\/(.*)$/", "\\1\\3", $fm_dir); |
if ((@file_exists($fm_test_symlink) && @is_link($fm_test_symlink)) |
| $fm_dir = preg_replace("/^(|.*\/)([^\/\.][^\.\/]|[^\/][^\.\/]|[^\/][^\.\/]|[^\/]{3,})\/\.\.\/(.*)$/", "\\1\\3", $fm_dir); |
|| (@file_exists($fm_test_symlink) && @is_link("$fm_test_symlink/"))) { |
| |
$fm_dir = $fm_cfg['dir']['start']; |
| |
break; |
| |
} |
| |
|
| while (preg_match("/^(|.*\/)\.\.\/(.*)$/", $fm_dir)) { |
$fm_test_symlink = substr($fm_test_symlink, |
| $fm_dir = preg_replace("/^(|.*\/)\.\.\/(.*)$/", "\\1\\2", $fm_dir); |
0, intval(strrpos($fm_test_symlink, '/'))); |
| } |
} |
| while (strlen($fm_dir) > 0 && $fm_dir[0] == '/') { |
} |
| $fm_dir = substr($fm_dir, 1, strlen($fm_dir)); |
|
| } |
|
| |
|
| /* |
if (! isset($fm_dir) || ! $fm_cfg['perm']['dir']['enter']) { |
| * Change to root directory. |
$fm_dir = $fm_cfg['dir']['start']; |
| */ |
} |
| |
|
| /* Store the starting working directory. */ |
/* |
| $fm_orig_dir = getcwd(); |
* Directory modifying. Dirty, but safe. |
| |
*/ |
| |
|
| if (@is_dir($fm_cfg['dir']['root'])) { |
$fm_dir = preg_replace('/\/\/+/','/', "$fm_dir/"); |
| chdir($fm_cfg['dir']['root']); |
$fm_dir = preg_replace('/^(|.*\/)\.\.\/([^\.\/][^\.\/]|[^\/][^\.\/]|[^\/][^\.\/]|[^\/]{3,})\/(.*)$/', '\\1\\3', $fm_dir); |
| } |
$fm_dir = preg_replace('/^(|.*\/)([^\/\.][^\.\/]|[^\/][^\.\/]|[^\/][^\.\/]|[^\/]{3,})\/\.\.\/(.*)$/', '\\1\\3', $fm_dir); |
| |
|
| $fm_root_dir = getcwd(); |
while (preg_match('/^(|.*\/)\.\.\/(.*)$/', $fm_dir)) { |
| |
$fm_dir = preg_replace('/^(|.*\/)\.\.\/(.*)$/', '\\1\\2', $fm_dir); |
| |
} |
| |
while (strlen($fm_dir) > 0 && $fm_dir[0] == '/') { |
| |
$fm_dir = substr($fm_dir, 1, strlen($fm_dir)); |
| |
} |
| |
|
| if (@file_exists($fm_dir) && @is_dir($fm_dir)) { |
/* |
| chdir($fm_dir); |
* Change to root directory. |
| |
*/ |
| |
|
| /* On some *BSD systems with PHP version <= 4.0.6 |
/* Store the starting working directory. */ |
| function chdir() is removing last '/' character |
$fm_orig_dir = getcwd(); |
| in $fm_dir variable, so we must improve it. */ |
|
| $fm_dir = append_slash($fm_dir); |
|
| } |
|
| else { |
|
| $fm_dir = ''; |
|
| } |
|
| |
|
| /* |
if (@is_dir($fm_cfg['dir']['root'])) { |
| * Prepare URL & HTML encode of some variables. |
chdir($fm_cfg['dir']['root']); |
| */ |
} |
| |
|
| $fm_filename_he = htmlentities($fm_filename); |
$fm_root_dir = getcwd(); |
| $fm_filename_he2 = str_replace(' ', ' ', $fm_filename_he); |
|
| //$fm_filename_ue = htmlentities(rawurlencode($fm_filename)); |
|
| $fm_dir_he = htmlentities($fm_dir); |
|
| $fm_dir_he2 = str_replace(' ', ' ', $fm_dir_he); |
|
| $fm_dir_ue = htmlentities(rawurlencode($fm_dir)); |
|
| $PHP_SELF_origvars_ue = htmlentities("$PHP_SELF?$fm_origvars"); |
|
| |
|
| /* |
if (@file_exists($fm_dir) && @is_dir($fm_dir)) { |
| * Title writting with current working direcotry information. |
chdir($fm_dir); |
| */ |
|
| |
|
| if (defined('LOADED_AS_MODULE')) { |
/* On some *BSD systems with PHP version <= 4.0.6 |
| OpenTable(); |
function chdir() is removing last '/' character |
| echo '<font class="pn-title">'._FM_FILE_MANAGER |
in $fm_dir variable, so we must improve it. */ |
| . (strlen($fm_dir) > 0 ? ": $fm_dir_he" : '') |
$fm_dir = append_slash($fm_dir); |
| . '</font>'; |
} else { |
| CloseTable(); |
$fm_dir = ''; |
| OpenTable(); |
} |
| } |
|
| else { |
|
| if (strlen($fm_dir) > 0) |
|
| echo "<h3>$fm_dir_he2</h3>"; |
|
| } |
|
| |
|
| /* |
/* |
| * Form |
* Prepare URL & HTML encode of some variables. |
| */ |
*/ |
| |
|
| echo '<form enctype="multipart/form-data" method=post' |
$fm_filename_he = htmlentities($fm_filename); |
| . ' action="' . htmlentities($PHP_SELF) . '">'; |
$fm_filename_he2 = str_replace(' ', ' ', $fm_filename_he); |
| |
//$fm_filename_ue = htmlentities(rawurlencode($fm_filename)); |
| |
$fm_dir_he = htmlentities($fm_dir); |
| |
$fm_dir_he2 = str_replace(' ', ' ', $fm_dir_he); |
| |
$fm_dir_ue = htmlentities(rawurlencode($fm_dir)); |
| |
$PHP_SELF_origvars_ue = htmlentities("$PHP_SELF?$fm_origvars"); |
| |
|
| write_origvars_html($fm_origvars); |
/* |
| |
* Title writting with current working direcotry information. |
| |
*/ |
| |
|
| echo '<input type=hidden value="'.$fm_filename_he.'" name="fm_filename">'; |
if (defined('LOADED_AS_MODULE')) { |
| echo '<input type=hidden value="'.$fm_dir_he.'" name="fm_dir">'; |
OpenTable(); |
| |
echo '<font class="pn-title">'._FM_FILE_MANAGER |
| |
. (strlen($fm_dir) > 0 ? ": $fm_dir_he" : '') |
| |
. '</font>'; |
| |
CloseTable(); |
| |
OpenTable(); |
| |
} |
| |
else { |
| |
if (strlen($fm_dir) > 0) |
| |
echo "<h3>$fm_dir_he2</h3>"; |
| |
} |
| |
|
| /* PN: PostNuke module calls */ |
/* |
| if (defined('LOADED_AS_MODULE')) { |
* Form |
| echo '<input type=hidden name="op" value="modload">'; |
*/ |
| echo '<input type=hidden name="name" value="'.$ModName.'">'; |
|
| echo '<input type=hidden name="file" value="index">'; |
|
| } |
|
| |
|
| /* |
echo '<form enctype="multipart/form-data" method=post' |
| * confirm delete files action |
. ' action="' . htmlentities($PHP_SELF) . '">'; |
| */ |
|
| if ($fm_action == "confirm_delete_file") { |
|
| echo "<input type=hidden value=delete_file name=fm_action>"; |
|
| |
|
| echo _FM_REALLY_DELETE |
write_origvars_html($fm_origvars); |
| . "<br><br><i>$fm_filename_he2</i><br><br>"; |
|
| echo $fm_dir == '' |
|
| ? _FM_FROM_ROOT_DIR . "?<br><br>" |
|
| : _FM_FROM_DIR |
|
| . "<br><br><i>$fm_dir_he2</i><br><br>"; |
|
| echo "<input type=submit name=submit value=\"" |
|
| . _FM_FILE_DELETE . "\"> " |
|
| . "<input type=submit name=submit value=\"" |
|
| . _FM_CANCEL . "\">"; |
|
| } |
|
| |
|
| /* |
echo '<input type=hidden value="'.$fm_filename_he.'" name="fm_filename">'; |
| * confirm remove directory action |
echo '<input type=hidden value="'.$fm_dir_he.'" name="fm_dir">'; |
| */ |
|
| elseif ($fm_action == "confirm_remove_directory") { |
|
| echo "<input type=hidden value=remove_directory name=fm_action>"; |
|
| |
|
| echo _FM_REALLY_REMOVE |
/* PN: PostNuke module calls */ |
| . "<br><br><i>$fm_filename_he2</i><br><br>"; |
if (defined('LOADED_AS_MODULE')) { |
| echo _FM_MUST_BE_EMPTY . "<br><br>"; |
echo '<input type=hidden name="op" value="modload">'; |
| echo "<input type=submit name=submit value=\"" |
echo '<input type=hidden name="name" value="'.$ModName.'">'; |
| . _FM_DIR_REMOVE . "\"> " |
echo '<input type=hidden name="file" value="index">'; |
| . "<input type=submit name=submit value=\"" |
} |
| . _FM_CANCEL . "\">"; |
|
| } |
|
| |
|
| /* |
switch ($fm_action) { |
| * confirm rename files action and confirm rename directory action |
|
| */ |
|
| elseif ($fm_action == "confirm_rename_file" |
|
| || $fm_action == "confirm_rename_directory") { |
|
| echo "<input type=hidden value=\""; |
|
| echo $fm_action == "confirm_rename_directory" |
|
| ? "rename_directory" : "rename_file"; |
|
| echo "\" name=fm_action>"; |
|
| |
|
| echo _FM_RENAME_FROM |
|
| . "<br><br><i>$fm_filename_he2</i><br><br>" |
|
| . _FM_RENAME_TO |
|
| . "<br><br>"; |
|
| echo "<input type=text value=\"\" name=fm_new_filename><br><br>"; |
|
| echo "<input type=submit name=submit value=\"" |
|
| . ($fm_action == "confirm_rename_directory" |
|
| ? _FM_DIR_RENAME : _FM_FILE_RENAME) |
|
| . "\"> " |
|
| . "<input type=submit name=submit value=\"" |
|
| . _FM_CANCEL . "\">"; |
|
| } |
|
| |
|
| /* |
/* |
| * confirm create directory and confirm create file actions |
* confirm delete files action |
| */ |
*/ |
| elseif ($fm_action == "confirm_create_directory" |
case 'confirm_delete_file': |
| || $fm_action == "confirm_create_file") { |
echo '<input type=hidden value=delete_file name=fm_action>'; |
| echo "<input type=hidden value="; |
|
| echo $fm_action == "confirm_create_directory" |
echo _FM_REALLY_DELETE |
| ? "create_directory" : "create_file"; |
. "<br><br><i>$fm_filename_he2</i><br><br>"; |
| echo " name=fm_action>"; |
echo $fm_dir == '' |
| |
? _FM_FROM_ROOT_DIR . "?<br><br>" |
| echo _FM_ENTER_NAME . ":<br><br>"; |
: _FM_FROM_DIR |
| echo "<input type=text value=\"\" name=fm_new_filename><br><br>"; |
. "<br><br><i>$fm_dir_he2</i><br><br>"; |
| echo "<input type=submit name=submit value=\"" |
echo "<input type=submit name=submit value=\"" |
| . ($fm_action == "confirm_create_directory" |
. _FM_FILE_DELETE . "\"> " |
| ? _FM_DIR_CREATE : _FM_FILE_CREATE) |
. "<input type=submit name=submit value=\"" |
| . "\"> " |
. _FM_CANCEL . "\">"; |
| . "<input type=submit name=submit value=\"" |
break; |
| . _FM_CANCEL . "\">"; |
|
| } |
|
| |
|
| /* |
/* |
| * confirm upload file action |
* confirm remove directory action |
| */ |
*/ |
| elseif ($fm_action == "confirm_upload_file") { |
case 'confirm_remove_directory': |
| echo "<input type=hidden value=\"upload_file\" name=fm_action>"; |
echo '<input type=hidden value=remove_directory name=fm_action>'; |
| |
|
| |
echo _FM_REALLY_REMOVE |
| |
. "<br><br><i>$fm_filename_he2</i><br><br>"; |
| |
echo _FM_MUST_BE_EMPTY . "<br><br>"; |
| |
echo "<input type=submit name=submit value=\"" |
| |
. _FM_DIR_REMOVE . "\"> " |
| |
. "<input type=submit name=submit value=\"" |
| |
. _FM_CANCEL . "\">"; |
| |
break; |
| |
|
| echo _FM_SELECT_LOCAL . ":<br><br>"; |
/* |
| echo "<input type=file value=\"\" name=fm_userfile><br><br>"; |
* confirm rename files action and confirm rename directory action |
| echo "<input type=submit name=submit value=\"" |
*/ |
| . _FM_FILE_UPLOAD . "\"> " |
case 'confirm_rename_file': |
| . "<input type=submit name=submit value=\"" |
case 'confirm_rename_directory': |
| . _FM_CANCEL . "\">"; |
echo "<input type=hidden value=\""; |
| } |
echo $fm_action == "confirm_rename_directory" |
| |
? "rename_directory" : "rename_file"; |
| |
echo "\" name=fm_action>"; |
| |
|
| |
echo _FM_RENAME_FROM |
| |
. "<br><br><i>$fm_filename_he2</i><br><br>" |
| |
. _FM_RENAME_TO |
| |
. "<br><br>"; |
| |
echo "<input type=text value=\"\" name=fm_new_filename><br><br>"; |
| |
echo "<input type=submit name=submit value=\"" |
| |
. ($fm_action == "confirm_rename_directory" |
| |
? _FM_DIR_RENAME : _FM_FILE_RENAME) |
| |
. "\"> " |
| |
. "<input type=submit name=submit value=\"" |
| |
. _FM_CANCEL . "\">"; |
| |
break; |
| |
|
| else { |
/* |
| |
* confirm create directory and confirm create file actions |
| |
*/ |
| |
case 'confirm_create_directory': |
| |
case 'confirm_create_file': |
| |
echo "<input type=hidden value="; |
| |
echo $fm_action == "confirm_create_directory" |
| |
? "create_directory" : "create_file"; |
| |
echo " name=fm_action>"; |
| |
|
| |
echo _FM_ENTER_NAME . ":<br><br>"; |
| |
echo "<input type=text value=\"\" name=fm_new_filename><br><br>"; |
| |
echo "<input type=submit name=submit value=\"" |
| |
. ($fm_action == "confirm_create_directory" |
| |
? _FM_DIR_CREATE : _FM_FILE_CREATE) |
| |
. "\"> " |
| |
. "<input type=submit name=submit value=\"" |
| |
. _FM_CANCEL . "\">"; |
| |
break; |
| |
|
| /* |
/* |
| * delete action |
* confirm upload file action |
| */ |
*/ |
| if ($fm_action == 'delete_file' && $fm_cfg['perm']['file']['delete']) { |
case 'confirm_upload_file': |
| if ($submit == _FM_FILE_DELETE) { |
echo '<input type=hidden value="upload_file" name=fm_action>'; |
| if (@unlink($fm_filename) == false) |
|
| fm_echo_message(_FM_FILE_DELETE_ERR); |
echo _FM_SELECT_LOCAL . ':<br><br>'; |
| else |
echo '<input type=file value="" name=fm_userfile><br><br>'; |
| fm_echo_message(_FM_FILE_DELETE_OK); |
echo '<input type=submit name=submit value="' |
| } |
. _FM_FILE_UPLOAD . '"> ' |
| else fm_echo_message(_FM_CANCELED); |
. '<input type=submit name=submit value="' |
| echo '<br><br>'; |
. _FM_CANCEL . '">'; |
| } |
break; |
| |
|
| /* |
/* |
| * remove direcotry |
* confirm edit file and edit file form |
| */ |
*/ |
| if ($fm_action == 'remove_directory' && $fm_cfg['perm']['dir']['remove']) { |
case 'confirm_edit_file': |
| if ($submit == _FM_DIR_REMOVE) { |
if (is_readable($fm_filename) && is_writeable($fm_filename)) { |
| if (@rmdir($fm_filename) == 0) |
// TODO: |
| fm_echo_message(_FM_DIR_REMOVE_ERR); |
// 1. check file type - if binary, ask if really edit |
| else |
// 2. check file size - if too big, ask if really edit |
| fm_echo_message(_FM_DIR_REMOVE_OK); |
echo '<input type=hidden value="edit_file" name=fm_action>'; |
| } |
|
| else fm_echo_message(_FM_CANCELED); |
echo _FM_REALLY_EDIT |
| echo '<br><br>'; |
. "<br><br><i>$fm_filename_he2</i><br><br>"; |
| } |
echo $fm_dir == '' |
| |
? _FM_IN_ROOT_DIR . "?<br><br>" |
| |
: _FM_IN_DIR |
| |
. "<br><br><i>$fm_dir_he2</i><br><br>"; |
| |
echo "<input type=submit name=submit value=\"" |
| |
. _FM_FILE_EDIT . "\"> " |
| |
. "<input type=submit name=submit value=\"" |
| |
. _FM_CANCEL . "\">"; |
| |
break; |
| |
} |
| |
case 'edit_file': |
| |
if (is_readable($fm_filename) && is_writeable($fm_filename)) { |
| |
if ($submit == _FM_FILE_EDIT) { |
| |
echo '<input type=hidden value="save_file" name=fm_action>'; |
| |
// Please write me, if you want to have cols and rows configurable. |
| |
echo '<textarea name="fm_file_data" cols=50 rows=15>'; |
| |
htmlentities(@readfile($fm_filename)); |
| |
echo '</textarea><br><br>'; |
| |
echo '<input type=submit name=submit value="' |
| |
. _FM_FILE_SAVE . '"> ' |
| |
. '<input type=submit name=submit value="' |
| |
. _FM_CANCEL . '">'; |
| |
break; |
| |
} else fm_echo_message(_FM_CANCELED); |
| |
} else { |
| |
fm_echo_message(_FM_FILE_EDIT_ERR); |
| |
} |
| |
|
| /* |
echo '<br><br>'; |
| * rename action |
|
| */ |
|
| if (($fm_action == 'rename_directory' && $fm_cfg['perm']['dir']['rename']) |
|
| || ($fm_action == 'rename_file' && $fm_cfg['perm']['file']['rename'])) { |
|
| if ($fm_new_filename != '' && |
|
| (($submit == _FM_DIR_RENAME && $fm_action == "rename_directory") |
|
| || ($submit == _FM_FILE_RENAME && $fm_action == 'rename_file') |
|
| )) { |
|
| if (@rename($fm_filename, $fm_new_filename) == false) |
|
| fm_echo_message(_FM_RENAME_ERR); |
|
| else |
|
| fm_echo_message(_FM_RENAME_OK); |
|
| } |
|
| else fm_echo_message(_FM_CANCELED); |
|
| echo '<br><br>'; |
|
| } |
|
| |
|
| /* |
default: |
| * create directory and create file actions |
|
| */ |
|
| if (($fm_action == 'create_directory' && $fm_cfg['perm']['dir']['create']) |
|
| || ($fm_action == 'create_file' && $fm_cfg['perm']['file']['create'])) { |
|
| if ($fm_new_filename != '' && |
|
| (($submit == _FM_DIR_CREATE && $fm_action == 'create_directory') |
|
| || ($submit == _FM_FILE_CREATE && $fm_action == 'create_file')) |
|
| ) { |
|
| if ($fm_action == 'create_directory') { |
|
| if (@mkdir($fm_new_filename, $fm_cfg['mode']['dir']) == false) |
|
| fm_echo_message(_FM_DIR_CREATE_ERR); |
|
| else |
|
| fm_echo_message(_FM_DIR_CREATE_OK); |
|
| } |
|
| else { |
|
| if (file_exists($fm_new_filename)) |
|
| fm_echo_message(_FM_FILE_CREATE_ERR1); |
|
| else { |
|
| if (($fh = @fopen($fm_new_filename, "w")) == false) |
|
| fm_echo_message($phpWebFileManager_LANG[file_create_err2]); |
|
| else { |
|
| fclose($fh); |
|
| fm_echo_message(_FM_FILE_CREATE_OK); |
|
| |
|
| if ($fm_cfg['mode']['file'] != 0) { |
/* |
| if (@chmod($fm_new_filename, $fm_cfg['mode']['file']) == false) |
* save action |
| fm_echo_message(' '. _chmod_err); |
*/ |
| else |
if ($fm_action == 'save_file' && $fm_cfg['perm']['file']['save']) { |
| fm_echo_message(' '. _chmod_ok); |
if ($submit == _FM_FILE_SAVE) { |
| } |
if($fp = @fopen($fm_filename, 'w')) { |
| |
flock($fp, 2); |
| |
fwrite($fp, $fm_file_data, strlen($fm_file_data)); |
| |
flock($fp, 3); |
| |
fclose($fp); |
| |
fm_echo_message(_FM_FILE_SAVE_OK); |
| |
} else { |
| |
fm_echo_message(_FM_FILE_SAVE_ERR); |
| } |
} |
| } |
} |
| |
else fm_echo_message(_FM_CANCELED); |
| |
echo '<br><br>'; |
| } |
} |
| } |
|
| else fm_echo_message(_FM_CANCELED); |
|
| echo '<br><br>'; |
|
| } |
|
| |
|
| /* |
/* |
| * file upload action |
* delete action |
| */ |
*/ |
| if ($fm_action == 'upload_file' && $fm_cfg['perm']['file']['upload']) { |
if ($fm_action == 'delete_file' && $fm_cfg['perm']['file']['delete']) { |
| if ($submit == _FM_FILE_UPLOAD && $fm_userfile_name != '') { |
if ($submit == _FM_FILE_DELETE) { |
| |
if (@unlink($fm_filename) == false) |
| $tmp_target_filename = $target_filename = $fm_userfile_name; |
fm_echo_message(_FM_FILE_DELETE_ERR); |
| |
else |
| $i = 2; |
fm_echo_message(_FM_FILE_DELETE_OK); |
| while (file_exists($tmp_target_filename)) { |
|
| if ($i == 2) { |
|
| fm_echo_message(_FM_FILENAME_CHANGED); |
|
| echo '<br>'; |
|
| } |
} |
| $tmp_target_filename = $target_filename . '-' . $i; |
else fm_echo_message(_FM_CANCELED); |
| $i++; |
echo '<br><br>'; |
| } |
} |
| |
|
| $target_filename = $tmp_target_filename; |
/* |
| |
* remove direcotry |
| //echo("fm_userfile = $fm_userfile<br>"); |
*/ |
| //echo("fm_userfile_name = $fm_userfile_name<br>"); |
if ($fm_action == 'remove_directory' && $fm_cfg['perm']['dir']['remove']) { |
| //echo("target_filename = $target_filename<br>"); |
if ($submit == _FM_DIR_REMOVE) { |
| |
if (@rmdir($fm_filename) == 0) |
| if (@copy($fm_userfile, $target_filename)) { |
fm_echo_message(_FM_DIR_REMOVE_ERR); |
| |
|
| fm_echo_message(_FM_FILE_UPLOAD_OK); |
|
| |
|
| if ($fm_cfg['mode']['file'] != 0) { |
|
| if (@chmod($target_filename, $fm_cfg['mode']['file']) == false) |
|
| fm_echo_message(' '._FM_CHMOD_ERR); |
|
| else |
else |
| fm_echo_message(' '._FM_CHMOD_OK); |
fm_echo_message(_FM_DIR_REMOVE_OK); |
| } |
} |
| |
else fm_echo_message(_FM_CANCELED); |
| |
echo '<br><br>'; |
| } |
} |
| else |
|
| fm_echo_message(_FM_FILE_UPLOAD_ERR); |
|
| } |
|
| else fm_echo_message(_FM_CANCELED); |
|
| |
|
| echo '<br><br>'; |
|
| } |
|
| |
|
| |
|
| echo '<table cellpadding="2" class=phpWebFileManager>'; |
/* |
| |
* rename action |
| |
*/ |
| |
if (($fm_action == 'rename_directory' && $fm_cfg['perm']['dir']['rename']) |
| |
|| ($fm_action == 'rename_file' && $fm_cfg['perm']['file']['rename'])) { |
| |
if ($fm_new_filename != '' && |
| |
(($submit == _FM_DIR_RENAME && $fm_action == "rename_directory") |
| |
|| ($submit == _FM_FILE_RENAME && $fm_action == 'rename_file') |
| |
)) { |
| |
if (@rename($fm_filename, $fm_new_filename) == false) |
| |
fm_echo_message(_FM_RENAME_ERR); |
| |
else |
| |
fm_echo_message(_FM_RENAME_OK); |
| |
} |
| |
else fm_echo_message(_FM_CANCELED); |
| |
echo '<br><br>'; |
| |
} |
| |
|
| $line = 0; |
/* |
| |
* create directory and create file actions |
| |
*/ |
| |
if (($fm_action == 'create_directory' && $fm_cfg['perm']['dir']['create']) |
| |
|| ($fm_action == 'create_file' && $fm_cfg['perm']['file']['create'])) { |
| |
if ($fm_new_filename != '' && |
| |
(($submit == _FM_DIR_CREATE && $fm_action == 'create_directory') |
| |
|| ($submit == _FM_FILE_CREATE && $fm_action == 'create_file')) |
| |
) { |
| |
if ($fm_action == 'create_directory') { |
| |
if (@mkdir($fm_new_filename, $fm_cfg['mode']['dir']) == false) { |
| |
fm_echo_message(_FM_DIR_CREATE_ERR); |
| |
} else { |
| |
fm_echo_message(_FM_DIR_CREATE_OK); |
| |
} |
| |
} |
| |
else { |
| |
if (file_exists($fm_new_filename)) |
| |
fm_echo_message(_FM_FILE_CREATE_ERR1); |
| |
else { |
| |
if (($fh = @fopen($fm_new_filename, "w")) == false) { |
| |
fm_echo_message($phpWebFileManager_LANG[file_create_err2]); |
| |
} else { |
| |
fclose($fh); |
| |
fm_echo_message(_FM_FILE_CREATE_OK); |
| |
|
| |
if ($fm_cfg['mode']['file'] != 0) { |
| |
if (@chmod($fm_new_filename, $fm_cfg['mode']['file']) == false) { |
| |
fm_echo_message(' '. _FM_CHMOD_ERR); |
| |
} else { |
| |
fm_echo_message(' '. _FM_CHMOD_OK); |
| |
} |
| |
} |
| |
} |
| |
} |
| |
} |
| |
} |
| |
else fm_echo_message(_FM_CANCELED); |
| |
echo '<br><br>'; |
| |
} |
| |
|
| if (strlen(getcwd()) > strlen($fm_root_dir)) { |
/* |
| echo '<tr valign=middle'; |
* file upload action |
| if (! empty($fm_cfg['color']['odd'])) |
*/ |
| echo ' bgcolor="'.$fm_cfg['color']['odd'].'"'; |
if ($fm_action == 'upload_file' && $fm_cfg['perm']['file']['upload']) { |
| echo '>'; |
if ($submit == _FM_FILE_UPLOAD && $fm_userfile_name != '') { |
| |
|
| |
$tmp_target_filename = $target_filename = $fm_userfile_name; |
| |
|
| |
$i = 2; |
| |
while (file_exists($tmp_target_filename)) { |
| |
if ($i == 2) { |
| |
fm_echo_message(_FM_FILENAME_CHANGED); |
| |
echo '<br>'; |
| |
} |
| |
$tmp_target_filename = $target_filename . '-' . $i; |
| |
$i++; |
| |
} |
| |
|
| echo "<td align=center>" |
$target_filename = $tmp_target_filename; |
| . "<a href=\"$PHP_SELF_origvars_ue" . "fm_dir=$fm_dir_ue..\">" |
|
| . "<img alt=\"" . _FM_BACK |
|
| . "\" border=0 src=\"" |
|
| . (defined('LOADED_AS_MODULE') ? "modules/$ModName/" : '') |
|
| . "icons/back.gif\"></a>" . "</td>"; |
|
| |
|
| echo "<td width=\"100%\" colspan=\"6\">" |
//echo("fm_userfile = $fm_userfile<br>"); |
| . "<a href=\"$PHP_SELF_origvars_ue" . "fm_dir=$fm_dir_ue..\">" |
//echo("fm_userfile_name = $fm_userfile_name<br>"); |
| . "(" . _FM_PARENT_DIR . ")</a>" |
//echo("target_filename = $target_filename<br>"); |
| . "</td>"; |
|
| |
|
| echo "</tr>\n"; |
if (@copy($fm_userfile, $target_filename)) { |
| |
|
| $line++; |
fm_echo_message(_FM_FILE_UPLOAD_OK); |
| } |
|
| |
|
| /* |
if ($fm_cfg['mode']['file'] != 0) { |
| * Column display counting. |
if (@chmod($target_filename, $fm_cfg['mode']['file']) == false) { |
| */ |
fm_echo_message(' '._FM_CHMOD_ERR); |
| |
} else { |
| |
fm_echo_message(' '._FM_CHMOD_OK); |
| |
} |
| |
} |
| |
} |
| |
else |
| |
fm_echo_message(_FM_FILE_UPLOAD_ERR); |
| |
} |
| |
else fm_echo_message(_FM_CANCELED); |
| |
|
| $rename_column = $fm_cfg['perm']['dir']['rename'] |
echo '<br><br>'; |
| || $fm_cfg['perm']['file']['rename']; |
} |
| $delete_column = $fm_cfg['perm']['dir']['remove'] |
|
| || $fm_cfg['perm']['file']['delete']; |
|
| $view_column = $fm_cfg['perm']['dir']['enter'] |
|
| || $fm_cfg['perm']['file']['view']; |
|
| $last_row = $fm_cfg['perm']['dir']['create'] |
|
| || $fm_cfg['perm']['file']['create'] |
|
| || $fm_cfg['perm']['file']['upload']; |
|
| |
|
| /* |
|
| * Two steps for() loop. |
|
| * One for directories and one for files. |
|
| */ |
|
| for ($k = 0; $k < 2; $k++) { |
|
| |
|
| $d = dir('./'); |
echo '<table cellpadding="2" class=phpWebFileManager>'; |
| |
|
| /* Order in alphabetical order. */ |
$line = 0; |
| $listing = array(); |
|
| while ($entry = $d->read()) |
|
| array_push($listing, $entry); |
|
| sort($listing); |
|
| |
|
| while ($entry = array_shift($listing)) { |
|
| $entry_he = htmlentities($entry); |
|
| $entry_he2 = str_replace(' ', ' ', $entry_he); |
|
| $entry_ue = htmlentities(rawurlencode($entry)); |
|
| |
|
| // Dirty fastfix by Asbjørn Værnes <avaernes@online.no> |
|
| $entry_ue = str_replace('ö', '%F6', $entry_ue); |
|
| $entry_ue = str_replace('æ', '%E6', $entry_ue); |
|
| $entry_ue = str_replace('ø', '%F8', $entry_ue); |
|
| $entry_ue = str_replace('å', '%E5', $entry_ue); |
|
| $entry_ue = str_replace('&Aelig;', '%C6', $entry_ue); |
|
| $entry_ue = str_replace('Ø', '%D8', $entry_ue); |
|
| $entry_ue = str_replace('Å', '%C5', $entry_ue); |
|
| |
|
| if ($entry != '.' && $entry != '..' && |
|
| (($k == 0 && is_dir($entry)) |
|
| || ($k == 1 && ! is_dir($entry)))) { |
|
| |
|
| |
if (strlen(getcwd()) > strlen($fm_root_dir)) { |
| echo '<tr valign=middle'; |
echo '<tr valign=middle'; |
| $line++; |
if (! empty($fm_cfg['color']['odd'])) |
| if ($line % 2) { |
echo ' bgcolor="'.$fm_cfg['color']['odd'].'"'; |
| if (! empty($fm_cfg['color']['odd'])) |
|
| echo ' bgcolor="'.$fm_cfg['color']['odd'].'"'; |
|
| } else { |
|
| if (! empty($fm_cfg['color']['even'])) |
|
| echo ' bgcolor="'.$fm_cfg['color']['even'].'"'; |
|
| } |
|
| echo '>'; |
echo '>'; |
| |
|
| if (is_dir($entry)) { |
echo "<td align=center>" |
| if ($fm_cfg['show']['icons']) { |
. "<a href=\"$PHP_SELF_origvars_ue" . "fm_dir=$fm_dir_ue..\">" |
| echo "<td align=center>"; |
. "<img alt=\"" . _FM_BACK |
| if ($fm_cfg['perm']['dir']['enter'] && ! is_link($entry)) |
. "\" border=0 src=\"" |
| echo "<a href=\"$PHP_SELF_origvars_ue" |
. (defined('LOADED_AS_MODULE') ? "modules/$ModName/" : '') |
| . "fm_dir=$fm_dir_ue$entry_ue\">"; |
. "icons/back.gif\"></a>" . "</td>"; |
| |
|
| echo (is_link($entry) |
echo "<td width=\"100%\" colspan=\"6\">" |
| ? '<b>~</b>' |
. "<a href=\"$PHP_SELF_origvars_ue" . "fm_dir=$fm_dir_ue..\">" |
| : "<img alt=\"" . _FM_DIR |
. "(" . _FM_PARENT_DIR . ")</a>" |
| . "\" border=0 src=\"" |
. "</td>"; |
| . (defined('LOADED_AS_MODULE') |
|
| ? "modules/$ModName/" : '') |
|
| . "icons/dir.gif\">"); |
|
| |
|
| if ($fm_cfg['perm']['dir']['enter'] && ! is_link($entry)) |
|
| echo '</a>'; |
|
| |
|
| echo '</td>'; |
|
| } |
|
| |
|
| echo "<td width=\"100%\">"; |
echo "</tr>\n"; |
| |
|
| if ($fm_cfg['perm']['dir']['enter'] |
|
| && ($fm_cfg['perm']['dir']['follow_symlinks'] |
|
| || ! is_link($entry))) { |
|
| echo "<a href=\"$PHP_SELF_origvars_ue" |
|
| . "fm_dir=$fm_dir_ue$entry_ue\">" |
|
| . $entry_he2 . "</a>"; |
|
| } |
|
| else { |
|
| echo $entry_he2; |
|
| } |
|
| } |
|
| else { |
|
| if ($fm_cfg['show']['icons']) { |
|
| echo '<td align=center>'; |
|
| echo (is_link($entry) ? '<b>@</b>' : ' '); |
|
| echo '</td>'; |
|
| } |
|
| echo '<td width="100%">' . $entry_he2; |
|
| } |
|
| |
|
| echo '</td>'; |
$line++; |
| |
} |
| |
|
| if (! is_dir($entry)) { |
/* |
| if ($fm_cfg['show']['size']) { |
* Column display counting. |
| echo '<td align=right nowrap><small>'; |
*/ |
| $size = filesize($entry); |
|
| $unit = "B"; |
$rename_column = $fm_cfg['perm']['dir']['rename'] |
| if ( $size > 1073741824 ) { |
|| $fm_cfg['perm']['file']['rename']; |
| $size = round ($size / 1073741824, 1); |
$delete_column = $fm_cfg['perm']['dir']['remove'] |
| $unit = "GB"; |
|| $fm_cfg['perm']['file']['delete']; |
| } elseif ( $size > 1048576 ) { |
$view_column = $fm_cfg['perm']['dir']['enter'] |
| $size = round ($size / 1048576, 1); |
|| $fm_cfg['perm']['file']['view']; |
| $unit = "MB"; |
$edit_column = $fm_cfg['perm']['file']['edit']; |
| } elseif ( $size > 1024 ) { |
$last_row = $fm_cfg['perm']['dir']['create'] |
| $size = round ($size / 1024, 1); |
|| $fm_cfg['perm']['file']['create'] |
| $unit = "kB"; |
|| $fm_cfg['perm']['file']['upload']; |
| |
|
| |
/* |
| |
* Two steps for() loop. |
| |
* One for directories and one for files. |
| |
*/ |
| |
for ($k = 0; $k < 2; $k++) { |
| |
|
| |
$d = dir('./'); |
| |
|
| |
/* Order in alphabetical order. */ |
| |
$listing = array(); |
| |
while ($entry = $d->read()) |
| |
array_push($listing, $entry); |
| |
sort($listing); |
| |
|
| |
while ($entry = array_shift($listing)) { |
| |
$entry_he = htmlentities($entry); |
| |
$entry_he2 = str_replace(' ', ' ', $entry_he); |
| |
$entry_ue = htmlentities(rawurlencode($entry)); |
| |
|
| |
// Dirty fastfix by Asbjørn Værnes <avaernes@online.no> |
| |
$entry_ue = str_replace('ö', '%F6', $entry_ue); |
| |
$entry_ue = str_replace('æ', '%E6', $entry_ue); |
| |
$entry_ue = str_replace('ø', '%F8', $entry_ue); |
| |
$entry_ue = str_replace('å', '%E5', $entry_ue); |
| |
$entry_ue = str_replace('&Aelig;', '%C6', $entry_ue); |
| |
$entry_ue = str_replace('Ø', '%D8', $entry_ue); |
| |
$entry_ue = str_replace('Å', '%C5', $entry_ue); |
| |
|
| |
if ($entry != '.' && $entry != '..' && |
| |
(($k == 0 && is_dir($entry)) |
| |
|| ($k == 1 && ! is_dir($entry)))) { |
| |
|
| |
echo '<tr valign=middle'; |
| |
$line++; |
| |
if ($line % 2) { |
| |
if (! empty($fm_cfg['color']['odd'])) |
| |
echo ' bgcolor="'.$fm_cfg['color']['odd'].'"'; |
| |
} else { |
| |
if (! empty($fm_cfg['color']['even'])) |
| |
echo ' bgcolor="'.$fm_cfg['color']['even'].'"'; |
| } |
} |
| echo $size . ' ' . $unit; |
echo '>'; |
| echo '</small></td>'; |
|
| } |
|
| |
|
| if ($fm_cfg['show']['date']) { |
if (is_dir($entry)) { |
| echo '<td align=center nowrap><small>'; |
if ($fm_cfg['show']['icons']) { |
| echo date($fm_cfg['format']['date'], filemtime($entry)); |
echo "<td align=center>"; |
| echo '</small></td>'; |
if ($fm_cfg['perm']['dir']['enter'] && ! is_link($entry)) |
| } |
echo "<a href=\"$PHP_SELF_origvars_ue" |
| |
. "fm_dir=$fm_dir_ue$entry_ue\">"; |
| |
|
| |
echo (is_link($entry) |
| |
? '<b>~</b>' |
| |
: "<img alt=\"" . _FM_DIR |
| |
. "\" border=0 src=\"" |
| |
. (defined('LOADED_AS_MODULE') |
| |
? "modules/$ModName/" : '') |
| |
. "icons/dir.gif\">"); |
| |
|
| |
if ($fm_cfg['perm']['dir']['enter'] && ! is_link($entry)) |
| |
echo '</a>'; |
| |
|
| |
echo '</td>'; |
| |
} |
| |
|
| |
echo "<td width=\"100%\">"; |
| |
|
| |
if ($fm_cfg['perm']['dir']['enter'] |
| |
&& ($fm_cfg['perm']['dir']['follow_symlinks'] |
| |
|| ! is_link($entry))) { |
| |
echo "<a href=\"$PHP_SELF_origvars_ue" |
| |
. "fm_dir=$fm_dir_ue$entry_ue\">" |
| |
. $entry_he2 . "</a>"; |
| |
} else { |
| |
echo $entry_he2; |
| |
} |
| |
} |
| |
else { |
| |
if ($fm_cfg['show']['icons']) { |
| |
echo '<td align=center>'; |
| |
echo (is_link($entry) ? '<b>@</b>' : ' '); |
| |
echo '</td>'; |
| |
} |
| |
echo '<td width="100%">' . $entry_he2; |
| |
} |
| |
|
| if ($rename_column) { |
echo '</td>'; |
| echo "<td><small>"; |
|
| if ($fm_cfg['perm']['file']['rename']) |
|
| echo "[<a href=\"$PHP_SELF_origvars_ue" |
|
| . "fm_dir=$fm_dir_ue&" |
|
| . "fm_action=confirm_rename_file" |
|
| . "&fm_filename=$entry_ue\">" |
|
| . _FM_FILE_RENAME |
|
| . "</a>]"; |
|
| echo '</small></td>'; |
|
| } |
|
| |
|
| if ($delete_column) { |
if (! is_dir($entry)) { |
| echo '<td><small>'; |
if ($fm_cfg['show']['size']) { |
| if ($fm_cfg['perm']['file']['delete']) |
echo '<td align=right nowrap><small>'; |
| echo "[<a href=\"$PHP_SELF_origvars_ue" |
$size = filesize($entry); |
| . "fm_dir=$fm_dir_ue" |
$unit = 'B'; |
| . "&fm_action=confirm_delete_file" |
if ( $size > 1073741824 ) { |
| . "&fm_filename=$entry_ue\">" |
$size = round($size / 1073741824, 1); |
| . _FM_FILE_DELETE |
$unit = 'GB'; |
| . "</a>]"; |
} elseif ( $size > 1048576 ) { |
| echo '</small></td>'; |
$size = round($size / 1048576, 1); |
| } |
$unit = 'MB'; |
| |
} elseif ( $size > 1024 ) { |
| |
$size = round($size / 1024, 1); |
| |
$unit = 'kB'; |
| |
} |
| |
echo $size . ' ' . $unit; |
| |
echo '</small></td>'; |
| |
} |
| |
|
| |
if ($fm_cfg['show']['date']) { |
| |
echo '<td align=center nowrap><small>'; |
| |
echo date($fm_cfg['format']['date'], filemtime($entry)); |
| |
echo '</small></td>'; |
| |
} |
| |
|
| |
if ($rename_column) { |
| |
echo "<td><small>"; |
| |
if ($fm_cfg['perm']['file']['rename']) { |
| |
echo "[<a href=\"$PHP_SELF_origvars_ue" |
| |
. "fm_dir=$fm_dir_ue&" |
| |
. "fm_action=confirm_rename_file" |
| |
. "&fm_filename=$entry_ue\">" |
| |
. _FM_FILE_RENAME |
| |
. "</a>]"; |
| |
} |
| |
echo '</small></td>'; |
| |
} |
| |
|
| |
if ($delete_column) { |
| |
echo '<td><small>'; |
| |
if ($fm_cfg['perm']['file']['delete']) { |
| |
echo "[<a href=\"$PHP_SELF_origvars_ue" |
| |
. "fm_dir=$fm_dir_ue" |
| |
. "&fm_action=confirm_delete_file" |
| |
. "&fm_filename=$entry_ue\">" |
| |
. _FM_FILE_DELETE |
| |
. "</a>]"; |
| |
} |
| |
echo '</small></td>'; |
| |
} |
| |
|
| |
if ($view_column) { |
| |
echo '<td><small>'; |
| |
if ($fm_cfg['perm']['file']['view']) { |
| |
$url = parse_url('http://'.$HTTP_SERVER_VARS['HTTP_HOST'] |
| |
.$HTTP_SERVER_VARS['REQUEST_URI']); |
| |
$url['path'] = get_path_without_scriptname($url) |
| |
. (strlen($fm_cfg['url']) > 0 |
| |
? $fm_cfg['url'] : $fm_cfg['dir']['root']) |
| |
. $fm_dir_ue . $entry_ue; |
| |
unset($url['query']); |
| |
unset($url['fragment']); |
| |
|
| |
echo "[<a target=_blank href=\"" |
| |
. str_replace('%2F', '/', glue_url($url)) . "\">" |
| |
. _FM_FILE_VIEW . "</a>]"; |
| |
} |
| |
echo '</small></td>'; |
| |
} |
| |
|
| |
if ($edit_column) { |
| |
echo '<td><small>'; |
| |
if (1 || $fm_cfg['perm']['file']['edit'] |
| |
&& is_readable($fm_filename) |
| |
&& is_writeable($fm_filename)) { |
| |
echo "[<a href=\"$PHP_SELF_origvars_ue" |
| |
. "fm_dir=$fm_dir_ue" |
| |
. "&fm_action=confirm_edit_file" |
| |
. "&fm_filename=$entry_ue\">" |
| |
. _FM_FILE_EDIT |
| |
. "</a>]"; |
| |
} |
| |
echo '</small></td>'; |
| |
} |
| |
} else { |
| |
|
| |
if ($fm_cfg['show']['size']) { |
| |
echo '<td></td>'; |
| |
} |
| |
|
| |
if ($fm_cfg['show']['date']) { |
| |
echo '<td></td>'; |
| |
} |
| |
|
| |
if ($rename_column) { |
| |
echo '<td><small>'; |
| |
if ($fm_cfg['perm']['dir']['rename']) |
| |
echo "[<a href=\"$PHP_SELF_origvars_ue" |
| |
. "fm_dir=$fm_dir_ue" |
| |
. "&fm_action=confirm_rename_directory" |
| |
. "&fm_filename=$entry_ue\">" |
| |
. _FM_DIR_RENAME |
| |
. "</a>]"; |
| |
echo '</small></td>'; |
| |
} |
| |
|
| |
if ($delete_column) { |
| |
echo '<td><small>'; |
| |
if ($fm_cfg['perm']['dir']['remove']) |
| |
echo "[<a href=\"$PHP_SELF_origvars_ue" |
| |
. "fm_dir=$fm_dir_ue" |
| |
. "&fm_action=confirm_remove_directory" |
| |
. "&fm_filename=$entry_ue\">" |
| |
. _FM_DIR_REMOVE |
| |
."</a>]"; |
| |
echo '</small></td>'; |
| |
} |
| |
|
| |
if ($view_column) { |
| |
echo '<td><small>'; |
| |
if ($fm_cfg['perm']['dir']['enter'] |
| |
&& ($fm_cfg['perm']['dir']['follow_symlinks'] |
| |
|| ! is_link($entry))) |
| |
echo "[<a href=\"$PHP_SELF_origvars_ue" |
| |
. "fm_dir=$fm_dir_ue$entry_ue\">" |
| |
. _FM_DIR_ENTER |
| |
."</a>]"; |
| |
echo '</small></td>'; |
| |
} |
| |
|
| |
if ($edit_column) { |
| |
echo '<td><small> </small></td>'; |
| |
} |
| |
} |
| |
|
| $url = parse_url("http://${HTTP_HOST}${REQUEST_URI}"); |
echo "</tr>\n"; |
| $url['path'] = get_path_without_scriptname($url) |
|
| . (strlen($fm_cfg['url']) > 0 |
|
| ? $fm_cfg['url'] : $fm_cfg['dir']['root']) |
|
| . $fm_dir_ue . $entry_ue; |
|
| unset($url['query']); |
|
| unset($url['fragment']); |
|
| |
|
| if ($view_column) { |
|
| echo '<td><small>'; |
|
| if ($fm_cfg['perm']['file']['view']) |
|
| echo "[<a target=_blank href=\"" |
|
| . str_replace('%2F', '/', glue_url($url)) . "\">" |
|
| . _FM_FILE_VIEW . "</a>]"; |
|
| echo "</small></td>"; |
|
| } |
} |
| } |
} |
| else { |
|
| |
|
| if ($fm_cfg['show']['size']) { |
$d->close(); |
| echo '<td></td>'; |
} |
| } |
|
| |
|
| if ($fm_cfg['show']['date']) { |
|
| echo '<td></td>'; |
|
| } |
|
| |
|
| if ($rename_column) { |
if ($last_row) { |
| echo '<td><small>'; |
echo '<tr><td colspan=8 align=center><small>'; |
| if ($fm_cfg['perm']['dir']['rename']) |
|
| echo "[<a href=\"$PHP_SELF_origvars_ue" |
|
| . "fm_dir=$fm_dir_ue" |
|
| . "&fm_action=confirm_rename_directory" |
|
| . "&fm_filename=$entry_ue\">" |
|
| . _FM_DIR_RENAME |
|
| . "</a>]"; |
|
| echo '</small></td>'; |
|
| } |
|
| |
|
| if ($delete_column) { |
if ($fm_cfg['perm']['dir']['create']) |
| echo '<td><small>'; |
echo "<br>[<a href=$PHP_SELF_origvars_ue" |
| if ($fm_cfg['perm']['dir']['remove']) |
. "fm_dir=$fm_dir_ue" |
| echo "[<a href=\"$PHP_SELF_origvars_ue" |
. "&fm_action=confirm_create_directory>" |
| . "fm_dir=$fm_dir_ue" |
. _FM_DIR_CREATE |
| . "&fm_action=confirm_remove_directory" |
. "</a>]"; |
| . "&fm_filename=$entry_ue\">" |
|
| . _FM_DIR_REMOVE |
if ($fm_cfg['perm']['file']['create']) |
| ."</a>]"; |
echo " [<a href=$PHP_SELF_origvars_ue" |
| echo '</small></td>'; |
. "fm_dir=$fm_dir_ue" |
| } |
. "&fm_action=confirm_create_file>" |
| |
. _FM_FILE_CREATE |
| if ($view_column) { |
. "</a>]"; |
| echo '<td><small>'; |
|
| if ($fm_cfg['perm']['dir']['enter'] |
if ($fm_cfg['perm']['file']['upload']) |
| && ($fm_cfg['perm']['dir']['follow_symlinks'] |
echo " [<a href=$PHP_SELF_origvars_ue" |
| || ! is_link($entry))) |
. "fm_dir=$fm_dir_ue" |
| echo "[<a href=\"$PHP_SELF_origvars_ue" |
. "&fm_action=confirm_upload_file>" |
| . "fm_dir=$fm_dir_ue$entry_ue\">" |
. _FM_FILE_UPLOAD |
| . _FM_DIR_ENTER |
. "</a>]"; |
| ."</a>]"; |
|
| echo '</small></td>'; |
|
| } |
|
| } |
|
| |
|
| echo "</tr>\n"; |
echo '</small></td></tr>'; |
| } |
} |
| } |
|
| |
|
| $d->close(); |
echo '</table>'; |
| } |
|
| |
|
| if ($last_row) { |
|
| echo '<tr><td colspan=7 align=center><small>'; |
|
| |
|
| if ($fm_cfg['perm']['dir']['create']) |
} |
| echo "<br>[<a href=$PHP_SELF_origvars_ue" |
|
| . "fm_dir=$fm_dir_ue" |
|
| . "&fm_action=confirm_create_directory>" |
|
| . _FM_DIR_CREATE |
|
| . "</a>]"; |
|
| |
|
| if ($fm_cfg['perm']['file']['create']) |
echo '</form>'; |
| echo " [<a href=$PHP_SELF_origvars_ue" |
|
| . "fm_dir=$fm_dir_ue" |
|
| . "&fm_action=confirm_create_file>" |
|
| . _FM_FILE_CREATE |
|
| . "</a>]"; |
|
| |
|
| if ($fm_cfg['perm']['file']['upload']) |
/* Now return back to the initial working directory. */ |
| echo " [<a href=$PHP_SELF_origvars_ue" |
chdir($fm_orig_dir); |
| . "fm_dir=$fm_dir_ue" |
|
| . "&fm_action=confirm_upload_file>" |
|
| . _FM_FILE_UPLOAD |
|
| . "</a>]"; |
|
| |
|
| echo '</small></td></tr>'; |
if (defined('LOADED_AS_MODULE')) { |
| |
CloseTable(); |
| |
include 'footer.php'; |
| } |
} |
| |
|
| echo '</table>'; |
|
| |
|
| } |
} |
| |
|
| echo '</form>'; |
fm_main(); |
| |
|
| /* Now return back to the initial working directory. */ |
|
| chdir($fm_orig_dir); |
|
| |
|
| if (defined('LOADED_AS_MODULE')) { |
|
| CloseTable(); |
|
| include 'footer.php'; |
|
| } |
|
| |
|
| ?> |
?> |