/** * This function realizes the procedure of pasting files, that is common for all the versions of Dolphin.php . The $func_print parameter is used to specify some function for printing messages. * * @param string $func_print * @return bool */ function paste($func_print) { if(!empty($_SESSION['copy'])) { if(!empty($_GET['dir'])) $_SESSION['DIR']=clean($_GET['dir']); $error=false; if(abs_path($_SESSION['DIR'])==abs_path(dirname($_SESSION['copy'][0]))) // if it's the same dir, modify $_SESSION['copy'] to make the copies of files { foreach($_SESSION['copy'] as $k=>$v) { $name = gen_copy_name($_SESSION['DIR'], $v); //echo $v.' - '.$name; if(!d_copy($v,$name)) $error=true; } }else foreach($_SESSION['copy'] as $v) if(!d_copy($v,$_SESSION['DIR'].'/'.basename($v))) $error=true; $_SESSION['copy']=array(); if(!$error) { $func_print('All files were copied successfully'); return true; }else { $func_print('There were problems while copying files. '.reason()); return false; } } if(!empty($_SESSION['cut'])) { if(!empty($_GET['dir'])) $_SESSION['DIR']=clean($_GET['dir']); $error=false; if(abs_path($_SESSION['DIR'])!=abs_path(dirname($_SESSION['cut'][0]))) { foreach($_SESSION['cut'] as $v) { if(!@d_rename($v,$_SESSION['DIR'].'/'.basename($v)) && !(@d_copy($v,$_SESSION['DIR'].'/'.basename($v)) && @d_remove($v)) ) { $error=true; } } } $_SESSION['cut']=array(); if(!$error) { $func_print('All files were cut successfully.'); return true; }else { $func_print('There were some problems while cutting files. '.reason()); } return false; } }
<h4>After renaming:</h4> <i>image<b>1</b>.jpg</i><br> <i>image<b>2</b>.jpg</i><br> <i>image<b>3</b>.jpg</i><br> <h3>Rename</h3> You have selected <b>'.sizeof($_POST['files']).'</b> files. <br>Enter the mask: <input type=text name="mask" value="file?.ext"> <br><input type=submit name="apply" value="rename"> </form>'); }else { $nomain=false; $error=false; $i=1; foreach($_SESSION['files'] as $k=>$v) if(!@d_rename(clean($v),clean($_SESSION['DIR'].'/'.str_replace('?',$i++,$_POST['mask'])))) $error=true; if(!$error) light_message('All files have been renamed successfully'); else light_message('There were some problems while renaming files.'.reason(),'index.php'); $_SESSION['files']=false; unset($_SESSION['files']); } } break; case 'copy': case 'cut': $nomain=false; if(!empty($_REQUEST['file'])) $_REQUEST['files']=array($_REQUEST['file']); if(empty($_REQUEST['files'])) { light_message('Choose one or more files you want to '.$_REQUEST['act'].'.');
$end = true; } $_RESULT = array( 'dirs' => $_SESSION['DIRS'], 'files' => $_SESSION['FILES'], 'total' => show_size(false,true,$_SESSION['TOTAL_BYTES']), 'end' => $end, 'success' => $_SESSION['DCACHE'] !== false, ); break; case 'rename': $f = clean($_REQUEST['old']); if(empty($_REQUEST['new'])) $_REQUEST['new'] = basename($f); $newname = clean(dirname($f).'/'.$_REQUEST['new']); if(!d_rename($f,$newname)) $_RESULT = array( 'success' => false, 'reason' => reason(), 'f' => $f ); else $_RESULT = array( 'success' => true ); break; case 'mkdir': $f=clean($_SESSION['DIR'].'/'.$_REQUEST['name']); if(!d_mkdir($f)) $_RESULT = array('success' => false, 'reason' => reason()); else $_RESULT = array('success' => true); break; case 'mkfile': $f=clean($_SESSION['DIR'].'/'.$_REQUEST['name']); if(file_exists($f) && $_REQUEST['confirm']==0) { $_RESULT = array('exists' => true); }else if(file_exists($f) && $_REQUEST['confirm'] == 1 || !file_exists($f))