mirror of
https://github.com/Chouchen/Shikiryu_Backup.git
synced 2021-06-30 16:02:14 +02:00
🎨 Apply PSR2
This commit is contained in:
parent
ab7887ce84
commit
db51375185
@ -125,7 +125,8 @@ class Email extends TransportAbstract
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public static function getMimeType($file) {
|
||||
public static function getMimeType($file)
|
||||
{
|
||||
if (function_exists('finfo_open')) {
|
||||
$finfo = finfo_open(FILEINFO_MIME_TYPE);
|
||||
$type = (string) finfo_file($finfo, $file);
|
||||
@ -135,17 +136,19 @@ class Email extends TransportAbstract
|
||||
return mime_content_type($file);
|
||||
} else {
|
||||
$ext = strtolower(array_pop(explode('.', $file)));
|
||||
if (array_key_exists($ext, self::$mimeTypes))
|
||||
if (array_key_exists($ext, self::$mimeTypes)) {
|
||||
return self::$mimeTypes[$ext];
|
||||
else
|
||||
} else {
|
||||
return 'application/octet-stream';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param BackupAbstract $backup
|
||||
*/
|
||||
public function __construct(BackupAbstract $backup, array $config) {
|
||||
public function __construct(BackupAbstract $backup, array $config)
|
||||
{
|
||||
parent::__construct($backup, $config);
|
||||
$this->setFiles($this->backup->getFilesTobackup());
|
||||
$this->setStreams($this->backup->getStreamsTobackup());
|
||||
@ -198,10 +201,9 @@ class Email extends TransportAbstract
|
||||
// Checking files are selected
|
||||
$zip = new \ZipArchive(); // Load zip library
|
||||
$zip_name = time().".zip"; // Zip name
|
||||
if ($zip->open(TEMP_DIR.$zip_name, \ZIPARCHIVE::CREATE)==TRUE) {
|
||||
if ($zip->open(TEMP_DIR.$zip_name, \ZIPARCHIVE::CREATE)==true) {
|
||||
if (!empty($this->files)) {
|
||||
foreach($this->files as $file => $name)
|
||||
{
|
||||
foreach ($this->files as $file => $name) {
|
||||
$zip->addFile($file, $name); // Adding files into zip
|
||||
}
|
||||
}
|
||||
@ -223,7 +225,7 @@ Content-Transfer-Encoding: 8bit
|
||||
|
||||
" . $this->message . "\r\n";
|
||||
|
||||
if(!empty($this->files))
|
||||
if (!empty($this->files)) {
|
||||
foreach ($this->files as $file => $name) {
|
||||
$output .= "
|
||||
--$random_hash
|
||||
@ -233,10 +235,13 @@ Content-Disposition: attachment; filename=" . $name . "
|
||||
|
||||
" . chunk_split(base64_encode(file_get_contents($file)));
|
||||
}
|
||||
}
|
||||
|
||||
if(!empty($this->streams))
|
||||
if (!empty($this->streams)) {
|
||||
foreach ($this->streams as $name => $stream) {
|
||||
if(count(explode('.',$name))<2) $name = 'backup'.$name.'.txt';
|
||||
if (count(explode('.', $name))<2) {
|
||||
$name = 'backup'.$name.'.txt';
|
||||
}
|
||||
$output .= "
|
||||
--$random_hash
|
||||
Content-Type: text/plain; name=" . $name . "
|
||||
@ -245,8 +250,8 @@ Content-Disposition: attachment; filename=" . $name . "
|
||||
|
||||
" . chunk_split(base64_encode($stream));
|
||||
}
|
||||
}
|
||||
$output.="--$random_hash--";
|
||||
return mail($this->email_to, $this->subject, $output, $headers);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -28,7 +28,7 @@ abstract class BackupAbstract
|
||||
*
|
||||
* @param array $config array of options and parameters
|
||||
*/
|
||||
function __construct($config = array())
|
||||
public function __construct($config = array())
|
||||
{
|
||||
|
||||
$this->options = !empty($config['options']) ? $config['options'] : [];
|
||||
@ -174,7 +174,7 @@ abstract class BackupAbstract
|
||||
if (touch(TEMP_DIR . $zip_name) === false) {
|
||||
throw new \Exception('Backup::Zip::Permission denied.');
|
||||
}
|
||||
if ($zip->open(TEMP_DIR . $zip_name, \ZipArchive::OVERWRITE) == TRUE) {
|
||||
if ($zip->open(TEMP_DIR . $zip_name, \ZipArchive::OVERWRITE) == true) {
|
||||
foreach ($this->files_to_backup as $file => $name) {
|
||||
$zip->addFile($file, $name); // Adding files into zip
|
||||
}
|
||||
@ -270,5 +270,4 @@ abstract class BackupAbstract
|
||||
throw new \Exception('name option is for zip only.');
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -64,4 +64,3 @@ class Files extends BackupAbstract
|
||||
// TODO: Implement build() method.
|
||||
}
|
||||
}
|
||||
?>
|
||||
|
Loading…
Reference in New Issue
Block a user