Created
November 1, 2018 12:45
-
-
Save Sekaiichi/aa10ed01d33a1a10f4f3c6ad64d278e3 to your computer and use it in GitHub Desktop.
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
<?php | |
/** | |
* Created by PhpStorm. | |
* User: Mkhusaynov | |
* Date: 10/26/2018 | |
* Time: 10:56 AM | |
*/ | |
namespace app\commands; | |
use yii\console\Controller; | |
class DeleteTempFilesController extends Controller | |
{ | |
public $allPath = [ | |
'\\\\du-dlr004\\f$\\ALL_F\\OSPanel\\domains\\smms8\\web\\uploads\\registration', | |
'\\\\du-dlr004\\f$\\ALL_F\\OSPanel\\domains\\smms8\\web\\uploads\\registration\\temp', | |
'\\\\du-dlr004\\f$\\ALL_F\\OSPanel\\domains\\smms8\\web\\uploads\\personal-area', | |
'\\\\du-dlr004\\f$\\ALL_F\\OSPanel\\domains\\smms8\\web\\uploads\\personal-area\\temp', | |
'\\\\du-dlr004\\f$\\ALL_F\\OSPanel\\domains\\smms8\\web\\uploads\\img\\thumb', | |
'\\\\du-dlr004\\f$\\ALL_F\\OSPanel\\domains\\smms8\\web\\uploads\\img\\original', | |
'\\\\du-dlr004\\f$\\ALL_F\\OSPanel\\domains\\smms8\\web\\uploads\\converter', | |
'\\\\du-dlr002\\f$\\OSPanel\\domains\\dealer5.tj\\web\\uploads\\registration', | |
'\\\\du-dlr002\\f$\\OSPanel\\domains\\dealer5.tj\\web\\uploads\\registration\\temporary', | |
'\\\\du-dlr002\\f$\\OSPanel\\domains\\dealer5.tj\\web\\uploads\\personal-area\\', | |
'\\\\du-dlr002\\f$\\OSPanel\\domains\\dealer5.tj\\web\\uploads\\personal-area\\temporary', | |
'\\\\du-dlr002\\f$\\OSPanel\\domains\\dealer5.tj\\web\\uploads\\archive', | |
]; | |
protected function delete($path){ | |
if (is_dir("$path")){ | |
$handle=opendir($path); | |
while (false!==($file = readdir($handle))) { | |
if(!is_dir($path.'/'.$file)){ | |
if ($file != "." && $file != "..") { | |
$Diff = (time() - filectime("$path/$file"))/60/60/24; | |
if ($Diff > 8) unlink("$path/$file"); | |
} | |
} | |
} | |
closedir($handle); | |
} | |
} | |
public function actionDeleteFiles(){ | |
foreach ($this->allPath as $path){ | |
$this->delete($path); | |
} | |
} | |
} | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment