| version 1.36, 2003/02/04 21:52:54 |
version 1.37, 2003/02/11 20:04:21 |
|
|
| * http://www.platon.sk/projects/phpWebFileManager/ |
* http://www.platon.sk/projects/phpWebFileManager/ |
| */ |
*/ |
| |
|
| /* $Platon: phpWebFileManager/index.php,v 1.35 2003/02/03 21:50:51 nepto Exp $ */ |
/* $Platon: phpWebFileManager/index.php,v 1.36 2003/02/04 21:52:54 nepto Exp $ */ |
| |
|
| /* |
/* |
| * phpWebFileManager initialization |
* phpWebFileManager initialization |
| Line 41 require_once $fm_init_file; |
|
| Line 41 require_once $fm_init_file; |
|
| |
|
| require_once $PN_PathPrefix . 'functions.inc.php'; |
require_once $PN_PathPrefix . 'functions.inc.php'; |
| |
|
| /* |
|
| * fm_echo_message() |
|
| * |
|
| * Writes message on output. |
|
| */ |
|
| |
|
| function fm_echo_message($message) /* {{{ */ |
|
| { |
|
| echo '<small>'.$message.'</small>'; |
|
| } /* }}} */ |
|
| |
|
| if (! function_exists('fm_header')) { |
if (! function_exists('fm_header')) { |
| function fm_header($var_ar) /* {{{ */ |
function fm_header($var_ar) /* {{{ */ |
| { |
{ |
| extract($var_ar); |
extract($var_ar); |
| if (defined('LOADED_AS_MODULE')) { |
$message = htmlspecialchars(join("\n", $fm_action_message)); |
| OpenTable(); |
if (defined('LOADED_AS_MODULE')) { |
| echo '<font class="pn-title">'._FM_FILE_MANAGER |
if (strlen($message) > 0) { |
| . (strlen($fm_dir) > 0 ? ": $fm_dir_he" : '') |
$message = ' '.$message; |
| . '</font>'; |
} |
| CloseTable(); |
OpenTable(); |
| OpenTable(); |
echo '<font class="pn-title">',_FM_FILE_MANAGER, |
| } else { |
(strlen($fm_dir) > 0 ? ": $fm_dir_he" : ''), |
| if (strlen($fm_dir) > 0) { |
'</font>', $message; |
| echo '<h3>'.$fm_dir_he2.'</h3>'."\n"; |
|
| } |
CloseTable(); |
| } |
OpenTable(); |
| } /* }}} */ |
} else { |
| |
echo '<table cellpadding="0" cellspacing="0" border="0" width="100%"><tr>'; |
| |
echo '<td align="left"><b>', _FM_DIR, ':</b> /', @$fm_dir_he2, '</td>'; |
| |
echo '<td align="right">', $message, '</td>'; |
| |
echo '</tr></table>', "\n"; |
| |
echo '<hr>', "\n"; |
| |
} |
| |
} /* }}} */ |
| } |
} |
| |
|
| |
if (! function_exists('fm_footer')) { |
| |
function fm_footer($var_ar) /* {{{ */ |
| |
{ |
| |
global $fm_cfg; |
| |
extract($var_ar); |
| |
if (defined('LOADED_AS_MODULE')) { |
| |
CloseTable(); |
| |
OpenTable(); |
| |
} else { |
| |
echo '<hr>',"\n"; |
| |
} |
| |
if ($fm_cfg['perm']['dir']['create']) { |
| |
echo '<a href="'.$PHP_SELF_origvars_ue |
| |
. $fm_cfg['cgi'].'dir='.$fm_dir_ue.'&' |
| |
. $fm_cfg['cgi'].'action=confirm_create_directory">' |
| |
. _FM_DIR_CREATE.'</a>'; |
| |
} else { |
| |
echo _FM_DIR_CREATE; |
| |
} |
| |
echo ' | '; |
| |
if ($fm_cfg['perm']['file']['create']) { |
| |
echo '<a href="'.$PHP_SELF_origvars_ue |
| |
. $fm_cfg['cgi'].'dir='.$fm_dir_ue.'&' |
| |
. $fm_cfg['cgi'].'action=confirm_create_file">' |
| |
. _FM_FILE_CREATE.'</a>'; |
| |
} else { |
| |
echo _FM_FILE_CREATE; |
| |
} |
| |
echo ' | '; |
| |
if ($fm_cfg['perm']['file']['upload']) { |
| |
echo '<a href="'.$PHP_SELF_origvars_ue |
| |
. $fm_cfg['cgi'].'dir='.$fm_dir_ue.'&' |
| |
. $fm_cfg['cgi'].'action=confirm_upload_file">' |
| |
. _FM_FILE_UPLOAD.'</a>'; |
| |
} else { |
| |
echo _FM_FILE_UPLOAD; |
| |
} |
| |
if (defined('LOADED_AS_MODULE')) { |
| |
CloseTable(); |
| |
include 'footer.php'; |
| |
} |
| |
} /* }}} */ |
| |
} |
| /* |
/* |
| * Main phpWebFileManager function |
* Main phpWebFileManager function |
| */ |
*/ |
| Line 99 function fm_main() /* {{{ */ |
|
| Line 138 function fm_main() /* {{{ */ |
|
| $fm_new_filename = fm_get_cgi_var($fm_cfg['cgi'].'new_filename', ''); |
$fm_new_filename = fm_get_cgi_var($fm_cfg['cgi'].'new_filename', ''); |
| $fm_file_data = fm_get_cgi_var($fm_cfg['cgi'].'file_data', ''); |
$fm_file_data = fm_get_cgi_var($fm_cfg['cgi'].'file_data', ''); |
| $PHP_SELF = @$HTTP_SERVER_VARS['PHP_SELF']; |
$PHP_SELF = @$HTTP_SERVER_VARS['PHP_SELF']; |
| |
$PHP_SELF_origvars_ue = htmlentities("$PHP_SELF?$fm_origvars"); |
| |
|
| /* |
/* |
| * Debugging CGI varaibles |
* Debugging CGI varaibles |
| */ |
*/ |
| Line 186 function fm_main() /* {{{ */ |
|
| Line 226 function fm_main() /* {{{ */ |
|
| $fm_dir_he = htmlentities($fm_dir); |
$fm_dir_he = htmlentities($fm_dir); |
| $fm_dir_he2 = str_replace(' ', ' ', $fm_dir_he); |
$fm_dir_he2 = str_replace(' ', ' ', $fm_dir_he); |
| $fm_dir_ue = htmlentities(rawurlencode($fm_dir)); |
$fm_dir_ue = htmlentities(rawurlencode($fm_dir)); |
| $PHP_SELF_origvars_ue = htmlentities("$PHP_SELF?$fm_origvars"); |
|
| |
|
| /* |
/* |
| * Title writting with current working direcotry information. |
* ACTIONS |
| |
*/ |
| |
$action_message = array(); |
| |
|
| |
/* |
| |
* save action |
| |
*/ |
| |
if ($fm_action == 'save_file' && $fm_cfg['perm']['file']['save']) { /* {{{ */ |
| |
if ($fm_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); |
| |
$action_message[] = _FM_FILE_SAVE_OK; |
| |
} else { |
| |
$action_message[] = _FM_FILE_SAVE_ERR; |
| |
} |
| |
} else { |
| |
$action_message[] = _FM_CANCELED; |
| |
} |
| |
} /* }}} */ |
| |
|
| |
/* |
| |
* delete action |
| |
*/ |
| |
if ($fm_action == 'delete_file' && $fm_cfg['perm']['file']['delete']) { /* {{{ */ |
| |
if ($fm_submit == _FM_FILE_DELETE) { |
| |
if (@unlink($fm_filename) == false) { |
| |
$action_message[] = _FM_FILE_DELETE_ERR; |
| |
} else { |
| |
$action_message[] = _FM_FILE_DELETE_OK; |
| |
} |
| |
} else { |
| |
$action_message[] = _FM_CANCELED; |
| |
} |
| |
} /* }}} */ |
| |
|
| |
/* |
| |
* remove direcotry |
| |
*/ |
| |
if ($fm_action == 'remove_directory' && $fm_cfg['perm']['dir']['remove']) { /* {{{ */ |
| |
if ($fm_submit == _FM_DIR_REMOVE) { |
| |
if (@rmdir($fm_filename) == 0) { |
| |
$action_message[] = _FM_DIR_REMOVE_ERR; |
| |
} else { |
| |
$action_message[] = _FM_DIR_REMOVE_OK; |
| |
} |
| |
} else { |
| |
$action_message[] = _FM_CANCELED; |
| |
} |
| |
} /* }}} */ |
| |
|
| |
/* |
| |
* 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 != '' && |
| |
(($fm_submit == _FM_DIR_RENAME && $fm_action == "rename_directory") |
| |
|| ($fm_submit == _FM_FILE_RENAME && $fm_action == 'rename_file') |
| |
)) { |
| |
if (@rename($fm_filename, $fm_new_filename) == false) { |
| |
$action_message[] = _FM_RENAME_ERR; |
| |
} else { |
| |
$action_message[] = _FM_RENAME_OK; |
| |
} |
| |
} else { |
| |
$action_message[] = _FM_CANCELED; |
| |
} |
| |
} /* }}} */ |
| |
|
| |
/* |
| |
* 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 != '' && |
| |
(($fm_submit == _FM_DIR_CREATE && $fm_action == 'create_directory') |
| |
|| ($fm_submit == _FM_FILE_CREATE && $fm_action == 'create_file')) |
| |
) { |
| |
if ($fm_action == 'create_directory') { |
| |
if (@mkdir($fm_new_filename, $fm_cfg['mode']['dir']) == false) { |
| |
$action_message[] = _FM_DIR_CREATE_ERR; |
| |
} else { |
| |
$action_message[] = _FM_DIR_CREATE_OK; |
| |
} |
| |
} else { |
| |
if (file_exists($fm_new_filename)) |
| |
$action_message[] = _FM_FILE_CREATE_ERR1; |
| |
else { |
| |
if (($fh = @fopen($fm_new_filename, 'w')) == false) { |
| |
$action_message[] = _FM_FILE_CREATE_ERR2; |
| |
} else { |
| |
fclose($fh); |
| |
$action_message[] = _FM_FILE_CREATE_OK; |
| |
|
| |
if ($fm_cfg['mode']['file'] != 0) { |
| |
if (@chmod($fm_new_filename, $fm_cfg['mode']['file']) == false) { |
| |
$action_message[] = ' '. _FM_CHMOD_ERR; |
| |
} else { |
| |
$action_message[] = ' '. _FM_CHMOD_OK; |
| |
} |
| |
} |
| |
} |
| |
} |
| |
} |
| |
} else { |
| |
$action_message[] = _FM_CANCELED; |
| |
} |
| |
} /* }}} */ |
| |
|
| |
/* |
| |
* file upload action |
| |
*/ |
| |
if ($fm_action == 'upload_file' && $fm_cfg['perm']['file']['upload']) { /* {{{ */ |
| |
global $HTTP_POST_FILES; |
| |
$fm_userfile = @$HTTP_POST_FILES[$fm_cfg['cgi'].'userfile']['tmp_name']; |
| |
$fm_userfile_name = @$HTTP_POST_FILES[$fm_cfg['cgi'].'userfile']['name']; |
| |
|
| |
if ($fm_submit == _FM_FILE_UPLOAD && $fm_userfile_name != '') { |
| |
$tmp_target_filename = $target_filename = $fm_userfile_name; |
| |
for ($i = 2; file_exists($tmp_target_filename); $i++) { |
| |
if ($i == 2) { |
| |
$action_message[] = _FM_FILENAME_CHANGED; |
| |
} |
| |
$tmp_target_filename = $target_filename . '-' . $i; |
| |
} |
| |
$target_filename = $tmp_target_filename; |
| |
if (@copy($fm_userfile, $target_filename)) { |
| |
$action_message[] = _FM_FILE_UPLOAD_OK; |
| |
if ($fm_cfg['mode']['file'] != 0) { |
| |
if (@chmod($target_filename, $fm_cfg['mode']['file']) == false) { |
| |
$action_message[] = ' '._FM_CHMOD_ERR; |
| |
} else { |
| |
$action_message[] = ' '._FM_CHMOD_OK; |
| |
} |
| |
} |
| |
} else { |
| |
$action_message[] = _FM_FILE_UPLOAD_ERR; |
| |
} |
| |
} else { |
| |
$action_message[] = _FM_CANCELED; |
| |
} |
| |
} /* }}} */ |
| |
|
| fm_header(array( |
/* |
| 'fm_filename' => $fm_filename_he, |
* file edit action |
| 'fm_filename_he' => $fm_filename_he, |
*/ |
| 'fm_filename_he2' => $fm_filename_he2, |
if ($fm_action == 'edit_file' && $fm_cfg['perm']['file']['edit']) { /* {{{ */ |
| 'fm_dir' => $fm_dir, |
if (is_readable($fm_filename) && is_writeable($fm_filename)) { |
| 'fm_dir_he' => $fm_dir_he, |
if ($fm_submit == _FM_FILE_EDIT) { |
| 'fm_dir_he2' => $fm_dir_he2, |
// will display edit dialog |
| 'fm_dir_ue' => $fm_dir_ue |
} else { |
| )); |
$action_message[] = _FM_CANCELED; |
| |
} |
| |
} else { |
| |
$action_message[] = _FM_FILE_EDIT_ERR; |
| |
} |
| |
} /* }}} */ |
| |
|
| /* |
/* |
| * Form |
* Form |
| Line 219 function fm_main() /* {{{ */ |
|
| Line 406 function fm_main() /* {{{ */ |
|
| echo '<input type=hidden name="file" value="index">'."\n"; |
echo '<input type=hidden name="file" value="index">'."\n"; |
| } |
} |
| |
|
| |
/* |
| |
* Variable array |
| |
*/ |
| |
$var_ar = array( |
| |
'fm_filename' => $fm_filename_he, |
| |
'fm_filename_he' => $fm_filename_he, |
| |
'fm_filename_he2' => $fm_filename_he2, |
| |
'fm_dir' => $fm_dir, |
| |
'fm_dir_he' => $fm_dir_he, |
| |
'fm_dir_he2' => $fm_dir_he2, |
| |
'fm_dir_ue' => $fm_dir_ue, |
| |
'fm_action_message' => $action_message, |
| |
'PHP_SELF' => $PHP_SELF, |
| |
'PHP_SELF_origvars_ue' => $PHP_SELF_origvars_ue, |
| |
); |
| |
|
| |
/* |
| |
* Title writting with current working direcotry information. |
| |
*/ |
| |
|
| |
fm_header($var_ar); |
| |
|
| switch ($fm_action) { |
switch ($fm_action) { |
| |
|
| /* |
/* |
| Line 226 function fm_main() /* {{{ */ |
|
| Line 435 function fm_main() /* {{{ */ |
|
| */ |
*/ |
| case 'confirm_delete_file': |
case 'confirm_delete_file': |
| echo '<input type=hidden value=delete_file name="'.$fm_cfg['cgi'].'action">'; |
echo '<input type=hidden value=delete_file name="'.$fm_cfg['cgi'].'action">'; |
| |
|
| echo _FM_REALLY_DELETE.'<br><br><i>'.$fm_filename_he2.'</i><br><br>'; |
echo _FM_REALLY_DELETE.'<br><br><i>'.$fm_filename_he2.'</i><br><br>'; |
| echo $fm_dir == '' |
echo $fm_dir == '' |
| ? _FM_FROM_ROOT_DIR.'?<br><br>' |
? _FM_FROM_ROOT_DIR.'?<br><br>' |
| Line 240 function fm_main() /* {{{ */ |
|
| Line 448 function fm_main() /* {{{ */ |
|
| */ |
*/ |
| case 'confirm_remove_directory': |
case 'confirm_remove_directory': |
| echo '<input type=hidden value=remove_directory name="'.$fm_cfg['cgi'].'action">'; |
echo '<input type=hidden value=remove_directory name="'.$fm_cfg['cgi'].'action">'; |
| |
|
| echo _FM_REALLY_REMOVE.'<br><br><i>'.$fm_filename_he2.'</i><br><br>'; |
echo _FM_REALLY_REMOVE.'<br><br><i>'.$fm_filename_he2.'</i><br><br>'; |
| echo _FM_MUST_BE_EMPTY.'<br><br>'; |
echo _FM_MUST_BE_EMPTY.'<br><br>'; |
| echo '<input type=submit name="'.$fm_cfg['cgi'].'submit" value="'._FM_DIR_REMOVE.'"> '; |
echo '<input type=submit name="'.$fm_cfg['cgi'].'submit" value="'._FM_DIR_REMOVE.'"> '; |
| Line 255 function fm_main() /* {{{ */ |
|
| Line 462 function fm_main() /* {{{ */ |
|
| echo '<input type=hidden value="'; |
echo '<input type=hidden value="'; |
| echo $fm_action == 'confirm_rename_directory' ? 'rename_directory' : 'rename_file'; |
echo $fm_action == 'confirm_rename_directory' ? 'rename_directory' : 'rename_file'; |
| echo '" name="'.$fm_cfg['cgi'].'action">'; |
echo '" name="'.$fm_cfg['cgi'].'action">'; |
| |
|
| echo _FM_RENAME_FROM.'<br><br><i>'.$fm_filename_he2.'</i><br><br>'; |
echo _FM_RENAME_FROM.'<br><br><i>'.$fm_filename_he2.'</i><br><br>'; |
| echo _FM_RENAME_TO.'<br><br>'; |
echo _FM_RENAME_TO.'<br><br>'; |
| echo '<input type=text value="" name="'.$fm_cfg['cgi'].'new_filename"><br><br>'; |
echo '<input type=text value="" name="'.$fm_cfg['cgi'].'new_filename"><br><br>'; |
| Line 273 function fm_main() /* {{{ */ |
|
| Line 479 function fm_main() /* {{{ */ |
|
| echo '<input type=hidden value="'; |
echo '<input type=hidden value="'; |
| echo $fm_action == 'confirm_create_directory' ? 'create_directory' : 'create_file'; |
echo $fm_action == 'confirm_create_directory' ? 'create_directory' : 'create_file'; |
| echo '" name="'.$fm_cfg['cgi'].'action">'; |
echo '" name="'.$fm_cfg['cgi'].'action">'; |
| |
|
| echo _FM_ENTER_NAME . ':<br><br>'; |
echo _FM_ENTER_NAME . ':<br><br>'; |
| echo '<input type=text value="" name="'.$fm_cfg['cgi'].'new_filename"><br><br>'; |
echo '<input type=text value="" name="'.$fm_cfg['cgi'].'new_filename"><br><br>'; |
| echo '<input type=submit name="'.$fm_cfg['cgi'].'submit" value="'; |
echo '<input type=submit name="'.$fm_cfg['cgi'].'submit" value="'; |
| Line 287 function fm_main() /* {{{ */ |
|
| Line 492 function fm_main() /* {{{ */ |
|
| */ |
*/ |
| case 'confirm_upload_file': |
case 'confirm_upload_file': |
| echo '<input type=hidden value="upload_file" name="'.$fm_cfg['cgi'].'action">'; |
echo '<input type=hidden value="upload_file" name="'.$fm_cfg['cgi'].'action">'; |
| |
|
| echo _FM_SELECT_LOCAL . ':<br><br>'; |
echo _FM_SELECT_LOCAL . ':<br><br>'; |
| echo '<input type=file value="" name="'.$fm_cfg['cgi'].'userfile"><br><br>'; |
echo '<input type=file value="" name="'.$fm_cfg['cgi'].'userfile"><br><br>'; |
| echo '<input type=submit name="'.$fm_cfg['cgi'].'submit" value="'._FM_FILE_UPLOAD.'"> '; |
echo '<input type=submit name="'.$fm_cfg['cgi'].'submit" value="'._FM_FILE_UPLOAD.'"> '; |
| Line 298 function fm_main() /* {{{ */ |
|
| Line 502 function fm_main() /* {{{ */ |
|
| * confirm edit file and edit file form |
* confirm edit file and edit file form |
| */ |
*/ |
| case 'confirm_edit_file': |
case 'confirm_edit_file': |
| if (is_readable($fm_filename) && is_writeable($fm_filename)) { |
// TODO: |
| // TODO: |
// 1. check file type - if binary, ask if really edit |
| // 1. check file type - if binary, ask if really edit |
// 2. check file size - if too big, ask if really edit |
| // 2. check file size - if too big, ask if really edit |
echo '<input type=hidden value="edit_file" name="'.$fm_cfg['cgi'].'action">'; |
| echo '<input type=hidden value="edit_file" name="'.$fm_cfg['cgi'].'action">'; |
echo _FM_REALLY_EDIT |
| |
. '<br><br><i>'.$fm_filename_he2.'</i><br><br>'; |
| echo _FM_REALLY_EDIT |
echo $fm_dir == '' |
| . '<br><br><i>'.$fm_filename_he2.'</i><br><br>'; |
? _FM_IN_ROOT_DIR . '?<br><br>' |
| echo $fm_dir == '' |
: _FM_IN_DIR . '<br><br><i>'.$fm_dir_he2.'</i><br><br>'; |
| ? _FM_IN_ROOT_DIR . '?<br><br>' |
echo '<input type=submit name="'.$fm_cfg['cgi'].'submit" value="'._FM_FILE_EDIT.'"> '; |
| : _FM_IN_DIR . '<br><br><i>'.$fm_dir_he2.'</i><br><br>'; |
echo '<input type=submit name="'.$fm_cfg['cgi'].'submit" value="'._FM_CANCEL.'">'; |
| echo '<input type=submit name="'.$fm_cfg['cgi'].'submit" value="'._FM_FILE_EDIT.'"> '; |
break; |
| |
case 'edit_file': |
| |
if (is_readable($fm_filename) && is_writeable($fm_filename) && $fm_submit == _FM_FILE_EDIT) { |
| |
echo '<input type=hidden value="save_file" name="'.$fm_cfg['cgi'].'action">'; |
| |
// Please write me, if you want to have cols and rows configurable. |
| |
echo '<textarea name="'.$fm_cfg['cgi'].'file_data" cols=50 rows=15>'; |
| |
htmlentities(@readfile($fm_filename)); |
| |
echo '</textarea><br><br>'; |
| |
echo '<input type=submit name="'.$fm_cfg['cgi'].'submit" value="'._FM_FILE_SAVE.'"> '; |
| echo '<input type=submit name="'.$fm_cfg['cgi'].'submit" value="'._FM_CANCEL.'">'; |
echo '<input type=submit name="'.$fm_cfg['cgi'].'submit" value="'._FM_CANCEL.'">'; |
| break; |
break; |
| } |
} |
| case 'edit_file': |
|
| if (is_readable($fm_filename) && is_writeable($fm_filename)) { |
|
| if ($fm_submit == _FM_FILE_EDIT) { |
|
| echo '<input type=hidden value="save_file" name="'.$fm_cfg['cgi'].'action">'; |
|
| // Please write me, if you want to have cols and rows configurable. |
|
| echo '<textarea name="'.$fm_cfg['cgi'].'file_data" cols=50 rows=15>'; |
|
| htmlentities(@readfile($fm_filename)); |
|
| echo '</textarea><br><br>'; |
|
| echo '<input type=submit name="'.$fm_cfg['cgi'].'submit" value="'._FM_FILE_SAVE.'"> '; |
|
| echo '<input type=submit name="'.$fm_cfg['cgi'].'submit" value="'._FM_CANCEL.'">'; |
|
| break; |
|
| } else fm_echo_message(_FM_CANCELED); |
|
| } else { |
|
| fm_echo_message(_FM_FILE_EDIT_ERR); |
|
| } |
|
| |
|
| echo '<br><br>'; |
|
| |
|
| default: |
|
| |
|
| /* |
|
| * save action |
|
| */ |
|
| if ($fm_action == 'save_file' && $fm_cfg['perm']['file']['save']) { |
|
| if ($fm_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>'; |
|
| } |
|
| |
|
| /* |
|
| * delete action |
|
| */ |
|
| if ($fm_action == 'delete_file' && $fm_cfg['perm']['file']['delete']) { |
|
| if ($fm_submit == _FM_FILE_DELETE) { |
|
| if (@unlink($fm_filename) == false) |
|
| fm_echo_message(_FM_FILE_DELETE_ERR); |
|
| else |
|
| fm_echo_message(_FM_FILE_DELETE_OK); |
|
| } |
|
| else fm_echo_message(_FM_CANCELED); |
|
| echo '<br><br>'; |
|
| } |
|
| |
|
| /* |
default: // File listing |
| * remove direcotry |
|
| */ |
|
| if ($fm_action == 'remove_directory' && $fm_cfg['perm']['dir']['remove']) { |
|
| if ($fm_submit == _FM_DIR_REMOVE) { |
|
| if (@rmdir($fm_filename) == 0) |
|
| fm_echo_message(_FM_DIR_REMOVE_ERR); |
|
| else |
|
| fm_echo_message(_FM_DIR_REMOVE_OK); |
|
| } |
|
| else fm_echo_message(_FM_CANCELED); |
|
| 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 != '' && |
|
| (($fm_submit == _FM_DIR_RENAME && $fm_action == "rename_directory") |
|
| || ($fm_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>'; |
|
| } |
|
| |
|
| /* |
|
| * 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 != '' && |
|
| (($fm_submit == _FM_DIR_CREATE && $fm_action == 'create_directory') |
|
| || ($fm_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(_FM_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>'; |
|
| } |
|
| |
|
| /* |
|
| * file upload action |
|
| */ |
|
| if ($fm_action == 'upload_file' && $fm_cfg['perm']['file']['upload']) { |
|
| global $HTTP_POST_FILES; |
|
| $fm_userfile = @$HTTP_POST_FILES[$fm_cfg['cgi'].'userfile']['tmp_name']; |
|
| $fm_userfile_name = @$HTTP_POST_FILES[$fm_cfg['cgi'].'userfile']['name']; |
|
| if ($fm_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++; |
|
| } |
|
| |
|
| $target_filename = $tmp_target_filename; |
|
| |
|
| //echo("fm_userfile = $fm_userfile<br>"); |
|
| //echo("fm_userfile_name = $fm_userfile_name<br>"); |
|
| //echo("target_filename = $target_filename<br>"); |
|
| |
|
| if (@copy($fm_userfile, $target_filename)) { |
|
| |
|
| 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 { |
|
| fm_echo_message(' '._FM_CHMOD_OK); |
|
| } |
|
| } |
|
| } |
|
| else |
|
| fm_echo_message(_FM_FILE_UPLOAD_ERR); |
|
| } |
|
| else fm_echo_message(_FM_CANCELED); |
|
| |
|
| echo '<br><br>'; |
|
| } |
|
| |
|
| /* |
/* |
| * Column display counting |
* Column display counting |
| Line 493 function fm_main() /* {{{ */ |
|
| Line 536 function fm_main() /* {{{ */ |
|
| $delete_column = $fm_cfg['perm']['dir']['remove'] || $fm_cfg['perm']['file']['delete']; |
$delete_column = $fm_cfg['perm']['dir']['remove'] || $fm_cfg['perm']['file']['delete']; |
| $view_column = $fm_cfg['perm']['dir']['enter'] || $fm_cfg['perm']['file']['view']; |
$view_column = $fm_cfg['perm']['dir']['enter'] || $fm_cfg['perm']['file']['view']; |
| $edit_column = $fm_cfg['perm']['file']['edit']; |
$edit_column = $fm_cfg['perm']['file']['edit']; |
| $last_row = $fm_cfg['perm']['dir']['create'] |
|
| || $fm_cfg['perm']['file']['create'] |
|
| || $fm_cfg['perm']['file']['upload']; |
|
| |
|
| /* |
/* |
| * Colspan counting |
* Colspan counting |
| Line 522 function fm_main() /* {{{ */ |
|
| Line 562 function fm_main() /* {{{ */ |
|
| if (! empty($fm_cfg['color']['odd'])) |
if (! empty($fm_cfg['color']['odd'])) |
| echo ' bgcolor="'.$fm_cfg['color']['odd'].'"'; |
echo ' bgcolor="'.$fm_cfg['color']['odd'].'"'; |
| echo '>'; |
echo '>'; |
| |
|
| if ($fm_cfg['show']['icons']) { |
if ($fm_cfg['show']['icons']) { |
| echo '<td align=center>'; |
echo '<td align=center>'; |
| echo '<a href="'.$PHP_SELF_origvars_ue.$fm_cfg['cgi'].'dir='.$fm_dir_ue.'..">'; |
echo '<a href="'.$PHP_SELF_origvars_ue.$fm_cfg['cgi'].'dir='.$fm_dir_ue.'..">'; |
| Line 530 function fm_main() /* {{{ */ |
|
| Line 569 function fm_main() /* {{{ */ |
|
| . $fm_cfg['url']['icons'].$fm_cfg['icons']['sys']['UP-DIR'].'"></a>'; |
. $fm_cfg['url']['icons'].$fm_cfg['icons']['sys']['UP-DIR'].'"></a>'; |
| echo '</td>'; |
echo '</td>'; |
| } |
} |
| |
|
| echo '<td width="100%" colspan="'.($colspan - 1).'">'; |
echo '<td width="100%" colspan="'.($colspan - 1).'">'; |
| echo '<a href="'.$PHP_SELF_origvars_ue.$fm_cfg['cgi'].'dir='.$fm_dir_ue.'..">'; |
echo '<a href="'.$PHP_SELF_origvars_ue.$fm_cfg['cgi'].'dir='.$fm_dir_ue.'..">'; |
| echo '('._FM_PARENT_DIR.')</a>'; |
echo '('._FM_PARENT_DIR.')</a>'; |
| echo '</td>'; |
echo '</td>'; |
| |
|
| echo '</tr>'."\n"; |
echo '</tr>'."\n"; |
| |
|
| $line++; |
$line++; |
| } |
} |
| |
|
| Line 631 function fm_main() /* {{{ */ |
|
| Line 667 function fm_main() /* {{{ */ |
|
| echo $entry_he2; |
echo $entry_he2; |
| } |
} |
| } else { |
} else { |
| // Setting up view URL |
// Setting up view URL |
| if ($view_column && $fm_cfg['perm']['file']['view']) { |
if ($view_column && $fm_cfg['perm']['file']['view']) { |
| $view_url = parse_url('http://'.$HTTP_SERVER_VARS['HTTP_HOST'] |
$view_url = parse_url('http://'.$HTTP_SERVER_VARS['HTTP_HOST'] |
| .$HTTP_SERVER_VARS['REQUEST_URI']); |
.$HTTP_SERVER_VARS['REQUEST_URI']); |
| Line 791 function fm_main() /* {{{ */ |
|
| Line 827 function fm_main() /* {{{ */ |
|
| } |
} |
| echo '</tr>'."\n"; |
echo '</tr>'."\n"; |
| } |
} |
| |
|
| if ($last_row) { |
|
| echo '<tr><td colspan="'.$colspan.'" align=center><br><small>'; |
|
| |
|
| if ($fm_cfg['perm']['dir']['create']) { |
|
| echo '[<a href="'.$PHP_SELF_origvars_ue |
|
| . $fm_cfg['cgi'].'dir='.$fm_dir_ue.'&' |
|
| . $fm_cfg['cgi'].'action=confirm_create_directory">' |
|
| . _FM_DIR_CREATE.'</a>]'; |
|
| echo ' '; |
|
| } |
|
| |
|
| if ($fm_cfg['perm']['file']['create']) { |
|
| echo '[<a href="'.$PHP_SELF_origvars_ue |
|
| . $fm_cfg['cgi'].'dir='.$fm_dir_ue.'&' |
|
| . $fm_cfg['cgi'].'action=confirm_create_file">' |
|
| . _FM_FILE_CREATE.'</a>]'; |
|
| echo ' '; |
|
| } |
|
| |
|
| if ($fm_cfg['perm']['file']['upload']) { |
|
| echo '[<a href="'.$PHP_SELF_origvars_ue |
|
| . $fm_cfg['cgi'].'dir='.$fm_dir_ue.'&' |
|
| . $fm_cfg['cgi'].'action=confirm_upload_file">' |
|
| . _FM_FILE_UPLOAD.'</a>]'; |
|
| echo ' '; |
|
| } |
|
| |
|
| echo '</small></td></tr>'."\n"; |
|
| } |
|
| |
|
| echo '</table>'."\n"; |
echo '</table>'."\n"; |
| |
|
| } |
} |
| |
|
| echo '</form>'."\n"; |
|
| |
|
| /* Now return back to the initial working directory. */ |
/* Now return back to the initial working directory. */ |
| chdir($fm_orig_dir); |
chdir($fm_orig_dir); |
| |
|
| if (defined('LOADED_AS_MODULE')) { |
fm_footer($var_ar); |
| CloseTable(); |
|
| include 'footer.php'; |
echo '</form>'."\n"; |
| } |
|
| } /* }}} */ |
} /* }}} */ |
| |
|
| /* |
/* |
| Line 843 function fm_main() /* {{{ */ |
|
| Line 844 function fm_main() /* {{{ */ |
|
| |
|
| fm_main(); |
fm_main(); |
| |
|
| /* vim: set expandtab tabstop=4 shiftwidth=4: |
/* vim: set tabstop=4 shiftwidth=4: |
| * vim600: fdm=marker fdl=0 fdc=0 |
* vim600: fdm=marker fdl=0 fdc=0 |
| */ |
*/ |
| |
|