| [1955] | 1 | <?php | 
|---|
|  | 2 | # -- BEGIN LICENSE BLOCK --------------------------------------- | 
|---|
|  | 3 | # | 
|---|
|  | 4 | # This file is part of Dotclear 2. | 
|---|
|  | 5 | # | 
|---|
|  | 6 | # Copyright (c) 2003-2013 Olivier Meunier & Association Dotclear | 
|---|
|  | 7 | # Licensed under the GPL version 2.0 license. | 
|---|
|  | 8 | # See LICENSE file or | 
|---|
|  | 9 | # http://www.gnu.org/licenses/old-licenses/gpl-2.0.html | 
|---|
|  | 10 | # | 
|---|
|  | 11 | # -- END LICENSE BLOCK ----------------------------------------- | 
|---|
|  | 12 | if (!defined('DC_RC_PATH')) { return; } | 
|---|
|  | 13 |  | 
|---|
|  | 14 | class dcMaintenanceZipmedia extends dcMaintenanceTask | 
|---|
|  | 15 | { | 
|---|
| [1989] | 16 | protected $perm = 'admin'; | 
|---|
| [1984] | 17 | protected $blog = true; | 
|---|
| [1955] | 18 | protected $tab = 'backup'; | 
|---|
|  | 19 | protected $group = 'zipblog'; | 
|---|
|  | 20 |  | 
|---|
|  | 21 | protected function init() | 
|---|
|  | 22 | { | 
|---|
|  | 23 | $this->task = __('Download media folder of current blog'); | 
|---|
| [2044] | 24 |  | 
|---|
|  | 25 | $this->description = __('It may be useful to backup your media folder. This compress all content of media folder into a single zip file. Notice : with some hosters, the media folder cannot be compressed with this plugin if it is too big.'); | 
|---|
| [1955] | 26 | } | 
|---|
|  | 27 |  | 
|---|
|  | 28 | public function execute() | 
|---|
|  | 29 | { | 
|---|
|  | 30 | // Instance media | 
|---|
|  | 31 | $this->core->media = new dcMedia($this->core); | 
|---|
|  | 32 | $this->core->media->chdir(null); | 
|---|
|  | 33 | $this->core->media->getDir(); | 
|---|
|  | 34 |  | 
|---|
|  | 35 | // Create zip | 
|---|
|  | 36 | @set_time_limit(300); | 
|---|
|  | 37 | $fp = fopen('php://output', 'wb'); | 
|---|
|  | 38 | $zip = new fileZip($fp); | 
|---|
|  | 39 | $zip->addExclusion('#(^|/).(.*?)_(m|s|sq|t).jpg$#'); | 
|---|
|  | 40 | $zip->addDirectory($this->core->media->root.'/', '', true); | 
|---|
|  | 41 |  | 
|---|
|  | 42 | // Log task execution here as we sent file and stop script | 
|---|
|  | 43 | $this->log(); | 
|---|
|  | 44 |  | 
|---|
|  | 45 | // Send zip | 
|---|
| [3034] | 46 | header('Content-Disposition: attachment;filename='.date('Y-m-d').'-'.$this->core->blog->id.'-'.'media.zip'); | 
|---|
| [1955] | 47 | header('Content-Type: application/x-zip'); | 
|---|
|  | 48 | $zip->write(); | 
|---|
|  | 49 | unset($zip); | 
|---|
|  | 50 | exit(1); | 
|---|
|  | 51 | } | 
|---|
|  | 52 | } | 
|---|