Code Duplication    Length = 3-5 lines in 4 locations

php/elFinderVolumeDriver.class.php 4 locations

@@ 694-696 (lines=3) @@
691
		}
692
693
		if (!$this->options['allowChmodReadOnly']) {
694
			if (!$this->attr($this->decode($hash), 'write', null, ($file['mime'] === 'directory'))) {
695
				return $this->setError(elFinder::ERROR_PERM_DENIED, $file['name']);
696
			}
697
		}
698
699
		$path = $this->decode($hash);
@@ 1589-1591 (lines=3) @@
1586
			return $this->setError(elFinder::ERROR_EXISTS, $name);
1587
		}
1588
		
1589
		if (!$this->allowCreate($dir, $name, ($file['mime'] === 'directory'))) {
1590
			return $this->setError(elFinder::ERROR_PERM_DENIED);
1591
		}
1592
1593
		$this->rmTmb($file); // remove old name tmbs, we cannot do this after dir move
1594
@@ 1624-1626 (lines=3) @@
1621
		$dir  = $this->dirnameCE($path);
1622
		$name = $this->uniqueName($dir, $this->basenameCE($path), ' '.$suffix.' ');
1623
1624
		if (!$this->allowCreate($dir, $name, ($file['mime'] === 'directory'))) {
1625
			return $this->setError(elFinder::ERROR_PERM_DENIED);
1626
		}
1627
1628
		return ($path = $this->copy($path, $dir, $name)) == false
1629
			? false
@@ 1689-1693 (lines=5) @@
1686
			// check POST data `overwrite` for 3rd party uploader
1687
			$overwrite = isset($_POST['overwrite'])? (bool)$_POST['overwrite'] : $this->options['uploadOverwrite'];
1688
			if ($overwrite) {
1689
				if (!$file['write']) {
1690
					return $this->setError(elFinder::ERROR_PERM_DENIED);
1691
				} elseif ($file['mime'] == 'directory') {
1692
					return $this->setError(elFinder::ERROR_NOT_REPLACE, $name);
1693
				} 
1694
				$this->remove($test);
1695
			} else {
1696
				$name = $this->uniqueName($dstpath, $name, '-', false);