public function action() { $mode = $_POST['new_mode']; $rec_option = $_POST['is_recursive']; $valid_options = array('none', 'files', 'folders', 'both'); $chmod_perm = is_dir($path) ? $chmod_dirs : $chmod_files; // check perm if ($chmod_perm === FALSE) { $fileORfolder = is_dir($path) ? 'folders' : 'files'; $response = "Changing" . $fileORfolder . "permissions are not allowed."; $this->r = array($response, 403); return; } // check mode if (!preg_match("/^[0-7]{3}\$/", $mode)) { $this->r = array('The supplied permission mode is incorrect.', 400); return; } // check recursive option if (!in_array($rec_option, $valid_options)) { $this->r = array("wrong option", 400); return; } // check if server disabled chmod if (is_function_callable('chmod') === FALSE) { $this->r = array('The chmod function has been disabled by the server.', 'chmod', 403); return; } $mode = "0" . $mode; $mode = octdec($mode); rchmod($path, $mode, $rec_option); }
if ($chmod_perm === FALSE) { response(sprintf(trans('File_Permission_Not_Allowed'), is_dir($path) ? lcfirst(trans('Folders')) : lcfirst(trans('Files'))), 403)->send(); exit; } // check mode if (!preg_match("/^[0-7]{3}\$/", $mode)) { response(trans('File_Permission_Wrong_Mode'), 400)->send(); exit; } // check recursive option if (!in_array($rec_option, $valid_options)) { response("wrong option", 400)->send(); exit; } // check if server disabled chmod if (is_function_callable('chmod') === FALSE) { response(sprintf(trans('Function_Disabled'), 'chmod'), 403)->send(); exit; } $mode = "0" . $mode; $mode = octdec($mode); rchmod($path, $mode, $rec_option); break; case 'save_text_file': $content = $_POST['new_content']; // $content = htmlspecialchars($content); not needed // $content = stripslashes($content); // no file if (!file_exists($path)) { response(trans('File_Not_Found'), 404)->send(); exit;
// can't copy/cut files if ($copy_cut_files === false) { response(sprintf(trans('Copy_Cut_Not_Allowed'), $_POST['sub_action'] == 'copy' ? lcfirst(trans('Copy')) : lcfirst(trans('Cut')), trans('Files')), 403)->send(); exit; } } $_SESSION['RF']['clipboard']['path'] = $_POST['path']; $_SESSION['RF']['clipboard_action'] = $_POST['sub_action']; break; case 'clear_clipboard': $_SESSION['RF']['clipboard'] = null; $_SESSION['RF']['clipboard_action'] = null; break; case 'chmod': $path = $current_path . $_POST['path']; if (is_dir($path) && $chmod_dirs === false || is_file($path) && $chmod_files === false || is_function_callable("chmod") === false) { response(sprintf(trans('File_Permission_Not_Allowed'), is_dir($path) ? lcfirst(trans('Folders')) : lcfirst(trans('Files')), 403), 400)->send(); exit; } else { $perm = decoct(fileperms($path) & 0777); $perm_user = substr($perm, 0, 1); $perm_group = substr($perm, 1, 1); $perm_all = substr($perm, 2, 1); $ret = '<div id="files_permission_start"> <form id="chmod_form"> <table class="table file-perms-table"> <thead> <tr> <td></td> <td>r </td> <td>w </td>
// can't copy/cut files if ($copy_cut_files === FALSE) { die(sprintf(lang_Copy_Cut_Not_Allowed, $_POST['sub_action'] == 'copy' ? lcfirst(lang_Copy) : lcfirst(lang_Cut), lang_Files)); } } $_SESSION['RF']['clipboard']['path'] = $_POST['path']; $_SESSION['RF']['clipboard']['path_thumb'] = $_POST['path_thumb']; $_SESSION['RF']['clipboard_action'] = $_POST['sub_action']; break; case 'clear_clipboard': $_SESSION['RF']['clipboard'] = NULL; $_SESSION['RF']['clipboard_action'] = NULL; break; case 'chmod': $path = $current_path . $_POST['path']; if (is_dir($path) && $chmod_dirs === FALSE || is_file($path) && $chmod_files === FALSE || is_function_callable("chmod") === FALSE) { die(sprintf(lang_File_Permission_Not_Allowed, is_dir($path) ? lcfirst(lang_Folders) : lcfirst(lang_Files))); } else { $perm = decoct(fileperms($path) & 0777); $perm_user = substr($perm, 0, 1); $perm_group = substr($perm, 1, 1); $perm_all = substr($perm, 2, 1); $ret = '<div id="files_permission_start"> <form id="chmod_form"> <table class="file-perms-table"> <thead> <tr> <td></td> <td>r </td> <td>w </td> <td>x </td>
die; } // user wants to paste folder to it's own sub folder.. baaaah. if (is_dir($data['path']) && strpos($path, $data['path']) !== FALSE) { die; } // something terribly gone wrong if ($action != 'copy' && $action != 'cut') { die('no action'); } // check for writability if (is_really_writable($path) === FALSE || is_really_writable($path_thumb) === FALSE) { die($path . '--' . $path_thumb . '--' . lang_Dir_No_Write); } // check if server disables copy or rename if (is_function_callable($action == 'copy' ? 'copy' : 'rename') === FALSE) { die(sprintf(lang_Function_Disabled, $action == 'copy' ? lcfirst(lang_Copy) : lcfirst(lang_Cut))); } if ($action == 'copy') { rcopy($data['path'], $path); rcopy($data['path_thumb'], $path_thumb); } elseif ($action == 'cut') { rrename($data['path'], $path); rrename($data['path_thumb'], $path_thumb); // cleanup if (is_dir($data['path']) === TRUE) { rrename_after_cleaner($data['path']); rrename_after_cleaner($data['path_thumb']); } } // cleanup
public function action($parent) { $util = new Utility(); $c = $parent->config; $path = $c['current_path'] . $_POST['path']; if (is_dir($path) && $c['chmod_dirs'] === false || is_file($path) && $c['chmod_files'] === false || is_function_callable("chmod") === false) { $this->r = array(sprintf('Changing %s permissions are not allowed.', is_dir($path) ? 'folders' : 'files'), 403); return; } else { $perm = decoct(fileperms($path) & 0777); $perm_user = substr($perm, 0, 1); $perm_group = substr($perm, 1, 1); $perm_all = substr($perm, 2, 1); $ret = '<div id="files_permission_start"> <form id="chmod_form"> <table class="file-perms-table"> <thead> <tr> <td></td> <td>r </td> <td>w </td> <td>x </td> </tr> </thead> <tbody> <tr> <td>User</td> <td><input id="u_4" type="checkbox" data-value="4" data-group="user" onChange="chmod_logic();"' . ($util->chmod_logic_helper($perm_user, 4) ? " checked" : "") . '></td> <td><input id="u_2" type="checkbox" data-value="2" data-group="user" onChange="chmod_logic();"' . ($util->chmod_logic_helper($perm_user, 2) ? " checked" : "") . '></td> <td><input id="u_1" type="checkbox" data-value="1" data-group="user" onChange="chmod_logic();"' . ($util->chmod_logic_helper($perm_user, 1) ? " checked" : "") . '></td> </tr> <tr> <td>Group</td> <td><input id="g_4" type="checkbox" data-value="4" data-group="group" onChange="chmod_logic();"' . ($util->chmod_logic_helper($perm_group, 4) ? " checked" : "") . '></td> <td><input id="g_2" type="checkbox" data-value="2" data-group="group" onChange="chmod_logic();"' . ($util->chmod_logic_helper($perm_group, 2) ? " checked" : "") . '></td> <td><input id="g_1" type="checkbox" data-value="1" data-group="group" onChange="chmod_logic();"' . ($util->chmod_logic_helper($perm_group, 1) ? " checked" : "") . '></td> </tr> <tr> <td>All</td> <td><input id="a_4" type="checkbox" data-value="4" data-group="all" onChange="chmod_logic();"' . ($util->chmod_logic_helper($perm_all, 4) ? " checked" : "") . '></td> <td><input id="a_2" type="checkbox" data-value="2" data-group="all" onChange="chmod_logic();"' . ($util->chmod_logic_helper($perm_all, 2) ? " checked" : "") . '></td> <td><input id="a_1" type="checkbox" data-value="1" data-group="all" onChange="chmod_logic();"' . ($util->chmod_logic_helper($perm_all, 1) ? " checked" : "") . '></td> </tr> <tr> <td></td> <td colspan="3"><input type="text" name="chmod_value" id="chmod_value" value="' . $perm . '" data-def-value="' . $perm . '"></td> </tr> </tbody> </table>'; if (is_dir($path)) { $ret .= '<div>Apply recursively? <ul> <li><input value="none" name="apply_recursive" type="radio" checked> No </li> <li><input value="files" name="apply_recursive" type="radio"> Files</li> <li><input value="folders" name="apply_recursive" type="radio"> Folders </li> <li><input value="both" name="apply_recursive" type="radio"> Files & Folders</li> </ul> </div>'; } $ret .= '</form></div>'; $this->r = array($ret, 200); } }