function set_chmod($dir, $chmod, $type = 'is_file') { global $filesystem; if (file_exists($dir) && $type($dir)) { if (!check_chmod(decoct($chmod), get_chmod($dir))) { $filesystem->chmod($dir, $chmod); } } else { $filesystem->mkdir($dir, $chmod); set_chmod($dir, $chmod, CHMOD_DIR); } }
function set_chmod($dir, $chmod, $type = CHMOD_FILE, $stop = false) { global $filesystem; if (file_exists($dir) && $type($dir)) { if (!check_chmod(decoct($chmod), get_chmod($dir))) { $filesystem->chmod($dir, $chmod); } } else { if ($type == CHMOD_DIR && !$stop) { $filesystem->mkdir($dir, $chmod); set_chmod($dir, $chmod, CHMOD_DIR, true); } elseif (!$stop) { $filesystem->file_put_contents($dir, ''); set_chmod($dir, $chmod, CHMOD_FILE, true); } } }
foreach ($filenames as $f) { $files[] = array('path' => $f, 'chmod' => $dat['chmod'], 'recursive' => false, 'req' => $dat['req']); } } else { if ($dat['chmod'] == CHMOD_EX) { set_chmod($dat['path'], 0777, CHMOD_DIR); } elseif ($dat['chmod'] == CHMOD_WR) { set_chmod($dat['path'], 0666, CHMOD_FILE); } $files[] = $dat; } } @clearstatcache(); sort($files); foreach ($files as $arr) { $chmod = get_chmod($arr['path']); if (check_chmod($arr['chmod'], $chmod)) { $status = '<strong style="color: #008000;">' . $lang->phrase('admin_explorer_chmod_status_ok') . '</strong>'; } elseif ($arr['req'] == false) { $status = '<strong style="color: #ffaa00;">' . $lang->phrase('admin_explorer_chmod_status_failure_x') . '</strong>'; } else { $status = '<strong style="color: #ff0000;">' . $lang->phrase('admin_explorer_chmod_status_failure') . '</strong>'; } ?> <tr class="mbox"> <td><?php echo $arr['path']; ?> </td> <td><?php echo $arr['chmod'];
function showContent($print = true) { global $lang; $dir_list = $file_list = $subdir_size_list = array(); $total_dir_size = 0; if (($dir_handle = opendir($this->path)) === false) { error('admin.php?action=explorer', $lang->phrase('admin_explorer_could_not_open_dir') . realpath($this->path)); } while (($file = @readdir($dir_handle)) !== false) { if ($file == '.' || $file == '..') { continue; } if (is_dir($this->path . $file)) { $dir_list[] = $file; if ($this->show_subfolders_size) { $stack = array($this->path . $file . '/'); $size = 0; while (count($stack) > 0) { $subdir = array_shift($stack); $subdir_handle = @opendir($subdir); while (($subdir_file = @readdir($subdir_handle)) !== false) { if ($subdir_file == '.' || $subdir_file == '..') { continue; } if ($this->show_subfolders_size) { if (is_dir($subdir . $subdir_file)) { array_push($stack, $subdir . $subdir_file . '/'); } } $size += @filesize($subdir . $subdir_file); } @closedir($subdir_handle); } $subdir_size_list[$file] = $size; $total_dir_size += $size; } } else { $file_list[] = $file; $total_dir_size += @filesize($this->path . $file); } } @closedir($dir_handle); natcasesort($dir_list); natcasesort($file_list); $total_files = count($dir_list) + count($file_list); $total_size = $this->formatSize($total_dir_size); $print_spacer = count($file_list) > 0 && count($dir_list) > 0 ? true : false; $page_link = $this->realPath(dirname($this->script_file) . '/' . $this->path); $rp = realpath($this->path); $root = extract_dir($this->root); $rp = str_replace($root, '', $rp); $heading_path = $this->realPath($rp); $heading_path_parts = explode("/", $heading_path); $levels = count($heading_path_parts) - 2; for ($heading_path = ""; $levels > -1; $levels--) { for ($i = 0, $path = ""; $i < $levels; $i++) { $path .= "../"; } $link = '&path=' . urlencode($this->realPath($this->path . $path)); $heading_path .= '<a href="' . $this->script_file . $link . '">' . array_shift($heading_path_parts) . '</a>' . DIRECTORY_SEPARATOR; } $newdir = $this->script_file . '&path=' . urlencode(str_replace('/\\', '/', $this->path)); $newdir_html = '<span style="float: right;"><a class="button" href="' . $newdir . '&job=newdir">' . $lang->phrase('admin_explorer_create_new_directory') . '</a></span>'; $html = ' <table cellpadding="4" cellspacing="0" class="border">'; $html .= "\n" . ' <tr>'; $html .= "\n" . ' <td class="obox"><span style="float: right;"><a class="button" href="admin.php?action=explorer&job=all_chmod">' . $lang->phrase('admin_explorer_check_chmod') . '</a></span>' . iif(count($dir_list) == 0, $newdir_html) . $lang->phrase('admin_explorer_filemanager') . '</td>'; $html .= "\n" . ' </tr>'; $html .= "\n" . ' <tr>'; $html .= "\n" . ' <td class="ubox">' . $lang->phrase('admin_explorer_directory_x') . extract_dir($this->root) . $heading_path . '</td>'; $html .= "\n" . ' </tr>'; $html .= "\n" . ' </table><br />'; $html .= "\n" . ' <table cellpadding="4" cellspacing="0" class="border">'; if (count($dir_list) > 0) { $html .= "\n" . ' <tr>'; $html .= "\n" . ' <td class="obox" colspan="5">' . $newdir_html . $lang->phrase('admin_explorer_directories') . '</td>'; $html .= "\n" . ' </tr>'; $html .= "\n" . ' <tr>'; $html .= "\n" . ' <td class="ubox" width="30%">' . $lang->phrase('admin_explorer_directory') . '</td>'; $html .= "\n" . ' <td class="ubox" width="9%">' . $lang->phrase('admin_explorer_size') . '</td>'; $html .= "\n" . ' <td class="ubox" width="20%">' . $lang->phrase('admin_explorer_created_on') . '</td>'; $html .= "\n" . ' <td class="ubox" width="8%">' . $lang->phrase('admin_explorer_chmod') . '</td>'; $html .= "\n" . ' <td class="ubox" width="33%">' . $lang->phrase('admin_explorer_action') . '</td>'; $html .= "\n" . ' </tr>'; } while (($dir = array_shift($dir_list)) !== NULL) { $path_url = '&path=' . urlencode(str_replace('/\\', '/', $this->path) . $dir . '/'); $link = $this->script_file . $path_url; $size = $this->show_subfolders_size ? $this->formatSize($subdir_size_list[$dir]) : " "; $chmod = get_chmod($this->path . $dir); $icon = $this->icons('directory'); $html .= "\n" . ' <tr>'; $html .= "\n" . ' <td class="mbox">'; $html .= "\n" . ' <a href="' . $link . '" target="Main">' . $icon . $dir . '</a>'; $html .= "\n" . ' </td>'; $html .= "\n" . ' <td class="mbox" align="right">'; $html .= "\n" . ' ' . $size; $html .= "\n" . ' </td>'; $html .= "\n" . ' <td class="mbox">'; $html .= "\n" . ' ' . gmdate("d.m.y, H:i", times(filectime($this->path . $dir))); $html .= "\n" . ' </td>'; $html .= "\n" . ' <td class="mbox" align="right">'; $html .= "\n" . ' ' . $chmod; $html .= "\n" . ' </td>'; $html .= "\n" . ' <td class="mbox">'; $html .= "\n" . ' <a class="button" href="' . $link . '&job=chmod&type=dir">' . $lang->phrase('admin_explorer_file_chmod') . '</a> <a class="button" href="' . $link . '&job=rename&type=dir">' . $lang->phrase('admin_explorer_file_rename') . '</a> <a class="button" href="' . $link . '&job=delete&type=dir">' . $lang->phrase('admin_explorer_file_delete') . '</a>'; $html .= "\n" . ' </td>'; $html .= "\n" . ' </tr>'; } if ($print_spacer) { $html .= "\n" . ' </table><br />'; $html .= "\n" . ' <table cellpadding="4" cellspacing="0" class="border">'; } if (count($file_list) > 0) { $lang->assign('total_files', $total_files); $lang->assign('total_size', $total_size); $html .= "\n" . ' <tr>'; $html .= "\n" . ' <td class="obox" colspan="6">' . $lang->phrase('admin_explorer_files') . '</td>'; $html .= "\n" . ' </tr>'; $html .= "\n" . ' <tr>'; $html .= "\n" . ' <td class="ubox" width="30%">' . $lang->phrase('admin_explorer_toal_files') . '</td>'; $html .= "\n" . ' <td class="ubox" width="7%">' . $lang->phrase('admin_explorer_size') . '</td>'; $html .= "\n" . ' <td class="ubox" width="12%">' . $lang->phrase('admin_explorer_last_modified') . '</td>'; $html .= "\n" . ' <td class="ubox" width="12%">' . $lang->phrase('admin_explorer_created_on') . '</td>'; $html .= "\n" . ' <td class="ubox" width="7%">' . $lang->phrase('admin_explorer_chmod') . '</td>'; $html .= "\n" . ' <td class="ubox" width="33%">' . $lang->phrase('admin_explorer_action') . '</td>'; $html .= "\n" . ' </tr>'; } while (($file = array_shift($file_list)) !== NULL) { $extension = preg_replace("/^.*?\\.(\\w{1,8})\$/", "\\1", $file); $path_url = '&path=' . urlencode(str_replace('/\\', '/', $this->path) . $file); $link = $this->script_file . $path_url; $icon = $this->icons($extension); $html .= "\n" . ' <tr>'; $html .= "\n" . ' <td class="mbox">'; $html .= "\n" . ' <a href="' . str_replace('/\\', '/', $this->path) . $file . '">' . $icon . $file . '</a>'; $html .= "\n" . ' </td>'; $html .= "\n" . ' <td class="mbox" align="right">'; $html .= "\n" . ' ' . $this->formatSize(filesize($this->path . $file)); $html .= "\n" . ' </td>'; $html .= "\n" . ' <td class="mbox">'; $html .= "\n" . ' ' . gmdate("d.m.y, H:i", times(filemtime($this->path . $file))); $html .= "\n" . ' </td>'; $html .= "\n" . ' <td class="mbox">'; $html .= "\n" . ' ' . gmdate("d.m.y, H:i", times(filectime($this->path . $file))); $html .= "\n" . ' </td>'; $html .= "\n" . ' <td class="mbox" align="right">'; $html .= "\n" . ' ' . get_chmod($this->path . $file); $html .= "\n" . ' </td>'; $html .= "\n" . ' <td class="mbox">'; $html .= "\n" . ' <a class="button" href="' . $link . '&job=chmod">' . $lang->phrase('admin_explorer_file_chmod') . '</a> <a class="button" href="' . $link . '&job=rename">' . $lang->phrase('admin_explorer_file_rename') . '</a> <a class="button" href="' . $link . '&job=delete">' . $lang->phrase('admin_explorer_file_delete') . '</a>'; $html .= iif(in_array($extension, $this->extract), ' <a class="button" href="' . $link . '&job=extract">' . $lang->phrase('admin_explorer_file_extract') . '</a>') . iif(in_array($extension, $this->plain), ' <a class="button" href="' . $link . '&job=edit">' . $lang->phrase('admin_explorer_file_edit') . '</a>'); $html .= "\n" . ' </td>'; $html .= "\n" . ' </tr>'; } $html .= "\n" . ' </table>'; if ($print) { echo $html; } else { return $html; } }
} elseif ($dat['chmod'] == CHWR) { set_chmod($path, 0666, CHMOD_FILE); } $files[] = $dat; } } @clearstatcache(); sort($files); $failure = false; foreach ($files as $arr) { $filesys_path = '../' . $arr['path']; $path = realpath($filesys_path); if (empty($path)) { $path = $arr['path']; } $chmod = get_chmod($filesys_path); if (check_chmod($arr['chmod'], $chmod)) { $status = '<strong class="hl_true">OK</strong>'; $int_status = true; } elseif ($arr['req'] == false) { $status = '<strong class="hl_null">Failure*</strong>'; $int_status = null; } else { $status = '<strong class="hl_false">Failure</strong>'; $int_status = false; $failure = true; } if ($arr['req'] == true || $int_status != true) { ?> <tr> <td><?php
function extract_files($to_dir, $files = null) { global $filesystem; $this->error = ""; // Make sure the $to_dir is pointing to a valid dir, or we error and return if (!is_dir($to_dir)) { $this->error = "Extract files error: Destination directory ({$to_dir}) does not exist"; return false; } $to_dir = realpath($to_dir) . DIRECTORY_SEPARATOR; //+------------------------------ // Get the file info from the tar //+------------------------------ $in_files = $this->read_tar(); if (!empty($this->error)) { return false; } $error_files = array(); foreach ($in_files as $k => $file) { //----------------------------------------- // Stop any potential file traversal issues //----------------------------------------- $file['name'] = str_replace('..', '', $file['name']); $error_files[$k] = $file['name']; //--------------------------------------------- // Are we choosing which files to extract? //--------------------------------------------- if (is_array($files) && !in_array($file['name'], $files)) { continue; } //--------------------------------------------- // GNU TAR format dictates that all paths *must* be in the *nix // format - if this is not the case, blame the tar vendor, not me! //--------------------------------------------- if (preg_match("#/#", $file['name'])) { $path_info = explode("/", $file['name']); $file_name = array_pop($path_info); } else { $path_info = array(); $file_name = $file['name']; } //--------------------------------------------- // If we have a path, then we must build the directory tree //--------------------------------------------- $cur_dir = $to_dir; if (count($path_info) > 0) { foreach ($path_info as $dir_component) { if (empty($dir_component)) { continue; } $cur_dir .= $dir_component . '/'; if (file_exists($cur_dir) && !is_dir($cur_dir)) { $this->warnings[] = "{$cur_dir} exists, but is not a directory"; continue; } if (!is_dir($cur_dir)) { $filesystem->mkdir($cur_dir, 0777); } else { $filesystem->chmod($cur_dir, 0777); } } } //--------------------------------------------- // check the typeflags, and work accordingly //--------------------------------------------- if (empty($file['typeflag'])) { $chmod_changed = false; if (file_exists($cur_dir . $file_name)) { $chmod = get_chmod($cur_dir . $file_name, true); $filesystem->chmod($cur_dir . $file_name, 0666); $chmod_changed = true; } if ($filesystem->file_put_contents($cur_dir . $file_name, $file['data'], true)) { unset($error_files[$k]); } else { $this->warnings[] = "Could not write data to {$cur_dir}{$file_name}"; } if ($chmod_changed == true) { $filesystem->chmod($cur_dir . $file_name, $chmod); } } else { if ($file['typeflag'] == 5) { if (file_exists($cur_dir . $file_name) && !is_dir($cur_dir . $file_name)) { $this->warnings[] = "{$cur_dir}{$file_name} exists, but is not a directory"; continue; } if (!is_dir($cur_dir . $file_name)) { if ($filesystem->mkdir($cur_dir . $file_name, 0777)) { unset($error_files[$k]); } } else { $filesystem->chmod($cur_dir . $file_name, 0777); unset($error_files[$k]); } } else { if ($file['typeflag'] == 6) { $this->warnings[] = "Cannot handle named pipes"; continue; } else { if ($file['typeflag'] == 1) { $this->warnings[] = "Cannot handle system links"; continue; } else { if ($file['typeflag'] == 4) { $this->warnings[] = "Cannot handle device files"; continue; } else { if ($file['typeflag'] == 3) { $this->warnings[] = "Cannot handle device files"; continue; } else { $this->warnings[] = "Unknown typeflag found"; continue; } } } } } } if ($this->ignore_chmod == false) { if (!$filesystem->chmod($cur_dir . $file_name, $file['mode'])) { $this->warnings[] = "CHMOD {$file['mode']} on {$cur_dir}{$file_name} failed!"; } } @touch($cur_dir . $file_name, $file['mtime']); } return $error_files; }
<?php echo foot(); } elseif ($job == "newdir2") { $chmod = $gpc->get('chmod', int); $name = $gpc->get('name', str, 'New Directory'); $path = urldecode($gpc->get('path', none)); $new = $path . $name . '/'; echo head(); if ($filesystem->mkdir($new, chmod_str2oct($chmod))) { ok('admin.php?action=explorer&path=' . urlencode($new)); } else { error('admin.php?action=explorer&path=' . urlencode($path)); } } elseif ($job == "chmod") { $path = $gpc->get('path', none); $chmod = get_chmod($path); echo head(' onload="octalchange()"'); ?> <form name="form" method="post" action="admin.php?action=explorer&job=chmod2"> <input type="hidden" name="path" value="<?php echo $path; ?> "> <table class="border"> <tr> <td class="obox" colspan="2">Set CHMOD</td> </tr> <tr> <td class="mbox">New CHMOD:</td> <td class="mbox"><input type="text" name="chmod" id="chmod" value="<?php echo $chmod;
function showContent($print = true) { $dir_list = $file_list = $subdir_size_list = array(); $total_dir_size = 0; if (($dir_handle = opendir($this->path)) === false) { $this->error("Could NOT open dir: " . realpath($this->path)); return false; } while (($file = @readdir($dir_handle)) !== false) { if ($file == '.' || $file == '..') { continue; } if (is_dir($this->path . $file)) { $dir_list[] = $file; if ($this->show_subfolders_size) { $stack = array($this->path . $file . '/'); $size = 0; while (count($stack) > 0) { $subdir = array_shift($stack); $subdir_handle = @opendir($subdir); while (($subdir_file = @readdir($subdir_handle)) !== false) { if ($subdir_file == '.' || $subdir_file == '..') { continue; } if ($this->show_subfolders_size) { if (is_dir($subdir . $subdir_file)) { array_push($stack, $subdir . $subdir_file . '/'); } } $size += @filesize($subdir . $subdir_file); } @closedir($subdir_handle); } $subdir_size_list[$file] = $size; $total_dir_size += $size; } } else { $file_list[] = $file; $total_dir_size += @filesize($this->path . $file); } } @closedir($dir_handle); natcasesort($dir_list); natcasesort($file_list); $total_files = count($dir_list) + count($file_list); $total_size = $this->formatSize($total_dir_size); $print_spacer = count($file_list) > 0 && count($dir_list) > 0 ? true : false; $page_link = $this->realPath(viscacha_dirname($this->script_file) . '/' . $this->path); $rp = realpath($this->path); $root = realpath('../' . $this->root); $rp = str_replace($root, '', $rp); $heading_path = $this->realPath($rp); $heading_path_parts = explode("/", $heading_path); $levels = count($heading_path_parts) - 2; for ($heading_path = ""; $levels > -1; $levels--) { for ($i = 0, $path = ""; $i < $levels; $i++) { $path .= "../"; } $link = '&path=' . urlencode($this->realPath($this->path . $path)); $heading_path .= '<a href="' . $this->script_file . $link . '">' . array_shift($heading_path_parts) . '</a>' . DIRECTORY_SEPARATOR; } $newdir = $this->script_file . '&path=' . urlencode(str_replace('/\\', '/', $this->path)); $newdir_html = '<span style="float: right;">[<a href="' . $newdir . '&job=newdir">Create new directory</a>]</span>'; $html = ' <table cellpadding="4" cellspacing="0" class="border">'; $html .= "\n" . ' <tr>'; $html .= "\n" . ' <td class="obox">Filemanager</td>'; $html .= "\n" . ' </tr>'; $html .= "\n" . ' <tr>'; $html .= "\n" . ' <td class="ubox">Directory: ' . realpath('../' . $this->root) . $heading_path . '</td>'; $html .= "\n" . ' </tr>'; $html .= "\n" . ' </table><br />'; $html .= "\n" . ' <table cellpadding="4" cellspacing="0" class="border">'; if (count($dir_list) > 0) { $html .= "\n" . ' <tr>'; $html .= "\n" . ' <td class="obox" colspan="5">' . $newdir_html . ' Directories</td>'; $html .= "\n" . ' </tr>'; $html .= "\n" . ' <tr>'; $html .= "\n" . ' <td class="ubox" width="30%">Directory</td>'; $html .= "\n" . ' <td class="ubox" width="9%">Size</td>'; $html .= "\n" . ' <td class="ubox" width="20%">Created on</td>'; $html .= "\n" . ' <td class="ubox" width="8%">CHMOD</td>'; $html .= "\n" . ' <td class="ubox" width="33%">Action</td>'; $html .= "\n" . ' </tr>'; } while (($dir = array_shift($dir_list)) !== NULL) { $path_url = '&path=' . urlencode(str_replace('/\\', '/', $this->path) . $dir . '/'); $link = $this->script_file . $path_url; $size = $this->show_subfolders_size ? $this->formatSize($subdir_size_list[$dir]) : " "; $chmod = get_chmod($this->path . $dir); $icon = $this->icons('directory'); $html .= "\n" . ' <tr>'; $html .= "\n" . ' <td class="mbox">'; $html .= "\n" . ' <a href="' . $link . '" target="Main">' . $icon . $dir . '</a>'; $html .= "\n" . ' </td>'; $html .= "\n" . ' <td class="mbox" align="right">'; $html .= "\n" . ' ' . $size; $html .= "\n" . ' </td>'; $html .= "\n" . ' <td class="mbox">'; $html .= "\n" . ' ' . date("d.m.y, H:i", @filectime($this->path . $dir)); $html .= "\n" . ' </td>'; $html .= "\n" . ' <td class="mbox" align="right">'; $html .= "\n" . ' ' . $chmod; $html .= "\n" . ' </td>'; $html .= "\n" . ' <td class="mbox">'; $html .= "\n" . ' [<a href="' . $link . '&job=chmod&type=dir">CHMOD</a>] [<a href="' . $link . '&job=rename&type=dir">Rename</a>] [<a href="' . $link . '&job=delete&type=dir">Delete</a>]'; $html .= "\n" . ' </td>'; $html .= "\n" . ' </tr>'; } if ($print_spacer) { $html .= "\n" . ' </table><br />'; $html .= "\n" . ' <table cellpadding="4" cellspacing="0" class="border">'; } if (count($file_list) > 0) { $html .= "\n" . ' <tr>'; $html .= "\n" . ' <td class="obox" colspan="6">' . iif(!$print_spacer, $newdir_html) . 'Files</td>'; $html .= "\n" . ' </tr>'; $html .= "\n" . ' <tr>'; $html .= "\n" . ' <td class="ubox" width="30%">Total: ' . $total_files . ' files (' . $total_size . ')</td>'; $html .= "\n" . ' <td class="ubox" width="7%">Size</td>'; $html .= "\n" . ' <td class="ubox" width="12%">Last modified</td>'; $html .= "\n" . ' <td class="ubox" width="12%">Created in</td>'; $html .= "\n" . ' <td class="ubox" width="7%">CHMOD</td>'; $html .= "\n" . ' <td class="ubox" width="33%">Action</td>'; $html .= "\n" . ' </tr>'; } while (($file = array_shift($file_list)) !== NULL) { $extension = preg_replace("/^.*?\\.(\\w{1,8})\$/", "\\1", $file); $path_url = '&path=' . urlencode(str_replace('/\\', '/', $this->path) . $file); $link = $this->script_file . $path_url; $icon = $this->icons($extension); $html .= "\n" . ' <tr>'; $html .= "\n" . ' <td class="mbox">'; $html .= "\n" . ' <a href="' . str_replace('/\\', '/', $this->path) . $file . '">' . $icon . $file . '</a>'; $html .= "\n" . ' </td>'; $html .= "\n" . ' <td class="mbox" align="right">'; $html .= "\n" . ' ' . $this->formatSize(@filesize($this->path . $file)); $html .= "\n" . ' </td>'; $html .= "\n" . ' <td class="mbox">'; $html .= "\n" . ' ' . date("d.m.y, H:i", @filemtime($this->path . $file)); $html .= "\n" . ' </td>'; $html .= "\n" . ' <td class="mbox">'; $html .= "\n" . ' ' . date("d.m.y, H:i", @filectime($this->path . $file)); $html .= "\n" . ' </td>'; $html .= "\n" . ' <td class="mbox" align="right">'; $html .= "\n" . ' ' . get_chmod($this->path . $file); $html .= "\n" . ' </td>'; $html .= "\n" . ' <td class="mbox">'; $html .= "\n" . ' [<a href="' . $link . '&job=chmod">CHMOD</a>] [<a href="' . $link . '&job=rename">Rename</a>] [<a href="' . $link . '&job=delete">Delete</a>]'; $html .= iif(in_array($extension, $this->extract), ' [<a href="' . $link . '&job=extract">Extract</a>]') . iif(in_array($extension, $this->plain), ' [<a href="' . $link . '&job=edit">Edit</a>]'); $html .= "\n" . ' </td>'; $html .= "\n" . ' </tr>'; } $html .= "\n" . ' </table>'; if ($print) { echo $html; } else { return $html; } }
* You should have received a copy of the GNU Affero General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. */ define('EQDKP_INC', true); $eqdkp_root_path = './../../../'; include_once $eqdkp_root_path . 'common.php'; if (!register('user')->is_signedin()) { echo 'You have no permission to see this page as you are not logged in'; exit; } include_once $eqdkp_root_path . 'libraries/elfinder/php/elFinderConnector.class.php'; include_once $eqdkp_root_path . 'libraries/elfinder/php/elFinder.class.php'; include_once $eqdkp_root_path . 'libraries/elfinder/php/elFinderVolumeDriver.class.php'; include_once $eqdkp_root_path . 'libraries/elfinder/php/elFinderVolumeLocalFileSystem.class.php'; /** * Simple function to demonstrate how to control file access using "accessControl" callback. * This method will disable accessing files/folders starting from '.' (dot) * * @param string $attr attribute name (read|write|locked|hidden) * @param string $path file path relative to volume root directory started with directory separator * @return bool|null **/ function access($attr, $path, $data, $volume) { return strpos(basename($path), '.') === 0 ? !($attr == 'read' || $attr == 'write') : null; // else elFinder decide it itself } $opts = array('roots' => array(array('driver' => 'LocalFileSystem', 'path' => register('pfh')->FolderPath('users/' . register('user')->id, 'files'), 'URL' => register('pfh')->FileLink('users/' . register('user')->id . '/', 'files', 'absolute'), 'accessControl' => 'access', 'uploadAllow' => array('image/jpeg', 'image/png', 'image/gif'), 'uploadDeny' => array('all'), 'disabled' => array('extract', 'archive', 'mkdir', 'mkfile', 'help', 'rename', 'download', 'edit'), 'maxFilesInDir' => MAX_FILES_USERFOLDER, 'tmbPathMode' => get_chmod(true)))); // run elFinder $connector = new elFinderConnector(new elFinder($opts)); $connector->run();
* This method will disable accessing files/folders starting from '.' (dot) * * @param string $attr attribute name (read|write|locked|hidden) * @param string $path file path relative to volume root directory started with directory separator * @return bool|null **/ function access($attr, $path, $data, $volume) { if (basename($path) == "index.html") { return !($attr == 'read' || $attr == 'locked'); } return strpos(basename($path), '.') === 0 ? !($attr == 'read' || $attr == 'write') : null; // else elFinder decide it itself } if ($blnIsAdmin) { $opts = array('roots' => array(array('driver' => 'LocalFileSystem', 'path' => register('pfh')->FolderPath('', 'files'), 'startPath' => register('pfh')->FolderPath('system', 'files'), 'URL' => register('pfh')->FileLink('', 'files', 'absolute'), 'accessControl' => 'access', 'uploadAllow' => array('all'), 'uploadDeny' => array('application/x-php', 'application/x-perl', 'application/x-python-bytecode', 'application/x-ruby', 'text/x-php', 'text/x-perl', 'text/x-python-bytecode', 'text/x-ruby', 'text/x-c++'), 'uploadOrder' => array('allow', 'deny'), 'disabled' => array('extract', 'archive', 'mkfile', 'help', 'edit'), 'tmbPathMode' => get_chmod(true)))); } elseif ($blnIsUser) { $opts = array('roots' => array(array('driver' => 'LocalFileSystem', 'path' => register('pfh')->FolderPath('system', 'files'), 'startPath' => register('pfh')->FolderPath('system', 'files'), 'URL' => register('pfh')->FileLink('', 'files', 'absolute'), 'accessControl' => 'access', 'uploadAllow' => array('image/jpeg', 'image/png', 'image/gif', 'application/x-zip-compressed', 'application/zip', 'application/x-zip'), 'uploadDeny' => array('all'), 'disabled' => array('extract', 'archive', 'mkdir', 'mkfile', 'help', 'rename', 'download', 'edit')))); } if (register('input')->get('sf') != "") { $path = register('encrypt')->decrypt(str_replace(" ", "+", register('input')->get('sf'))); $rel_path = str_replace(register('environment')->link, registry::get_const('root_path'), $path); $opts['roots'][0]['path'] = $opts['roots'][0]['startPath'] = $rel_path; $opts['roots'][0]['URL'] = $path; register('pfh')->FolderPath($rel_path); } //Create system folder register('pfh')->FolderPath('system', 'files'); // run elFinder $connector = new elFinderConnector(new elFinder($opts)); $connector->run();