Example #1
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"];
    $mkname = base_name(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));
}
Example #2
0
function archive_items($dir)
{
    if (($GLOBALS["permissions"] & 01) != 01) {
        show_error($GLOBALS["error_msg"]["accessfunc"]);
    }
    if (!$GLOBALS["zip"] && !$GLOBALS["tar"] && !$GLOBALS["tgz"]) {
        show_error($GLOBALS["error_msg"]["miscnofunc"]);
    }
    if (isset($GLOBALS['__POST']["name"])) {
        $name = base_name(stripslashes($GLOBALS['__POST']["name"]));
        if ($name == "") {
            show_error($GLOBALS["error_msg"]["miscnoname"]);
        }
        switch ($GLOBALS['__POST']["type"]) {
            case "zip":
                zip_items($dir, $name);
                break;
            case "tar":
                tar_items($dir, $name);
                break;
            default:
                tgz_items($dir, $name);
        }
        header("Location: " . make_link("list", $dir, NULL));
    }
    show_header($GLOBALS["messages"]["actarchive"]);
    echo "<BR><FORM name=\"archform\" method=\"post\" action=\"" . make_link("arch", $dir, NULL) . "\">\n";
    $cnt = count($GLOBALS['__POST']["selitems"]);
    for ($i = 0; $i < $cnt; ++$i) {
        echo "<INPUT type=\"hidden\" name=\"selitems[]\" value=\"" . stripslashes($GLOBALS['__POST']["selitems"][$i]) . "\">\n";
    }
    echo "<TABLE width=\"300\"><TR><TD>" . $GLOBALS["messages"]["nameheader"] . ":</TD><TD align=\"right\">";
    echo "<INPUT type=\"text\" name=\"name\" size=\"25\"></TD></TR>\n";
    echo "<TR><TD>" . $GLOBALS["messages"]["typeheader"] . ":</TD><TD align=\"right\"><SELECT name=\"type\">\n";
    if ($GLOBALS["zip"]) {
        echo "<OPTION value=\"zip\">Zip</OPTION>\n";
    }
    if ($GLOBALS["tar"]) {
        echo "<OPTION value=\"tar\">Tar</OPTION>\n";
    }
    if ($GLOBALS["tgz"]) {
        echo "<OPTION value=\"tgz\">TGz</OPTION>\n";
    }
    echo "</SELECT></TD></TR>";
    echo "<TR><TD></TD><TD align=\"right\"><INPUT type=\"submit\" value=\"" . $GLOBALS["messages"]["btncreate"] . "\">\n";
    echo "<input type=\"button\" value=\"" . $GLOBALS["messages"]["btncancel"];
    echo "\" onClick=\"javascript:location='" . make_link("list", $dir, NULL) . "';\">\n</TD></TR></FORM></TABLE><BR>\n";
    ?>
<script language="JavaScript1.2" type="text/javascript">
<!--
	if(document.archform) document.archform.name.focus();
// -->
</script><?php 
}
Example #3
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;
}
Example #4
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 
}
Example #5
0
 public function client_list_image_clean($mp_menu)
 {
     if (!is_dir(ROOT_PATH . 'weixin/list_image/')) {
         return false;
     }
     foreach ($mp_menu as $key => $val) {
         if ($val['sub_button']) {
             foreach ($val['sub_button'] as $sub_key => $sub_val) {
                 $attach_list[] = $sub_val['attch_key'] . '.jpg';
             }
         }
         $attach_list[] = $val['attch_key'] . '.jpg';
     }
     $files_list = fetch_file_lists(ROOT_PATH . 'weixin/list_image/', 'jpg');
     foreach ($files_list as $search_file) {
         if (!in_array(str_replace('square_', '', base_name($search_file)))) {
             unlink($search_file);
         }
     }
 }
Example #6
0
function list_dir($dir)
{
    // list directory contents
    $allow = ($GLOBALS["permissions"] & 01) == 01;
    $admin = ($GLOBALS["permissions"] & 04) == 04 || ($GLOBALS["permissions"] & 02) == 02;
    $dir_up = dirname($dir);
    if ($dir_up == ".") {
        $dir_up = "";
    }
    if (!get_show_item($dir_up, base_name($dir))) {
        show_error($dir . " : " . $GLOBALS["error_msg"]["accessdir"]);
    }
    // make file & dir tables, & get total filesize & number of items
    make_tables($dir, $dir_list, $file_list, $tot_file_size, $num_items);
    $s_dir = $dir;
    if (strlen($s_dir) > 50) {
        $s_dir = "..." . substr($s_dir, -47);
    }
    show_header($GLOBALS["messages"]["actdir"] . ": /" . get_rel_item("", $s_dir));
    // Javascript functions:
    include "./.include/javascript.php";
    // Sorting of items
    $_img = "&nbsp;<IMG width=\"10\" height=\"10\" border=\"0\" align=\"ABSMIDDLE\" src=\"_img/";
    if ($GLOBALS["srt"] == "yes") {
        $_srt = "no";
        $_img .= "_arrowup.gif\" ALT=\"^\">";
    } else {
        $_srt = "yes";
        $_img .= "_arrowdown.gif\" ALT=\"v\">";
    }
    // Toolbar
    echo "<BR><TABLE width=\"95%\"><TR><TD><TABLE><TR>\n";
    // PARENT DIR
    echo "<TD><A HREF=\"" . make_link("list", $dir_up, NULL) . "\">";
    echo "<IMG border=\"0\" width=\"16\" height=\"16\" align=\"ABSMIDDLE\" src=\"_img/_up.gif\" ";
    echo "ALT=\"" . $GLOBALS["messages"]["uplink"] . "\" TITLE=\"" . $GLOBALS["messages"]["uplink"] . "\"></A></TD>\n";
    // HOME DIR
    echo "<TD><A HREF=\"" . make_link("list", NULL, NULL) . "\">";
    echo "<IMG border=\"0\" width=\"16\" height=\"16\" align=\"ABSMIDDLE\" src=\"_img/_home.gif\" ";
    echo "ALT=\"" . $GLOBALS["messages"]["homelink"] . "\" TITLE=\"" . $GLOBALS["messages"]["homelink"] . "\"></A></TD>\n";
    // RELOAD
    echo "<TD><A HREF=\"javascript:location.reload();\"><IMG border=\"0\" width=\"16\" height=\"16\" ";
    echo "align=\"ABSMIDDLE\" src=\"_img/_refresh.gif\" ALT=\"" . $GLOBALS["messages"]["reloadlink"];
    echo "\" TITLE=\"" . $GLOBALS["messages"]["reloadlink"] . "\"></A></TD>\n";
    // SEARCH
    echo "<TD><A HREF=\"" . make_link("search", $dir, NULL) . "\">";
    echo "<IMG border=\"0\" width=\"16\" height=\"16\" align=\"ABSMIDDLE\" src=\"_img/_search.gif\" ";
    echo "ALT=\"" . $GLOBALS["messages"]["searchlink"] . "\" TITLE=\"" . $GLOBALS["messages"]["searchlink"];
    echo "\"></A></TD>\n";
    echo "<TD>::</TD>";
    if ($allow) {
        // COPY
        echo "<TD><A HREF=\"javascript:Copy();\"><IMG border=\"0\" width=\"16\" height=\"16\" ";
        echo "align=\"ABSMIDDLE\" src=\"_img/_copy.gif\" ALT=\"" . $GLOBALS["messages"]["copylink"];
        echo "\" TITLE=\"" . $GLOBALS["messages"]["copylink"] . "\"></A></TD>\n";
        // MOVE
        echo "<TD><A HREF=\"javascript:Move();\"><IMG border=\"0\" width=\"16\" height=\"16\" ";
        echo "align=\"ABSMIDDLE\" src=\"_img/_move.gif\" ALT=\"" . $GLOBALS["messages"]["movelink"];
        echo "\" TITLE=\"" . $GLOBALS["messages"]["movelink"] . "\"></A></TD>\n";
        // DELETE
        echo "<TD><A HREF=\"javascript:Delete();\"><IMG border=\"0\" width=\"16\" height=\"16\" ";
        echo "align=\"ABSMIDDLE\" src=\"_img/_delete.gif\" ALT=\"" . $GLOBALS["messages"]["dellink"];
        echo "\" TITLE=\"" . $GLOBALS["messages"]["dellink"] . "\"></A></TD>\n";
        // UPLOAD
        if ($GLOBALS["display_file_upload_icon"]) {
            if (get_cfg_var("file_uploads")) {
                echo "<TD><A HREF=\"" . make_link("upload", $dir, NULL) . "\">";
                echo "<IMG border=\"0\" width=\"16\" height=\"16\" align=\"ABSMIDDLE\" ";
                echo "src=\"_img/_upload.gif\" ALT=\"" . $GLOBALS["messages"]["uploadlink"];
                echo "\" TITLE=\"" . $GLOBALS["messages"]["uploadlink"] . "\"></A></TD>\n";
            } else {
                echo "<TD><IMG border=\"0\" width=\"16\" height=\"16\" align=\"ABSMIDDLE\" ";
                echo "src=\"_img/_upload_.gif\" ALT=\"" . $GLOBALS["messages"]["uploadlink"];
                echo "\" TITLE=\"" . $GLOBALS["messages"]["uploadlink"] . "\"></TD>\n";
            }
        }
        // ARCHIVE
        if ($GLOBALS["zip"] || $GLOBALS["tar"] || $GLOBALS["tgz"]) {
            echo "<TD><A HREF=\"javascript:Archive();\"><IMG border=\"0\" width=\"16\" height=\"16\" ";
            echo "align=\"ABSMIDDLE\" src=\"_img/_archive.gif\" ALT=\"" . $GLOBALS["messages"]["comprlink"];
            echo "\" TITLE=\"" . $GLOBALS["messages"]["comprlink"] . "\"></A></TD>\n";
        }
    } else {
        // COPY
        echo "<TD><IMG border=\"0\" width=\"16\" height=\"16\" align=\"ABSMIDDLE\" ";
        echo "src=\"_img/_copy_.gif\" ALT=\"" . $GLOBALS["messages"]["copylink"] . "\" TITLE=\"";
        echo $GLOBALS["messages"]["copylink"] . "\"></TD>\n";
        // MOVE
        echo "<TD><IMG border=\"0\" width=\"16\" height=\"16\" align=\"ABSMIDDLE\" ";
        echo "src=\"_img/_move_.gif\" ALT=\"" . $GLOBALS["messages"]["movelink"] . "\" TITLE=\"";
        echo $GLOBALS["messages"]["movelink"] . "\"></TD>\n";
        // DELETE
        echo "<TD><IMG border=\"0\" width=\"16\" height=\"16\" align=\"ABSMIDDLE\" ";
        echo "src=\"_img/_delete_.gif\" ALT=\"" . $GLOBALS["messages"]["dellink"] . "\" TITLE=\"";
        echo $GLOBALS["messages"]["dellink"] . "\"></TD>\n";
        // UPLOAD
        echo "<TD><IMG border=\"0\" width=\"16\" height=\"16\" align=\"ABSMIDDLE\" ";
        echo "src=\"_img/_upload_.gif\" ALT=\"" . $GLOBALS["messages"]["uplink"];
        echo "\" TITLE=\"" . $GLOBALS["messages"]["uplink"] . "\"></TD>\n";
    }
    // ADMIN & LOGOUT
    if ($GLOBALS["require_login"]) {
        echo "<TD>::</TD>";
        // ADMIN
        if ($admin) {
            echo "<TD><A HREF=\"" . make_link("admin", $dir, NULL) . "\">";
            echo "<IMG border=\"0\" width=\"16\" height=\"16\" align=\"ABSMIDDLE\" ";
            echo "src=\"_img/_admin.gif\" ALT=\"" . $GLOBALS["messages"]["adminlink"] . "\" TITLE=\"";
            echo $GLOBALS["messages"]["adminlink"] . "\"></A></TD>\n";
        }
        // LOGOUT
        echo "<TD><A HREF=\"" . make_link("logout", NULL, NULL) . "\">";
        echo "<IMG border=\"0\" width=\"16\" height=\"16\" align=\"ABSMIDDLE\" ";
        echo "src=\"_img/_logout.gif\" ALT=\"" . $GLOBALS["messages"]["logoutlink"] . "\" TITLE=\"";
        echo $GLOBALS["messages"]["logoutlink"] . "\"></A></TD>\n";
    }
    echo "</TR></TABLE></TD>\n";
    // Create File / Dir
    if ($allow) {
        echo "<TD align=\"right\"><TABLE><FORM action=\"" . make_link("mkitem", $dir, NULL) . "\" method=\"post\">\n<TR><TD>";
        echo "<SELECT name=\"mktype\"><option value=\"file\">" . $GLOBALS["mimes"]["file"] . "</option>";
        echo "<option value=\"dir\">" . $GLOBALS["mimes"]["dir"] . "</option></SELECT>\n";
        echo "<INPUT name=\"mkname\" type=\"text\" size=\"15\">";
        echo "<INPUT type=\"submit\" value=\"" . $GLOBALS["messages"]["btncreate"];
        echo "\"></TD></TR></FORM></TABLE></TD>\n";
    }
    echo "</TR></TABLE>\n";
    // End Toolbar
    // Begin Table + Form for checkboxes
    echo "<TABLE WIDTH=\"95%\"><FORM name=\"selform\" method=\"POST\" action=\"" . make_link("post", $dir, NULL) . "\">\n";
    echo "<INPUT type=\"hidden\" name=\"do_action\"><INPUT type=\"hidden\" name=\"first\" value=\"y\">\n";
    // Table Header
    echo "<TR><TD colspan=\"7\"><HR></TD></TR><TR><TD WIDTH=\"2%\" class=\"header\">\n";
    echo "<INPUT TYPE=\"checkbox\" name=\"toggleAllC\" onclick=\"javascript:ToggleAll(this);\"></TD>\n";
    echo "<TD WIDTH=\"44%\" class=\"header\"><B>\n";
    if ($GLOBALS["order"] == "name") {
        $new_srt = $_srt;
    } else {
        $new_srt = "yes";
    }
    echo "<A href=\"" . make_link("list", $dir, NULL, "name", $new_srt) . "\">" . $GLOBALS["messages"]["nameheader"];
    if ($GLOBALS["order"] == "name") {
        echo $_img;
    }
    echo "</A></B></TD>\n<TD WIDTH=\"10%\" class=\"header\"><B>";
    if ($GLOBALS["order"] == "size") {
        $new_srt = $_srt;
    } else {
        $new_srt = "yes";
    }
    echo "<A href=\"" . make_link("list", $dir, NULL, "size", $new_srt) . "\">" . $GLOBALS["messages"]["sizeheader"];
    if ($GLOBALS["order"] == "size") {
        echo $_img;
    }
    echo "</A></B></TD>\n<TD WIDTH=\"16%\" class=\"header\"><B>";
    if ($GLOBALS["order"] == "type") {
        $new_srt = $_srt;
    } else {
        $new_srt = "yes";
    }
    echo "<A href=\"" . make_link("list", $dir, NULL, "type", $new_srt) . "\">" . $GLOBALS["messages"]["typeheader"];
    if ($GLOBALS["order"] == "type") {
        echo $_img;
    }
    echo "</A></B></TD>\n<TD WIDTH=\"14%\" class=\"header\"><B>";
    if ($GLOBALS["order"] == "mod") {
        $new_srt = $_srt;
    } else {
        $new_srt = "yes";
    }
    echo "<A href=\"" . make_link("list", $dir, NULL, "mod", $new_srt) . "\">" . $GLOBALS["messages"]["modifheader"];
    if ($GLOBALS["order"] == "mod") {
        echo $_img;
    }
    echo "</A></B></TD><TD WIDTH=\"8%\" class=\"header\"><B>" . $GLOBALS["messages"]["permheader"] . "</B>\n";
    echo "</TD><TD WIDTH=\"6%\" class=\"header\"><B>" . $GLOBALS["messages"]["actionheader"] . "</B></TD></TR>\n";
    echo "<TR><TD colspan=\"7\"><HR></TD></TR>\n";
    // make & print Table using lists
    print_table($dir, make_list($dir_list, $file_list), $allow);
    // print number of items & total filesize
    echo "<TR><TD colspan=\"7\"><HR></TD></TR><TR>\n<TD class=\"header\"></TD>";
    echo "<TD class=\"header\">" . $num_items . " " . $GLOBALS["messages"]["miscitems"] . " (";
    if (function_exists("disk_free_space")) {
        $free = parse_file_size(disk_free_space(get_abs_dir($dir)));
    } elseif (function_exists("diskfreespace")) {
        $free = parse_file_size(diskfreespace(get_abs_dir($dir)));
    } else {
        $free = "?";
    }
    // echo "Total: ".parse_file_size(disk_total_space(get_abs_dir($dir))).", ";
    echo $GLOBALS["messages"]["miscfree"] . ": " . $free . ")</TD>\n";
    echo "<TD class=\"header\">" . parse_file_size($tot_file_size) . "</TD>\n";
    for ($i = 0; $i < 4; ++$i) {
        echo "<TD class=\"header\"></TD>";
    }
    echo "</TR>\n<TR><TD colspan=\"7\"><HR></TD></TR></FORM></TABLE>\n";
    ?>
<script language="JavaScript1.2" type="text/javascript">
<!--
	// Uncheck all items (to avoid problems with new items)
	var ml = document.selform;
	var len = ml.elements.length;
	for(var i=0; i<len; ++i) {
		var e = ml.elements[i];
		if(e.name == "selitems[]" && e.checked == true) {
			e.checked=false;
		}
	}
// -->
</script><?php 
}
function copy_move_items($dir)
{
    // copy/move file/dir
    if (($GLOBALS["permissions"] & 01) != 01) {
        show_error($GLOBALS["error_msg"]["accessfunc"]);
    }
    // Vars
    $first = $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"]);
    // Copy or Move?
    if ($GLOBALS["action"] != "move") {
        $_img = "_img/__copy.gif";
    } else {
        $_img = "_img/__cut.gif";
    }
    // Get New Location & Names
    if (!isset($GLOBALS['__POST']["confirm"]) || $GLOBALS['__POST']["confirm"] != "true") {
        show_header($GLOBALS["action"] != "move" ? $GLOBALS["messages"]["actcopyitems"] : $GLOBALS["messages"]["actmoveitems"]);
        // JavaScript for Form:
        // Select new target directory / execute action
        ?>
<script language="JavaScript1.2" type="text/javascript">
<!--
	function NewDir(newdir) {
		document.selform.new_dir.value = newdir;
		document.selform.submit();
	}
	
	function Execute() {
		document.selform.confirm.value = "true";
	}
//-->
</script><?php 
        // "Copy / Move from .. to .."
        $s_dir = $dir;
        if (strlen($s_dir) > 40) {
            $s_dir = "..." . substr($s_dir, -37);
        }
        $s_ndir = $new_dir;
        if (strlen($s_ndir) > 40) {
            $s_ndir = "..." . substr($s_ndir, -37);
        }
        echo "<BR><IMG SRC=\"" . $_img . "\" align=\"ABSMIDDLE\" ALT=\"\">&nbsp;";
        echo sprintf($GLOBALS["action"] != "move" ? $GLOBALS["messages"]["actcopyfrom"] : $GLOBALS["messages"]["actmovefrom"], $s_dir, $s_ndir);
        echo "<IMG SRC=\"_img/__paste.gif\" align=\"ABSMIDDLE\" ALT=\"\">\n";
        // Form for Target Directory & New Names
        echo "<BR><BR><FORM name=\"selform\" method=\"post\" action=\"";
        echo make_link("post", $dir, NULL) . "\"><TABLE>\n";
        echo "<INPUT type=\"hidden\" name=\"do_action\" value=\"" . $GLOBALS["action"] . "\">\n";
        echo "<INPUT type=\"hidden\" name=\"confirm\" value=\"false\">\n";
        echo "<INPUT type=\"hidden\" name=\"first\" value=\"n\">\n";
        echo "<INPUT type=\"hidden\" name=\"new_dir\" value=\"" . $new_dir . "\">\n";
        // List Directories to select Target
        dir_print(dir_list($new_dir), $new_dir);
        echo "</TABLE><BR><TABLE>\n";
        // Print Text Inputs to change Names
        for ($i = 0; $i < $cnt; ++$i) {
            $selitem = stripslashes($GLOBALS['__POST']["selitems"][$i]);
            if (isset($GLOBALS['__POST']["newitems"][$i])) {
                $newitem = stripslashes($GLOBALS['__POST']["newitems"][$i]);
                if ($first == "y") {
                    $newitem = $selitem;
                }
            } else {
                $newitem = $selitem;
            }
            $s_item = $selitem;
            if (strlen($s_item) > 50) {
                $s_item = substr($s_item, 0, 47) . "...";
            }
            echo "<TR><TD><IMG SRC=\"_img/_info.gif\" align=\"ABSMIDDLE\" ALT=\"\">";
            // Old Name
            echo "<INPUT type=\"hidden\" name=\"selitems[]\" value=\"";
            echo $selitem . "\">&nbsp;" . $s_item . "&nbsp;";
            // New Name
            echo "</TD><TD><INPUT type=\"text\" size=\"25\" name=\"newitems[]\" value=\"";
            echo $newitem . "\"></TD></TR>\n";
        }
        // Submit & Cancel
        echo "</TABLE><BR><TABLE><TR>\n<TD>";
        echo "<INPUT type=\"submit\" value=\"";
        echo $GLOBALS["action"] != "move" ? $GLOBALS["messages"]["btncopy"] : $GLOBALS["messages"]["btnmove"];
        echo "\" onclick=\"javascript:Execute();\"></TD>\n<TD>";
        echo "<input type=\"button\" value=\"" . $GLOBALS["messages"]["btncancel"];
        echo "\" onClick=\"javascript:location='" . make_link("list", $dir, NULL);
        echo "';\"></TD>\n</TR></FORM></TABLE><BR>\n";
        return;
    }
    // DO COPY/MOVE
    // ALL OK?
    if (!@file_exists(get_abs_dir($new_dir))) {
        show_error($new_dir . ": " . $GLOBALS["error_msg"]["targetexist"]);
    }
    if (!get_show_item($new_dir, "")) {
        show_error($new_dir . ": " . $GLOBALS["error_msg"]["accesstarget"]);
    }
    if (!down_home(get_abs_dir($new_dir))) {
        show_error($new_dir . ": " . $GLOBALS["error_msg"]["targetabovehome"]);
    }
    // copy / move files
    $err = false;
    for ($i = 0; $i < $cnt; ++$i) {
        $tmp = stripslashes($GLOBALS['__POST']["selitems"][$i]);
        $new = base_name(stripslashes($GLOBALS['__POST']["newitems"][$i]));
        $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 (!@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 (@file_exists($abs_new_item)) {
            $error[$i] = $GLOBALS["error_msg"]["targetdoesexist"];
            $err = true;
            continue;
        }
        // Copy / Move
        if ($GLOBALS["action"] == "copy") {
            if (@is_link($abs_item) || @is_file($abs_item)) {
                // check file-exists to avoid error with 0-size files (PHP 4.3.0)
                $ok = @copy_file($abs_item, $abs_new_item);
                //||@file_exists($abs_new_item);
            } elseif (@is_dir($abs_item)) {
                $ok = copy_dir($abs_item, $abs_new_item);
            }
        } else {
            $ok = @rename($abs_item, $abs_new_item);
        }
        if ($ok === false) {
            $error[$i] = $GLOBALS["action"] == "copy" ? $GLOBALS["error_msg"]["copyitem"] : $GLOBALS["error_msg"]["moveitem"];
            $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));
}
Example #8
0
function remove($item)
{
    // remove file / dir
    $ok = true;
    if (@is_link($item) || @is_file($item)) {
        $ok = @unlink($item);
    } elseif (@is_dir($item)) {
        if (($handle = @opendir($item)) === false) {
            show_error(base_name($item) . ": " . $GLOBALS["error_msg"]["opendir"]);
        }
        while (($file = readdir($handle)) !== false) {
            if ($file == ".." || $file == ".") {
                continue;
            }
            $new_item = $item . "/" . $file;
            if (!@file_exists($new_item)) {
                show_error(base_name($item) . ": " . $GLOBALS["error_msg"]["readdir"]);
            }
            //if(!get_show_item($item, $new_item)) continue;
            if (@is_dir($new_item)) {
                $ok = remove($new_item);
            } else {
                $ok = @unlink($new_item);
            }
        }
        closedir($handle);
        $ok = @rmdir($item);
    }
    return $ok;
}