1
|
<?php
|
2
|
/**
|
3
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
|
4
|
*
|
5
|
* This program is free software: you can redistribute it and/or modify
|
6
|
* it under the terms of the GNU General Public License as published by
|
7
|
* the Free Software Foundation, either version 3 of the License, or
|
8
|
* (at your option) any later version.
|
9
|
*
|
10
|
* This program is distributed in the hope that it will be useful,
|
11
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
12
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
13
|
* GNU General Public License for more details.
|
14
|
*
|
15
|
* You should have received a copy of the GNU General Public License
|
16
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
17
|
*
|
18
|
* @category modules
|
19
|
* @package droplets
|
20
|
* @subpackage restore_droplets
|
21
|
* @author Dietmar Wöllbrink
|
22
|
* @copyright WebsiteBaker Org. e.V.
|
23
|
* @link http://websitebaker.org/
|
24
|
* @license http://www.gnu.org/licenses/gpl.html
|
25
|
* @platform WebsiteBaker 2.8.4
|
26
|
* @requirements PHP 5.4 and higher
|
27
|
* @version $Id: restore_droplets.php 2 2017-07-02 15:14:29Z Manuela $
|
28
|
* @filesource $HeadURL: svn://isteam.dynxs.de/wb/2.10.x/trunk/modules/droplets/commands/restore_droplets.php $
|
29
|
* @lastmodified $Date: 2017-07-02 17:14:29 +0200 (Sun, 02 Jul 2017) $
|
30
|
*
|
31
|
*/
|
32
|
/* -------------------------------------------------------- */
|
33
|
// Must include code to stop this file being accessed directly
|
34
|
if(defined('WB_PATH') == false) { die('Cannot access '.basename(__DIR__).'/'.basename(__FILE__).' directly'); }
|
35
|
/* -------------------------------------------------------- */
|
36
|
|
37
|
$aUnzipDroplets = array();
|
38
|
/**
|
39
|
*
|
40
|
*/
|
41
|
if(!$oApp->checkFTAN() ) {
|
42
|
msgQueue::add($oTrans->MESSAGE_GENERIC_SECURITY_ACCESS);
|
43
|
} elseif(!isset($aRequestVars['restore_id']) || !is_array($aRequestVars['restore_id'])) {
|
44
|
msgQueue::add('::'.$oTrans->DROPLET_MESSAGE_MISSING_UNMARKED_ARCHIVE_FILES );
|
45
|
} else {
|
46
|
$aDroplet = array();
|
47
|
if( !class_exists('PclZip',false) ) { require( $oReg->AppPath.'/include/pclzip/pclzip.lib.php'); }
|
48
|
if(!function_exists('insertDropletFile')) { require($sAddonPath.'/droplets.functions.php'); }
|
49
|
// unzip to buffer and store in DB / fetch ach entry as single process, to surpress buffer overflow
|
50
|
foreach($aRequestVars['restore_id'] as $index => $iArchiveIndex ) {
|
51
|
$oArchive = new PclZip( $aRequestVars['ArchiveFile'] );
|
52
|
$sDroplet = $oArchive->extract(PCLZIP_OPT_BY_INDEX, $iArchiveIndex,
|
53
|
PCLZIP_OPT_EXTRACT_AS_STRING);
|
54
|
if ($sDroplet == 0) {
|
55
|
msgQueue::add( 'UNABLE TO UNZIP FILE'.'::'.$oArchive->errorInfo(true) );
|
56
|
} else {
|
57
|
// $sSearchFor = 'php';
|
58
|
// $file_types = preg_replace( '/\s*[,;\|#]\s*/','|',$sSearchFor );
|
59
|
// if (!preg_match('/^(to|cc|bcc|Reply-To)$/', $kind)) {
|
60
|
$aDroplet['name'] = $sDroplet[0]['filename'];
|
61
|
$aDroplet['content'] = explode("\n",$sDroplet[0]['content']);
|
62
|
// if ( !preg_match('/'.$file_types.'/si', $aDroplet['name'], $aMatch) ) {
|
63
|
// continue; }
|
64
|
if( $sTmp = insertDroplet($aDroplet, $oDb, $oApp, false)) {
|
65
|
$aUnzipDroplets[] = $sTmp;
|
66
|
}
|
67
|
}
|
68
|
}
|
69
|
//
|
70
|
if (($error = $oArchive->errorCode()) != 0 )
|
71
|
{
|
72
|
msgQueue::add( sizeof( $aUnzipDroplets ).' '. $oTrans->DROPLET_IMPORT_ARCHIV_IMPORTED);
|
73
|
} else {
|
74
|
if ( sizeof( $aUnzipDroplets ) > 0 ) {
|
75
|
msgQueue::add( implode(', ',$aUnzipDroplets).'<br />'.sizeof( $aUnzipDroplets ).' '. $oTrans->DROPLET_IMPORT_ARCHIV_IMPORTED, true);
|
76
|
} else {
|
77
|
msgQueue::add( sizeof( $aUnzipDroplets ).' '. $oTrans->DROPLET_IMPORT_ARCHIV_IMPORTED, true);
|
78
|
}
|
79
|
}
|
80
|
}
|