Dotclear

source: plugins/maintenance/inc/tasks/class.dc.maintenance.zipmedia.php @ 1989:b234959829da

Revision 1989:b234959829da, 1.3 KB checked in by Denis Jean-Chirstian <contact@…>, 12 years ago (diff)

Revamp plugin maintenance, step 5, now open to admin user and various fixes, addresses #999

Line 
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 -----------------------------------------
12if (!defined('DC_RC_PATH')) { return; }
13
14class dcMaintenanceZipmedia extends dcMaintenanceTask
15{
16     protected $perm = 'admin';
17     protected $blog = true;
18     protected $tab = 'backup';
19     protected $group = 'zipblog';
20
21     protected function init()
22     {
23          $this->task = __('Download media folder of current blog');
24     }
25
26     public function execute()
27     {
28          // Instance media
29          $this->core->media = new dcMedia($this->core);
30          $this->core->media->chdir(null);
31          $this->core->media->getDir();
32
33          // Create zip
34          @set_time_limit(300);
35          $fp = fopen('php://output', 'wb');
36          $zip = new fileZip($fp);
37          $zip->addExclusion('#(^|/).(.*?)_(m|s|sq|t).jpg$#');
38          $zip->addDirectory($this->core->media->root.'/', '', true);
39
40          // Log task execution here as we sent file and stop script
41          $this->log();
42
43          // Send zip
44          header('Content-Disposition: attachment;filename=media.zip');
45          header('Content-Type: application/x-zip');
46          $zip->write();
47          unset($zip);
48          exit(1);
49     }
50}
Note: See TracBrowser for help on using the repository browser.

Sites map