Code Duplication    Length = 3-5 lines in 4 locations

php/elFinderVolumeDriver.class.php 4 locations

@@ 676-678 (lines=3) @@
673
		}
674
675
		if (!$this->options['allowChmodReadOnly']) {
676
			if (!$this->attr($this->decode($hash), 'write', null, ($file['mime'] === 'directory'))) {
677
				return $this->setError(elFinder::ERROR_PERM_DENIED, $file['name']);
678
			}
679
		}
680
681
		$path = $this->decode($hash);
@@ 1545-1547 (lines=3) @@
1542
			return $this->setError(elFinder::ERROR_EXISTS, $name);
1543
		}
1544
		
1545
		if (!$this->allowCreate($dir, $name, ($file['mime'] === 'directory'))) {
1546
			return $this->setError(elFinder::ERROR_PERM_DENIED);
1547
		}
1548
1549
		$this->rmTmb($file); // remove old name tmbs, we cannot do this after dir move
1550
@@ 1580-1582 (lines=3) @@
1577
		$dir  = $this->dirnameCE($path);
1578
		$name = $this->uniqueName($dir, $this->basenameCE($path), ' '.$suffix.' ');
1579
1580
		if (!$this->allowCreate($dir, $name, ($file['mime'] === 'directory'))) {
1581
			return $this->setError(elFinder::ERROR_PERM_DENIED);
1582
		}
1583
1584
		return ($path = $this->copy($path, $dir, $name)) == false
1585
			? false
@@ 1645-1649 (lines=5) @@
1642
			// check POST data `overwrite` for 3rd party uploader
1643
			$overwrite = isset($_POST['overwrite'])? (bool)$_POST['overwrite'] : $this->options['uploadOverwrite'];
1644
			if ($overwrite) {
1645
				if (!$file['write']) {
1646
					return $this->setError(elFinder::ERROR_PERM_DENIED);
1647
				} elseif ($file['mime'] == 'directory') {
1648
					return $this->setError(elFinder::ERROR_NOT_REPLACE, $name);
1649
				} 
1650
				$this->remove($test);
1651
			} else {
1652
				$name = $this->uniqueName($dstpath, $name, '-', false);