Пример #1
0
 function copy_dir($abs_item, $abs_new_item)
 {
     if (jx_isFTPMode()) {
         $tmp_dir = jx_ftp_make_local_copy($abs_item);
         $res = $GLOBALS['FTPCONNECTION']->putRecursive($tmp_dir, $abs_new_item);
         remove($tmp_dir);
         return $res;
     } else {
         return copy_dir($abs_item, $abs_new_item);
     }
 }
Пример #2
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();
}
Пример #3
0
/**
 * Allows to view sourcecode (formatted by GeSHi or unformatted) and images
 *
 */
function jx_show_file($dir, $item)
{
    // show file contents
    show_header($GLOBALS["messages"]["actview"] . ": " . $item);
    $index2_edit_link = str_replace('/index3.php', '/index2.php', make_link('edit', $dir, $item));
    echo '<a name="top" class="componentheading" href="javascript:window.close();">[ ' . _PROMPT_CLOSE . ' ]</a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;';
    $abs_item = get_abs_item($dir, $item);
    if (get_is_editable($abs_item) && $GLOBALS['jx_File']->is_writable($abs_item)) {
        // Edit the file in the PopUp
        echo '<a class="componentheading" href="' . make_link('edit', $dir, $item) . '&amp;return_to=' . urlencode($_SERVER['PHP_SELF'] . '?' . $_SERVER['QUERY_STRING']) . '">[ ' . $GLOBALS["messages"]["editlink"] . ' ]</a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;';
        // Edit the file in the parent window
        //echo '<a class="componentheading" href="javascript:opener.location=\''.$index2_edit_link.'\'; window.close();">[ '.$GLOBALS["messages"]["editlink"].' ]</a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;';
    }
    echo '<a class="componentheading" href="#bottom">[ ' . _CMN_BOTTOM . ' ]</a>';
    echo '<br /><br />';
    if (@eregi($GLOBALS["images_ext"], $item)) {
        echo '<img src="' . $GLOBALS['home_url'] . '/' . $dir . '/' . $item . '" alt="' . $GLOBALS["messages"]["actview"] . ": " . $item . '" /><br /><br />';
    } else {
        if (file_exists($GLOBALS['mosConfig_absolute_path'] . '/includes/domit/xml_saxy_shared.php')) {
            require_once $GLOBALS['mosConfig_absolute_path'] . '/includes/domit/xml_saxy_shared.php';
        } elseif (file_exists($GLOBALS['mosConfig_absolute_path'] . '/libraries/domit/xml_saxy_shared.php')) {
            require_once $GLOBALS['mosConfig_absolute_path'] . '/libraries/domit/xml_saxy_shared.php';
        } else {
            return;
        }
        if (file_exists($GLOBALS['mosConfig_absolute_path'] . '/mambots/content/geshi/geshi.php')) {
            $geshiFile = $GLOBALS['mosConfig_absolute_path'] . '/mambots/content/geshi/geshi.php';
        } elseif (file_exists($GLOBALS['mosConfig_absolute_path'] . '/libraries/geshi/geshi.php')) {
            $geshiFile = $GLOBALS['mosConfig_absolute_path'] . '/libraries/geshi/geshi.php';
        }
        if (file_exists($geshiFile)) {
            @ini_set('memory_limit', '32M');
            // GeSHi 1.0.7 is very memory-intensive
            include_once $geshiFile;
            // Create the GeSHi object that renders our source beautiful
            $geshi = new GeSHi('', '', dirname($geshiFile) . '/geshi');
            $file = get_abs_item($dir, $item);
            $pathinfo = pathinfo($file);
            if (jx_isFTPMode()) {
                $file = jx_ftp_make_local_copy($file);
            }
            if (is_callable(array($geshi, 'load_from_file'))) {
                $geshi->load_from_file($file);
            } else {
                $geshi->set_source(file_get_contents($file));
            }
            if (is_callable(array($geshi, 'getlanguagesuage_name_from_extension'))) {
                $lang = $geshi->getlanguage_name_from_extension($pathinfo['extension']);
            } else {
                $pathinfo = pathinfo($item);
                $lang = $pathinfo['extension'];
            }
            $geshi->set_language($lang);
            $geshi->enable_line_numbers(GESHI_NORMAL_LINE_NUMBERS);
            $text = $geshi->parse_code();
            if (jx_isFTPMode()) {
                unlink($file);
            }
            echo '<div style="text-align:left;">' . $text . '</div>';
            echo '<div style="line-height:25px;vertical-align:middle;text-align:center;" class="small">Rendering Time: <strong>' . $geshi->get_time() . ' Sec.</strong></div>';
        } else {
            // When GeSHi is not available, just display the plain file contents
            echo '<div class="quote" style="text-align:left;">' . nl2br(htmlentities($GLOBALS['jx_File']->file_get_contents(get_abs_item($dir, $item)))) . '</div>';
        }
    }
    echo '<a href="#top" name="bottom" class="componentheading">[ ' . _CMN_TOP . ' ]</a><br /><br />';
}