file_exists(dirname(get_abs_dir($new_dir)))) { ext_Result::sendResult( $action, false, dirname(get_abs_dir($new_dir)).": ".$GLOBALS["error_msg"]["targetexist"]); } if(!get_show_item($new_dir,"")) { ext_Result::sendResult( $action, false, $new_dir.": ".$GLOBALS["error_msg"]["accesstarget"]); } if(!down_home(get_abs_dir($new_dir))) { ext_Result::sendResult( $action, false, $new_dir.": ".$GLOBALS["error_msg"]["targetabovehome"]); } // copy / move files $err=false; for($i=0;$i<$cnt;++$i) { $tmp = basename(stripslashes($GLOBALS['__POST']["selitems"][$i])); $new = basename(stripslashes($GLOBALS['__POST']["selitems"][$i])); if( ext_isFTPMode() ) { $abs_item = get_item_info($dir,$tmp); $abs_new_item = $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['ext_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['ext_File']->file_exists($abs_new_item)) { $error[$i]= $GLOBALS["error_msg"]["targetdoesexist"]; $err=true; continue; } // Copy / Move if($action=="copy") { if(@is_link(ext_TextEncoding::fromUTF8($abs_item)) || get_is_file(ext_TextEncoding::fromUTF8($abs_item))) { // check file-exists to avoid error with 0-size files (PHP 4.3.0) if( ext_isFTPMode() ) $abs_item = '/'.$dir.'/'.$abs_item['name']; $ok=@$GLOBALS['ext_File']->copy( $abs_item ,$abs_new_item); //||@file_exists($abs_new_item); } elseif(@get_is_dir(ext_TextEncoding::fromUTF8($abs_item))) { $ext_copy_dir = ext_isFTPMode() ? '/'.$dir.'/'.$abs_item['name'].'/' : $abs_item; if( ext_isFTPMode() ) $abs_new_item .= '/'; $ok=$GLOBALS['ext_File']->ext_copy_dir( $ext_copy_dir, $abs_new_item); } } else { $ok= $GLOBALS['ext_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]."\n"; } ext_Result::sendResult( $action, false, $err_msg); } ext_Result::sendResult( $action, true, 'The File(s)/Directory(s) were successfully '.($action=='copy'?'copied':'moved').'.' ); } function ext_copy_move_dialog($dir='') { $action = extGetParam( $_REQUEST, 'action' ); ?> { "xtype": "form", "id": "simpleform", "labelWidth": 125, "width": "340", "url":"", "dialogtitle": "", "frame": true, "items": [{ "xtype": "textfield", "fieldLabel": "Destination", "name": "new_dir", "value": "/", "width":175, "allowBlank":false }], "buttons": [{ text: '', handler: function() { form = Ext.getCmp('simpleform').getForm(); statusBarMessage( 'Please wait...', true ); var requestParams = getRequestParams(); requestParams.confirm = 'true'; requestParams.action = ''; form.submit({ //reset: true, reset: false, success: function(form, action) { statusBarMessage( action.result.message, false, true ); try{ dirTree.getSelectionModel().getSelectedNode().reload(); } catch(e) {} datastore.reload(); Ext.getCmp("dialog").destroy(); }, failure: function(form, action) { if( !action.result ) return; Ext.MessageBox.alert('Error!', action.result.error); statusBarMessage( action.result.error, false, false ); }, scope: form, // add some vars to the request, similar to hidden fields params: requestParams }); } },{ text: '', handler: function() { Ext.getCmp("dialog").destroy(); } } ] }