Code Duplication    Length = 3-5 lines in 4 locations

php/elFinderVolumeDriver.class.php 4 locations

@@ 674-676 (lines=3) @@
671
		}
672
673
		if (!$this->options['allowChmodReadOnly']) {
674
			if (!$this->attr($this->decode($hash), 'write', null, ($file['mime'] === 'directory'))) {
675
				return $this->setError(elFinder::ERROR_PERM_DENIED, $file['name']);
676
			}
677
		}
678
679
		$path = $this->decode($hash);
@@ 1541-1543 (lines=3) @@
1538
			return $this->setError(elFinder::ERROR_EXISTS, $name);
1539
		}
1540
		
1541
		if (!$this->allowCreate($dir, $name, ($file['mime'] === 'directory'))) {
1542
			return $this->setError(elFinder::ERROR_PERM_DENIED);
1543
		}
1544
1545
		$this->rmTmb($file); // remove old name tmbs, we cannot do this after dir move
1546
@@ 1576-1578 (lines=3) @@
1573
		$dir  = $this->dirnameCE($path);
1574
		$name = $this->uniqueName($dir, $this->basenameCE($path), ' '.$suffix.' ');
1575
1576
		if (!$this->allowCreate($dir, $name, ($file['mime'] === 'directory'))) {
1577
			return $this->setError(elFinder::ERROR_PERM_DENIED);
1578
		}
1579
1580
		return ($path = $this->copy($path, $dir, $name)) == false
1581
			? false
@@ 1641-1645 (lines=5) @@
1638
			// check POST data `overwrite` for 3rd party uploader
1639
			$overwrite = isset($_POST['overwrite'])? (bool)$_POST['overwrite'] : $this->options['uploadOverwrite'];
1640
			if ($overwrite) {
1641
				if (!$file['write']) {
1642
					return $this->setError(elFinder::ERROR_PERM_DENIED);
1643
				} elseif ($file['mime'] == 'directory') {
1644
					return $this->setError(elFinder::ERROR_NOT_REPLACE, $name);
1645
				} 
1646
				$this->remove($test);
1647
			} else {
1648
				$name = $this->uniqueName($dstpath, $name, '-', false);