Edit File by line

Deprecated: str_replace(): Passing null to parameter #2 ($replace) of type array|string is deprecated in /home/sportsfever/public_html/filemanger/function.php on line 93

Warning: Undefined array key "page_file_edit_line" in /home/sportsfever/public_html/filemanger/edit_text_line.php on line 32
/home/sportsfe.../httpdocs/wp-conte.../plugins/wp-file-.../lib/php
File: elFinderVolumeDriver.class.php
return $this->setError(elFinder::ERROR_UPLOAD_FILE_SIZE);
[2500] Fix | Delete
}
[2501] Fix | Delete
[2502] Fix | Delete
$dstpath = $this->decode($dst);
[2503] Fix | Delete
if (isset($hashes[$name])) {
[2504] Fix | Delete
$test = $this->decode($hashes[$name]);
[2505] Fix | Delete
$file = $this->stat($test);
[2506] Fix | Delete
} else {
[2507] Fix | Delete
$test = $this->joinPathCE($dstpath, $name);
[2508] Fix | Delete
$file = $this->isNameExists($test);
[2509] Fix | Delete
}
[2510] Fix | Delete
[2511] Fix | Delete
$this->clearcache();
[2512] Fix | Delete
[2513] Fix | Delete
if ($file && $file['name'] === $name) { // file exists and check filename for item ID based filesystem
[2514] Fix | Delete
if ($this->uploadOverwrite) {
[2515] Fix | Delete
if (!$file['write']) {
[2516] Fix | Delete
return $this->setError(elFinder::ERROR_PERM_DENIED);
[2517] Fix | Delete
} elseif ($file['mime'] == 'directory') {
[2518] Fix | Delete
return $this->setError(elFinder::ERROR_NOT_REPLACE, $name);
[2519] Fix | Delete
}
[2520] Fix | Delete
$this->remove($test);
[2521] Fix | Delete
} else {
[2522] Fix | Delete
$name = $this->uniqueName($dstpath, $name, '-', false);
[2523] Fix | Delete
}
[2524] Fix | Delete
}
[2525] Fix | Delete
[2526] Fix | Delete
$stat = array(
[2527] Fix | Delete
'mime' => $mime,
[2528] Fix | Delete
'width' => 0,
[2529] Fix | Delete
'height' => 0,
[2530] Fix | Delete
'size' => $tmpsize);
[2531] Fix | Delete
[2532] Fix | Delete
// $w = $h = 0;
[2533] Fix | Delete
if (strpos($mime, 'image') === 0 && ($s = getimagesize($tmpname))) {
[2534] Fix | Delete
$stat['width'] = $s[0];
[2535] Fix | Delete
$stat['height'] = $s[1];
[2536] Fix | Delete
}
[2537] Fix | Delete
// $this->clearcache();
[2538] Fix | Delete
if (($path = $this->saveCE($fp, $dstpath, $name, $stat)) == false) {
[2539] Fix | Delete
return false;
[2540] Fix | Delete
}
[2541] Fix | Delete
[2542] Fix | Delete
$stat = $this->stat($path);
[2543] Fix | Delete
// Try get URL
[2544] Fix | Delete
if (empty($stat['url']) && ($url = $this->getContentUrl($stat['hash']))) {
[2545] Fix | Delete
$stat['url'] = $url;
[2546] Fix | Delete
}
[2547] Fix | Delete
[2548] Fix | Delete
return $stat;
[2549] Fix | Delete
}
[2550] Fix | Delete
[2551] Fix | Delete
/**
[2552] Fix | Delete
* Paste files
[2553] Fix | Delete
*
[2554] Fix | Delete
* @param Object $volume source volume
[2555] Fix | Delete
* @param $src
[2556] Fix | Delete
* @param string $dst destination dir hash
[2557] Fix | Delete
* @param bool $rmSrc remove source after copy?
[2558] Fix | Delete
* @param array $hashes
[2559] Fix | Delete
*
[2560] Fix | Delete
* @return array|false
[2561] Fix | Delete
* @throws elFinderAbortException
[2562] Fix | Delete
* @internal param string $source file hash
[2563] Fix | Delete
* @author Dmitry (dio) Levashov
[2564] Fix | Delete
*/
[2565] Fix | Delete
public function paste($volume, $src, $dst, $rmSrc = false, $hashes = array())
[2566] Fix | Delete
{
[2567] Fix | Delete
$err = $rmSrc ? elFinder::ERROR_MOVE : elFinder::ERROR_COPY;
[2568] Fix | Delete
[2569] Fix | Delete
if ($this->commandDisabled('paste')) {
[2570] Fix | Delete
return $this->setError($err, '#' . $src, elFinder::ERROR_PERM_DENIED);
[2571] Fix | Delete
}
[2572] Fix | Delete
[2573] Fix | Delete
if (($file = $volume->file($src, $rmSrc)) == false) {
[2574] Fix | Delete
return $this->setError($err, '#' . $src, elFinder::ERROR_FILE_NOT_FOUND);
[2575] Fix | Delete
}
[2576] Fix | Delete
[2577] Fix | Delete
$name = $file['name'];
[2578] Fix | Delete
$errpath = $volume->path($file['hash']);
[2579] Fix | Delete
[2580] Fix | Delete
if (($dir = $this->dir($dst)) == false) {
[2581] Fix | Delete
return $this->setError($err, $errpath, elFinder::ERROR_TRGDIR_NOT_FOUND, '#' . $dst);
[2582] Fix | Delete
}
[2583] Fix | Delete
[2584] Fix | Delete
if (!$dir['write'] || !$file['read']) {
[2585] Fix | Delete
return $this->setError($err, $errpath, elFinder::ERROR_PERM_DENIED);
[2586] Fix | Delete
}
[2587] Fix | Delete
[2588] Fix | Delete
$destination = $this->decode($dst);
[2589] Fix | Delete
[2590] Fix | Delete
if (($test = $volume->closest($src, $rmSrc ? 'locked' : 'read', $rmSrc))) {
[2591] Fix | Delete
return $rmSrc
[2592] Fix | Delete
? $this->setError($err, $errpath, elFinder::ERROR_LOCKED, $volume->path($test))
[2593] Fix | Delete
: $this->setError($err, $errpath, empty($file['thash']) ? elFinder::ERROR_PERM_DENIED : elFinder::ERROR_MKOUTLINK);
[2594] Fix | Delete
}
[2595] Fix | Delete
[2596] Fix | Delete
if (isset($hashes[$name])) {
[2597] Fix | Delete
$test = $this->decode($hashes[$name]);
[2598] Fix | Delete
$stat = $this->stat($test);
[2599] Fix | Delete
} else {
[2600] Fix | Delete
$test = $this->joinPathCE($destination, $name);
[2601] Fix | Delete
$stat = $this->isNameExists($test);
[2602] Fix | Delete
}
[2603] Fix | Delete
$this->clearcache();
[2604] Fix | Delete
$dstDirExists = false;
[2605] Fix | Delete
if ($stat && $stat['name'] === $name) { // file exists and check filename for item ID based filesystem
[2606] Fix | Delete
if ($this->options['copyOverwrite']) {
[2607] Fix | Delete
// do not replace file with dir or dir with file
[2608] Fix | Delete
if (!$this->isSameType($file['mime'], $stat['mime'])) {
[2609] Fix | Delete
return $this->setError(elFinder::ERROR_NOT_REPLACE, $this->path($stat['hash']));
[2610] Fix | Delete
}
[2611] Fix | Delete
// existed file is not writable
[2612] Fix | Delete
if (empty($stat['write'])) {
[2613] Fix | Delete
return $this->setError($err, $errpath, elFinder::ERROR_PERM_DENIED);
[2614] Fix | Delete
}
[2615] Fix | Delete
if ($this->options['copyJoin']) {
[2616] Fix | Delete
if (!empty($stat['locked'])) {
[2617] Fix | Delete
return $this->setError(elFinder::ERROR_LOCKED, $this->path($stat['hash']));
[2618] Fix | Delete
}
[2619] Fix | Delete
} else {
[2620] Fix | Delete
// existed file locked or has locked child
[2621] Fix | Delete
if (($locked = $this->closestByAttr($test, 'locked', true))) {
[2622] Fix | Delete
$stat = $this->stat($locked);
[2623] Fix | Delete
return $this->setError(elFinder::ERROR_LOCKED, $this->path($stat['hash']));
[2624] Fix | Delete
}
[2625] Fix | Delete
}
[2626] Fix | Delete
// target is entity file of alias
[2627] Fix | Delete
if ($volume === $this && ((isset($file['target']) && $test == $file['target']) || $test == $this->decode($src))) {
[2628] Fix | Delete
return $this->setError(elFinder::ERROR_REPLACE, $errpath);
[2629] Fix | Delete
}
[2630] Fix | Delete
// remove existed file
[2631] Fix | Delete
if (!$this->options['copyJoin'] || $stat['mime'] !== 'directory') {
[2632] Fix | Delete
if (!$this->remove($test)) {
[2633] Fix | Delete
return $this->setError(elFinder::ERROR_REPLACE, $this->path($stat['hash']));
[2634] Fix | Delete
}
[2635] Fix | Delete
} else if ($stat['mime'] === 'directory') {
[2636] Fix | Delete
$dstDirExists = true;
[2637] Fix | Delete
}
[2638] Fix | Delete
} else {
[2639] Fix | Delete
$name = $this->uniqueName($destination, $name, ' ', false);
[2640] Fix | Delete
}
[2641] Fix | Delete
}
[2642] Fix | Delete
[2643] Fix | Delete
// copy/move inside current volume
[2644] Fix | Delete
if ($volume === $this) { // changing == operand to === fixes issue #1285 - Paul Canning 24/03/2016
[2645] Fix | Delete
$source = $this->decode($src);
[2646] Fix | Delete
// do not copy into itself
[2647] Fix | Delete
if ($this->inpathCE($destination, $source)) {
[2648] Fix | Delete
return $this->setError(elFinder::ERROR_COPY_ITSELF, $errpath);
[2649] Fix | Delete
}
[2650] Fix | Delete
$rmDir = false;
[2651] Fix | Delete
if ($rmSrc) {
[2652] Fix | Delete
if ($dstDirExists) {
[2653] Fix | Delete
$rmDir = true;
[2654] Fix | Delete
$method = 'copy';
[2655] Fix | Delete
} else {
[2656] Fix | Delete
$method = 'move';
[2657] Fix | Delete
}
[2658] Fix | Delete
} else {
[2659] Fix | Delete
$method = 'copy';
[2660] Fix | Delete
}
[2661] Fix | Delete
$this->clearcache();
[2662] Fix | Delete
if ($res = ($path = $this->$method($source, $destination, $name)) ? $this->stat($path) : false) {
[2663] Fix | Delete
if ($rmDir) {
[2664] Fix | Delete
$this->remove($source);
[2665] Fix | Delete
}
[2666] Fix | Delete
} else {
[2667] Fix | Delete
return false;
[2668] Fix | Delete
}
[2669] Fix | Delete
} else {
[2670] Fix | Delete
// copy/move from another volume
[2671] Fix | Delete
if (!$this->options['copyTo'] || !$volume->copyFromAllowed()) {
[2672] Fix | Delete
return $this->setError(elFinder::ERROR_COPY, $errpath, elFinder::ERROR_PERM_DENIED);
[2673] Fix | Delete
}
[2674] Fix | Delete
[2675] Fix | Delete
$this->error = array();
[2676] Fix | Delete
if (($path = $this->copyFrom($volume, $src, $destination, $name)) == false) {
[2677] Fix | Delete
return false;
[2678] Fix | Delete
}
[2679] Fix | Delete
[2680] Fix | Delete
if ($rmSrc && !$this->error()) {
[2681] Fix | Delete
if (!$volume->rm($src)) {
[2682] Fix | Delete
if ($volume->file($src)) {
[2683] Fix | Delete
$this->addError(elFinder::ERROR_RM_SRC);
[2684] Fix | Delete
} else {
[2685] Fix | Delete
$this->removed[] = $file;
[2686] Fix | Delete
}
[2687] Fix | Delete
}
[2688] Fix | Delete
}
[2689] Fix | Delete
$res = $this->stat($path);
[2690] Fix | Delete
}
[2691] Fix | Delete
return $res;
[2692] Fix | Delete
}
[2693] Fix | Delete
[2694] Fix | Delete
/**
[2695] Fix | Delete
* Return path info array to archive of target items
[2696] Fix | Delete
*
[2697] Fix | Delete
* @param array $hashes
[2698] Fix | Delete
*
[2699] Fix | Delete
* @return array|false
[2700] Fix | Delete
* @throws Exception
[2701] Fix | Delete
* @author Naoki Sawada
[2702] Fix | Delete
*/
[2703] Fix | Delete
public function zipdl($hashes)
[2704] Fix | Delete
{
[2705] Fix | Delete
if ($this->commandDisabled('zipdl')) {
[2706] Fix | Delete
return $this->setError(elFinder::ERROR_PERM_DENIED);
[2707] Fix | Delete
}
[2708] Fix | Delete
[2709] Fix | Delete
$archivers = $this->getArchivers();
[2710] Fix | Delete
$cmd = null;
[2711] Fix | Delete
if (!$archivers || empty($archivers['create'])) {
[2712] Fix | Delete
return false;
[2713] Fix | Delete
}
[2714] Fix | Delete
$archivers = $archivers['create'];
[2715] Fix | Delete
if (!$archivers) {
[2716] Fix | Delete
return false;
[2717] Fix | Delete
}
[2718] Fix | Delete
$file = $mime = '';
[2719] Fix | Delete
foreach (array('zip', 'tgz') as $ext) {
[2720] Fix | Delete
$mime = $this->mimetype('file.' . $ext, true);
[2721] Fix | Delete
if (isset($archivers[$mime])) {
[2722] Fix | Delete
$cmd = $archivers[$mime];
[2723] Fix | Delete
break;
[2724] Fix | Delete
}
[2725] Fix | Delete
}
[2726] Fix | Delete
if (!$cmd) {
[2727] Fix | Delete
$cmd = array_shift($archivers);
[2728] Fix | Delete
if (!empty($ext)) {
[2729] Fix | Delete
$mime = $this->mimetype('file.' . $ext, true);
[2730] Fix | Delete
}
[2731] Fix | Delete
}
[2732] Fix | Delete
$ext = $cmd['ext'];
[2733] Fix | Delete
$res = false;
[2734] Fix | Delete
$mixed = false;
[2735] Fix | Delete
$hashes = array_values($hashes);
[2736] Fix | Delete
$dirname = dirname(str_replace($this->separator, DIRECTORY_SEPARATOR, $this->path($hashes[0])));
[2737] Fix | Delete
$cnt = count($hashes);
[2738] Fix | Delete
if ($cnt > 1) {
[2739] Fix | Delete
for ($i = 1; $i < $cnt; $i++) {
[2740] Fix | Delete
if ($dirname !== dirname(str_replace($this->separator, DIRECTORY_SEPARATOR, $this->path($hashes[$i])))) {
[2741] Fix | Delete
$mixed = true;
[2742] Fix | Delete
break;
[2743] Fix | Delete
}
[2744] Fix | Delete
}
[2745] Fix | Delete
}
[2746] Fix | Delete
if ($mixed || $this->root == $this->dirnameCE($this->decode($hashes[0]))) {
[2747] Fix | Delete
$prefix = $this->rootName;
[2748] Fix | Delete
} else {
[2749] Fix | Delete
$prefix = basename($dirname);
[2750] Fix | Delete
}
[2751] Fix | Delete
if ($dir = $this->getItemsInHand($hashes)) {
[2752] Fix | Delete
$tmppre = (substr(PHP_OS, 0, 3) === 'WIN') ? 'zd-' : 'elfzdl-';
[2753] Fix | Delete
$pdir = dirname($dir);
[2754] Fix | Delete
// garbage collection (expire 2h)
[2755] Fix | Delete
register_shutdown_function(array('elFinder', 'GlobGC'), $pdir . DIRECTORY_SEPARATOR . $tmppre . '*', 7200);
[2756] Fix | Delete
$files = self::localScandir($dir);
[2757] Fix | Delete
if ($files && ($arc = tempnam($dir, $tmppre))) {
[2758] Fix | Delete
unlink($arc);
[2759] Fix | Delete
$arc = $arc . '.' . $ext;
[2760] Fix | Delete
$name = basename($arc);
[2761] Fix | Delete
if ($arc = $this->makeArchive($dir, $files, $name, $cmd)) {
[2762] Fix | Delete
$file = tempnam($pdir, $tmppre);
[2763] Fix | Delete
unlink($file);
[2764] Fix | Delete
$res = rename($arc, $file);
[2765] Fix | Delete
$this->rmdirRecursive($dir);
[2766] Fix | Delete
}
[2767] Fix | Delete
}
[2768] Fix | Delete
}
[2769] Fix | Delete
return $res ? array('path' => $file, 'ext' => $ext, 'mime' => $mime, 'prefix' => $prefix) : false;
[2770] Fix | Delete
}
[2771] Fix | Delete
[2772] Fix | Delete
/**
[2773] Fix | Delete
* Return file contents
[2774] Fix | Delete
*
[2775] Fix | Delete
* @param string $hash file hash
[2776] Fix | Delete
*
[2777] Fix | Delete
* @return string|false
[2778] Fix | Delete
* @author Dmitry (dio) Levashov
[2779] Fix | Delete
**/
[2780] Fix | Delete
public function getContents($hash)
[2781] Fix | Delete
{
[2782] Fix | Delete
$file = $this->file($hash);
[2783] Fix | Delete
[2784] Fix | Delete
if (!$file) {
[2785] Fix | Delete
return $this->setError(elFinder::ERROR_FILE_NOT_FOUND);
[2786] Fix | Delete
}
[2787] Fix | Delete
[2788] Fix | Delete
if ($file['mime'] == 'directory') {
[2789] Fix | Delete
return $this->setError(elFinder::ERROR_NOT_FILE);
[2790] Fix | Delete
}
[2791] Fix | Delete
[2792] Fix | Delete
if (!$file['read']) {
[2793] Fix | Delete
return $this->setError(elFinder::ERROR_PERM_DENIED);
[2794] Fix | Delete
}
[2795] Fix | Delete
[2796] Fix | Delete
if ($this->getMaxSize > 0 && $file['size'] > $this->getMaxSize) {
[2797] Fix | Delete
return $this->setError(elFinder::ERROR_UPLOAD_FILE_SIZE);
[2798] Fix | Delete
}
[2799] Fix | Delete
[2800] Fix | Delete
return $file['size'] ? $this->_getContents($this->convEncIn($this->decode($hash), true)) : '';
[2801] Fix | Delete
}
[2802] Fix | Delete
[2803] Fix | Delete
/**
[2804] Fix | Delete
* Put content in text file and return file info.
[2805] Fix | Delete
*
[2806] Fix | Delete
* @param string $hash file hash
[2807] Fix | Delete
* @param string $content new file content
[2808] Fix | Delete
*
[2809] Fix | Delete
* @return array|false
[2810] Fix | Delete
* @author Dmitry (dio) Levashov
[2811] Fix | Delete
**/
[2812] Fix | Delete
public function putContents($hash, $content)
[2813] Fix | Delete
{
[2814] Fix | Delete
if ($this->commandDisabled('edit')) {
[2815] Fix | Delete
return $this->setError(elFinder::ERROR_PERM_DENIED);
[2816] Fix | Delete
}
[2817] Fix | Delete
[2818] Fix | Delete
$path = $this->decode($hash);
[2819] Fix | Delete
[2820] Fix | Delete
if (!($file = $this->file($hash))) {
[2821] Fix | Delete
return $this->setError(elFinder::ERROR_FILE_NOT_FOUND);
[2822] Fix | Delete
}
[2823] Fix | Delete
[2824] Fix | Delete
if (!$file['write']) {
[2825] Fix | Delete
return $this->setError(elFinder::ERROR_PERM_DENIED);
[2826] Fix | Delete
}
[2827] Fix | Delete
[2828] Fix | Delete
// check data cheme
[2829] Fix | Delete
if (preg_match('~^\0data:(.+?/.+?);base64,~', $content, $m)) {
[2830] Fix | Delete
$dMime = $m[1];
[2831] Fix | Delete
if ($file['size'] > 0 && $dMime !== $file['mime']) {
[2832] Fix | Delete
return $this->setError(elFinder::ERROR_PERM_DENIED);
[2833] Fix | Delete
}
[2834] Fix | Delete
$content = base64_decode(substr($content, strlen($m[0])));
[2835] Fix | Delete
}
[2836] Fix | Delete
[2837] Fix | Delete
// check MIME
[2838] Fix | Delete
$name = $this->basenameCE($path);
[2839] Fix | Delete
$mime = '';
[2840] Fix | Delete
$mimeByName = $this->mimetype($name, true);
[2841] Fix | Delete
if ($this->mimeDetect !== 'internal') {
[2842] Fix | Delete
if ($tp = $this->tmpfile()) {
[2843] Fix | Delete
fwrite($tp, $content);
[2844] Fix | Delete
$info = stream_get_meta_data($tp);
[2845] Fix | Delete
$filepath = $info['uri'];
[2846] Fix | Delete
$mime = $this->mimetype($filepath, $name);
[2847] Fix | Delete
fclose($tp);
[2848] Fix | Delete
}
[2849] Fix | Delete
}
[2850] Fix | Delete
if (!$this->allowPutMime($mimeByName) || ($mime && !$this->allowPutMime($mime))) {
[2851] Fix | Delete
return $this->setError(elFinder::ERROR_UPLOAD_FILE_MIME);
[2852] Fix | Delete
}
[2853] Fix | Delete
[2854] Fix | Delete
$this->clearcache();
[2855] Fix | Delete
$res = false;
[2856] Fix | Delete
if ($this->convEncOut($this->_filePutContents($this->convEncIn($path), $content))) {
[2857] Fix | Delete
$this->rmTmb($file);
[2858] Fix | Delete
$this->clearstatcache();
[2859] Fix | Delete
$res = $this->stat($path);
[2860] Fix | Delete
}
[2861] Fix | Delete
return $res;
[2862] Fix | Delete
}
[2863] Fix | Delete
[2864] Fix | Delete
/**
[2865] Fix | Delete
* Extract files from archive
[2866] Fix | Delete
*
[2867] Fix | Delete
* @param string $hash archive hash
[2868] Fix | Delete
* @param null $makedir
[2869] Fix | Delete
*
[2870] Fix | Delete
* @return array|bool
[2871] Fix | Delete
* @author Dmitry (dio) Levashov,
[2872] Fix | Delete
* @author Alexey Sukhotin
[2873] Fix | Delete
*/
[2874] Fix | Delete
public function extract($hash, $makedir = null)
[2875] Fix | Delete
{
[2876] Fix | Delete
if ($this->commandDisabled('extract')) {
[2877] Fix | Delete
return $this->setError(elFinder::ERROR_PERM_DENIED);
[2878] Fix | Delete
}
[2879] Fix | Delete
[2880] Fix | Delete
if (($file = $this->file($hash)) == false) {
[2881] Fix | Delete
return $this->setError(elFinder::ERROR_FILE_NOT_FOUND);
[2882] Fix | Delete
}
[2883] Fix | Delete
[2884] Fix | Delete
$archiver = isset($this->archivers['extract'][$file['mime']])
[2885] Fix | Delete
? $this->archivers['extract'][$file['mime']]
[2886] Fix | Delete
: array();
[2887] Fix | Delete
[2888] Fix | Delete
if (!$archiver) {
[2889] Fix | Delete
return $this->setError(elFinder::ERROR_NOT_ARCHIVE);
[2890] Fix | Delete
}
[2891] Fix | Delete
[2892] Fix | Delete
$path = $this->decode($hash);
[2893] Fix | Delete
$parent = $this->stat($this->dirnameCE($path));
[2894] Fix | Delete
[2895] Fix | Delete
if (!$file['read'] || !$parent['write']) {
[2896] Fix | Delete
return $this->setError(elFinder::ERROR_PERM_DENIED);
[2897] Fix | Delete
}
[2898] Fix | Delete
$this->clearcache();
[2899] Fix | Delete
$this->extractToNewdir = is_null($makedir) ? 'auto' : (bool)$makedir;
[2900] Fix | Delete
[2901] Fix | Delete
if ($path = $this->convEncOut($this->_extract($this->convEncIn($path), $archiver))) {
[2902] Fix | Delete
if (is_array($path)) {
[2903] Fix | Delete
foreach ($path as $_k => $_p) {
[2904] Fix | Delete
$path[$_k] = $this->stat($_p);
[2905] Fix | Delete
}
[2906] Fix | Delete
} else {
[2907] Fix | Delete
$path = $this->stat($path);
[2908] Fix | Delete
}
[2909] Fix | Delete
return $path;
[2910] Fix | Delete
} else {
[2911] Fix | Delete
return false;
[2912] Fix | Delete
}
[2913] Fix | Delete
}
[2914] Fix | Delete
[2915] Fix | Delete
/**
[2916] Fix | Delete
* Add files to archive
[2917] Fix | Delete
*
[2918] Fix | Delete
* @param $hashes
[2919] Fix | Delete
* @param $mime
[2920] Fix | Delete
* @param string $name
[2921] Fix | Delete
*
[2922] Fix | Delete
* @return array|bool
[2923] Fix | Delete
* @throws Exception
[2924] Fix | Delete
*/
[2925] Fix | Delete
public function archive($hashes, $mime, $name = '')
[2926] Fix | Delete
{
[2927] Fix | Delete
if ($this->commandDisabled('archive')) {
[2928] Fix | Delete
return $this->setError(elFinder::ERROR_PERM_DENIED);
[2929] Fix | Delete
}
[2930] Fix | Delete
[2931] Fix | Delete
if ($name !== '' && !$this->nameAccepted($name, false)) {
[2932] Fix | Delete
return $this->setError(elFinder::ERROR_INVALID_NAME);
[2933] Fix | Delete
}
[2934] Fix | Delete
[2935] Fix | Delete
$archiver = isset($this->archivers['create'][$mime])
[2936] Fix | Delete
? $this->archivers['create'][$mime]
[2937] Fix | Delete
: array();
[2938] Fix | Delete
[2939] Fix | Delete
if (!$archiver) {
[2940] Fix | Delete
return $this->setError(elFinder::ERROR_ARCHIVE_TYPE);
[2941] Fix | Delete
}
[2942] Fix | Delete
[2943] Fix | Delete
$files = array();
[2944] Fix | Delete
$useRemoteArchive = !empty($this->options['useRemoteArchive']);
[2945] Fix | Delete
[2946] Fix | Delete
$dir = '';
[2947] Fix | Delete
foreach ($hashes as $hash) {
[2948] Fix | Delete
if (($file = $this->file($hash)) == false) {
[2949] Fix | Delete
return $this->setError(elFinder::ERROR_FILE_NOT_FOUND, '#' . $hash);
[2950] Fix | Delete
}
[2951] Fix | Delete
if (!$file['read']) {
[2952] Fix | Delete
return $this->setError(elFinder::ERROR_PERM_DENIED);
[2953] Fix | Delete
}
[2954] Fix | Delete
$path = $this->decode($hash);
[2955] Fix | Delete
if ($dir === '') {
[2956] Fix | Delete
$dir = $this->dirnameCE($path);
[2957] Fix | Delete
$stat = $this->stat($dir);
[2958] Fix | Delete
if (!$stat['write']) {
[2959] Fix | Delete
return $this->setError(elFinder::ERROR_PERM_DENIED);
[2960] Fix | Delete
}
[2961] Fix | Delete
}
[2962] Fix | Delete
[2963] Fix | Delete
$files[] = $useRemoteArchive ? $hash : $this->basenameCE($path);
[2964] Fix | Delete
}
[2965] Fix | Delete
[2966] Fix | Delete
if ($name === '') {
[2967] Fix | Delete
$name = count($files) == 1 ? $files[0] : 'Archive';
[2968] Fix | Delete
} else {
[2969] Fix | Delete
$name = str_replace(array('/', '\\'), '_', preg_replace('/\.' . preg_quote($archiver['ext'], '/') . '$/i', '', $name));
[2970] Fix | Delete
}
[2971] Fix | Delete
$name .= '.' . $archiver['ext'];
[2972] Fix | Delete
$name = $this->uniqueName($dir, $name, '');
[2973] Fix | Delete
$this->clearcache();
[2974] Fix | Delete
if ($useRemoteArchive) {
[2975] Fix | Delete
return ($path = $this->remoteArchive($files, $name, $archiver)) ? $this->stat($path) : false;
[2976] Fix | Delete
} else {
[2977] Fix | Delete
return ($path = $this->convEncOut($this->_archive($this->convEncIn($dir), $this->convEncIn($files), $this->convEncIn($name), $archiver))) ? $this->stat($path) : false;
[2978] Fix | Delete
}
[2979] Fix | Delete
}
[2980] Fix | Delete
[2981] Fix | Delete
/**
[2982] Fix | Delete
* Create an archive from remote items
[2983] Fix | Delete
*
[2984] Fix | Delete
* @param array $hashes files hashes list
[2985] Fix | Delete
* @param string $name archive name
[2986] Fix | Delete
* @param array $arc archiver options
[2987] Fix | Delete
*
[2988] Fix | Delete
* @return string|boolean path of created archive
[2989] Fix | Delete
* @throws Exception
[2990] Fix | Delete
*/
[2991] Fix | Delete
protected function remoteArchive($hashes, $name, $arc)
[2992] Fix | Delete
{
[2993] Fix | Delete
$resPath = false;
[2994] Fix | Delete
$file0 = $this->file($hashes[0]);
[2995] Fix | Delete
if ($file0 && ($dir = $this->getItemsInHand($hashes))) {
[2996] Fix | Delete
$files = self::localScandir($dir);
[2997] Fix | Delete
if ($files) {
[2998] Fix | Delete
if ($arc = $this->makeArchive($dir, $files, $name, $arc)) {
[2999] Fix | Delete
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function