-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
27 additions
and
73 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,7 +3,7 @@ | |
/** | ||
* | ||
* @package Mind | ||
* @version Release: 5.6.3 | ||
* @version Release: 5.6.4 | ||
* @license GPL3 | ||
* @author Ali YILMAZ <[email protected]> | ||
* @category Php Framework, Design pattern builder for PHP. | ||
|
@@ -4681,90 +4681,44 @@ public function upload($files, $path, $force=false){ | |
return $result; | ||
} | ||
|
||
/** | ||
* File downloader. | ||
/** | ||
* It helps to copy files or files | ||
* | ||
* @param mixed $links | ||
* @param array $opt | ||
* @param mixed $sources | ||
* @param mixed $destinations | ||
* @return array | ||
*/ | ||
public function download($links, $opt = array()) | ||
{ | ||
|
||
$result = array(); | ||
$nLinks = array(); | ||
|
||
if(empty($links)){ | ||
return $result; | ||
} | ||
|
||
if(!is_array($links)){ | ||
$links = array($links); | ||
} | ||
|
||
foreach($links as $link) { | ||
public function duplicate($sources, $destinations){ | ||
$result = []; | ||
|
||
if($this->is_url($link)){ | ||
if($this->remoteFileSize($link)>1){ | ||
$nLinks[] = $link; | ||
} | ||
} | ||
|
||
if(!$this->is_url($link)){ | ||
if(!strstr($link, '://')){ | ||
|
||
if(file_exists($link)){ | ||
$nLinks[] = $link; | ||
} | ||
|
||
} | ||
$destinations = (isset($destinations)) ? (!is_array($destinations) ? [$destinations] : $destinations) : null; | ||
if(!is_null($destinations)) { | ||
foreach ($destinations as $destination) { | ||
if(!is_dir($destination)){ mkdir($destination, 0777, true); } | ||
} | ||
|
||
} | ||
|
||
if(count($nLinks) != count($links)){ | ||
return $result; | ||
} | ||
|
||
$path = ''; | ||
if(!empty($opt['path'])){ | ||
$path .= $opt['path']; | ||
|
||
if(!is_dir($path)){ | ||
mkdir($path, 0777, true); | ||
} | ||
} else { | ||
$path .= './download'; | ||
} | ||
|
||
foreach ($nLinks as $nLink) { | ||
|
||
$destination = $path; | ||
|
||
$other_path = $this->permalink($this->info($nLink, 'filename')).'.'.$this->info($nLink, 'extension'); | ||
|
||
if(!is_dir($destination)){ | ||
mkdir($destination, 0777, true); | ||
} | ||
|
||
if(file_exists($destination.'/'.$other_path)){ | ||
|
||
$remote_file = $this->remoteFileSize($nLink); | ||
$local_file = filesize($destination.'/'.$other_path); | ||
|
||
if($remote_file != $local_file){ | ||
unlink($destination.'/'.$other_path); | ||
copy($nLink, $destination.'/'.$other_path); | ||
$sources = (isset($sources)) ? (!is_array($sources) ? [$sources] : $sources) : null; | ||
if(!is_null($sources)){ | ||
foreach ($sources as $source) { | ||
$new_file_name = $this->info($source, 'filename'); | ||
$new_file_extension = $this->info($source, 'extension'); | ||
$new_file = $this->permalink($new_file_name).'.'.$new_file_extension; | ||
|
||
if(!is_null($destinations)){ | ||
foreach ($destinations as $destination) { | ||
$new_file_path = $destination.'/'.$new_file; | ||
|
||
if(copy($source, $new_file_path)){ | ||
$result[] = $new_file_path; | ||
} | ||
} | ||
} | ||
} else { | ||
copy($nLink, $destination.'/'.$other_path); | ||
} | ||
|
||
$result[] = $destination.'/'.$other_path; | ||
} | ||
} | ||
|
||
return $result; | ||
|
||
} | ||
|
||
/** | ||
|