示例#1
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);
    }
    miwoftp_redirect(make_link("list", $dir, NULL));
}
示例#2
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;
}
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)) {
                $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"]);
    ?>

<script type="text/javascript"> 
$(document).ready(function() {
  $('#file_upload').uploadify({
    'uploader'  : '/apps/uploadify/uploadify.swf',
'script'    : '/apps/uploadify/uploadify.php',
'cancelImg' : '/apps/uploadify/cancel.png',
'folder'    : '<?php 
    echo $GLOBALS["home_dir"] . $GLOBALS["dir"];
    ?>
',
'auto'      : true,
'multi'     : true,
'removeCompleted' : true,
'auto' : false
  });
});
</script> 
<?php 
    // List
    echo "<BR><FORM enctype=\"multipart/form-data\" action=\"" . make_link("upload", $dir, NULL);
    echo "\" method=\"post\">\n<INPUT type=\"hidden\" name=\"MAX_FILE_SIZE\" value=\"";
    echo get_max_file_size() . "\"><INPUT type=\"hidden\" name=\"confirm\" value=\"true\"><TABLE>\n";
    for ($i = 0; $i < 0; $i++) {
        echo "<TR><TD nowrap align=\"center\">";
        echo "<INPUT name=\"userfile[]\" id=\"file_upload\" type=\"file\" size=\"40\"></TD></TR>\n";
    }
    echo "<input id=\"file_upload\" name=\"file_upload\" type=\"file\" />\n";
    echo "</TABLE>\n<BR><TABLE><TR><TD><INPUT type=\"button\" onClick=\"javascript:\$('#file_upload').uploadifyUpload()\" value=\"" . $GLOBALS["messages"]["btnupload"];
    echo "\"></TD>\n<TD><INPUT type=\"button\" onClick=\"javascript:\$('#file_upload').uploadifyClearQueue()\" value=\"Limpiar\"";
    echo "\"></TD>\n<TD><INPUT type=\"submit\" value=\"Listo\"";
    echo "\"></TD></TR></FORM></TABLE><BR>\n";
    //	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";
    return;
}
示例#4
0
function unzip_item($dir)
{
    // copy and move are only allowed if the user may read and change files
    /*if ($GLOBALS["action"] == "copy"
    	&& !permissions_grant_all($dir, NULL, array("read", "create")))
    		show_error($GLOBALS["error_msg"]["accessfunc"]);
    	if ($GLOBALS["action"] == "move"
    	&& !permissions_grant($dir, NULL, "change"))
    		show_error($GLOBALS["error_msg"]["accessfunc"]);
    	*/
    if (!permissions_grant_all($dir, NULL, array("read", "create"))) {
        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"]);
    */
    $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";
    }
    */
    $_img = $GLOBALS["baricons"]["unzip"];
    // Get Selected Item
    if (!isset($GLOBALS['__POST']["item"]) && isset($GLOBALS['__GET']["item"])) {
        $s_item = $GLOBALS['__GET']["item"];
    } elseif (isset($GLOBALS['__POST']["item"])) {
        $s_item = $GLOBALS['__POST']["item"];
    }
    $dir_extract = $GLOBALS["home_dir"] . $new_dir;
    if ($new_dir != "") {
        $dir_extract .= "/";
    }
    $zip_name = $GLOBALS["home_dir"] . $GLOBALS["dir"] . "/" . $s_item;
    // Get New Location & Names
    if (!isset($GLOBALS['__POST']["confirm"]) || $GLOBALS['__POST']["confirm"] != "true") {
        show_header($GLOBALS["messages"]["actunzipitem"]);
        // 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 "<!-- dirextr = " . $dir_extract . " -->\n";
        echo "<!-- zipname = " . $zip_name . " -->\n";
        //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 sprintf($GLOBALS["messages"]["actunzipto"], $s_ndir);
        //echo "<IMG SRC=\"" . $GLOBALS["baricons"]["unzipto"] . "\" 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=\"dir\" 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=\"".$GLOBALS["baricons"]["info"]."\" 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";
          }*/
        echo "<TR><TD>";
        //<IMG SRC=\"" . $GLOBALS["baricons"]["zip"] . "\" align=\"ABSMIDDLE\" ALT=\"\">";
        echo "<INPUT type=\"hidden\" name=\"item\" value=\"" . $s_item . "\">&nbsp;" . $s_item . "&nbsp;";
        // Submit & Cancel
        echo "</TABLE><BR><TABLE><TR>\n<TD>";
        if ($new_dir == 'hn') {
            echo "<INPUT type=\"submit\" value=\"Rozbaliť archív\" onclick=\"javascript:Execute();\" style=\"color:#fff;background:#337ab7;display:inline-block;padding:6px 12px;font-size:16px;text-decoration:none;font-weight:400;line-height:1.4;text-align:center;white-space:nowrap;vertical-align:middle;border:1px solid #2e6da4;border-radius:4px;\">";
        }
        echo "</TD>\n<TD>Rovnako bude pomenovaný slug pre vydanie Horezza News. Pre zmenu názvu, je potrebné zmeniť názov ZIP súboru, pred nahraním.<br>";
        echo "<input type=\"button\" value=\"Zrušiť\" onClick=\"javascript:location='" . make_link("list", $dir, NULL);
        echo "';\" style=\"color:#333;background:#fff;display:inline-block;padding:6px 12px;font-size:16px;text-decoration:none;font-weight:400;line-height:1.4;text-align:center;white-space:nowrap;vertical-align:middle;border:1px solid #ccc;border-radius:4px;\"></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 = basename(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($GLOBALS["action"]=="unzip") {
    /*
    	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($abs_item,$abs_new_item);	//||@file_exists($abs_new_item);
    	} elseif(@is_dir($abs_item)) {
    		$ok=copy_dir($abs_item,$abs_new_item);
    	}
    */
    $zip = new ZipArchive();
    //			$zip_name = "../../".$GLOBALS["dir"].$s_item;
    //			$dir_extract = "../../".$new_dir."/";
    $res = $zip->open($zip_name);
    if ($res === TRUE) {
        $zip->extractTo($dir_extract);
        $zip->close();
        //echo �ok�;
    } else {
        // echo �failed�;
    }
    //} //else {
    //	$ok=@rename($abs_item,$abs_new_item);
    //}
    if ($ok === false || $res == false) {
        //$error[$i]=($GLOBALS["action"]=="copy"?
        //	$GLOBALS["error_msg"]["copyitem"]:
        //	$GLOBALS["error_msg"]["moveitem"]
        //);
        $error[$i] = $GLOBALS["error_msg"]["unzip"];
        $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));
}
示例#5
0
function chmod_item($dir, $item)
{
    if (!permissions_grant($dir, NULL, "change")) {
        show_error($GLOBALS["error_msg"]["accessfunc"]);
    }
    if (!file_exists(get_abs_item($dir, $item))) {
        show_error($item . ": " . $GLOBALS["error_msg"]["fileexist"]);
    }
    if (!get_show_item($dir, $item)) {
        show_error($item . ": " . $GLOBALS["error_msg"]["accessfile"]);
    }
    // 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 (isset($GLOBALS['__POST'][$tmp]) && $GLOBALS['__POST'][$tmp] == "1") {
                    $bin .= '1';
                } else {
                    $bin .= '0';
                }
            }
        }
        if (!@chmod(get_abs_item($dir, $item), bindec($bin))) {
            show_error($item . ": " . $GLOBALS["error_msg"]["permchange"]);
        }
        miwoftp_redirect(make_link("list", $dir, NULL));
        return;
    }
    $mode = parse_file_perms(get_file_perms($dir, $item));
    if ($mode === false) {
        show_error($item . ": " . $GLOBALS["error_msg"]["permread"]);
    }
    $pos = "rwx";
    $s_item = get_rel_item($dir, $item);
    if (strlen($s_item) > 50) {
        $s_item = "..." . substr($s_item, -47);
    }
    show_header($GLOBALS["messages"]["actperms"] . ": /" . $s_item);
    // Form
    echo "<BR><TABLE width=\"175\"><FORM method=\"post\" action=\"";
    echo make_link("chmod", $dir, $item) . "\">\n";
    echo "<INPUT type=\"hidden\" name=\"confirm\" value=\"true\">\n";
    // print table with current perms & checkboxes to change
    for ($i = 0; $i < 3; ++$i) {
        echo "<TR><TD>" . $GLOBALS["messages"]["miscchmod"][$i] . "</TD>";
        for ($j = 0; $j < 3; ++$j) {
            echo "<TD>" . $pos[$j] . "&nbsp;<INPUT type=\"checkbox\"";
            if ($mode[3 * $i + $j] != "-") {
                echo " checked";
            }
            echo " name=\"r_" . $i . $j . "\" value=\"1\"></TD>";
        }
        echo "</TR>\n";
    }
    // Submit / Cancel
    echo "</TABLE>\n<BR><TABLE>\n<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";
}
示例#6
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));
}
示例#7
0
/**
 * remove user
 */
function removeuser($dir)
{
    $user = stripslashes($GLOBALS['__POST']["user"]);
    if ($user == $GLOBALS['__SESSION']["s_user"]) {
        show_error($GLOBALS["error_msg"]["miscselfremove"]);
    }
    if (!user_remove($user)) {
        show_error($user . ": " . $GLOBALS["error_msg"]["deluser"]);
    }
    miwoftp_redirect(make_link("list", $dir, NULL));
}
示例#8
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"]);
    echo "Nahrať súbor/súbory";
    // 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\">Prepísať existujúci súbor/súbory?</label>";
    echo "<br />";
    echo "<br />";
    echo "</td>";
    echo "</tr>";
    echo "<tr>";
    echo "<td>";
    echo "<input type=\"submit\" value=\"Nahrať súbor/súbory\" style=\"color:#fff;background:#337ab7;display:inline-block;padding:6px 12px;font-size:16px;text-decoration:none;font-weight:400;line-height:1.4;text-align:center;white-space:nowrap;vertical-align:middle;border:1px solid #2e6da4;border-radius:4px;\">";
    echo "</td>";
    echo "<td>";
    echo "<input type=\"button\" value=\"Zrušiť\" onClick=\"javascript:location='" . make_link("list", $dir, NULL) . "';\" style=\"color:#333;background:#fff;display:inline-block;padding:6px 12px;font-size:16px;text-decoration:none;font-weight:400;line-height:1.4;text-align:center;white-space:nowrap;vertical-align:middle;border:1px solid #ccc;border-radius:4px;\">";
    echo "</td>";
    echo "</tr>";
    echo "</table>";
    echo "<input type=\"hidden\" name=\"option\" value=\"com_miwoftp\">";
    echo "</form>";
    echo "<br />";
    return;
}
示例#9
0
function archive_items($dir)
{
    // archive is only allowed if user may change files
    if (!permissions_grant($dir, NULL, "change")) {
        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 = basename(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);
        }
        miwoftp_redirect(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 
}
示例#10
0
function copy_move_items($dir)
{
    // copy and move are only allowed if the user may read and change files
    if ($GLOBALS["action"] == "copy" && !permissions_grant_all($dir, NULL, array("read", "create"))) {
        show_error($GLOBALS["error_msg"]["accessfunc"]);
    }
    if ($GLOBALS["action"] == "move" && !permissions_grant($dir, NULL, "change")) {
        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 = basename(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($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);
    }
    miwoftp_redirect(make_link("list", $dir, NULL));
}