function copy_move_items($dir) { // copy/move file/dir if (($GLOBALS["permissions"] & 01) != 01) { show_error($GLOBALS["error_msg"]["accessfunc"]); } $action = stripslashes(JRequest::getCmd('action')); if ($action == "post") { $action = JRequest::getCmd("do_action"); } elseif (empty($action)) { $action = "list"; } // 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 ($action != "move") { $images = "images/__copy.gif"; } else { $images = "images/__cut.gif"; } // Get New Location & Names if (!isset($GLOBALS['__POST']["confirm"]) || $GLOBALS['__POST']["confirm"] != "true") { show_header($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=\"" . _QUIXPLORER_URL . '/images/' . $images . "\" align=\"absmiddle\" alt=\"\" /> <strong>"; echo sprintf($action != "move" ? $GLOBALS["messages"]["actcopyfrom"] : $GLOBALS["messages"]["actmovefrom"], $s_dir, $s_ndir); echo "</strong><img src=\"" . _QUIXPLORER_URL . "/images/__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 style=\"width:500px;\" class=\"adminform\">\n"; echo "<input type=\"hidden\" name=\"do_action\" value=\"" . $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 />\n\t\t<table style=\"width:500px;\" class=\"adminform\">\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=\"" . _QUIXPLORER_URL . "/images/information.png\" align=\"absmiddle\" alt=\"\">"; // old name echo "<input type=\"hidden\" name=\"selitems[]\" value=\""; echo $selitem . "\"> " . $s_item . " "; // 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 $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></table><br /></form>\n"; return; } // DO COPY/MOVE // ALL OK? if (!@$GLOBALS['nx_File']->file_exists(get_abs_dir($new_dir))) { show_error(get_abs_dir($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])); if (nx_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['nx_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['nx_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 (nx_isFTPMode()) { $abs_item = '/' . $dir . '/' . $abs_item['name']; } $ok = @$GLOBALS['nx_File']->copy($abs_item, $abs_new_item); //||@file_exists($abs_new_item); } elseif (@get_is_dir($abs_item)) { $dir = nx_isFTPMode() ? '/' . $dir . '/' . $abs_item['name'] . '/' : $abs_item; if (nx_isFTPMode()) { $abs_new_item .= '/'; } $ok = $GLOBALS['nx_File']->copy_dir($dir, $abs_new_item); } } else { $ok = $GLOBALS['nx_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] . "<br />\n"; } show_error($err_msg); } header("Location: " . make_link("list", $dir, NULL)); }
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=\"\"> "; //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."\"> ".$s_item." "; // 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 . "\"> " . $s_item . " "; // 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)); }
function unzip_item($dir) { _debug("unzip_item({$dir})"); global $home_dir; // copy and move are only allowed if the user may read and change files if (!permissions_grant_all($dir, NULL, array("read", "create"))) { show_error($GLOBALS["error_msg"]["accessfunc"]); } // Vars $new_dir = isset($GLOBALS['__POST']["new_dir"]) ? stripslashes($GLOBALS['__POST']["new_dir"]) : $dir; $_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 = "{$home_dir}/{$new_dir}"; if ($new_dir != "") { $dir_extract .= "/"; } $zip_name = "{$home_dir}/{$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 "<CENTER><BR><BR><IMG SRC=\"" . $_img . "\" align=\"ABSMIDDLE\" ALT=\"\"> "; 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 echo "<TR><TD><IMG SRC=\"" . $GLOBALS["baricons"]["zip"] . "\" align=\"ABSMIDDLE\" ALT=\"\">"; echo "<INPUT type=\"hidden\" name=\"item\" value=\"" . $s_item . "\"> " . $s_item . " "; // Submit & Cancel echo "</TABLE><BR><TABLE><TR>\n<TD>"; echo "<INPUT type=\"submit\" value=\""; echo $GLOBALS["messages"]["btnunzip"]; 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><BR><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); } */ //---------------------------------- print_r($GLOBALS); _debug("unzip_item(): Extracting {$zip_name} to {$dir_extract}"); //$dir_extract[0]='/'; //$dir_extract = '.'. $dir_extract; //------------------------------------------------------echo $zip_name.' aa'.$dir_extract.'aa'; $exx = pathinfo($zip_name, PATHINFO_EXTENSION); if ($exx == 'zip') { $zip = new ZipArchive(); $res = $zip->open($zip_name); if ($res === TRUE) { $zip->extractTo($dir_extract); $zip->close(); } else { } } else { // gz, tar, bz2, .... include_once './_lib/archive.php'; extArchive::extract($zip_name, $dir_extract); } // FIXME $i is not set anymore.. remove code? if (!isset($i)) { $i = 0; } if ($res == false) { $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); } header("Location: " . make_link("list", $dir, NULL)); }
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 = $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") { $msg = $GLOBALS["action"] != "move" ? $GLOBALS["messages"]["actcopyitems"] : $GLOBALS["messages"]["actmoveitems"]; show_header($msg); // 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=\"\"> "; echo htmlspecialchars(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=\"" . htmlspecialchars($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 = $GLOBALS['__POST']["selitems"][$i]; if (isset($GLOBALS['__POST']["newitems"][$i])) { $newitem = $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 htmlspecialchars($selitem) . "\"> " . htmlspecialchars($s_item) . " "; // New Name echo "</TD><TD><INPUT type=\"text\" size=\"25\" name=\"newitems[]\" value=\""; echo htmlspecialchars($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 = $GLOBALS['__POST']["selitems"][$i]; $new = basename($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); } header("Location: " . make_link("list", $dir, NULL)); }