1. PHP / Говнокод #18537

    +2

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    11. 11
    12. 12
    13. 13
    14. 14
    15. 15
    16. 16
    17. 17
    18. 18
    19. 19
    20. 20
    21. 21
    22. 22
    23. 23
    protected function ___install($filename) {
    
    		$basename = $this->pagefiles->cleanBasename($filename, true, false, true); 
    		$pathInfo = pathinfo($basename); 
    		$basename = basename($basename, ".$pathInfo[extension]"); 
    
    		$basenameNoExt = $basename; 
    		$basename .= ".$pathInfo[extension]"; 
    
    		// ensure filename is unique
    		$cnt = 0; 
    		while(file_exists($this->pagefiles->path() . $basename)) {
    			$cnt++;
    			$basename = "$basenameNoExt-$cnt.$pathInfo[extension]";
    		}
    
    		if(strpos($filename, ' ') !== false && strpos($filename, '://') !== false) $filename = str_replace(' ', '%20', trim($filename)); // per Pete
    		$destination = $this->pagefiles->path() . $basename; 
    		if(!@copy($filename, $destination)) throw new WireException("Unable to copy: $filename => $destination"); 
    		if($this->config->chmodFile) chmod($this->pagefiles->path() . $basename, octdec($this->config->chmodFile));
    		$this->changed('file');
    		parent::set('basename', $basename); 
    	}

    Запостил: WGH, 27 Июля 2015

    Комментарии (8) RSS

    Добавить комментарий