Ejemplo n.º 1
0
 function execAction($dir)
 {
     if (($GLOBALS["permissions"] & 01) != 01) {
         ext_Result::sendResult('upload', false, $GLOBALS["error_msg"]["accessfunc"]);
     }
     $this->_downloadMethods = array(new CurlDownloader(), new WgetDownloader(), new FopenDownloader(), new FsockopenDownloader());
     //DEBUG ext_Result::sendResult('transfer', false, $dir );
     // Execute
     if (isset($GLOBALS['__POST']["confirm"]) && $GLOBALS['__POST']["confirm"] == "true") {
         // CSRF Security Check
         if (!ext_checkToken($GLOBALS['__POST']["token"])) {
             ext_Result::sendResult('tokencheck', false, 'Request failed: Security Token not valid.');
         }
         $cnt = count($GLOBALS['__POST']['userfile']);
         $err = false;
         foreach ($this->_downloadMethods as $method) {
             if ($method->isSupported()) {
                 $downloader =& $method;
                 break;
             }
         }
         // upload files & check for errors
         for ($i = 0; $i < $cnt; $i++) {
             $errors[$i] = NULL;
             $items[$i] = stripslashes(basename($GLOBALS['__POST']['userfile'][$i]));
             $abs = get_abs_item($dir, $items[$i]);
             if ($items[$i] == "") {
                 continue;
             }
             if (@file_exists($abs) && empty($_REQUEST['overwrite_files'])) {
                 $errors[$i] = $GLOBALS["error_msg"]["itemdoesexist"];
                 $err = true;
                 continue;
             }
             // Upload
             $ok = $downloader->download($GLOBALS['__POST']['userfile'][$i], $abs);
             if ($ok === true) {
                 $mode = ext_isFTPMode() ? 644 : 0644;
                 @$GLOBALS['ext_File']->chmod($abs, $mode);
             } else {
                 $errors[$i] = $ok;
                 $err = true;
                 continue;
             }
         }
         if ($err) {
             // there were errors
             $err_msg = "";
             for ($i = 0; $i < $cnt; $i++) {
                 if ($errors[$i] == NULL) {
                     continue;
                 }
                 $err_msg .= $items[$i] . " : " . $errors[$i] . "\n";
             }
             ext_Result::sendResult('transfer', false, $err_msg);
         }
         ext_Result::sendResult('transfer', true, ext_Lang::msg('transfer_completed'));
         return;
     }
 }
Ejemplo n.º 2
0
 function execAction($dir, $item)
 {
     if (!ext_isArchive($item)) {
         ext_Result::sendResult('archive', false, $item . ': ' . ext_Lang::err('extract_noarchive'));
     } else {
         // CSRF Security Check
         if (!ext_checkToken($GLOBALS['__POST']["token"])) {
             ext_Result::sendResult('tokencheck', false, 'Request failed: Security Token not valid.');
         }
         $archive_name = realpath(get_abs_item($dir, $item));
         if (empty($dir)) {
             $extract_dir = realpath($GLOBALS['home_dir']);
         } else {
             $extract_dir = realpath($GLOBALS['home_dir'] . "/" . $dir);
         }
         require_once _EXT_PATH . '/libraries/Archive/archive.php';
         $res = extArchive::extract($archive_name, $extract_dir);
         if (PEAR::isError($res)) {
             ext_Result::sendResult('extract', false, ext_Lang::err('extract_failure') . ' - ' . $res->getMessage());
         }
         if ($res === false) {
             ext_Result::sendResult('extract', false, ext_Lang::err('extract_failure'));
         } else {
             ext_Result::sendResult('extract', true, ext_Lang::msg('extract_success'));
         }
         ext_Result::sendResult('extract', true, ext_Lang::msg('extract_success'));
     }
 }
Ejemplo n.º 3
0
function make_item($dir)
{
    if (!permissions_grant($dir, NULL, "create")) {
        show_error($GLOBALS["error_msg"]["accessfunc"]);
    }
    $mkname = $GLOBALS['__POST']["mkname"];
    $mktype = $GLOBALS['__POST']["mktype"];
    $mkname = basename(stripslashes($mkname));
    if ($mkname == "") {
        show_error($GLOBALS["error_msg"]["miscnoname"]);
    }
    $new = get_abs_item($dir, $mkname);
    if (@file_exists($new)) {
        show_error($mkname . ": " . $GLOBALS["error_msg"]["itemdoesexist"]);
    }
    if ($mktype != "file") {
        $ok = @mkdir($new, 0777);
        $err = $GLOBALS["error_msg"]["createdir"];
    } else {
        $ok = @touch($new);
        $err = $GLOBALS["error_msg"]["createfile"];
    }
    if ($ok === false) {
        show_error($err);
    }
    header("Location: " . make_link("list", $dir, NULL));
}
Ejemplo n.º 4
0
function download_item($dir, $item)
{
    // Security Fix:
    $item = basename($item);
    while (@ob_end_clean()) {
    }
    ob_start();
    if (!get_is_file($dir, $item)) {
        show_error($item . ": " . $GLOBALS["error_msg"]["fileexist"]);
    }
    if (!get_show_item($dir, $item)) {
        show_error($item . ": " . $GLOBALS["error_msg"]["accessfile"]);
    }
    $abs_item = get_abs_item($dir, $item);
    $browser = id_browser();
    header('Content-Type: ' . ($browser == 'IE' || $browser == 'OPERA' ? 'application/octetstream' : 'application/octet-stream'));
    header('Expires: ' . gmdate('D, d M Y H:i:s') . ' GMT');
    header('Content-Transfer-Encoding: binary');
    header('Content-Length: ' . filesize(realpath($abs_item)));
    //header("Content-Encoding: none");
    if ($browser == 'IE') {
        header('Content-Disposition: attachment; filename="' . $item . '"');
        header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
        header('Pragma: public');
    } else {
        header('Content-Disposition: attachment; filename="' . $item . '"');
        header('Cache-Control: no-cache, must-revalidate');
        header('Pragma: no-cache');
    }
    @set_time_limit(0);
    @readfile($abs_item);
    ob_end_flush();
    exit;
}
Ejemplo n.º 5
0
function find_item($dir, $pat, &$list, $recur)
{
    // find items
    $handle = @opendir(get_abs_dir($dir));
    if ($handle === false) {
        return;
    }
    // unable to open dir
    while (($new_item = readdir($handle)) !== false) {
        if (!@file_exists(get_abs_item($dir, $new_item))) {
            continue;
        }
        if (!get_show_item($dir, $new_item)) {
            continue;
        }
        // match?
        if (@eregi($pat, $new_item)) {
            $list[] = array($dir, $new_item);
        }
        // search sub-directories
        if (get_is_dir($dir, $new_item) && $recur) {
            find_item(get_rel_item($dir, $new_item), $pat, $list, $recur);
        }
    }
    closedir($handle);
}
Ejemplo n.º 6
0
/**
 * @version $Id: search.php 98 2008-02-11 17:56:04Z soeren $
 * @package eXtplorer
 * @copyright soeren 2007
 * @author The eXtplorer project (http://sourceforge.net/projects/extplorer)
 * @author The  The QuiX project (http://quixplorer.sourceforge.net)
 * 
 * @license
 * The contents of this file are subject to the Mozilla Public License
 * Version 1.1 (the "License"); you may not use this file except in
 * compliance with the License. You may obtain a copy of the License at
 * http://www.mozilla.org/MPL/
 * 
 * Software distributed under the License is distributed on an "AS IS"
 * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
 * License for the specific language governing rights and limitations
 * under the License.
 * 
 * Alternatively, the contents of this file may be used under the terms
 * of the GNU General Public License Version 2 or later (the "GPL"), in
 * which case the provisions of the GPL are applicable instead of
 * those above. If you wish to allow use of your version of this file only
 * under the terms of the GPL and not to allow others to use
 * your version of this file under the MPL, indicate your decision by
 * deleting  the provisions above and replace  them with the notice and
 * other provisions required by the GPL.  If you do not delete
 * the provisions above, a recipient may use your version of this file
 * under either the MPL or the GPL."
 * 
 * File-Search Functions
 */
function find_item($dir, $pat, &$list, $recur)
{
    // find items
    $homedir = realpath($GLOBALS['home_dir']);
    $handle = @$GLOBALS['ext_File']->opendir(get_abs_dir($dir));
    if ($handle === false && $dir == "") {
        $handle = @$GLOBALS['ext_File']->opendir($homedir . $GLOBALS['separator']);
    }
    if ($handle === false) {
        ext_Result::sendResult('search', false, $dir . ": " . $GLOBALS["error_msg"]["opendir"]);
    }
    while (($new_item = $GLOBALS['ext_File']->readdir($handle)) !== false) {
        if (is_array($new_item)) {
            $abs_new_item = $new_item;
        } else {
            $abs_new_item = get_abs_item($dir, $new_item);
        }
        if (!$GLOBALS['ext_File']->file_exists($abs_new_item)) {
            continue;
        }
        if (!get_show_item($dir, $new_item)) {
            continue;
        }
        // match?
        if (@eregi($pat, $new_item)) {
            $list[] = array($dir, $new_item);
        }
        // search sub-directories
        if (get_is_dir($abs_new_item) && $recur) {
            find_item(get_rel_item($dir, $new_item), $pat, $list, $recur);
        }
    }
    $GLOBALS['ext_File']->closedir($handle);
}
Ejemplo n.º 7
0
function download_item($dir, $item)
{
    // download file
    // Security Fix:
    $item = basename($item);
    if (($GLOBALS["permissions"] & 01) != 01) {
        show_error($GLOBALS["error_msg"]["accessfunc"]);
    }
    if (!get_is_file($dir, $item)) {
        show_error($item . ": " . $GLOBALS["error_msg"]["fileexist"]);
    }
    if (!get_show_item($dir, $item)) {
        show_error($item . ": " . $GLOBALS["error_msg"]["accessfile"]);
    }
    $abs_item = get_abs_item($dir, $item);
    $browser = id_browser();
    header('Content-Type: ' . ($browser == 'IE' || $browser == 'OPERA' ? 'application/octetstream' : 'application/octet-stream'));
    header('Expires: ' . gmdate('D, d M Y H:i:s') . ' GMT');
    header('Content-Transfer-Encoding: binary');
    header('Content-Length: ' . filesize($abs_item));
    if ($browser == 'IE') {
        header('Content-Disposition: attachment; filename="' . $item . '"');
        header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
        header('Pragma: public');
    } else {
        header('Content-Disposition: attachment; filename="' . $item . '"');
        header('Cache-Control: no-cache, must-revalidate');
        header('Pragma: no-cache');
    }
    @readfile($abs_item);
    exit;
}
Ejemplo n.º 8
0
 function execAction($dir)
 {
     // delete files/dirs
     if (($GLOBALS["permissions"] & 01) != 01) {
         ext_Result::sendResult('delete', false, $GLOBALS["error_msg"]["accessfunc"]);
     }
     // CSRF Security Check
     if (!ext_checkToken($GLOBALS['__POST']["token"])) {
         ext_Result::sendResult('tokencheck', false, 'Request failed: Security Token not valid.');
     }
     $cnt = count($GLOBALS['__POST']["selitems"]);
     $err = false;
     // delete files & check for errors
     for ($i = 0; $i < $cnt; ++$i) {
         $items[$i] = basename(stripslashes($GLOBALS['__POST']["selitems"][$i]));
         if (ext_isFTPMode()) {
             $abs = get_item_info($dir, $items[$i]);
         } else {
             $abs = get_abs_item($dir, $items[$i]);
         }
         if (!@$GLOBALS['ext_File']->file_exists($abs)) {
             $error[$i] = $GLOBALS["error_msg"]["itemexist"];
             $err = true;
             continue;
         }
         if (!get_show_item($dir, $items[$i])) {
             $error[$i] = $GLOBALS["error_msg"]["accessitem"];
             $err = true;
             continue;
         }
         // Delete
         if (ext_isFTPMode()) {
             $abs = str_replace('\\', '/', get_abs_item($dir, $abs));
         }
         $ok = $GLOBALS['ext_File']->remove($abs);
         if ($ok === false || PEAR::isError($ok)) {
             $error[$i] = $GLOBALS["error_msg"]["delitem"];
             if (PEAR::isError($ok)) {
                 $error[$i] .= ' [' . $ok->getMessage() . ']';
             }
             $err = true;
             continue;
         }
         $error[$i] = NULL;
     }
     if ($err) {
         // there were errors
         $err_msg = "";
         for ($i = 0; $i < $cnt; ++$i) {
             if ($error[$i] == NULL) {
                 continue;
             }
             $err_msg .= $items[$i] . " : " . $error[$i] . ".\n";
         }
         ext_Result::sendResult('delete', false, $err_msg);
     }
     ext_Result::sendResult('delete', true, $GLOBALS['messages']['success_delete_file']);
 }
Ejemplo n.º 9
0
function zip_items($dir, $name)
{
    $items = qxpage_selected_items();
    if (!preg_match("/\\.zip\$/", $name)) {
        $name .= ".zip";
    }
    zip_selected_items(get_abs_item($dir, $name), $dir, $items);
    header("Location: " . make_link("list", $dir, NULL));
}
Ejemplo n.º 10
0
function del_items($dir)
{
    $mainframe =& JFactory::getApplication();
    // delete files/dirs
    if (($GLOBALS["permissions"] & 01) != 01) {
        show_error($GLOBALS["error_msg"]["accessfunc"]);
    }
    $cnt = count($GLOBALS['__POST']["selitems"]);
    $err = false;
    // delete files & check for errors
    for ($i = 0; $i < $cnt; ++$i) {
        $items[$i] = stripslashes($GLOBALS['__POST']["selitems"][$i]);
        if (nx_isFTPMode()) {
            $abs = get_item_info($dir, $items[$i]);
        } else {
            $abs = get_abs_item($dir, $items[$i]);
        }
        if (!@$GLOBALS['nx_File']->file_exists($abs)) {
            $error[$i] = $GLOBALS["error_msg"]["itemexist"];
            $err = true;
            continue;
        }
        if (!get_show_item($dir, $items[$i])) {
            $error[$i] = $GLOBALS["error_msg"]["accessitem"];
            $err = true;
            continue;
        }
        // Delete
        if (nx_isFTPMode()) {
            $abs = get_abs_item($dir, $abs);
        }
        $ok = $GLOBALS['nx_File']->remove($abs);
        if ($ok === false || PEAR::isError($ok)) {
            $error[$i] = $GLOBALS["error_msg"]["delitem"];
            if (PEAR::isError($ok)) {
                $error[$i] .= ' [' . $ok->getMessage() . ']';
            }
            $err = true;
            continue;
        }
        $error[$i] = NULL;
    }
    if ($err) {
        // there were errors
        $err_msg = "";
        for ($i = 0; $i < $cnt; ++$i) {
            if ($error[$i] == NULL) {
                continue;
            }
            $err_msg .= $items[$i] . " : " . $error[$i] . "<br/>\n";
        }
        show_error($err_msg);
    }
    $mainframe->redirect(make_link("list", $dir, null), $GLOBALS['messages']['success_delete_file']);
}
Ejemplo n.º 11
0
function download_item($dir, $item, $unlink = false)
{
    // download file
    global $action, $mosConfig_cache_path;
    // Security Fix:
    $item = basename($item);
    while (@ob_end_clean()) {
    }
    ob_start();
    if (jx_isFTPMode()) {
        $abs_item = $dir . '/' . $item;
    } else {
        $abs_item = get_abs_item($dir, $item);
        if (!strstr($abs_item, realpath($GLOBALS['home_dir']))) {
            $abs_item = realpath($GLOBALS['home_dir']) . $abs_item;
        }
    }
    if (($GLOBALS["permissions"] & 01) != 01) {
        show_error($GLOBALS["error_msg"]["accessfunc"]);
    }
    if (!$GLOBALS['jx_File']->file_exists($abs_item)) {
        show_error($item . ": " . $GLOBALS["error_msg"]["fileexist"]);
    }
    if (!get_show_item($dir, $item)) {
        show_error($item . ": " . $GLOBALS["error_msg"]["accessfile"]);
    }
    if (jx_isFTPMode()) {
        $abs_item = jx_ftp_make_local_copy($abs_item);
        $unlink = true;
    }
    $browser = id_browser();
    header('Content-Type: ' . ($browser == 'IE' || $browser == 'OPERA' ? 'application/octetstream' : 'application/octet-stream'));
    header('Expires: ' . gmdate('D, d M Y H:i:s') . ' GMT');
    header('Content-Transfer-Encoding: binary');
    header('Content-Length: ' . filesize(realpath($abs_item)));
    //header("Content-Encoding: none");
    if ($browser == 'IE') {
        header('Content-Disposition: attachment; filename="' . $item . '"');
        header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
        header('Pragma: public');
    } else {
        header('Content-Disposition: attachment; filename="' . $item . '"');
        header('Cache-Control: no-cache, must-revalidate');
        header('Pragma: no-cache');
    }
    @set_time_limit(0);
    @readFileChunked($abs_item);
    if ($unlink == true) {
        unlink($abs_item);
    }
    ob_end_flush();
    jx_exit();
}
Ejemplo n.º 12
0
function _is_download_allowed($dir, $items)
{
    foreach ($items as $file) {
        if (!permissions_grant($dir, $file, "read")) {
            return false;
        }
        if (!get_show_item($dir, $file)) {
            return false;
        }
        if (!file_exists(get_abs_item($dir, $file))) {
            return false;
        }
    }
    return true;
}
Ejemplo n.º 13
0
function rename_item($dir, $item)
{
    // rename directory or file
    $mainframe =& JFactory::getApplication();
    if (($GLOBALS["permissions"] & 01) != 01) {
        show_error($GLOBALS["error_msg"]["accessfunc"]);
    }
    if (isset($GLOBALS['__POST']["confirm"]) && $GLOBALS['__POST']["confirm"] == "true") {
        $newitemname = $GLOBALS['__POST']["newitemname"];
        $newitemname = trim(basename(stripslashes($newitemname)));
        if ($newitemname == '') {
            show_error($GLOBALS["error_msg"]["miscnoname"]);
        }
        if (!nx_isFTPMode()) {
            $abs_old = get_abs_item($dir, $item);
            $abs_new = get_abs_item($dir, $newitemname);
        } else {
            $abs_old = get_item_info($dir, $item);
            $abs_new = get_item_info($dir, $newitemname);
        }
        if (@$GLOBALS['nx_File']->file_exists($abs_new)) {
            show_error($newitemname . ": " . $GLOBALS["error_msg"]["itemdoesexist"]);
        }
        $perms_old = $GLOBALS['nx_File']->fileperms($abs_old);
        $ok = $GLOBALS['nx_File']->rename(get_abs_item($dir, $item), get_abs_item($dir, $newitemname));
        if (nx_isFTPMode()) {
            $abs_new = get_item_info($dir, $newitemname);
        }
        $GLOBALS['nx_File']->chmod($abs_new, $perms_old);
        if ($ok === false || PEAR::isError($ok)) {
            show_error('Could not rename ' . $item . ' to ' . $newitemname);
        }
        $msg = sprintf($GLOBALS['messages']['success_rename_file'], $item, $newitemname);
        $mainframe->redirect(make_link("list", $dir, null), $msg);
    }
    show_header($GLOBALS['messages']['rename_file']);
    // Form
    echo '<br /><form method="post" action="';
    echo make_link("rename", $dir, $item) . "\">\n";
    echo "<input type=\"hidden\" name=\"confirm\" value=\"true\" />\n";
    echo "<input type=\"hidden\" name=\"item\" value=\"" . stripslashes($GLOBALS['__GET']["item"]) . "\" />\n";
    // Submit / Cancel
    echo "<table>\n<tr><tr><td colspan=\"2\">\n";
    echo "<label for=\"newitemname\">" . $GLOBALS["messages"]["newname"] . ":</label>&nbsp;&nbsp;&nbsp;<input name=\"newitemname\" id=\"newitemname\" type=\"text\" size=\"60\" value=\"" . stripslashes($_GET['item']) . "\" /><br /><br /><br /></td></tr>\n";
    echo "<tr><tr><td>\n<input type=\"submit\" value=\"" . $GLOBALS["messages"]["btnchange"];
    echo "\"></td>\n<td><input type=\"button\" value=\"" . $GLOBALS["messages"]["btncancel"];
    echo "\" onclick=\"javascript:location='" . make_link("list", $dir, NULL) . "';\">\n</td></tr></form></table><br />\n";
}
Ejemplo n.º 14
0
function zip_items($dir, $name)
{
    $cnt = count($GLOBALS['__POST']["selitems"]);
    $abs_dir = get_abs_dir($dir);
    $zipfile = new ZipFile();
    for ($i = 0; $i < $cnt; ++$i) {
        $selitem = stripslashes($GLOBALS['__POST']["selitems"][$i]);
        if (!$zipfile->add($abs_dir, $selitem)) {
            show_error($selitem . ": Failed adding item.");
        }
    }
    if (!$zipfile->save(get_abs_item($dir, $name))) {
        show_error($name . ": Failed saving zipfile.");
    }
    header("Location: " . make_link("list", $dir, NULL));
}
Ejemplo n.º 15
0
function download_item($dir, $item)
{
    // Security Fix:
    $item = basename($item);
    if (!permissions_grant($dir, $item, "read")) {
        show_error($GLOBALS["error_msg"]["accessfunc"]);
    }
    if (!get_is_file($dir, $item)) {
        show_error($item . ": " . $GLOBALS["error_msg"]["fileexist"]);
    }
    if (!get_show_item($dir, $item)) {
        show_error($item . ": " . $GLOBALS["error_msg"]["accessfile"]);
    }
    $abs_item = get_abs_item($dir, $item);
    _download($abs_item, $item);
}
Ejemplo n.º 16
0
/**
 * @version $Id: search.php 201 2011-06-27 09:45:09Z soeren $
 * @package eXtplorer
 * @copyright soeren 2007-2013
 * @author The eXtplorer project (http://extplorer.net)
 * @author The	The QuiX project (http://quixplorer.sourceforge.net)
 *
 * @license
 * The contents of this file are subject to the Mozilla Public License
 * Version 1.1 (the "License"); you may not use this file except in
 * compliance with the License. You may obtain a copy of the License at
 * http://www.mozilla.org/MPL/
 *
 * Software distributed under the License is distributed on an "AS IS"
 * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
 * License for the specific language governing rights and limitations
 * under the License.
 *
 * Alternatively, the contents of this file may be used under the terms
 * of the GNU General Public License Version 2 or later (the "GPL"), in
 * which case the provisions of the GPL are applicable instead of
 * those above. If you wish to allow use of your version of this file only
 * under the terms of the GPL and not to allow others to use
 * your version of this file under the MPL, indicate your decision by
 * deleting  the provisions above and replace  them with the notice and
 * other provisions required by the GPL.  If you do not delete
 * the provisions above, a recipient may use your version of this file
 * under either the MPL or the GPL."
 *
 * File-Search Functions
 */
function find_item($dir, $pat, &$list, $recur, $content)
{
    // find items
    $homedir = realpath($GLOBALS['home_dir']);
    $opendir = $dir;
    if (!is_dir($dir)) {
        $opendir = get_abs_dir($dir);
    }
    $handle = @$GLOBALS['ext_File']->opendir($opendir);
    if ($handle === false && $dir == "") {
        $handle = @$GLOBALS['ext_File']->opendir($homedir . $GLOBALS['separator']);
    }
    if ($handle === false) {
        ext_Result::sendResult('search', false, $opendir . ": " . $GLOBALS["error_msg"]["opendir"]);
    }
    while (($new_item = $GLOBALS['ext_File']->readdir($handle)) !== false) {
        if (is_array($new_item)) {
            $abs_new_item = $new_item;
        } else {
            $abs_new_item = get_abs_item($dir, $new_item);
        }
        //if(!$GLOBALS['ext_File']->file_exists($abs_new_item)) continue;
        if (!get_show_item($dir, $new_item)) {
            continue;
        }
        $isDir = get_is_dir($abs_new_item);
        // match?
        if (@preg_match('@' . $pat . '@is', $new_item) > 0) {
            $list[] = array($dir, $new_item);
        } else {
            if (!$isDir) {
                if ($content && $GLOBALS['ext_File']->filesize($abs_new_item) < 524288) {
                    $data = $GLOBALS['ext_File']->file_get_contents($abs_new_item);
                    //$data = fread($handle, 524288); // Only read first 512kb
                    if (preg_match('@' . $pat . '@is', $data) > 0) {
                        $list[] = array($dir, $new_item);
                    }
                }
            }
        }
        // search sub-directories
        if ($isDir && $recur) {
            find_item($abs_new_item, $pat, $list, $recur, $content);
        }
    }
    $GLOBALS['ext_File']->closedir($handle);
}
Ejemplo n.º 17
0
function del_items($dir)
{
    // check if user is allowed to delete files
    if (!permissions_grant($dir, NULL, "delete")) {
        show_error($GLOBALS["error_msg"]["accessfunc"]);
    }
    $cnt = count($GLOBALS['__POST']["selitems"]);
    $err = false;
    // delete files & check for errors
    for ($i = 0; $i < $cnt; ++$i) {
        $items[$i] = stripslashes($GLOBALS['__POST']["selitems"][$i]);
        $abs = get_abs_item($dir, $items[$i]);
        if (!@file_exists(get_abs_item($dir, $items[$i]))) {
            $error[$i] = $GLOBALS["error_msg"]["itemexist"];
            $err = true;
            continue;
        }
        if (!get_show_item($dir, $items[$i])) {
            $error[$i] = $GLOBALS["error_msg"]["accessitem"];
            $err = true;
            continue;
        }
        // Delete
        $ok = remove(get_abs_item($dir, $items[$i]));
        if ($ok === false) {
            $error[$i] = $GLOBALS["error_msg"]["delitem"];
            $err = true;
            continue;
        }
        $error[$i] = NULL;
    }
    if ($err) {
        // there were errors
        $err_msg = "";
        for ($i = 0; $i < $cnt; ++$i) {
            if ($error[$i] == NULL) {
                continue;
            }
            $err_msg .= $items[$i] . " : " . $error[$i] . "<BR>\n";
        }
        show_error($err_msg);
    }
    miwoftp_redirect(make_link("list", $dir, NULL));
}
Ejemplo n.º 18
0
function del_items($dir)
{
    // delete files/dirs
    if (($GLOBALS["permissions"] & 01) != 01) {
        show_error($GLOBALS["error_msg"]["accessfunc"]);
    }
    $cnt = count($GLOBALS['__POST']["selitems"]);
    $err = false;
    // delete files & check for errors
    for ($i = 0; $i < $cnt; ++$i) {
        $items[$i] = stripslashes($GLOBALS['__POST']["selitems"][$i]);
        $abs = get_abs_item($dir, $items[$i]);
        if (!@file_exists(get_abs_item($dir, $items[$i]))) {
            $error[$i] = $GLOBALS["error_msg"]["itemexist"];
            $err = true;
            continue;
        }
        if (!get_show_item($dir, $items[$i])) {
            $error[$i] = $GLOBALS["error_msg"]["accessitem"];
            $err = true;
            continue;
        }
        // Delete
        $ok = remove(get_abs_item($dir, $items[$i]));
        if ($ok === false) {
            $error[$i] = $GLOBALS["error_msg"]["delitem"];
            $err = true;
            continue;
        }
        $error[$i] = NULL;
    }
    if ($err) {
        // there were errors
        $err_msg = "";
        for ($i = 0; $i < $cnt; ++$i) {
            if ($error[$i] == NULL) {
                continue;
            }
            $err_msg .= $items[$i] . " : " . $error[$i] . "<BR>\n";
        }
        show_error($err_msg);
    }
    header("Location: " . make_link("list", $dir, NULL));
}
Ejemplo n.º 19
0
function download_item($dir, $item)
{
    // download file
    // Security Fix:
    $item = base_name($item);
    if (($GLOBALS["permissions"] & 01) != 01) {
        show_error($GLOBALS["error_msg"]["accessfunc"]);
    }
    if (!get_is_file($dir, $item)) {
        show_error($item . ": " . $GLOBALS["error_msg"]["fileexist"]);
    }
    if (!get_show_item($dir, $item)) {
        show_error($item . ": " . $GLOBALS["error_msg"]["accessfile"]);
    }
    $abs_item = get_abs_item($dir, $item);
    $browser = id_browser();
    header('Content-Type: ' . ($browser == 'IE' || $browser == 'OPERA' ? 'application/octetstream' : 'application/octet-stream'));
    header('Expires: ' . gmdate('D, d M Y H:i:s') . ' GMT');
    header('Content-Transfer-Encoding: binary');
    header('Content-Length: ' . get_file_size($dir, $item));
    header('Content-Description: File Download');
    if ($browser == 'IE') {
        header('Content-Disposition: attachment; filename="' . $item . '"');
        header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
        header('Pragma: public');
    } else {
        header('Content-Disposition: attachment; filename="' . $item . '"');
        header('Cache-Control: no-cache, must-revalidate');
        header('Pragma: no-cache');
    }
    //@readfile($abs_item);
    flush();
    $fp = popen("tail -c " . get_file_size($dir, $item) . " {$abs_item} 2>&1", "r");
    while (!feof($fp)) {
        // Send the current file part to the browser.
        print fread($fp, 1024);
        // Flush the content to the browser.
        flush();
    }
    fclose($fp);
    exit;
}
Ejemplo n.º 20
0
function make_item($dir)
{
    // make new directory or file
    if (($GLOBALS["permissions"] & 01) != 01) {
        show_error($GLOBALS["error_msg"]["accessfunc"]);
    }
    $mkname = $GLOBALS['__POST']["mkname"];
    $mktype = $GLOBALS['__POST']["mktype"];
    $symlink_target = $GLOBALS['__POST']['symlink_target'];
    $mkname = basename(stripslashes($mkname));
    if ($mkname == "") {
        show_error($GLOBALS["error_msg"]["miscnoname"]);
    }
    $new = get_abs_item($dir, $mkname);
    if (@$GLOBALS['jx_File']->file_exists($new)) {
        show_error($mkname . ": " . $GLOBALS["error_msg"]["itemdoesexist"]);
    }
    if ($mktype == "dir") {
        $ok = @$GLOBALS['jx_File']->mkdir($new, 0777);
        $err = $GLOBALS["error_msg"]["createdir"];
    } elseif ($mktype == 'file') {
        $ok = @$GLOBALS['jx_File']->mkfile($new);
        $err = $GLOBALS["error_msg"]["createfile"];
    } elseif ($mktype == 'symlink') {
        if (empty($symlink_target)) {
            show_error('Please provide a valid <strong>target</strong> for the symbolic link.');
        }
        if (!file_exists($symlink_target) || !is_readable($symlink_target)) {
            show_error('The file you wanted to make a symbolic link to does not exist or is not accessible by PHP.');
        }
        $ok = symlink($symlink_target, $new);
        $err = 'The symbolic link could not be created.';
    }
    if ($ok === false || PEAR::isError($ok)) {
        if (PEAR::isError($ok)) {
            $err .= $ok->getMessage();
        }
        show_error($err);
    }
    header("Location: " . make_link("list", $dir, NULL));
}
Ejemplo n.º 21
0
 function execAction($dir, $item)
 {
     if (!ext_isArchive($item)) {
         ext_Result::sendResult('archive', false, $item . ': ' . ext_Lang::err('extract_noarchive'));
     } else {
         $archive_name = realpath(get_abs_item($dir, $item));
         if (empty($dir)) {
             $extract_dir = realpath($GLOBALS['home_dir']);
         } else {
             $extract_dir = realpath($GLOBALS['home_dir'] . "/" . $dir);
         }
         require_once _EXT_PATH . '/libraries/Archive/archive.php';
         $res = extArchive::extract($archive_name, $extract_dir);
         if (PEAR::isError($res)) {
             ext_Result::sendResult('extract', false, ext_Lang::err('extract_failure') . ' - ' . $res->getMessage());
         }
         if ($res === false) {
             ext_Result::sendResult('extract', false, ext_Lang::err('extract_failure'));
         } else {
             ext_Result::sendResult('extract', true, ext_Lang::msg('extract_success'));
         }
         ext_Result::sendResult('extract', true, ext_Lang::msg('extract_success'));
     }
 }
Ejemplo n.º 22
0
function edit_file($dir, $item)
{
    // edit file
    if (($GLOBALS["permissions"] & 01) != 01) {
        show_error($GLOBALS["error_msg"]["accessfunc"]);
    }
    if (!get_is_file($dir, $item)) {
        show_error($item . ": " . $GLOBALS["error_msg"]["fileexist"]);
    }
    if (!get_show_item($dir, $item)) {
        show_error($item . ": " . $GLOBALS["error_msg"]["accessfile"]);
    }
    $fname = get_abs_item($dir, $item);
    if (isset($GLOBALS['__POST']["dosave"]) && $GLOBALS['__POST']["dosave"] == "yes") {
        // Save / Save As
        $item = base_name(stripslashes($GLOBALS['__POST']["fname"]));
        $fname2 = get_abs_item($dir, $item);
        if (!isset($item) || $item == "") {
            show_error($GLOBALS["error_msg"]["miscnoname"]);
        }
        if ($fname != $fname2 && @file_exists($fname2)) {
            show_error($item . ": " . $GLOBALS["error_msg"]["itemdoesexist"]);
        }
        savefile($fname2);
        $fname = $fname2;
    }
    // open file
    $fp = @fopen($fname, "r");
    if ($fp === false) {
        show_error($item . ": " . $GLOBALS["error_msg"]["openfile"]);
    }
    // header
    $s_item = get_rel_item($dir, $item);
    if (strlen($s_item) > 50) {
        $s_item = "..." . substr($s_item, -47);
    }
    show_header($GLOBALS["messages"]["actedit"] . ": /" . $s_item);
    // Wordwrap (works only in IE)
    ?>
<script language="JavaScript1.2" type="text/javascript">
<!--
	function chwrap() {
		if(document.editfrm.wrap.checked) {
			document.editfrm.code.wrap="soft";
		} else {
			document.editfrm.code.wrap="off";
		}
	}
// -->
</script><?php 
    // Form
    echo "<BR><FORM name=\"editfrm\" method=\"post\" action=\"" . make_link("edit", $dir, $item) . "\">\n";
    echo "<input type=\"hidden\" name=\"dosave\" value=\"yes\">\n";
    echo "<TEXTAREA NAME=\"code\" rows=\"25\" cols=\"120\" wrap=\"off\">";
    // Show File In TextArea
    $buffer = "";
    while (!feof($fp)) {
        $buffer .= fgets($fp, 4096);
    }
    @fclose($fp);
    echo htmlspecialchars($buffer);
    echo "</TEXTAREA><BR>\n<TABLE><TR><TD>Wordwrap: (IE only)</TD><TD><INPUT type=\"checkbox\" name=\"wrap\" ";
    echo "onClick=\"javascript:chwrap();\" value=\"1\"></TD></TR></TABLE><BR>\n";
    echo "<TABLE><TR><TD><INPUT type=\"text\" name=\"fname\" value=\"" . $item . "\"></TD>";
    echo "<TD><input type=\"submit\" value=\"" . $GLOBALS["messages"]["btnsave"];
    echo "\"></TD>\n<TD><input type=\"reset\" value=\"" . $GLOBALS["messages"]["btnreset"] . "\"></TD>\n<TD>";
    echo "<input type=\"button\" value=\"" . $GLOBALS["messages"]["btnclose"] . "\" onClick=\"javascript:location='";
    echo make_link("list", $dir, NULL) . "';\"></TD></TR></FORM></TABLE><BR>\n";
    ?>
<script language="JavaScript1.2" type="text/javascript">
<!--
	if(document.editfrm) document.editfrm.code.focus();
// -->
</script><?php 
}
Ejemplo n.º 23
0
    function execAction($dir)
    {
        // make new directory or file
        if (($GLOBALS["permissions"] & 01) != 01) {
            ext_Result::sendResult('mkitem', false, $GLOBALS["error_msg"]["accessfunc"]);
        }
        if (extGetParam($_POST, 'confirm') == 'true') {
            // CSRF Security Check
            if (!ext_checkToken($GLOBALS['__POST']["token"])) {
                ext_Result::sendResult('tokencheck', false, 'Request failed: Security Token not valid.');
            }
            $mkname = $GLOBALS['__POST']["mkname"];
            $mktype = $GLOBALS['__POST']["mktype"];
            $symlink_target = $GLOBALS['__POST']['symlink_target'];
            $mkname = basename(stripslashes($mkname));
            if ($mkname == "") {
                ext_Result::sendResult('mkitem', false, $GLOBALS["error_msg"]["miscnoname"]);
            }
            $new = get_abs_item($dir, $mkname);
            if (@$GLOBALS['ext_File']->file_exists($new)) {
                ext_Result::sendResult('mkitem', false, $mkname . ": " . $GLOBALS["error_msg"]["itemdoesexist"]);
            }
            $err = print_r($_POST, true);
            if ($mktype == "dir") {
                $ok = @$GLOBALS['ext_File']->mkdir($new, 0777);
                $err = $GLOBALS["error_msg"]["createdir"];
            } elseif ($mktype == 'file') {
                $ok = @$GLOBALS['ext_File']->mkfile($new);
                $err = $GLOBALS["error_msg"]["createfile"];
            } elseif ($mktype == 'symlink') {
                if (empty($symlink_target)) {
                    ext_Result::sendResult('mkitem', false, 'Please provide a valid <strong>target</strong> for the symbolic link.');
                }
                if (!file_exists($symlink_target) || !is_readable($symlink_target)) {
                    ext_Result::sendResult('mkitem', false, 'The file you wanted to make a symbolic link to does not exist or is not accessible by PHP.');
                }
                $ok = symlink($symlink_target, $new);
                $err = 'The symbolic link could not be created.';
            }
            if ($ok == false || PEAR::isError($ok)) {
                if (PEAR::isError($ok)) {
                    $err .= $ok->getMessage();
                }
                ext_Result::sendResult('mkitem', false, $err);
            }
            ext_Result::sendResult('mkitem', true, 'The item ' . $new . ' was created');
            return;
        }
        ?>
		{
		"xtype": "form",
		"id": "simpleform",
		"labelWidth": 125,
		"url":"<?php 
        echo basename($GLOBALS['script_name']);
        ?>
",
		"dialogtitle": "Create New File/Directory",
		"frame": true,
		"items": [{
			"xtype": "textfield",
			"fieldLabel": "<?php 
        echo ext_Lang::msg("nameheader", true);
        ?>
",
			"name": "mkname",
			"width":175,
			"allowBlank":false
			},{
			"xtype": "combo",
			"fieldLabel": "Type",
			"store": [["file", "<?php 
        echo ext_Lang::mime('file', true);
        ?>
"],
						["dir", "<?php 
        echo ext_Lang::mime('dir', true);
        ?>
"]
						<?php 
        if (!ext_isFTPMode() && !$GLOBALS['isWindows']) {
            ?>
						,["symlink", "<?php 
            echo ext_Lang::mime('symlink', true);
            ?>
"]
						<?php 
        }
        ?>
					],
			displayField:"type",
			valueField: "mktype",
			value: "file",
			hiddenName: "mktype",
			disableKeyFilter: true,
			editable: false,
			triggerAction: "all",
			mode: "local",
			allowBlank: false,
			selectOnFocus:true
		},{
			"xtype": "textfield",
			"fieldLabel": "<?php 
        echo ext_Lang::msg('symlink_target', true);
        ?>
",
			"name": "symlink_target",
			"width":175,
			"allowBlank":true
		}],
		"buttons": [{
			"text": "<?php 
        echo ext_Lang::msg('btncreate', true);
        ?>
", 
			"handler": function() {
				statusBarMessage( "Please wait...", true );
				Ext.getCmp("simpleform").getForm().submit({
					//reset: true,
					reset: false,
					success: function(form, action) {
						statusBarMessage( action.result.message, false, true );
						try{ 
							dirTree.getSelectionModel().getSelectedNode().reload(); 
						} catch(e) {}
						datastore.reload();
						Ext.getCmp("dialog").destroy();
					},
					failure: function(form, action) {
						if( !action.result ) return;
						Ext.Msg.alert("Error!", action.result.error);
						statusBarMessage( action.result.error, false, false );
					},
					scope: Ext.getCmp("simpleform"),
					// add some vars to the request, similar to hidden fields
					params: {option: "com_extplorer", 
							action: "mkitem", 
							dir: datastore.directory, 
							confirm: "true",
							token: "<?php 
        echo ext_getToken();
        ?>
"
					}
				})
			}
		},{
			"text": "<?php 
        echo ext_Lang::msg('btncancel', true);
        ?>
", 
			"handler": function() { Ext.getCmp("dialog").destroy(); }
		}]
	}
	<?php 
    }
Ejemplo n.º 24
0
function upload_items($dir)
{
    if (!permissions_grant($dir, NULL, "create")) {
        show_error($GLOBALS["error_msg"]["accessfunc"]);
    }
    // Execute
    if (isset($GLOBALS['__POST']["confirm"]) && $GLOBALS['__POST']["confirm"] == "true") {
        $cnt = count($GLOBALS['__FILES']['userfile']['name']);
        $err = false;
        $err_avaliable = isset($GLOBALS['__FILES']['userfile']['error']);
        // upload files & check for errors
        for ($i = 0; $i < $cnt; $i++) {
            $errors[$i] = NULL;
            $tmp = $GLOBALS['__FILES']['userfile']['tmp_name'][$i];
            $items[$i] = stripslashes($GLOBALS['__FILES']['userfile']['name'][$i]);
            if ($err_avaliable) {
                $up_err = $GLOBALS['__FILES']['userfile']['error'][$i];
            } else {
                $up_err = file_exists($tmp) ? 0 : 4;
            }
            $abs = get_abs_item($dir, $items[$i]);
            if ($items[$i] == "" || $up_err == 4) {
                continue;
            }
            if ($up_err == 1 || $up_err == 2) {
                $errors[$i] = $GLOBALS["error_msg"]["miscfilesize"];
                $err = true;
                continue;
            }
            if ($up_err == 3) {
                $errors[$i] = $GLOBALS["error_msg"]["miscfilepart"];
                $err = true;
                continue;
            }
            if (!is_uploaded_file($tmp)) {
                $errors[$i] = $GLOBALS["error_msg"]["uploadfile"];
                $err = true;
                continue;
            }
            if (file_exists($abs) && empty($_REQUEST['overwrite_files'])) {
                $errors[$i] = $GLOBALS["error_msg"]["itemdoesexist"];
                $err = true;
                continue;
            }
            // Upload
            if (function_exists("move_uploaded_file")) {
                $ok = @move_uploaded_file($tmp, $abs);
            } else {
                $ok = @copy($tmp, $abs);
                @nlink($tmp);
                // try to delete...
            }
            if ($ok === false) {
                $errors[$i] = $GLOBALS["error_msg"]["uploadfile"];
                $err = true;
                continue;
            }
        }
        if ($err) {
            // there were errors
            $err_msg = "";
            for ($i = 0; $i < $cnt; $i++) {
                if ($errors[$i] == NULL) {
                    continue;
                }
                $err_msg .= $items[$i] . " : " . $errors[$i] . "<BR>\n";
            }
            show_error($err_msg);
        }
        miwoftp_redirect(make_link("list", $dir, NULL));
        return;
    }
    show_header($GLOBALS["messages"]["actupload"]);
    // List
    echo "<br />";
    echo "<form enctype=\"multipart/form-data\" action=\"" . make_link("upload", $dir, NULL) . "\" method=\"post\">";
    echo "<input type=\"hidden\" name=\"MAX_FILE_SIZE\" value=\"\" method=\"post\">";
    echo "<input type=\"hidden\" name=\"MAX_FILE_SIZE\" value=\"" . get_max_file_size() . "\">";
    echo "<input type=\"hidden\" name=\"confirm\" value=\"true\">";
    echo "<table>";
    $filecount = 10;
    for ($ii = 0; $ii < $filecount; $ii++) {
        echo "<tr>";
        echo "<td nowrap align=\"center\">";
        echo "<input name=\"userfile[]\" type=\"file\" size=\"40\">";
        echo "</td>";
        echo "</tr>";
    }
    echo "</table>";
    echo "<br />";
    echo "<table>";
    echo "<tr>";
    echo "<td colspan=\"2\">";
    echo "<input type=\"checkbox\" checked=\"checked\" value=\"1\" name=\"overwrite_files\" id=\"overwrite_files\" /><label for=\"overwrite_files\">" . $GLOBALS["messages"]["overwrite_files"] . "</label>";
    echo "<br />";
    echo "<br />";
    echo "</td>";
    echo "</tr>";
    echo "<tr>";
    echo "<td>";
    echo "<input type=\"submit\" value=\"" . $GLOBALS["messages"]["btnupload"] . "\">";
    echo "</td>";
    echo "<td>";
    echo "<input type=\"button\" value=\"" . $GLOBALS["messages"]["btncancel"] . "\" onClick=\"javascript:location='" . make_link("list", $dir, NULL) . "';\">";
    echo "</td>";
    echo "</tr>";
    echo "</table>";
    echo "<input type=\"hidden\" name=\"option\" value=\"com_miwoftp\">";
    echo "</form>";
    echo "<br />";
    return;
}
Ejemplo n.º 25
0
function print_table($dir, $list, $allow)
{
    // print table of files
    global $dir_up;
    if (!is_array($list)) {
        return;
    }
    if ($dir != "" || strstr($dir, _EXT_PATH)) {
        echo "<tr class=\"sectiontableentry1\"><td valign=\"baseline\"><a href=\"" . make_link("list", $dir_up, NULL) . "\">";
        echo "<img border=\"0\" align=\"absmiddle\" src=\"" . _EXT_URL . "/images/up.png\" ";
        echo "alt=\"" . $GLOBALS["messages"]["uplink"] . "\" title=\"" . $GLOBALS["messages"]["uplink"] . "\"/>&nbsp;&nbsp;..</a></td>\n";
        echo "<td>&nbsp;</td><td>&nbsp;</td><td>&nbsp;</td>";
        echo "</tr>";
    }
    $i = 0;
    while (list($item, ) = each($list)) {
        if ($item == 'index.html') {
            continue;
        }
        $abs_item = get_abs_item($dir, $item);
        $is_writable = is_writable($abs_item);
        $is_chmodable = $GLOBALS['ext_File']->is_chmodable($abs_item);
        $is_readable = is_readable($abs_item);
        $is_deletable = $GLOBALS['ext_File']->is_deletable($abs_item);
        $file_info = @stat($abs_item);
        $is_file = false;
        //if(is_link($abs_item)) $extra=" -> ".@readlink($abs_item);
        if (@is_dir($abs_item)) {
            $link = make_link("list", get_rel_item($dir, $item), NULL);
        } else {
            //if(get_is_editable($dir,$item) || get_is_image($dir,$item)) {
            $link = make_link("download", $dir, $item);
            $is_file = true;
        }
        //else $link = "";
        $class = $i % 2 ? 'sectiontableentry1' : 'sectiontableentry2';
        //echo "<tr class=\"rowdata\">"
        echo '<tr class="' . $class . '">';
        // Icon + Link
        echo "<td nowrap=\"nowrap\">";
        if ($is_readable) {
            echo "<a href=\"" . $link . "\"";
            if ($is_file) {
                echo " title=\"" . $GLOBALS["messages"]["downlink"] . ": " . $item . "\"";
            }
            echo ">";
        }
        //else echo "<A>";
        echo "<img border=\"0\" ";
        echo "align=\"absmiddle\" vspace=\"5\" hspace=\"5\" src=\"" . _EXT_URL . "/images/" . get_mime_type($abs_item, "img") . "\" alt=\"\">&nbsp;";
        $s_item = $item;
        if (strlen($s_item) > 50) {
            $s_item = substr($s_item, 0, 47) . "...";
        }
        $s_item = htmlspecialchars($s_item);
        if (!$is_file) {
            echo '<strong>' . $s_item . '</strong>';
        } else {
            echo $s_item;
        }
        if ($is_readable) {
            echo "</a>";
            // ...$extra...
        }
        echo "</td>\n";
        // Size
        echo "<td>" . parse_file_size(get_file_size($abs_item)) . "</td>\n";
        // type
        echo "<td>" . get_mime_type($abs_item, "type") . "</td>\n";
        // modified
        echo "<td>" . parse_file_date(get_file_date($abs_item)) . "</td>\n";
        // actions
        echo "</tr>\n";
        $i++;
    }
}
Ejemplo n.º 26
0
/**
 * File/Directory Copy & Move Functions
 */
function copy_move_items($dir)
{
    // copy/move file/dir
    $action = extGetParam($_REQUEST, 'action');
    if (($GLOBALS["permissions"] & 01) != 01) {
        ext_Result::sendResult($action, false, $GLOBALS["error_msg"]["accessfunc"]);
    }
    // Vars
    $first = extGetParam($GLOBALS['__POST'], 'first');
    if ($first == "y") {
        $new_dir = $dir;
    } else {
        $new_dir = stripslashes($GLOBALS['__POST']["new_dir"]);
    }
    if ($new_dir == ".") {
        $new_dir = "";
    }
    $cnt = count($GLOBALS['__POST']["selitems"]);
    // DO COPY/MOVE
    // ALL OK?
    if (!@$GLOBALS['ext_File']->file_exists(get_abs_dir($new_dir))) {
        ext_Result::sendResult($action, false, get_abs_dir($new_dir) . ": " . $GLOBALS["error_msg"]["targetexist"]);
    }
    if (!get_show_item($new_dir, "")) {
        ext_Result::sendResult($action, false, $new_dir . ": " . $GLOBALS["error_msg"]["accesstarget"]);
    }
    if (!down_home(get_abs_dir($new_dir))) {
        ext_Result::sendResult($action, false, $new_dir . ": " . $GLOBALS["error_msg"]["targetabovehome"]);
    }
    // copy / move files
    $err = false;
    for ($i = 0; $i < $cnt; ++$i) {
        $tmp = basename(stripslashes($GLOBALS['__POST']["selitems"][$i]));
        $new = basename(stripslashes($GLOBALS['__POST']["selitems"][$i]));
        if (ext_isFTPMode()) {
            $abs_item = get_item_info($dir, $tmp);
            $abs_new_item = get_item_info('/' . $new_dir, $new);
        } else {
            $abs_item = get_abs_item($dir, $tmp);
            $abs_new_item = get_abs_item($new_dir, $new);
        }
        $items[$i] = $tmp;
        // Check
        if ($new == "") {
            $error[$i] = $GLOBALS["error_msg"]["miscnoname"];
            $err = true;
            continue;
        }
        if (!@$GLOBALS['ext_File']->file_exists($abs_item)) {
            $error[$i] = $GLOBALS["error_msg"]["itemexist"];
            $err = true;
            continue;
        }
        if (!get_show_item($dir, $tmp)) {
            $error[$i] = $GLOBALS["error_msg"]["accessitem"];
            $err = true;
            continue;
        }
        if (@$GLOBALS['ext_File']->file_exists($abs_new_item)) {
            $error[$i] = $GLOBALS["error_msg"]["targetdoesexist"];
            $err = true;
            continue;
        }
        // Copy / Move
        if ($action == "copy") {
            if (@is_link($abs_item) || get_is_file($abs_item)) {
                // check file-exists to avoid error with 0-size files (PHP 4.3.0)
                if (ext_isFTPMode()) {
                    $abs_item = '/' . $dir . '/' . $abs_item['name'];
                }
                $ok = @$GLOBALS['ext_File']->copy($abs_item, $abs_new_item);
                //||@file_exists($abs_new_item);
            } elseif (@get_is_dir($abs_item)) {
                $copy_dir = ext_isFTPMode() ? '/' . $dir . '/' . $abs_item['name'] . '/' : $abs_item;
                if (ext_isFTPMode()) {
                    $abs_new_item .= '/';
                }
                $ok = $GLOBALS['ext_File']->copy_dir($copy_dir, $abs_new_item);
            }
        } else {
            $ok = $GLOBALS['ext_File']->rename($abs_item, $abs_new_item);
        }
        if ($ok === false || PEAR::isError($ok)) {
            $error[$i] = $action == "copy" ? $GLOBALS["error_msg"]["copyitem"] : $GLOBALS["error_msg"]["moveitem"];
            if (PEAR::isError($ok)) {
                $error[$i] .= ' [' . $ok->getMessage() . ']';
            }
            $err = true;
            continue;
        }
        $error[$i] = NULL;
    }
    if ($err) {
        // there were errors
        $err_msg = "";
        for ($i = 0; $i < $cnt; ++$i) {
            if ($error[$i] == NULL) {
                continue;
            }
            $err_msg .= $items[$i] . " : " . $error[$i] . "\n";
        }
        ext_Result::sendResult($action, false, $err_msg);
    }
    ext_Result::sendResult($action, true, 'The File(s)/Directory(s) were successfully ' . ($action == 'copy' ? 'copied' : 'moved') . '.');
}
Ejemplo n.º 27
0
 function execAction($dir, $item, $unlink = false)
 {
     // Security Fix:
     $item = basename($item);
     while (@ob_end_clean()) {
     }
     ob_start();
     if (ext_isFTPMode()) {
         $abs_item = $dir . '/' . $item;
     } else {
         $abs_item = get_abs_item($dir, $item);
         //if( !strstr( $abs_item, $GLOBALS['home_dir']) )
         //	$abs_item = realpath($GLOBALS['home_dir']).$abs_item;
     }
     if (!$GLOBALS['ext_File']->file_exists($abs_item)) {
         ext_Result::sendResult('download', false, $item . ": " . $GLOBALS["error_msg"]["fileexist"]);
         return false;
     }
     if (!get_show_item($dir, $item)) {
         ext_Result::sendResult('download', false, $item . ": " . $GLOBALS["error_msg"]["accessfile"]);
         return false;
     }
     @set_time_limit(0);
     if (ext_isFTPMode()) {
         $abs_item = ext_ftp_make_local_copy($abs_item);
         $unlink = true;
     }
     $browser = id_browser();
     header('Expires: ' . gmdate('D, d M Y H:i:s') . ' GMT');
     header('Content-Transfer-Encoding: binary');
     header('Content-Length: ' . filesize(realpath($abs_item)));
     //header("Content-Encoding: none");
     if (isset($_GET['action2']) && $_GET['action2'] == 'view') {
         $content_disposition = 'inline';
         include_once _EXT_PATH . '/libraries/Archive/file.php';
         $extension = extFile::getExt($item);
         switch (strtolower($extension)) {
             case 'doc':
             case 'dot':
                 $extension = 'msword';
                 break;
             case 'docx':
             case 'dotx':
                 $extension = 'vnd.openxmlformats-officedocument.wordprocessingml.template';
                 break;
             case 'docm':
                 $extension = 'vnd.ms-word.document.macroEnabled.12';
                 break;
             case 'docm':
                 $extension = 'vnd.ms-word.template.macroEnabled.12';
                 break;
             case 'xls':
             case 'xlt':
             case 'xla':
                 $extension = 'vnd.ms-excel';
                 break;
             case 'xlsx':
                 $extension = 'vnd.openxmlformats-officedocument.spreadsheetml.sheet';
                 break;
             case 'xltx':
                 $extension = 'vnd.openxmlformats-officedocument.spreadsheetml.template';
                 break;
             case 'xlsm':
                 $extension = 'vnd.ms-excel.sheet.macroEnabled.12';
                 break;
             case 'xltm':
                 $extension = 'vnd.ms-excel.template.macroEnabled.12';
                 break;
             case 'xlam':
                 $extension = 'vnd.ms-excel.addin.macroEnabled.12';
                 break;
             case 'xlsb':
                 $extension = 'vnd.ms-excel.sheet.binary.macroEnabled.12';
                 break;
             case 'ppt':
             case 'pot':
             case 'pps':
             case 'ppa':
                 $extension = 'vnd.ms-powerpoint';
                 break;
             case 'pptx':
                 $extension = 'vnd.openxmlformats-officedocument.presentationml.presentation';
                 break;
             case 'potx':
                 $extension = 'vnd.openxmlformats-officedocument.presentationml.template';
                 break;
             case 'ppsx':
                 $extension = 'vnd.openxmlformats-officedocument.presentationml.slideshow';
                 break;
             case 'ppam':
                 $extension = 'vnd.ms-powerpoint.addin.macroEnabled.12';
                 break;
             case 'pptm':
                 $extension = 'vnd.ms-powerpoint.presentation.macroEnabled.12';
                 break;
             case 'potm':
                 $extension = 'vnd.ms-powerpoint.template.macroEnabled.12';
                 break;
             case 'ppsm':
                 $extension = 'vnd.ms-powerpoint.slideshow.macroEnabled.12';
                 break;
             case 'rtf':
                 $extension = 'application/rtf';
                 break;
         }
         header('Content-Type: application/' . $extension . '; Charset=' . $GLOBALS["system_charset"]);
     } else {
         $content_disposition = 'attachment';
         if ($browser == 'IE' || $browser == 'OPERA') {
             header('Content-Type: application/octetstream; Charset=' . $GLOBALS["system_charset"]);
         } else {
             header('Content-Type: application/octet-stream; Charset=' . $GLOBALS["system_charset"]);
         }
     }
     if ($browser == 'IE') {
         // http://support.microsoft.com/kb/436616/ja
         header('Content-Disposition: ' . $content_disposition . '; filename="' . urlencode($item) . '"');
         header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
         header('Pragma: public');
     } else {
         header('Content-Disposition: ' . $content_disposition . '; filename="' . $item . '"');
         header('Cache-Control: no-cache, must-revalidate');
         header('Pragma: no-cache');
     }
     if ($GLOBALS['use_mb']) {
         if (mb_detect_encoding($abs_item) == 'ASCII') {
             @readFileChunked(utf8_decode($abs_item));
         } else {
             @readFileChunked($abs_item);
         }
     } else {
         @readFileChunked(utf8_decode($abs_item));
     }
     if ($unlink == true) {
         unlink(utf8_decode($abs_item));
     }
     ob_end_flush();
     ext_exit();
 }
Ejemplo n.º 28
0
    function execAction($dir, $item)
    {
        if (($GLOBALS["permissions"] & 01) != 01) {
            ext_Result::sendResult('diff', false, ext_Lang::err('accessfunc'));
        }
        $fname = get_abs_item($dir, $item);
        if (!get_is_file(utf8_decode($fname))) {
            ext_Result::sendResult('diff', false, $item . ": " . ext_Lang::err('fileexist'));
        }
        if (!get_show_item($dir, $item)) {
            ext_Result::sendResult('diff', false, $item . ": " . ext_Lang::err('accessfile'));
        }
        $cnt = 0;
        if (!empty($GLOBALS['__POST']["selitems"])) {
            $cnt = count($GLOBALS['__POST']["selitems"]);
        }
        $item2 = extGetParam($_POST, 'item2');
        if ($item2 !== null) {
            $fname2 = get_abs_item('', utf8_decode($item2));
        } elseif ($cnt >= 2) {
            $item2 = $GLOBALS['__POST']["selitems"][1];
            $fname2 = get_abs_item($dir, $item2);
        }
        if ($item2 !== null) {
            if (!get_is_file($fname2)) {
                ext_Result::sendResult('diff', false, $item2 . ": " . ext_Lang::err('fileexist'));
            }
            if (!get_show_item('', $item2)) {
                ext_Result::sendResult('diff', false, $item2 . ": " . ext_Lang::err('accessfile'));
            }
        } elseif (empty($cnt) && extGetParam($_POST, 'confirm') == 'true') {
            ext_Result::sendResult('diff', false, 'Please select a second file to diff to');
        }
        if ($item2 || $cnt >= 2) {
            // Show File In TextArea
            $content = $GLOBALS['ext_File']->file_get_contents($fname);
            $content2 = $GLOBALS['ext_File']->file_get_contents($fname2);
            //$content = nl2br(str_replace("\t", "&nbsp;&nbsp;&nbsp;&nbsp;", htmlentities($content)));
            //$content2 = nl2br(str_replace("\t", "&nbsp;&nbsp;&nbsp;&nbsp;", htmlentities($content2)));
            $diff = $this->inline_diff($content, $content2);
            if (empty($diff)) {
                ext_Result::sendResult('diff', true, 'Both Files are identical');
            }
            $diff = utf8_encode(nl2br($diff));
            echo '{ "xtype": "panel", "dialogtitle": "Diff Result", "html": "' . str_replace(array("\n", "\r"), array('', ''), $diff) . '" }';
            exit;
        }
        ?>
{
	"xtype": "form",
	"id": "simpleform",
	"width": "700",
	"labelWidth": 125,
	"url":"<?php 
        echo basename($GLOBALS['script_name']);
        ?>
",
	"dialogtitle": "Diff <?php 
        echo htmlentities($item);
        if ($item2) {
            echo ' and ' . htmlentities($item2);
        }
        ?>
",
	"title": "Diff",
	"items": [{
		xtype: "textfield",
		fieldLabel: 'File to Compare',
		name: 'item2',
		value: "<?php 
        echo $dir;
        ?>
/",
		width:175,
		allowBlank:false
		}],
    buttons: [{
		"text": "<?php 
        echo ext_Lang::msg('btndiff', true);
        ?>
", 
		"handler": function() {
			statusBarMessage( 'Please wait...', true );
			form = Ext.getCmp("simpleform").getForm();
			form.submit({
				//reset: true,
				reset: false,
				success: function(form, action) {
					Ext.getCmp("dialog").setContent( action.result.message, true );
				},
				failure: function(form, action) {
					if( !action.result ) return;
					Ext.MessageBox.alert('Error!', action.result.error);
					statusBarMessage( action.result.error, false, true );
				},
				scope: form,
				// add some vars to the request, similar to hidden fields
				params: {
					"option": "com_extplorer", 
					"action": "diff", 
					"dir": "<?php 
        echo stripslashes($GLOBALS['__POST']["dir"]);
        ?>
", 
					"item": "<?php 
        echo $item;
        ?>
",
					"selitems[]": ['<?php 
        echo implode("','", $GLOBALS['__POST']["selitems"]);
        ?>
'], 
					confirm: 'true'
				}
			});
		}
	},{
		"text": "<?php 
        echo ext_Lang::msg('btncancel', true);
        ?>
", 
		"handler": function() { Ext.getCmp("dialog").destroy(); }
	}]
}
	<?php 
    }
Ejemplo n.º 29
0
function get_mime_type($dir, $item, $query)
{
    // get file's mimetype
    if (get_is_dir($dir, $item)) {
        // directory
        $mime_type = $GLOBALS["super_mimes"]["dir"][0];
        $image = $GLOBALS["super_mimes"]["dir"][1];
        if ($query == "img") {
            return $image;
        } else {
            return $mime_type;
        }
    }
    // mime_type
    foreach ($GLOBALS["used_mime_types"] as $mime) {
        list($desc, $img, $ext, $type) = $mime;
        if (preg_match('/' . $ext . '/i', $item)) {
            $mime_type = $desc;
            $image = $img;
            if ($query == "img") {
                return $image;
            } else {
                if ($query == "ext") {
                    return $type;
                } else {
                    return $mime_type;
                }
            }
        }
    }
    if (function_exists("is_executable") && @is_executable(get_abs_item($dir, $item)) || preg_match('/' . $GLOBALS["super_mimes"]["exe"][2] . '/i', $item)) {
        // executable
        $mime_type = $GLOBALS["super_mimes"]["exe"][0];
        $image = $GLOBALS["super_mimes"]["exe"][1];
    } else {
        // unknown file
        $mime_type = $GLOBALS["super_mimes"]["file"][0];
        $image = $GLOBALS["super_mimes"]["file"][1];
    }
    if ($query == "img") {
        return $image;
    } else {
        return $mime_type;
    }
}
Ejemplo n.º 30
0
    function execAction($dir, $item)
    {
        // change permissions
        if (($GLOBALS["permissions"] & 01) != 01) {
            ext_Result::sendResult('chmod', false, $GLOBALS["error_msg"]["accessfunc"]);
        }
        if (!empty($GLOBALS['__POST']["selitems"])) {
            $cnt = count($GLOBALS['__POST']["selitems"]);
        } else {
            $GLOBALS['__POST']["selitems"][] = $item;
            $cnt = 1;
        }
        if (!empty($GLOBALS['__POST']['do_recurse'])) {
            $do_recurse = true;
        } else {
            $do_recurse = false;
        }
        // Execute
        if (isset($GLOBALS['__POST']["confirm"]) && $GLOBALS['__POST']["confirm"] == "true") {
            $bin = '';
            for ($i = 0; $i < 3; $i++) {
                for ($j = 0; $j < 3; $j++) {
                    $tmp = "r_" . $i . $j;
                    if (!empty($GLOBALS['__POST'][$tmp])) {
                        $bin .= '1';
                    } else {
                        $bin .= '0';
                    }
                }
            }
            if ($bin == '0') {
                // Changing permissions to "none" is not allowed
                ext_Result::sendResult('chmod', false, $item . ": " . ext_Lang::err('chmod_none_not_allowed'));
            }
            $old_bin = $bin;
            for ($i = 0; $i < $cnt; ++$i) {
                if (ext_isFTPMode()) {
                    $mode = decoct(bindec($bin));
                } else {
                    $mode = bindec($bin);
                }
                $item = $GLOBALS['__POST']["selitems"][$i];
                if (ext_isFTPMode()) {
                    $abs_item = get_item_info($dir, $item);
                } else {
                    $abs_item = get_abs_item($dir, $item);
                }
                if (!$GLOBALS['ext_File']->file_exists($abs_item)) {
                    ext_Result::sendResult('chmod', false, $item . ": " . $GLOBALS["error_msg"]["fileexist"]);
                }
                if (!get_show_item($dir, $item)) {
                    ext_Result::sendResult('chmod', false, $item . ": " . $GLOBALS["error_msg"]["accessfile"]);
                }
                if ($do_recurse) {
                    $ok = $GLOBALS['ext_File']->chmodRecursive($abs_item, $mode);
                } else {
                    if (get_is_dir($abs_item)) {
                        // when we chmod a directory we must care for the permissions
                        // to prevent that the directory becomes not readable (when the "execute bits" are removed)
                        $bin = substr_replace($bin, '1', 2, 1);
                        // set 1st x bit to 1
                        $bin = substr_replace($bin, '1', 5, 1);
                        // set  2nd x bit to 1
                        $bin = substr_replace($bin, '1', 8, 1);
                        // set 3rd x bit to 1
                        if (ext_isFTPMode()) {
                            $mode = decoct(bindec($bin));
                        } else {
                            $mode = bindec($bin);
                        }
                    }
                    //ext_Result::sendResult('chmod', false, $GLOBALS['FTPCONNECTION']->pwd());
                    $ok = @$GLOBALS['ext_File']->chmod($abs_item, $mode);
                }
                $bin = $old_bin;
            }
            if ($ok === false || PEAR::isError($ok)) {
                $msg = $item . ": " . $GLOBALS["error_msg"]["permchange"];
                $msg .= PEAR::isError($ok) ? ' [' . $ok->getMessage() . ']' : '';
                ext_Result::sendResult('chmod', false, $msg);
            }
            ext_Result::sendResult('chmod', true, ext_Lang::msg('permchange'));
            return;
        }
        if (ext_isFTPMode()) {
            $abs_item = get_item_info($dir, $GLOBALS['__POST']["selitems"][0]);
        } else {
            $abs_item = get_abs_item($dir, $GLOBALS['__POST']["selitems"][0]);
            $abs_item = utf8_decode($abs_item);
        }
        $mode = parse_file_perms(get_file_perms($abs_item));
        if ($mode === false) {
            ext_Result::sendResult('chmod', false, $item . ": " . $GLOBALS["error_msg"]["permread"]);
        }
        $pos = "rwx";
        $text = "";
        for ($i = 0; $i < $cnt; ++$i) {
            $s_item = get_rel_item($dir, $GLOBALS['__POST']["selitems"][$i]);
            if (strlen($s_item) > 50) {
                $s_item = "..." . substr($s_item, -47);
            }
            $text .= $s_item . ($i + 1 < $cnt ? ', ' : '');
        }
        ?>
		{
		"xtype": "form",
		"id": "simpleform",
		"width": "300",
		"labelWidth": 125,
		"url":"<?php 
        echo basename($GLOBALS['script_name']);
        ?>
",
		"dialogtitle": "<?php 
        echo ext_Lang::msg('actperms');
        ?>
",
		"title" : "<?php 
        echo $text;
        ?>
",
		"frame": true,
		"items": [{
			"layout": "column",
			"items": [{
	<?php 
        // print table with current perms & checkboxes to change
        for ($i = 0; $i < 3; ++$i) {
            ?>
			"width":80, 
			"title":"<?php 
            echo ext_Lang::msg(array('miscchmod' => $i), true);
            ?>
",					
			"items": [{
				<?php 
            for ($j = 0; $j < 3; ++$j) {
                ?>
					"xtype": "checkbox",
					"boxLabel":"<?php 
                echo $pos[$j];
                ?>
",
					<?php 
                if ($mode[3 * $i + $j] != "-") {
                    echo '"checked":true,';
                }
                ?>
						"name":"<?php 
                echo "r_" . $i . $j;
                ?>
"
					}	<?php 
                if ($j < 2) {
                    echo ',{';
                }
            }
            ?>
	
				]
			}
		<?php 
            if ($i < 2) {
                echo ',{';
            }
        }
        ?>
,{
			"width":400, 
			"style":"margin-left:10px", 
			"clear":true,
			"html": "&nbsp;"
		}]

	},{
		"xtype": "checkbox",
		"fieldLabel":"<?php 
        echo ext_Lang::msg('recurse_subdirs', true);
        ?>
",
		"name":"do_recurse"
	}],
	"buttons": [{
		"text": "<?php 
        echo ext_Lang::msg('btnsave', true);
        ?>
", 
		"handler": function() {
			statusBarMessage( '<?php 
        echo ext_Lang::msg('permissions_processing', true);
        ?>
', true );
			form = Ext.getCmp("simpleform").getForm();
			form.submit({
				//reset: true,
				reset: false,
				success: function(form, action) {
					statusBarMessage( action.result.message, false, true );
					datastore.reload();
					Ext.getCmp("dialog").destroy();
				},
				failure: function(form, action) {
					statusBarMessage( action.result.error, false, false );
					Ext.Msg.alert('<?php 
        echo ext_Lang::err('error', true);
        ?>
', action.result.error);
				},
				scope: form,
				params: {
					"option": "com_extplorer", 
					"action": "chmod", 
					"dir": "<?php 
        echo stripslashes($GLOBALS['__POST']["dir"]);
        ?>
", 
					"selitems[]": ['<?php 
        echo implode("','", $GLOBALS['__POST']["selitems"]);
        ?>
'], 
					confirm: 'true'
				}
			});
		}
	},{
		"text": "<?php 
        echo ext_Lang::msg('btncancel', true);
        ?>
", 
		"handler": function() { Ext.getCmp("dialog").destroy(); }
	}]
}
	
		<?php 
    }