Version Description
Download this release
Release Info
Developer | wpdprx |
Plugin | BackUpWordPress |
Version | 0.1.2 |
Comparing to | |
See all releases |
Version 0.1.2
- Archive.php +1405 -0
- Archive/Predicate.php +57 -0
- Archive/Predicate/And.php +87 -0
- Archive/Predicate/Current.php +52 -0
- Archive/Predicate/Custom.php +88 -0
- Archive/Predicate/Duplicate.php +116 -0
- Archive/Predicate/Ereg.php +59 -0
- Archive/Predicate/Eregi.php +61 -0
- Archive/Predicate/Extension.php +71 -0
- Archive/Predicate/False.php +47 -0
- Archive/Predicate/Index.php +62 -0
- Archive/Predicate/MIME.php +75 -0
- Archive/Predicate/MaxDepth.php +63 -0
- Archive/Predicate/MinSize.php +59 -0
- Archive/Predicate/MinTime.php +63 -0
- Archive/Predicate/Not.php +55 -0
- Archive/Predicate/Or.php +85 -0
- Archive/Predicate/True.php +45 -0
- Archive/Reader.php +416 -0
- Archive/Reader/Ar.php +387 -0
- Archive/Reader/Archive.php +98 -0
- Archive/Reader/Bzip2.php +254 -0
- Archive/Reader/Cache.php +262 -0
- Archive/Reader/ChangeName.php +212 -0
- Archive/Reader/Concat.php +187 -0
- Archive/Reader/Directory.php +220 -0
- Archive/Reader/File.php +296 -0
- Archive/Reader/Filter.php +90 -0
- Archive/Reader/Gzip.php +276 -0
- Archive/Reader/Memory.php +227 -0
- Archive/Reader/MimeList.php +939 -0
- Archive/Reader/Multi.php +95 -0
- Archive/Reader/Relay.php +134 -0
- Archive/Reader/Select.php +63 -0
- Archive/Reader/Tar.php +355 -0
- Archive/Reader/Uncompress.php +312 -0
- Archive/Reader/Zip.php +493 -0
- Archive/Writer.php +119 -0
- Archive/Writer/AddBaseName.php +102 -0
- Archive/Writer/Ar.php +204 -0
- Archive/Writer/Archive.php +99 -0
- Archive/Writer/Bzip2.php +137 -0
- Archive/Writer/Files.php +250 -0
- Archive/Writer/Gzip.php +139 -0
- Archive/Writer/Mail.php +200 -0
- Archive/Writer/Memory.php +127 -0
- Archive/Writer/MemoryArchive.php +213 -0
- Archive/Writer/Multi.php +130 -0
- Archive/Writer/Output.php +93 -0
- Archive/Writer/Tar.php +230 -0
- Archive/Writer/UniqueAppender.php +143 -0
- Archive/Writer/Zip.php +260 -0
- PEAR.php +1112 -0
- Sajax.php +361 -0
- Type.php +398 -0
- backupwordpress.php +81 -0
- bigdump/bigdump.php +1030 -0
- bkpwp-classes/interface.php +49 -0
- bkpwp-classes/manage_backups.php +876 -0
- bkpwp-classes/options.php +449 -0
- bkpwp-classes/schedule.php +86 -0
- bkpwp-pages/bkpwp_footer.php +28 -0
- bkpwp-pages/bkpwp_help.php +209 -0
- bkpwp-pages/bkpwp_mail_footer.php +4 -0
- bkpwp-pages/bkpwp_manage_backups.php +365 -0
- bkpwp-pages/bkpwp_manage_presets.php +156 -0
- bkpwp-pages/bkpwp_options.php +220 -0
- bkpwp-pages/bkpwp_schedule.php +250 -0
- functions-interface.php +225 -0
- functions.php +307 -0
- images/disk.png +0 -0
- images/loading.gif +0 -0
- locale/de_DE.mo +0 -0
- locale/de_DE.po +1151 -0
- readme.txt +60 -0
- screenshot-1.png +0 -0
- screenshot-2.png +0 -0
- screenshot-3.png +0 -0
- screenshot-4.png +0 -0
- screenshot-5.png +0 -0
Archive.php
ADDED
@@ -0,0 +1,1405 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
|
3 |
+
|
4 |
+
/**
|
5 |
+
* Factory to access the most common File_Archive features
|
6 |
+
* It uses lazy include, so you dont have to include the files from
|
7 |
+
* File/Archive/* directories
|
8 |
+
*
|
9 |
+
* PHP versions 4 and 5
|
10 |
+
*
|
11 |
+
* This library is free software; you can redistribute it and/or
|
12 |
+
* modify it under the terms of the GNU Lesser General Public
|
13 |
+
* License as published by the Free Software Foundation; either
|
14 |
+
* version 2.1 of the License, or (at your option) any later version.
|
15 |
+
*
|
16 |
+
* This library is distributed in the hope that it will be useful,
|
17 |
+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
18 |
+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
19 |
+
* Lesser General Public License for more details.
|
20 |
+
*
|
21 |
+
* You should have received a copy of the GNU Lesser General Public
|
22 |
+
* License along with this library; if not, write to the Free Software
|
23 |
+
* Foundation, Inc., 59 Temple Place, Suite 330,Boston,MA 02111-1307 USA
|
24 |
+
*
|
25 |
+
* @category File Formats
|
26 |
+
* @package File_Archive
|
27 |
+
* @author Vincent Lascaux <vincentlascaux@php.net>
|
28 |
+
* @copyright 1997-2005 The PHP Group
|
29 |
+
* @license http://www.gnu.org/copyleft/lesser.html LGPL
|
30 |
+
* @version CVS: $Id: Archive.php,v 1.85 2005/08/16 08:48:59 vincentlascaux Exp $
|
31 |
+
* @link http://pear.php.net/package/File_Archive
|
32 |
+
*/
|
33 |
+
|
34 |
+
/**
|
35 |
+
* To have access to PEAR::isError and PEAR::raiseError
|
36 |
+
* We should probably use lazy include and remove this inclusion...
|
37 |
+
*/
|
38 |
+
if (!class_exists("pear")) {
|
39 |
+
require_once $GLOBALS['bkpwp_plugin_path']."PEAR.php";
|
40 |
+
}
|
41 |
+
|
42 |
+
function File_Archive_cleanCache($file, $group)
|
43 |
+
{
|
44 |
+
$file = split('_', $file);
|
45 |
+
if (count($file) != 3) {
|
46 |
+
return false; //not a File_Archive file, keep it
|
47 |
+
}
|
48 |
+
|
49 |
+
$name = $file[2];
|
50 |
+
$name = urldecode($name);
|
51 |
+
|
52 |
+
$group = $file[1];
|
53 |
+
|
54 |
+
//clean the cache only for files in File_Archive groups
|
55 |
+
return substr($group, 0, 11) == 'FileArchive' &&
|
56 |
+
!file_exists($name); //and only if the related file no longer exists
|
57 |
+
}
|
58 |
+
|
59 |
+
/**
|
60 |
+
* Factory to access the most common File_Archive features
|
61 |
+
* It uses lazy include, so you dont have to include the files from
|
62 |
+
* File/Archive/* directories
|
63 |
+
*/
|
64 |
+
class File_Archive
|
65 |
+
{
|
66 |
+
function& _option($name)
|
67 |
+
{
|
68 |
+
static $container = array(
|
69 |
+
'zipCompressionLevel' => 9,
|
70 |
+
'gzCompressionLevel' => 9,
|
71 |
+
'tmpDirectory' => '.',
|
72 |
+
'cache' => null,
|
73 |
+
'appendRemoveDuplicates' => false,
|
74 |
+
'blockSize' => 65536,
|
75 |
+
'cacheCondition' => false
|
76 |
+
);
|
77 |
+
return $container[$name];
|
78 |
+
}
|
79 |
+
/**
|
80 |
+
* Sets an option that will be used by default by all readers or writers
|
81 |
+
* Option names are case sensitive
|
82 |
+
* Currently, the following options are used:
|
83 |
+
*
|
84 |
+
* "cache"
|
85 |
+
* Instance of a Cache_Lite object used to cache some compressed
|
86 |
+
* data to speed up future compressions of files
|
87 |
+
* Default: null (no cache used)
|
88 |
+
*
|
89 |
+
* "zipCompressionLevel"
|
90 |
+
* Value between 0 and 9 specifying the default compression level used
|
91 |
+
* by Zip writers (0 no compression, 9 highest compression)
|
92 |
+
* Default: 9
|
93 |
+
*
|
94 |
+
* "gzCompressionLevel"
|
95 |
+
* Value between 0 and 9 specifying the default compression level used
|
96 |
+
* by Gz writers (0 no compression, 9 highest compression)
|
97 |
+
* Default: 9
|
98 |
+
*
|
99 |
+
* "tmpDirectory"
|
100 |
+
* Directory where the temporary files generated by File_Archive will
|
101 |
+
* be created
|
102 |
+
* Default: '.'
|
103 |
+
*
|
104 |
+
* "appendRemoveDuplicates"
|
105 |
+
* If set to true, the appender created will by default remove the
|
106 |
+
* file present in the archive when adding a new one. This will slow the
|
107 |
+
* appending of files to archives
|
108 |
+
* Default: false
|
109 |
+
*
|
110 |
+
* "blockSize"
|
111 |
+
* To transfer data from a reader to a writer, some chunks a read from the
|
112 |
+
* source and written to the writer. This parameter controls the size of the
|
113 |
+
* chunks
|
114 |
+
* Default: 64kB
|
115 |
+
*
|
116 |
+
* "cacheCondition"
|
117 |
+
* This parameter specifies when a cache should be used. When the cache is
|
118 |
+
* used, the data of the reader is saved in a temporary file for future access.
|
119 |
+
* The cached reader will be read only once, even if you read it several times.
|
120 |
+
* This can be usefull to read compressed files or downloaded files (from http or ftp)
|
121 |
+
* The possible values for this option are
|
122 |
+
* - false: never use cache
|
123 |
+
* - a regexp: A cache will be used if the specified URL matches the regexp
|
124 |
+
* preg_match is used
|
125 |
+
* Default: false
|
126 |
+
* Example: '/^(http|ftp):\/\//' will cache all files downloaded via http or ftp
|
127 |
+
*
|
128 |
+
*/
|
129 |
+
function setOption($name, $value)
|
130 |
+
{
|
131 |
+
$option =& File_Archive::_option($name);
|
132 |
+
$option = $value;
|
133 |
+
if ($name == 'cache' && $value !== null) {
|
134 |
+
//TODO: ask to Cache_Lite to allow that
|
135 |
+
$value->_fileNameProtection = false;
|
136 |
+
}
|
137 |
+
}
|
138 |
+
|
139 |
+
/**
|
140 |
+
* Retrieve the value of an option
|
141 |
+
*/
|
142 |
+
function getOption($name)
|
143 |
+
{
|
144 |
+
return File_Archive::_option($name);
|
145 |
+
}
|
146 |
+
|
147 |
+
/**
|
148 |
+
* Create a reader to read the URL $URL.
|
149 |
+
* If the URL is a directory, it will recursively read that directory.
|
150 |
+
* If $uncompressionLevel is not null, the archives (files with extension
|
151 |
+
* tar, zip, gz or tgz) will be considered as directories (up to a depth of
|
152 |
+
* $uncompressionLevel if $uncompressionLevel > 0). The reader will only
|
153 |
+
* read files with a directory depth of $directoryDepth. It reader will
|
154 |
+
* replace the given URL ($URL) with $symbolic in the public filenames
|
155 |
+
* The default symbolic name is the last filename in the URL (or '' for
|
156 |
+
* directories)
|
157 |
+
*
|
158 |
+
* Examples:
|
159 |
+
* Considere the following file system
|
160 |
+
* <pre>
|
161 |
+
* a.txt
|
162 |
+
* b.tar (archive that contains the following files)
|
163 |
+
* c.txt
|
164 |
+
* d.tgz (archive that contains the following files)
|
165 |
+
* e.txt
|
166 |
+
* dir1/
|
167 |
+
* f.txt
|
168 |
+
* dir2/
|
169 |
+
* g.txt
|
170 |
+
* dir3/
|
171 |
+
* h.tar (archive that contains the following files)
|
172 |
+
* i.txt
|
173 |
+
* </pre>
|
174 |
+
*
|
175 |
+
* read('.') will return a reader that gives access to following
|
176 |
+
* files (recursively read current dir):
|
177 |
+
* <pre>
|
178 |
+
* a.txt
|
179 |
+
* b.tar
|
180 |
+
* dir2/g.txt
|
181 |
+
* dir2/dir3/h.tar
|
182 |
+
* </pre>
|
183 |
+
*
|
184 |
+
* read('.', 'myBaseDir') will return the following reader:
|
185 |
+
* <pre>
|
186 |
+
* myBaseDir/a.txt
|
187 |
+
* myBaseDir/b.tar
|
188 |
+
* myBaseDir/dir2/g.txt
|
189 |
+
* myBaseDir/dir2/dir3/h.tar
|
190 |
+
* </pre>
|
191 |
+
*
|
192 |
+
* read('.', '', -1) will return the following reader (uncompress
|
193 |
+
* everything)
|
194 |
+
* <pre>
|
195 |
+
* a.txt
|
196 |
+
* b.tar/c.txt
|
197 |
+
* b.tar/d.tgz/e.txt
|
198 |
+
* b.tar/d.tgz/dir1/f.txt
|
199 |
+
* dir2/g.txt
|
200 |
+
* dir2/dir3/h.tar/i.txt
|
201 |
+
* </pre>
|
202 |
+
*
|
203 |
+
* read('.', '', 1) will uncompress only one level (so d.tgz will
|
204 |
+
* not be uncompressed):
|
205 |
+
* <pre>
|
206 |
+
* a.txt
|
207 |
+
* b.tar/c.txt
|
208 |
+
* b.tar/d.tgz
|
209 |
+
* dir2/g.txt
|
210 |
+
* dir2/dir3/h.tar/i.txt
|
211 |
+
* </pre>
|
212 |
+
*
|
213 |
+
* read('.', '', 0, 0) will not recurse into subdirectories
|
214 |
+
* <pre>
|
215 |
+
* a.txt
|
216 |
+
* b.tar
|
217 |
+
* </pre>
|
218 |
+
*
|
219 |
+
* read('.', '', 0, 1) will recurse only one level in
|
220 |
+
* subdirectories
|
221 |
+
* <pre>
|
222 |
+
* a.txt
|
223 |
+
* b.tar
|
224 |
+
* dir2/g.txt
|
225 |
+
* </pre>
|
226 |
+
*
|
227 |
+
* read('.', '', -1, 2) will uncompress everything and recurse in
|
228 |
+
* only 2 levels in subdirectories or archives
|
229 |
+
* <pre>
|
230 |
+
* a.txt
|
231 |
+
* b.tar/c.txt
|
232 |
+
* b.tar/d.tgz/e.txt
|
233 |
+
* dir2/g.txt
|
234 |
+
* </pre>
|
235 |
+
*
|
236 |
+
* The recursion level is determined by the real path, not the symbolic one.
|
237 |
+
* So read('.', 'myBaseDir', -1, 2) will result to the same files:
|
238 |
+
* <pre>
|
239 |
+
* myBaseDir/a.txt
|
240 |
+
* myBaseDir/b.tar/c.txt
|
241 |
+
* myBaseDir/b.tar/d.tgz/e.txt (accepted because the real depth is 2)
|
242 |
+
* myBaseDir/dir2/g.txt
|
243 |
+
* </pre>
|
244 |
+
*
|
245 |
+
* Use readSource to do the same thing, reading from a specified reader instead of
|
246 |
+
* reading from the system files
|
247 |
+
*
|
248 |
+
* To read a single file, you can do read('a.txt', 'public_name.txt')
|
249 |
+
* If no public name is provided, the default one is the name of the file
|
250 |
+
* read('dir2/g.txt') contains the single file named 'g.txt'
|
251 |
+
* read('b.tar/c.txt') contains the single file named 'c.txt'
|
252 |
+
*
|
253 |
+
* Note: This function uncompress files reading their extension
|
254 |
+
* The compressed files must have a tar, zip, gz or tgz extension
|
255 |
+
* Since it is impossible for some URLs to use is_dir or is_file, this
|
256 |
+
* function may not work with
|
257 |
+
* URLs containing folders which name ends with such an extension
|
258 |
+
*/
|
259 |
+
function readSource(&$source, $URL, $symbolic = null,
|
260 |
+
$uncompression = 0, $directoryDepth = -1)
|
261 |
+
{
|
262 |
+
return File_Archive::_readSource($source, $URL, $reachable, $baseDir,
|
263 |
+
$symbolic, $uncompression, $directoryDepth);
|
264 |
+
}
|
265 |
+
|
266 |
+
/**
|
267 |
+
* This function performs exactly as readSource, but with two additional parameters
|
268 |
+
* ($reachable and $baseDir) that will be set so that $reachable."/".$baseDir == $URL
|
269 |
+
* and $reachable can be reached (in case of error)
|
270 |
+
*
|
271 |
+
* @access private
|
272 |
+
*/
|
273 |
+
function _readSource(&$toConvert, $URL, &$reachable, &$baseDir, $symbolic = null,
|
274 |
+
$uncompression = 0, $directoryDepth = -1)
|
275 |
+
{
|
276 |
+
$source =& File_Archive::_convertToReader($toConvert);
|
277 |
+
if (PEAR::isError($source)) {
|
278 |
+
return $source;
|
279 |
+
}
|
280 |
+
if (is_array($URL)) {
|
281 |
+
$converted = array();
|
282 |
+
foreach($URL as $key => $foo) {
|
283 |
+
$converted[] =& File_Archive::_convertToReader($URL[$key]);
|
284 |
+
}
|
285 |
+
return File_Archive::readMulti($converted);
|
286 |
+
}
|
287 |
+
|
288 |
+
//No need to uncompress more than $directoryDepth
|
289 |
+
//That's not perfect, and some archives will still be uncompressed just
|
290 |
+
//to be filtered out :(
|
291 |
+
if ($directoryDepth >= 0) {
|
292 |
+
$uncompressionLevel = min($uncompression, $directoryDepth);
|
293 |
+
} else {
|
294 |
+
$uncompressionLevel = $uncompression;
|
295 |
+
}
|
296 |
+
|
297 |
+
require_once $GLOBALS['bkpwp_plugin_path'].'Archive/Reader.php';
|
298 |
+
$std = File_Archive_Reader::getStandardURL($URL);
|
299 |
+
|
300 |
+
//Modify the symbolic name if necessary
|
301 |
+
$slashPos = strrpos($std, '/');
|
302 |
+
if ($symbolic === null) {
|
303 |
+
if ($slashPos === false) {
|
304 |
+
$realSymbolic = $std;
|
305 |
+
} else {
|
306 |
+
$realSymbolic = substr($std, $slashPos+1);
|
307 |
+
}
|
308 |
+
} else {
|
309 |
+
$realSymbolic = $symbolic;
|
310 |
+
}
|
311 |
+
if ($slashPos !== false) {
|
312 |
+
$baseFile = substr($std, 0, $slashPos+1);
|
313 |
+
$lastFile = substr($std, $slashPos+1);
|
314 |
+
} else {
|
315 |
+
$baseFile = '';
|
316 |
+
$lastFile = $std;
|
317 |
+
}
|
318 |
+
|
319 |
+
if (strpos($lastFile, '*')!==false ||
|
320 |
+
strpos($lastFile, '?')!==false) {
|
321 |
+
//We have to build a regexp here
|
322 |
+
$regexp = str_replace(
|
323 |
+
array('\*', '\?'),
|
324 |
+
array('[^/]*', '[^/]'),
|
325 |
+
preg_quote($lastFile)
|
326 |
+
);
|
327 |
+
$result = File_Archive::_readSource($source, $baseFile,
|
328 |
+
$reachable, $baseDir, null, 0, -1);
|
329 |
+
return File_Archive::filter(
|
330 |
+
File_Archive::predEreg('^'.$regexp.'$'),
|
331 |
+
$result
|
332 |
+
);
|
333 |
+
}
|
334 |
+
|
335 |
+
//If the URL can be interpreted as a directory, and we are reading from the file system
|
336 |
+
if ((empty($URL) || is_dir($URL)) && $source === null) {
|
337 |
+
require_once "Archive/Reader/Directory.php";
|
338 |
+
require_once "Archive/Reader/ChangeName.php";
|
339 |
+
|
340 |
+
if ($uncompressionLevel != 0) {
|
341 |
+
require_once "Archive/Reader/Uncompress.php";
|
342 |
+
$result = new File_Archive_Reader_Uncompress(
|
343 |
+
new File_Archive_Reader_Directory($std, '', $directoryDepth),
|
344 |
+
$uncompressionLevel
|
345 |
+
);
|
346 |
+
} else {
|
347 |
+
$result = new File_Archive_Reader_Directory($std, '', $directoryDepth);
|
348 |
+
}
|
349 |
+
|
350 |
+
if ($directoryDepth >= 0) {
|
351 |
+
require_once $GLOBALS['bkpwp_plugin_path'].'Archive/Reader/Filter.php';
|
352 |
+
require_once $GLOBALS['bkpwp_plugin_path'].'Archive/Predicate/MaxDepth.php';
|
353 |
+
|
354 |
+
$tmp =& File_Archive::filter(
|
355 |
+
new File_Archive_Predicate_MaxDepth($directoryDepth),
|
356 |
+
$result
|
357 |
+
);
|
358 |
+
unset($result);
|
359 |
+
$result =& $tmp;
|
360 |
+
}
|
361 |
+
if (!empty($realSymbolic)) {
|
362 |
+
if ($symbolic === null) {
|
363 |
+
$realSymbolic = '';
|
364 |
+
}
|
365 |
+
$tmp =& new File_Archive_Reader_AddBaseName(
|
366 |
+
$realSymbolic,
|
367 |
+
$result
|
368 |
+
);
|
369 |
+
unset($result);
|
370 |
+
$result =& $tmp;
|
371 |
+
}
|
372 |
+
|
373 |
+
//If the URL can be interpreted as a file, and we are reading from the file system
|
374 |
+
} else if (is_file($URL) && substr($URL, -1)!='/' && $source === null) {
|
375 |
+
require_once "Archive/Reader/File.php";
|
376 |
+
$result = new File_Archive_Reader_File($URL, $realSymbolic);
|
377 |
+
|
378 |
+
//Else, we will have to build a complex reader
|
379 |
+
} else {
|
380 |
+
require_once "Archive/Reader/File.php";
|
381 |
+
|
382 |
+
$realPath = $std;
|
383 |
+
|
384 |
+
// Try to find a file with a known extension in the path (
|
385 |
+
// (to manage URLs like archive.tar/directory/file)
|
386 |
+
$pos = 0;
|
387 |
+
do {
|
388 |
+
if ($pos+1<strlen($realPath)) {
|
389 |
+
$pos = strpos($realPath, '/', $pos+1);
|
390 |
+
} else {
|
391 |
+
$pos = false;
|
392 |
+
}
|
393 |
+
if ($pos === false) {
|
394 |
+
$pos = strlen($realPath);
|
395 |
+
}
|
396 |
+
|
397 |
+
$file = substr($realPath, 0, $pos);
|
398 |
+
$baseDir = substr($realPath, $pos+1);
|
399 |
+
$dotPos = strrpos($file, '.');
|
400 |
+
$extension = '';
|
401 |
+
if ($dotPos !== false) {
|
402 |
+
$extension = substr($file, $dotPos+1);
|
403 |
+
}
|
404 |
+
} while ($pos < strlen($realPath) &&
|
405 |
+
(!File_Archive::isKnownExtension($extension) ||
|
406 |
+
(is_dir($file) && $source==null)));
|
407 |
+
|
408 |
+
$reachable = $file;
|
409 |
+
|
410 |
+
//If we are reading from the file system
|
411 |
+
if ($source === null) {
|
412 |
+
//Create a file reader
|
413 |
+
$result = new File_Archive_Reader_File($file);
|
414 |
+
} else {
|
415 |
+
//Select in the source the file $file
|
416 |
+
|
417 |
+
require_once "Archive/Reader/Select.php";
|
418 |
+
$result = new File_Archive_Reader_Select($file, $source);
|
419 |
+
}
|
420 |
+
|
421 |
+
require_once "Archive/Reader/Uncompress.php";
|
422 |
+
$tmp = new File_Archive_Reader_Uncompress($result, $uncompressionLevel);
|
423 |
+
unset($result);
|
424 |
+
$result = $tmp;
|
425 |
+
|
426 |
+
//Select the requested folder in the uncompress reader
|
427 |
+
$isDir = $result->setBaseDir($std);
|
428 |
+
if (PEAR::isError($isDir)) {
|
429 |
+
return $isDir;
|
430 |
+
}
|
431 |
+
if ($isDir && $symbolic==null) {
|
432 |
+
//Default symbolic name for directories is empty
|
433 |
+
$realSymbolic = '';
|
434 |
+
}
|
435 |
+
|
436 |
+
if ($directoryDepth >= 0) {
|
437 |
+
//Limit the maximum depth if necessary
|
438 |
+
require_once "Archive/Predicate/MaxDepth.php";
|
439 |
+
|
440 |
+
$tmp = new File_Archive_Reader_Filter(
|
441 |
+
new File_Archive_Predicate(
|
442 |
+
$directoryDepth +
|
443 |
+
substr_count(substr($std, $pos+1), '/')
|
444 |
+
),
|
445 |
+
$result
|
446 |
+
);
|
447 |
+
unset($result);
|
448 |
+
$result =& $tmp;
|
449 |
+
}
|
450 |
+
|
451 |
+
if ($std != $realSymbolic) {
|
452 |
+
require_once "Archive/Reader/ChangeName.php";
|
453 |
+
|
454 |
+
//Change the base name to the symbolic one if necessary
|
455 |
+
$tmp = new File_Archive_Reader_ChangeBaseName(
|
456 |
+
$std,
|
457 |
+
$realSymbolic,
|
458 |
+
$result
|
459 |
+
);
|
460 |
+
unset($result);
|
461 |
+
$result =& $tmp;
|
462 |
+
}
|
463 |
+
}
|
464 |
+
|
465 |
+
$cacheCondition = File_Archive::getOption('cacheCondition');
|
466 |
+
if ($cacheCondition !== false &&
|
467 |
+
preg_match($cacheCondition, $URL)) {
|
468 |
+
$tmp =& File_Archive::cache($result);
|
469 |
+
unset($result);
|
470 |
+
$result =& $tmp;
|
471 |
+
}
|
472 |
+
|
473 |
+
return $result;
|
474 |
+
}
|
475 |
+
function read($URL, $symbolic = null,
|
476 |
+
$uncompression = 0, $directoryDepth = -1)
|
477 |
+
{
|
478 |
+
$source = null;
|
479 |
+
return File_Archive::readSource($source, $URL, $symbolic, $uncompression, $directoryDepth);
|
480 |
+
}
|
481 |
+
|
482 |
+
/**
|
483 |
+
* Create a file reader on an uploaded file. The reader will read
|
484 |
+
* $_FILES[$name]['tmp_name'] and will have $_FILES[$name]['name']
|
485 |
+
* as a symbolic filename.
|
486 |
+
*
|
487 |
+
* A PEAR error is returned if one of the following happen
|
488 |
+
* - $_FILES[$name] is not set
|
489 |
+
* - $_FILES[$name]['error'] is not 0
|
490 |
+
* - is_uploaded_file returns false
|
491 |
+
*
|
492 |
+
* @param string $name Index of the file in the $_FILES array
|
493 |
+
* @return File_Archive_Reader File reader on the uploaded file
|
494 |
+
*/
|
495 |
+
function readUploadedFile($name)
|
496 |
+
{
|
497 |
+
if (!isset($_FILES[$name])) {
|
498 |
+
return PEAR::raiseError("File $name has not been uploaded");
|
499 |
+
}
|
500 |
+
switch ($_FILES[$name]['error']) {
|
501 |
+
case 0:
|
502 |
+
//No error
|
503 |
+
break;
|
504 |
+
case 1:
|
505 |
+
return PEAR::raiseError(
|
506 |
+
"The upload size limit didn't allow to upload file ".
|
507 |
+
$_FILES[$name]['name']
|
508 |
+
);
|
509 |
+
case 2:
|
510 |
+
return PEAR::raiseError(
|
511 |
+
"The form size limit didn't allow to upload file ".
|
512 |
+
$_FILES[$name]['name']
|
513 |
+
);
|
514 |
+
case 3:
|
515 |
+
return PEAR::raiseError(
|
516 |
+
"The file was not entirely uploaded"
|
517 |
+
);
|
518 |
+
case 4:
|
519 |
+
return PEAR::raiseError(
|
520 |
+
"The uploaded file is empty"
|
521 |
+
);
|
522 |
+
default:
|
523 |
+
return PEAR::raiseError(
|
524 |
+
"Unknown error ".$_FILES[$name]['error']." in file upload. ".
|
525 |
+
"Please, report a bug"
|
526 |
+
);
|
527 |
+
}
|
528 |
+
if (!is_uploaded_file($_FILES[$name]['tmp_name'])) {
|
529 |
+
return PEAR::raiseError("The file is not an uploaded file");
|
530 |
+
}
|
531 |
+
|
532 |
+
require_once "Archive/Reader/File.php";
|
533 |
+
return new File_Archive_Reader_File(
|
534 |
+
$_FILES[$name]['tmp_name'],
|
535 |
+
$_FILES[$name]['name'],
|
536 |
+
$_FILES[$name]['type']
|
537 |
+
);
|
538 |
+
}
|
539 |
+
|
540 |
+
/**
|
541 |
+
* Adds a cache layer above the specified reader
|
542 |
+
* The data of the reader is saved in a temporary file for future access.
|
543 |
+
* The cached reader will be read only once, even if you read it several times.
|
544 |
+
* This can be usefull to read compressed files or downloaded files (from http or ftp)
|
545 |
+
*
|
546 |
+
* @param mixed $toConvert The reader to cache
|
547 |
+
* It can be a File_Archive_Reader or a string, which will be converted using the
|
548 |
+
* read function
|
549 |
+
*/
|
550 |
+
function cache(&$toConvert)
|
551 |
+
{
|
552 |
+
$source =& File_Archive::_convertToReader($toConvert);
|
553 |
+
if (PEAR::isError($source)) {
|
554 |
+
return $source;
|
555 |
+
}
|
556 |
+
|
557 |
+
require_once $GLOBALS['bkpwp_plugin_path'].'Archive/Reader/Cache.php';
|
558 |
+
return new File_Archive_Reader_Cache($source);
|
559 |
+
}
|
560 |
+
|
561 |
+
/**
|
562 |
+
* Try to interpret the object as a reader
|
563 |
+
* Strings are converted to readers using File_Archive::read
|
564 |
+
* Arrays are converted to readers using File_Archive::readMulti
|
565 |
+
*
|
566 |
+
* @access private
|
567 |
+
*/
|
568 |
+
function &_convertToReader(&$source)
|
569 |
+
{
|
570 |
+
if (is_string($source)) {
|
571 |
+
$cacheCondition = File_Archive::getOption('cacheCondition');
|
572 |
+
if ($cacheCondition !== false &&
|
573 |
+
preg_match($cacheCondition, $source)) {
|
574 |
+
return File_Archive::cache(File_Archive::read($source));
|
575 |
+
} else {
|
576 |
+
return File_Archive::read($source);
|
577 |
+
}
|
578 |
+
} else if (is_array($source)) {
|
579 |
+
return File_Archive::readMulti($source);
|
580 |
+
} else {
|
581 |
+
return $source;
|
582 |
+
}
|
583 |
+
}
|
584 |
+
|
585 |
+
/**
|
586 |
+
* Try to interpret the object as a writer
|
587 |
+
* Strings are converted to writers using File_Archive::appender
|
588 |
+
* Arrays are converted to writers using a multi writer
|
589 |
+
*
|
590 |
+
* @access private
|
591 |
+
*/
|
592 |
+
function &_convertToWriter(&$dest)
|
593 |
+
{
|
594 |
+
if (is_string($dest)) {
|
595 |
+
return File_Archive::appender($dest);
|
596 |
+
} else if (is_array($dest)) {
|
597 |
+
require_once $GLOBALS['bkpwp_plugin_path'].'Archive/Writer/Multi.php';
|
598 |
+
$writer = new File_Archive_Writer_Multi();
|
599 |
+
foreach($dest as $key => $foo) {
|
600 |
+
$writer->addWriter($dest[$key]);
|
601 |
+
}
|
602 |
+
} else {
|
603 |
+
return $dest;
|
604 |
+
}
|
605 |
+
}
|
606 |
+
|
607 |
+
/**
|
608 |
+
* Check if a file with a specific extension can be read as an archive
|
609 |
+
* with File_Archive::read*
|
610 |
+
* This function is case sensitive.
|
611 |
+
*
|
612 |
+
* @param string $extension the checked extension
|
613 |
+
* @return bool whether this file can be understood reading its extension
|
614 |
+
* Currently, supported extensions are tar, zip, gz, tgz, tbz, bz2,
|
615 |
+
* bzip2, ar, deb
|
616 |
+
*/
|
617 |
+
function isKnownExtension($extension)
|
618 |
+
{
|
619 |
+
return $extension == 'tar' ||
|
620 |
+
$extension == 'zip' ||
|
621 |
+
$extension == 'gz' ||
|
622 |
+
$extension == 'tgz' ||
|
623 |
+
$extension == 'tbz' ||
|
624 |
+
$extension == 'bz2' ||
|
625 |
+
$extension == 'bzip2' ||
|
626 |
+
$extension == 'ar' ||
|
627 |
+
$extension == 'deb' /* ||
|
628 |
+
$extension == 'cab' ||
|
629 |
+
$extension == 'rar' */;
|
630 |
+
}
|
631 |
+
|
632 |
+
/**
|
633 |
+
* Create a reader that will read the single file source $source as
|
634 |
+
* a specific archive
|
635 |
+
*
|
636 |
+
* @param string $extension determines the kind of archive $source contains
|
637 |
+
* $extension is case sensitive
|
638 |
+
* @param File_Archive_Reader $source stores the archive
|
639 |
+
* @param bool $sourceOpened specifies if the archive is already opened
|
640 |
+
* if false, next will be called on source
|
641 |
+
* Closing the returned archive will close $source iif $sourceOpened
|
642 |
+
* is true
|
643 |
+
* @return A File_Archive_Reader that uncompresses the archive contained in
|
644 |
+
* $source interpreting it as a $extension archive
|
645 |
+
* If $extension is not handled return false
|
646 |
+
*/
|
647 |
+
function readArchive($extension, &$toConvert, $sourceOpened = false)
|
648 |
+
{
|
649 |
+
$source =& File_Archive::_convertToReader($toConvert);
|
650 |
+
if (PEAR::isError($source)) {
|
651 |
+
return $source;
|
652 |
+
}
|
653 |
+
|
654 |
+
switch($extension) {
|
655 |
+
case 'tgz':
|
656 |
+
return File_Archive::readArchive('tar',
|
657 |
+
File_Archive::readArchive('gz', $source, $sourceOpened)
|
658 |
+
);
|
659 |
+
case 'tbz':
|
660 |
+
return File_Archive::readArchive('tar',
|
661 |
+
File_Archive::readArchive('bz2', $source, $sourceOpened)
|
662 |
+
);
|
663 |
+
case 'tar':
|
664 |
+
require_once $GLOBALS['bkpwp_plugin_path'].'Archive/Reader/Tar.php';
|
665 |
+
return new File_Archive_Reader_Tar($source, $sourceOpened);
|
666 |
+
|
667 |
+
case 'gz':
|
668 |
+
case 'gzip':
|
669 |
+
require_once $GLOBALS['bkpwp_plugin_path'].'Archive/Reader/Gzip.php';
|
670 |
+
return new File_Archive_Reader_Gzip($source, $sourceOpened);
|
671 |
+
|
672 |
+
case 'zip':
|
673 |
+
require_once $GLOBALS['bkpwp_plugin_path'].'Archive/Reader/Zip.php';
|
674 |
+
return new File_Archive_Reader_Zip($source, $sourceOpened);
|
675 |
+
|
676 |
+
case 'bz2':
|
677 |
+
case 'bzip2':
|
678 |
+
require_once $GLOBALS['bkpwp_plugin_path'].'Archive/Reader/Bzip2.php';
|
679 |
+
return new File_Archive_Reader_Bzip2($source, $sourceOpened);
|
680 |
+
|
681 |
+
case 'deb':
|
682 |
+
case 'ar':
|
683 |
+
require_once $GLOBALS['bkpwp_plugin_path'].'Archive/Reader/Ar.php';
|
684 |
+
return new File_Archive_Reader_Ar($source, $sourceOpened);
|
685 |
+
|
686 |
+
/* case 'cab':
|
687 |
+
require_once $GLOBALS['bkpwp_plugin_path'].'Archive/Reader/Cab.php';
|
688 |
+
return new File_Archive_Reader_Cab($source, $sourceOpened);
|
689 |
+
|
690 |
+
|
691 |
+
case 'rar':
|
692 |
+
require_once "Archive/Reader/Rar.php";
|
693 |
+
return new File_Archive_Reader_Rar($source, $sourceOpened); */
|
694 |
+
|
695 |
+
default:
|
696 |
+
return false;
|
697 |
+
}
|
698 |
+
}
|
699 |
+
|
700 |
+
/**
|
701 |
+
* Contains only one file with data read from a memory buffer
|
702 |
+
*
|
703 |
+
* @param string $memory content of the file
|
704 |
+
* @param string $filename public name of the file
|
705 |
+
* @param array $stat statistics of the file. Index 7 (size) will be
|
706 |
+
* overwritten to match the size of $memory
|
707 |
+
* @param string $mime mime type of the file. Default will determine the
|
708 |
+
* mime type thanks to the extension of $filename
|
709 |
+
* @see File_Archive_Reader_Memory
|
710 |
+
*/
|
711 |
+
function readMemory($memory, $filename, $stat=array(), $mime=null)
|
712 |
+
{
|
713 |
+
require_once "Archive/Reader/Memory.php";
|
714 |
+
return new File_Archive_Reader_Memory($memory, $filename, $stat, $mime);
|
715 |
+
}
|
716 |
+
|
717 |
+
/**
|
718 |
+
* Contains several other sources. Take care the sources don't have several
|
719 |
+
* files with the same filename. The sources are given as a parameter, or
|
720 |
+
* can be added thanks to the reader addSource method
|
721 |
+
*
|
722 |
+
* @param array $sources Array of strings or readers that will be added to
|
723 |
+
* the multi reader. If the parameter is a string, a reader will be
|
724 |
+
* built thanks to the read function
|
725 |
+
* @see File_Archive_Reader_Multi, File_Archive::read()
|
726 |
+
*/
|
727 |
+
function readMulti($sources = array())
|
728 |
+
{
|
729 |
+
require_once "Archive/Reader/Multi.php";
|
730 |
+
$result = new File_Archive_Reader_Multi();
|
731 |
+
foreach ($sources as $index => $foo) {
|
732 |
+
$s =& File_Archive::_convertToReader($sources[$index]);
|
733 |
+
if (PEAR::isError($s)) {
|
734 |
+
return $s;
|
735 |
+
} else {
|
736 |
+
$result->addSource($s);
|
737 |
+
}
|
738 |
+
}
|
739 |
+
return $result;
|
740 |
+
}
|
741 |
+
/**
|
742 |
+
* Make the files of a source appear as one large file whose content is the
|
743 |
+
* concatenation of the content of all the files
|
744 |
+
*
|
745 |
+
* @param File_Archive_Reader $source The source whose files must be
|
746 |
+
* concatened
|
747 |
+
* @param string $filename name of the only file of the created reader
|
748 |
+
* @param array $stat statistics of the file. Index 7 (size) will be
|
749 |
+
* overwritten to match the total size of the files
|
750 |
+
* @param string $mime mime type of the file. Default will determine the
|
751 |
+
* mime type thanks to the extension of $filename
|
752 |
+
* @see File_Archive_Reader_Concat
|
753 |
+
*/
|
754 |
+
function readConcat(&$toConvert, $filename, $stat=array(), $mime=null)
|
755 |
+
{
|
756 |
+
$source =& File_Archive::_convertToReader($toConvert);
|
757 |
+
if (PEAR::isError($source)) {
|
758 |
+
return $source;
|
759 |
+
}
|
760 |
+
|
761 |
+
require_once "Archive/Reader/Concat.php";
|
762 |
+
return new File_Archive_Reader_Concat($source, $filename, $stat, $mime);
|
763 |
+
}
|
764 |
+
|
765 |
+
/**
|
766 |
+
* Removes from a source the files that do not follow a given predicat
|
767 |
+
*
|
768 |
+
* @param File_Archive_Predicate $predicate Only the files for which
|
769 |
+
* $predicate->isTrue() will be kept
|
770 |
+
* @param File_Archive_Reader $source Source that will be filtered
|
771 |
+
* @see File_Archive_Reader_Filter
|
772 |
+
*/
|
773 |
+
function filter($predicate, &$toConvert)
|
774 |
+
{
|
775 |
+
$source =& File_Archive::_convertToReader($toConvert);
|
776 |
+
if (PEAR::isError($source)) {
|
777 |
+
return $source;
|
778 |
+
}
|
779 |
+
|
780 |
+
require_once "Archive/Reader/Filter.php";
|
781 |
+
return new File_Archive_Reader_Filter($predicate, $source);
|
782 |
+
}
|
783 |
+
/**
|
784 |
+
* Predicate that always evaluate to true
|
785 |
+
*
|
786 |
+
* @see File_Archive_Predicate_True
|
787 |
+
*/
|
788 |
+
function predTrue()
|
789 |
+
{
|
790 |
+
require_once "Archive/Predicate/True.php";
|
791 |
+
return new File_Archive_Predicate_True();
|
792 |
+
}
|
793 |
+
/**
|
794 |
+
* Predicate that always evaluate to false
|
795 |
+
*
|
796 |
+
* @see File_Archive_Predicate_False
|
797 |
+
*/
|
798 |
+
function predFalse()
|
799 |
+
{
|
800 |
+
require_once "Archive/Predicate/False.php";
|
801 |
+
return new File_Archive_Predicate_False();
|
802 |
+
}
|
803 |
+
/**
|
804 |
+
* Predicate that evaluates to the logical AND of the parameters
|
805 |
+
* You can add other predicates thanks to the
|
806 |
+
* File_Archive_Predicate_And::addPredicate() function
|
807 |
+
*
|
808 |
+
* @param File_Archive_Predicate (any number of them)
|
809 |
+
* @see File_Archive_Predicate_And
|
810 |
+
*/
|
811 |
+
function predAnd()
|
812 |
+
{
|
813 |
+
require_once "Archive/Predicate/And.php";
|
814 |
+
$pred = new File_Archive_Predicate_And();
|
815 |
+
$args = func_get_args();
|
816 |
+
foreach ($args as $p) {
|
817 |
+
$pred->addPredicate($p);
|
818 |
+
}
|
819 |
+
return $pred;
|
820 |
+
}
|
821 |
+
/**
|
822 |
+
* Predicate that evaluates to the logical OR of the parameters
|
823 |
+
* You can add other predicates thanks to the
|
824 |
+
* File_Archive_Predicate_Or::addPredicate() function
|
825 |
+
*
|
826 |
+
* @param File_Archive_Predicate (any number of them)
|
827 |
+
* @see File_Archive_Predicate_Or
|
828 |
+
*/
|
829 |
+
function predOr()
|
830 |
+
{
|
831 |
+
require_once "Archive/Predicate/Or.php";
|
832 |
+
$pred = new File_Archive_Predicate_Or();
|
833 |
+
$args = func_get_args();
|
834 |
+
foreach ($args as $p) {
|
835 |
+
$pred->addPredicate($p);
|
836 |
+
}
|
837 |
+
return $pred;
|
838 |
+
}
|
839 |
+
/**
|
840 |
+
* Negate a predicate
|
841 |
+
*
|
842 |
+
* @param File_Archive_Predicate $pred Predicate to negate
|
843 |
+
* @see File_Archive_Predicate_Not
|
844 |
+
*/
|
845 |
+
function predNot($pred)
|
846 |
+
{
|
847 |
+
require_once "Archive/Predicate/Not.php";
|
848 |
+
return new File_Archive_Predicate_Not($pred);
|
849 |
+
}
|
850 |
+
/**
|
851 |
+
* Evaluates to true iif the file is larger than a given size
|
852 |
+
*
|
853 |
+
* @param int $size the minimal size of the files (in Bytes)
|
854 |
+
* @see File_Archive_Predicate_MinSize
|
855 |
+
*/
|
856 |
+
function predMinSize($size)
|
857 |
+
{
|
858 |
+
require_once "Archive/Predicate/MinSize.php";
|
859 |
+
return new File_Archive_Predicate_MinSize($size);
|
860 |
+
}
|
861 |
+
/**
|
862 |
+
* Evaluates to true iif the file has been modified after a given time
|
863 |
+
*
|
864 |
+
* @param int $time Unix timestamp of the minimal modification time of the
|
865 |
+
* files
|
866 |
+
* @see File_Archive_Predicate_MinTime
|
867 |
+
*/
|
868 |
+
function predMinTime($time)
|
869 |
+
{
|
870 |
+
require_once "Archive/Predicate/MinTime.php";
|
871 |
+
return new File_Archive_Predicate_MinTime($time);
|
872 |
+
}
|
873 |
+
/**
|
874 |
+
* Evaluates to true iif the file has less that a given number of
|
875 |
+
* directories in its path
|
876 |
+
*
|
877 |
+
* @param int $depth Maximal number of directories in path of the files
|
878 |
+
* @see File_Archive_Predicate_MaxDepth
|
879 |
+
*/
|
880 |
+
function predMaxDepth($depth)
|
881 |
+
{
|
882 |
+
require_once "Archive/Predicate/MaxDepth.php";
|
883 |
+
return new File_Archive_Predicate_MaxDepth($depth);
|
884 |
+
}
|
885 |
+
/**
|
886 |
+
* Evaluates to true iif the extension of the file is in a given list
|
887 |
+
*
|
888 |
+
* @param array or string $list List or comma separated string of possible
|
889 |
+
* extension of the files
|
890 |
+
* @see File_Archive_Predicate_Extension
|
891 |
+
*/
|
892 |
+
function predExtension($list)
|
893 |
+
{
|
894 |
+
require_once "Archive/Predicate/Extension.php";
|
895 |
+
return new File_Archive_Predicate_Extension($list);
|
896 |
+
}
|
897 |
+
/**
|
898 |
+
* Evaluates to true iif the MIME type of the file is in a given list
|
899 |
+
*
|
900 |
+
* @param array or string $list List or comma separated string of possible
|
901 |
+
* MIME types of the files. You may enter wildcards like "image/*" to
|
902 |
+
* select all the MIME in class image
|
903 |
+
* @see File_Archive_Predicate_MIME, MIME_Type::isWildcard()
|
904 |
+
*/
|
905 |
+
function predMIME($list)
|
906 |
+
{
|
907 |
+
require_once "Archive/Predicate/MIME.php";
|
908 |
+
return new File_Archive_Predicate_MIME($list);
|
909 |
+
}
|
910 |
+
/**
|
911 |
+
* Evaluates to true iif the name of the file follow a given regular
|
912 |
+
* expression
|
913 |
+
*
|
914 |
+
* @param string $ereg regular expression that the filename must follow
|
915 |
+
* @see File_Archive_Predicate_Ereg, ereg()
|
916 |
+
*/
|
917 |
+
function predEreg($ereg)
|
918 |
+
{
|
919 |
+
require_once "Archive/Predicate/Ereg.php";
|
920 |
+
return new File_Archive_Predicate_Ereg($ereg);
|
921 |
+
}
|
922 |
+
/**
|
923 |
+
* Evaluates to true iif the name of the file follow a given regular
|
924 |
+
* expression (case insensitive version)
|
925 |
+
*
|
926 |
+
* @param string $ereg regular expression that the filename must follow
|
927 |
+
* @see File_Archive_Predicate_Eregi, eregi
|
928 |
+
*/
|
929 |
+
function predEregi($ereg)
|
930 |
+
{
|
931 |
+
require_once "Archive/Predicate/Eregi.php";
|
932 |
+
return new File_Archive_Predicate_Eregi($ereg);
|
933 |
+
}
|
934 |
+
/**
|
935 |
+
* Evaluates to true only after a given number of evaluations
|
936 |
+
* This can be used to select files by index since the evaluation is done
|
937 |
+
* once per file
|
938 |
+
*
|
939 |
+
* @param array The indexes for which the returned predicate will return true
|
940 |
+
* are the keys of the array
|
941 |
+
* The predicate will return true if isset($indexes[$pos])
|
942 |
+
*/
|
943 |
+
function predIndex($indexes)
|
944 |
+
{
|
945 |
+
require_once "Archive/Predicate/Index.php";
|
946 |
+
return new File_Archive_Predicate_Index($indexes);
|
947 |
+
}
|
948 |
+
/**
|
949 |
+
* Custom predicate built by supplying a string expression
|
950 |
+
*
|
951 |
+
* Here are different ways to create a predicate that keeps only files
|
952 |
+
* with names shorter than 100 chars
|
953 |
+
* <sample>
|
954 |
+
* File_Archive::predCustom("return strlen($name)<100;")
|
955 |
+
* File_Archive::predCustom("strlen($name)<100;")
|
956 |
+
* File_Archive::predCustom("strlen($name)<100")
|
957 |
+
* File_Archive::predCustom("strlen($source->getFilename())<100")
|
958 |
+
* </sample>
|
959 |
+
*
|
960 |
+
* @param string $expression String containing an expression that evaluates
|
961 |
+
* to a boolean. If the expression doesn't contain a return
|
962 |
+
* statement, it will be added at the begining of the expression
|
963 |
+
* A ';' will be added at the end of the expression so that you don't
|
964 |
+
* have to write it. You may use the $name variable to refer to the
|
965 |
+
* current filename (with path...), $time for the modification time
|
966 |
+
* (unix timestamp), $size for the size of the file in bytes, $mime
|
967 |
+
* for the MIME type of the file
|
968 |
+
* @see File_Archive_Predicate_Custom
|
969 |
+
*/
|
970 |
+
function predCustom($expression)
|
971 |
+
{
|
972 |
+
require_once "Archive/Predicate/Custom.php";
|
973 |
+
return new File_Archive_Predicate_Custom($expression);
|
974 |
+
}
|
975 |
+
|
976 |
+
/**
|
977 |
+
* Send the files as a mail attachment
|
978 |
+
*
|
979 |
+
* @param Mail $mail Object used to send mail (see Mail::factory)
|
980 |
+
* @param array or String $to An array or a string with comma separated
|
981 |
+
* recipients
|
982 |
+
* @param array $headers The headers that will be passed to the Mail_mime
|
983 |
+
* object
|
984 |
+
* @param string $message Text body of the mail
|
985 |
+
* @see File_Archive_Writer_Mail
|
986 |
+
*/
|
987 |
+
function toMail($to, $headers, $message, $mail = null)
|
988 |
+
{
|
989 |
+
require_once "Archive/Writer/Mail.php";
|
990 |
+
return new File_Archive_Writer_Mail($to, $headers, $message, $mail);
|
991 |
+
}
|
992 |
+
/**
|
993 |
+
* Write the files on the hard drive
|
994 |
+
*
|
995 |
+
* @param string $baseDir if specified, the files will be created in that
|
996 |
+
* directory. If they don't exist, the directories will automatically
|
997 |
+
* be created
|
998 |
+
* @see File_Archive_Writer_Files
|
999 |
+
*/
|
1000 |
+
function toFiles($baseDir = "")
|
1001 |
+
{
|
1002 |
+
require_once "Archive/Writer/Files.php";
|
1003 |
+
return new File_Archive_Writer_Files($baseDir);
|
1004 |
+
}
|
1005 |
+
/**
|
1006 |
+
* Send the content of the files to a memory buffer
|
1007 |
+
*
|
1008 |
+
* toMemory returns a writer where the data will be written.
|
1009 |
+
* In this case, the data is accessible using the getData member
|
1010 |
+
*
|
1011 |
+
* toVariable returns a writer that will write into the given
|
1012 |
+
* variable
|
1013 |
+
*
|
1014 |
+
* @param out $data if specified, the data will be written to this buffer
|
1015 |
+
* Else, you can retrieve the buffer with the
|
1016 |
+
* File_Archive_Writer_Memory::getData() function
|
1017 |
+
* @see File_Archive_Writer_Memory
|
1018 |
+
*/
|
1019 |
+
function toMemory()
|
1020 |
+
{
|
1021 |
+
$v = '';
|
1022 |
+
return File_Archive::toVariable($v);
|
1023 |
+
}
|
1024 |
+
function toVariable(&$v)
|
1025 |
+
{
|
1026 |
+
require_once "Archive/Writer/Memory.php";
|
1027 |
+
return new File_Archive_Writer_Memory($v);
|
1028 |
+
}
|
1029 |
+
/**
|
1030 |
+
* Duplicate the writing operation on two writers
|
1031 |
+
*
|
1032 |
+
* @param File_Archive_Writer $a, $b writers where data will be duplicated
|
1033 |
+
* @see File_Archive_Writer_Multi
|
1034 |
+
*/
|
1035 |
+
function toMulti(&$aC, &$bC)
|
1036 |
+
{
|
1037 |
+
$a =& File_Archive::_convertToWriter($aC);
|
1038 |
+
$b =& File_Archive::_convertToWriter($bC);
|
1039 |
+
|
1040 |
+
if (PEAR::isError($a)) {
|
1041 |
+
return $a;
|
1042 |
+
}
|
1043 |
+
if (PEAR::isError($b)) {
|
1044 |
+
return $b;
|
1045 |
+
}
|
1046 |
+
|
1047 |
+
require_once "Archive/Writer/Multi.php";
|
1048 |
+
$writer = new File_Archive_Writer_Multi();
|
1049 |
+
$writer->addWriter($a);
|
1050 |
+
$writer->addWriter($b);
|
1051 |
+
return $writer;
|
1052 |
+
}
|
1053 |
+
/**
|
1054 |
+
* Send the content of the files to the standard output (so to the client
|
1055 |
+
* for a website)
|
1056 |
+
*
|
1057 |
+
* @param bool $sendHeaders If true some headers will be sent to force the
|
1058 |
+
* download of the file. Default value is true
|
1059 |
+
* @see File_Archive_Writer_Output
|
1060 |
+
*/
|
1061 |
+
function toOutput($sendHeaders = true)
|
1062 |
+
{
|
1063 |
+
require_once "Archive/Writer/Output.php";
|
1064 |
+
return new File_Archive_Writer_Output($sendHeaders);
|
1065 |
+
}
|
1066 |
+
/**
|
1067 |
+
* Compress the data to a tar, gz, tar/gz or zip format
|
1068 |
+
*
|
1069 |
+
* @param string $filename name of the archive file
|
1070 |
+
* @param File_Archive_Writer $innerWriter writer where the archive will be
|
1071 |
+
* written
|
1072 |
+
* @param string $type can be one of tgz, tbz, tar, zip, gz, gzip, bz2,
|
1073 |
+
* bzip2 (default is the extension of $filename) or any composition
|
1074 |
+
* of them (for example tar.gz or tar.bz2). The case of this
|
1075 |
+
* parameter is not important.
|
1076 |
+
* @param array $stat Statistics of the archive (see stat function)
|
1077 |
+
* @param bool $autoClose If set to true, $innerWriter will be closed when
|
1078 |
+
* the returned archive is close. Default value is true.
|
1079 |
+
*/
|
1080 |
+
function toArchive($filename, &$toConvert, $type = null,
|
1081 |
+
$stat = array(), $autoClose = true)
|
1082 |
+
{
|
1083 |
+
$innerWriter =& File_Archive::_convertToWriter($toConvert);
|
1084 |
+
if (PEAR::isError($innerWriter)) {
|
1085 |
+
return $innerWriter;
|
1086 |
+
}
|
1087 |
+
$shortcuts = array("tgz" , "tbz" );
|
1088 |
+
$reals = array("tar.gz", "tar.bz2");
|
1089 |
+
|
1090 |
+
if ($type === null) {
|
1091 |
+
$extensions = strtolower($filename);
|
1092 |
+
} else {
|
1093 |
+
$extensions = strtolower($type);
|
1094 |
+
}
|
1095 |
+
$extensions = explode('.', str_replace($shortcuts, $reals, $extensions));
|
1096 |
+
if ($innerWriter !== null) {
|
1097 |
+
$writer =& $innerWriter;
|
1098 |
+
} else {
|
1099 |
+
$writer = File_Archive::toFiles();
|
1100 |
+
}
|
1101 |
+
$nbCompressions = 0;
|
1102 |
+
$currentFilename = $filename;
|
1103 |
+
while (($extension = array_pop($extensions)) !== null) {
|
1104 |
+
unset($next);
|
1105 |
+
switch($extension) {
|
1106 |
+
case "tar":
|
1107 |
+
require_once "Archive/Writer/Tar.php";
|
1108 |
+
$next = new File_Archive_Writer_Tar(
|
1109 |
+
$currentFilename, $writer, $stat, $autoClose
|
1110 |
+
);
|
1111 |
+
unset($writer); $writer =& $next;
|
1112 |
+
break;
|
1113 |
+
case "zip":
|
1114 |
+
require_once "Archive/Writer/Zip.php";
|
1115 |
+
$next = new File_Archive_Writer_Zip(
|
1116 |
+
$currentFilename, $writer, $stat, $autoClose
|
1117 |
+
);
|
1118 |
+
unset($writer); $writer =& $next;
|
1119 |
+
break;
|
1120 |
+
case "gz":
|
1121 |
+
case "gzip":
|
1122 |
+
require_once "Archive/Writer/Gzip.php";
|
1123 |
+
$next = new File_Archive_Writer_Gzip(
|
1124 |
+
$currentFilename, $writer, $stat, $autoClose
|
1125 |
+
);
|
1126 |
+
unset($writer); $writer =& $next;
|
1127 |
+
break;
|
1128 |
+
case "bz2":
|
1129 |
+
case "bzip2":
|
1130 |
+
require_once "Archive/Writer/Bzip2.php";
|
1131 |
+
$next = new File_Archive_Writer_Bzip2(
|
1132 |
+
$currentFilename, $writer, $stat, $autoClose
|
1133 |
+
);
|
1134 |
+
unset($writer); $writer =& $next;
|
1135 |
+
break;
|
1136 |
+
case "deb":
|
1137 |
+
case "ar":
|
1138 |
+
require_once "Archive/Writer/Ar.php";
|
1139 |
+
$next = new File_Archive_Writer_Ar(
|
1140 |
+
$currentFilename, $writer, $stat, $autoClose
|
1141 |
+
);
|
1142 |
+
unset($writer); $writer =& $next;
|
1143 |
+
break;
|
1144 |
+
default:
|
1145 |
+
if ($type !== null || $nbCompressions == 0) {
|
1146 |
+
return PEAR::raiseError("Archive $extension unknown");
|
1147 |
+
}
|
1148 |
+
break;
|
1149 |
+
}
|
1150 |
+
$nbCompressions ++;
|
1151 |
+
$autoClose = true;
|
1152 |
+
$currentFilename = implode(".", $extensions);
|
1153 |
+
}
|
1154 |
+
return $writer;
|
1155 |
+
}
|
1156 |
+
|
1157 |
+
|
1158 |
+
/**
|
1159 |
+
* File_Archive::extract($source, $dest) is equivalent to $source->extract($dest)
|
1160 |
+
* If $source is a PEAR error, the error will be returned
|
1161 |
+
* It is thus easier to use this function than $source->extract, since it reduces the number of
|
1162 |
+
* error checking and doesn't force you to define a variable $source
|
1163 |
+
*
|
1164 |
+
* You may use strings as source and dest. In that case the source is automatically
|
1165 |
+
* converted to a reader using File_Archive::read and the dest is converted to a
|
1166 |
+
* writer using File_Archive::appender
|
1167 |
+
* Since PHP doesn't allow to pass literal strings by ref, you will have to use temporary
|
1168 |
+
* variables.
|
1169 |
+
* File_Archive::extract($src = 'archive.zip/', $dest = 'dir') will extract the archive to 'dir'
|
1170 |
+
* It is the same as
|
1171 |
+
* File_Archive::extract(
|
1172 |
+
* File_Archive::read('archive.zip/'),
|
1173 |
+
* File_Archive::appender('dir')
|
1174 |
+
* );
|
1175 |
+
* You may use any variable in the extract function ($from/$to, $a/$b...).
|
1176 |
+
*
|
1177 |
+
* @param File_Archive_Reader $source The source that will be read
|
1178 |
+
* @param File_Archive_Writer $dest Where to copy $source files
|
1179 |
+
* @param bool $autoClose if true (default), $dest will be closed after the extraction
|
1180 |
+
* @param int $bufferSize Size of the buffer to use to move data from the reader to the buffer
|
1181 |
+
* If $bufferSize <= 0 (default), the blockSize option is used
|
1182 |
+
* You shouldn't need to change that
|
1183 |
+
* @return null or a PEAR error if an error occured
|
1184 |
+
*/
|
1185 |
+
function extract(&$sourceToConvert, &$destToConvert, $autoClose = true, $bufferSize = 0)
|
1186 |
+
{
|
1187 |
+
$source =& File_Archive::_convertToReader($sourceToConvert);
|
1188 |
+
if (PEAR::isError($source)) {
|
1189 |
+
return $source;
|
1190 |
+
}
|
1191 |
+
$dest =& File_Archive::_convertToWriter($destToConvert);
|
1192 |
+
return $source->extract($dest, $autoClose, $bufferSize);
|
1193 |
+
}
|
1194 |
+
|
1195 |
+
/**
|
1196 |
+
* Create a writer that can be used to append files to an archive inside a source
|
1197 |
+
* If the archive can't be found in the source, it will be created
|
1198 |
+
* If source is set to null, File_Archive::toFiles will be assumed
|
1199 |
+
* If type is set to null, the type of the archive will be determined looking at
|
1200 |
+
* the extension in the URL
|
1201 |
+
* stat is the array of stat (returned by stat() PHP function of Reader getStat())
|
1202 |
+
* to use if the archive must be created
|
1203 |
+
*
|
1204 |
+
* This function allows to create or append data to nested archives. Only one
|
1205 |
+
* archive will be created and if your creation requires creating several nested
|
1206 |
+
* archives, a PEAR error will be returned
|
1207 |
+
*
|
1208 |
+
* After this call, $source will be closed and should not be used until the
|
1209 |
+
* returned writer is closed.
|
1210 |
+
*
|
1211 |
+
* @param File_Archive_Reader $source A reader where some files will be appended
|
1212 |
+
* @param string $URL URL to reach the archive in the source.
|
1213 |
+
* if $URL is null, a writer to append files to the $source reader will
|
1214 |
+
* be returned
|
1215 |
+
* @param bool $unique If true, the duplicate files will be deleted on close
|
1216 |
+
* Default is false (and setting it to true may have some performance
|
1217 |
+
* consequences)
|
1218 |
+
* @param string $type Extension of the archive (or null to use the one in the URL)
|
1219 |
+
* @param array $stat Used only if archive is created, array of stat as returned
|
1220 |
+
* by PHP stat function or Reader getStat function: stats of the archive)
|
1221 |
+
* Time (index 9) will be overwritten to current time
|
1222 |
+
* @return File_Archive_Writer a writer that you can use to append files to the reader
|
1223 |
+
*/
|
1224 |
+
function appenderFromSource(&$toConvert, $URL = null, $unique = null,
|
1225 |
+
$type = null, $stat = array())
|
1226 |
+
{
|
1227 |
+
$source =& File_Archive::_convertToReader($toConvert);
|
1228 |
+
if (PEAR::isError($source)) {
|
1229 |
+
return $source;
|
1230 |
+
}
|
1231 |
+
if ($unique == null) {
|
1232 |
+
$unique = File_Archive::getOption("appendRemoveDuplicates");
|
1233 |
+
}
|
1234 |
+
|
1235 |
+
//Do not report the fact that the archive does not exist as an error
|
1236 |
+
PEAR::pushErrorHandling(PEAR_ERROR_RETURN);
|
1237 |
+
|
1238 |
+
if ($URL === null) {
|
1239 |
+
$result =& $source;
|
1240 |
+
} else {
|
1241 |
+
if ($type === null) {
|
1242 |
+
$result = File_Archive::_readSource($source, $URL.'/', $reachable, $baseDir);
|
1243 |
+
} else {
|
1244 |
+
$result = File_Archive::readArchive(
|
1245 |
+
$type,
|
1246 |
+
File_Archive::_readSource($source, $URL, $reachable, $baseDir)
|
1247 |
+
);
|
1248 |
+
}
|
1249 |
+
}
|
1250 |
+
|
1251 |
+
PEAR::popErrorHandling();
|
1252 |
+
|
1253 |
+
if (!PEAR::isError($result)) {
|
1254 |
+
if ($unique) {
|
1255 |
+
require_once "Archive/Writer/UniqueAppender.php";
|
1256 |
+
return new File_Archive_Writer_UniqueAppender($result);
|
1257 |
+
} else {
|
1258 |
+
return $result->makeAppendWriter();
|
1259 |
+
}
|
1260 |
+
}
|
1261 |
+
|
1262 |
+
//The source can't be found and has to be created
|
1263 |
+
$stat[9] = $stat['mtime'] = time();
|
1264 |
+
|
1265 |
+
if (empty($baseDir)) {
|
1266 |
+
if ($source !== null) {
|
1267 |
+
$writer =& $source->makeWriter();
|
1268 |
+
} else {
|
1269 |
+
$writer =& File_Archive::toFiles();
|
1270 |
+
}
|
1271 |
+
if (PEAR::isError($writer)) {
|
1272 |
+
return $writer;
|
1273 |
+
}
|
1274 |
+
|
1275 |
+
PEAR::pushErrorHandling(PEAR_ERROR_RETURN);
|
1276 |
+
$result = File_Archive::toArchive($reachable, $writer, $type);
|
1277 |
+
PEAR::popErrorHandling();
|
1278 |
+
|
1279 |
+
if (PEAR::isError($result)) {
|
1280 |
+
$result = File_Archive::toFiles($reachable);
|
1281 |
+
}
|
1282 |
+
} else {
|
1283 |
+
$reachedSource = File_Archive::readSource($source, $reachable);
|
1284 |
+
if (PEAR::isError($reachedSource)) {
|
1285 |
+
return $reachedSource;
|
1286 |
+
}
|
1287 |
+
$writer = $reachedSource->makeWriter();
|
1288 |
+
if (PEAR::isError($writer)) {
|
1289 |
+
return $writer;
|
1290 |
+
}
|
1291 |
+
|
1292 |
+
PEAR::pushErrorHandling(PEAR_ERROR_RETURN);
|
1293 |
+
$result = File_Archive::toArchive($baseDir, $writer, $type);
|
1294 |
+
PEAR::popErrorHandling();
|
1295 |
+
|
1296 |
+
if (PEAR::isError($result)) {
|
1297 |
+
require_once "Archive/Writer/AddBaseName.php";
|
1298 |
+
$result = new File_Archive_Writer_AddBaseName(
|
1299 |
+
$baseDir, $writer);
|
1300 |
+
if (PEAR::isError($result)) {
|
1301 |
+
return $result;
|
1302 |
+
}
|
1303 |
+
}
|
1304 |
+
}
|
1305 |
+
return $result;
|
1306 |
+
}
|
1307 |
+
|
1308 |
+
/**
|
1309 |
+
* Create a writer that allows appending new files to an existing archive
|
1310 |
+
* This function actes as appendToSource with source being the system files
|
1311 |
+
* $URL can't be null here
|
1312 |
+
*
|
1313 |
+
* @param File_Archive_Reader $source A reader where some files will be appended
|
1314 |
+
* @return File_Archive_Writer a writer that you can use to append files to the reader
|
1315 |
+
*/
|
1316 |
+
function appender($URL, $unique = null, $type = null, $stat = array())
|
1317 |
+
{
|
1318 |
+
$source = null;
|
1319 |
+
return File_Archive::appenderFromSource($source, $URL, $unique, $type, $stat);
|
1320 |
+
}
|
1321 |
+
|
1322 |
+
/**
|
1323 |
+
* Remove the files that follow a given predicate from the source
|
1324 |
+
* If URL is null, the files will be removed from the source directly
|
1325 |
+
* Else, URL must link to a source from which the files will be removed
|
1326 |
+
*
|
1327 |
+
* @param File_Archive_Predicate $pred The files that follow the predicate
|
1328 |
+
* (for which $pred->isTrue($source) is true) will be erased
|
1329 |
+
* @param File_Archive_Reader $source A reader that contains the files to remove
|
1330 |
+
*/
|
1331 |
+
function removeFromSource(&$pred, &$toConvert, $URL = null)
|
1332 |
+
{
|
1333 |
+
$source =& File_Archive::_convertToReader($toConvert);
|
1334 |
+
if (PEAR::isError($source)) {
|
1335 |
+
return $source;
|
1336 |
+
}
|
1337 |
+
if ($URL === null) {
|
1338 |
+
$result = &$source;
|
1339 |
+
} else {
|
1340 |
+
if (substr($URL, -1) !== '/') {
|
1341 |
+
$URL .= '/';
|
1342 |
+
}
|
1343 |
+
$result = File_Archive::readSource($source, $URL);
|
1344 |
+
}
|
1345 |
+
|
1346 |
+
$writer = $result->makeWriterRemoveFiles($pred);
|
1347 |
+
if (PEAR::isError($writer)) {
|
1348 |
+
return $writer;
|
1349 |
+
}
|
1350 |
+
$writer->close();
|
1351 |
+
}
|
1352 |
+
|
1353 |
+
/**
|
1354 |
+
* Remove the files that follow a given predicate from the archive specified
|
1355 |
+
* in $URL
|
1356 |
+
*
|
1357 |
+
* @param $URL URL of the archive where some files must be removed
|
1358 |
+
*/
|
1359 |
+
function remove($pred, $URL)
|
1360 |
+
{
|
1361 |
+
$source = null;
|
1362 |
+
return File_Archive::removeFromSource($pred, $source, $URL);
|
1363 |
+
}
|
1364 |
+
|
1365 |
+
/**
|
1366 |
+
* Remove duplicates from a source, keeping the most recent one (or the one that has highest pos in
|
1367 |
+
* the archive if the files have same date or no date specified)
|
1368 |
+
*
|
1369 |
+
* @param File_Archive_Reader a reader that may contain duplicates
|
1370 |
+
*/
|
1371 |
+
function removeDuplicatesFromSource(&$toConvert, $URL = null)
|
1372 |
+
{
|
1373 |
+
$source =& File_Archive::_convertToReader($toConvert);
|
1374 |
+
if (PEAR::isError($source)) {
|
1375 |
+
return $source;
|
1376 |
+
}
|
1377 |
+
if ($URL !== null && substr($URL, -1) != '/') {
|
1378 |
+
$URL .= '/';
|
1379 |
+
}
|
1380 |
+
|
1381 |
+
if ($source === null) {
|
1382 |
+
$source = File_Archive::read($URL);
|
1383 |
+
}
|
1384 |
+
|
1385 |
+
require_once "Archive/Predicate/Duplicate.php";
|
1386 |
+
$pred = new File_Archive_Predicate_Duplicate($source);
|
1387 |
+
$source->close();
|
1388 |
+
return File_Archive::removeFromSource(
|
1389 |
+
$pred,
|
1390 |
+
$source,
|
1391 |
+
null
|
1392 |
+
);
|
1393 |
+
}
|
1394 |
+
|
1395 |
+
/**
|
1396 |
+
* Remove duplicates from the archive specified in the URL
|
1397 |
+
*/
|
1398 |
+
function removeDuplicates($URL)
|
1399 |
+
{
|
1400 |
+
$source = null;
|
1401 |
+
return File_Archive::removeDuplicatesFromSource($source, $URL);
|
1402 |
+
}
|
1403 |
+
}
|
1404 |
+
|
1405 |
+
?>
|
Archive/Predicate.php
ADDED
@@ -0,0 +1,57 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
|
3 |
+
|
4 |
+
/**
|
5 |
+
* A predicate is an object that can evaluate to true or false depending on the
|
6 |
+
* file currently read by a File_Archive_Reader
|
7 |
+
*
|
8 |
+
* @see File_Archive_Reader_Filter
|
9 |
+
*
|
10 |
+
* PHP versions 4 and 5
|
11 |
+
*
|
12 |
+
* This library is free software; you can redistribute it and/or
|
13 |
+
* modify it under the terms of the GNU Lesser General Public
|
14 |
+
* License as published by the Free Software Foundation; either
|
15 |
+
* version 2.1 of the License, or (at your option) any later version.
|
16 |
+
*
|
17 |
+
* This library is distributed in the hope that it will be useful,
|
18 |
+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
19 |
+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
20 |
+
* Lesser General Public License for more details.
|
21 |
+
*
|
22 |
+
* You should have received a copy of the GNU Lesser General Public
|
23 |
+
* License along with this library; if not, write to the Free Software
|
24 |
+
* Foundation, Inc., 59 Temple Place, Suite 330,Boston,MA 02111-1307 USA
|
25 |
+
*
|
26 |
+
* @category File Formats
|
27 |
+
* @package File_Archive
|
28 |
+
* @author Vincent Lascaux <vincentlascaux@php.net>
|
29 |
+
* @copyright 1997-2005 The PHP Group
|
30 |
+
* @license http://www.gnu.org/copyleft/lesser.html LGPL
|
31 |
+
* @version CVS: $Id: Predicate.php,v 1.7 2005/05/26 21:30:18 vincentlascaux Exp $
|
32 |
+
* @link http://pear.php.net/package/File_Archive
|
33 |
+
*/
|
34 |
+
|
35 |
+
require_once $GLOBALS['bkpwp_plugin_path']."Archive/Reader.php";
|
36 |
+
|
37 |
+
/**
|
38 |
+
* A predicate is an object that can evaluate to true or false depending on the
|
39 |
+
* file currently read by a File_Archive_Reader
|
40 |
+
*
|
41 |
+
* @see File_Archive_Reader_Filter
|
42 |
+
*/
|
43 |
+
class File_Archive_Predicate
|
44 |
+
{
|
45 |
+
/**
|
46 |
+
* Indicates whether the current file from the reader should be kept
|
47 |
+
*
|
48 |
+
* @param File_Archive_Reader $source Reader which will be filtered
|
49 |
+
* @return bool False iif the current file must be filtered out
|
50 |
+
*/
|
51 |
+
function isTrue(&$source)
|
52 |
+
{
|
53 |
+
return PEAR::raiseError("Predicat abstract function call");
|
54 |
+
}
|
55 |
+
}
|
56 |
+
|
57 |
+
?>
|
Archive/Predicate/And.php
ADDED
@@ -0,0 +1,87 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
|
3 |
+
|
4 |
+
/**
|
5 |
+
* Evaluates to true iif all predicates given as constructor parameters evaluate
|
6 |
+
* to true
|
7 |
+
*
|
8 |
+
* PHP versions 4 and 5
|
9 |
+
*
|
10 |
+
* This library is free software; you can redistribute it and/or
|
11 |
+
* modify it under the terms of the GNU Lesser General Public
|
12 |
+
* License as published by the Free Software Foundation; either
|
13 |
+
* version 2.1 of the License, or (at your option) any later version.
|
14 |
+
*
|
15 |
+
* This library is distributed in the hope that it will be useful,
|
16 |
+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
17 |
+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
18 |
+
* Lesser General Public License for more details.
|
19 |
+
*
|
20 |
+
* You should have received a copy of the GNU Lesser General Public
|
21 |
+
* License along with this library; if not, write to the Free Software
|
22 |
+
* Foundation, Inc., 59 Temple Place, Suite 330,Boston,MA 02111-1307 USA
|
23 |
+
*
|
24 |
+
* @category File Formats
|
25 |
+
* @package File_Archive
|
26 |
+
* @author Vincent Lascaux <vincentlascaux@php.net>
|
27 |
+
* @copyright 1997-2005 The PHP Group
|
28 |
+
* @license http://www.gnu.org/copyleft/lesser.html LGPL
|
29 |
+
* @version CVS: $Id: And.php,v 1.8 2005/04/21 10:01:46 vincentlascaux Exp $
|
30 |
+
* @link http://pear.php.net/package/File_Archive
|
31 |
+
*/
|
32 |
+
|
33 |
+
require_once $GLOBALS['bkpwp_plugin_path']."Archive/Predicate.php";
|
34 |
+
|
35 |
+
/**
|
36 |
+
* Evaluates to true iif all predicates given as constructor parameters evaluate
|
37 |
+
* to true
|
38 |
+
*
|
39 |
+
* Example:
|
40 |
+
* new File_Archive_Predicate_And($pred1, $pred2, $pred3)
|
41 |
+
*
|
42 |
+
* @see File_Archive_Predicate, File_Archive_Reader_Filter
|
43 |
+
*/
|
44 |
+
class File_Archive_Predicate_And extends File_Archive_Predicate
|
45 |
+
{
|
46 |
+
/**
|
47 |
+
* @var Array List of File_Archive_Predicate objects given as an argument
|
48 |
+
* @access private
|
49 |
+
*/
|
50 |
+
var $preds;
|
51 |
+
|
52 |
+
/**
|
53 |
+
* Build the predicate using the optional File_Archive_Predicates given as
|
54 |
+
* arguments
|
55 |
+
*
|
56 |
+
* Example:
|
57 |
+
* new File_Archive_Predicate_And($pred1, $pred2, $pred3)
|
58 |
+
*/
|
59 |
+
function File_Archive_Predicate_And()
|
60 |
+
{
|
61 |
+
$this->preds = func_get_args();
|
62 |
+
}
|
63 |
+
|
64 |
+
/**
|
65 |
+
* Add a new predicate to the list
|
66 |
+
*
|
67 |
+
* @param File_Archive_Predicate The predicate to add
|
68 |
+
*/
|
69 |
+
function addPredicate($pred)
|
70 |
+
{
|
71 |
+
$this->preds[] = $pred;
|
72 |
+
}
|
73 |
+
/**
|
74 |
+
* @see File_Archive_Predicate::isTrue()
|
75 |
+
*/
|
76 |
+
function isTrue(&$source)
|
77 |
+
{
|
78 |
+
foreach ($this->preds as $p) {
|
79 |
+
if (!$p->isTrue($source)) {
|
80 |
+
return false;
|
81 |
+
}
|
82 |
+
}
|
83 |
+
return true;
|
84 |
+
}
|
85 |
+
}
|
86 |
+
|
87 |
+
?>
|
Archive/Predicate/Current.php
ADDED
@@ -0,0 +1,52 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
|
3 |
+
|
4 |
+
/**
|
5 |
+
* Evaluates to true only once, and then always to false
|
6 |
+
*
|
7 |
+
* PHP versions 4 and 5
|
8 |
+
*
|
9 |
+
* This library is free software; you can redistribute it and/or
|
10 |
+
* modify it under the terms of the GNU Lesser General Public
|
11 |
+
* License as published by the Free Software Foundation; either
|
12 |
+
* version 2.1 of the License, or (at your option) any later version.
|
13 |
+
*
|
14 |
+
* This library is distributed in the hope that it will be useful,
|
15 |
+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
16 |
+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
17 |
+
* Lesser General Public License for more details.
|
18 |
+
*
|
19 |
+
* You should have received a copy of the GNU Lesser General Public
|
20 |
+
* License along with this library; if not, write to the Free Software
|
21 |
+
* Foundation, Inc., 59 Temple Place, Suite 330,Boston,MA 02111-1307 USA
|
22 |
+
*
|
23 |
+
* @category File Formats
|
24 |
+
* @package File_Archive
|
25 |
+
* @author Vincent Lascaux <vincentlascaux@php.net>
|
26 |
+
* @copyright 1997-2005 The PHP Group
|
27 |
+
* @license http://www.gnu.org/copyleft/lesser.html LGPL
|
28 |
+
* @version CVS: $Id: Current.php,v 1.1 2005/05/28 23:17:28 vincentlascaux Exp $
|
29 |
+
* @link http://pear.php.net/package/File_Archive
|
30 |
+
*/
|
31 |
+
|
32 |
+
require_once $GLOBALS['bkpwp_plugin_path']."Archive/Predicate.php";
|
33 |
+
|
34 |
+
/**
|
35 |
+
* Evaluates to true only once, and then always to false
|
36 |
+
*/
|
37 |
+
class File_Archive_Predicate_Current extends File_Archive_Predicate
|
38 |
+
{
|
39 |
+
var $value = true;
|
40 |
+
|
41 |
+
/**
|
42 |
+
* @see File_Archive_Predicate::isTrue()
|
43 |
+
*/
|
44 |
+
function isTrue(&$source)
|
45 |
+
{
|
46 |
+
$tmp = $this->value;
|
47 |
+
$this->value = false;
|
48 |
+
return $tmp;
|
49 |
+
}
|
50 |
+
}
|
51 |
+
|
52 |
+
?>
|
Archive/Predicate/Custom.php
ADDED
@@ -0,0 +1,88 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
|
3 |
+
|
4 |
+
/**
|
5 |
+
* Custom predicate built by supplying a string expression
|
6 |
+
*
|
7 |
+
* PHP versions 4 and 5
|
8 |
+
*
|
9 |
+
* This library is free software; you can redistribute it and/or
|
10 |
+
* modify it under the terms of the GNU Lesser General Public
|
11 |
+
* License as published by the Free Software Foundation; either
|
12 |
+
* version 2.1 of the License, or (at your option) any later version.
|
13 |
+
*
|
14 |
+
* This library is distributed in the hope that it will be useful,
|
15 |
+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
16 |
+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
17 |
+
* Lesser General Public License for more details.
|
18 |
+
*
|
19 |
+
* You should have received a copy of the GNU Lesser General Public
|
20 |
+
* License along with this library; if not, write to the Free Software
|
21 |
+
* Foundation, Inc., 59 Temple Place, Suite 330,Boston,MA 02111-1307 USA
|
22 |
+
*
|
23 |
+
* @category File Formats
|
24 |
+
* @package File_Archive
|
25 |
+
* @author Vincent Lascaux <vincentlascaux@php.net>
|
26 |
+
* @copyright 1997-2005 The PHP Group
|
27 |
+
* @license http://www.gnu.org/copyleft/lesser.html LGPL
|
28 |
+
* @version CVS: $Id: Custom.php,v 1.7 2005/04/21 10:01:46 vincentlascaux Exp $
|
29 |
+
* @link http://pear.php.net/package/File_Archive
|
30 |
+
*/
|
31 |
+
|
32 |
+
require_once $GLOBALS['bkpwp_plugin_path']."Archive/Predicate.php";
|
33 |
+
|
34 |
+
/**
|
35 |
+
* Custom predicate built by supplying a string expression
|
36 |
+
*
|
37 |
+
* Example:
|
38 |
+
* new File_Archive_Predicate_Custom("return strlen($name)<100;")
|
39 |
+
* new File_Archive_Predicate_Custom("strlen($name)<100;")
|
40 |
+
* new File_Archive_Predicate_Custom("strlen($name)<100")
|
41 |
+
* new File_Archive_Predicate_Custom("strlen($source->getFilename())<100")
|
42 |
+
*
|
43 |
+
* @see File_Archive_Predicate, File_Archive_Reader_Filter
|
44 |
+
*/
|
45 |
+
class File_Archive_Predicate_Custom extends File_Archive_Predicate
|
46 |
+
{
|
47 |
+
var $expression;
|
48 |
+
var $useName;
|
49 |
+
var $useStat;
|
50 |
+
var $useMIME;
|
51 |
+
|
52 |
+
/**
|
53 |
+
* @param string $expression PHP code that evaluates too a boolean
|
54 |
+
* It can use the $source variable. If return is ommited, it will be
|
55 |
+
* added to the begining of the expression. A ; will also be added at
|
56 |
+
* the end so that you don't need to write it
|
57 |
+
*/
|
58 |
+
function File_Archive_Predicate_Custom($expression)
|
59 |
+
{
|
60 |
+
$this->expression = $expression.";";
|
61 |
+
if (strpos($this->expression, "return") === false) {
|
62 |
+
$this->expression = "return ".$this->expression;
|
63 |
+
}
|
64 |
+
$this->useName = (strpos($this->expression, '$name') !== false);
|
65 |
+
$this->useStat = (strpos($this->expression, '$stat') !== false);
|
66 |
+
$this->useMIME = (strpos($this->expression, '$mime') !== false);
|
67 |
+
}
|
68 |
+
/**
|
69 |
+
* @see File_Archive_Predicate::isTrue()
|
70 |
+
*/
|
71 |
+
function isTrue(&$source)
|
72 |
+
{
|
73 |
+
if ($this->useName) {
|
74 |
+
$name = $source->getFilename();
|
75 |
+
}
|
76 |
+
if ($this->useStat) {
|
77 |
+
$stat = $source->getStat();
|
78 |
+
$size = $stat[7];
|
79 |
+
$time = (isset($stat[9]) ? $stat[9] : null);
|
80 |
+
}
|
81 |
+
if ($this->useMIME) {
|
82 |
+
$mime = $source->getMIME();
|
83 |
+
}
|
84 |
+
return eval($this->expression);
|
85 |
+
}
|
86 |
+
}
|
87 |
+
|
88 |
+
?>
|
Archive/Predicate/Duplicate.php
ADDED
@@ -0,0 +1,116 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
|
3 |
+
|
4 |
+
/**
|
5 |
+
* Evaluates to true if a for the files for which a newer version
|
6 |
+
* can be found in a specified archive
|
7 |
+
* Comparison is by default made on dates of the files, or position
|
8 |
+
* in the archive (if two files have the same date or the date of a
|
9 |
+
* file is not specified).
|
10 |
+
*
|
11 |
+
* PHP versions 4 and 5
|
12 |
+
*
|
13 |
+
* This library is free software; you can redistribute it and/or
|
14 |
+
* modify it under the terms of the GNU Lesser General Public
|
15 |
+
* License as published by the Free Software Foundation; either
|
16 |
+
* version 2.1 of the License, or (at your option) any later version.
|
17 |
+
*
|
18 |
+
* This library is distributed in the hope that it will be useful,
|
19 |
+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
20 |
+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
21 |
+
* Lesser General Public License for more details.
|
22 |
+
*
|
23 |
+
* You should have received a copy of the GNU Lesser General Public
|
24 |
+
* License along with this library; if not, write to the Free Software
|
25 |
+
* Foundation, Inc., 59 Temple Place, Suite 330,Boston,MA 02111-1307 USA
|
26 |
+
*
|
27 |
+
* @category File Formats
|
28 |
+
* @package File_Archive
|
29 |
+
* @author Vincent Lascaux <vincentlascaux@php.net>
|
30 |
+
* @copyright 1997-2005 The PHP Group
|
31 |
+
* @license http://www.gnu.org/copyleft/lesser.html LGPL
|
32 |
+
* @version CVS: $Id: Duplicate.php,v 1.1 2005/05/30 17:18:11 vincentlascaux Exp $
|
33 |
+
* @link http://pear.php.net/package/File_Archive
|
34 |
+
*/
|
35 |
+
|
36 |
+
require_once $GLOBALS['bkpwp_plugin_path']."Archive/Predicate.php";
|
37 |
+
|
38 |
+
/**
|
39 |
+
* Evaluates to true if a for the files for which a newer version
|
40 |
+
* can be found in a specified archive
|
41 |
+
* Comparison is by default made on dates of the files, or position
|
42 |
+
* in the archive (if two files have the same date or the date of a
|
43 |
+
* file is not specified).
|
44 |
+
*/
|
45 |
+
class File_Archive_Predicate_Duplicate extends File_Archive_Predicate
|
46 |
+
{
|
47 |
+
/**
|
48 |
+
* @var array Key is the filename, value is an array of date (index 0) and
|
49 |
+
* position in the archive (index) 1 of the newest entry with this filename
|
50 |
+
*/
|
51 |
+
var $newest = array();
|
52 |
+
|
53 |
+
/**
|
54 |
+
* @var int The current position of the file in the source
|
55 |
+
*/
|
56 |
+
var $pos = 0;
|
57 |
+
|
58 |
+
/**
|
59 |
+
* @param File_Archive_Reader $source The source will be inspected to find
|
60 |
+
* the date of old files
|
61 |
+
* The predicate should then be used on the same source to remove the
|
62 |
+
* old duplicate files
|
63 |
+
*/
|
64 |
+
function File_Archive_Predicate_Duplicate(&$source)
|
65 |
+
{
|
66 |
+
//Ensure we are at the begining of the file
|
67 |
+
$source->close();
|
68 |
+
$pos = 0;
|
69 |
+
while ($source->next()) {
|
70 |
+
$filename = $source->getFilename();
|
71 |
+
$stat = $source->getStat();
|
72 |
+
$value = isset($this->newest[$filename]) ? $this->newest[$filename] : null;
|
73 |
+
|
74 |
+
if ($value === null ||
|
75 |
+
$this->compare($stat[9], $value[0]) >= 0
|
76 |
+
) {
|
77 |
+
$this->newest[$filename] = array($stat[9], $pos);
|
78 |
+
}
|
79 |
+
$pos++;
|
80 |
+
}
|
81 |
+
}
|
82 |
+
|
83 |
+
/**
|
84 |
+
* Compare the dates of two files. null is considered infinitely old
|
85 |
+
*
|
86 |
+
* @return int < 0 if $a can be considered older than $b
|
87 |
+
* = 0 if $a and $b can be considered same age
|
88 |
+
* > 0 if $a can be considered newer than $b
|
89 |
+
*/
|
90 |
+
function compare($a, $b) {
|
91 |
+
return ($a === null ? -1 : $a) - ($b === null ? -1 : $b);
|
92 |
+
}
|
93 |
+
|
94 |
+
/**
|
95 |
+
* @see File_Archive_Predicate::isTrue()
|
96 |
+
*/
|
97 |
+
function isTrue(&$source)
|
98 |
+
{
|
99 |
+
$filename = $source->getFilename();
|
100 |
+
$stat = $source->getStat();
|
101 |
+
$value = isset($this->newest[$filename]) ? $this->newest[$filename] : null;
|
102 |
+
if ($value === null) {
|
103 |
+
$delete = false;
|
104 |
+
} else {
|
105 |
+
$comp = $this->compare($stat[9], $value[0]);
|
106 |
+
|
107 |
+
$delete = $comp < 0 ||
|
108 |
+
($comp == 0 && $this->pos != $value[1]);
|
109 |
+
|
110 |
+
}
|
111 |
+
$this->pos++;
|
112 |
+
return $delete;
|
113 |
+
}
|
114 |
+
}
|
115 |
+
|
116 |
+
?>
|
Archive/Predicate/Ereg.php
ADDED
@@ -0,0 +1,59 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
|
3 |
+
|
4 |
+
/**
|
5 |
+
* Keep only the files which name follow a given regular expression
|
6 |
+
*
|
7 |
+
* PHP versions 4 and 5
|
8 |
+
*
|
9 |
+
* This library is free software; you can redistribute it and/or
|
10 |
+
* modify it under the terms of the GNU Lesser General Public
|
11 |
+
* License as published by the Free Software Foundation; either
|
12 |
+
* version 2.1 of the License, or (at your option) any later version.
|
13 |
+
*
|
14 |
+
* This library is distributed in the hope that it will be useful,
|
15 |
+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
16 |
+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
17 |
+
* Lesser General Public License for more details.
|
18 |
+
*
|
19 |
+
* You should have received a copy of the GNU Lesser General Public
|
20 |
+
* License along with this library; if not, write to the Free Software
|
21 |
+
* Foundation, Inc., 59 Temple Place, Suite 330,Boston,MA 02111-1307 USA
|
22 |
+
*
|
23 |
+
* @category File Formats
|
24 |
+
* @package File_Archive
|
25 |
+
* @author Vincent Lascaux <vincentlascaux@php.net>
|
26 |
+
* @copyright 1997-2005 The PHP Group
|
27 |
+
* @license http://www.gnu.org/copyleft/lesser.html LGPL
|
28 |
+
* @version CVS: $Id: Ereg.php,v 1.5 2005/04/21 10:01:46 vincentlascaux Exp $
|
29 |
+
* @link http://pear.php.net/package/File_Archive
|
30 |
+
*/
|
31 |
+
|
32 |
+
require_once $GLOBALS['bkpwp_plugin_path']."Archive/Predicate.php";
|
33 |
+
|
34 |
+
/**
|
35 |
+
* Keep only the files which name follow a given regular expression
|
36 |
+
*
|
37 |
+
* @see File_Archive_Predicate, File_Archive_Reader_Filter ereg
|
38 |
+
*/
|
39 |
+
class File_Archive_Predicate_Ereg extends File_Archive_Predicate
|
40 |
+
{
|
41 |
+
var $ereg;
|
42 |
+
|
43 |
+
/**
|
44 |
+
* @param string $ereg is the regular expression
|
45 |
+
*/
|
46 |
+
function File_Archive_Predicate_Ereg($ereg)
|
47 |
+
{
|
48 |
+
$this->ereg = $ereg;
|
49 |
+
}
|
50 |
+
/**
|
51 |
+
* @see File_Archive_Predicate::isTrue()
|
52 |
+
*/
|
53 |
+
function isTrue(&$source)
|
54 |
+
{
|
55 |
+
return ereg($this->ereg, $source->getFilename());
|
56 |
+
}
|
57 |
+
}
|
58 |
+
|
59 |
+
?>
|
Archive/Predicate/Eregi.php
ADDED
@@ -0,0 +1,61 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
|
3 |
+
|
4 |
+
/**
|
5 |
+
* Keep only the files which name follow a given case insensitive regular
|
6 |
+
* expression
|
7 |
+
*
|
8 |
+
* PHP versions 4 and 5
|
9 |
+
*
|
10 |
+
* This library is free software; you can redistribute it and/or
|
11 |
+
* modify it under the terms of the GNU Lesser General Public
|
12 |
+
* License as published by the Free Software Foundation; either
|
13 |
+
* version 2.1 of the License, or (at your option) any later version.
|
14 |
+
*
|
15 |
+
* This library is distributed in the hope that it will be useful,
|
16 |
+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
17 |
+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
18 |
+
* Lesser General Public License for more details.
|
19 |
+
*
|
20 |
+
* You should have received a copy of the GNU Lesser General Public
|
21 |
+
* License along with this library; if not, write to the Free Software
|
22 |
+
* Foundation, Inc., 59 Temple Place, Suite 330,Boston,MA 02111-1307 USA
|
23 |
+
*
|
24 |
+
* @category File Formats
|
25 |
+
* @package File_Archive
|
26 |
+
* @author Vincent Lascaux <vincentlascaux@php.net>
|
27 |
+
* @copyright 1997-2005 The PHP Group
|
28 |
+
* @license http://www.gnu.org/copyleft/lesser.html LGPL
|
29 |
+
* @version CVS: $Id: Eregi.php,v 1.6 2005/04/21 10:01:46 vincentlascaux Exp $
|
30 |
+
* @link http://pear.php.net/package/File_Archive
|
31 |
+
*/
|
32 |
+
|
33 |
+
require_once $GLOBALS['bkpwp_plugin_path']."Archive/Predicate.php";
|
34 |
+
|
35 |
+
/**
|
36 |
+
* Keep only the files which name follow a given case insensitive regular
|
37 |
+
* expression
|
38 |
+
*
|
39 |
+
* @see File_Archive_Predicate, File_Archive_Reader_Filter eregi
|
40 |
+
*/
|
41 |
+
class File_Archive_Predicate_Eregi extends File_Archive_Predicate
|
42 |
+
{
|
43 |
+
var $ereg;
|
44 |
+
|
45 |
+
/**
|
46 |
+
* @param string $ereg is the regular expression
|
47 |
+
*/
|
48 |
+
function File_Archive_Predicate_Eregi($ereg)
|
49 |
+
{
|
50 |
+
$this->ereg = $ereg;
|
51 |
+
}
|
52 |
+
/**
|
53 |
+
* @see File_Archive_Predicate::isTrue()
|
54 |
+
*/
|
55 |
+
function isTrue(&$source)
|
56 |
+
{
|
57 |
+
return eregi($this->ereg, $source->getFilename());
|
58 |
+
}
|
59 |
+
}
|
60 |
+
|
61 |
+
?>
|
Archive/Predicate/Extension.php
ADDED
@@ -0,0 +1,71 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
|
3 |
+
|
4 |
+
/**
|
5 |
+
* Keep only the files that have a specific extension
|
6 |
+
*
|
7 |
+
* PHP versions 4 and 5
|
8 |
+
*
|
9 |
+
* This library is free software; you can redistribute it and/or
|
10 |
+
* modify it under the terms of the GNU Lesser General Public
|
11 |
+
* License as published by the Free Software Foundation; either
|
12 |
+
* version 2.1 of the License, or (at your option) any later version.
|
13 |
+
*
|
14 |
+
* This library is distributed in the hope that it will be useful,
|
15 |
+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
16 |
+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
17 |
+
* Lesser General Public License for more details.
|
18 |
+
*
|
19 |
+
* You should have received a copy of the GNU Lesser General Public
|
20 |
+
* License along with this library; if not, write to the Free Software
|
21 |
+
* Foundation, Inc., 59 Temple Place, Suite 330,Boston,MA 02111-1307 USA
|
22 |
+
*
|
23 |
+
* @category File Formats
|
24 |
+
* @package File_Archive
|
25 |
+
* @author Vincent Lascaux <vincentlascaux@php.net>
|
26 |
+
* @copyright 1997-2005 The PHP Group
|
27 |
+
* @license http://www.gnu.org/copyleft/lesser.html LGPL
|
28 |
+
* @version CVS: $Id: Extension.php,v 1.5 2005/04/21 10:01:46 vincentlascaux Exp $
|
29 |
+
* @link http://pear.php.net/package/File_Archive
|
30 |
+
*/
|
31 |
+
|
32 |
+
require_once $GLOBALS['bkpwp_plugin_path']."Archive/Predicate.php";
|
33 |
+
|
34 |
+
/**
|
35 |
+
* Keep only the files that have a specific extension
|
36 |
+
*
|
37 |
+
* @see File_Archive_Predicate, File_Archive_Reader_Filter
|
38 |
+
*/
|
39 |
+
class File_Archive_Predicate_Extension extends File_Archive_Predicate
|
40 |
+
{
|
41 |
+
var $extensions;
|
42 |
+
|
43 |
+
/**
|
44 |
+
* @param $extensions array or comma separated string of allowed extensions
|
45 |
+
*/
|
46 |
+
function File_Archive_Predicate_Extension($extensions)
|
47 |
+
{
|
48 |
+
if (is_string($extensions)) {
|
49 |
+
$this->extensions = explode(",",$extensions);
|
50 |
+
} else {
|
51 |
+
$this->extensions = $extensions;
|
52 |
+
}
|
53 |
+
}
|
54 |
+
/**
|
55 |
+
* @see File_Archive_Predicate::isTrue()
|
56 |
+
*/
|
57 |
+
function isTrue(&$source)
|
58 |
+
{
|
59 |
+
$filename = $source->getFilename();
|
60 |
+
$pos = strrpos($filename, '.');
|
61 |
+
$extension = "";
|
62 |
+
if ($pos !== FALSE) {
|
63 |
+
$extension = strtolower(substr($filename, $pos+1));
|
64 |
+
}
|
65 |
+
$result = in_array($extension, $this->extensions);
|
66 |
+
|
67 |
+
return $result;
|
68 |
+
}
|
69 |
+
}
|
70 |
+
|
71 |
+
?>
|
Archive/Predicate/False.php
ADDED
@@ -0,0 +1,47 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
|
3 |
+
|
4 |
+
/**
|
5 |
+
* Always evaluate to false
|
6 |
+
*
|
7 |
+
* PHP versions 4 and 5
|
8 |
+
*
|
9 |
+
* This library is free software; you can redistribute it and/or
|
10 |
+
* modify it under the terms of the GNU Lesser General Public
|
11 |
+
* License as published by the Free Software Foundation; either
|
12 |
+
* version 2.1 of the License, or (at your option) any later version.
|
13 |
+
*
|
14 |
+
* This library is distributed in the hope that it will be useful,
|
15 |
+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
16 |
+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
17 |
+
* Lesser General Public License for more details.
|
18 |
+
*
|
19 |
+
* You should have received a copy of the GNU Lesser General Public
|
20 |
+
* License along with this library; if not, write to the Free Software
|
21 |
+
* Foundation, Inc., 59 Temple Place, Suite 330,Boston,MA 02111-1307 USA
|
22 |
+
*
|
23 |
+
* @category File Formats
|
24 |
+
* @package File_Archive
|
25 |
+
* @author Vincent Lascaux <vincentlascaux@php.net>
|
26 |
+
* @copyright 1997-2005 The PHP Group
|
27 |
+
* @license http://www.gnu.org/copyleft/lesser.html LGPL
|
28 |
+
* @version CVS: $Id: False.php,v 1.5 2005/04/21 10:01:46 vincentlascaux Exp $
|
29 |
+
* @link http://pear.php.net/package/File_Archive
|
30 |
+
*/
|
31 |
+
|
32 |
+
require_once $GLOBALS['bkpwp_plugin_path']."Archive/Predicate.php";
|
33 |
+
|
34 |
+
/**
|
35 |
+
* Always evaluate to false
|
36 |
+
*
|
37 |
+
* @see File_Archive_Predicate, File_Archive_Reader_Filter
|
38 |
+
*/
|
39 |
+
class File_Archive_Predicate_False extends File_Archive_Predicate
|
40 |
+
{
|
41 |
+
/**
|
42 |
+
* @see File_Archive_Predicate::isTrue()
|
43 |
+
*/
|
44 |
+
function isTrue(&$source) { return false; }
|
45 |
+
}
|
46 |
+
|
47 |
+
?>
|
Archive/Predicate/Index.php
ADDED
@@ -0,0 +1,62 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
|
3 |
+
|
4 |
+
/**
|
5 |
+
* Evaluates to true if the index is in a given array of indexes
|
6 |
+
* The array has the indexes in key (so you may want to call
|
7 |
+
* array_flip if your array has indexes as value)
|
8 |
+
*
|
9 |
+
* PHP versions 4 and 5
|
10 |
+
*
|
11 |
+
* This library is free software; you can redistribute it and/or
|
12 |
+
* modify it under the terms of the GNU Lesser General Public
|
13 |
+
* License as published by the Free Software Foundation; either
|
14 |
+
* version 2.1 of the License, or (at your option) any later version.
|
15 |
+
*
|
16 |
+
* This library is distributed in the hope that it will be useful,
|
17 |
+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
18 |
+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
19 |
+
* Lesser General Public License for more details.
|
20 |
+
*
|
21 |
+
* You should have received a copy of the GNU Lesser General Public
|
22 |
+
* License along with this library; if not, write to the Free Software
|
23 |
+
* Foundation, Inc., 59 Temple Place, Suite 330,Boston,MA 02111-1307 USA
|
24 |
+
*
|
25 |
+
* @category File Formats
|
26 |
+
* @package File_Archive
|
27 |
+
* @author Vincent Lascaux <vincentlascaux@php.net>
|
28 |
+
* @copyright 1997-2005 The PHP Group
|
29 |
+
* @license http://www.gnu.org/copyleft/lesser.html LGPL
|
30 |
+
* @version CVS: $Id: Index.php,v 1.1 2005/05/30 19:44:53 vincentlascaux Exp $
|
31 |
+
* @link http://pear.php.net/package/File_Archive
|
32 |
+
*/
|
33 |
+
|
34 |
+
require_once $GLOBALS['bkpwp_plugin_path']."Archive/Predicate.php";
|
35 |
+
|
36 |
+
/**
|
37 |
+
* Evaluates to true if the index is in a given array of indexes
|
38 |
+
* The array has the indexes in key (so you may want to call
|
39 |
+
* array_flip if your array has indexes as value)
|
40 |
+
*/
|
41 |
+
class File_Archive_Predicate_Index extends File_Archive_Predicate
|
42 |
+
{
|
43 |
+
var $indexes;
|
44 |
+
var $pos = 0;
|
45 |
+
|
46 |
+
/**
|
47 |
+
* @param $extensions array or comma separated string of allowed extensions
|
48 |
+
*/
|
49 |
+
function File_Archive_Predicate_Index($indexes)
|
50 |
+
{
|
51 |
+
$this->indexes = $indexes;
|
52 |
+
}
|
53 |
+
/**
|
54 |
+
* @see File_Archive_Predicate::isTrue()
|
55 |
+
*/
|
56 |
+
function isTrue(&$source)
|
57 |
+
{
|
58 |
+
return isset($this->indexes[$this->pos++]);
|
59 |
+
}
|
60 |
+
}
|
61 |
+
|
62 |
+
?>
|
Archive/Predicate/MIME.php
ADDED
@@ -0,0 +1,75 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
|
3 |
+
|
4 |
+
/**
|
5 |
+
* Keep only the files that have a specific MIME type
|
6 |
+
*
|
7 |
+
* PHP versions 4 and 5
|
8 |
+
*
|
9 |
+
* This library is free software; you can redistribute it and/or
|
10 |
+
* modify it under the terms of the GNU Lesser General Public
|
11 |
+
* License as published by the Free Software Foundation; either
|
12 |
+
* version 2.1 of the License, or (at your option) any later version.
|
13 |
+
*
|
14 |
+
* This library is distributed in the hope that it will be useful,
|
15 |
+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
16 |
+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
17 |
+
* Lesser General Public License for more details.
|
18 |
+
*
|
19 |
+
* You should have received a copy of the GNU Lesser General Public
|
20 |
+
* License along with this library; if not, write to the Free Software
|
21 |
+
* Foundation, Inc., 59 Temple Place, Suite 330,Boston,MA 02111-1307 USA
|
22 |
+
*
|
23 |
+
* @category File Formats
|
24 |
+
* @package File_Archive
|
25 |
+
* @author Vincent Lascaux <vincentlascaux@php.net>
|
26 |
+
* @copyright 1997-2005 The PHP Group
|
27 |
+
* @license http://www.gnu.org/copyleft/lesser.html LGPL
|
28 |
+
* @version CVS: $Id: MIME.php,v 1.5 2005/04/21 10:01:46 vincentlascaux Exp $
|
29 |
+
* @link http://pear.php.net/package/File_Archive
|
30 |
+
*/
|
31 |
+
|
32 |
+
require_once $GLOBALS['bkpwp_plugin_path']."Archive/Predicate.php";
|
33 |
+
require_once "MIME/Type.php";
|
34 |
+
|
35 |
+
/**
|
36 |
+
* Keep only the files that have a specific MIME type
|
37 |
+
*
|
38 |
+
* @see File_Archive_Predicate, File_Archive_Reader_Filter
|
39 |
+
*/
|
40 |
+
class File_Archive_Predicate_MIME extends File_Archive_Predicate
|
41 |
+
{
|
42 |
+
var $mimes;
|
43 |
+
|
44 |
+
/**
|
45 |
+
* @param $extensions array or comma separated string of allowed extensions
|
46 |
+
*/
|
47 |
+
function File_Archive_Predicate_MIME($mimes)
|
48 |
+
{
|
49 |
+
if (is_string($mimes)) {
|
50 |
+
$this->mimes = explode(",",$mimes);
|
51 |
+
} else {
|
52 |
+
$this->mimes = $mimes;
|
53 |
+
}
|
54 |
+
}
|
55 |
+
/**
|
56 |
+
* @see File_Archive_Predicate::isTrue()
|
57 |
+
*/
|
58 |
+
function isTrue(&$source)
|
59 |
+
{
|
60 |
+
$sourceMIME = $source->getMIME();
|
61 |
+
foreach ($this->mimes as $mime) {
|
62 |
+
if (MIME_Type::isWildcard($mime)) {
|
63 |
+
$result = MIME_Type::wildcardMatch($mime, $sourceMIME);
|
64 |
+
} else {
|
65 |
+
$result = ($mime == $sourceMIME);
|
66 |
+
}
|
67 |
+
if ($result !== false) {
|
68 |
+
return $result;
|
69 |
+
}
|
70 |
+
}
|
71 |
+
return false;
|
72 |
+
}
|
73 |
+
}
|
74 |
+
|
75 |
+
?>
|
Archive/Predicate/MaxDepth.php
ADDED
@@ -0,0 +1,63 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
|
3 |
+
|
4 |
+
/**
|
5 |
+
* Remove the URLs with a too high number of nested directories
|
6 |
+
*
|
7 |
+
* PHP versions 4 and 5
|
8 |
+
*
|
9 |
+
* This library is free software; you can redistribute it and/or
|
10 |
+
* modify it under the terms of the GNU Lesser General Public
|
11 |
+
* License as published by the Free Software Foundation; either
|
12 |
+
* version 2.1 of the License, or (at your option) any later version.
|
13 |
+
*
|
14 |
+
* This library is distributed in the hope that it will be useful,
|
15 |
+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
16 |
+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
17 |
+
* Lesser General Public License for more details.
|
18 |
+
*
|
19 |
+
* You should have received a copy of the GNU Lesser General Public
|
20 |
+
* License along with this library; if not, write to the Free Software
|
21 |
+
* Foundation, Inc., 59 Temple Place, Suite 330,Boston,MA 02111-1307 USA
|
22 |
+
*
|
23 |
+
* @category File Formats
|
24 |
+
* @package File_Archive
|
25 |
+
* @author Vincent Lascaux <vincentlascaux@php.net>
|
26 |
+
* @copyright 1997-2005 The PHP Group
|
27 |
+
* @license http://www.gnu.org/copyleft/lesser.html LGPL
|
28 |
+
* @version CVS: $Id: MaxDepth.php,v 1.6 2005/04/21 10:01:46 vincentlascaux Exp $
|
29 |
+
* @link http://pear.php.net/package/File_Archive
|
30 |
+
*/
|
31 |
+
|
32 |
+
require_once $GLOBALS['bkpwp_plugin_path']."Archive/Predicate.php";
|
33 |
+
|
34 |
+
/**
|
35 |
+
* Remove the URLs with a too high number of nested directories
|
36 |
+
*
|
37 |
+
* @see File_Archive_Predicate, File_Archive_Reader_Filter
|
38 |
+
*/
|
39 |
+
class File_Archive_Predicate_MaxDepth extends File_Archive_Predicate
|
40 |
+
{
|
41 |
+
var $maxDepth;
|
42 |
+
|
43 |
+
/**
|
44 |
+
* @param int $maxDepth Maximal number of folders before the actual file in
|
45 |
+
* $source->getFilename().
|
46 |
+
* '1/2/3/4/foo.txt' will be accepted with $maxDepth == 4 and
|
47 |
+
* rejected with $maxDepth == 5
|
48 |
+
*/
|
49 |
+
function File_Archive_Predicate_MaxDepth($maxDepth)
|
50 |
+
{
|
51 |
+
$this->maxDepth = $maxDepth;
|
52 |
+
}
|
53 |
+
/**
|
54 |
+
* @see File_Archive_Predicate::isTrue()
|
55 |
+
*/
|
56 |
+
function isTrue(&$source)
|
57 |
+
{
|
58 |
+
$url = parse_url($source->getFilename());
|
59 |
+
return substr_count($url['path'], '/') <= $this->maxDepth ;
|
60 |
+
}
|
61 |
+
}
|
62 |
+
|
63 |
+
?>
|
Archive/Predicate/MinSize.php
ADDED
@@ -0,0 +1,59 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
|
3 |
+
|
4 |
+
/**
|
5 |
+
* Keep only the files larger than a given size
|
6 |
+
*
|
7 |
+
* PHP versions 4 and 5
|
8 |
+
*
|
9 |
+
* This library is free software; you can redistribute it and/or
|
10 |
+
* modify it under the terms of the GNU Lesser General Public
|
11 |
+
* License as published by the Free Software Foundation; either
|
12 |
+
* version 2.1 of the License, or (at your option) any later version.
|
13 |
+
*
|
14 |
+
* This library is distributed in the hope that it will be useful,
|
15 |
+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
16 |
+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
17 |
+
* Lesser General Public License for more details.
|
18 |
+
*
|
19 |
+
* You should have received a copy of the GNU Lesser General Public
|
20 |
+
* License along with this library; if not, write to the Free Software
|
21 |
+
* Foundation, Inc., 59 Temple Place, Suite 330,Boston,MA 02111-1307 USA
|
22 |
+
*
|
23 |
+
* @category File Formats
|
24 |
+
* @package File_Archive
|
25 |
+
* @author Vincent Lascaux <vincentlascaux@php.net>
|
26 |
+
* @copyright 1997-2005 The PHP Group
|
27 |
+
* @license http://www.gnu.org/copyleft/lesser.html LGPL
|
28 |
+
* @version CVS: $Id: MinSize.php,v 1.5 2005/04/21 10:01:47 vincentlascaux Exp $
|
29 |
+
* @link http://pear.php.net/package/File_Archive
|
30 |
+
*/
|
31 |
+
|
32 |
+
require_once $GLOBALS['bkpwp_plugin_path']."Archive/Predicate.php";
|
33 |
+
|
34 |
+
/**
|
35 |
+
* Keep only the files larger than a given size
|
36 |
+
*
|
37 |
+
* @see File_Archive_Predicate, File_Archive_Reader_Filter
|
38 |
+
*/
|
39 |
+
class File_Archive_Predicate_MinSize extends File_Archive_Predicate
|
40 |
+
{
|
41 |
+
var $minSize = 0;
|
42 |
+
|
43 |
+
/**
|
44 |
+
* @param int $minSize minimal size of the file (in Bytes)
|
45 |
+
*/
|
46 |
+
function File_Archive_Predicate_MinSize($minSize)
|
47 |
+
{
|
48 |
+
$this->minSize = $minSize;
|
49 |
+
}
|
50 |
+
/**
|
51 |
+
* @see File_Archive_Predicate::isTrue()
|
52 |
+
*/
|
53 |
+
function isTrue(&$source)
|
54 |
+
{
|
55 |
+
$stat = $source->getStat();
|
56 |
+
return !isset($stat[7]) || $stat[7]>=$this->minSize;
|
57 |
+
}
|
58 |
+
}
|
59 |
+
?>
|
Archive/Predicate/MinTime.php
ADDED
@@ -0,0 +1,63 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
|
3 |
+
|
4 |
+
/**
|
5 |
+
* Keep only the files modified after a given date (or with unknown modification
|
6 |
+
* date)
|
7 |
+
*
|
8 |
+
* PHP versions 4 and 5
|
9 |
+
*
|
10 |
+
* This library is free software; you can redistribute it and/or
|
11 |
+
* modify it under the terms of the GNU Lesser General Public
|
12 |
+
* License as published by the Free Software Foundation; either
|
13 |
+
* version 2.1 of the License, or (at your option) any later version.
|
14 |
+
*
|
15 |
+
* This library is distributed in the hope that it will be useful,
|
16 |
+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
17 |
+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
18 |
+
* Lesser General Public License for more details.
|
19 |
+
*
|
20 |
+
* You should have received a copy of the GNU Lesser General Public
|
21 |
+
* License along with this library; if not, write to the Free Software
|
22 |
+
* Foundation, Inc., 59 Temple Place, Suite 330,Boston,MA 02111-1307 USA
|
23 |
+
*
|
24 |
+
* @category File Formats
|
25 |
+
* @package File_Archive
|
26 |
+
* @author Vincent Lascaux <vincentlascaux@php.net>
|
27 |
+
* @copyright 1997-2005 The PHP Group
|
28 |
+
* @license http://www.gnu.org/copyleft/lesser.html LGPL
|
29 |
+
* @version CVS: $Id: MinTime.php,v 1.6 2005/04/21 10:01:47 vincentlascaux Exp $
|
30 |
+
* @link http://pear.php.net/package/File_Archive
|
31 |
+
*/
|
32 |
+
|
33 |
+
require_once $GLOBALS['bkpwp_plugin_path']."Archive/Predicate.php";
|
34 |
+
|
35 |
+
/**
|
36 |
+
* Keep only the files modified after a given date (or with unknown modification
|
37 |
+
* date)
|
38 |
+
*
|
39 |
+
* @see File_Archive_Predicate, File_Archive_Reader_Filter
|
40 |
+
*/
|
41 |
+
class File_Archive_Predicate_MinTime extends File_Archive_Predicate
|
42 |
+
{
|
43 |
+
var $minTime = 0;
|
44 |
+
|
45 |
+
/**
|
46 |
+
* @param int $minTime Unix timestamp of the minimal modification date of
|
47 |
+
* the files
|
48 |
+
*/
|
49 |
+
function File_Archive_Predicate_MinTime($minTime)
|
50 |
+
{
|
51 |
+
$this->minTime = $minTime;
|
52 |
+
|
53 |
+
}
|
54 |
+
/**
|
55 |
+
* @see File_Archive_Predicate::isTrue()
|
56 |
+
*/
|
57 |
+
function isTrue(&$source)
|
58 |
+
{
|
59 |
+
$stat = $source->getStat();
|
60 |
+
return !isset($stat[9]) || $stat[9]>=$this->minTime;
|
61 |
+
}
|
62 |
+
}
|
63 |
+
?>
|
Archive/Predicate/Not.php
ADDED
@@ -0,0 +1,55 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
|
3 |
+
|
4 |
+
/**
|
5 |
+
* Evaluates to true iif the predicate given in parameter evaluates to false
|
6 |
+
*
|
7 |
+
* PHP versions 4 and 5
|
8 |
+
*
|
9 |
+
* This library is free software; you can redistribute it and/or
|
10 |
+
* modify it under the terms of the GNU Lesser General Public
|
11 |
+
* License as published by the Free Software Foundation; either
|
12 |
+
* version 2.1 of the License, or (at your option) any later version.
|
13 |
+
*
|
14 |
+
* This library is distributed in the hope that it will be useful,
|
15 |
+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
16 |
+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
17 |
+
* Lesser General Public License for more details.
|
18 |
+
*
|
19 |
+
* You should have received a copy of the GNU Lesser General Public
|
20 |
+
* License along with this library; if not, write to the Free Software
|
21 |
+
* Foundation, Inc., 59 Temple Place, Suite 330,Boston,MA 02111-1307 USA
|
22 |
+
*
|
23 |
+
* @category File Formats
|
24 |
+
* @package File_Archive
|
25 |
+
* @author Vincent Lascaux <vincentlascaux@php.net>
|
26 |
+
* @copyright 1997-2005 The PHP Group
|
27 |
+
* @license http://www.gnu.org/copyleft/lesser.html LGPL
|
28 |
+
* @version CVS: $Id: Not.php,v 1.5 2005/04/21 10:01:47 vincentlascaux Exp $
|
29 |
+
* @link http://pear.php.net/package/File_Archive
|
30 |
+
*/
|
31 |
+
|
32 |
+
require_once $GLOBALS['bkpwp_plugin_path']."Archive/Predicate.php";
|
33 |
+
|
34 |
+
/**
|
35 |
+
* Evaluates to true iif the predicate given in parameter evaluates to false
|
36 |
+
*
|
37 |
+
* @see File_Archive_Predicate, File_Archive_Reader_Filter
|
38 |
+
*/
|
39 |
+
class File_Archive_Predicate_Not extends File_Archive_Predicate
|
40 |
+
{
|
41 |
+
var $pred;
|
42 |
+
function File_Archive_Predicate_Not($pred)
|
43 |
+
{
|
44 |
+
$this->pred = $pred;
|
45 |
+
}
|
46 |
+
/**
|
47 |
+
* @see File_Archive_Predicate::isTrue()
|
48 |
+
*/
|
49 |
+
function isTrue(&$source)
|
50 |
+
{
|
51 |
+
return !$this->pred->isTrue($source);
|
52 |
+
}
|
53 |
+
}
|
54 |
+
|
55 |
+
?>
|
Archive/Predicate/Or.php
ADDED
@@ -0,0 +1,85 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
|
3 |
+
|
4 |
+
/**
|
5 |
+
* Evaluates to true iif one at least of the predicates
|
6 |
+
* given as constructor parameters evaluate to true
|
7 |
+
*
|
8 |
+
* PHP versions 4 and 5
|
9 |
+
*
|
10 |
+
* This library is free software; you can redistribute it and/or
|
11 |
+
* modify it under the terms of the GNU Lesser General Public
|
12 |
+
* License as published by the Free Software Foundation; either
|
13 |
+
* version 2.1 of the License, or (at your option) any later version.
|
14 |
+
*
|
15 |
+
* This library is distributed in the hope that it will be useful,
|
16 |
+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
17 |
+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
18 |
+
* Lesser General Public License for more details.
|
19 |
+
*
|
20 |
+
* You should have received a copy of the GNU Lesser General Public
|
21 |
+
* License along with this library; if not, write to the Free Software
|
22 |
+
* Foundation, Inc., 59 Temple Place, Suite 330,Boston,MA 02111-1307 USA
|
23 |
+
*
|
24 |
+
* @category File Formats
|
25 |
+
* @package File_Archive
|
26 |
+
* @author Vincent Lascaux <vincentlascaux@php.net>
|
27 |
+
* @copyright 1997-2005 The PHP Group
|
28 |
+
* @license http://www.gnu.org/copyleft/lesser.html LGPL
|
29 |
+
* @version CVS: $Id: Or.php,v 1.8 2005/04/21 10:01:47 vincentlascaux Exp $
|
30 |
+
* @link http://pear.php.net/package/File_Archive
|
31 |
+
*/
|
32 |
+
|
33 |
+
require_once $GLOBALS['bkpwp_plugin_path']."Archive/Predicate.php";
|
34 |
+
|
35 |
+
/**
|
36 |
+
* Evaluates to true iif one at least of the predicates
|
37 |
+
* given as constructor parameters evaluate to true
|
38 |
+
*
|
39 |
+
* @see File_Archive_Predicate, File_Archive_Reader_Filter
|
40 |
+
*/
|
41 |
+
class File_Archive_Predicate_Or extends File_Archive_Predicate
|
42 |
+
{
|
43 |
+
/**
|
44 |
+
* @var Array List of File_Archive_Predicate objects given as an argument
|
45 |
+
* @access private
|
46 |
+
*/
|
47 |
+
var $preds;
|
48 |
+
|
49 |
+
/**
|
50 |
+
* Build the predicate using the optional File_Archive_Predicates given as
|
51 |
+
* arguments
|
52 |
+
*
|
53 |
+
* Example:
|
54 |
+
* new File_Archive_Predicate_And($pred1, $pred2, $pred3)
|
55 |
+
*/
|
56 |
+
function File_Archive_Predicate_And()
|
57 |
+
{
|
58 |
+
$this->preds = func_get_args();
|
59 |
+
}
|
60 |
+
|
61 |
+
/**
|
62 |
+
* Add a new predicate to the list
|
63 |
+
*
|
64 |
+
* @param File_Archive_Predicate The predicate to add
|
65 |
+
*/
|
66 |
+
function addPredicate($pred)
|
67 |
+
{
|
68 |
+
$this->preds[] = $pred;
|
69 |
+
}
|
70 |
+
|
71 |
+
/**
|
72 |
+
* @see File_Archive_Predicate::isTrue()
|
73 |
+
*/
|
74 |
+
function isTrue(&$source)
|
75 |
+
{
|
76 |
+
foreach ($this->preds as $p) {
|
77 |
+
if ($p->isTrue($source)) {
|
78 |
+
return true;
|
79 |
+
}
|
80 |
+
}
|
81 |
+
return false;
|
82 |
+
}
|
83 |
+
}
|
84 |
+
|
85 |
+
?>
|
Archive/Predicate/True.php
ADDED
@@ -0,0 +1,45 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
|
3 |
+
|
4 |
+
/**
|
5 |
+
* Always evaluate to true
|
6 |
+
*
|
7 |
+
* PHP versions 4 and 5
|
8 |
+
*
|
9 |
+
* This library is free software; you can redistribute it and/or
|
10 |
+
* modify it under the terms of the GNU Lesser General Public
|
11 |
+
* License as published by the Free Software Foundation; either
|
12 |
+
* version 2.1 of the License, or (at your option) any later version.
|
13 |
+
*
|
14 |
+
* This library is distributed in the hope that it will be useful,
|
15 |
+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
16 |
+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
17 |
+
* Lesser General Public License for more details.
|
18 |
+
*
|
19 |
+
* You should have received a copy of the GNU Lesser General Public
|
20 |
+
* License along with this library; if not, write to the Free Software
|
21 |
+
* Foundation, Inc., 59 Temple Place, Suite 330,Boston,MA 02111-1307 USA
|
22 |
+
*
|
23 |
+
* @category File Formats
|
24 |
+
* @package File_Archive
|
25 |
+
* @author Vincent Lascaux <vincentlascaux@php.net>
|
26 |
+
* @copyright 1997-2005 The PHP Group
|
27 |
+
* @license http://www.gnu.org/copyleft/lesser.html LGPL
|
28 |
+
* @version CVS: $Id: True.php,v 1.5 2005/04/21 10:01:47 vincentlascaux Exp $
|
29 |
+
* @link http://pear.php.net/package/File_Archive
|
30 |
+
*/
|
31 |
+
|
32 |
+
require_once $GLOBALS['bkpwp_plugin_path']."Archive/Predicate.php";
|
33 |
+
|
34 |
+
/**
|
35 |
+
* Always evaluate to true
|
36 |
+
*/
|
37 |
+
class File_Archive_Predicate_True extends File_Archive_Predicate
|
38 |
+
{
|
39 |
+
/**
|
40 |
+
* @see File_Archive_Predicate::isTrue()
|
41 |
+
*/
|
42 |
+
function isTrue(&$source) { return true; }
|
43 |
+
}
|
44 |
+
|
45 |
+
?>
|
Archive/Reader.php
ADDED
@@ -0,0 +1,416 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
|
3 |
+
|
4 |
+
/**
|
5 |
+
* Abstract base class for all the readers
|
6 |
+
*
|
7 |
+
* A reader is a compilation of serveral files that can be read
|
8 |
+
*
|
9 |
+
* PHP versions 4 and 5
|
10 |
+
*
|
11 |
+
* This library is free software; you can redistribute it and/or
|
12 |
+
* modify it under the terms of the GNU Lesser General Public
|
13 |
+
* License as published by the Free Software Foundation; either
|
14 |
+
* version 2.1 of the License, or (at your option) any later version.
|
15 |
+
*
|
16 |
+
* This library is distributed in the hope that it will be useful,
|
17 |
+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
18 |
+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
19 |
+
* Lesser General Public License for more details.
|
20 |
+
*
|
21 |
+
* You should have received a copy of the GNU Lesser General Public
|
22 |
+
* License along with this library; if not, write to the Free Software
|
23 |
+
* Foundation, Inc., 59 Temple Place, Suite 330,Boston,MA 02111-1307 USA
|
24 |
+
*
|
25 |
+
* @category File Formats
|
26 |
+
* @package File_Archive
|
27 |
+
* @author Vincent Lascaux <vincentlascaux@php.net>
|
28 |
+
* @copyright 1997-2005 The PHP Group
|
29 |
+
* @license http://www.gnu.org/copyleft/lesser.html LGPL
|
30 |
+
* @version CVS: $Id: Reader.php,v 1.33 2005/07/07 12:24:57 vincentlascaux Exp $
|
31 |
+
* @link http://pear.php.net/package/File_Archive
|
32 |
+
*/
|
33 |
+
|
34 |
+
require_once $GLOBALS['bkpwp_plugin_path']."PEAR.php";
|
35 |
+
|
36 |
+
/**
|
37 |
+
* Abstract base class for all the readers
|
38 |
+
*
|
39 |
+
* A reader is a compilation of serveral files that can be read
|
40 |
+
*/
|
41 |
+
class File_Archive_Reader
|
42 |
+
{
|
43 |
+
/**
|
44 |
+
* Move to the next file in the reader
|
45 |
+
*
|
46 |
+
* @return bool false iif no more files are available
|
47 |
+
*/
|
48 |
+
function next()
|
49 |
+
{
|
50 |
+
return false;
|
51 |
+
}
|
52 |
+
|
53 |
+
/**
|
54 |
+
* Move to the next file whose name is in directory $filename
|
55 |
+
* or is exactly $filename
|
56 |
+
*
|
57 |
+
* @param string $filename Name of the file to find in the archive
|
58 |
+
* @param bool $close If true, close the reader and search from the first file
|
59 |
+
* @return bool whether the file was found in the archive or not
|
60 |
+
*/
|
61 |
+
function select($filename, $close = true)
|
62 |
+
{
|
63 |
+
$std = $this->getStandardURL($filename);
|
64 |
+
|
65 |
+
if ($close) {
|
66 |
+
$error = $this->close();
|
67 |
+
if (PEAR::isError($error)) {
|
68 |
+
return $error;
|
69 |
+
}
|
70 |
+
}
|
71 |
+
while (($error = $this->next()) === true) {
|
72 |
+
$sourceName = $this->getFilename();
|
73 |
+
if (
|
74 |
+
empty($std) ||
|
75 |
+
|
76 |
+
//$std is a file
|
77 |
+
$std == $sourceName ||
|
78 |
+
|
79 |
+
//$std is a directory
|
80 |
+
strncmp($std.'/', $sourceName, strlen($std)+1) == 0
|
81 |
+
) {
|
82 |
+
return true;
|
83 |
+
}
|
84 |
+
}
|
85 |
+
return $error;
|
86 |
+
}
|
87 |
+
|
88 |
+
/**
|
89 |
+
* Returns the standard path
|
90 |
+
* Changes \ to /
|
91 |
+
* Removes the .. and . from the URL
|
92 |
+
* @param string $path a valid URL that may contain . or .. and \
|
93 |
+
* @static
|
94 |
+
*/
|
95 |
+
function getStandardURL($path)
|
96 |
+
{
|
97 |
+
if ($path == '.') {
|
98 |
+
return '';
|
99 |
+
}
|
100 |
+
$std = str_replace("\\", "/", $path);
|
101 |
+
while ($std != ($std = preg_replace("/[^\/:?]+\/\.\.\//", "", $std))) ;
|
102 |
+
$std = str_replace("/./", "", $std);
|
103 |
+
if (strncmp($std, "./", 2) == 0) {
|
104 |
+
return substr($std, 2);
|
105 |
+
} else {
|
106 |
+
return $std;
|
107 |
+
}
|
108 |
+
}
|
109 |
+
|
110 |
+
/**
|
111 |
+
* Returns the name of the file currently read by the reader
|
112 |
+
*
|
113 |
+
* Warning: undefined behaviour if no call to next have been
|
114 |
+
* done or if last call to next has returned false
|
115 |
+
*
|
116 |
+
* @return string Name of the current file
|
117 |
+
*/
|
118 |
+
function getFilename()
|
119 |
+
{
|
120 |
+
return PEAR::raiseError("Reader abstract function call (getFilename)");
|
121 |
+
}
|
122 |
+
|
123 |
+
/**
|
124 |
+
* Returns the list of filenames from the current pos to the end of the source
|
125 |
+
* The source will be closed after having called this function
|
126 |
+
* This function goes through the whole archive (which may be slow).
|
127 |
+
* If you intend to work on the reader, doing it in one pass would be faster
|
128 |
+
*
|
129 |
+
* @return array filenames from the current pos to the end of the source
|
130 |
+
*/
|
131 |
+
function getFileList()
|
132 |
+
{
|
133 |
+
$result = array();
|
134 |
+
while ( ($error = $this->next()) === true) {
|
135 |
+
$result[] = $this->getFilename();
|
136 |
+
}
|
137 |
+
$this->close();
|
138 |
+
if (PEAR::isError($error)) {
|
139 |
+
return $error;
|
140 |
+
} else {
|
141 |
+
return $result;
|
142 |
+
}
|
143 |
+
}
|
144 |
+
|
145 |
+
/**
|
146 |
+
* Returns an array of statistics about the file
|
147 |
+
* (see the PHP stat function for more information)
|
148 |
+
*
|
149 |
+
* The returned array may be empty, even if readers should try
|
150 |
+
* their best to return as many data as possible
|
151 |
+
*/
|
152 |
+
function getStat() { return array(); }
|
153 |
+
|
154 |
+
/**
|
155 |
+
* Returns the MIME associated with the current file
|
156 |
+
* The default function does that by looking at the extension of the file
|
157 |
+
*/
|
158 |
+
function getMime()
|
159 |
+
{
|
160 |
+
require_once $GLOBALS['bkpwp_plugin_path']."Archive/Reader/MimeList.php";
|
161 |
+
return File_Archive_Reader_GetMime($this->getFilename());
|
162 |
+
}
|
163 |
+
|
164 |
+
/**
|
165 |
+
* If the current file of the archive is a physical file,
|
166 |
+
*
|
167 |
+
* @return the name of the physical file containing the data
|
168 |
+
* or null if no such file exists
|
169 |
+
*
|
170 |
+
* The data filename may not be the same as the filename.
|
171 |
+
*/
|
172 |
+
function getDataFilename() { return null; }
|
173 |
+
|
174 |
+
/**
|
175 |
+
* Reads some data from the current file
|
176 |
+
* If the end of the file is reached, returns null
|
177 |
+
* If $length is not specified, reads up to the end of the file
|
178 |
+
* If $length is specified reads up to $length
|
179 |
+
*/
|
180 |
+
function getData($length = -1)
|
181 |
+
{
|
182 |
+
return PEAR::raiseError("Reader abstract function call (getData)");
|
183 |
+
}
|
184 |
+
|
185 |
+
/**
|
186 |
+
* Skip some data and returns how many bytes have been skipped
|
187 |
+
* This is strictly equivalent to
|
188 |
+
* return strlen(getData($length))
|
189 |
+
* But could be far more efficient
|
190 |
+
*/
|
191 |
+
function skip($length = -1)
|
192 |
+
{
|
193 |
+
$data = $this->getData($length);
|
194 |
+
if (PEAR::isError($data)) {
|
195 |
+
return $data;
|
196 |
+
} else {
|
197 |
+
return strlen($data);
|
198 |
+
}
|
199 |
+
}
|
200 |
+
|
201 |
+
/**
|
202 |
+
* Move the current position back of a given amount of bytes.
|
203 |
+
* Not all readers may implement this function (a PEAR error will
|
204 |
+
* be returned if the reader can't rewind)
|
205 |
+
*
|
206 |
+
* @param int $length number of bytes to seek before the current pos
|
207 |
+
* or -1 to move back to the begining of the current file
|
208 |
+
* @return the number of bytes really rewinded (which may be less than
|
209 |
+
* $length if the current pos is less than $length
|
210 |
+
*/
|
211 |
+
function rewind($length = -1)
|
212 |
+
{
|
213 |
+
return PEAR::raiseError('Rewind function is not implemented on this reader');
|
214 |
+
}
|
215 |
+
|
216 |
+
/**
|
217 |
+
* Returns the current offset in the current file
|
218 |
+
*/
|
219 |
+
function tell()
|
220 |
+
{
|
221 |
+
$offset = $this->rewind();
|
222 |
+
$this->skip($offset);
|
223 |
+
return $offset;
|
224 |
+
}
|
225 |
+
|
226 |
+
/**
|
227 |
+
* Put back the reader in the state it was before the first call
|
228 |
+
* to next()
|
229 |
+
*/
|
230 |
+
function close()
|
231 |
+
{
|
232 |
+
}
|
233 |
+
|
234 |
+
/**
|
235 |
+
* Sends the current file to the Writer $writer
|
236 |
+
* The data will be sent by chunks of at most $bufferSize bytes
|
237 |
+
* If $bufferSize <= 0 (default), the blockSize option is used
|
238 |
+
*/
|
239 |
+
function sendData(&$writer, $bufferSize = 0)
|
240 |
+
{
|
241 |
+
if (PEAR::isError($writer)) {
|
242 |
+
return $writer;
|
243 |
+
}
|
244 |
+
if ($bufferSize <= 0) {
|
245 |
+
$bufferSize = File_Archive::getOption('blockSize');
|
246 |
+
}
|
247 |
+
|
248 |
+
$filename = $this->getDataFilename();
|
249 |
+
if ($filename !== null) {
|
250 |
+
$error = $writer->writeFile($filename);
|
251 |
+
if (PEAR::isError($error)) {
|
252 |
+
return $error;
|
253 |
+
}
|
254 |
+
} else {
|
255 |
+
while (($data = $this->getData($bufferSize)) !== null) {
|
256 |
+
if (PEAR::isError($data)) {
|
257 |
+
return $data;
|
258 |
+
}
|
259 |
+
$error = $writer->writeData($data);
|
260 |
+
if (PEAR::isError($error)) {
|
261 |
+
return $error;
|
262 |
+
}
|
263 |
+
}
|
264 |
+
}
|
265 |
+
}
|
266 |
+
|
267 |
+
/**
|
268 |
+
* Sends the whole reader to $writer and close the reader
|
269 |
+
*
|
270 |
+
* @param File_Archive_Writer $writer Where to write the files of the reader
|
271 |
+
* @param bool $autoClose If true, close $writer at the end of the function.
|
272 |
+
* Default value is true
|
273 |
+
* @param int $bufferSize Size of the chunks that will be sent to the writer
|
274 |
+
* If $bufferSize <= 0 (default value), the blockSize option is used
|
275 |
+
*/
|
276 |
+
function extract(&$writer, $autoClose = true, $bufferSize = 0)
|
277 |
+
{
|
278 |
+
if (PEAR::isError($writer)) {
|
279 |
+
$this->close();
|
280 |
+
return $writer;
|
281 |
+
}
|
282 |
+
|
283 |
+
while (($error = $this->next()) === true) {
|
284 |
+
if ($writer->newFileNeedsMIME()) {
|
285 |
+
$mime = $this->getMime();
|
286 |
+
} else {
|
287 |
+
$mime = null;
|
288 |
+
}
|
289 |
+
$error = $writer->newFile(
|
290 |
+
$this->getFilename(),
|
291 |
+
$this->getStat(),
|
292 |
+
$mime
|
293 |
+
);
|
294 |
+
if (PEAR::isError($error)) {
|
295 |
+
break;
|
296 |
+
}
|
297 |
+
$error = $this->sendData($writer, $bufferSize);
|
298 |
+
if (PEAR::isError($error)) {
|
299 |
+
break;
|
300 |
+
}
|
301 |
+
}
|
302 |
+
$this->close();
|
303 |
+
if ($autoClose) {
|
304 |
+
$writer->close();
|
305 |
+
}
|
306 |
+
if (PEAR::isError($error)) {
|
307 |
+
return $error;
|
308 |
+
}
|
309 |
+
}
|
310 |
+
|
311 |
+
/**
|
312 |
+
* Extract only one file (given by the URL)
|
313 |
+
*
|
314 |
+
* @param string $filename URL of the file to extract from this
|
315 |
+
* @param File_Archive_Writer $writer Where to write the file
|
316 |
+
* @param bool $autoClose If true, close $writer at the end of the function
|
317 |
+
* Default value is true
|
318 |
+
* @param int $bufferSize Size of the chunks that will be sent to the writer
|
319 |
+
* If $bufferSize <= 0 (default value), the blockSize option is used
|
320 |
+
*/
|
321 |
+
function extractFile($filename, &$writer,
|
322 |
+
$autoClose = true, $bufferSize = 0)
|
323 |
+
{
|
324 |
+
if (PEAR::isError($writer)) {
|
325 |
+
return $writer;
|
326 |
+
}
|
327 |
+
|
328 |
+
if (($error = $this->select($filename)) === true) {
|
329 |
+
$result = $this->sendData($writer, $bufferSize);
|
330 |
+
if (!PEAR::isError($result)) {
|
331 |
+
$result = true;
|
332 |
+
}
|
333 |
+
} else if ($error === false) {
|
334 |
+
$result = PEAR::raiseError("File $filename not found");
|
335 |
+
} else {
|
336 |
+
$result = $error;
|
337 |
+
}
|
338 |
+
if ($autoClose) {
|
339 |
+
$error = $writer->close();
|
340 |
+
if (PEAR::isError($error)) {
|
341 |
+
return $error;
|
342 |
+
}
|
343 |
+
}
|
344 |
+
return $result;
|
345 |
+
}
|
346 |
+
|
347 |
+
/**
|
348 |
+
* Return a writer that allows appending files to the archive
|
349 |
+
* After having called makeAppendWriter, $this is closed and should not be
|
350 |
+
* used until the returned writer is closed.
|
351 |
+
*
|
352 |
+
* @return a writer that will allow to append files to an existing archive
|
353 |
+
* @see makeWriter
|
354 |
+
*/
|
355 |
+
function makeAppendWriter()
|
356 |
+
{
|
357 |
+
require_once $GLOBALS['bkpwp_plugin_path']."Archive/Predicate/False.php";
|
358 |
+
return $this->makeWriterRemoveFiles(new File_Archive_Predicate_False());
|
359 |
+
}
|
360 |
+
|
361 |
+
/**
|
362 |
+
* Return a writer that has the same properties as the one returned by
|
363 |
+
* makeAppendWriter, but after having removed all the files that follow a
|
364 |
+
* given predicate.
|
365 |
+
* After a call to makeWriterRemoveFiles, $this is closed and should not
|
366 |
+
* be used until the returned writer is closed
|
367 |
+
*
|
368 |
+
* @param File_Archive_Predicate $pred the predicate verified by removed files
|
369 |
+
* @return File_Archive_Writer that allows to append files to the archive
|
370 |
+
*/
|
371 |
+
function makeWriterRemoveFiles($pred)
|
372 |
+
{
|
373 |
+
return PEAR::raiseError("Reader abstract function call (makeWriterRemoveFiles)");
|
374 |
+
}
|
375 |
+
|
376 |
+
/**
|
377 |
+
* Returns a writer that removes the current file
|
378 |
+
* This is a syntaxic sugar for makeWriterRemoveFiles(new File_Archive_Predicate_Current());
|
379 |
+
*/
|
380 |
+
function makeWriterRemove()
|
381 |
+
{
|
382 |
+
require_once $GLOBALS['bkpwp_plugin_path']."Archive/Predicate/Current.php";
|
383 |
+
return $this->makeWriterRemoveFiles(new File_Archive_Predicate_Current());
|
384 |
+
}
|
385 |
+
|
386 |
+
/**
|
387 |
+
* Removes the current file from the reader
|
388 |
+
*/
|
389 |
+
function remove()
|
390 |
+
{
|
391 |
+
$writer = $this->makeWriterRemove();
|
392 |
+
if (PEAR::isError($writer)) {
|
393 |
+
return $writer;
|
394 |
+
}
|
395 |
+
$writer->close();
|
396 |
+
}
|
397 |
+
|
398 |
+
/**
|
399 |
+
* Return a writer that has the same properties as the one returned by makeWriter, but after
|
400 |
+
* having removed a block of data from the current file. The writer will append data to the current file
|
401 |
+
* no data (other than the block) will be removed
|
402 |
+
*
|
403 |
+
* @param array Lengths of the blocks. The first one will be discarded, the second one kept, the third
|
404 |
+
* one discarded... If the sum of the blocks is less than the size of the file, the comportment is the
|
405 |
+
* same as if a last block was set in the array to reach the size of the file
|
406 |
+
* if $length is -1, the file is truncated from the specified pos
|
407 |
+
* It is possible to specify blocks of size 0
|
408 |
+
* @param int $seek relative pos of the block
|
409 |
+
*/
|
410 |
+
function makeWriterRemoveBlocks($blocks, $seek = 0)
|
411 |
+
{
|
412 |
+
return PEAR::raiseError("Reader abstract function call (makeWriterRemoveBlocks)");
|
413 |
+
}
|
414 |
+
}
|
415 |
+
|
416 |
+
?>
|
Archive/Reader/Ar.php
ADDED
@@ -0,0 +1,387 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Read a file saved in Ar file format
|
4 |
+
*
|
5 |
+
* PHP versions 4 and 5
|
6 |
+
*
|
7 |
+
* This library is free software; you can redistribute it and/or
|
8 |
+
* modify it under the terms of the GNU Lesser General Public
|
9 |
+
* License as published by the Free Software Foundation; either
|
10 |
+
* version 2.1 of the License, or (at your option) any later version.
|
11 |
+
*
|
12 |
+
* This library is distributed in the hope that it will be useful,
|
13 |
+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
14 |
+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
15 |
+
* Lesser General Public License for more details.
|
16 |
+
*
|
17 |
+
* You should have received a copy of the GNU Lesser General Public
|
18 |
+
* License along with this library; if not, write to the Free Software
|
19 |
+
* Foundation, Inc., 59 Temple Place, Suite 330,Boston,MA 02111-1307 USA
|
20 |
+
*
|
21 |
+
* @category File Formats
|
22 |
+
* @package File_Archive
|
23 |
+
* @author Pablo Fischer <pablo@pablo.com.mx>
|
24 |
+
* @copyright 1997-2005 The PHP Group
|
25 |
+
* @license http://www.gnu.org/copyleft/lesser.html LGPL
|
26 |
+
* @version CVS: $Id:
|
27 |
+
* @link http://pear.php.net/package/File_Archive
|
28 |
+
*/
|
29 |
+
|
30 |
+
require_once $GLOBALS['bkpwp_plugin_path']."Archive/Reader/Archive.php";
|
31 |
+
|
32 |
+
/**
|
33 |
+
* Read an Ar archive
|
34 |
+
*/
|
35 |
+
class File_Archive_Reader_Ar extends File_Archive_Reader_Archive
|
36 |
+
{
|
37 |
+
/**
|
38 |
+
* @var int The number of files to read to reach the end of the
|
39 |
+
* current ar file
|
40 |
+
*
|
41 |
+
* @access private
|
42 |
+
*/
|
43 |
+
var $_nbBytesLeft = 0;
|
44 |
+
|
45 |
+
/**
|
46 |
+
* @var int The size of the header in number of bytes
|
47 |
+
* The header is not always 60 bytes since it sometimes
|
48 |
+
* contains a long filename
|
49 |
+
* @access private
|
50 |
+
*/
|
51 |
+
var $_header = 0;
|
52 |
+
|
53 |
+
/**
|
54 |
+
* @var boolean Flag set if their is a 1 byte footer after the data
|
55 |
+
* of the current ar file
|
56 |
+
*
|
57 |
+
* @access private
|
58 |
+
*/
|
59 |
+
var $_footer = false;
|
60 |
+
|
61 |
+
/**
|
62 |
+
* @var boolean Flag that has tell us if we have read the header of the
|
63 |
+
* current file
|
64 |
+
* @access private
|
65 |
+
*/
|
66 |
+
var $_alreadyRead = false;
|
67 |
+
|
68 |
+
/**
|
69 |
+
* @var string Name of the file being read
|
70 |
+
* @access private
|
71 |
+
*/
|
72 |
+
var $_currentFilename = null;
|
73 |
+
|
74 |
+
/**
|
75 |
+
* @var string Stat properties of the file being read
|
76 |
+
* It has: name, utime, uid, gid, mode, size and data
|
77 |
+
* @access private
|
78 |
+
*/
|
79 |
+
var $_currentStat = null;
|
80 |
+
|
81 |
+
/**
|
82 |
+
* @see File_Archive_Reader::getFilename()
|
83 |
+
*/
|
84 |
+
function getFilename()
|
85 |
+
{
|
86 |
+
return $this->_currentFilename;
|
87 |
+
}
|
88 |
+
|
89 |
+
/**
|
90 |
+
* @see File_Archive_Reader::close()
|
91 |
+
*/
|
92 |
+
function close()
|
93 |
+
{
|
94 |
+
$this->_currentFilename = null;
|
95 |
+
$this->_currentStat = null;
|
96 |
+
$this->_nbBytesLeft = 0;
|
97 |
+
$this->_header = 0;
|
98 |
+
$this->_footer = false;
|
99 |
+
$this->_alreadyRead = false;
|
100 |
+
return parent::close();
|
101 |
+
}
|
102 |
+
|
103 |
+
/**
|
104 |
+
* @see File_Archive_Reader::getStat()
|
105 |
+
*/
|
106 |
+
function getStat()
|
107 |
+
{
|
108 |
+
return $this->_currentStat;
|
109 |
+
}
|
110 |
+
|
111 |
+
/**
|
112 |
+
* @see File_Archive_Reader::next()
|
113 |
+
*/
|
114 |
+
function next()
|
115 |
+
{
|
116 |
+
$error = parent::next();
|
117 |
+
if ($error !== true) {
|
118 |
+
return $error;
|
119 |
+
}
|
120 |
+
|
121 |
+
$this->source->skip(
|
122 |
+
$this->_nbBytesLeft + ($this->_footer ? 1 : 0)
|
123 |
+
);
|
124 |
+
|
125 |
+
$filename = $this->source->getDataFilename();
|
126 |
+
|
127 |
+
if (!$this->_alreadyRead) {
|
128 |
+
$header = $this->source->getData(8);
|
129 |
+
if ($header != "!<arch>\n") {
|
130 |
+
return PEAR::raiseError("File {$filename} is not a valid Ar file format (starts with $header)");
|
131 |
+
}
|
132 |
+
$this->_alreadyRead = true;
|
133 |
+
}
|
134 |
+
|
135 |
+
|
136 |
+
$name = $this->source->getData(16);
|
137 |
+
$mtime = $this->source->getData(12);
|
138 |
+
$uid = $this->source->getData(6);
|
139 |
+
$gid = $this->source->getData(6);
|
140 |
+
$mode = $this->source->getData(8);
|
141 |
+
$size = $this->source->getData(10);
|
142 |
+
$delim = $this->source->getData(2);
|
143 |
+
|
144 |
+
if ($delim === null) {
|
145 |
+
return false;
|
146 |
+
}
|
147 |
+
|
148 |
+
// All files inside should have more than 0 bytes of size
|
149 |
+
if ($size < 0) {
|
150 |
+
return PEAR::raiseError("Files must be at least one byte long");
|
151 |
+
}
|
152 |
+
|
153 |
+
$this->_footer = ($size % 2 == 1);
|
154 |
+
|
155 |
+
// if the filename starts with a length, then just read the bytes of it
|
156 |
+
if (preg_match("/\#1\/(\d+)/", $name, $matches)) {
|
157 |
+
$this->_header = 60 + $matches[1];
|
158 |
+
$name = $this->source->getData($matches[1]);
|
159 |
+
$size -= $matches[1];
|
160 |
+
} else {
|
161 |
+
// strip trailing spaces in name, so we can distinguish spaces in a filename with padding
|
162 |
+
$this->_header = 60;
|
163 |
+
$name = preg_replace ("/\s+$/", "", $name);
|
164 |
+
}
|
165 |
+
|
166 |
+
$this->_nbBytesLeft = $size;
|
167 |
+
if (empty($name) || empty($mtime) || empty($uid) ||
|
168 |
+
empty($gid) || empty($mode) || empty($size)) {
|
169 |
+
return PEAR::raiseError("An ar field is empty");
|
170 |
+
}
|
171 |
+
|
172 |
+
$this->_currentFilename = $this->getStandardURL($name);
|
173 |
+
$this->_currentStat = array(
|
174 |
+
2 => $mode,
|
175 |
+
'mode' => $mode,
|
176 |
+
4 => $uid,
|
177 |
+
'uid' => $uid,
|
178 |
+
5 => $gid,
|
179 |
+
'gid' => $gid,
|
180 |
+
7 => $size,
|
181 |
+
'size' => $size,
|
182 |
+
9 => $mtime,
|
183 |
+
'mtime' => $mtime
|
184 |
+
);
|
185 |
+
|
186 |
+
return true;
|
187 |
+
}
|
188 |
+
|
189 |
+
/**
|
190 |
+
* @see File_Archive_Reader::getData()
|
191 |
+
*/
|
192 |
+
function getData($length = -1)
|
193 |
+
{
|
194 |
+
if ($length == -1) {
|
195 |
+
$length = $this->_nbBytesLeft;
|
196 |
+
} else {
|
197 |
+
$length = min($length, $this->_nbBytesLeft);
|
198 |
+
}
|
199 |
+
if ($length == 0) {
|
200 |
+
return null;
|
201 |
+
} else {
|
202 |
+
$this->_nbBytesLeft -= $length;
|
203 |
+
$data = $this->source->getData($length);
|
204 |
+
if (PEAR::isError($data)) {
|
205 |
+
return $data;
|
206 |
+
}
|
207 |
+
if (strlen($data) != $length) {
|
208 |
+
return PEAR::raiseError('Unexpected end of Ar archive');
|
209 |
+
}
|
210 |
+
return $data;
|
211 |
+
}
|
212 |
+
}
|
213 |
+
|
214 |
+
/**
|
215 |
+
* @see File_Archive_Reader::skip
|
216 |
+
*/
|
217 |
+
function skip($length = -1)
|
218 |
+
{
|
219 |
+
if ($length == -1) {
|
220 |
+
$length = $this->_nbBytesLeft;
|
221 |
+
} else {
|
222 |
+
$length = min($length, $this->_nbBytesLeft);
|
223 |
+
}
|
224 |
+
if ($length == 0) {
|
225 |
+
return 0;
|
226 |
+
} else {
|
227 |
+
$this->_nbBytesLeft -= $length;
|
228 |
+
$skipped = $this->source->skip($length);
|
229 |
+
if (PEAR::isError($skipped)) {
|
230 |
+
return $skipped;
|
231 |
+
}
|
232 |
+
if ($skipped != $length) {
|
233 |
+
return PEAR::raiseError('Unexpected end of Ar archive');
|
234 |
+
}
|
235 |
+
return $skipped;
|
236 |
+
}
|
237 |
+
}
|
238 |
+
|
239 |
+
/**
|
240 |
+
* @see File_Archive_Reader::rewind
|
241 |
+
*/
|
242 |
+
function rewind($length = -1)
|
243 |
+
{
|
244 |
+
if ($length == -1) {
|
245 |
+
$length = $this->_currentStat[7] - $this->_nbBytesLeft;
|
246 |
+
} else {
|
247 |
+
$length = min($length, $this->_currentStat[7] - $this->_nbBytesLeft);
|
248 |
+
}
|
249 |
+
if ($length == 0) {
|
250 |
+
return 0;
|
251 |
+
} else {
|
252 |
+
$rewinded = $this->source->rewind($length);
|
253 |
+
if (!PEAR::isError($rewinded)) {
|
254 |
+
$this->_nbBytesLeft += $rewinded;
|
255 |
+
}
|
256 |
+
return $rewinded;
|
257 |
+
}
|
258 |
+
}
|
259 |
+
|
260 |
+
/**
|
261 |
+
* @see File_Archive_Reader::tell()
|
262 |
+
*/
|
263 |
+
function tell()
|
264 |
+
{
|
265 |
+
return $this->_currentStat[7] - $this->_nbBytesLeft;
|
266 |
+
}
|
267 |
+
|
268 |
+
/**
|
269 |
+
* @see File_Archive_Reader::makeWriterRemoveFiles()
|
270 |
+
*/
|
271 |
+
function makeWriterRemoveFiles($pred)
|
272 |
+
{
|
273 |
+
require_once $GLOBALS['bkpwp_plugin_path']."Archive/Writer/Ar.php";
|
274 |
+
|
275 |
+
$blocks = array();
|
276 |
+
$seek = null;
|
277 |
+
$gap = 0;
|
278 |
+
if ($this->_currentFilename !== null && $pred->isTrue($this)) {
|
279 |
+
$seek = $this->_header + $this->_currentStat[7] + ($this->_footer ? 1 : 0);
|
280 |
+
$blocks[] = $seek; //Remove this file
|
281 |
+
}
|
282 |
+
|
283 |
+
while (($error = $this->next()) === true) {
|
284 |
+
$size = $this->_header + $this->_currentStat[7] + ($this->_footer ? 1 : 0);
|
285 |
+
if ($pred->isTrue($this)) {
|
286 |
+
if ($seek === null) {
|
287 |
+
$seek = $size;
|
288 |
+
$blocks[] = $size;
|
289 |
+
} else if ($gap > 0) {
|
290 |
+
$blocks[] = $gap; //Don't remove the files between the gap
|
291 |
+
$blocks[] = $size;
|
292 |
+
$seek += $size;
|
293 |
+
} else {
|
294 |
+
$blocks[count($blocks)-1] += $size; //Also remove this file
|
295 |
+
$seek += $size;
|
296 |
+
}
|
297 |
+
$gap = 0;
|
298 |
+
} else {
|
299 |
+
if ($seek !== null) {
|
300 |
+
$seek += $size;
|
301 |
+
$gap += $size;
|
302 |
+
}
|
303 |
+
}
|
304 |
+
}
|
305 |
+
if ($seek === null) {
|
306 |
+
$seek = 0;
|
307 |
+
} else {
|
308 |
+
if ($gap == 0) {
|
309 |
+
array_pop($blocks);
|
310 |
+
} else {
|
311 |
+
$blocks[] = $gap;
|
312 |
+
}
|
313 |
+
}
|
314 |
+
|
315 |
+
$writer = new File_Archive_Writer_Ar(null,
|
316 |
+
$this->source->makeWriterRemoveBlocks($blocks, -$seek)
|
317 |
+
);
|
318 |
+
$this->close();
|
319 |
+
return $writer;
|
320 |
+
}
|
321 |
+
|
322 |
+
/**
|
323 |
+
* @see File_Archive_Reader::makeWriterRemoveBlocks()
|
324 |
+
*/
|
325 |
+
function makeWriterRemoveBlocks($blocks, $seek = 0)
|
326 |
+
{
|
327 |
+
if ($this->_currentStat === null) {
|
328 |
+
return PEAR::raiseError('No file selected');
|
329 |
+
}
|
330 |
+
|
331 |
+
$blockPos = $this->_currentStat[7] - $this->_nbBytesLeft + $seek;
|
332 |
+
|
333 |
+
$this->rewind();
|
334 |
+
$keep = false;
|
335 |
+
|
336 |
+
$data = $this->getData($blockPos);
|
337 |
+
foreach ($blocks as $length) {
|
338 |
+
if ($keep) {
|
339 |
+
$data .= $this->getData($length);
|
340 |
+
} else {
|
341 |
+
$this->skip($length);
|
342 |
+
}
|
343 |
+
$keep = !$keep;
|
344 |
+
}
|
345 |
+
if ($keep) {
|
346 |
+
$data .= $this->getData();
|
347 |
+
}
|
348 |
+
|
349 |
+
$filename = $this->_currentFilename;
|
350 |
+
$stat = $this->_currentStat;
|
351 |
+
|
352 |
+
$writer = $this->makeWriterRemove();
|
353 |
+
if (PEAR::isError($writer)) {
|
354 |
+
return $writer;
|
355 |
+
}
|
356 |
+
|
357 |
+
unset($stat[7]);
|
358 |
+
$writer->newFile($filename, $stat);
|
359 |
+
$writer->writeData($data);
|
360 |
+
return $writer;
|
361 |
+
}
|
362 |
+
|
363 |
+
/**
|
364 |
+
* @see File_Archive_Reader::makeAppendWriter
|
365 |
+
*/
|
366 |
+
function makeAppendWriter()
|
367 |
+
{
|
368 |
+
require_once $GLOBALS['bkpwp_plugin_path']."Archive/Writer/Ar.php";
|
369 |
+
|
370 |
+
while (($error = $this->next()) === true) { }
|
371 |
+
if (PEAR::isError($error)) {
|
372 |
+
$this->close();
|
373 |
+
return $error;
|
374 |
+
}
|
375 |
+
|
376 |
+
$innerWriter = $this->source->makeWriterRemoveBlocks(array());
|
377 |
+
if (PEAR::isError($innerWriter)) {
|
378 |
+
return $innerWriter;
|
379 |
+
}
|
380 |
+
|
381 |
+
unset($this->source);
|
382 |
+
$this->close();
|
383 |
+
|
384 |
+
return new File_Archive_Writer_Ar(null, $innerWriter);
|
385 |
+
}
|
386 |
+
}
|
387 |
+
?>
|
Archive/Reader/Archive.php
ADDED
@@ -0,0 +1,98 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
|
3 |
+
|
4 |
+
/**
|
5 |
+
* Base class for all the archive readers (that read from a single file)
|
6 |
+
*
|
7 |
+
* PHP versions 4 and 5
|
8 |
+
*
|
9 |
+
* This library is free software; you can redistribute it and/or
|
10 |
+
* modify it under the terms of the GNU Lesser General Public
|
11 |
+
* License as published by the Free Software Foundation; either
|
12 |
+
* version 2.1 of the License, or (at your option) any later version.
|
13 |
+
*
|
14 |
+
* This library is distributed in the hope that it will be useful,
|
15 |
+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
16 |
+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
17 |
+
* Lesser General Public License for more details.
|
18 |
+
*
|
19 |
+
* You should have received a copy of the GNU Lesser General Public
|
20 |
+
* License along with this library; if not, write to the Free Software
|
21 |
+
* Foundation, Inc., 59 Temple Place, Suite 330,Boston,MA 02111-1307 USA
|
22 |
+
*
|
23 |
+
* @category File Formats
|
24 |
+
* @package File_Archive
|
25 |
+
* @author Vincent Lascaux <vincentlascaux@php.net>
|
26 |
+
* @copyright 1997-2005 The PHP Group
|
27 |
+
* @license http://www.gnu.org/copyleft/lesser.html LGPL
|
28 |
+
* @version CVS: $Id: Archive.php,v 1.12 2005/05/23 19:25:24 vincentlascaux Exp $
|
29 |
+
* @link http://pear.php.net/package/File_Archive
|
30 |
+
*/
|
31 |
+
|
32 |
+
require_once $GLOBALS['bkpwp_plugin_path']."Archive/Reader.php";
|
33 |
+
|
34 |
+
/**
|
35 |
+
* Base class for all the archive readers (that read from a single file)
|
36 |
+
*/
|
37 |
+
class File_Archive_Reader_Archive extends File_Archive_Reader
|
38 |
+
{
|
39 |
+
/**
|
40 |
+
* @var File_Archive_Reader Single file source that contains the archive
|
41 |
+
* to uncompress
|
42 |
+
* @access protected
|
43 |
+
*/
|
44 |
+
var $source = null;
|
45 |
+
|
46 |
+
/**
|
47 |
+
* @var bool Indicate whether the $source is currently opened
|
48 |
+
* @access private
|
49 |
+
*/
|
50 |
+
var $sourceOpened = false;
|
51 |
+
|
52 |
+
/**
|
53 |
+
* The source was let in this state at the end
|
54 |
+
*
|
55 |
+
* @var bool Indicate whether the $source was given opened
|
56 |
+
* @access private
|
57 |
+
*/
|
58 |
+
var $sourceInitiallyOpened;
|
59 |
+
|
60 |
+
//ABSTRACT
|
61 |
+
/**
|
62 |
+
* @see File_Archive_Reader::next()
|
63 |
+
*
|
64 |
+
* Open the source if necessary
|
65 |
+
*/
|
66 |
+
function next()
|
67 |
+
{
|
68 |
+
if (!$this->sourceOpened && ($error = $this->source->next()) !== true) {
|
69 |
+
return $error;
|
70 |
+
}
|
71 |
+
|
72 |
+
$this->sourceOpened = true;
|
73 |
+
return true;
|
74 |
+
}
|
75 |
+
|
76 |
+
//PUBLIC
|
77 |
+
function File_Archive_Reader_Archive(&$source, $sourceOpened = false)
|
78 |
+
{
|
79 |
+
$this->source =& $source;
|
80 |
+
$this->sourceOpened = $this->sourceInitiallyOpened = $sourceOpened;
|
81 |
+
}
|
82 |
+
/**
|
83 |
+
* Close the source if it was given closed in the constructor
|
84 |
+
*
|
85 |
+
* @see File_Archive_Reader::close()
|
86 |
+
*/
|
87 |
+
function close()
|
88 |
+
{
|
89 |
+
if (!$this->sourceInitiallyOpened && $this->sourceOpened) {
|
90 |
+
$this->sourceOpened = false;
|
91 |
+
if ($this->source !== null) {
|
92 |
+
return $this->source->close();
|
93 |
+
}
|
94 |
+
}
|
95 |
+
}
|
96 |
+
}
|
97 |
+
|
98 |
+
?>
|
Archive/Reader/Bzip2.php
ADDED
@@ -0,0 +1,254 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
|
3 |
+
|
4 |
+
/**
|
5 |
+
* Uncompress a file that was compressed in the Bzip2 format
|
6 |
+
*
|
7 |
+
* PHP versions 4 and 5
|
8 |
+
*
|
9 |
+
* This library is free software; you can redistribute it and/or
|
10 |
+
* modify it under the terms of the GNU Lesser General Public
|
11 |
+
* License as published by the Free Software Foundation; either
|
12 |
+
* version 2.1 of the License, or (at your option) any later version.
|
13 |
+
*
|
14 |
+
* This library is distributed in the hope that it will be useful,
|
15 |
+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
16 |
+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
17 |
+
* Lesser General Public License for more details.
|
18 |
+
*
|
19 |
+
* You should have received a copy of the GNU Lesser General Public
|
20 |
+
* License along with this library; if not, write to the Free Software
|
21 |
+
* Foundation, Inc., 59 Temple Place, Suite 330,Boston,MA 02111-1307 USA
|
22 |
+
*
|
23 |
+
* @category File Formats
|
24 |
+
* @package File_Archive
|
25 |
+
* @author Vincent Lascaux <vincentlascaux@php.net>
|
26 |
+
* @copyright 1997-2005 The PHP Group
|
27 |
+
* @license http://www.gnu.org/copyleft/lesser.html LGPL
|
28 |
+
* @version CVS: $Id: Bzip2.php,v 1.19 2005/07/26 09:06:03 vincentlascaux Exp $
|
29 |
+
* @link http://pear.php.net/package/File_Archive
|
30 |
+
*/
|
31 |
+
|
32 |
+
require_once $GLOBALS['bkpwp_plugin_path']."Archive/Reader/Archive.php";
|
33 |
+
require_once $GLOBALS['bkpwp_plugin_path']."Archive/Writer/Files.php";
|
34 |
+
|
35 |
+
/**
|
36 |
+
* Uncompress a file that was compressed in the Bzip2 format
|
37 |
+
*/
|
38 |
+
class File_Archive_Reader_Bzip2 extends File_Archive_Reader_Archive
|
39 |
+
{
|
40 |
+
var $nbRead = 0;
|
41 |
+
var $bzfile = null;
|
42 |
+
var $tmpName = null;
|
43 |
+
var $filePos = 0;
|
44 |
+
|
45 |
+
/**
|
46 |
+
* @see File_Archive_Reader::close()
|
47 |
+
*/
|
48 |
+
function close($innerClose = true)
|
49 |
+
{
|
50 |
+
if ($this->bzfile !== null)
|
51 |
+
bzclose($this->bzfile);
|
52 |
+
if ($this->tmpName !== null)
|
53 |
+
unlink($this->tmpName);
|
54 |
+
|
55 |
+
$this->bzfile = null;
|
56 |
+
$this->tmpName = null;
|
57 |
+
$this->nbRead = 0;
|
58 |
+
$this->filePos = 0;
|
59 |
+
return parent::close($innerClose);
|
60 |
+
}
|
61 |
+
|
62 |
+
/**
|
63 |
+
* @see File_Archive_Reader::next()
|
64 |
+
*/
|
65 |
+
function next()
|
66 |
+
{
|
67 |
+
if (!parent::next()) {
|
68 |
+
return false;
|
69 |
+
}
|
70 |
+
|
71 |
+
$this->nbRead++;
|
72 |
+
if ($this->nbRead > 1) {
|
73 |
+
return false;
|
74 |
+
}
|
75 |
+
|
76 |
+
$dataFilename = $this->source->getDataFilename();
|
77 |
+
if ($dataFilename !== null)
|
78 |
+
{
|
79 |
+
$this->tmpName = null;
|
80 |
+
$this->bzfile = @bzopen($dataFilename, 'r');
|
81 |
+
if ($this->bzfile === false) {
|
82 |
+
return PEAR::raiseError("bzopen failed to open $dataFilename");
|
83 |
+
}
|
84 |
+
} else {
|
85 |
+
$this->tmpName = tempnam(File_Archive::getOption('tmpDirectory'), 'far');
|
86 |
+
|
87 |
+
//Generate the tmp data
|
88 |
+
$dest = new File_Archive_Writer_Files();
|
89 |
+
$dest->newFile($this->tmpName);
|
90 |
+
$this->source->sendData($dest);
|
91 |
+
$dest->close();
|
92 |
+
|
93 |
+
$this->bzfile = bzopen($this->tmpName, 'r');
|
94 |
+
}
|
95 |
+
|
96 |
+
return true;
|
97 |
+
}
|
98 |
+
/**
|
99 |
+
* Return the name of the single file contained in the archive
|
100 |
+
* deduced from the name of the archive (the extension is removed)
|
101 |
+
*
|
102 |
+
* @see File_Archive_Reader::getFilename()
|
103 |
+
*/
|
104 |
+
function getFilename()
|
105 |
+
{
|
106 |
+
$name = $this->source->getFilename();
|
107 |
+
$pos = strrpos($name, ".");
|
108 |
+
if ($pos === false || $pos === 0) {
|
109 |
+
return $name;
|
110 |
+
} else {
|
111 |
+
return substr($name, 0, $pos);
|
112 |
+
}
|
113 |
+
}
|
114 |
+
/**
|
115 |
+
* @see File_Archive_Reader::getData()
|
116 |
+
*/
|
117 |
+
function getData($length = -1)
|
118 |
+
{
|
119 |
+
if ($length == -1) {
|
120 |
+
$data = '';
|
121 |
+
do {
|
122 |
+
$newData = bzread($this->bzfile);
|
123 |
+
$data .= $newData;
|
124 |
+
} while ($newData != '');
|
125 |
+
$this->filePos += strlen($data);
|
126 |
+
} else if ($length == 0) {
|
127 |
+
return '';
|
128 |
+
} else {
|
129 |
+
$data = '';
|
130 |
+
|
131 |
+
//The loop is here to correct what appears to be a bzread bug
|
132 |
+
while (strlen($data) < $length) {
|
133 |
+
$newData = bzread($this->bzfile, $length - strlen($data));
|
134 |
+
if ($newData == '') {
|
135 |
+
break;
|
136 |
+
}
|
137 |
+
$data .= $newData;
|
138 |
+
}
|
139 |
+
$this->filePos += strlen($data);
|
140 |
+
}
|
141 |
+
|
142 |
+
return $data == '' ? null : $data;
|
143 |
+
}
|
144 |
+
|
145 |
+
/**
|
146 |
+
* @see File_Archive_Reader::rewind
|
147 |
+
*/
|
148 |
+
function rewind($length = -1)
|
149 |
+
{
|
150 |
+
$before = $this->filePos;
|
151 |
+
|
152 |
+
bzclose($this->bzfile);
|
153 |
+
if ($this->tmpName === null) {
|
154 |
+
$this->bzfile = bzopen($this->source->getDataFilename(), 'r');
|
155 |
+
} else {
|
156 |
+
$this->bzfile = bzopen($this->tmpName, 'r');
|
157 |
+
}
|
158 |
+
$this->filePos = 0;
|
159 |
+
|
160 |
+
if ($length != -1) {
|
161 |
+
$this->skip($before - $length);
|
162 |
+
}
|
163 |
+
return $before - $this->filePos;
|
164 |
+
}
|
165 |
+
|
166 |
+
/**
|
167 |
+
* @see File_Archive_Reader::tell()
|
168 |
+
*/
|
169 |
+
function tell()
|
170 |
+
{
|
171 |
+
return $this->filePos;
|
172 |
+
}
|
173 |
+
|
174 |
+
/**
|
175 |
+
* @see File_Archive_Reader::makeAppendWriter()
|
176 |
+
*/
|
177 |
+
function makeAppendWriter()
|
178 |
+
{
|
179 |
+
return PEAR::raiseError('Unable to append files to a bzip2 archive');
|
180 |
+
}
|
181 |
+
|
182 |
+
/**
|
183 |
+
* @see File_Archive_Reader::makeWriterRemoveFiles()
|
184 |
+
*/
|
185 |
+
function makeWriterRemoveFiles($pred)
|
186 |
+
{
|
187 |
+
return PEAR::raiseError('Unable to remove files from a bzip2 archive');
|
188 |
+
}
|
189 |
+
|
190 |
+
/**
|
191 |
+
* @see File_Archive_Reader::makeWriterRemoveBlocks()
|
192 |
+
*/
|
193 |
+
function makeWriterRemoveBlocks($blocks, $seek = 0)
|
194 |
+
{
|
195 |
+
require_once $GLOBALS['bkpwp_plugin_path']."Archive/Writer/Bzip2.php";
|
196 |
+
|
197 |
+
if ($this->nbRead == 0) {
|
198 |
+
return PEAR::raiseError('No file selected');
|
199 |
+
}
|
200 |
+
|
201 |
+
//Uncompress data to a temporary file
|
202 |
+
$tmp = tmpfile();
|
203 |
+
$expectedPos = $this->filePos + $seek;
|
204 |
+
|
205 |
+
$this->rewind();
|
206 |
+
|
207 |
+
//Read the begining of the file
|
208 |
+
while ($this->filePos < $expectedPos &&
|
209 |
+
($data = $this->getData(min($expectedPos - $this->filePos, 8192))) !== null) {
|
210 |
+
fwrite($tmp, $data);
|
211 |
+
}
|
212 |
+
|
213 |
+
$keep = false;
|
214 |
+
foreach ($blocks as $length) {
|
215 |
+
if ($keep) {
|
216 |
+
$expectedPos = $this->filePos + $length;
|
217 |
+
while ($this->filePos < $expectedPos &&
|
218 |
+
($data = $this->getData(min($expectedPos - $this->filePos, 8192))) !== null) {
|
219 |
+
fwrite($tmp, $data);
|
220 |
+
}
|
221 |
+
} else {
|
222 |
+
$this->skip($length);
|
223 |
+
}
|
224 |
+
$keep = !$keep;
|
225 |
+
}
|
226 |
+
if ($keep) {
|
227 |
+
//Read the end of the file
|
228 |
+
while(($data = $this->getData(8192)) !== null) {
|
229 |
+
fwrite($tmp, $data);
|
230 |
+
}
|
231 |
+
}
|
232 |
+
fseek($tmp, 0);
|
233 |
+
|
234 |
+
//Create the writer
|
235 |
+
$this->source->rewind();
|
236 |
+
$innerWriter = $this->source->makeWriterRemoveBlocks(array()); //Truncate the source
|
237 |
+
unset($this->source);
|
238 |
+
$writer = new File_Archive_Writer_Bzip2(null, $innerWriter);
|
239 |
+
|
240 |
+
//And compress data from the temporary file
|
241 |
+
while (!feof($tmp)) {
|
242 |
+
$data = fread($tmp, 8192);
|
243 |
+
$writer->writeData($data);
|
244 |
+
}
|
245 |
+
fclose($tmp);
|
246 |
+
|
247 |
+
//Do not close inner writer since makeWriter was called
|
248 |
+
$this->close();
|
249 |
+
|
250 |
+
return $writer;
|
251 |
+
}
|
252 |
+
}
|
253 |
+
|
254 |
+
?>
|
Archive/Reader/Cache.php
ADDED
@@ -0,0 +1,262 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
|
3 |
+
|
4 |
+
/**
|
5 |
+
* This reader caches the files of another reader
|
6 |
+
* It allow fast access to files. This is usefull if the access to the reader
|
7 |
+
* is slow (HTTP, FTP...), but will need more IO if the file is only extracted
|
8 |
+
*
|
9 |
+
* PHP versions 4 and 5
|
10 |
+
*
|
11 |
+
* This library is free software; you can redistribute it and/or
|
12 |
+
* modify it under the terms of the GNU Lesser General Public
|
13 |
+
* License as published by the Free Software Foundation; either
|
14 |
+
* version 2.1 of the License, or (at your option) any later version.
|
15 |
+
*
|
16 |
+
* This library is distributed in the hope that it will be useful,
|
17 |
+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
18 |
+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
19 |
+
* Lesser General Public License for more details.
|
20 |
+
*
|
21 |
+
* You should have received a copy of the GNU Lesser General Public
|
22 |
+
* License along with this library; if not, write to the Free Software
|
23 |
+
* Foundation, Inc., 59 Temple Place, Suite 330,Boston,MA 02111-1307 USA
|
24 |
+
*
|
25 |
+
* @category File Formats
|
26 |
+
* @package File_Archive
|
27 |
+
* @author Vincent Lascaux <vincentlascaux@php.net>
|
28 |
+
* @copyright 1997-2005 The PHP Group
|
29 |
+
* @license http://www.gnu.org/copyleft/lesser.html LGPL
|
30 |
+
* @version CVS: $Id: Cache.php,v 1.1 2005/07/07 12:24:58 vincentlascaux Exp $
|
31 |
+
* @link http://pear.php.net/package/File_Archive
|
32 |
+
*/
|
33 |
+
|
34 |
+
require_once $GLOBALS['bkpwp_plugin_path']."Archive/Reader.php";
|
35 |
+
|
36 |
+
/**
|
37 |
+
* This reader caches the files of another reader
|
38 |
+
* It allow fast access to files. This is usefull if the access to the reader
|
39 |
+
* is slow (HTTP, FTP...), but will need more IO if the file is only extracted
|
40 |
+
*/
|
41 |
+
class File_Archive_Reader_Cache extends File_Archive_Reader
|
42 |
+
{
|
43 |
+
var $tmpFile;
|
44 |
+
var $files = array();
|
45 |
+
var $pos = 0;
|
46 |
+
var $fromSource = true;
|
47 |
+
var $endOfSource = false;
|
48 |
+
var $source;
|
49 |
+
|
50 |
+
/**
|
51 |
+
* $source is the reader to filter
|
52 |
+
*/
|
53 |
+
function File_Archive_Reader_Cache(&$source)
|
54 |
+
{
|
55 |
+
$this->source =& $source;
|
56 |
+
$this->tmpFile = tmpfile();
|
57 |
+
}
|
58 |
+
|
59 |
+
function _writeEndOfFile()
|
60 |
+
{
|
61 |
+
$bufferSize = File_Archive::getOption('blockSize');
|
62 |
+
while (($data = $this->source->getData($bufferSize))!=null) {
|
63 |
+
fwrite($this->tmpFile, $data);
|
64 |
+
}
|
65 |
+
}
|
66 |
+
/**
|
67 |
+
* @see File_Archive_Reader::next()
|
68 |
+
*/
|
69 |
+
function next()
|
70 |
+
{
|
71 |
+
//Write the end of the current file to the temp file
|
72 |
+
if ($this->fromSource && !empty($this->files)) {
|
73 |
+
$this->_writeEndOfFile();
|
74 |
+
}
|
75 |
+
|
76 |
+
if ($this->pos+1 < count($this->files) && !$this->fromSource) {
|
77 |
+
$this->pos++;
|
78 |
+
fseek($this->tmpFile, $this->files[$this->pos]['pos'], SEEK_SET);
|
79 |
+
return true;
|
80 |
+
} else {
|
81 |
+
$this->fromSource = true;
|
82 |
+
if ($this->endOfSource) {
|
83 |
+
return false;
|
84 |
+
}
|
85 |
+
|
86 |
+
$ret = $this->source->next();
|
87 |
+
if ($ret !== true) {
|
88 |
+
$this->endOfSource = true;
|
89 |
+
$this->source->close();
|
90 |
+
return $ret;
|
91 |
+
}
|
92 |
+
|
93 |
+
$this->endOfSource = false;
|
94 |
+
fseek($this->tmpFile, 0, SEEK_END);
|
95 |
+
$this->files[] = array(
|
96 |
+
'name' => $this->source->getFilename(),
|
97 |
+
'stat' => $this->source->getStat(),
|
98 |
+
'mime' => $this->source->getMime(),
|
99 |
+
'pos' => ftell($this->tmpFile)
|
100 |
+
);
|
101 |
+
$this->pos = count($this->files)-1;
|
102 |
+
|
103 |
+
return true;
|
104 |
+
}
|
105 |
+
}
|
106 |
+
|
107 |
+
/**
|
108 |
+
* @see File_Archive_Reader::getFilename()
|
109 |
+
*/
|
110 |
+
function getFilename() { return $this->files[$this->pos]['name']; }
|
111 |
+
/**
|
112 |
+
* @see File_Archive_Reader::getStat()
|
113 |
+
*/
|
114 |
+
function getStat() { return $this->files[$this->pos]['stat']; }
|
115 |
+
/**
|
116 |
+
* @see File_Archive_Reader::getMime()
|
117 |
+
*/
|
118 |
+
function getMime() { return $this->files[$this->pos]['mime']; }
|
119 |
+
/**
|
120 |
+
* @see File_Archive_Reader::getDataFilename()
|
121 |
+
*/
|
122 |
+
function getDataFilename() { return null; }
|
123 |
+
/**
|
124 |
+
* @see File_Archive_Reader::getData()
|
125 |
+
*/
|
126 |
+
function getData($length = -1)
|
127 |
+
{
|
128 |
+
if ($this->fromSource) {
|
129 |
+
$data = $this->source->getData($length);
|
130 |
+
if (PEAR::isError($data)) {
|
131 |
+
return $data;
|
132 |
+
}
|
133 |
+
|
134 |
+
fwrite($this->tmpFile, $data);
|
135 |
+
return $data;
|
136 |
+
} else {
|
137 |
+
if ($length == 0) {
|
138 |
+
return '';
|
139 |
+
}
|
140 |
+
|
141 |
+
if ($length > 0 && $this->pos+1 < count($this->files)) {
|
142 |
+
$maxSize = $this->files[$this->pos+1]['pos'] - ftell($this->tmpFile);
|
143 |
+
if ($maxSize == 0) {
|
144 |
+
return null;
|
145 |
+
}
|
146 |
+
if ($length > $maxSize) {
|
147 |
+
$length = $maxSize;
|
148 |
+
}
|
149 |
+
return fread($this->tmpFile, $length);
|
150 |
+
} else {
|
151 |
+
$contents = '';
|
152 |
+
$blockSize = File_Archive::getOption('blockSize');
|
153 |
+
while (!feof($this->tmpFile)) {
|
154 |
+
$contents .= fread($this->tmpFile, $blockSize);
|
155 |
+
}
|
156 |
+
return $contents == '' ? null : $contents;
|
157 |
+
}
|
158 |
+
}
|
159 |
+
}
|
160 |
+
/**
|
161 |
+
* @see File_Archive_Reader::skip()
|
162 |
+
*/
|
163 |
+
function skip($length = -1)
|
164 |
+
{
|
165 |
+
if ($this->fromSource) {
|
166 |
+
return strlen($this->getData($length));
|
167 |
+
} else {
|
168 |
+
if ($length >= 0 && $this->pos+1 < count($this->files)) {
|
169 |
+
$maxSize = $this->files[$this->pos+1]['pos'] - ftell($this->tmpFile);
|
170 |
+
if ($maxSize == 0) {
|
171 |
+
return null;
|
172 |
+
}
|
173 |
+
if ($length > $maxSize) {
|
174 |
+
$length = $maxSize;
|
175 |
+
}
|
176 |
+
fseek($this->tmpFile, $length, SEEK_CUR);
|
177 |
+
return $length;
|
178 |
+
} else {
|
179 |
+
$before = ftell($this->tmpFile);
|
180 |
+
fseek($this->tmpFile, 0, SEEK_SET);
|
181 |
+
$after = fteel($this->tmpFile);
|
182 |
+
return $after - $before;
|
183 |
+
}
|
184 |
+
}
|
185 |
+
}
|
186 |
+
/**
|
187 |
+
* @see File_Archive_Reader::rewind()
|
188 |
+
*/
|
189 |
+
function rewind($length = -1)
|
190 |
+
{
|
191 |
+
if ($this->fromSource) {
|
192 |
+
$this->_writeEndOfFile();
|
193 |
+
$this->fromSource = false;
|
194 |
+
}
|
195 |
+
$before = ftell($this->tmpFile);
|
196 |
+
$pos = $this->files[$this->pos]['pos'];
|
197 |
+
fseek($this->tmpFile, $pos, SEEK_SET);
|
198 |
+
return $pos - $before;
|
199 |
+
}
|
200 |
+
/**
|
201 |
+
* @see File_Archive_Reader::tell()
|
202 |
+
*/
|
203 |
+
function tell()
|
204 |
+
{
|
205 |
+
return ftell($this->tmpFile) - $this->files[$this->pos]['pos'];
|
206 |
+
}
|
207 |
+
/**
|
208 |
+
* @see File_Archive_Reader::close()
|
209 |
+
*/
|
210 |
+
function close()
|
211 |
+
{
|
212 |
+
$this->fromSource = false;
|
213 |
+
$this->pos = 0;
|
214 |
+
fseek($this->tmpFile, 0, SEEK_SET);
|
215 |
+
}
|
216 |
+
function _closeAndReset()
|
217 |
+
{
|
218 |
+
$this->close();
|
219 |
+
|
220 |
+
fclose($this->tmpFile);
|
221 |
+
$this->tmpFile = tmpfile();
|
222 |
+
$this->endOfSource = false;
|
223 |
+
$this->files = array();
|
224 |
+
$this->source->close();
|
225 |
+
}
|
226 |
+
/**
|
227 |
+
* @see File_Archive_Reader::makeAppendWriter()
|
228 |
+
*/
|
229 |
+
function makeAppendWriter()
|
230 |
+
{
|
231 |
+
$writer = $this->source->makeAppendWriter();
|
232 |
+
if (!PEAR::isError($writer)) {
|
233 |
+
$this->_closeAndReset();
|
234 |
+
}
|
235 |
+
|
236 |
+
return $writer;
|
237 |
+
}
|
238 |
+
/**
|
239 |
+
* @see File_Archive_Reader::makeWriterRemoveFiles()
|
240 |
+
*/
|
241 |
+
function makeWriterRemoveFiles($pred)
|
242 |
+
{
|
243 |
+
$writer = $this->source->makeWriterRemoveFiles($pred);
|
244 |
+
if (!PEAR::isError($writer)) {
|
245 |
+
$this->_closeAndReset();
|
246 |
+
}
|
247 |
+
return $writer;
|
248 |
+
}
|
249 |
+
/**
|
250 |
+
* @see File_Archive_Reader::makeWriterRemoveBlocks()
|
251 |
+
*/
|
252 |
+
function makeWriterRemoveBlocks($blocks, $seek = 0)
|
253 |
+
{
|
254 |
+
$writer = $this->source->makeWriterRemoveBlocks($blocks, $seek);
|
255 |
+
if (!PEAR::isError($writer)) {
|
256 |
+
$this->_closeAndReset();
|
257 |
+
}
|
258 |
+
return $writer;
|
259 |
+
}
|
260 |
+
}
|
261 |
+
|
262 |
+
?>
|
Archive/Reader/ChangeName.php
ADDED
@@ -0,0 +1,212 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
|
3 |
+
|
4 |
+
/**
|
5 |
+
* Add a directory to the public name of all the files of a reader
|
6 |
+
*
|
7 |
+
* PHP versions 4 and 5
|
8 |
+
*
|
9 |
+
* This library is free software; you can redistribute it and/or
|
10 |
+
* modify it under the terms of the GNU Lesser General Public
|
11 |
+
* License as published by the Free Software Foundation; either
|
12 |
+
* version 2.1 of the License, or (at your option) any later version.
|
13 |
+
*
|
14 |
+
* This library is distributed in the hope that it will be useful,
|
15 |
+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
16 |
+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
17 |
+
* Lesser General Public License for more details.
|
18 |
+
*
|
19 |
+
* You should have received a copy of the GNU Lesser General Public
|
20 |
+
* License along with this library; if not, write to the Free Software
|
21 |
+
* Foundation, Inc., 59 Temple Place, Suite 330,Boston,MA 02111-1307 USA
|
22 |
+
*
|
23 |
+
* @category File Formats
|
24 |
+
* @package File_Archive
|
25 |
+
* @author Vincent Lascaux <vincentlascaux@php.net>
|
26 |
+
* @copyright 1997-2005 The PHP Group
|
27 |
+
* @license http://www.gnu.org/copyleft/lesser.html LGPL
|
28 |
+
* @version CVS: $Id: ChangeName.php,v 1.19 2005/07/09 12:54:35 vincentlascaux Exp $
|
29 |
+
* @link http://pear.php.net/package/File_Archive
|
30 |
+
*/
|
31 |
+
|
32 |
+
require_once $GLOBALS['bkpwp_plugin_path']."Archive/Reader/Relay.php";
|
33 |
+
|
34 |
+
/**
|
35 |
+
* Add a directory to the public name of all the files of a reader
|
36 |
+
*
|
37 |
+
* Example:
|
38 |
+
* If archive.tar is a file archive containing files a.txt and foo/b.txt
|
39 |
+
* new File_Archive_Reader_AddBaseName('bar',
|
40 |
+
* new File_Archive_Reader_Tar(
|
41 |
+
* new File_Archive_Reader_File('archive.tar')
|
42 |
+
* )
|
43 |
+
* ) is a reader containing files bar/a.txt and bar/foo/b.txt
|
44 |
+
*/
|
45 |
+
class File_Archive_Reader_AddBaseName extends File_Archive_Reader_Relay
|
46 |
+
{
|
47 |
+
var $baseName;
|
48 |
+
function File_Archive_Reader_AddBaseName($baseName, &$source)
|
49 |
+
{
|
50 |
+
parent::File_Archive_Reader_Relay($source);
|
51 |
+
$this->baseName = $this->getStandardURL($baseName);
|
52 |
+
}
|
53 |
+
|
54 |
+
/**
|
55 |
+
* Modify the name by adding baseName to it
|
56 |
+
*/
|
57 |
+
function modifyName($name)
|
58 |
+
{
|
59 |
+
return $this->baseName.
|
60 |
+
(empty($this->baseName) || empty($name) ? '': '/').
|
61 |
+
$name;
|
62 |
+
}
|
63 |
+
|
64 |
+
/**
|
65 |
+
* Remove baseName from the name
|
66 |
+
* Return false if the name doesn't start with baseName
|
67 |
+
*/
|
68 |
+
function unmodifyName($name)
|
69 |
+
{
|
70 |
+
if (strncmp($name, $this->baseName.'/', strlen($this->baseName)+1) == 0) {
|
71 |
+
$res = substr($name, strlen($this->baseName)+1);
|
72 |
+
if ($res === false) {
|
73 |
+
return '';
|
74 |
+
} else {
|
75 |
+
return $res;
|
76 |
+
}
|
77 |
+
} else if (empty($this->baseName)) {
|
78 |
+
return $name;
|
79 |
+
} else if ($name == $this->baseName) {
|
80 |
+
return '';
|
81 |
+
} else {
|
82 |
+
return false;
|
83 |
+
}
|
84 |
+
}
|
85 |
+
|
86 |
+
/**
|
87 |
+
* @see File_Archive_Reader::getFilename()
|
88 |
+
*/
|
89 |
+
function getFilename()
|
90 |
+
{
|
91 |
+
return $this->modifyName(parent::getFilename());
|
92 |
+
}
|
93 |
+
/**
|
94 |
+
* @see File_Archive_Reader::getFileList()
|
95 |
+
*/
|
96 |
+
function getFileList()
|
97 |
+
{
|
98 |
+
$list = parent::getFileList();
|
99 |
+
$result = array();
|
100 |
+
foreach ($list as $name) {
|
101 |
+
$result[] = $this->modifyName($name);
|
102 |
+
}
|
103 |
+
return $result;
|
104 |
+
}
|
105 |
+
/**
|
106 |
+
* @see File_Archive_Reader::select()
|
107 |
+
*/
|
108 |
+
function select($filename, $close = true)
|
109 |
+
{
|
110 |
+
$name = $this->unmodifyName($filename);
|
111 |
+
if ($name === false) {
|
112 |
+
return false;
|
113 |
+
} else {
|
114 |
+
return $this->source->select($name, $close);
|
115 |
+
}
|
116 |
+
}
|
117 |
+
}
|
118 |
+
|
119 |
+
/**
|
120 |
+
* Change a directory name to another
|
121 |
+
*
|
122 |
+
* Example:
|
123 |
+
* If archive.tar is a file archive containing files a.txt and foo/b.txt
|
124 |
+
* new File_Archive_Reader_ChangeBaseName('foo', 'bar'
|
125 |
+
* new File_Archive_Reader_Tar(
|
126 |
+
* new File_Archive_Reader_File('archive.tar')
|
127 |
+
* )
|
128 |
+
* ) is a reader containing files a.txt and bar/b.txt
|
129 |
+
*/
|
130 |
+
class File_Archive_Reader_ChangeBaseName extends File_Archive_Reader_Relay
|
131 |
+
{
|
132 |
+
var $oldBaseName;
|
133 |
+
var $newBaseName;
|
134 |
+
|
135 |
+
function File_Archive_Reader_ChangeBaseName
|
136 |
+
($oldBaseName, $newBaseName, &$source)
|
137 |
+
{
|
138 |
+
parent::File_Archive_Reader_Relay($source);
|
139 |
+
$this->oldBaseName = $this->getStandardURL($oldBaseName);
|
140 |
+
if (substr($this->oldBaseName, -1) == '/') {
|
141 |
+
$this->oldBaseName = substr($this->oldBaseName, 0, -1);
|
142 |
+
}
|
143 |
+
|
144 |
+
$this->newBaseName = $this->getStandardURL($newBaseName);
|
145 |
+
if (substr($this->newBaseName, -1) == '/') {
|
146 |
+
$this->newBaseName = substr($this->newBaseName, 0, -1);
|
147 |
+
}
|
148 |
+
}
|
149 |
+
|
150 |
+
function modifyName($name)
|
151 |
+
{
|
152 |
+
if (empty($this->oldBaseName) ||
|
153 |
+
!strncmp($name, $this->oldBaseName.'/', strlen($this->oldBaseName)+1) ||
|
154 |
+
strcmp($name, $this->oldBaseName) == 0) {
|
155 |
+
return $this->newBaseName.
|
156 |
+
(
|
157 |
+
empty($this->newBaseName) ||
|
158 |
+
strlen($name)<=strlen($this->oldBaseName)+1 ?
|
159 |
+
'' : '/'
|
160 |
+
).
|
161 |
+
substr($name, strlen($this->oldBaseName)+1);
|
162 |
+
} else {
|
163 |
+
return $name;
|
164 |
+
}
|
165 |
+
}
|
166 |
+
function unmodifyName($name)
|
167 |
+
{
|
168 |
+
if (empty($this->newBaseName) ||
|
169 |
+
!strncmp($name, $this->newBaseName.'/', strlen($this->newBaseName)+1) ||
|
170 |
+
strcmp($name, $this->newBaseName) == 0) {
|
171 |
+
return $this->oldBaseName.
|
172 |
+
(
|
173 |
+
empty($this->oldBaseName) ||
|
174 |
+
strlen($name)<=strlen($this->newBaseName)+1 ?
|
175 |
+
'' : '/'
|
176 |
+
).
|
177 |
+
substr($name, strlen($this->newBaseName)+1);
|
178 |
+
} else {
|
179 |
+
return $name;
|
180 |
+
}
|
181 |
+
}
|
182 |
+
|
183 |
+
/**
|
184 |
+
* @see File_Archive_Reader::getFilename()
|
185 |
+
*/
|
186 |
+
function getFilename()
|
187 |
+
{
|
188 |
+
return $this->modifyName(parent::getFilename());
|
189 |
+
}
|
190 |
+
/**
|
191 |
+
* @see File_Archive_Reader::getFileList()
|
192 |
+
*/
|
193 |
+
function getFileList()
|
194 |
+
{
|
195 |
+
$list = parent::getFileList();
|
196 |
+
$result = array();
|
197 |
+
foreach ($list as $name) {
|
198 |
+
$result[] = $this->modifyName($name);
|
199 |
+
}
|
200 |
+
return $result;
|
201 |
+
}
|
202 |
+
/**
|
203 |
+
* @see File_Archive_Reader::select()
|
204 |
+
*/
|
205 |
+
function select($filename, $close = true)
|
206 |
+
{
|
207 |
+
return $this->source->select($this->unmodifyName($filename));
|
208 |
+
}
|
209 |
+
|
210 |
+
}
|
211 |
+
|
212 |
+
?>
|
Archive/Reader/Concat.php
ADDED
@@ -0,0 +1,187 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
|
3 |
+
|
4 |
+
/**
|
5 |
+
* A reader that concatene the data of the files of a source
|
6 |
+
*
|
7 |
+
* PHP versions 4 and 5
|
8 |
+
*
|
9 |
+
* This library is free software; you can redistribute it and/or
|
10 |
+
* modify it under the terms of the GNU Lesser General Public
|
11 |
+
* License as published by the Free Software Foundation; either
|
12 |
+
* version 2.1 of the License, or (at your option) any later version.
|
13 |
+
*
|
14 |
+
* This library is distributed in the hope that it will be useful,
|
15 |
+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
16 |
+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
17 |
+
* Lesser General Public License for more details.
|
18 |
+
*
|
19 |
+
* You should have received a copy of the GNU Lesser General Public
|
20 |
+
* License along with this library; if not, write to the Free Software
|
21 |
+
* Foundation, Inc., 59 Temple Place, Suite 330,Boston,MA 02111-1307 USA
|
22 |
+
*
|
23 |
+
* @category File Formats
|
24 |
+
* @package File_Archive
|
25 |
+
* @author Vincent Lascaux <vincentlascaux@php.net>
|
26 |
+
* @copyright 1997-2005 The PHP Group
|
27 |
+
* @license http://www.gnu.org/copyleft/lesser.html LGPL
|
28 |
+
* @version CVS: $Id: Concat.php,v 1.17 2005/07/07 15:48:28 vincentlascaux Exp $
|
29 |
+
* @link http://pear.php.net/package/File_Archive
|
30 |
+
*/
|
31 |
+
|
32 |
+
require_once $GLOBALS['bkpwp_plugin_path']."Archive/Reader/Relay.php";
|
33 |
+
|
34 |
+
/**
|
35 |
+
* This reader provides one single file that is the concatenation of the data of
|
36 |
+
* all the files of another reader
|
37 |
+
*/
|
38 |
+
class File_Archive_Reader_Concat extends File_Archive_Reader
|
39 |
+
{
|
40 |
+
var $source;
|
41 |
+
var $filename;
|
42 |
+
var $stat;
|
43 |
+
var $mime;
|
44 |
+
var $opened = false;
|
45 |
+
var $filePos = 0;
|
46 |
+
|
47 |
+
function File_Archive_Reader_Concat(&$source, $filename,
|
48 |
+
$stat=array(), $mime=null)
|
49 |
+
{
|
50 |
+
$this->source =& $source;
|
51 |
+
$this->filename = $filename;
|
52 |
+
$this->stat = $stat;
|
53 |
+
$this->mime = $mime;
|
54 |
+
|
55 |
+
//Compute the total length
|
56 |
+
$this->stat[7] = 0;
|
57 |
+
while (($error = $source->next()) === true) {
|
58 |
+
$sourceStat = $source->getStat();
|
59 |
+
if (isset($sourceStat[7])) {
|
60 |
+
$this->stat[7] += $sourceStat[7];
|
61 |
+
} else {
|
62 |
+
unset($this->stat[7]);
|
63 |
+
break;
|
64 |
+
}
|
65 |
+
}
|
66 |
+
if (isset($this->stat[7])) {
|
67 |
+
$this->stat['size'] = $this->stat[7];
|
68 |
+
}
|
69 |
+
if (PEAR::isError($error) || PEAR::isError($source->close())) {
|
70 |
+
die("Error in File_Archive_Reader_Concat constructor ".
|
71 |
+
'('.$error->getMessage().'), cannot continue');
|
72 |
+
}
|
73 |
+
}
|
74 |
+
|
75 |
+
/**
|
76 |
+
* @see File_Archive_Reader::next()
|
77 |
+
*/
|
78 |
+
function next()
|
79 |
+
{
|
80 |
+
if (!$this->opened) {
|
81 |
+
return $this->opened = $this->source->next();
|
82 |
+
} else {
|
83 |
+
return false;
|
84 |
+
}
|
85 |
+
}
|
86 |
+
/**
|
87 |
+
* @see File_Archive_Reader::getFilename()
|
88 |
+
*/
|
89 |
+
function getFilename() { return $this->filename; }
|
90 |
+
/**
|
91 |
+
* @see File_Archive_Reader::getStat()
|
92 |
+
*/
|
93 |
+
function getStat() { return $this->stat; }
|
94 |
+
/**
|
95 |
+
* @see File_Archive_Reader::getMime()
|
96 |
+
*/
|
97 |
+
function getMime()
|
98 |
+
{
|
99 |
+
return $this->mime==null ? parent::getMime() : $this->mime;
|
100 |
+
}
|
101 |
+
/**
|
102 |
+
* @see File_Archive_Reader::getData()
|
103 |
+
*/
|
104 |
+
function getData($length = -1)
|
105 |
+
{
|
106 |
+
if ($length == 0) {
|
107 |
+
return '';
|
108 |
+
}
|
109 |
+
|
110 |
+
$result = '';
|
111 |
+
while ($length == -1 || strlen($result)<$length) {
|
112 |
+
$sourceData = $this->source->getData(
|
113 |
+
$length==-1 ? -1 : $length - strlen($result)
|
114 |
+
);
|
115 |
+
|
116 |
+
if (PEAR::isError($sourceData)) {
|
117 |
+
return $sourceData;
|
118 |
+
}
|
119 |
+
|
120 |
+
if ($sourceData === null) {
|
121 |
+
$error = $this->source->next();
|
122 |
+
if (PEAR::isError($error)) {
|
123 |
+
return $error;
|
124 |
+
}
|
125 |
+
if (!$error) {
|
126 |
+
break;
|
127 |
+
}
|
128 |
+
} else {
|
129 |
+
$result .= $sourceData;
|
130 |
+
}
|
131 |
+
}
|
132 |
+
$this->filePos += strlen($result);
|
133 |
+
return $result == '' ? null : $result;
|
134 |
+
}
|
135 |
+
/**
|
136 |
+
* @see File_Archive_Reader::skip()
|
137 |
+
*/
|
138 |
+
function skip($length = -1)
|
139 |
+
{
|
140 |
+
$skipped = 0;
|
141 |
+
while ($skipped < $length) {
|
142 |
+
$sourceSkipped = $this->source->skip($length);
|
143 |
+
if (PEAR::isError($sourceSkipped)) {
|
144 |
+
return $skipped;
|
145 |
+
}
|
146 |
+
$skipped += $sourceSkipped;
|
147 |
+
$filePos += $sourceSkipped;
|
148 |
+
}
|
149 |
+
return $skipped;
|
150 |
+
}
|
151 |
+
/**
|
152 |
+
* @see File_Archive_Reader::rewind()
|
153 |
+
*/
|
154 |
+
function rewind($length = -1)
|
155 |
+
{
|
156 |
+
//TODO: implement rewind
|
157 |
+
return parent::rewind($length);
|
158 |
+
}
|
159 |
+
|
160 |
+
/**
|
161 |
+
* @see File_Archive_Reader::tell()
|
162 |
+
*/
|
163 |
+
function tell()
|
164 |
+
{
|
165 |
+
return $this->filePos;
|
166 |
+
}
|
167 |
+
|
168 |
+
/**
|
169 |
+
* @see File_Archive_Reader::close()
|
170 |
+
*/
|
171 |
+
function close()
|
172 |
+
{
|
173 |
+
$this->opened = false;
|
174 |
+
$this->filePos = 0;
|
175 |
+
return $this->source->close();
|
176 |
+
}
|
177 |
+
|
178 |
+
/**
|
179 |
+
* @see File_Archive_Reader::makeWriter
|
180 |
+
*/
|
181 |
+
function makeWriter($fileModif = true, $seek = 0)
|
182 |
+
{
|
183 |
+
return $this->source->makeWriter($fileModif, $seek);
|
184 |
+
}
|
185 |
+
}
|
186 |
+
|
187 |
+
?>
|
Archive/Reader/Directory.php
ADDED
@@ -0,0 +1,220 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
|
3 |
+
|
4 |
+
/**
|
5 |
+
* Recursively reads a directory
|
6 |
+
*
|
7 |
+
* PHP versions 4 and 5
|
8 |
+
*
|
9 |
+
* This library is free software; you can redistribute it and/or
|
10 |
+
* modify it under the terms of the GNU Lesser General Public
|
11 |
+
* License as published by the Free Software Foundation; either
|
12 |
+
* version 2.1 of the License, or (at your option) any later version.
|
13 |
+
*
|
14 |
+
* This library is distributed in the hope that it will be useful,
|
15 |
+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
16 |
+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
17 |
+
* Lesser General Public License for more details.
|
18 |
+
*
|
19 |
+
* You should have received a copy of the GNU Lesser General Public
|
20 |
+
* License along with this library; if not, write to the Free Software
|
21 |
+
* Foundation, Inc., 59 Temple Place, Suite 330,Boston,MA 02111-1307 USA
|
22 |
+
*
|
23 |
+
* @category File Formats
|
24 |
+
* @package File_Archive
|
25 |
+
* @author Vincent Lascaux <vincentlascaux@php.net>
|
26 |
+
* @copyright 1997-2005 The PHP Group
|
27 |
+
* @license http://www.gnu.org/copyleft/lesser.html LGPL
|
28 |
+
* @version CVS: $Id: Directory.php,v 1.21 2005/07/07 12:24:58 vincentlascaux Exp $
|
29 |
+
* @link http://pear.php.net/package/File_Archive
|
30 |
+
*/
|
31 |
+
|
32 |
+
require_once $GLOBALS['bkpwp_plugin_path']."Archive/Reader/Relay.php";
|
33 |
+
require_once $GLOBALS['bkpwp_plugin_path']."Archive/Reader/File.php";
|
34 |
+
|
35 |
+
/**
|
36 |
+
* Recursively reads a directory
|
37 |
+
*/
|
38 |
+
class File_Archive_Reader_Directory extends File_Archive_Reader_Relay
|
39 |
+
{
|
40 |
+
/**
|
41 |
+
* @var String URL of the directory that must be read
|
42 |
+
* @access private
|
43 |
+
*/
|
44 |
+
var $directory;
|
45 |
+
/**
|
46 |
+
* @var Int The subdirectories will be read up to a depth of maxRecurs
|
47 |
+
* If maxRecurs == 0, the subdirectories will not be read
|
48 |
+
* If maxRecurs == -1, the depth is considered infinite
|
49 |
+
* @access private
|
50 |
+
*/
|
51 |
+
var $maxRecurs;
|
52 |
+
/**
|
53 |
+
* @var Object Handle returned by the openedDirectory function
|
54 |
+
* @access private
|
55 |
+
*/
|
56 |
+
var $directoryHandle = null;
|
57 |
+
|
58 |
+
/**
|
59 |
+
* $directory is the path of the directory that must be read
|
60 |
+
* If $maxRecurs is specified, the subdirectories will be read up to a depth
|
61 |
+
* of $maxRecurs. In particular, if $maxRecurs == 0, the subdirectories
|
62 |
+
* won't be read.
|
63 |
+
*/
|
64 |
+
function File_Archive_Reader_Directory($directory, $symbolic='',
|
65 |
+
$maxRecurs=-1)
|
66 |
+
{
|
67 |
+
parent::File_Archive_Reader_Relay($tmp = null);
|
68 |
+
$this->directory = empty($directory) ? '.' : $directory;
|
69 |
+
$this->symbolic = $this->getStandardURL($symbolic);
|
70 |
+
$this->maxRecurs = $maxRecurs;
|
71 |
+
}
|
72 |
+
|
73 |
+
/**
|
74 |
+
* @see File_Archive_Reader::close()
|
75 |
+
*/
|
76 |
+
function close()
|
77 |
+
{
|
78 |
+
$error = parent::close();
|
79 |
+
|
80 |
+
if ($this->directoryHandle !== null) {
|
81 |
+
closedir($this->directoryHandle);
|
82 |
+
$this->directoryHandle = null;
|
83 |
+
}
|
84 |
+
|
85 |
+
return $error;
|
86 |
+
}
|
87 |
+
|
88 |
+
/**
|
89 |
+
* @see File_Archive_Reader::next()
|
90 |
+
*
|
91 |
+
* The files are returned in the same order as readdir
|
92 |
+
*/
|
93 |
+
function next()
|
94 |
+
{
|
95 |
+
if ($this->directoryHandle === null) {
|
96 |
+
$this->directoryHandle = opendir($this->directory);
|
97 |
+
if (!is_resource($this->directoryHandle)) {
|
98 |
+
return PEAR::raiseError(
|
99 |
+
"Directory {$this->directory} not found"
|
100 |
+
);
|
101 |
+
}
|
102 |
+
}
|
103 |
+
|
104 |
+
while ($this->source === null ||
|
105 |
+
($error = $this->source->next()) !== true) {
|
106 |
+
|
107 |
+
if ($this->source !== null) {
|
108 |
+
$this->source->close();
|
109 |
+
}
|
110 |
+
|
111 |
+
$file = readdir($this->directoryHandle);
|
112 |
+
if ($file == '.' || $file == '..') {
|
113 |
+
continue;
|
114 |
+
}
|
115 |
+
if ($file === false) {
|
116 |
+
return false;
|
117 |
+
}
|
118 |
+
|
119 |
+
$current = $this->directory.'/'.$file;
|
120 |
+
if (is_dir($current)) {
|
121 |
+
if ($this->maxRecurs != 0) {
|
122 |
+
$this->source = new File_Archive_Reader_Directory(
|
123 |
+
$current, $file.'/', $this->maxRecurs-1
|
124 |
+
);
|
125 |
+
}
|
126 |
+
} else {
|
127 |
+
$this->source = new File_Archive_Reader_File($current, $file);
|
128 |
+
}
|
129 |
+
}
|
130 |
+
|
131 |
+
return $error;
|
132 |
+
}
|
133 |
+
|
134 |
+
/**
|
135 |
+
* @see File_Archive_Reader::getFilename()
|
136 |
+
*/
|
137 |
+
function getFilename() { return $this->symbolic . parent::getFilename(); }
|
138 |
+
|
139 |
+
/**
|
140 |
+
* @see File_Archive_Reader::makeWriterRemoveFiles()
|
141 |
+
*/
|
142 |
+
function makeWriterRemoveFiles($pred)
|
143 |
+
{
|
144 |
+
if ($source !== null && $pred->isTrue($this)) {
|
145 |
+
$toUnlink = $this->getDataFilename();
|
146 |
+
} else {
|
147 |
+
$toUnlink = null;
|
148 |
+
}
|
149 |
+
|
150 |
+
while ($this->next()) {
|
151 |
+
if ($toUnlink !== null &&
|
152 |
+
!@unlink($toUnlink)) {
|
153 |
+
return PEAR::raiseError("Unable to unlink $toUnlink");
|
154 |
+
}
|
155 |
+
$toUnlink = ($pred->isTrue($this) ? $this->getDataFilename() : null);
|
156 |
+
}
|
157 |
+
if ($toUnlink !== null &&
|
158 |
+
!@unlink("Unable to unlink $toUnlink")) {
|
159 |
+
return PEAR::raiseError($pred);
|
160 |
+
}
|
161 |
+
|
162 |
+
require_once $GLOBALS['bkpwp_plugin_path']."Archive/Writer/Files.php";
|
163 |
+
|
164 |
+
$writer = new File_Archive_Writer_Files($this->directory);
|
165 |
+
$this->close();
|
166 |
+
return $writer;
|
167 |
+
}
|
168 |
+
|
169 |
+
function &getLastSource()
|
170 |
+
{
|
171 |
+
if ($this->source === null ||
|
172 |
+
is_a($this->source, 'File_Archive_Reader_File')) {
|
173 |
+
return $this->source;
|
174 |
+
} else {
|
175 |
+
return $this->source->getLastSource();
|
176 |
+
}
|
177 |
+
}
|
178 |
+
|
179 |
+
/**
|
180 |
+
* @see File_Archive_Reader::makeWriterRemoveBlocks()
|
181 |
+
*/
|
182 |
+
function makeWriterRemoveBlocks($blocks, $seek = 0)
|
183 |
+
{
|
184 |
+
$lastSource = &$this->getLastSource();
|
185 |
+
if ($lastSource === null) {
|
186 |
+
return PEAR::raiseError('No file selected');
|
187 |
+
}
|
188 |
+
|
189 |
+
require_once $GLOBALS['bkpwp_plugin_path']."Archive/Writer/Files.php";
|
190 |
+
|
191 |
+
$writer = $lastSource->makeWriterRemoveBlocks($blocks, $seek);
|
192 |
+
if (!PEAR::isError($writer)) {
|
193 |
+
$writer->basePath = $this->directory;
|
194 |
+
$this->close();
|
195 |
+
}
|
196 |
+
|
197 |
+
return $writer;
|
198 |
+
}
|
199 |
+
|
200 |
+
/**
|
201 |
+
* @see File_Archive_Reader::makeAppendWriter
|
202 |
+
*/
|
203 |
+
function makeAppendWriter()
|
204 |
+
{
|
205 |
+
require_once $GLOBALS['bkpwp_plugin_path']."Archive/Writer/Files.php";
|
206 |
+
|
207 |
+
if ($this->source === null ||
|
208 |
+
is_a($this->source, 'File_Archive_Reader_File') ) {
|
209 |
+
$writer = new File_Archive_Writer_Files($this->directory);
|
210 |
+
} else {
|
211 |
+
$writer = $this->source->makeAppendWriter($seek);
|
212 |
+
}
|
213 |
+
|
214 |
+
$this->close();
|
215 |
+
|
216 |
+
return $writer;
|
217 |
+
}
|
218 |
+
}
|
219 |
+
|
220 |
+
?>
|
Archive/Reader/File.php
ADDED
@@ -0,0 +1,296 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
|
3 |
+
|
4 |
+
/**
|
5 |
+
* Reader that represents a single file
|
6 |
+
*
|
7 |
+
* PHP versions 4 and 5
|
8 |
+
*
|
9 |
+
* This library is free software; you can redistribute it and/or
|
10 |
+
* modify it under the terms of the GNU Lesser General Public
|
11 |
+
* License as published by the Free Software Foundation; either
|
12 |
+
* version 2.1 of the License, or (at your option) any later version.
|
13 |
+
*
|
14 |
+
* This library is distributed in the hope that it will be useful,
|
15 |
+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
16 |
+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
17 |
+
* Lesser General Public License for more details.
|
18 |
+
*
|
19 |
+
* You should have received a copy of the GNU Lesser General Public
|
20 |
+
* License along with this library; if not, write to the Free Software
|
21 |
+
* Foundation, Inc., 59 Temple Place, Suite 330,Boston,MA 02111-1307 USA
|
22 |
+
*
|
23 |
+
* @category File Formats
|
24 |
+
* @package File_Archive
|
25 |
+
* @author Vincent Lascaux <vincentlascaux@php.net>
|
26 |
+
* @copyright 1997-2005 The PHP Group
|
27 |
+
* @license http://www.gnu.org/copyleft/lesser.html LGPL
|
28 |
+
* @version CVS: $Id: File.php,v 1.30 2005/07/11 11:53:53 vincentlascaux Exp $
|
29 |
+
* @link http://pear.php.net/package/File_Archive
|
30 |
+
*/
|
31 |
+
|
32 |
+
require_once $GLOBALS['bkpwp_plugin_path']."Archive/Reader.php";
|
33 |
+
require_once $GLOBALS['bkpwp_plugin_path']."Type.php";
|
34 |
+
|
35 |
+
/**
|
36 |
+
* Reader that represents a single file
|
37 |
+
*/
|
38 |
+
class File_Archive_Reader_File extends File_Archive_Reader
|
39 |
+
{
|
40 |
+
/**
|
41 |
+
* @var object Handle to the file being read
|
42 |
+
* @access private
|
43 |
+
*/
|
44 |
+
var $handle = null;
|
45 |
+
/**
|
46 |
+
* @var string Name of the physical file being read
|
47 |
+
* @access private
|
48 |
+
*/
|
49 |
+
var $filename;
|
50 |
+
/**
|
51 |
+
* @var string Name of the file returned by the reader
|
52 |
+
* @access private
|
53 |
+
*/
|
54 |
+
var $symbolic;
|
55 |
+
/**
|
56 |
+
* @var array Stats of the file
|
57 |
+
* Will only be set after a call to $this->getStat()
|
58 |
+
* @access private
|
59 |
+
*/
|
60 |
+
var $stat = null;
|
61 |
+
/**
|
62 |
+
* @var string Mime type of the file
|
63 |
+
* Will only be set after a call to $this->getMime()
|
64 |
+
*/
|
65 |
+
var $mime = null;
|
66 |
+
/**
|
67 |
+
* @var boolean Has the file already been read
|
68 |
+
* @access private
|
69 |
+
*/
|
70 |
+
var $alreadyRead = false;
|
71 |
+
|
72 |
+
/**
|
73 |
+
* $filename is the physical file to read
|
74 |
+
* $symbolic is the name declared by the reader
|
75 |
+
* If $symbolic is not specified, $filename is assumed
|
76 |
+
*/
|
77 |
+
function File_Archive_Reader_File($filename, $symbolic = null, $mime = null)
|
78 |
+
{
|
79 |
+
$this->filename = $filename;
|
80 |
+
$this->mime = $mime;
|
81 |
+
if ($symbolic === null) {
|
82 |
+
$this->symbolic = $this->getStandardURL($filename);
|
83 |
+
} else {
|
84 |
+
$this->symbolic = $this->getStandardURL($symbolic);
|
85 |
+
}
|
86 |
+
}
|
87 |
+
/**
|
88 |
+
* @see File_Archive_Reader::close()
|
89 |
+
*
|
90 |
+
* Close the file handle
|
91 |
+
*/
|
92 |
+
function close()
|
93 |
+
{
|
94 |
+
$this->alreadyRead = false;
|
95 |
+
if ($this->handle !== null) {
|
96 |
+
fclose($this->handle);
|
97 |
+
$this->handle = null;
|
98 |
+
}
|
99 |
+
}
|
100 |
+
/**
|
101 |
+
* @see File_Archive_Reader::next()
|
102 |
+
*
|
103 |
+
* The first time next is called, it will open the file handle and return
|
104 |
+
* true. Then it will return false
|
105 |
+
* Raise an error if the file does not exist
|
106 |
+
*/
|
107 |
+
function next()
|
108 |
+
{
|
109 |
+
if ($this->alreadyRead) {
|
110 |
+
return false;
|
111 |
+
} else {
|
112 |
+
$this->alreadyRead = true;
|
113 |
+
return true;
|
114 |
+
}
|
115 |
+
}
|
116 |
+
/**
|
117 |
+
* @see File_Archive_Reader::getFilename()
|
118 |
+
*/
|
119 |
+
function getFilename() { return $this->symbolic; }
|
120 |
+
/**
|
121 |
+
* @see File_Archive_Reader::getDataFilename()
|
122 |
+
*
|
123 |
+
* Return the name of the file
|
124 |
+
*/
|
125 |
+
function getDataFilename() { return $this->filename; }
|
126 |
+
/**
|
127 |
+
* @see File_Archive_Reader::getStat() stat()
|
128 |
+
*/
|
129 |
+
function getStat()
|
130 |
+
{
|
131 |
+
if ($this->stat === null) {
|
132 |
+
$this->stat = @stat($this->filename);
|
133 |
+
|
134 |
+
//If we can't use the stat function
|
135 |
+
if ($this->stat === false) {
|
136 |
+
$this->stat = array();
|
137 |
+
}
|
138 |
+
}
|
139 |
+
return $this->stat;
|
140 |
+
}
|
141 |
+
|
142 |
+
/**
|
143 |
+
* @see File_Archive_Reader::getMime
|
144 |
+
*/
|
145 |
+
function getMime()
|
146 |
+
{
|
147 |
+
if ($this->mime === null) {
|
148 |
+
PEAR::pushErrorHandling(PEAR_ERROR_RETURN);
|
149 |
+
$this->mime = MIME_Type::autoDetect($this->getDataFilename());
|
150 |
+
PEAR::popErrorHandling();
|
151 |
+
|
152 |
+
if (PEAR::isError($this->mime)) {
|
153 |
+
$this->mime = parent::getMime();
|
154 |
+
}
|
155 |
+
}
|
156 |
+
return $this->mime;
|
157 |
+
}
|
158 |
+
|
159 |
+
/**
|
160 |
+
* Opens the file if it was not already opened
|
161 |
+
*/
|
162 |
+
function _ensureFileOpened()
|
163 |
+
{
|
164 |
+
if ($this->handle === null) {
|
165 |
+
$this->handle = @fopen($this->filename, "r");
|
166 |
+
|
167 |
+
if (!is_resource($this->handle)) {
|
168 |
+
$this->handle = null;
|
169 |
+
return PEAR::raiseError("Can't open {$this->filename} for reading");
|
170 |
+
}
|
171 |
+
if ($this->handle === false) {
|
172 |
+
$this->handle = null;
|
173 |
+
return PEAR::raiseError("File {$this->filename} not found");
|
174 |
+
}
|
175 |
+
}
|
176 |
+
}
|
177 |
+
|
178 |
+
/**
|
179 |
+
* @see File_Archive_Reader::getData()
|
180 |
+
*/
|
181 |
+
function getData($length = -1)
|
182 |
+
{
|
183 |
+
$error = $this->_ensureFileOpened();
|
184 |
+
if (PEAR::isError($error)) {
|
185 |
+
return $error;
|
186 |
+
}
|
187 |
+
|
188 |
+
if (feof($this->handle)) {
|
189 |
+
return null;
|
190 |
+
}
|
191 |
+
if ($length == -1) {
|
192 |
+
$contents = '';
|
193 |
+
$blockSize = File_Archive::getOption('blockSize');
|
194 |
+
while (!feof($this->handle)) {
|
195 |
+
$contents .= fread($this->handle, $blockSize);
|
196 |
+
}
|
197 |
+
return $contents;
|
198 |
+
} else {
|
199 |
+
if ($length == 0) {
|
200 |
+
return "";
|
201 |
+
} else {
|
202 |
+
return fread($this->handle, $length);
|
203 |
+
}
|
204 |
+
}
|
205 |
+
}
|
206 |
+
|
207 |
+
/**
|
208 |
+
* @see File_Archive_Reader::skip()
|
209 |
+
*/
|
210 |
+
function skip($length = -1)
|
211 |
+
{
|
212 |
+
$error = $this->_ensureFileOpened();
|
213 |
+
if (PEAR::isError($error)) {
|
214 |
+
return $error;
|
215 |
+
}
|
216 |
+
|
217 |
+
$before = ftell($this->handle);
|
218 |
+
if (($length == -1 && @fseek($this->handle, 0, SEEK_END) === -1) ||
|
219 |
+
($length >= 0 && @fseek($this->handle, $length, SEEK_CUR) === -1)) {
|
220 |
+
return parent::skip($length);
|
221 |
+
} else {
|
222 |
+
return ftell($this->handle) - $before;
|
223 |
+
}
|
224 |
+
}
|
225 |
+
|
226 |
+
/**
|
227 |
+
* @see File_Archive_Reader::rewind
|
228 |
+
*/
|
229 |
+
function rewind($length = -1)
|
230 |
+
{
|
231 |
+
if ($this->handle === null) {
|
232 |
+
return 0;
|
233 |
+
}
|
234 |
+
|
235 |
+
$before = ftell($this->handle);
|
236 |
+
if (($length == -1 && @fseek($this->handle, 0, SEEK_SET) === -1) ||
|
237 |
+
($length >= 0 && @fseek($this->handle, -$length, SEEK_CUR) === -1)) {
|
238 |
+
return parent::rewind($length);
|
239 |
+
} else {
|
240 |
+
return $before - ftell($this->handle);
|
241 |
+
}
|
242 |
+
}
|
243 |
+
|
244 |
+
/**
|
245 |
+
* @see File_Archive_Reader::tell()
|
246 |
+
*/
|
247 |
+
function tell()
|
248 |
+
{
|
249 |
+
if ($this->handle === null) {
|
250 |
+
return 0;
|
251 |
+
} else {
|
252 |
+
return ftell($this->handle);
|
253 |
+
}
|
254 |
+
}
|
255 |
+
|
256 |
+
|
257 |
+
/**
|
258 |
+
* @see File_Archive_Reader::makeWriterRemoveFiles()
|
259 |
+
*/
|
260 |
+
function makeWriterRemoveFiles($pred)
|
261 |
+
{
|
262 |
+
return PEAR::raiseError(
|
263 |
+
'File_Archive_Reader_File represents a single file, you cant remove it');
|
264 |
+
}
|
265 |
+
|
266 |
+
/**
|
267 |
+
* @see File_Archive_Reader::makeWriterRemoveBlocks()
|
268 |
+
*/
|
269 |
+
function makeWriterRemoveBlocks($blocks, $seek = 0)
|
270 |
+
{
|
271 |
+
require_once $GLOBALS['bkpwp_plugin_path']."Archive/Writer/Files.php";
|
272 |
+
|
273 |
+
$writer = new File_Archive_Writer_Files();
|
274 |
+
|
275 |
+
$file = $this->getDataFilename();
|
276 |
+
$pos = $this->tell();
|
277 |
+
$this->close();
|
278 |
+
|
279 |
+
$writer->openFileRemoveBlock($file, $pos + $seek, $blocks);
|
280 |
+
|
281 |
+
return $writer;
|
282 |
+
}
|
283 |
+
|
284 |
+
/**
|
285 |
+
* @see File_Archive_Reader::makeAppendWriter
|
286 |
+
*/
|
287 |
+
function makeAppendWriter()
|
288 |
+
{
|
289 |
+
return PEAR::raiseError(
|
290 |
+
'File_Archive_Reader_File represents a single file.'.
|
291 |
+
' makeAppendWriter cant be executed on it'
|
292 |
+
);
|
293 |
+
}
|
294 |
+
}
|
295 |
+
|
296 |
+
?>
|
Archive/Reader/Filter.php
ADDED
@@ -0,0 +1,90 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
|
3 |
+
|
4 |
+
/**
|
5 |
+
* Filter out the files that do not respect a given predicat
|
6 |
+
*
|
7 |
+
* PHP versions 4 and 5
|
8 |
+
*
|
9 |
+
* This library is free software; you can redistribute it and/or
|
10 |
+
* modify it under the terms of the GNU Lesser General Public
|
11 |
+
* License as published by the Free Software Foundation; either
|
12 |
+
* version 2.1 of the License, or (at your option) any later version.
|
13 |
+
*
|
14 |
+
* This library is distributed in the hope that it will be useful,
|
15 |
+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
16 |
+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
17 |
+
* Lesser General Public License for more details.
|
18 |
+
*
|
19 |
+
* You should have received a copy of the GNU Lesser General Public
|
20 |
+
* License along with this library; if not, write to the Free Software
|
21 |
+
* Foundation, Inc., 59 Temple Place, Suite 330,Boston,MA 02111-1307 USA
|
22 |
+
*
|
23 |
+
* @category File Formats
|
24 |
+
* @package File_Archive
|
25 |
+
* @author Vincent Lascaux <vincentlascaux@php.net>
|
26 |
+
* @copyright 1997-2005 The PHP Group
|
27 |
+
* @license http://www.gnu.org/copyleft/lesser.html LGPL
|
28 |
+
* @version CVS: $Id: Filter.php,v 1.10 2005/07/09 12:54:35 vincentlascaux Exp $
|
29 |
+
* @link http://pear.php.net/package/File_Archive
|
30 |
+
*/
|
31 |
+
|
32 |
+
require_once $GLOBALS['bkpwp_plugin_path']."Archive/Reader/Relay.php";
|
33 |
+
|
34 |
+
/**
|
35 |
+
* Filter out the files that do not respect a given predicat
|
36 |
+
*/
|
37 |
+
class File_Archive_Reader_Filter extends File_Archive_Reader_Relay
|
38 |
+
{
|
39 |
+
/**
|
40 |
+
* @var File_Archive_Reader_Predicat
|
41 |
+
* @access private
|
42 |
+
*/
|
43 |
+
var $predicate;
|
44 |
+
|
45 |
+
/**
|
46 |
+
* $source is the reader to filter
|
47 |
+
*/
|
48 |
+
function File_Archive_Reader_Filter($predicate, &$source)
|
49 |
+
{
|
50 |
+
parent::File_Archive_Reader_Relay($source);
|
51 |
+
$this->predicate = $predicate;
|
52 |
+
}
|
53 |
+
|
54 |
+
/**
|
55 |
+
* @see File_Archive_Reader::next()
|
56 |
+
*/
|
57 |
+
function next()
|
58 |
+
{
|
59 |
+
do {
|
60 |
+
$error = $this->source->next();
|
61 |
+
if ($error !== true) {
|
62 |
+
return $error;
|
63 |
+
}
|
64 |
+
} while (!$this->predicate->isTrue($this->source));
|
65 |
+
return true;
|
66 |
+
}
|
67 |
+
|
68 |
+
/**
|
69 |
+
* @see File_Archive_Reader::select()
|
70 |
+
*/
|
71 |
+
function select($filename, $close = true)
|
72 |
+
{
|
73 |
+
if ($close) {
|
74 |
+
$error = $this->close();
|
75 |
+
if (PEAR::isError($error)) {
|
76 |
+
return $error;
|
77 |
+
}
|
78 |
+
}
|
79 |
+
|
80 |
+
do {
|
81 |
+
$error = $this->source->select($filename, false);
|
82 |
+
if ($error !== true) {
|
83 |
+
return $error;
|
84 |
+
}
|
85 |
+
} while (!$this->predicate->isTrue($this->source));
|
86 |
+
return true;
|
87 |
+
}
|
88 |
+
}
|
89 |
+
|
90 |
+
?>
|
Archive/Reader/Gzip.php
ADDED
@@ -0,0 +1,276 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
|
3 |
+
|
4 |
+
/**
|
5 |
+
* Uncompress a file that was compressed in the Gzip format
|
6 |
+
*
|
7 |
+
* PHP versions 4 and 5
|
8 |
+
*
|
9 |
+
* This library is free software; you can redistribute it and/or
|
10 |
+
* modify it under the terms of the GNU Lesser General Public
|
11 |
+
* License as published by the Free Software Foundation; either
|
12 |
+
* version 2.1 of the License, or (at your option) any later version.
|
13 |
+
*
|
14 |
+
* This library is distributed in the hope that it will be useful,
|
15 |
+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
16 |
+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
17 |
+
* Lesser General Public License for more details.
|
18 |
+
*
|
19 |
+
* You should have received a copy of the GNU Lesser General Public
|
20 |
+
* License along with this library; if not, write to the Free Software
|
21 |
+
* Foundation, Inc., 59 Temple Place, Suite 330,Boston,MA 02111-1307 USA
|
22 |
+
*
|
23 |
+
* @category File Formats
|
24 |
+
* @package File_Archive
|
25 |
+
* @author Vincent Lascaux <vincentlascaux@php.net>
|
26 |
+
* @copyright 1997-2005 The PHP Group
|
27 |
+
* @license http://www.gnu.org/copyleft/lesser.html LGPL
|
28 |
+
* @version CVS: $Id: Gzip.php,v 1.27 2005/06/19 20:09:57 vincentlascaux Exp $
|
29 |
+
* @link http://pear.php.net/package/File_Archive
|
30 |
+
*/
|
31 |
+
|
32 |
+
require_once $GLOBALS['bkpwp_plugin_path']."Archive/Reader/Archive.php";
|
33 |
+
require_once $GLOBALS['bkpwp_plugin_path']."Archive/Writer/Files.php";
|
34 |
+
|
35 |
+
/**
|
36 |
+
* Uncompress a file that was compressed in the Gzip format
|
37 |
+
*/
|
38 |
+
class File_Archive_Reader_Gzip extends File_Archive_Reader_Archive
|
39 |
+
{
|
40 |
+
var $nbRead = 0;
|
41 |
+
var $filePos = 0;
|
42 |
+
var $gzfile = null;
|
43 |
+
var $tmpName = null;
|
44 |
+
|
45 |
+
/**
|
46 |
+
* @see File_Archive_Reader::close()
|
47 |
+
*/
|
48 |
+
function close($innerClose = true)
|
49 |
+
{
|
50 |
+
if ($this->gzfile !== null) {
|
51 |
+
gzclose($this->gzfile);
|
52 |
+
}
|
53 |
+
if ($this->tmpName !== null) {
|
54 |
+
unlink($this->tmpName);
|
55 |
+
}
|
56 |
+
|
57 |
+
$this->nbRead = 0;
|
58 |
+
$this->filePos = 0;
|
59 |
+
$this->gzfile = null;
|
60 |
+
$this->tmpName = null;
|
61 |
+
|
62 |
+
return parent::close($innerClose);
|
63 |
+
}
|
64 |
+
|
65 |
+
/**
|
66 |
+
* @see File_Archive_Reader::next()
|
67 |
+
*/
|
68 |
+
function next()
|
69 |
+
{
|
70 |
+
if (!parent::next()) {
|
71 |
+
return false;
|
72 |
+
}
|
73 |
+
|
74 |
+
$this->nbRead++;
|
75 |
+
$this->filePos = 0;
|
76 |
+
if ($this->nbRead > 1) {
|
77 |
+
return false;
|
78 |
+
}
|
79 |
+
|
80 |
+
$dataFilename = $this->source->getDataFilename();
|
81 |
+
if ($dataFilename !== null)
|
82 |
+
{
|
83 |
+
$this->tmpName = null;
|
84 |
+
$this->gzfile = gzopen($dataFilename, 'r');
|
85 |
+
} else {
|
86 |
+
$this->tmpName = tempnam(File_Archive::getOption('tmpDirectory'), 'far');
|
87 |
+
|
88 |
+
//Generate the tmp data
|
89 |
+
$dest = new File_Archive_Writer_Files();
|
90 |
+
$dest->newFile($this->tmpName);
|
91 |
+
$this->source->sendData($dest);
|
92 |
+
$dest->close();
|
93 |
+
|
94 |
+
$this->gzfile = gzopen($this->tmpName, 'r');
|
95 |
+
}
|
96 |
+
|
97 |
+
return true;
|
98 |
+
}
|
99 |
+
|
100 |
+
/**
|
101 |
+
* Return the name of the single file contained in the archive
|
102 |
+
* deduced from the name of the archive (the extension is removed)
|
103 |
+
*
|
104 |
+
* @see File_Archive_Reader::getFilename()
|
105 |
+
*/
|
106 |
+
function getFilename()
|
107 |
+
{
|
108 |
+
$name = $this->source->getFilename();
|
109 |
+
$slashPos = strrpos($name, '/');
|
110 |
+
if ($slashPos !== false) {
|
111 |
+
$name = substr($name, $slashPos+1);
|
112 |
+
}
|
113 |
+
$dotPos = strrpos($name, '.');
|
114 |
+
if ($dotPos !== false && $dotPos > 0) {
|
115 |
+
$name = substr($name, 0, $dotPos);
|
116 |
+
}
|
117 |
+
|
118 |
+
return $name;
|
119 |
+
}
|
120 |
+
|
121 |
+
/**
|
122 |
+
* @see File_Archive_Reader::getData()
|
123 |
+
*/
|
124 |
+
function getData($length = -1)
|
125 |
+
{
|
126 |
+
if ($length == -1) {
|
127 |
+
$data = '';
|
128 |
+
do
|
129 |
+
{
|
130 |
+
$newData = gzread($this->gzfile, 8192);
|
131 |
+
$data .= $newData;
|
132 |
+
} while ($newData != '');
|
133 |
+
} else if ($length == 0) {
|
134 |
+
return '';
|
135 |
+
} else {
|
136 |
+
$data = gzread($this->gzfile, $length);
|
137 |
+
}
|
138 |
+
|
139 |
+
$this->filePos += strlen($data);
|
140 |
+
return $data == '' ? null : $data;
|
141 |
+
}
|
142 |
+
|
143 |
+
/**
|
144 |
+
* @see File_Archive_Reader::skip()
|
145 |
+
*/
|
146 |
+
function skip($length = -1)
|
147 |
+
{
|
148 |
+
if($length == -1) {
|
149 |
+
do
|
150 |
+
{
|
151 |
+
$tmp = gzread($this->gzfile, 8192);
|
152 |
+
$this->filePos += strlen($tmp);
|
153 |
+
} while ($tmp != '');
|
154 |
+
} else {
|
155 |
+
if (@gzseek($this->gzfile, $this->filePos + $length) === -1) {
|
156 |
+
return parent::skip($length);
|
157 |
+
} else {
|
158 |
+
$this->filePos += $length;
|
159 |
+
return $length;
|
160 |
+
}
|
161 |
+
}
|
162 |
+
}
|
163 |
+
|
164 |
+
/**
|
165 |
+
* @see File_Archive_Reader::rewind()
|
166 |
+
*/
|
167 |
+
function rewind($length = -1)
|
168 |
+
{
|
169 |
+
if ($length == -1) {
|
170 |
+
if (@gzseek($this->gzfile, 0) === -1) {
|
171 |
+
return parent::rewind($length);
|
172 |
+
} else {
|
173 |
+
$tmp = $this->filePos;
|
174 |
+
$this->filePos = 0;
|
175 |
+
return $tmp;
|
176 |
+
}
|
177 |
+
} else {
|
178 |
+
$length = min($length, $this->filePos);
|
179 |
+
if (@gzseek($this->gzfile, $this->filePos - $length) === -1) {
|
180 |
+
return parent::rewind($length);
|
181 |
+
} else {
|
182 |
+
$this->filePos -= $length;
|
183 |
+
return $length;
|
184 |
+
}
|
185 |
+
}
|
186 |
+
}
|
187 |
+
|
188 |
+
/**
|
189 |
+
* @see File_Archive_Reader::tell()
|
190 |
+
*/
|
191 |
+
function tell()
|
192 |
+
{
|
193 |
+
return $this->filePos;
|
194 |
+
}
|
195 |
+
|
196 |
+
/**
|
197 |
+
* @see File_Archive_Reader::makeAppendWriter()
|
198 |
+
*/
|
199 |
+
function makeAppendWriter()
|
200 |
+
{
|
201 |
+
return PEAR::raiseError('Unable to append files to a gzip archive');
|
202 |
+
}
|
203 |
+
|
204 |
+
/**
|
205 |
+
* @see File_Archive_Reader::makeWriterRemoveFiles()
|
206 |
+
*/
|
207 |
+
function makeWriterRemoveFiles($pred)
|
208 |
+
{
|
209 |
+
return PEAR::raiseError('Unable to remove files from a gzip archive');
|
210 |
+
}
|
211 |
+
|
212 |
+
/**
|
213 |
+
* @see File_Archive_Reader::makeWriterRemoveBlocks()
|
214 |
+
*/
|
215 |
+
function makeWriterRemoveBlocks($blocks, $seek = 0)
|
216 |
+
{
|
217 |
+
require_once $GLOBALS['bkpwp_plugin_path']."Archive/Writer/Gzip.php";
|
218 |
+
|
219 |
+
if ($this->nbRead == 0) {
|
220 |
+
return PEAR::raiseError('No file selected');
|
221 |
+
}
|
222 |
+
|
223 |
+
//Uncompress data to a temporary file
|
224 |
+
$tmp = tmpfile();
|
225 |
+
$expectedPos = $this->filePos + $seek;
|
226 |
+
$this->rewind();
|
227 |
+
|
228 |
+
//Read the begining of the file
|
229 |
+
while ($this->filePos < $expectedPos &&
|
230 |
+
($data = $this->getData(min($expectedPos - $this->filePos, 8192))) !== null) {
|
231 |
+
fwrite($tmp, $data);
|
232 |
+
}
|
233 |
+
|
234 |
+
$keep = false;
|
235 |
+
foreach ($blocks as $length) {
|
236 |
+
if ($keep) {
|
237 |
+
$expectedPos = $this->filePos + $length;
|
238 |
+
while ($this->filePos < $expectedPos &&
|
239 |
+
($data = $this->getData(min($expectedPos - $this->filePos, 8192))) !== null) {
|
240 |
+
fwrite($tmp, $data);
|
241 |
+
}
|
242 |
+
} else {
|
243 |
+
$this->skip($length);
|
244 |
+
}
|
245 |
+
$keep = !$keep;
|
246 |
+
}
|
247 |
+
if ($keep) {
|
248 |
+
//Read the end of the file
|
249 |
+
while(($data = $this->getData(8192)) !== null) {
|
250 |
+
fwrite($tmp, $data);
|
251 |
+
}
|
252 |
+
}
|
253 |
+
fseek($tmp, 0);
|
254 |
+
|
255 |
+
//Create the writer
|
256 |
+
$this->source->rewind();
|
257 |
+
$innerWriter = $this->source->makeWriterRemoveBlocks(array()); //Truncate the source
|
258 |
+
unset($this->source);
|
259 |
+
$writer = new File_Archive_Writer_Gzip(null, $innerWriter);
|
260 |
+
|
261 |
+
//And compress data from the temporary file
|
262 |
+
while (!feof($tmp)) {
|
263 |
+
$data = fread($tmp, 8192);
|
264 |
+
$writer->writeData($data);
|
265 |
+
}
|
266 |
+
fclose($tmp);
|
267 |
+
|
268 |
+
//Do not close inner writer since makeWriter was called
|
269 |
+
$this->close();
|
270 |
+
|
271 |
+
return $writer;
|
272 |
+
}
|
273 |
+
|
274 |
+
}
|
275 |
+
|
276 |
+
?>
|
Archive/Reader/Memory.php
ADDED
@@ -0,0 +1,227 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
|
3 |
+
|
4 |
+
/**
|
5 |
+
* A reader that takes its input from a memory buffer
|
6 |
+
*
|
7 |
+
* PHP versions 4 and 5
|
8 |
+
*
|
9 |
+
* This library is free software; you can redistribute it and/or
|
10 |
+
* modify it under the terms of the GNU Lesser General Public
|
11 |
+
* License as published by the Free Software Foundation; either
|
12 |
+
* version 2.1 of the License, or (at your option) any later version.
|
13 |
+
*
|
14 |
+
* This library is distributed in the hope that it will be useful,
|
15 |
+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
16 |
+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
17 |
+
* Lesser General Public License for more details.
|
18 |
+
*
|
19 |
+
* You should have received a copy of the GNU Lesser General Public
|
20 |
+
* License along with this library; if not, write to the Free Software
|
21 |
+
* Foundation, Inc., 59 Temple Place, Suite 330,Boston,MA 02111-1307 USA
|
22 |
+
*
|
23 |
+
* @category File Formats
|
24 |
+
* @package File_Archive
|
25 |
+
* @author Vincent Lascaux <vincentlascaux@php.net>
|
26 |
+
* @copyright 1997-2005 The PHP Group
|
27 |
+
* @license http://www.gnu.org/copyleft/lesser.html LGPL
|
28 |
+
* @version CVS: $Id: Memory.php,v 1.19 2005/06/19 20:09:57 vincentlascaux Exp $
|
29 |
+
* @link http://pear.php.net/package/File_Archive
|
30 |
+
*/
|
31 |
+
|
32 |
+
require_once $GLOBALS['bkpwp_plugin_path']."Archive/Reader.php";
|
33 |
+
|
34 |
+
/**
|
35 |
+
* A reader that takes its input from a memory buffer
|
36 |
+
*/
|
37 |
+
class File_Archive_Reader_Memory extends File_Archive_Reader
|
38 |
+
{
|
39 |
+
/**
|
40 |
+
* @var String Name of the file exported by this reader
|
41 |
+
* @access private
|
42 |
+
*/
|
43 |
+
var $filename;
|
44 |
+
/**
|
45 |
+
* @var Array Stat of the file exported by this reader
|
46 |
+
* @access private
|
47 |
+
*/
|
48 |
+
var $stat;
|
49 |
+
/**
|
50 |
+
* @var String MIME type of the file exported by this reader
|
51 |
+
* @access private
|
52 |
+
*/
|
53 |
+
var $mime;
|
54 |
+
/**
|
55 |
+
* @var String Memory buffer that contains the data of the file
|
56 |
+
* @access private
|
57 |
+
*/
|
58 |
+
var $memory;
|
59 |
+
/**
|
60 |
+
* @var Int Current position in the file
|
61 |
+
* @access private
|
62 |
+
*/
|
63 |
+
var $offset = 0;
|
64 |
+
/**
|
65 |
+
* @var Boolean Has the file already been read
|
66 |
+
* @access private
|
67 |
+
*/
|
68 |
+
var $alreadyRead = false;
|
69 |
+
|
70 |
+
/**
|
71 |
+
* @param string $memory is the content of the file.
|
72 |
+
* This parameter is passed as a reference for performance
|
73 |
+
* reasons. The content should not be changer after the constructor
|
74 |
+
* @param string $filename is the name of the file
|
75 |
+
* @param array $stat are the statistics of the file. The size will be
|
76 |
+
* recomputed from $memory
|
77 |
+
* @param string $mime is the mime type of the file
|
78 |
+
*/
|
79 |
+
function File_Archive_Reader_Memory(&$memory, $filename,
|
80 |
+
$stat=array(), $mime=null)
|
81 |
+
{
|
82 |
+
$this->memory = &$memory;
|
83 |
+
$this->filename = $this->getStandardURL($filename);
|
84 |
+
$this->stat = $stat;
|
85 |
+
$this->stat[7] = $this->stat['size'] = strlen($this->memory);
|
86 |
+
$this->mime = $mime;
|
87 |
+
}
|
88 |
+
|
89 |
+
/**
|
90 |
+
* The subclass should overwrite this function to change the filename, stat
|
91 |
+
* and memory
|
92 |
+
*/
|
93 |
+
function next()
|
94 |
+
{
|
95 |
+
if ($this->alreadyRead) {
|
96 |
+
return false;
|
97 |
+
} else {
|
98 |
+
$this->alreadyRead = true;
|
99 |
+
return true;
|
100 |
+
}
|
101 |
+
}
|
102 |
+
|
103 |
+
/**
|
104 |
+
* @see File_Archive_Reader::getFilename()
|
105 |
+
*/
|
106 |
+
function getFilename() { return $this->filename; }
|
107 |
+
/**
|
108 |
+
* @see File_Archive_Reader::getStat()
|
109 |
+
*/
|
110 |
+
function getStat() { return $this->stat; }
|
111 |
+
/**
|
112 |
+
* @see File_Archive_Reader::getMime()
|
113 |
+
*/
|
114 |
+
function getMime()
|
115 |
+
{
|
116 |
+
return $this->mime==null ? parent::getMime() : $this->mime;
|
117 |
+
}
|
118 |
+
|
119 |
+
/**
|
120 |
+
* @see File_Archive_Reader::getData()
|
121 |
+
*/
|
122 |
+
function getData($length = -1)
|
123 |
+
{
|
124 |
+
if ($this->offset == strlen($this->memory)) {
|
125 |
+
return null;
|
126 |
+
}
|
127 |
+
if ($length == -1) {
|
128 |
+
$actualLength = strlen($this->memory) - $this->offset;
|
129 |
+
} else {
|
130 |
+
$actualLength = min($length, strlen($this->memory) - $this->offset);
|
131 |
+
}
|
132 |
+
$result = substr($this->memory, $this->offset, $actualLength);
|
133 |
+
$this->offset += $actualLength;
|
134 |
+
return $result;
|
135 |
+
}
|
136 |
+
|
137 |
+
/**
|
138 |
+
* @see File_Archive_Reader::skip()
|
139 |
+
*/
|
140 |
+
function skip($length = -1)
|
141 |
+
{
|
142 |
+
if ($length == -1) {
|
143 |
+
$length = strlen($this->memory) - $this->offset;
|
144 |
+
} else {
|
145 |
+
$length = min($length, strlen($this->memory) - $this->offset);
|
146 |
+
}
|
147 |
+
$this->offset += $length;
|
148 |
+
return $length;
|
149 |
+
}
|
150 |
+
|
151 |
+
/**
|
152 |
+
* @see File_Archive_Reader::rewind()
|
153 |
+
*/
|
154 |
+
function rewind($length = -1)
|
155 |
+
{
|
156 |
+
if ($length == -1) {
|
157 |
+
$tmp = $this->offset;
|
158 |
+
$this->offset = 0;
|
159 |
+
return $tmp;
|
160 |
+
} else {
|
161 |
+
$length = min($length, $this->offset);
|
162 |
+
$this->offset -= $length;
|
163 |
+
return $length;
|
164 |
+
}
|
165 |
+
}
|
166 |
+
|
167 |
+
/**
|
168 |
+
* @see File_Archive_Reader::tell()
|
169 |
+
*/
|
170 |
+
function tell()
|
171 |
+
{
|
172 |
+
return $this->offset;
|
173 |
+
}
|
174 |
+
|
175 |
+
/**
|
176 |
+
* @see File_Archive_Reader::close()
|
177 |
+
*/
|
178 |
+
function close()
|
179 |
+
{
|
180 |
+
$this->offset = 0;
|
181 |
+
$this->alreadyRead = false;
|
182 |
+
}
|
183 |
+
|
184 |
+
/**
|
185 |
+
* @see File_Archive_Reader::makeAppendWriter()
|
186 |
+
*/
|
187 |
+
function makeAppendWriter()
|
188 |
+
{
|
189 |
+
return PEAR::raiseError('Unable to append files to a memory archive');
|
190 |
+
}
|
191 |
+
|
192 |
+
/**
|
193 |
+
* @see File_Archive_Reader::makeWriterRemoveFiles()
|
194 |
+
*/
|
195 |
+
function makeWriterRemoveFiles($pred)
|
196 |
+
{
|
197 |
+
return PEAR::raiseError('Unable to remove files from a memory archive');
|
198 |
+
}
|
199 |
+
|
200 |
+
/**
|
201 |
+
* @see File_Archive_Reader::makeWriterRemoveBlocks()
|
202 |
+
*/
|
203 |
+
function makeWriterRemoveBlocks($blocks, $seek = 0)
|
204 |
+
{
|
205 |
+
require_once $GLOBALS['bkpwp_plugin_path']."Archive/Writer/Memory.php";
|
206 |
+
$data = substr($this->memory, 0, $this->offset + $seek);
|
207 |
+
$this->memory = substr($this->memory, $this->offset + $seek);
|
208 |
+
|
209 |
+
$keep = false;
|
210 |
+
foreach ($blocks as $length) {
|
211 |
+
if ($keep) {
|
212 |
+
$data .= substr($this->memory, 0, $length);
|
213 |
+
}
|
214 |
+
$this->memory = substr($this->memory, $length);
|
215 |
+
$keep = !$keep;
|
216 |
+
}
|
217 |
+
if ($keep) {
|
218 |
+
$this->memory = $data . $this->memory;
|
219 |
+
} else {
|
220 |
+
$this->memory = $data;
|
221 |
+
}
|
222 |
+
$this->close();
|
223 |
+
return new File_Archive_Writer_Memory($this->memory, strlen($this->memory));
|
224 |
+
}
|
225 |
+
}
|
226 |
+
|
227 |
+
?>
|
Archive/Reader/MimeList.php
ADDED
@@ -0,0 +1,939 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
|
3 |
+
|
4 |
+
/**
|
5 |
+
* Retrieve the MIME of a file thanks to its extension
|
6 |
+
*
|
7 |
+
* PHP versions 4 and 5
|
8 |
+
*
|
9 |
+
* This library is free software; you can redistribute it and/or
|
10 |
+
* modify it under the terms of the GNU Lesser General Public
|
11 |
+
* License as published by the Free Software Foundation; either
|
12 |
+
* version 2.1 of the License, or (at your option) any later version.
|
13 |
+
*
|
14 |
+
* This library is distributed in the hope that it will be useful,
|
15 |
+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
16 |
+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
17 |
+
* Lesser General Public License for more details.
|
18 |
+
*
|
19 |
+
* You should have received a copy of the GNU Lesser General Public
|
20 |
+
* License along with this library; if not, write to the Free Software
|
21 |
+
* Foundation, Inc., 59 Temple Place, Suite 330,Boston,MA 02111-1307 USA
|
22 |
+
*
|
23 |
+
* @category File Formats
|
24 |
+
* @package File_Archive
|
25 |
+
* @author Vincent Lascaux <vincentlascaux@php.net>
|
26 |
+
* @copyright 1997-2005 The PHP Group
|
27 |
+
* @license http://www.gnu.org/copyleft/lesser.html LGPL
|
28 |
+
* @version CVS: $Id: MimeList.php,v 1.7 2005/02/23 20:11:42 vincentlascaux Exp $
|
29 |
+
* @link http://pear.php.net/package/File_Archive
|
30 |
+
*/
|
31 |
+
|
32 |
+
/**
|
33 |
+
* Returns the MIME of the filename, deducted from its extension
|
34 |
+
* If the extension is unknown, returns "application/octet-stream"
|
35 |
+
*/
|
36 |
+
function File_Archive_Reader_GetMime($filename)
|
37 |
+
{
|
38 |
+
$pos = strrpos($filename, '.');
|
39 |
+
$extension = "";
|
40 |
+
if ($pos !== false) {
|
41 |
+
$extension = strtolower(substr($filename, $pos+1));
|
42 |
+
}
|
43 |
+
|
44 |
+
switch($extension) {
|
45 |
+
case '3dmf':
|
46 |
+
return 'x-world/x-3dmf';
|
47 |
+
case 'a':
|
48 |
+
return 'application/octet-stream';
|
49 |
+
case 'aab':
|
50 |
+
return 'application/x-authorware-bin';
|
51 |
+
case 'aam':
|
52 |
+
return 'application/x-authorware-map';
|
53 |
+
case 'aas':
|
54 |
+
return 'application/x-authorware-seg';
|
55 |
+
case 'abc':
|
56 |
+
return 'text/vnd.abc';
|
57 |
+
case 'acgi':
|
58 |
+
return 'text/html';
|
59 |
+
case 'afl':
|
60 |
+
return 'video/animaflex';
|
61 |
+
case 'ai':
|
62 |
+
return 'application/postscript';
|
63 |
+
case 'aif':
|
64 |
+
return 'audio/aiff';
|
65 |
+
case 'aifc':
|
66 |
+
return 'audio/aiff';
|
67 |
+
case 'aiff':
|
68 |
+
return 'audio/aiff';
|
69 |
+
case 'aim':
|
70 |
+
return 'application/x-aim';
|
71 |
+
case 'aip':
|
72 |
+
return 'text/x-audiosoft-intra';
|
73 |
+
case 'ani':
|
74 |
+
return 'application/x-navi-animation';
|
75 |
+
case 'aos':
|
76 |
+
return 'application/x-nokia-9000-communicator-add-on-software';
|
77 |
+
case 'aps':
|
78 |
+
return 'application/mime';
|
79 |
+
case 'arc':
|
80 |
+
return 'application/octet-stream';
|
81 |
+
case 'arj':
|
82 |
+
return 'application/arj';
|
83 |
+
case 'art':
|
84 |
+
return 'image/x-jg';
|
85 |
+
case 'asf':
|
86 |
+
return 'video/x-ms-asf';
|
87 |
+
case 'asm':
|
88 |
+
return 'text/x-asm';
|
89 |
+
case 'asp':
|
90 |
+
return 'text/asp';
|
91 |
+
case 'asx':
|
92 |
+
return 'application/x-mplayer2';
|
93 |
+
case 'au':
|
94 |
+
return 'audio/basic';
|
95 |
+
case 'avi':
|
96 |
+
return 'application/x-troff-msvideo';
|
97 |
+
case 'avs':
|
98 |
+
return 'video/avs-video';
|
99 |
+
case 'bcpio':
|
100 |
+
return 'application/x-bcpio';
|
101 |
+
case 'bin':
|
102 |
+
return 'application/x-binary';
|
103 |
+
case 'bm':
|
104 |
+
return 'image/bmp';
|
105 |
+
case 'bmp':
|
106 |
+
return 'image/bmp';
|
107 |
+
case 'boo':
|
108 |
+
return 'application/book';
|
109 |
+
case 'book':
|
110 |
+
return 'application/book';
|
111 |
+
case 'boz':
|
112 |
+
return 'application/x-bzip2';
|
113 |
+
case 'bsh':
|
114 |
+
return 'application/x-bsh';
|
115 |
+
case 'bz':
|
116 |
+
return 'application/x-bzip';
|
117 |
+
case 'bz2':
|
118 |
+
return 'application/x-bzip2';
|
119 |
+
case 'c':
|
120 |
+
return 'text/plain';
|
121 |
+
case 'c++':
|
122 |
+
return 'text/plain';
|
123 |
+
case 'cat':
|
124 |
+
return 'application/vnd.ms-pki.seccat';
|
125 |
+
case 'cc':
|
126 |
+
return 'text/plain';
|
127 |
+
case 'ccad':
|
128 |
+
return 'application/clariscad';
|
129 |
+
case 'cco':
|
130 |
+
return 'application/x-cocoa';
|
131 |
+
case 'cdf':
|
132 |
+
return 'application/cdf';
|
133 |
+
case 'cer':
|
134 |
+
return 'application/pkix-cert';
|
135 |
+
case 'cha':
|
136 |
+
return 'application/x-chat';
|
137 |
+
case 'chat':
|
138 |
+
return 'application/x-chat';
|
139 |
+
case 'class':
|
140 |
+
return 'application/java';
|
141 |
+
case 'com':
|
142 |
+
return 'application/octet-stream';
|
143 |
+
case 'conf':
|
144 |
+
return 'text/plain';
|
145 |
+
case 'cpio':
|
146 |
+
return 'application/x-cpio';
|
147 |
+
case 'cpp':
|
148 |
+
return 'text/x-c';
|
149 |
+
case 'cpt':
|
150 |
+
return 'application/mac-compactpro';
|
151 |
+
case 'crl':
|
152 |
+
return 'application/pkcs-crl';
|
153 |
+
case 'csh':
|
154 |
+
return 'application/x-csh';
|
155 |
+
case 'css':
|
156 |
+
return 'text/css';
|
157 |
+
case 'cxx':
|
158 |
+
return 'text/plain';
|
159 |
+
case 'dcr':
|
160 |
+
return 'application/x-director';
|
161 |
+
case 'deepv':
|
162 |
+
return 'application/x-deepv';
|
163 |
+
case 'def':
|
164 |
+
return 'text/plain';
|
165 |
+
case 'der':
|
166 |
+
return 'application/x-x509-ca-cert';
|
167 |
+
case 'dif':
|
168 |
+
return 'video/x-dv';
|
169 |
+
case 'dir':
|
170 |
+
return 'application/x-director';
|
171 |
+
case 'dl':
|
172 |
+
return 'video/dl';
|
173 |
+
case 'doc':
|
174 |
+
return 'application/msword';
|
175 |
+
case 'dot':
|
176 |
+
return 'application/msword';
|
177 |
+
case 'dp':
|
178 |
+
return 'application/commonground';
|
179 |
+
case 'drw':
|
180 |
+
return 'application/drafting';
|
181 |
+
case 'dump':
|
182 |
+
return 'application/octet-stream';
|
183 |
+
case 'dv':
|
184 |
+
return 'video/x-dv';
|
185 |
+
case 'dvi':
|
186 |
+
return 'application/x-dvi';
|
187 |
+
case 'dwf':
|
188 |
+
return 'drawing/x-dwf (old)';
|
189 |
+
case 'dwg':
|
190 |
+
return 'application/acad';
|
191 |
+
case 'dxf':
|
192 |
+
return 'application/dxf';
|
193 |
+
case 'dxr':
|
194 |
+
return 'application/x-director';
|
195 |
+
case 'el':
|
196 |
+
return 'text/x-script.elisp';
|
197 |
+
case 'elc':
|
198 |
+
return 'application/x-bytecode.elisp (compiled elisp)';
|
199 |
+
case 'env':
|
200 |
+
return 'application/x-envoy';
|
201 |
+
case 'eps':
|
202 |
+
return 'application/postscript';
|
203 |
+
case 'es':
|
204 |
+
return 'application/x-esrehber';
|
205 |
+
case 'etx':
|
206 |
+
return 'text/x-setext';
|
207 |
+
case 'evy':
|
208 |
+
return 'application/envoy';
|
209 |
+
case 'exe':
|
210 |
+
return 'application/octet-stream';
|
211 |
+
case 'f':
|
212 |
+
return 'text/plain';
|
213 |
+
case 'f77':
|
214 |
+
return 'text/x-fortran';
|
215 |
+
case 'f90':
|
216 |
+
return 'text/plain';
|
217 |
+
case 'fdf':
|
218 |
+
return 'application/vnd.fdf';
|
219 |
+
case 'fif':
|
220 |
+
return 'application/fractals';
|
221 |
+
case 'fli':
|
222 |
+
return 'video/fli';
|
223 |
+
case 'flo':
|
224 |
+
return 'image/florian';
|
225 |
+
case 'flx':
|
226 |
+
return 'text/vnd.fmi.flexstor';
|
227 |
+
case 'fmf':
|
228 |
+
return 'video/x-atomic3d-feature';
|
229 |
+
case 'for':
|
230 |
+
return 'text/plain';
|
231 |
+
case 'fpx':
|
232 |
+
return 'image/vnd.fpx';
|
233 |
+
case 'frl':
|
234 |
+
return 'application/freeloader';
|
235 |
+
case 'funk':
|
236 |
+
return 'audio/make';
|
237 |
+
case 'g':
|
238 |
+
return 'text/plain';
|
239 |
+
case 'g3':
|
240 |
+
return 'image/g3fax';
|
241 |
+
case 'gif':
|
242 |
+
return 'image/gif';
|
243 |
+
case 'gl':
|
244 |
+
return 'video/gl';
|
245 |
+
case 'gsd':
|
246 |
+
return 'audio/x-gsm';
|
247 |
+
case 'gsm':
|
248 |
+
return 'audio/x-gsm';
|
249 |
+
case 'gsp':
|
250 |
+
return 'application/x-gsp';
|
251 |
+
case 'gss':
|
252 |
+
return 'application/x-gss';
|
253 |
+
case 'gtar':
|
254 |
+
return 'application/x-gtar';
|
255 |
+
case 'gz':
|
256 |
+
return 'application/x-compressed';
|
257 |
+
case 'gzip':
|
258 |
+
return 'application/x-gzip';
|
259 |
+
case 'h':
|
260 |
+
return 'text/plain';
|
261 |
+
case 'hdf':
|
262 |
+
return 'application/x-hdf';
|
263 |
+
case 'help':
|
264 |
+
return 'application/x-helpfile';
|
265 |
+
case 'hgl':
|
266 |
+
return 'application/vnd.hp-hpgl';
|
267 |
+
case 'hh':
|
268 |
+
return 'text/plain';
|
269 |
+
case 'hlb':
|
270 |
+
return 'text/x-script';
|
271 |
+
case 'hlp':
|
272 |
+
return 'application/hlp';
|
273 |
+
case 'hpg':
|
274 |
+
return 'application/vnd.hp-hpgl';
|
275 |
+
case 'hpgl':
|
276 |
+
return 'application/vnd.hp-hpgl';
|
277 |
+
case 'hqx':
|
278 |
+
return 'application/binhex';
|
279 |
+
case 'hta':
|
280 |
+
return 'application/hta';
|
281 |
+
case 'htc':
|
282 |
+
return 'text/x-component';
|
283 |
+
case 'htm':
|
284 |
+
return 'text/html';
|
285 |
+
case 'html':
|
286 |
+
return 'text/html';
|
287 |
+
case 'htmls':
|
288 |
+
return 'text/html';
|
289 |
+
case 'htt':
|
290 |
+
return 'text/webviewhtml';
|
291 |
+
case 'htx':
|
292 |
+
return 'text/html';
|
293 |
+
case 'ice':
|
294 |
+
return 'x-conference/x-cooltalk';
|
295 |
+
case 'ico':
|
296 |
+
return 'image/x-icon';
|
297 |
+
case 'idc':
|
298 |
+
return 'text/plain';
|
299 |
+
case 'ief':
|
300 |
+
return 'image/ief';
|
301 |
+
case 'iefs':
|
302 |
+
return 'image/ief';
|
303 |
+
case 'iges':
|
304 |
+
return 'application/iges';
|
305 |
+
case 'igs':
|
306 |
+
return 'application/iges';
|
307 |
+
case 'ima':
|
308 |
+
return 'application/x-ima';
|
309 |
+
case 'imap':
|
310 |
+
return 'application/x-httpd-imap';
|
311 |
+
case 'inf':
|
312 |
+
return 'application/inf';
|
313 |
+
case 'ins':
|
314 |
+
return 'application/x-internett-signup';
|
315 |
+
case 'ip':
|
316 |
+
return 'application/x-ip2';
|
317 |
+
case 'isu':
|
318 |
+
return 'video/x-isvideo';
|
319 |
+
case 'it':
|
320 |
+
return 'audio/it';
|
321 |
+
case 'iv':
|
322 |
+
return 'application/x-inventor';
|
323 |
+
case 'ivr':
|
324 |
+
return 'i-world/i-vrml';
|
325 |
+
case 'ivy':
|
326 |
+
return 'application/x-livescreen';
|
327 |
+
case 'jam':
|
328 |
+
return 'audio/x-jam';
|
329 |
+
case 'jav':
|
330 |
+
return 'text/plain';
|
331 |
+
case 'java':
|
332 |
+
return 'text/plain';
|
333 |
+
case 'jcm':
|
334 |
+
return 'application/x-java-commerce';
|
335 |
+
case 'jfif':
|
336 |
+
return 'image/jpeg';
|
337 |
+
case 'jfif-tbnl':
|
338 |
+
return 'image/jpeg';
|
339 |
+
case 'jpe':
|
340 |
+
return 'image/jpeg';
|
341 |
+
case 'jpeg':
|
342 |
+
return 'image/jpeg';
|
343 |
+
case 'jpg':
|
344 |
+
return 'image/jpeg';
|
345 |
+
case 'jps':
|
346 |
+
return 'image/x-jps';
|
347 |
+
case 'js':
|
348 |
+
return 'application/x-javascript';
|
349 |
+
case 'jut':
|
350 |
+
return 'image/jutvision';
|
351 |
+
case 'kar':
|
352 |
+
return 'audio/midi';
|
353 |
+
case 'ksh':
|
354 |
+
return 'application/x-ksh';
|
355 |
+
case 'la':
|
356 |
+
return 'audio/nspaudio';
|
357 |
+
case 'lam':
|
358 |
+
return 'audio/x-liveaudio';
|
359 |
+
case 'latex':
|
360 |
+
return 'application/x-latex';
|
361 |
+
case 'lha':
|
362 |
+
return 'application/lha';
|
363 |
+
case 'lhx':
|
364 |
+
return 'application/octet-stream';
|
365 |
+
case 'list':
|
366 |
+
return 'text/plain';
|
367 |
+
case 'lma':
|
368 |
+
return 'audio/nspaudio';
|
369 |
+
case 'log':
|
370 |
+
return 'text/plain';
|
371 |
+
case 'lsp':
|
372 |
+
return 'application/x-lisp';
|
373 |
+
case 'lst':
|
374 |
+
return 'text/plain';
|
375 |
+
case 'lsx':
|
376 |
+
return 'text/x-la-asf';
|
377 |
+
case 'ltx':
|
378 |
+
return 'application/x-latex';
|
379 |
+
case 'lzh':
|
380 |
+
return 'application/octet-stream';
|
381 |
+
case 'lzx':
|
382 |
+
return 'application/lzx';
|
383 |
+
case 'm':
|
384 |
+
return 'text/plain';
|
385 |
+
case 'm1v':
|
386 |
+
return 'video/mpeg';
|
387 |
+
case 'm2a':
|
388 |
+
return 'audio/mpeg';
|
389 |
+
case 'm2v':
|
390 |
+
return 'video/mpeg';
|
391 |
+
case 'm3u':
|
392 |
+
return 'audio/x-mpequrl';
|
393 |
+
case 'man':
|
394 |
+
return 'application/x-troff-man';
|
395 |
+
case 'map':
|
396 |
+
return 'application/x-navimap';
|
397 |
+
case 'mar':
|
398 |
+
return 'text/plain';
|
399 |
+
case 'mbd':
|
400 |
+
return 'application/mbedlet';
|
401 |
+
case 'mc$':
|
402 |
+
return 'application/x-magic-cap-package-1.0';
|
403 |
+
case 'mcd':
|
404 |
+
return 'application/mcad';
|
405 |
+
case 'mcf':
|
406 |
+
return 'image/vasa';
|
407 |
+
case 'mcp':
|
408 |
+
return 'application/netmc';
|
409 |
+
case 'me':
|
410 |
+
return 'application/x-troff-me';
|
411 |
+
case 'mht':
|
412 |
+
return 'message/rfc822';
|
413 |
+
case 'mhtml':
|
414 |
+
return 'message/rfc822';
|
415 |
+
case 'mid':
|
416 |
+
return 'application/x-midi';
|
417 |
+
case 'midi':
|
418 |
+
return 'audio/midi';
|
419 |
+
case 'mif':
|
420 |
+
return 'application/x-frame';
|
421 |
+
case 'mime':
|
422 |
+
return 'message/rfc822';
|
423 |
+
case 'mjf':
|
424 |
+
return 'audio/x-vnd.audioexplosion.mjuicemediafile';
|
425 |
+
case 'mjpg':
|
426 |
+
return 'video/x-motion-jpeg';
|
427 |
+
case 'mm':
|
428 |
+
return 'application/base64';
|
429 |
+
case 'mme':
|
430 |
+
return 'application/base64';
|
431 |
+
case 'mod':
|
432 |
+
return 'audio/mod';
|
433 |
+
case 'moov':
|
434 |
+
return 'video/quicktime';
|
435 |
+
case 'mov':
|
436 |
+
return 'video/quicktime';
|
437 |
+
case 'movie':
|
438 |
+
return 'video/x-sgi-movie';
|
439 |
+
case 'mp2':
|
440 |
+
return 'video/mpeg';
|
441 |
+
case 'mp3':
|
442 |
+
return 'video/mpeg';
|
443 |
+
case 'mpa':
|
444 |
+
return 'audio/mpeg';
|
445 |
+
case 'mpc':
|
446 |
+
return 'application/x-project';
|
447 |
+
case 'mpe':
|
448 |
+
return 'video/mpeg';
|
449 |
+
case 'mpeg':
|
450 |
+
return 'video/mpeg';
|
451 |
+
case 'mpg':
|
452 |
+
return 'video/mpeg';
|
453 |
+
case 'mpga':
|
454 |
+
return 'audio/mpeg';
|
455 |
+
case 'mpp':
|
456 |
+
return 'application/vnd.ms-project';
|
457 |
+
case 'mpt':
|
458 |
+
return 'application/x-project';
|
459 |
+
case 'mpv':
|
460 |
+
return 'application/x-project';
|
461 |
+
case 'mpx':
|
462 |
+
return 'application/x-project';
|
463 |
+
case 'mrc':
|
464 |
+
return 'application/marc';
|
465 |
+
case 'ms':
|
466 |
+
return 'application/x-troff-ms';
|
467 |
+
case 'mv':
|
468 |
+
return 'video/x-sgi-movie';
|
469 |
+
case 'my':
|
470 |
+
return 'audio/make';
|
471 |
+
case 'mzz':
|
472 |
+
return 'application/x-vnd.audioexplosion.mzz';
|
473 |
+
case 'nap':
|
474 |
+
return 'image/naplps';
|
475 |
+
case 'naplps':
|
476 |
+
return 'image/naplps';
|
477 |
+
case 'nc':
|
478 |
+
return 'application/x-netcdf';
|
479 |
+
case 'ncm':
|
480 |
+
return 'application/vnd.nokia.configuration-message';
|
481 |
+
case 'nif':
|
482 |
+
return 'image/x-niff';
|
483 |
+
case 'niff':
|
484 |
+
return 'image/x-niff';
|
485 |
+
case 'nix':
|
486 |
+
return 'application/x-mix-transfer';
|
487 |
+
case 'nsc':
|
488 |
+
return 'application/x-conference';
|
489 |
+
case 'nvd':
|
490 |
+
return 'application/x-navidoc';
|
491 |
+
case 'o':
|
492 |
+
return 'application/octet-stream';
|
493 |
+
case 'oda':
|
494 |
+
return 'application/oda';
|
495 |
+
case 'omc':
|
496 |
+
return 'application/x-omc';
|
497 |
+
case 'omcd':
|
498 |
+
return 'application/x-omcdatamaker';
|
499 |
+
case 'omcr':
|
500 |
+
return 'application/x-omcregerator';
|
501 |
+
case 'p':
|
502 |
+
return 'text/x-pascal';
|
503 |
+
case 'p10':
|
504 |
+
return 'application/pkcs10';
|
505 |
+
case 'p12':
|
506 |
+
return 'application/pkcs-12';
|
507 |
+
case 'p7a':
|
508 |
+
return 'application/x-pkcs7-signature';
|
509 |
+
case 'p7c':
|
510 |
+
return 'application/pkcs7-mime';
|
511 |
+
case 'p7m':
|
512 |
+
return 'application/pkcs7-mime';
|
513 |
+
case 'p7r':
|
514 |
+
return 'application/x-pkcs7-certreqresp';
|
515 |
+
case 'p7s':
|
516 |
+
return 'application/pkcs7-signature';
|
517 |
+
case 'part':
|
518 |
+
return 'application/pro_eng';
|
519 |
+
case 'pas':
|
520 |
+
return 'text/pascal';
|
521 |
+
case 'pbm':
|
522 |
+
return 'image/x-portable-bitmap';
|
523 |
+
case 'pcl':
|
524 |
+
return 'application/vnd.hp-pcl';
|
525 |
+
case 'pct':
|
526 |
+
return 'image/x-pict';
|
527 |
+
case 'pcx':
|
528 |
+
return 'image/x-pcx';
|
529 |
+
case 'pdb':
|
530 |
+
return 'chemical/x-pdb';
|
531 |
+
case 'pdf':
|
532 |
+
return 'application/pdf';
|
533 |
+
case 'pfunk':
|
534 |
+
return 'audio/make';
|
535 |
+
case 'pgm':
|
536 |
+
return 'image/x-portable-graymap';
|
537 |
+
case 'pic':
|
538 |
+
return 'image/pict';
|
539 |
+
case 'pict':
|
540 |
+
return 'image/pict';
|
541 |
+
case 'pkg':
|
542 |
+
return 'application/x-newton-compatible-pkg';
|
543 |
+
case 'pko':
|
544 |
+
return 'application/vnd.ms-pki.pko';
|
545 |
+
case 'pl':
|
546 |
+
return 'text/plain';
|
547 |
+
case 'plx':
|
548 |
+
return 'application/x-pixclscript';
|
549 |
+
case 'pm':
|
550 |
+
return 'image/x-xpixmap';
|
551 |
+
case 'pm4':
|
552 |
+
return 'application/x-pagemaker';
|
553 |
+
case 'pm5':
|
554 |
+
return 'application/x-pagemaker';
|
555 |
+
case 'png':
|
556 |
+
return 'image/png';
|
557 |
+
case 'pnm':
|
558 |
+
return 'application/x-portable-anymap';
|
559 |
+
case 'pot':
|
560 |
+
return 'application/mspowerpoint';
|
561 |
+
case 'pov':
|
562 |
+
return 'model/x-pov';
|
563 |
+
case 'ppa':
|
564 |
+
return 'application/vnd.ms-powerpoint';
|
565 |
+
case 'ppm':
|
566 |
+
return 'image/x-portable-pixmap';
|
567 |
+
case 'pps':
|
568 |
+
return 'application/mspowerpoint';
|
569 |
+
case 'ppt':
|
570 |
+
return 'application/mspowerpoint';
|
571 |
+
case 'ppz':
|
572 |
+
return 'application/mspowerpoint';
|
573 |
+
case 'pre':
|
574 |
+
return 'application/x-freelance';
|
575 |
+
case 'prt':
|
576 |
+
return 'application/pro_eng';
|
577 |
+
case 'ps':
|
578 |
+
return 'application/postscript';
|
579 |
+
case 'psd':
|
580 |
+
return 'application/octet-stream';
|
581 |
+
case 'pvu':
|
582 |
+
return 'paleovu/x-pv';
|
583 |
+
case 'pwz':
|
584 |
+
return 'application/vnd.ms-powerpoint';
|
585 |
+
case 'py':
|
586 |
+
return 'text/x-script.phyton';
|
587 |
+
case 'pyc':
|
588 |
+
return 'applicaiton/x-bytecode.python';
|
589 |
+
case 'qcp':
|
590 |
+
return 'audio/vnd.qcelp';
|
591 |
+
case 'qd3':
|
592 |
+
return 'x-world/x-3dmf';
|
593 |
+
case 'qd3d':
|
594 |
+
return 'x-world/x-3dmf';
|
595 |
+
case 'qif':
|
596 |
+
return 'image/x-quicktime';
|
597 |
+
case 'qt':
|
598 |
+
return 'video/quicktime';
|
599 |
+
case 'qtc':
|
600 |
+
return 'video/x-qtc';
|
601 |
+
case 'qti':
|
602 |
+
return 'image/x-quicktime';
|
603 |
+
case 'qtif':
|
604 |
+
return 'image/x-quicktime';
|
605 |
+
case 'ra':
|
606 |
+
return 'audio/x-pn-realaudio';
|
607 |
+
case 'ram':
|
608 |
+
return 'audio/x-pn-realaudio';
|
609 |
+
case 'ras':
|
610 |
+
return 'application/x-cmu-raster';
|
611 |
+
case 'rast':
|
612 |
+
return 'image/cmu-raster';
|
613 |
+
case 'rexx':
|
614 |
+
return 'text/x-script.rexx';
|
615 |
+
case 'rf':
|
616 |
+
return 'image/vnd.rn-realflash';
|
617 |
+
case 'rgb':
|
618 |
+
return 'image/x-rgb';
|
619 |
+
case 'rm':
|
620 |
+
return 'application/vnd.rn-realmedia';
|
621 |
+
case 'rmi':
|
622 |
+
return 'audio/mid';
|
623 |
+
case 'rmm':
|
624 |
+
return 'audio/x-pn-realaudio';
|
625 |
+
case 'rmp':
|
626 |
+
return 'audio/x-pn-realaudio';
|
627 |
+
case 'rng':
|
628 |
+
return 'application/ringing-tones';
|
629 |
+
case 'rnx':
|
630 |
+
return 'application/vnd.rn-realplayer';
|
631 |
+
case 'roff':
|
632 |
+
return 'application/x-troff';
|
633 |
+
case 'rp':
|
634 |
+
return 'image/vnd.rn-realpix';
|
635 |
+
case 'rpm':
|
636 |
+
return 'audio/x-pn-realaudio-plugin';
|
637 |
+
case 'rt':
|
638 |
+
return 'text/richtext';
|
639 |
+
case 'rtf':
|
640 |
+
return 'application/rtf';
|
641 |
+
case 'rtx':
|
642 |
+
return 'text/richtext';
|
643 |
+
case 'rv':
|
644 |
+
return 'video/vnd.rn-realvideo';
|
645 |
+
case 's':
|
646 |
+
return 'text/x-asm';
|
647 |
+
case 's3m':
|
648 |
+
return 'audio/s3m';
|
649 |
+
case 'saveme':
|
650 |
+
return 'application/octet-stream';
|
651 |
+
case 'sbk':
|
652 |
+
return 'application/x-tbook';
|
653 |
+
case 'scm':
|
654 |
+
return 'application/x-lotusscreencam';
|
655 |
+
case 'sdml':
|
656 |
+
return 'text/plain';
|
657 |
+
case 'sdp':
|
658 |
+
return 'application/sdp';
|
659 |
+
case 'sdr':
|
660 |
+
return 'application/sounder';
|
661 |
+
case 'sea':
|
662 |
+
return 'application/sea';
|
663 |
+
case 'set':
|
664 |
+
return 'application/set';
|
665 |
+
case 'sgm':
|
666 |
+
return 'text/sgml';
|
667 |
+
case 'sgml':
|
668 |
+
return 'text/sgml';
|
669 |
+
case 'sh':
|
670 |
+
return 'application/x-bsh';
|
671 |
+
case 'shar':
|
672 |
+
return 'application/x-bsh';
|
673 |
+
case 'shtml':
|
674 |
+
return 'text/html';
|
675 |
+
case 'sid':
|
676 |
+
return 'audio/x-psid';
|
677 |
+
case 'sit':
|
678 |
+
return 'application/x-sit';
|
679 |
+
case 'skd':
|
680 |
+
return 'application/x-koan';
|
681 |
+
case 'skm':
|
682 |
+
return 'application/x-koan';
|
683 |
+
case 'skp':
|
684 |
+
return 'application/x-koan';
|
685 |
+
case 'skt':
|
686 |
+
return 'application/x-koan';
|
687 |
+
case 'sl':
|
688 |
+
return 'application/x-seelogo';
|
689 |
+
case 'smi':
|
690 |
+
return 'application/smil';
|
691 |
+
case 'smil':
|
692 |
+
return 'application/smil';
|
693 |
+
case 'snd':
|
694 |
+
return 'audio/basic';
|
695 |
+
case 'sol':
|
696 |
+
return 'application/solids';
|
697 |
+
case 'spc':
|
698 |
+
return 'application/x-pkcs7-certificates';
|
699 |
+
case 'spl':
|
700 |
+
return 'application/futuresplash';
|
701 |
+
case 'spr':
|
702 |
+
return 'application/x-sprite';
|
703 |
+
case 'sprite':
|
704 |
+
return 'application/x-sprite';
|
705 |
+
case 'src':
|
706 |
+
return 'application/x-wais-source';
|
707 |
+
case 'ssi':
|
708 |
+
return 'text/x-server-parsed-html';
|
709 |
+
case 'ssm':
|
710 |
+
return 'application/streamingmedia';
|
711 |
+
case 'sst':
|
712 |
+
return 'application/vnd.ms-pki.certstore';
|
713 |
+
case 'step':
|
714 |
+
return 'application/step';
|
715 |
+
case 'stl':
|
716 |
+
return 'application/sla';
|
717 |
+
case 'stp':
|
718 |
+
return 'application/step';
|
719 |
+
case 'sv4cpio':
|
720 |
+
return 'application/x-sv4cpio';
|
721 |
+
case 'sv4crc':
|
722 |
+
return 'application/x-sv4crc';
|
723 |
+
case 'svf':
|
724 |
+
return 'image/vnd.dwg';
|
725 |
+
case 'svr':
|
726 |
+
return 'application/x-world';
|
727 |
+
case 'swf':
|
728 |
+
return 'application/x-shockwave-flash';
|
729 |
+
case 't':
|
730 |
+
return 'application/x-troff';
|
731 |
+
case 'talk':
|
732 |
+
return 'text/x-speech';
|
733 |
+
case 'tar':
|
734 |
+
return 'application/x-tar';
|
735 |
+
case 'tbk':
|
736 |
+
return 'application/toolbook';
|
737 |
+
case 'tcl':
|
738 |
+
return 'application/x-tcl';
|
739 |
+
case 'tcsh':
|
740 |
+
return 'text/x-script.tcsh';
|
741 |
+
case 'tex':
|
742 |
+
return 'application/x-tex';
|
743 |
+
case 'texi':
|
744 |
+
return 'application/x-texinfo';
|
745 |
+
case 'texinfo':
|
746 |
+
return 'application/x-texinfo';
|
747 |
+
case 'text':
|
748 |
+
return 'text/plain';
|
749 |
+
case 'tgz':
|
750 |
+
return 'application/x-compressed';
|
751 |
+
case 'tif':
|
752 |
+
return 'image/tiff';
|
753 |
+
case 'tiff':
|
754 |
+
return 'image/tiff';
|
755 |
+
case 'tr':
|
756 |
+
return 'application/x-troff';
|
757 |
+
case 'tsi':
|
758 |
+
return 'audio/tsp-audio';
|
759 |
+
case 'tsp':
|
760 |
+
return 'application/dsptype';
|
761 |
+
case 'tsv':
|
762 |
+
return 'text/tab-separated-values';
|
763 |
+
case 'turbot':
|
764 |
+
return 'image/florian';
|
765 |
+
case 'txt':
|
766 |
+
return 'text/plain';
|
767 |
+
case 'uil':
|
768 |
+
return 'text/x-uil';
|
769 |
+
case 'uni':
|
770 |
+
return 'text/uri-list';
|
771 |
+
case 'unis':
|
772 |
+
return 'text/uri-list';
|
773 |
+
case 'unv':
|
774 |
+
return 'application/i-deas';
|
775 |
+
case 'uri':
|
776 |
+
return 'text/uri-list';
|
777 |
+
case 'uris':
|
778 |
+
return 'text/uri-list';
|
779 |
+
case 'ustar':
|
780 |
+
return 'multipart/x-ustar';
|
781 |
+
case 'uu':
|
782 |
+
return 'application/octet-stream';
|
783 |
+
case 'uue':
|
784 |
+
return 'text/x-uuencode';
|
785 |
+
case 'vcd':
|
786 |
+
return 'application/x-cdlink';
|
787 |
+
case 'vcs':
|
788 |
+
return 'text/x-vcalendar';
|
789 |
+
case 'vda':
|
790 |
+
return 'application/vda';
|
791 |
+
case 'vdo':
|
792 |
+
return 'video/vdo';
|
793 |
+
case 'vew':
|
794 |
+
return 'application/groupwise';
|
795 |
+
case 'viv':
|
796 |
+
return 'video/vivo';
|
797 |
+
case 'vivo':
|
798 |
+
return 'video/vivo';
|
799 |
+
case 'vmd':
|
800 |
+
return 'application/vocaltec-media-desc';
|
801 |
+
case 'vmf':
|
802 |
+
return 'application/vocaltec-media-file';
|
803 |
+
case 'voc':
|
804 |
+
return 'audio/voc';
|
805 |
+
case 'vos':
|
806 |
+
return 'video/vosaic';
|
807 |
+
case 'vox':
|
808 |
+
return 'audio/voxware';
|
809 |
+
case 'vqe':
|
810 |
+
return 'audio/x-twinvq-plugin';
|
811 |
+
case 'vqf':
|
812 |
+
return 'audio/x-twinvq';
|
813 |
+
case 'vql':
|
814 |
+
return 'audio/x-twinvq-plugin';
|
815 |
+
case 'vrml':
|
816 |
+
return 'application/x-vrml';
|
817 |
+
case 'vrt':
|
818 |
+
return 'x-world/x-vrt';
|
819 |
+
case 'vsd':
|
820 |
+
return 'application/x-visio';
|
821 |
+
case 'vst':
|
822 |
+
return 'application/x-visio';
|
823 |
+
case 'vsw':
|
824 |
+
return 'application/x-visio';
|
825 |
+
case 'w60':
|
826 |
+
return 'application/wordperfect6.0';
|
827 |
+
case 'w61':
|
828 |
+
return 'application/wordperfect6.1';
|
829 |
+
case 'w6w':
|
830 |
+
return 'application/msword';
|
831 |
+
case 'wav':
|
832 |
+
return 'audio/wav';
|
833 |
+
case 'wb1':
|
834 |
+
return 'application/x-qpro';
|
835 |
+
case 'wbmp':
|
836 |
+
return 'image/vnd.wap.wbmp';
|
837 |
+
case 'web':
|
838 |
+
return 'application/vnd.xara';
|
839 |
+
case 'wiz':
|
840 |
+
return 'application/msword';
|
841 |
+
case 'wk1':
|
842 |
+
return 'application/x-123';
|
843 |
+
case 'wmf':
|
844 |
+
return 'windows/metafile';
|
845 |
+
case 'wml':
|
846 |
+
return 'text/vnd.wap.wml';
|
847 |
+
case 'wmlc':
|
848 |
+
return 'application/vnd.wap.wmlc';
|
849 |
+
case 'wmls':
|
850 |
+
return 'text/vnd.wap.wmlscript';
|
851 |
+
case 'wmlsc':
|
852 |
+
return 'application/vnd.wap.wmlscriptc';
|
853 |
+
case 'word':
|
854 |
+
return 'application/msword';
|
855 |
+
case 'wp':
|
856 |
+
return 'application/wordperfect';
|
857 |
+
case 'wp5':
|
858 |
+
return 'application/wordperfect6.0';
|
859 |
+
case 'wp6':
|
860 |
+
return 'application/wordperfect';
|
861 |
+
case 'wpd':
|
862 |
+
return 'application/x-wpwin';
|
863 |
+
case 'wq1':
|
864 |
+
return 'application/x-lotus';
|
865 |
+
case 'wri':
|
866 |
+
return 'application/mswrite';
|
867 |
+
case 'wrl':
|
868 |
+
return 'model/vrml';
|
869 |
+
case 'wrz':
|
870 |
+
return 'model/vrml';
|
871 |
+
case 'wsc':
|
872 |
+
return 'text/scriplet';
|
873 |
+
case 'wsrc':
|
874 |
+
return 'application/x-wais-source';
|
875 |
+
case 'wtk':
|
876 |
+
return 'application/x-wintalk';
|
877 |
+
case 'xbm':
|
878 |
+
return 'image/x-xbitmap';
|
879 |
+
case 'xdr':
|
880 |
+
return 'video/x-amt-demorun';
|
881 |
+
case 'xgz':
|
882 |
+
return 'xgl/drawing';
|
883 |
+
case 'xif':
|
884 |
+
return 'image/vnd.xiff';
|
885 |
+
case 'xl':
|
886 |
+
return 'application/excel';
|
887 |
+
case 'xla':
|
888 |
+
return 'application/excel';
|
889 |
+
case 'xlb':
|
890 |
+
return 'application/excel';
|
891 |
+
case 'xlc':
|
892 |
+
return 'application/excel';
|
893 |
+
case 'xld':
|
894 |
+
return 'application/excel';
|
895 |
+
case 'xlk':
|
896 |
+
return 'application/excel';
|
897 |
+
case 'xll':
|
898 |
+
return 'application/excel';
|
899 |
+
case 'xlm':
|
900 |
+
return 'application/excel';
|
901 |
+
case 'xls':
|
902 |
+
return 'application/excel';
|
903 |
+
case 'xlt':
|
904 |
+
return 'application/excel';
|
905 |
+
case 'xlv':
|
906 |
+
return 'application/excel';
|
907 |
+
case 'xlw':
|
908 |
+
return 'application/excel';
|
909 |
+
case 'xm':
|
910 |
+
return 'audio/xm';
|
911 |
+
case 'xml':
|
912 |
+
return 'application/xml';
|
913 |
+
case 'xmz':
|
914 |
+
return 'xgl/movie';
|
915 |
+
case 'xpix':
|
916 |
+
return 'application/x-vnd.ls-xpix';
|
917 |
+
case 'xpm':
|
918 |
+
return 'image/xpm';
|
919 |
+
case 'x-png':
|
920 |
+
return 'image/png';
|
921 |
+
case 'xsr':
|
922 |
+
return 'video/x-amt-showrun';
|
923 |
+
case 'xwd':
|
924 |
+
return 'image/x-xwd';
|
925 |
+
case 'xyz':
|
926 |
+
return 'chemical/x-pdb';
|
927 |
+
case 'z':
|
928 |
+
return 'application/x-compress';
|
929 |
+
case 'zip':
|
930 |
+
return 'application/x-compressed';
|
931 |
+
case 'zoo':
|
932 |
+
return 'application/octet-stream';
|
933 |
+
case 'zsh':
|
934 |
+
return 'text/x-script.zsh';
|
935 |
+
default:
|
936 |
+
return 'application/octet-stream';
|
937 |
+
}
|
938 |
+
}
|
939 |
+
?>
|
Archive/Reader/Multi.php
ADDED
@@ -0,0 +1,95 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
|
3 |
+
|
4 |
+
/**
|
5 |
+
* Regroups several readers to make them appear as a single one
|
6 |
+
*
|
7 |
+
* PHP versions 4 and 5
|
8 |
+
*
|
9 |
+
* This library is free software; you can redistribute it and/or
|
10 |
+
* modify it under the terms of the GNU Lesser General Public
|
11 |
+
* License as published by the Free Software Foundation; either
|
12 |
+
* version 2.1 of the License, or (at your option) any later version.
|
13 |
+
*
|
14 |
+
* This library is distributed in the hope that it will be useful,
|
15 |
+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
16 |
+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
17 |
+
* Lesser General Public License for more details.
|
18 |
+
*
|
19 |
+
* You should have received a copy of the GNU Lesser General Public
|
20 |
+
* License along with this library; if not, write to the Free Software
|
21 |
+
* Foundation, Inc., 59 Temple Place, Suite 330,Boston,MA 02111-1307 USA
|
22 |
+
*
|
23 |
+
* @category File Formats
|
24 |
+
* @package File_Archive
|
25 |
+
* @author Vincent Lascaux <vincentlascaux@php.net>
|
26 |
+
* @copyright 1997-2005 The PHP Group
|
27 |
+
* @license http://www.gnu.org/copyleft/lesser.html LGPL
|
28 |
+
* @version CVS: $Id: Multi.php,v 1.10 2005/05/26 21:30:18 vincentlascaux Exp $
|
29 |
+
* @link http://pear.php.net/package/File_Archive
|
30 |
+
*/
|
31 |
+
|
32 |
+
require_once $GLOBALS['bkpwp_plugin_path']."Archive/Reader/Relay.php";
|
33 |
+
|
34 |
+
/**
|
35 |
+
* Regroups several readers to make them appear as a single one
|
36 |
+
*/
|
37 |
+
class File_Archive_Reader_Multi extends File_Archive_Reader_Relay
|
38 |
+
{
|
39 |
+
/**
|
40 |
+
* @var Array All the sources regrouped in this reader
|
41 |
+
* @access private
|
42 |
+
*/
|
43 |
+
var $sources = array();
|
44 |
+
/**
|
45 |
+
* @var Int Index of the source being read currently
|
46 |
+
* @access private
|
47 |
+
*/
|
48 |
+
var $currentIndex = 0;
|
49 |
+
|
50 |
+
function File_Archive_Reader_Multi()
|
51 |
+
{
|
52 |
+
parent::File_Archive_Reader_Relay($tmp = null);
|
53 |
+
}
|
54 |
+
|
55 |
+
/**
|
56 |
+
* Add a new reader to the list of readers
|
57 |
+
* @param File_Archive_Reader $source The source to add
|
58 |
+
*/
|
59 |
+
function addSource(&$source)
|
60 |
+
{
|
61 |
+
$this->sources[] =& $source;
|
62 |
+
}
|
63 |
+
|
64 |
+
/**
|
65 |
+
* @see File_Archive_Reader::next()
|
66 |
+
*/
|
67 |
+
function next()
|
68 |
+
{
|
69 |
+
while (array_key_exists($this->currentIndex, $this->sources)) {
|
70 |
+
$this->source =& $this->sources[$this->currentIndex];
|
71 |
+
|
72 |
+
if (($error = $this->source->next()) === false) {
|
73 |
+
$error = $this->source->close();
|
74 |
+
if (PEAR::isError($error)) {
|
75 |
+
return $error;
|
76 |
+
}
|
77 |
+
$this->currentIndex++;
|
78 |
+
} else {
|
79 |
+
return $error;
|
80 |
+
}
|
81 |
+
}
|
82 |
+
return false;
|
83 |
+
}
|
84 |
+
/**
|
85 |
+
* @see File_Archive_Reader::close()
|
86 |
+
*/
|
87 |
+
function close()
|
88 |
+
{
|
89 |
+
$error = parent::close();
|
90 |
+
$this->currentIndex = 0;
|
91 |
+
return $error;
|
92 |
+
}
|
93 |
+
}
|
94 |
+
|
95 |
+
?>
|
Archive/Reader/Relay.php
ADDED
@@ -0,0 +1,134 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
|
3 |
+
|
4 |
+
/**
|
5 |
+
* A reader that appears exactly as another does
|
6 |
+
*
|
7 |
+
* PHP versions 4 and 5
|
8 |
+
*
|
9 |
+
* This library is free software; you can redistribute it and/or
|
10 |
+
* modify it under the terms of the GNU Lesser General Public
|
11 |
+
* License as published by the Free Software Foundation; either
|
12 |
+
* version 2.1 of the License, or (at your option) any later version.
|
13 |
+
*
|
14 |
+
* This library is distributed in the hope that it will be useful,
|
15 |
+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
16 |
+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
17 |
+
* Lesser General Public License for more details.
|
18 |
+
*
|
19 |
+
* You should have received a copy of the GNU Lesser General Public
|
20 |
+
* License along with this library; if not, write to the Free Software
|
21 |
+
* Foundation, Inc., 59 Temple Place, Suite 330,Boston,MA 02111-1307 USA
|
22 |
+
*
|
23 |
+
* @category File Formats
|
24 |
+
* @package File_Archive
|
25 |
+
* @author Vincent Lascaux <vincentlascaux@php.net>
|
26 |
+
* @copyright 1997-2005 The PHP Group
|
27 |
+
* @license http://www.gnu.org/copyleft/lesser.html LGPL
|
28 |
+
* @version CVS: $Id: Relay.php,v 1.19 2005/07/09 12:54:35 vincentlascaux Exp $
|
29 |
+
* @link http://pear.php.net/package/File_Archive
|
30 |
+
*/
|
31 |
+
|
32 |
+
require_once $GLOBALS['bkpwp_plugin_path']."Archive/Reader.php";
|
33 |
+
|
34 |
+
/**
|
35 |
+
* This reader appear exactly as $source does
|
36 |
+
* This is usefull if you want to dynamically change $source or change
|
37 |
+
* its behaviour
|
38 |
+
*/
|
39 |
+
class File_Archive_Reader_Relay extends File_Archive_Reader
|
40 |
+
{
|
41 |
+
/**
|
42 |
+
* @var File_Archive_Reader This reader will have the same comportment as
|
43 |
+
* $source
|
44 |
+
* @access protected
|
45 |
+
*/
|
46 |
+
var $source;
|
47 |
+
|
48 |
+
function File_Archive_Reader_Relay(&$source)
|
49 |
+
{
|
50 |
+
$this->source =& $source;
|
51 |
+
}
|
52 |
+
|
53 |
+
/**
|
54 |
+
* @see File_Archive_Reader::next()
|
55 |
+
*/
|
56 |
+
function next() { return $this->source->next(); }
|
57 |
+
/**
|
58 |
+
* @see File_Archive_Reader::getFilename()
|
59 |
+
*/
|
60 |
+
function getFilename() { return $this->source->getFilename(); }
|
61 |
+
/**
|
62 |
+
* @see File_Archive_Reader::getStat()
|
63 |
+
*/
|
64 |
+
function getStat() { return $this->source->getStat(); }
|
65 |
+
/**
|
66 |
+
* @see File_Archive_Reader::getMime()
|
67 |
+
*/
|
68 |
+
function getMime() { return $this->source->getMime(); }
|
69 |
+
/**
|
70 |
+
* @see File_Archive_Reader::getDataFilename()
|
71 |
+
*/
|
72 |
+
function getDataFilename() { return $this->source->getDataFilename(); }
|
73 |
+
/**
|
74 |
+
* @see File_Archive_Reader::getData()
|
75 |
+
*/
|
76 |
+
function getData($length = -1) { return $this->source->getData($length); }
|
77 |
+
/**
|
78 |
+
* @see File_Archive_Reader::skip()
|
79 |
+
*/
|
80 |
+
function skip($length = -1) { return $this->source->skip($length); }
|
81 |
+
/**
|
82 |
+
* @see File_Archive_Reader::rewind()
|
83 |
+
*/
|
84 |
+
function rewind($length = -1) { return $this->source->rewind($length); }
|
85 |
+
/**
|
86 |
+
* @see File_Archive_Reader::tell()
|
87 |
+
*/
|
88 |
+
function tell() { return $this->source->tell(); }
|
89 |
+
|
90 |
+
/**
|
91 |
+
* @see File_Archive_Reader::close()
|
92 |
+
*/
|
93 |
+
function close()
|
94 |
+
{
|
95 |
+
if ($this->source !== null) {
|
96 |
+
return $this->source->close();
|
97 |
+
}
|
98 |
+
}
|
99 |
+
/**
|
100 |
+
* @see File_Archive_Reader::makeAppendWriter()
|
101 |
+
*/
|
102 |
+
function makeAppendWriter()
|
103 |
+
{
|
104 |
+
$writer = $this->source->makeAppendWriter();
|
105 |
+
if (!PEAR::isError($writer)) {
|
106 |
+
$this->close();
|
107 |
+
}
|
108 |
+
return $writer;
|
109 |
+
}
|
110 |
+
/**
|
111 |
+
* @see File_Archive_Reader::makeWriterRemoveFiles()
|
112 |
+
*/
|
113 |
+
function makeWriterRemoveFiles($pred)
|
114 |
+
{
|
115 |
+
$writer = $this->source->makeWriterRemoveFiles($pred);
|
116 |
+
if (!PEAR::isError($writer)) {
|
117 |
+
$this->close();
|
118 |
+
}
|
119 |
+
return $writer;
|
120 |
+
}
|
121 |
+
/**
|
122 |
+
* @see File_Archive_Reader::makeWriterRemoveBlocks()
|
123 |
+
*/
|
124 |
+
function makeWriterRemoveBlocks($blocks, $seek = 0)
|
125 |
+
{
|
126 |
+
$writer = $this->source->makeWriterRemoveBlocks($blocks, $seek);
|
127 |
+
if (!PEAR::isError($writer)) {
|
128 |
+
$this->close();
|
129 |
+
}
|
130 |
+
return $writer;
|
131 |
+
}
|
132 |
+
}
|
133 |
+
|
134 |
+
?>
|
Archive/Reader/Select.php
ADDED
@@ -0,0 +1,63 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
|
3 |
+
|
4 |
+
/**
|
5 |
+
* Reader that keeps the files selected by File_Archive::select function
|
6 |
+
*
|
7 |
+
* PHP versions 4 and 5
|
8 |
+
*
|
9 |
+
* This library is free software; you can redistribute it and/or
|
10 |
+
* modify it under the terms of the GNU Lesser General Public
|
11 |
+
* License as published by the Free Software Foundation; either
|
12 |
+
* version 2.1 of the License, or (at your option) any later version.
|
13 |
+
*
|
14 |
+
* This library is distributed in the hope that it will be useful,
|
15 |
+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
16 |
+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
17 |
+
* Lesser General Public License for more details.
|
18 |
+
*
|
19 |
+
* You should have received a copy of the GNU Lesser General Public
|
20 |
+
* License along with this library; if not, write to the Free Software
|
21 |
+
* Foundation, Inc., 59 Temple Place, Suite 330,Boston,MA 02111-1307 USA
|
22 |
+
*
|
23 |
+
* @category File Formats
|
24 |
+
* @package File_Archive
|
25 |
+
* @author Vincent Lascaux <vincentlascaux@php.net>
|
26 |
+
* @copyright 1997-2005 The PHP Group
|
27 |
+
* @license http://www.gnu.org/copyleft/lesser.html LGPL
|
28 |
+
* @version CVS: $Id: Select.php,v 1.3 2005/05/26 21:30:18 vincentlascaux Exp $
|
29 |
+
* @link http://pear.php.net/package/File_Archive
|
30 |
+
*/
|
31 |
+
|
32 |
+
require_once $GLOBALS['bkpwp_plugin_path']."Archive/Reader/Relay.php";
|
33 |
+
|
34 |
+
/**
|
35 |
+
* Reader that keeps the files selected by File_Archive::select function
|
36 |
+
*/
|
37 |
+
class File_Archive_Reader_Select extends File_Archive_Reader_Relay
|
38 |
+
{
|
39 |
+
/**
|
40 |
+
* @var File_Archive_Reader_Predicat
|
41 |
+
* @access private
|
42 |
+
*/
|
43 |
+
var $filename;
|
44 |
+
|
45 |
+
/**
|
46 |
+
* $source is the reader to filter
|
47 |
+
*/
|
48 |
+
function File_Archive_Reader_Select($filename, &$source)
|
49 |
+
{
|
50 |
+
parent::File_Archive_Reader_Relay($source);
|
51 |
+
$this->filename = $filename;
|
52 |
+
}
|
53 |
+
|
54 |
+
/**
|
55 |
+
* @see File_Archive_Reader::next()
|
56 |
+
*/
|
57 |
+
function next()
|
58 |
+
{
|
59 |
+
return $this->source->select($this->filename, false);
|
60 |
+
}
|
61 |
+
}
|
62 |
+
|
63 |
+
?>
|
Archive/Reader/Tar.php
ADDED
@@ -0,0 +1,355 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
|
3 |
+
|
4 |
+
/**
|
5 |
+
* Read a tar archive
|
6 |
+
*
|
7 |
+
* PHP versions 4 and 5
|
8 |
+
*
|
9 |
+
* This library is free software; you can redistribute it and/or
|
10 |
+
* modify it under the terms of the GNU Lesser General Public
|
11 |
+
* License as published by the Free Software Foundation; either
|
12 |
+
* version 2.1 of the License, or (at your option) any later version.
|
13 |
+
*
|
14 |
+
* This library is distributed in the hope that it will be useful,
|
15 |
+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
16 |
+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
17 |
+
* Lesser General Public License for more details.
|
18 |
+
*
|
19 |
+
* You should have received a copy of the GNU Lesser General Public
|
20 |
+
* License along with this library; if not, write to the Free Software
|
21 |
+
* Foundation, Inc., 59 Temple Place, Suite 330,Boston,MA 02111-1307 USA
|
22 |
+
*
|
23 |
+
* @category File Formats
|
24 |
+
* @package File_Archive
|
25 |
+
* @author Vincent Lascaux <vincentlascaux@php.net>
|
26 |
+
* @copyright 1997-2005 The PHP Group
|
27 |
+
* @license http://www.gnu.org/copyleft/lesser.html LGPL
|
28 |
+
* @version CVS: $Id: Tar.php,v 1.29 2005/07/11 11:53:53 vincentlascaux Exp $
|
29 |
+
* @link http://pear.php.net/package/File_Archive
|
30 |
+
*/
|
31 |
+
|
32 |
+
require_once $GLOBALS['bkpwp_plugin_path']."Archive/Reader/Archive.php";
|
33 |
+
|
34 |
+
/**
|
35 |
+
* Read a tar archive
|
36 |
+
*/
|
37 |
+
class File_Archive_Reader_Tar extends File_Archive_Reader_Archive
|
38 |
+
{
|
39 |
+
/**
|
40 |
+
* @var String Name of the file being read
|
41 |
+
* @access private
|
42 |
+
*/
|
43 |
+
var $currentFilename = null;
|
44 |
+
/**
|
45 |
+
* @var Array Stats of the file being read
|
46 |
+
* In TAR reader, indexes 2, 4, 5, 7, 9 are set
|
47 |
+
* @access private
|
48 |
+
*/
|
49 |
+
var $currentStat = null;
|
50 |
+
/**
|
51 |
+
* @var int Number of bytes that still have to be read before the end of
|
52 |
+
* file
|
53 |
+
* @access private
|
54 |
+
*/
|
55 |
+
var $leftLength = 0;
|
56 |
+
/**
|
57 |
+
* @var int Size of the footer
|
58 |
+
* A TAR file is made of chunks of 512 bytes. If 512 does not
|
59 |
+
* divide the file size a footer is added
|
60 |
+
* @access private
|
61 |
+
*/
|
62 |
+
var $footerLength = 0;
|
63 |
+
/**
|
64 |
+
* @var int nb bytes to seek back in order to reach the end of the archive
|
65 |
+
* or null if the end of the archive has not been reached
|
66 |
+
*/
|
67 |
+
var $seekToEnd = null;
|
68 |
+
|
69 |
+
/**
|
70 |
+
* @see File_Archive_Reader::skip()
|
71 |
+
*/
|
72 |
+
function skip($length = -1)
|
73 |
+
{
|
74 |
+
if ($length == -1) {
|
75 |
+
$length = $this->leftLength;
|
76 |
+
} else {
|
77 |
+
$length = min($this->leftLength, $length);
|
78 |
+
}
|
79 |
+
$skipped = $this->source->skip($length);
|
80 |
+
if (!PEAR::isError($skipped)) {
|
81 |
+
$this->leftLength -= $skipped;
|
82 |
+
}
|
83 |
+
return $skipped;
|
84 |
+
}
|
85 |
+
|
86 |
+
/**
|
87 |
+
* @see File_Archive_Reader::rewind()
|
88 |
+
*/
|
89 |
+
function rewind($length = -1)
|
90 |
+
{
|
91 |
+
if ($length == -1) {
|
92 |
+
$length = $this->currentStat[7] - $this->leftLength;
|
93 |
+
} else {
|
94 |
+
$length = min($length, $this->currentStat[7] - $this->leftLength);
|
95 |
+
}
|
96 |
+
$rewinded = $this->source->rewind($length);
|
97 |
+
if (!PEAR::isError($rewinded)) {
|
98 |
+
$this->leftLength += $rewinded;
|
99 |
+
}
|
100 |
+
return $rewinded;
|
101 |
+
}
|
102 |
+
|
103 |
+
/**
|
104 |
+
* @see File_Archive_Reader::tell()
|
105 |
+
*/
|
106 |
+
function tell()
|
107 |
+
{
|
108 |
+
return $this->currentStat[7] - $this->leftLength;
|
109 |
+
}
|
110 |
+
|
111 |
+
/**
|
112 |
+
* @see File_Archive_Reader::close()
|
113 |
+
*/
|
114 |
+
function close()
|
115 |
+
{
|
116 |
+
$this->leftLength = 0;
|
117 |
+
$this->currentFilename = null;
|
118 |
+
$this->currentStat = null;
|
119 |
+
$this->seekToEnd = null;
|
120 |
+
return parent::close();
|
121 |
+
}
|
122 |
+
|
123 |
+
/**
|
124 |
+
* @see File_Archive_Reader::getFilename()
|
125 |
+
*/
|
126 |
+
function getFilename() { return $this->currentFilename; }
|
127 |
+
/**
|
128 |
+
* @see File_Archive_Reader::getStat()
|
129 |
+
*/
|
130 |
+
function getStat() { return $this->currentStat; }
|
131 |
+
|
132 |
+
/**
|
133 |
+
* @see File_Archive_Reader::next()
|
134 |
+
*/
|
135 |
+
function next()
|
136 |
+
{
|
137 |
+
$error = parent::next();
|
138 |
+
if ($error !== true) {
|
139 |
+
return $error;
|
140 |
+
}
|
141 |
+
if ($this->seekToEnd !== null) {
|
142 |
+
return false;
|
143 |
+
}
|
144 |
+
|
145 |
+
do
|
146 |
+
{
|
147 |
+
$error = $this->source->skip($this->leftLength + $this->footerLength);
|
148 |
+
if (PEAR::isError($error)) {
|
149 |
+
return $error;
|
150 |
+
}
|
151 |
+
$rawHeader = $this->source->getData(512);
|
152 |
+
if (PEAR::isError($rawHeader)) {
|
153 |
+
return $rawHeader;
|
154 |
+
}
|
155 |
+
if (strlen($rawHeader)<512 || $rawHeader == pack("a512", "")) {
|
156 |
+
$this->seekToEnd = strlen($rawHeader);
|
157 |
+
$this->currentFilename = null;
|
158 |
+
return false;
|
159 |
+
}
|
160 |
+
|
161 |
+
$header = unpack(
|
162 |
+
"a100filename/a8mode/a8uid/a8gid/a12size/a12mtime/".
|
163 |
+
"a8checksum/a1type/a100linkname/a6magic/a2version/".
|
164 |
+
"a32uname/a32gname/a8devmajor/a8devminor/a155prefix",
|
165 |
+
$rawHeader);
|
166 |
+
$this->currentStat = array(
|
167 |
+
2 => octdec($header['mode']),
|
168 |
+
4 => octdec($header['uid']),
|
169 |
+
5 => octdec($header['gid']),
|
170 |
+
7 => octdec($header['size']),
|
171 |
+
9 => octdec($header['mtime'])
|
172 |
+
);
|
173 |
+
$this->currentStat['mode'] = $this->currentStat[2];
|
174 |
+
$this->currentStat['uid'] = $this->currentStat[4];
|
175 |
+
$this->currentStat['gid'] = $this->currentStat[5];
|
176 |
+
$this->currentStat['size'] = $this->currentStat[7];
|
177 |
+
$this->currentStat['mtime'] = $this->currentStat[9];
|
178 |
+
|
179 |
+
if ($header['magic'] == 'ustar') {
|
180 |
+
$this->currentFilename = $this->getStandardURL(
|
181 |
+
$header['prefix'] . $header['filename']
|
182 |
+
);
|
183 |
+
} else {
|
184 |
+
$this->currentFilename = $this->getStandardURL(
|
185 |
+
$header['filename']
|
186 |
+
);
|
187 |
+
}
|
188 |
+
|
189 |
+
$this->leftLength = $this->currentStat[7];
|
190 |
+
if ($this->leftLength % 512 == 0) {
|
191 |
+
$this->footerLength = 0;
|
192 |
+
} else {
|
193 |
+
$this->footerLength = 512 - $this->leftLength%512;
|
194 |
+
}
|
195 |
+
|
196 |
+
$checksum = 8*ord(" ");
|
197 |
+
for ($i = 0; $i < 148; $i++) {
|
198 |
+
$checksum += ord($rawHeader{$i});
|
199 |
+
}
|
200 |
+
for ($i = 156; $i < 512; $i++) {
|
201 |
+
$checksum += ord($rawHeader{$i});
|
202 |
+
}
|
203 |
+
|
204 |
+
if (octdec($header['checksum']) != $checksum) {
|
205 |
+
die('Checksum error on entry '.$this->currentFilename);
|
206 |
+
}
|
207 |
+
} while ($header['type'] != 0);
|
208 |
+
|
209 |
+
return true;
|
210 |
+
}
|
211 |
+
|
212 |
+
/**
|
213 |
+
* @see File_Archive_Reader::getData()
|
214 |
+
*/
|
215 |
+
function getData($length = -1)
|
216 |
+
{
|
217 |
+
if ($length == -1) {
|
218 |
+
$actualLength = $this->leftLength;
|
219 |
+
} else {
|
220 |
+
$actualLength = min($this->leftLength, $length);
|
221 |
+
}
|
222 |
+
|
223 |
+
if ($this->leftLength == 0) {
|
224 |
+
return null;
|
225 |
+
} else {
|
226 |
+
$data = $this->source->getData($actualLength);
|
227 |
+
if (strlen($data) != $actualLength) {
|
228 |
+
return PEAR::raiseError('Unexpected end of tar archive');
|
229 |
+
}
|
230 |
+
$this->leftLength -= $actualLength;
|
231 |
+
return $data;
|
232 |
+
}
|
233 |
+
}
|
234 |
+
|
235 |
+
/**
|
236 |
+
* @see File_Archive_Reader::makeWriterRemoveFiles()
|
237 |
+
*/
|
238 |
+
function makeWriterRemoveFiles($pred)
|
239 |
+
{
|
240 |
+
require_once $GLOBALS['bkpwp_plugin_path']."Archive/Writer/Tar.php";
|
241 |
+
|
242 |
+
$blocks = array();
|
243 |
+
$seek = null;
|
244 |
+
$gap = 0;
|
245 |
+
if ($this->currentFilename !== null && $pred->isTrue($this)) {
|
246 |
+
$seek = 512 + $this->currentStat[7] + $this->footerLength;
|
247 |
+
$blocks[] = $seek; //Remove this file
|
248 |
+
}
|
249 |
+
|
250 |
+
while (($error = $this->next()) === true) {
|
251 |
+
$size = 512 + $this->currentStat[7] + $this->footerLength;
|
252 |
+
if ($pred->isTrue($this)) {
|
253 |
+
if ($seek === null) {
|
254 |
+
$seek = $size;
|
255 |
+
$blocks[] = $size;
|
256 |
+
} else if ($gap > 0) {
|
257 |
+
$blocks[] = $gap; //Don't remove the files between the gap
|
258 |
+
$blocks[] = $size;
|
259 |
+
$seek += $size;
|
260 |
+
} else {
|
261 |
+
$blocks[count($blocks)-1] += $size; //Also remove this file
|
262 |
+
$seek += $size;
|
263 |
+
}
|
264 |
+
$gap = 0;
|
265 |
+
} else {
|
266 |
+
if ($seek !== null) {
|
267 |
+
$seek += $size;
|
268 |
+
$gap += $size;
|
269 |
+
}
|
270 |
+
}
|
271 |
+
}
|
272 |
+
if ($seek === null) {
|
273 |
+
$seek = $this->seekToEnd;
|
274 |
+
} else {
|
275 |
+
$seek += $this->seekToEnd;
|
276 |
+
if ($gap == 0) {
|
277 |
+
array_pop($blocks);
|
278 |
+
} else {
|
279 |
+
$blocks[] = $gap;
|
280 |
+
}
|
281 |
+
}
|
282 |
+
|
283 |
+
$writer = new File_Archive_Writer_Tar(null,
|
284 |
+
$this->source->makeWriterRemoveBlocks($blocks, -$seek)
|
285 |
+
);
|
286 |
+
$this->close();
|
287 |
+
return $writer;
|
288 |
+
}
|
289 |
+
|
290 |
+
/**
|
291 |
+
* @see File_Archive_Reader::makeWriterRemoveBlocks()
|
292 |
+
*/
|
293 |
+
function makeWriterRemoveBlocks($blocks, $seek = 0)
|
294 |
+
{
|
295 |
+
if ($this->seekToEnd !== null || $this->currentStat === null) {
|
296 |
+
return PEAR::raiseError('No file selected');
|
297 |
+
}
|
298 |
+
|
299 |
+
$blockPos = $this->currentStat[7] - $this->leftLength + $seek;
|
300 |
+
|
301 |
+
$this->rewind();
|
302 |
+
$keep = false;
|
303 |
+
|
304 |
+
$data = $this->getData($blockPos);
|
305 |
+
foreach ($blocks as $length) {
|
306 |
+
if ($keep) {
|
307 |
+
$data .= $this->getData($length);
|
308 |
+
} else {
|
309 |
+
$this->skip($length);
|
310 |
+
}
|
311 |
+
$keep = !$keep;
|
312 |
+
}
|
313 |
+
if ($keep) {
|
314 |
+
$data .= $this->getData();
|
315 |
+
}
|
316 |
+
|
317 |
+
$filename = $this->currentFilename;
|
318 |
+
$stat = $this->currentStat;
|
319 |
+
|
320 |
+
$writer = $this->makeWriterRemove();
|
321 |
+
if (PEAR::isError($writer)) {
|
322 |
+
return $writer;
|
323 |
+
}
|
324 |
+
|
325 |
+
unset($stat[7]);
|
326 |
+
$stat[9] = $stat['mtime'] = time();
|
327 |
+
$writer->newFile($filename, $stat);
|
328 |
+
$writer->writeData($data);
|
329 |
+
return $writer;
|
330 |
+
}
|
331 |
+
|
332 |
+
/**
|
333 |
+
* @see File_Archive_Reader::makeAppendWriter
|
334 |
+
*/
|
335 |
+
function makeAppendWriter()
|
336 |
+
{
|
337 |
+
require_once $GLOBALS['bkpwp_plugin_path']."Archive/Writer/Tar.php";
|
338 |
+
|
339 |
+
while (($error = $this->next()) === true) { }
|
340 |
+
if (PEAR::isError($error)) {
|
341 |
+
$this->close();
|
342 |
+
return $error;
|
343 |
+
}
|
344 |
+
|
345 |
+
$innerWriter = $this->source->makeWriterRemoveBlocks(array(), -$this->seekToEnd);
|
346 |
+
if (PEAR::isError($innerWriter)) {
|
347 |
+
return $innerWriter;
|
348 |
+
}
|
349 |
+
|
350 |
+
$this->close();
|
351 |
+
return new File_Archive_Writer_Tar(null, $innerWriter);
|
352 |
+
}
|
353 |
+
}
|
354 |
+
|
355 |
+
?>
|
Archive/Reader/Uncompress.php
ADDED
@@ -0,0 +1,312 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
|
3 |
+
|
4 |
+
/**
|
5 |
+
* Recursively uncompress every file it finds
|
6 |
+
*
|
7 |
+
* PHP versions 4 and 5
|
8 |
+
*
|
9 |
+
* This library is free software; you can redistribute it and/or
|
10 |
+
* modify it under the terms of the GNU Lesser General Public
|
11 |
+
* License as published by the Free Software Foundation; either
|
12 |
+
* version 2.1 of the License, or (at your option) any later version.
|
13 |
+
*
|
14 |
+
* This library is distributed in the hope that it will be useful,
|
15 |
+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
16 |
+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
17 |
+
* Lesser General Public License for more details.
|
18 |
+
*
|
19 |
+
* You should have received a copy of the GNU Lesser General Public
|
20 |
+
* License along with this library; if not, write to the Free Software
|
21 |
+
* Foundation, Inc., 59 Temple Place, Suite 330,Boston,MA 02111-1307 USA
|
22 |
+
*
|
23 |
+
* @category File Formats
|
24 |
+
* @package File_Archive
|
25 |
+
* @author Vincent Lascaux <vincentlascaux@php.net>
|
26 |
+
* @copyright 1997-2005 The PHP Group
|
27 |
+
* @license http://www.gnu.org/copyleft/lesser.html LGPL
|
28 |
+
* @version CVS: $Id: Uncompress.php,v 1.32 2005/07/09 12:54:35 vincentlascaux Exp $
|
29 |
+
* @link http://pear.php.net/package/File_Archive
|
30 |
+
*/
|
31 |
+
|
32 |
+
require_once $GLOBALS['bkpwp_plugin_path']."Archive/Reader.php";
|
33 |
+
require_once $GLOBALS['bkpwp_plugin_path']."Archive/Reader/ChangeName.php";
|
34 |
+
|
35 |
+
/**
|
36 |
+
* Recursively uncompress every file it finds
|
37 |
+
*/
|
38 |
+
class File_Archive_Reader_Uncompress extends File_Archive_Reader_Relay
|
39 |
+
{
|
40 |
+
/**
|
41 |
+
* @var Array Stack of readers
|
42 |
+
* @access private
|
43 |
+
*/
|
44 |
+
var $readers = array();
|
45 |
+
|
46 |
+
/**
|
47 |
+
* @var array of readers to close when closing $this
|
48 |
+
* @access private
|
49 |
+
*/
|
50 |
+
var $toClose = array();
|
51 |
+
|
52 |
+
/**
|
53 |
+
* @var File_Archive_Reader Reader from which all started (usefull to be
|
54 |
+
* able to close)
|
55 |
+
* @access private
|
56 |
+
*/
|
57 |
+
var $startReader;
|
58 |
+
|
59 |
+
/**
|
60 |
+
* @var Int Maximum depth of uncompression after the basicDir
|
61 |
+
* (that may contain some uncompression also)
|
62 |
+
* -1 means no limit
|
63 |
+
* @access private
|
64 |
+
*/
|
65 |
+
var $uncompressionLevel;
|
66 |
+
|
67 |
+
/**
|
68 |
+
* @var array Only files starting with $baseDir will be reported
|
69 |
+
* This array contains explode('/', $directoryName)
|
70 |
+
* @access private
|
71 |
+
*/
|
72 |
+
var $baseDir = '';
|
73 |
+
|
74 |
+
/**
|
75 |
+
* @var int Compression level required to go to reach the baseDir
|
76 |
+
* or null if it is currently being computed
|
77 |
+
* @access private
|
78 |
+
*/
|
79 |
+
var $baseDirCompressionLevel = null;
|
80 |
+
|
81 |
+
/**
|
82 |
+
* @var int We are selecting substr($baseDir, 0, $baseDirProgression)
|
83 |
+
*/
|
84 |
+
var $baseDirProgression = 0;
|
85 |
+
|
86 |
+
/**
|
87 |
+
* @var boolean Flag set to indicate that the current file has not been
|
88 |
+
* displayed
|
89 |
+
*/
|
90 |
+
var $currentFileNotDisplayed = false;
|
91 |
+
|
92 |
+
function File_Archive_Reader_Uncompress(
|
93 |
+
&$innerReader, $uncompressionLevel = -1)
|
94 |
+
{
|
95 |
+
parent::File_Archive_Reader_Relay($innerReader);
|
96 |
+
$this->startReader =& $innerReader;
|
97 |
+
$this->uncompressionLevel = $uncompressionLevel;
|
98 |
+
}
|
99 |
+
|
100 |
+
/**
|
101 |
+
* Attempt to change the current source (if the current file is an archive)
|
102 |
+
* If this is the case, push the current source onto the stack and make the
|
103 |
+
* good archive reader the current source. A file is considered as an
|
104 |
+
* archive if its extension is one of tar, gz, zip, tgz
|
105 |
+
*
|
106 |
+
* @return bool whether the source has been pushed or not
|
107 |
+
* @access private
|
108 |
+
*/
|
109 |
+
function push()
|
110 |
+
{
|
111 |
+
if ($this->uncompressionLevel >= 0 &&
|
112 |
+
$this->baseDirCompressionLevel !== null &&
|
113 |
+
count($this->readers) >= $this->uncompressionLevel
|
114 |
+
) {
|
115 |
+
return false;
|
116 |
+
}
|
117 |
+
|
118 |
+
// Check the extension of the file (maybe we need to uncompress it?)
|
119 |
+
$filename = $this->source->getFilename();
|
120 |
+
|
121 |
+
$extensions = explode('.', strtolower($filename));
|
122 |
+
|
123 |
+
$reader =& $this->source;
|
124 |
+
$nbUncompressions = 0;
|
125 |
+
|
126 |
+
while (($extension = array_pop($extensions)) !== null) {
|
127 |
+
$nbUncompressions++;
|
128 |
+
unset($next);
|
129 |
+
$next = File_Archive::readArchive($extension, $reader, $nbUncompressions == 1);
|
130 |
+
if ($next === false) {
|
131 |
+
$extensions = array();
|
132 |
+
} else {
|
133 |
+
unset($reader);
|
134 |
+
$reader =& $next;
|
135 |
+
}
|
136 |
+
}
|
137 |
+
if ($nbUncompressions == 1) {
|
138 |
+
return false;
|
139 |
+
} else {
|
140 |
+
$this->readers[count($this->readers)] =& $this->source;
|
141 |
+
unset($this->source);
|
142 |
+
$this->source = new File_Archive_Reader_AddBaseName(
|
143 |
+
$filename, $reader
|
144 |
+
);
|
145 |
+
return true;
|
146 |
+
}
|
147 |
+
}
|
148 |
+
/**
|
149 |
+
* @see File_Archive_Reader::close()
|
150 |
+
*/
|
151 |
+
function next()
|
152 |
+
{
|
153 |
+
if ($this->currentFileNotDisplayed) {
|
154 |
+
$this->currentFileNotDisplayed = false;
|
155 |
+
return true;
|
156 |
+
}
|
157 |
+
|
158 |
+
do {
|
159 |
+
do {
|
160 |
+
$selection = substr($this->baseDir, 0, $this->baseDirProgression);
|
161 |
+
if ($selection === false) {
|
162 |
+
$selection = '';
|
163 |
+
}
|
164 |
+
|
165 |
+
$error = $this->source->select($selection, false);
|
166 |
+
if (PEAR::isError($error)) {
|
167 |
+
return $error;
|
168 |
+
}
|
169 |
+
if (!$error) {
|
170 |
+
if (empty($this->readers)) {
|
171 |
+
return false;
|
172 |
+
}
|
173 |
+
$this->source->close();
|
174 |
+
unset($this->source);
|
175 |
+
$this->source =& $this->readers[count($this->readers)-1];
|
176 |
+
unset($this->readers[count($this->readers)-1]);
|
177 |
+
}
|
178 |
+
} while (!$error);
|
179 |
+
|
180 |
+
$filename = $this->source->getFilename();
|
181 |
+
if (strlen($filename) < strlen($this->baseDir)) {
|
182 |
+
$goodFile = (strncmp($filename, $this->baseDir, strlen($filename)) == 0 &&
|
183 |
+
$this->baseDir{strlen($filename)} == '/');
|
184 |
+
if ($goodFile) {
|
185 |
+
if (strlen($filename) + 2 < strlen($this->baseDirProgression)) {
|
186 |
+
$this->baseDirProgression = strpos($this->baseDir, '/', strlen($filename)+2);
|
187 |
+
if ($this->baseDirProgression === false) {
|
188 |
+
$this->baseDirProgression = strlen($this->baseDir);
|
189 |
+
}
|
190 |
+
} else {
|
191 |
+
$this->baseDirProgression = strlen($this->baseDir);
|
192 |
+
}
|
193 |
+
}
|
194 |
+
} else {
|
195 |
+
$goodFile = (strncmp($filename, $this->baseDir, strlen($this->baseDir)) == 0);
|
196 |
+
if ($goodFile) {
|
197 |
+
$this->baseDirProgression = strlen($this->baseDir);
|
198 |
+
}
|
199 |
+
}
|
200 |
+
} while ($goodFile && $this->push());
|
201 |
+
|
202 |
+
return true;
|
203 |
+
}
|
204 |
+
|
205 |
+
/**
|
206 |
+
* Efficiently filter out the files which URL does not start with $baseDir
|
207 |
+
* Throws an error if the $baseDir can't be found
|
208 |
+
* @return bool Whether baseDir was a directory or a file
|
209 |
+
*/
|
210 |
+
function setBaseDir($baseDir)
|
211 |
+
{
|
212 |
+
$this->baseDir = $baseDir;
|
213 |
+
$this->baseDirProgression = strpos($baseDir, '/');
|
214 |
+
if ($this->baseDirProgression === false) {
|
215 |
+
$this->baseDirProgression = strlen($baseDir);
|
216 |
+
}
|
217 |
+
|
218 |
+
$error = $this->next();
|
219 |
+
if ($error === false) {
|
220 |
+
return PEAR::raiseError("No directory $baseDir in inner reader");
|
221 |
+
} else if (PEAR::isError($error)) {
|
222 |
+
return $error;
|
223 |
+
}
|
224 |
+
|
225 |
+
$this->currentFileNotDisplayed = true;
|
226 |
+
return strlen($this->getFilename())>strlen($baseDir);
|
227 |
+
}
|
228 |
+
/**
|
229 |
+
* @see File_Archive_Reader::select()
|
230 |
+
*/
|
231 |
+
function select($filename, $close = true)
|
232 |
+
{
|
233 |
+
if ($close) {
|
234 |
+
$error = $this->close();
|
235 |
+
if (PEAR::isError($close)) {
|
236 |
+
return $error;
|
237 |
+
}
|
238 |
+
}
|
239 |
+
|
240 |
+
$oldBaseDir = $this->baseDir;
|
241 |
+
$oldProgression = $this->baseDirProgression;
|
242 |
+
|
243 |
+
$this->baseDir = $filename;
|
244 |
+
$this->baseDirProgression = 0;
|
245 |
+
|
246 |
+
$res = $this->next();
|
247 |
+
|
248 |
+
$this->baseDir = $oldBaseDir;
|
249 |
+
$this->baseDirProgression = $oldProgression;
|
250 |
+
|
251 |
+
return $res;
|
252 |
+
}
|
253 |
+
|
254 |
+
/**
|
255 |
+
* @see File_Archive_Reader::close()
|
256 |
+
*/
|
257 |
+
function close()
|
258 |
+
{
|
259 |
+
for ($i=0; $i<count($this->readers); ++$i) {
|
260 |
+
$this->readers[$i]->close();
|
261 |
+
}
|
262 |
+
//var_dump($this->toClose);
|
263 |
+
for ($i=0; $i<count($this->toClose); ++$i) {
|
264 |
+
if ($this->toClose[$i] !== null) {
|
265 |
+
$this->toClose[$i]->close();
|
266 |
+
}
|
267 |
+
}
|
268 |
+
|
269 |
+
$this->readers = array();
|
270 |
+
$this->toClose = array();
|
271 |
+
$error = parent::close();
|
272 |
+
$this->baseDirCompressionLevel = null;
|
273 |
+
$this->baseDirProgression = 0;
|
274 |
+
|
275 |
+
unset($this->source);
|
276 |
+
$this->source =& $this->startReader;
|
277 |
+
$this->source->close();
|
278 |
+
$this->currentFileNotDisplayed = false;
|
279 |
+
|
280 |
+
return $error;
|
281 |
+
}
|
282 |
+
|
283 |
+
/**
|
284 |
+
* @see File_Archive_Reader::makeAppendWriter()
|
285 |
+
*/
|
286 |
+
function makeAppendWriter()
|
287 |
+
{
|
288 |
+
//The reader needs to be open so that the base dir is found
|
289 |
+
$error = $this->next();
|
290 |
+
if (PEAR::isError($error)) {
|
291 |
+
return $error;
|
292 |
+
}
|
293 |
+
|
294 |
+
return parent::makeAppendWriter();
|
295 |
+
}
|
296 |
+
|
297 |
+
/**
|
298 |
+
* @see File_Archive_Reader::makeWriterRemoveFiles()
|
299 |
+
*/
|
300 |
+
function makeWriterRemoveFiles($pred)
|
301 |
+
{
|
302 |
+
//The reader needs to be open so that the base dir is found
|
303 |
+
$error = $this->next();
|
304 |
+
if (PEAR::isError($error)) {
|
305 |
+
return $error;
|
306 |
+
}
|
307 |
+
|
308 |
+
return parent::makeWriterRemoveFiles($pred);
|
309 |
+
}
|
310 |
+
}
|
311 |
+
|
312 |
+
?>
|
Archive/Reader/Zip.php
ADDED
@@ -0,0 +1,493 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
|
3 |
+
|
4 |
+
/**
|
5 |
+
* ZIP archive reader
|
6 |
+
*
|
7 |
+
* PHP versions 4 and 5
|
8 |
+
*
|
9 |
+
* This library is free software; you can redistribute it and/or
|
10 |
+
* modify it under the terms of the GNU Lesser General Public
|
11 |
+
* License as published by the Free Software Foundation; either
|
12 |
+
* version 2.1 of the License, or (at your option) any later version.
|
13 |
+
*
|
14 |
+
* This library is distributed in the hope that it will be useful,
|
15 |
+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
16 |
+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
17 |
+
* Lesser General Public License for more details.
|
18 |
+
*
|
19 |
+
* You should have received a copy of the GNU Lesser General Public
|
20 |
+
* License along with this library; if not, write to the Free Software
|
21 |
+
* Foundation, Inc., 59 Temple Place, Suite 330,Boston,MA 02111-1307 USA
|
22 |
+
*
|
23 |
+
* @category File Formats
|
24 |
+
* @package File_Archive
|
25 |
+
* @author Vincent Lascaux <vincentlascaux@php.net>
|
26 |
+
* @copyright 1997-2005 The PHP Group
|
27 |
+
* @license http://www.gnu.org/copyleft/lesser.html LGPL
|
28 |
+
* @version CVS: $Id: Zip.php,v 1.26 2005/06/19 20:09:58 vincentlascaux Exp $
|
29 |
+
* @link http://pear.php.net/package/File_Archive
|
30 |
+
*/
|
31 |
+
|
32 |
+
require_once $GLOBALS['bkpwp_plugin_path']."Archive/Reader/Archive.php";
|
33 |
+
|
34 |
+
/**
|
35 |
+
* ZIP archive reader
|
36 |
+
* Currently only allows to browse the archive (getData is not available)
|
37 |
+
*/
|
38 |
+
class File_Archive_Reader_Zip extends File_Archive_Reader_Archive
|
39 |
+
{
|
40 |
+
var $currentFilename = null;
|
41 |
+
var $currentStat = null;
|
42 |
+
var $header = null;
|
43 |
+
var $offset = 0;
|
44 |
+
var $data = null;
|
45 |
+
var $files = array();
|
46 |
+
var $seekToEnd = 0;
|
47 |
+
|
48 |
+
var $centralDirectory = null;
|
49 |
+
|
50 |
+
/**
|
51 |
+
* @see File_Archive_Reader::close()
|
52 |
+
*/
|
53 |
+
function close()
|
54 |
+
{
|
55 |
+
$this->currentFilename = null;
|
56 |
+
$this->currentStat = null;
|
57 |
+
$this->compLength = 0;
|
58 |
+
$this->data = null;
|
59 |
+
$this->seekToEnd = 0;
|
60 |
+
$this->files = array();
|
61 |
+
$this->centralDirectory = null;
|
62 |
+
|
63 |
+
return parent::close();
|
64 |
+
}
|
65 |
+
|
66 |
+
/**
|
67 |
+
* @see File_Archive_Reader::getFilename()
|
68 |
+
*/
|
69 |
+
function getFilename() { return $this->currentFilename; }
|
70 |
+
/**
|
71 |
+
* @see File_Archive_Reader::getStat()
|
72 |
+
*/
|
73 |
+
function getStat() { return $this->currentStat; }
|
74 |
+
|
75 |
+
/**
|
76 |
+
* Go to next entry in ZIP archive
|
77 |
+
* This function may stop on a folder, so it does not comply to the
|
78 |
+
* File_Archive_Reader::next specs
|
79 |
+
*
|
80 |
+
* @see File_Archive_Reader::next()
|
81 |
+
*/
|
82 |
+
function nextWithFolders()
|
83 |
+
{
|
84 |
+
if ($this->seekToEnd > 0) {
|
85 |
+
return false;
|
86 |
+
}
|
87 |
+
|
88 |
+
//Skip the data and the footer if they haven't been uncompressed
|
89 |
+
if ($this->header !== null && $this->data === null) {
|
90 |
+
$toSkip = $this->header['CLen'];
|
91 |
+
$error = $this->source->skip($toSkip);
|
92 |
+
if (PEAR::isError($error)) {
|
93 |
+
return $error;
|
94 |
+
}
|
95 |
+
}
|
96 |
+
|
97 |
+
$this->offset = 0;
|
98 |
+
$this->data = null;
|
99 |
+
|
100 |
+
//Read the header
|
101 |
+
$header = $this->source->getData(4);
|
102 |
+
if (PEAR::isError($header)) {
|
103 |
+
return $header;
|
104 |
+
}
|
105 |
+
if ($header == "\x50\x4b\x03\x04") {
|
106 |
+
//New entry
|
107 |
+
$header = $this->source->getData(26);
|
108 |
+
if (PEAR::isError($header)) {
|
109 |
+
return $header;
|
110 |
+
}
|
111 |
+
$this->header = unpack(
|
112 |
+
"vVersion/vFlag/vMethod/vTime/vDate/VCRC/VCLen/VNLen/vFile/vExtra",
|
113 |
+
$header);
|
114 |
+
|
115 |
+
//Check the compression method
|
116 |
+
if ($this->header['Method'] != 0 &&
|
117 |
+
$this->header['Method'] != 8 &&
|
118 |
+
$this->header['Method'] != 12) {
|
119 |
+
return PEAR::raiseError("File_Archive_Reader_Zip doesn't ".
|
120 |
+
"handle compression method {$this->header['Method']}");
|
121 |
+
}
|
122 |
+
if ($this->header['Flag'] & 1) {
|
123 |
+
return PEAR::raiseError("File_Archive_Reader_Zip doesn't ".
|
124 |
+
"handle encrypted files");
|
125 |
+
}
|
126 |
+
if ($this->header['Flag'] & 8) {
|
127 |
+
if ($this->centralDirectory === null) {
|
128 |
+
$this->readCentralDirectory();
|
129 |
+
}
|
130 |
+
$centralDirEntry = $this->centralDirectory[count($this->files)];
|
131 |
+
|
132 |
+
$this->header['CRC'] = $centralDirEntry['CRC'];
|
133 |
+
$this->header['CLen'] = $centralDirEntry['CLen'];
|
134 |
+
$this->header['NLen'] = $centralDirEntry['NLen'];
|
135 |
+
}
|
136 |
+
if ($this->header['Flag'] & 32) {
|
137 |
+
return PEAR::raiseError("File_Archive_Reader_Zip doesn't ".
|
138 |
+
"handle compressed patched data");
|
139 |
+
}
|
140 |
+
if ($this->header['Flag'] & 64) {
|
141 |
+
return PEAR::raiseError("File_Archive_Reader_Zip doesn't ".
|
142 |
+
"handle strong encrypted files");
|
143 |
+
}
|
144 |
+
|
145 |
+
$this->currentStat = array(
|
146 |
+
7=>$this->header['NLen'],
|
147 |
+
9=>mktime(
|
148 |
+
($this->header['Time'] & 0xF800) >> 11, //hour
|
149 |
+
($this->header['Time'] & 0x07E0) >> 5, //minute
|
150 |
+
($this->header['Time'] & 0x001F) >> 1, //second
|
151 |
+
($this->header['Date'] & 0x01E0) >> 5, //month
|
152 |
+
($this->header['Date'] & 0x001F) , //day
|
153 |
+
(($this->header['Date'] & 0xFE00) >> 9) + 1980 //year
|
154 |
+
)
|
155 |
+
);
|
156 |
+
$this->currentStat['size'] = $this->currentStat[7];
|
157 |
+
$this->currentStat['mtime'] = $this->currentStat[9];
|
158 |
+
|
159 |
+
$this->currentFilename = $this->source->getData($this->header['File']);
|
160 |
+
|
161 |
+
$error = $this->source->skip($this->header['Extra']);
|
162 |
+
if (PEAR::isError($error)) {
|
163 |
+
return $error;
|
164 |
+
}
|
165 |
+
|
166 |
+
$this->files[] = array('name' => $this->currentFilename,
|
167 |
+
'stat' => $this->currentStat,
|
168 |
+
'CRC' => $this->header['CRC'],
|
169 |
+
'CLen' => $this->header['CLen']
|
170 |
+
);
|
171 |
+
|
172 |
+
return true;
|
173 |
+
} else {
|
174 |
+
//Begining of central area
|
175 |
+
$this->seekToEnd = 4;
|
176 |
+
$this->currentFilename = null;
|
177 |
+
return false;
|
178 |
+
}
|
179 |
+
}
|
180 |
+
/**
|
181 |
+
* Go to next file entry in ZIP archive
|
182 |
+
* This function will not stop on a folder entry
|
183 |
+
* @see File_Archive_Reader::next()
|
184 |
+
*/
|
185 |
+
function next()
|
186 |
+
{
|
187 |
+
if (!parent::next()) {
|
188 |
+
return false;
|
189 |
+
}
|
190 |
+
|
191 |
+
do {
|
192 |
+
$result = $this->nextWithFolders();
|
193 |
+
if ($result !== true) {
|
194 |
+
return $result;
|
195 |
+
}
|
196 |
+
} while (substr($this->getFilename(), -1) == '/');
|
197 |
+
|
198 |
+
return true;
|
199 |
+
}
|
200 |
+
|
201 |
+
/**
|
202 |
+
* @see File_Archive_Reader::getData()
|
203 |
+
*/
|
204 |
+
function getData($length = -1)
|
205 |
+
{
|
206 |
+
if ($this->offset >= $this->currentStat[7]) {
|
207 |
+
return null;
|
208 |
+
}
|
209 |
+
|
210 |
+
if ($length>=0) {
|
211 |
+
$actualLength = min($length, $this->currentStat[7]-$this->offset);
|
212 |
+
} else {
|
213 |
+
$actualLength = $this->currentStat[7]-$this->offset;
|
214 |
+
}
|
215 |
+
|
216 |
+
$error = $this->uncompressData();
|
217 |
+
if (PEAR::isError($error)) {
|
218 |
+
return $error;
|
219 |
+
}
|
220 |
+
$result = substr($this->data, $this->offset, $actualLength);
|
221 |
+
$this->offset += $actualLength;
|
222 |
+
return $result;
|
223 |
+
}
|
224 |
+
/**
|
225 |
+
* @see File_Archive_Reader::skip()
|
226 |
+
*/
|
227 |
+
function skip($length = -1)
|
228 |
+
{
|
229 |
+
$before = $this->offset;
|
230 |
+
if ($length == -1) {
|
231 |
+
$this->offset = $this->currentStat[7];
|
232 |
+
} else {
|
233 |
+
$this->offset = min($this->offset + $length, $this->currentStat[7]);
|
234 |
+
}
|
235 |
+
return $this->offset - $before;
|
236 |
+
}
|
237 |
+
/**
|
238 |
+
* @see File_Archive_Reader::rewind()
|
239 |
+
*/
|
240 |
+
function rewind($length = -1)
|
241 |
+
{
|
242 |
+
$before = $this->offset;
|
243 |
+
if ($length == -1) {
|
244 |
+
$this->offset = 0;
|
245 |
+
} else {
|
246 |
+
$this->offset = min(0, $this->offset - $length);
|
247 |
+
}
|
248 |
+
return $before - $this->offset;
|
249 |
+
}
|
250 |
+
/**
|
251 |
+
* @see File_Archive_Reader::tell()
|
252 |
+
*/
|
253 |
+
function tell()
|
254 |
+
{
|
255 |
+
return $this->offset;
|
256 |
+
}
|
257 |
+
|
258 |
+
function uncompressData()
|
259 |
+
{
|
260 |
+
if ($this->data !== null)
|
261 |
+
return;
|
262 |
+
|
263 |
+
$this->data = $this->source->getData($this->header['CLen']);
|
264 |
+
if (PEAR::isError($this->data)) {
|
265 |
+
return $this->data;
|
266 |
+
}
|
267 |
+
if ($this->header['Method'] == 8) {
|
268 |
+
$this->data = gzinflate($this->data);
|
269 |
+
}
|
270 |
+
if ($this->header['Method'] == 12) {
|
271 |
+
$this->data = bzdecompress($this->data);
|
272 |
+
}
|
273 |
+
|
274 |
+
if (crc32($this->data) != $this->header['CRC']) {
|
275 |
+
return PEAR::raiseError("Zip archive: CRC fails on entry ".
|
276 |
+
$this->currentFilename);
|
277 |
+
}
|
278 |
+
}
|
279 |
+
|
280 |
+
/**
|
281 |
+
* @see File_Archive_Reader::makeWriterRemoveFiles()
|
282 |
+
*/
|
283 |
+
function makeWriterRemoveFiles($pred)
|
284 |
+
{
|
285 |
+
require_once $GLOBALS['bkpwp_plugin_path']."Archive/Writer/Zip.php";
|
286 |
+
|
287 |
+
$blocks = array();
|
288 |
+
$seek = null;
|
289 |
+
$gap = 0;
|
290 |
+
if ($this->currentFilename !== null && $pred->isTrue($this)) {
|
291 |
+
$seek = 30 + $this->header['File'] + $this->header['Extra'] + $this->header['CLen'];
|
292 |
+
$blocks[] = $seek; //Remove this file
|
293 |
+
array_pop($this->files);
|
294 |
+
}
|
295 |
+
|
296 |
+
while (($error = $this->nextWithFolders()) === true) {
|
297 |
+
$size = 30 + $this->header['File'] + $this->header['Extra'] + $this->header['CLen'];
|
298 |
+
if (substr($this->getFilename(), -1) == '/' || $pred->isTrue($this)) {
|
299 |
+
array_pop($this->files);
|
300 |
+
if ($seek === null) {
|
301 |
+
$seek = $size;
|
302 |
+
$blocks[] = $size;
|
303 |
+
} else if ($gap > 0) {
|
304 |
+
$blocks[] = $gap; //Don't remove the files between the gap
|
305 |
+
$blocks[] = $size;
|
306 |
+
$seek += $size;
|
307 |
+
} else {
|
308 |
+
$blocks[count($blocks)-1] += $size; //Also remove this file
|
309 |
+
$seek += $size;
|
310 |
+
}
|
311 |
+
$gap = 0;
|
312 |
+
} else {
|
313 |
+
if ($seek !== null) {
|
314 |
+
$seek += $size;
|
315 |
+
$gap += $size;
|
316 |
+
}
|
317 |
+
}
|
318 |
+
}
|
319 |
+
if (PEAR::isError($error)) {
|
320 |
+
return $error;
|
321 |
+
}
|
322 |
+
|
323 |
+
if ($seek === null) {
|
324 |
+
$seek = 4;
|
325 |
+
} else {
|
326 |
+
$seek += 4;
|
327 |
+
if ($gap == 0) {
|
328 |
+
array_pop($blocks);
|
329 |
+
} else {
|
330 |
+
$blocks[] = $gap;
|
331 |
+
}
|
332 |
+
}
|
333 |
+
|
334 |
+
$writer = new File_Archive_Writer_Zip(null,
|
335 |
+
$this->source->makeWriterRemoveBlocks($blocks, -$seek)
|
336 |
+
);
|
337 |
+
if (PEAR::isError($writer)) {
|
338 |
+
return $writer;
|
339 |
+
}
|
340 |
+
|
341 |
+
foreach ($this->files as $file) {
|
342 |
+
$writer->alreadyWrittenFile($file['name'], $file['stat'], $file['CRC'], $file['CLen']);
|
343 |
+
}
|
344 |
+
|
345 |
+
$this->close();
|
346 |
+
return $writer;
|
347 |
+
}
|
348 |
+
|
349 |
+
/**
|
350 |
+
* @see File_Archive_Reader::makeWriterRemoveBlocks()
|
351 |
+
*/
|
352 |
+
function makeWriterRemoveBlocks($blocks, $seek = 0)
|
353 |
+
{
|
354 |
+
if ($this->currentFilename === null) {
|
355 |
+
return PEAR::raiseError('No file selected');
|
356 |
+
}
|
357 |
+
|
358 |
+
$keep = false;
|
359 |
+
|
360 |
+
$this->uncompressData();
|
361 |
+
$newData = substr($this->data, 0, $this->offset + $seek);
|
362 |
+
$this->data = substr($this->data, $this->offset + $seek);
|
363 |
+
foreach ($blocks as $length) {
|
364 |
+
if ($keep) {
|
365 |
+
$newData .= substr($this->data, 0, $length);
|
366 |
+
}
|
367 |
+
$this->data = substr($this->data, $length);
|
368 |
+
$keep = !$keep;
|
369 |
+
}
|
370 |
+
if ($keep) {
|
371 |
+
$newData .= $this->data;
|
372 |
+
}
|
373 |
+
|
374 |
+
$filename = $this->currentFilename;
|
375 |
+
$stat = $this->currentStat;
|
376 |
+
|
377 |
+
$writer = $this->makeWriterRemove();
|
378 |
+
if (PEAR::isError($writer)) {
|
379 |
+
return $writer;
|
380 |
+
}
|
381 |
+
|
382 |
+
unset($stat[7]);
|
383 |
+
$stat[9] = $stat['mtime'] = time();
|
384 |
+
$writer->newFile($filename, $stat);
|
385 |
+
$writer->writeData($newData);
|
386 |
+
return $writer;
|
387 |
+
}
|
388 |
+
|
389 |
+
/**
|
390 |
+
* @see File_Archive_Reader::makeAppendWriter
|
391 |
+
*/
|
392 |
+
function makeAppendWriter()
|
393 |
+
{
|
394 |
+
require_once $GLOBALS['bkpwp_plugin_path']."Archive/Writer/Zip.php";
|
395 |
+
|
396 |
+
while (($error = $this->next()) === true) { }
|
397 |
+
if (PEAR::isError($error)) {
|
398 |
+
$this->close();
|
399 |
+
return $error;
|
400 |
+
}
|
401 |
+
|
402 |
+
$writer = new File_Archive_Writer_Zip(null,
|
403 |
+
$this->source->makeWriterRemoveBlocks(array(), -4)
|
404 |
+
);
|
405 |
+
|
406 |
+
foreach ($this->files as $file) {
|
407 |
+
$writer->alreadyWrittenFile($file['name'], $file['stat'], $file['CRC'], $file['CLen']);
|
408 |
+
}
|
409 |
+
|
410 |
+
$this->close();
|
411 |
+
return $writer;
|
412 |
+
}
|
413 |
+
|
414 |
+
/**
|
415 |
+
* This function seeks to the start of the [end of central directory] field,
|
416 |
+
* just after the \x50\x4b\x05\x06 signature and returns the number of bytes
|
417 |
+
* skipped
|
418 |
+
*
|
419 |
+
* The stream must initially be positioned before the end of central directory
|
420 |
+
*/
|
421 |
+
function seekToEndOfCentralDirectory()
|
422 |
+
{
|
423 |
+
$nbSkipped = $this->source->skip();
|
424 |
+
|
425 |
+
$nbSkipped -= $this->source->rewind(22) - 4;
|
426 |
+
if ($this->source->getData(4) == "\x50\x4b\x05\x06") {
|
427 |
+
return $nbSkipped;
|
428 |
+
}
|
429 |
+
|
430 |
+
while ($nbSkipped > 0) {
|
431 |
+
|
432 |
+
$nbRewind = $this->source->rewind(min(100, $nbSkipped));
|
433 |
+
while ($nbRewind >= -4) {
|
434 |
+
if ($nbRewind-- && $this->source->getData(1) == "\x50" &&
|
435 |
+
$nbRewind-- && $this->source->getData(1) == "\x4b" &&
|
436 |
+
$nbRewind-- && $this->source->getData(1) == "\x05" &&
|
437 |
+
$nbRewind-- && $this->source->getData(1) == "\x06") {
|
438 |
+
//We finally found it!
|
439 |
+
return $nbSkipped - $nbRewind;
|
440 |
+
}
|
441 |
+
}
|
442 |
+
$nbSkipped -= $nbRewind;
|
443 |
+
}
|
444 |
+
|
445 |
+
return PEAR::raiseError('End of central directory not found. The file is probably not a zip archive');
|
446 |
+
}
|
447 |
+
|
448 |
+
/**
|
449 |
+
* This function will fill the central directory variable
|
450 |
+
* and seek back to where it was called
|
451 |
+
*/
|
452 |
+
function readCentralDirectory()
|
453 |
+
{
|
454 |
+
$nbSkipped = $this->seekToEndOfCentralDirectory();
|
455 |
+
if (PEAR::isError($nbSkipped)) {
|
456 |
+
return $nbSkipped;
|
457 |
+
}
|
458 |
+
|
459 |
+
$this->source->skip(12);
|
460 |
+
$offset = $this->source->getData(4);
|
461 |
+
$nbSkipped += 16;
|
462 |
+
if (PEAR::isError($offset)) {
|
463 |
+
return $offset;
|
464 |
+
}
|
465 |
+
|
466 |
+
$offset = unpack("Vvalue", $offset);
|
467 |
+
$offset = $offset['value'];
|
468 |
+
|
469 |
+
$current = $this->source->tell();
|
470 |
+
$nbSkipped -= $this->source->rewind($current - $offset);
|
471 |
+
|
472 |
+
//Now we are the right pos to read the central directory
|
473 |
+
$this->centralDirectory = array();
|
474 |
+
while ($this->source->getData(4) == "\x50\x4b\x01\x02") {
|
475 |
+
$this->source->skip(12);
|
476 |
+
$header = $this->source->getData(16);
|
477 |
+
$nbSkipped += 32;
|
478 |
+
|
479 |
+
if (PEAR::isError($header)) {
|
480 |
+
return $header;
|
481 |
+
}
|
482 |
+
|
483 |
+
$header = unpack('VCRC/VCLen/VNLen/vFileLength/vExtraLength', $header);
|
484 |
+
$this->centralDirectory[] = array('CRC' => $header['CRC'],
|
485 |
+
'CLen' => $header['CLen'],
|
486 |
+
'NLen' => $header['NLen']);
|
487 |
+
$nbSkipped += $this->source->skip(14 + $header['FileLength'] + $header['ExtraLength']);
|
488 |
+
}
|
489 |
+
|
490 |
+
$this->source->rewind($nbSkipped+4);
|
491 |
+
}
|
492 |
+
}
|
493 |
+
?>
|
Archive/Writer.php
ADDED
@@ -0,0 +1,119 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
|
3 |
+
|
4 |
+
/**
|
5 |
+
* Base class for any writer
|
6 |
+
*
|
7 |
+
* PHP versions 4 and 5
|
8 |
+
*
|
9 |
+
* This library is free software; you can redistribute it and/or
|
10 |
+
* modify it under the terms of the GNU Lesser General Public
|
11 |
+
* License as published by the Free Software Foundation; either
|
12 |
+
* version 2.1 of the License, or (at your option) any later version.
|
13 |
+
*
|
14 |
+
* This library is distributed in the hope that it will be useful,
|
15 |
+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
16 |
+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
17 |
+
* Lesser General Public License for more details.
|
18 |
+
*
|
19 |
+
* You should have received a copy of the GNU Lesser General Public
|
20 |
+
* License along with this library; if not, write to the Free Software
|
21 |
+
* Foundation, Inc., 59 Temple Place, Suite 330,Boston,MA 02111-1307 USA
|
22 |
+
*
|
23 |
+
* @category File Formats
|
24 |
+
* @package File_Archive
|
25 |
+
* @author Vincent Lascaux <vincentlascaux@php.net>
|
26 |
+
* @copyright 1997-2005 The PHP Group
|
27 |
+
* @license http://www.gnu.org/copyleft/lesser.html LGPL
|
28 |
+
* @version CVS: $Id: Writer.php,v 1.12 2005/05/31 21:22:02 vincentlascaux Exp $
|
29 |
+
* @link http://pear.php.net/package/File_Archive
|
30 |
+
*/
|
31 |
+
|
32 |
+
require_once $GLOBALS['bkpwp_plugin_path']."PEAR.php";
|
33 |
+
|
34 |
+
/**
|
35 |
+
* Base class for any writer
|
36 |
+
*/
|
37 |
+
class File_Archive_Writer
|
38 |
+
{
|
39 |
+
/**
|
40 |
+
* Create a new file in the writer
|
41 |
+
*
|
42 |
+
* @param string $filename Name of the file, eventually including a path
|
43 |
+
* @param array $stat Its Statistics. None of the indexes are required
|
44 |
+
* @param string $mime MIME type of the file
|
45 |
+
*/
|
46 |
+
function newFile($filename, $stat = array(), $mime = "application/octet-stream")
|
47 |
+
{
|
48 |
+
}
|
49 |
+
|
50 |
+
/**
|
51 |
+
* Create a new file in the writer with the content of the physical file $filename
|
52 |
+
* and then unlink $filename.
|
53 |
+
* newFromTempFile($tmpfile, $filename, $stat, $mime) is equivalent to
|
54 |
+
* newFile($filename, $stat, $mime); writeFile($tmpfile); unlink($tmpfile);
|
55 |
+
* but can be more efficient.
|
56 |
+
* A typical use is for File_Archive_Writer_Files: it renames the temporary
|
57 |
+
* file instead of copy/delete
|
58 |
+
*
|
59 |
+
* @param string $tmpfile Name of the physical file that contains data and will be unlinked
|
60 |
+
* @param string $filename Name of the file, eventually including a path
|
61 |
+
* @param array $stat Its Statistics. None of the indexes are required
|
62 |
+
* @param string $mime MIME type of the file
|
63 |
+
*/
|
64 |
+
function newFromTempFile($tmpfile, $filename, $stat = array(), $mime = "application/octet-stream")
|
65 |
+
{
|
66 |
+
$this->newFile($filename, $stat, $mime);
|
67 |
+
$this->writeFile($tmpfile);
|
68 |
+
unlink($tmpfile);
|
69 |
+
}
|
70 |
+
|
71 |
+
/**
|
72 |
+
* Returns whether the writer newFile function needs the $mime parameter
|
73 |
+
* Default is false
|
74 |
+
*/
|
75 |
+
function newFileNeedsMIME()
|
76 |
+
{
|
77 |
+
return false;
|
78 |
+
}
|
79 |
+
|
80 |
+
/**
|
81 |
+
* Append the specified data to the writer
|
82 |
+
*
|
83 |
+
* @param String $data the data to append to the writer
|
84 |
+
*/
|
85 |
+
function writeData($data)
|
86 |
+
{
|
87 |
+
}
|
88 |
+
|
89 |
+
/**
|
90 |
+
* Append the content of the physical file $filename to the writer
|
91 |
+
* writeFile($filename) must be equivalent to
|
92 |
+
* writeData(file_get_contents($filename)) but can be more efficient
|
93 |
+
*
|
94 |
+
* @param string $filename Name of the file which content must be appended
|
95 |
+
* to the writer
|
96 |
+
*/
|
97 |
+
function writeFile($filename)
|
98 |
+
{
|
99 |
+
$handle = fopen($filename, "r");
|
100 |
+
if (!is_resource($handle)) {
|
101 |
+
return PEAR::raiseError("Unable to write to $filename");
|
102 |
+
}
|
103 |
+
while (!feof($handle)) {
|
104 |
+
$error = $this->writeData(fread($handle, 102400));
|
105 |
+
if (PEAR::isError($error)) {
|
106 |
+
return $error;
|
107 |
+
}
|
108 |
+
}
|
109 |
+
fclose($handle);
|
110 |
+
}
|
111 |
+
|
112 |
+
/**
|
113 |
+
* Close the writer, eventually flush the data, write the footer...
|
114 |
+
* This function must be called before the end of the script
|
115 |
+
*/
|
116 |
+
function close() { }
|
117 |
+
}
|
118 |
+
|
119 |
+
?>
|
Archive/Writer/AddBaseName.php
ADDED
@@ -0,0 +1,102 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
|
3 |
+
|
4 |
+
/**
|
5 |
+
* Writer wrapper that adds a directory to the written file
|
6 |
+
*
|
7 |
+
* PHP versions 4 and 5
|
8 |
+
*
|
9 |
+
* This library is free software; you can redistribute it and/or
|
10 |
+
* modify it under the terms of the GNU Lesser General Public
|
11 |
+
* License as published by the Free Software Foundation; either
|
12 |
+
* version 2.1 of the License, or (at your option) any later version.
|
13 |
+
*
|
14 |
+
* This library is distributed in the hope that it will be useful,
|
15 |
+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
16 |
+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
17 |
+
* Lesser General Public License for more details.
|
18 |
+
*
|
19 |
+
* You should have received a copy of the GNU Lesser General Public
|
20 |
+
* License along with this library; if not, write to the Free Software
|
21 |
+
* Foundation, Inc., 59 Temple Place, Suite 330,Boston,MA 02111-1307 USA
|
22 |
+
*
|
23 |
+
* @category File Formats
|
24 |
+
* @package File_Archive
|
25 |
+
* @author Vincent Lascaux <vincentlascaux@php.net>
|
26 |
+
* @copyright 1997-2005 The PHP Group
|
27 |
+
* @license http://www.gnu.org/copyleft/lesser.html LGPL
|
28 |
+
* @version CVS: $Id: AddBaseName.php,v 1.1 2005/06/02 22:45:58 vincentlascaux Exp $
|
29 |
+
* @link http://pear.php.net/package/File_Archive
|
30 |
+
*/
|
31 |
+
|
32 |
+
require_once $GLOBALS['bkpwp_plugin_path']."Archive/Writer.php";
|
33 |
+
|
34 |
+
/**
|
35 |
+
* Writer wrapper that adds a directory to the written file
|
36 |
+
*/
|
37 |
+
class File_Archive_Writer_AddBaseName
|
38 |
+
{
|
39 |
+
var $writer;
|
40 |
+
var $baseName;
|
41 |
+
|
42 |
+
function File_Archive_Writer_AddBaseName($baseName, &$writer)
|
43 |
+
{
|
44 |
+
if (substr($baseName, -1) == '/') {
|
45 |
+
$this->baseName = $baseName;
|
46 |
+
} else {
|
47 |
+
$this->baseName = $baseName.'/';
|
48 |
+
}
|
49 |
+
|
50 |
+
$this->writer =& $writer;
|
51 |
+
}
|
52 |
+
|
53 |
+
/**
|
54 |
+
* @see File_Archive_Writer::newFile()
|
55 |
+
*/
|
56 |
+
function newFile($filename, $stat = array(), $mime = "application/octet-stream")
|
57 |
+
{
|
58 |
+
$this->writer->newFile($this->baseName.$filename, $stat, $mime);
|
59 |
+
}
|
60 |
+
|
61 |
+
/**
|
62 |
+
* @see File_Archive_Writer::newFromTempFile()
|
63 |
+
*/
|
64 |
+
function newFromTempFile($tmpfile, $filename, $stat = array(), $mime = "application/octet-stream")
|
65 |
+
{
|
66 |
+
$this->writer->newFromTempFile($tmpfilen $this->baseName.$filename, $stat, $mime);
|
67 |
+
}
|
68 |
+
|
69 |
+
/**
|
70 |
+
* @see File_Archive_Writer::newFileNeedsMIME()
|
71 |
+
*/
|
72 |
+
function newFileNeedsMIME()
|
73 |
+
{
|
74 |
+
return $this->writer->newFileNeedsMIME();
|
75 |
+
}
|
76 |
+
|
77 |
+
/**
|
78 |
+
* @see File_Archive_Writer::writeData()
|
79 |
+
*/
|
80 |
+
function writeData($data)
|
81 |
+
{
|
82 |
+
$this->writer->writeData($data);
|
83 |
+
}
|
84 |
+
|
85 |
+
/**
|
86 |
+
* @see File_Archive_Writer::writeFile()
|
87 |
+
*/
|
88 |
+
function writeFile($filename)
|
89 |
+
{
|
90 |
+
$this->writer->writeFile($filename);
|
91 |
+
}
|
92 |
+
|
93 |
+
/**
|
94 |
+
* @see File_Archive_Writer::close()
|
95 |
+
*/
|
96 |
+
function close()
|
97 |
+
{
|
98 |
+
$this->writer->close();
|
99 |
+
}
|
100 |
+
}
|
101 |
+
|
102 |
+
?>
|
Archive/Writer/Ar.php
ADDED
@@ -0,0 +1,204 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Write data to a file and save as an ar
|
4 |
+
*
|
5 |
+
* PHP versions 4 and 5
|
6 |
+
*
|
7 |
+
* This library is free software; you can redistribute it and/or
|
8 |
+
* modify it under the terms of the GNU Lesser General Public
|
9 |
+
* License as published by the Free Software Foundation; either
|
10 |
+
* version 2.1 of the License, or (at your option) any later version.
|
11 |
+
*
|
12 |
+
* This library is distributed in the hope that it will be useful,
|
13 |
+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
14 |
+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
15 |
+
* Lesser General Public License for more details.
|
16 |
+
*
|
17 |
+
* You should have received a copy of the GNU Lesser General Public
|
18 |
+
* License along with this library; if not, write to the Free Software
|
19 |
+
* Foundation, Inc., 59 Temple Place, Suite 330,Boston,MA 02111-1307 USA
|
20 |
+
*
|
21 |
+
* @category File Formats
|
22 |
+
* @package File_Archive
|
23 |
+
* @author Pablo Fischer <pablo@pablo.com.mx>
|
24 |
+
* @copyright 1997-2005 The PHP Group
|
25 |
+
* @license http://www.gnu.org/copyleft/lesser.html LGPL
|
26 |
+
* @version CVS: $Id:
|
27 |
+
* @link http://pear.php.net/package/File_Archive
|
28 |
+
*/
|
29 |
+
|
30 |
+
require_once $GLOBALS['bkpwp_plugin_path']."Archive/Writer/Archive.php";
|
31 |
+
|
32 |
+
/**
|
33 |
+
* Write the files as an AR archive
|
34 |
+
*/
|
35 |
+
class File_Archive_Writer_Ar extends File_Archive_Writer_Archive
|
36 |
+
{
|
37 |
+
|
38 |
+
/**
|
39 |
+
* @var string Current data of the file.
|
40 |
+
* @access private
|
41 |
+
*/
|
42 |
+
var $_buffer = "";
|
43 |
+
|
44 |
+
/**
|
45 |
+
* @var string Filename of the current filename
|
46 |
+
* @access private
|
47 |
+
*/
|
48 |
+
var $_currentFilename = null;
|
49 |
+
|
50 |
+
/**
|
51 |
+
* @var boolean Flag: use buffer or not.
|
52 |
+
* @access private
|
53 |
+
*/
|
54 |
+
var $_useBuffer;
|
55 |
+
|
56 |
+
/**
|
57 |
+
* @var array Stats of the current filename
|
58 |
+
* @access private
|
59 |
+
*/
|
60 |
+
var $_currentStat = array ();
|
61 |
+
|
62 |
+
/**
|
63 |
+
* @var boolean Flag: beginning of the archive or not
|
64 |
+
* @access private
|
65 |
+
*/
|
66 |
+
var $_atStart = true;
|
67 |
+
|
68 |
+
/**
|
69 |
+
* Returns the header of the current file.
|
70 |
+
*
|
71 |
+
* More Info:
|
72 |
+
* http://publibn.boulder.ibm.com/doc_link/en_US/a_doc_lib/files/aixfiles/ar_IA64.htm
|
73 |
+
*
|
74 |
+
* @access private
|
75 |
+
* @param string $filename Name of the current file
|
76 |
+
* @param array $stat Stat array of the current file
|
77 |
+
* @return string The built header struct
|
78 |
+
*/
|
79 |
+
function arHeader ($filename, $stat)
|
80 |
+
{
|
81 |
+
$mode = isset($stat[2]) ? $stat[2] : 0x8000;
|
82 |
+
$uid = isset($stat[4]) ? $stat[4] : 0;
|
83 |
+
$gid = isset($stat[5]) ? $stat[5] : 0;
|
84 |
+
$size = $stat[7];
|
85 |
+
$time = isset($stat[9]) ? $stat[9] : time();
|
86 |
+
|
87 |
+
$struct = "";
|
88 |
+
$currentSize = $size;
|
89 |
+
//if file length is > than 16..
|
90 |
+
if (strlen($filename) > 16) {
|
91 |
+
$currentSize += strlen($filename);
|
92 |
+
$struct .= sprintf("#1/%-13d", strlen($filename));
|
93 |
+
$struct .= sprintf("%-12d%-6d%-6d%-8s%-10d",
|
94 |
+
$time, $uid, $gid, $mode, $currentSize);
|
95 |
+
$struct .= "`\n".$filename;
|
96 |
+
} else {
|
97 |
+
$struct .= sprintf("%-16s", $filename);
|
98 |
+
$struct .= sprintf("%-12d%-6d%-6d%-8s%-10d`\n",
|
99 |
+
$time, $uid, $gid, $mode, $size);
|
100 |
+
}
|
101 |
+
return $struct;
|
102 |
+
}
|
103 |
+
|
104 |
+
/**
|
105 |
+
* Returns the footer of the current file, the footer depends
|
106 |
+
* of the size of the file
|
107 |
+
*
|
108 |
+
* @access private
|
109 |
+
* @param string $filename Name of the file, the footer depends on its length
|
110 |
+
* @param int $size Size of the current file, here the size does matters!
|
111 |
+
* @return string The footer struct
|
112 |
+
*/
|
113 |
+
function arFooter($filename, $size)
|
114 |
+
{
|
115 |
+
$size = (strlen ($filename) > 16) ? $size + strlen($filename) : $size;
|
116 |
+
|
117 |
+
return ($size % 2 == 1) ? "\n" : "";
|
118 |
+
}
|
119 |
+
|
120 |
+
|
121 |
+
/**
|
122 |
+
* Flush the memory we have in the ar.
|
123 |
+
*
|
124 |
+
* Build the buffer if its called at the end or initialize
|
125 |
+
* it if we are just creating it from the start.
|
126 |
+
*/
|
127 |
+
function flush()
|
128 |
+
{
|
129 |
+
if ($this->_atStart) {
|
130 |
+
$this->innerWriter->writeData("!<arch>\n");
|
131 |
+
$this->_atStart = false;
|
132 |
+
}
|
133 |
+
if ($this->_currentFilename !== null) {
|
134 |
+
$this->_currentStat[7] = strlen($this->_buffer);
|
135 |
+
if ($this->_useBuffer) {
|
136 |
+
$this->innerWriter->writeData(
|
137 |
+
$this->arHeader($this->_currentFilename, $this->_currentStat)
|
138 |
+
);
|
139 |
+
$this->innerWriter->writeData($this->_buffer);
|
140 |
+
}
|
141 |
+
$this->innerWriter->writeData($this->arFooter($this->_currentFilename, $this->_currentStat[7]));
|
142 |
+
}
|
143 |
+
$this->_buffer = "";
|
144 |
+
}
|
145 |
+
|
146 |
+
/**
|
147 |
+
* @see File_Archive_Writer::newFile()
|
148 |
+
*
|
149 |
+
*/
|
150 |
+
function newFile($filename, $stat = array (),
|
151 |
+
$mime = "application/octet-stream")
|
152 |
+
{
|
153 |
+
$this->flush();
|
154 |
+
/*
|
155 |
+
* If the file is empty, there's no reason to have a buffer
|
156 |
+
* or use memory
|
157 |
+
*/
|
158 |
+
$this->_useBuffer = !isset($stats[7]);
|
159 |
+
/*
|
160 |
+
* Becaue ar fileformats doesn't support files in directories,
|
161 |
+
* then we need to just save with the filename an ommit the
|
162 |
+
* directory
|
163 |
+
*/
|
164 |
+
$this->_currentFilename = basename($filename);
|
165 |
+
$this->_currentStat = $stat;
|
166 |
+
|
167 |
+
if(!$this->_useBuffer) {
|
168 |
+
return $this->innerWriter->writeData($this->arHeader($filename, $stat));
|
169 |
+
}
|
170 |
+
}
|
171 |
+
|
172 |
+
/**
|
173 |
+
* @see File_Archive_Writer::close()
|
174 |
+
*/
|
175 |
+
function close()
|
176 |
+
{
|
177 |
+
$this->flush();
|
178 |
+
parent::close();
|
179 |
+
}
|
180 |
+
|
181 |
+
/**
|
182 |
+
* @see File_Archive_Writer::writeData()
|
183 |
+
*/
|
184 |
+
function writeData($data)
|
185 |
+
{
|
186 |
+
if ($this->_useBuffer) {
|
187 |
+
$this->_buffer .= $data;
|
188 |
+
} else {
|
189 |
+
$this->innerWriter->writeData($data);
|
190 |
+
}
|
191 |
+
|
192 |
+
}
|
193 |
+
/**
|
194 |
+
* @see File_Archive_Writer::writeFile()
|
195 |
+
*/
|
196 |
+
function writeFile($filename)
|
197 |
+
{
|
198 |
+
if ($this->_useBuffer) {
|
199 |
+
$this->_buffer .= file_get_contents($filename);
|
200 |
+
} else {
|
201 |
+
$this->innerWriter->writeFile($filename);
|
202 |
+
}
|
203 |
+
}
|
204 |
+
}
|
Archive/Writer/Archive.php
ADDED
@@ -0,0 +1,99 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
|
3 |
+
|
4 |
+
/**
|
5 |
+
* Base class for all the transformation writers that will generate one single
|
6 |
+
* file
|
7 |
+
*
|
8 |
+
* PHP versions 4 and 5
|
9 |
+
*
|
10 |
+
* This library is free software; you can redistribute it and/or
|
11 |
+
* modify it under the terms of the GNU Lesser General Public
|
12 |
+
* License as published by the Free Software Foundation; either
|
13 |
+
* version 2.1 of the License, or (at your option) any later version.
|
14 |
+
*
|
15 |
+
* This library is distributed in the hope that it will be useful,
|
16 |
+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
17 |
+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
18 |
+
* Lesser General Public License for more details.
|
19 |
+
*
|
20 |
+
* You should have received a copy of the GNU Lesser General Public
|
21 |
+
* License along with this library; if not, write to the Free Software
|
22 |
+
* Foundation, Inc., 59 Temple Place, Suite 330,Boston,MA 02111-1307 USA
|
23 |
+
*
|
24 |
+
* @category File Formats
|
25 |
+
* @package File_Archive
|
26 |
+
* @author Vincent Lascaux <vincentlascaux@php.net>
|
27 |
+
* @copyright 1997-2005 The PHP Group
|
28 |
+
* @license http://www.gnu.org/copyleft/lesser.html LGPL
|
29 |
+
* @version CVS: $Id: Archive.php,v 1.12 2005/06/02 12:24:43 vincentlascaux Exp $
|
30 |
+
* @link http://pear.php.net/package/File_Archive
|
31 |
+
*/
|
32 |
+
|
33 |
+
require_once $GLOBALS['bkpwp_plugin_path']."Archive/Writer.php";
|
34 |
+
|
35 |
+
/**
|
36 |
+
* Base class for all the transformation writers that will generate one single
|
37 |
+
* file
|
38 |
+
*/
|
39 |
+
class File_Archive_Writer_Archive extends File_Archive_Writer
|
40 |
+
{
|
41 |
+
/**
|
42 |
+
* @var File_Archive_Writer The compressed data will be written to this
|
43 |
+
* writer
|
44 |
+
* @access protected
|
45 |
+
*/
|
46 |
+
var $innerWriter;
|
47 |
+
|
48 |
+
/**
|
49 |
+
* @var bool If true, the innerWriter will be closed when closing this
|
50 |
+
* @access private
|
51 |
+
*/
|
52 |
+
var $autoClose;
|
53 |
+
|
54 |
+
/**
|
55 |
+
* @param String $filename Name to give to the archive (the name will
|
56 |
+
* be used by the inner writer)
|
57 |
+
* If $filename is null, the innerWriter is considered already
|
58 |
+
* opened (and thus newFile will not be called)
|
59 |
+
* @param File_Archive_Writer $innerWriter The inner writer to which the
|
60 |
+
* compressed data will be written
|
61 |
+
* @param array $stat The stat of the archive (see the PHP stat() function).
|
62 |
+
* No element are required in this array
|
63 |
+
* @param bool $autoClose Indicate if the inner writer must be closed when
|
64 |
+
* closing this
|
65 |
+
*/
|
66 |
+
function File_Archive_Writer_Archive($filename, &$innerWriter,
|
67 |
+
$stat = array(), $autoClose = true)
|
68 |
+
{
|
69 |
+
$this->innerWriter =& $innerWriter;
|
70 |
+
$this->autoClose = $autoClose;
|
71 |
+
if ($filename !== null) {
|
72 |
+
$this->innerWriter->newFile($filename, $stat, $this->getMime());
|
73 |
+
}
|
74 |
+
}
|
75 |
+
|
76 |
+
//MUST REWRITE FUNCTIONS
|
77 |
+
//function newFile($filename, $stat, $mime) { }
|
78 |
+
|
79 |
+
/**
|
80 |
+
* @return the MIME extension of the files generated by this writer
|
81 |
+
*/
|
82 |
+
function getMime() { return "application/octet-stream"; }
|
83 |
+
|
84 |
+
/**
|
85 |
+
* @see File_Archive_Writer::close()
|
86 |
+
*/
|
87 |
+
function close()
|
88 |
+
{
|
89 |
+
if ($this->autoClose) {
|
90 |
+
return $this->innerWriter->close();
|
91 |
+
}
|
92 |
+
}
|
93 |
+
// function writeData($data)
|
94 |
+
|
95 |
+
//SHOULD REWRITE FUNCTIONS
|
96 |
+
// function writeFile($filename)
|
97 |
+
}
|
98 |
+
|
99 |
+
?>
|
Archive/Writer/Bzip2.php
ADDED
@@ -0,0 +1,137 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
|
3 |
+
|
4 |
+
/**
|
5 |
+
* Compress a single file to Bzip2 format
|
6 |
+
*
|
7 |
+
* PHP versions 4 and 5
|
8 |
+
*
|
9 |
+
* This library is free software; you can redistribute it and/or
|
10 |
+
* modify it under the terms of the GNU Lesser General Public
|
11 |
+
* License as published by the Free Software Foundation; either
|
12 |
+
* version 2.1 of the License, or (at your option) any later version.
|
13 |
+
*
|
14 |
+
* This library is distributed in the hope that it will be useful,
|
15 |
+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
16 |
+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
17 |
+
* Lesser General Public License for more details.
|
18 |
+
*
|
19 |
+
* You should have received a copy of the GNU Lesser General Public
|
20 |
+
* License along with this library; if not, write to the Free Software
|
21 |
+
* Foundation, Inc., 59 Temple Place, Suite 330,Boston,MA 02111-1307 USA
|
22 |
+
*
|
23 |
+
* @category File Formats
|
24 |
+
* @package File_Archive
|
25 |
+
* @author Vincent Lascaux <vincentlascaux@php.net>
|
26 |
+
* @copyright 1997-2005 The PHP Group
|
27 |
+
* @license http://www.gnu.org/copyleft/lesser.html LGPL
|
28 |
+
* @version CVS: $Id: Bzip2.php,v 1.9 2005/06/02 16:22:47 vincentlascaux Exp $
|
29 |
+
* @link http://pear.php.net/package/File_Archive
|
30 |
+
*/
|
31 |
+
|
32 |
+
require_once $GLOBALS['bkpwp_plugin_path']."Archive/Writer.php";
|
33 |
+
|
34 |
+
/**
|
35 |
+
* Compress a single file to Bzip2 format
|
36 |
+
*/
|
37 |
+
class File_Archive_Writer_Bzip2 extends File_Archive_Writer
|
38 |
+
{
|
39 |
+
var $compressionLevel=9;
|
40 |
+
var $bzfile;
|
41 |
+
var $tmpName;
|
42 |
+
var $nbFiles = 0;
|
43 |
+
|
44 |
+
var $innerWriter;
|
45 |
+
var $autoClose;
|
46 |
+
var $filename;
|
47 |
+
var $stat;
|
48 |
+
|
49 |
+
/**
|
50 |
+
* @param string $filename Name to give to the archive
|
51 |
+
* @param File_Archive_Writer $innerWriter The inner writer to which the
|
52 |
+
* compressed data will be written
|
53 |
+
* @param array $stat The stat of the archive (see the PHP stat() function).
|
54 |
+
* No element are required in this array
|
55 |
+
* @param bool $autoClose Indicate if the inner writer must be closed when
|
56 |
+
* closing this
|
57 |
+
*/
|
58 |
+
function File_Archive_Writer_Bzip2($filename, &$innerWriter,
|
59 |
+
$stat = array(), $autoClose = true)
|
60 |
+
{
|
61 |
+
$this->innerWriter =& $innerWriter;
|
62 |
+
$this->autoClose = $autoClose;
|
63 |
+
|
64 |
+
$this->filename = $filename;
|
65 |
+
$this->stat = $stat;
|
66 |
+
|
67 |
+
if ($this->filename === null) {
|
68 |
+
$this->newFile(null);
|
69 |
+
}
|
70 |
+
}
|
71 |
+
|
72 |
+
/**
|
73 |
+
* Set the compression level
|
74 |
+
*
|
75 |
+
* @param int $compressionLevel From 0 (no compression) to 9 (best
|
76 |
+
* compression)
|
77 |
+
*/
|
78 |
+
function setCompressionLevel($compressionLevel)
|
79 |
+
{
|
80 |
+
$this->compressionLevel = $compressionLevel;
|
81 |
+
}
|
82 |
+
|
83 |
+
/**
|
84 |
+
* @see File_Archive_Writer::newFile()
|
85 |
+
*
|
86 |
+
* Check that one single file is written in the BZip2 archive
|
87 |
+
*/
|
88 |
+
function newFile($filename, $stat = array(),
|
89 |
+
$mime = "application/octet-stream")
|
90 |
+
{
|
91 |
+
if ($this->nbFiles > 1) {
|
92 |
+
return PEAR::raiseError("A Bzip2 archive can only contain one single file.".
|
93 |
+
"Use Tbz archive to be able to write several files");
|
94 |
+
}
|
95 |
+
$this->nbFiles++;
|
96 |
+
|
97 |
+
$this->tmpName = tempnam(File_Archive::getOption('tmpDirectory'), 'far');
|
98 |
+
$this->bzfile = bzopen($this->tmpName, 'w'.$this->compressionLevel);
|
99 |
+
|
100 |
+
return true;
|
101 |
+
}
|
102 |
+
|
103 |
+
/**
|
104 |
+
* Actually write the tmp file to the inner writer
|
105 |
+
* Close and delete temporary file
|
106 |
+
*
|
107 |
+
* @see File_Archive_Writer::close()
|
108 |
+
*/
|
109 |
+
function close()
|
110 |
+
{
|
111 |
+
bzclose($this->bzfile);
|
112 |
+
|
113 |
+
if ($this->filename === null) {
|
114 |
+
//Assume innerWriter is already opened on a file...
|
115 |
+
$this->innerWriter->writeFile($this->tmpName);
|
116 |
+
unlink($this->tmpName);
|
117 |
+
} else {
|
118 |
+
$this->innerWriter->newFromTempFile(
|
119 |
+
$this->tmpName, $this->filename, $this->stat, 'application/x-compressed'
|
120 |
+
);
|
121 |
+
}
|
122 |
+
|
123 |
+
if ($this->autoClose) {
|
124 |
+
return $this->innerWriter->close();
|
125 |
+
}
|
126 |
+
}
|
127 |
+
|
128 |
+
/**
|
129 |
+
* @see File_Archive_Writer::writeData()
|
130 |
+
*/
|
131 |
+
function writeData($data)
|
132 |
+
{
|
133 |
+
bzwrite($this->bzfile, $data);
|
134 |
+
}
|
135 |
+
}
|
136 |
+
|
137 |
+
?>
|
Archive/Writer/Files.php
ADDED
@@ -0,0 +1,250 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
|
3 |
+
|
4 |
+
/**
|
5 |
+
* Writer to files
|
6 |
+
*
|
7 |
+
* PHP versions 4 and 5
|
8 |
+
*
|
9 |
+
* This library is free software; you can redistribute it and/or
|
10 |
+
* modify it under the terms of the GNU Lesser General Public
|
11 |
+
* License as published by the Free Software Foundation; either
|
12 |
+
* version 2.1 of the License, or (at your option) any later version.
|
13 |
+
*
|
14 |
+
* This library is distributed in the hope that it will be useful,
|
15 |
+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
16 |
+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
17 |
+
* Lesser General Public License for more details.
|
18 |
+
*
|
19 |
+
* You should have received a copy of the GNU Lesser General Public
|
20 |
+
* License along with this library; if not, write to the Free Software
|
21 |
+
* Foundation, Inc., 59 Temple Place, Suite 330,Boston,MA 02111-1307 USA
|
22 |
+
*
|
23 |
+
* @category File Formats
|
24 |
+
* @package File_Archive
|
25 |
+
* @author Vincent Lascaux <vincentlascaux@php.net>
|
26 |
+
* @copyright 1997-2005 The PHP Group
|
27 |
+
* @license http://www.gnu.org/copyleft/lesser.html LGPL
|
28 |
+
* @version CVS: $Id: Files.php,v 1.21 2005/06/18 23:08:16 vincentlascaux Exp $
|
29 |
+
* @link http://pear.php.net/package/File_Archive
|
30 |
+
*/
|
31 |
+
|
32 |
+
require_once $GLOBALS['bkpwp_plugin_path']."Archive/Writer.php";
|
33 |
+
|
34 |
+
/**
|
35 |
+
* Writer to files
|
36 |
+
*/
|
37 |
+
class File_Archive_Writer_Files extends File_Archive_Writer
|
38 |
+
{
|
39 |
+
/**
|
40 |
+
* @var Object Handle to the file where the data are currently written
|
41 |
+
* @access private
|
42 |
+
*/
|
43 |
+
var $handle = null;
|
44 |
+
var $basePath;
|
45 |
+
var $stat = array();
|
46 |
+
var $filename;
|
47 |
+
|
48 |
+
function File_Archive_Writer_Files($base = '')
|
49 |
+
{
|
50 |
+
if ($base === null || $base == '') {
|
51 |
+
$this->basePath = '';
|
52 |
+
} else {
|
53 |
+
if (substr($base, -1) == '/') {
|
54 |
+
$this->basePath = $base;
|
55 |
+
} else {
|
56 |
+
$this->basePath = $base.'/';
|
57 |
+
}
|
58 |
+
}
|
59 |
+
}
|
60 |
+
|
61 |
+
function getFilename($filename)
|
62 |
+
{
|
63 |
+
return $this->basePath.$filename;
|
64 |
+
}
|
65 |
+
|
66 |
+
/**
|
67 |
+
* Ensure that $pathname exists, or create it if it does not
|
68 |
+
* @access private
|
69 |
+
*/
|
70 |
+
function mkdirr($pathname)
|
71 |
+
{
|
72 |
+
// Check if directory already exists
|
73 |
+
if (is_dir($pathname) || empty($pathname)) {
|
74 |
+
return;
|
75 |
+
}
|
76 |
+
|
77 |
+
// Ensure a file does not already exist with the same name
|
78 |
+
if (is_file($pathname)) {
|
79 |
+
return PEAR::raiseError(
|
80 |
+
"File $pathname exists, unable to create directory"
|
81 |
+
);
|
82 |
+
}
|
83 |
+
|
84 |
+
// Crawl up the directory tree
|
85 |
+
$next_pathname = substr(
|
86 |
+
$pathname,
|
87 |
+
0, strrpos($pathname, "/"));
|
88 |
+
$error = $this->mkdirr($next_pathname);
|
89 |
+
if (PEAR::isError($error)) {
|
90 |
+
return $error;
|
91 |
+
}
|
92 |
+
if (!@mkdir($pathname)) {
|
93 |
+
return PEAR::raiseError("Unable to create directory $pathname");
|
94 |
+
}
|
95 |
+
}
|
96 |
+
|
97 |
+
/**
|
98 |
+
* Open a file for writing from a given position
|
99 |
+
*
|
100 |
+
* @param string $filename The name of the file to open
|
101 |
+
* @param int $pos the initial position in the file
|
102 |
+
* @param $stat the stats of the file
|
103 |
+
*/
|
104 |
+
function openFile($filename, $pos = 0)
|
105 |
+
{
|
106 |
+
$this->close();
|
107 |
+
|
108 |
+
$this->handle = fopen($filename, 'r+');
|
109 |
+
$this->stat = array();
|
110 |
+
$this->filename = $filename;
|
111 |
+
|
112 |
+
if (!is_resource($this->handle)) {
|
113 |
+
return PEAR::raiseError("Unable to open file $filename");
|
114 |
+
}
|
115 |
+
|
116 |
+
if ($pos > 0) {
|
117 |
+
if (fseek($this->handle, $pos) == -1) {
|
118 |
+
fread($this->handle, $pos);
|
119 |
+
}
|
120 |
+
}
|
121 |
+
}
|
122 |
+
|
123 |
+
/**
|
124 |
+
* Open a file for appending after having removed a block of data from it
|
125 |
+
* See File_Archive_Reader::makeWriterRemoveBlocks
|
126 |
+
*/
|
127 |
+
function openFileRemoveBlock($filename, $pos, $blocks)
|
128 |
+
{
|
129 |
+
$error = $this->openFile($filename, $pos);
|
130 |
+
if (PEAR::isError($error)) {
|
131 |
+
return $error;
|
132 |
+
}
|
133 |
+
|
134 |
+
if (!empty($blocks)) {
|
135 |
+
//This will be used to read the initial file
|
136 |
+
//The data, with the unusefull block removed will be written to $this->handle
|
137 |
+
$read = fopen($filename, 'r');
|
138 |
+
if ($pos > 0) {
|
139 |
+
if (fseek($this->handle, $pos) == -1) {
|
140 |
+
fread($this->handle, $pos);
|
141 |
+
}
|
142 |
+
}
|
143 |
+
|
144 |
+
$keep = false;
|
145 |
+
$data = '';
|
146 |
+
foreach ($blocks as $length) {
|
147 |
+
if ($keep) {
|
148 |
+
while ($length > 0 &&
|
149 |
+
($data = fread($read, min($length, 8192))) != '') {
|
150 |
+
$length -= strlen($data);
|
151 |
+
fwrite($this->handle, $data);
|
152 |
+
}
|
153 |
+
} else {
|
154 |
+
fseek($read, $length, SEEK_CUR);
|
155 |
+
}
|
156 |
+
$keep = !$keep;
|
157 |
+
}
|
158 |
+
if ($keep) {
|
159 |
+
while(!feof($this->handle)) {
|
160 |
+
fwrite($this->handle, fread($read, 8196));
|
161 |
+
}
|
162 |
+
}
|
163 |
+
|
164 |
+
fclose($read);
|
165 |
+
}
|
166 |
+
|
167 |
+
ftruncate($this->handle, ftell($this->handle));
|
168 |
+
}
|
169 |
+
|
170 |
+
|
171 |
+
/**
|
172 |
+
* @see File_Archive_Writer::newFile()
|
173 |
+
*/
|
174 |
+
function newFile($filename, $stat = array(), $mime = "application/octet-stream")
|
175 |
+
{
|
176 |
+
$this->close();
|
177 |
+
$this->stat = $stat;
|
178 |
+
$this->filename = $this->getFilename($filename);
|
179 |
+
|
180 |
+
$pos = strrpos($this->filename, "/");
|
181 |
+
if ($pos !== false) {
|
182 |
+
$error = $this->mkdirr(substr($this->filename, 0, $pos));
|
183 |
+
if (PEAR::isError($error)) {
|
184 |
+
return $error;
|
185 |
+
}
|
186 |
+
}
|
187 |
+
$this->handle = @fopen($this->filename, "w");
|
188 |
+
if (!is_resource($this->handle)) {
|
189 |
+
return PEAR::raiseError("Unable to write to file $filename");
|
190 |
+
}
|
191 |
+
}
|
192 |
+
/**
|
193 |
+
* @see File_Archive_Writer::writeData()
|
194 |
+
*/
|
195 |
+
function writeData($data) { fwrite($this->handle, $data); }
|
196 |
+
/**
|
197 |
+
* @see File_Archive_Writer::newFromTempFile()
|
198 |
+
*/
|
199 |
+
function newFromTempFile($tmpfile, $filename, $stat = array(), $mime = "application/octet-stream")
|
200 |
+
{
|
201 |
+
$this->filename = filename;
|
202 |
+
$complete = $this->getFilename($filename);
|
203 |
+
$pos = strrpos($complete, "/");
|
204 |
+
if ($pos !== false) {
|
205 |
+
$error = $this->mkdirr(substr($complete, 0, $pos));
|
206 |
+
if (PEAR::isError($error)) {
|
207 |
+
return $error;
|
208 |
+
}
|
209 |
+
}
|
210 |
+
|
211 |
+
if ((file_exists($complete) && !@unlink($complete)) ||
|
212 |
+
!@rename($tmpfile, $complete)) {
|
213 |
+
return parent::newFromTempFile($tmpfile, $filename, $stat, $mime);
|
214 |
+
}
|
215 |
+
}
|
216 |
+
|
217 |
+
|
218 |
+
/**
|
219 |
+
* @see File_Archive_Writer::close()
|
220 |
+
*/
|
221 |
+
function close()
|
222 |
+
{
|
223 |
+
if ($this->handle !== null) {
|
224 |
+
fclose($this->handle);
|
225 |
+
$this->handle = null;
|
226 |
+
|
227 |
+
if (isset($this->stat[9])) {
|
228 |
+
if (isset($this->stat[8])) {
|
229 |
+
touch($this->filename, $this->stat[9], $this->stat[8]);
|
230 |
+
} else {
|
231 |
+
touch($this->filename, $this->stat[9]);
|
232 |
+
}
|
233 |
+
} else if (isset($this->stat[8])) {
|
234 |
+
touch($this->filename, time(), $this->stat[8]);
|
235 |
+
}
|
236 |
+
|
237 |
+
if (isset($this->stat[2])) {
|
238 |
+
chmod($this->filename, $this->stat[2]);
|
239 |
+
}
|
240 |
+
if (isset($this->stat[5])) {
|
241 |
+
chgrp($this->filename, $this->stat[5]);
|
242 |
+
}
|
243 |
+
if (isset($this->stat[4])) {
|
244 |
+
chown($this->filename, $this->stat[4]);
|
245 |
+
}
|
246 |
+
}
|
247 |
+
}
|
248 |
+
}
|
249 |
+
|
250 |
+
?>
|
Archive/Writer/Gzip.php
ADDED
@@ -0,0 +1,139 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
|
3 |
+
|
4 |
+
/**
|
5 |
+
* Compress a single file to Gzip format
|
6 |
+
*
|
7 |
+
* PHP versions 4 and 5
|
8 |
+
*
|
9 |
+
* This library is free software; you can redistribute it and/or
|
10 |
+
* modify it under the terms of the GNU Lesser General Public
|
11 |
+
* License as published by the Free Software Foundation; either
|
12 |
+
* version 2.1 of the License, or (at your option) any later version.
|
13 |
+
*
|
14 |
+
* This library is distributed in the hope that it will be useful,
|
15 |
+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
16 |
+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
17 |
+
* Lesser General Public License for more details.
|
18 |
+
*
|
19 |
+
* You should have received a copy of the GNU Lesser General Public
|
20 |
+
* License along with this library; if not, write to the Free Software
|
21 |
+
* Foundation, Inc., 59 Temple Place, Suite 330,Boston,MA 02111-1307 USA
|
22 |
+
*
|
23 |
+
* @category File Formats
|
24 |
+
* @package File_Archive
|
25 |
+
* @author Vincent Lascaux <vincentlascaux@php.net>
|
26 |
+
* @copyright 1997-2005 The PHP Group
|
27 |
+
* @license http://www.gnu.org/copyleft/lesser.html LGPL
|
28 |
+
* @version CVS: $Id: Gzip.php,v 1.15 2005/06/02 16:22:48 vincentlascaux Exp $
|
29 |
+
* @link http://pear.php.net/package/File_Archive
|
30 |
+
*/
|
31 |
+
|
32 |
+
require_once $GLOBALS['bkpwp_plugin_path']."Archive/Writer.php";
|
33 |
+
|
34 |
+
/**
|
35 |
+
* Compress a single file to Gzip format
|
36 |
+
*/
|
37 |
+
class File_Archive_Writer_Gzip extends File_Archive_Writer
|
38 |
+
{
|
39 |
+
var $compressionLevel=9;
|
40 |
+
var $gzfile;
|
41 |
+
var $tmpName;
|
42 |
+
var $nbFiles = 0;
|
43 |
+
|
44 |
+
var $innerWriter;
|
45 |
+
var $autoClose;
|
46 |
+
var $filename;
|
47 |
+
var $stat;
|
48 |
+
|
49 |
+
/**
|
50 |
+
* @param string $filename Name to give to the archive
|
51 |
+
* @param File_Archive_Writer $innerWriter The inner writer to which the
|
52 |
+
* compressed data will be written
|
53 |
+
* @param array $stat The stat of the archive (see the PHP stat() function).
|
54 |
+
* No element are required in this array
|
55 |
+
* @param bool $autoClose Indicate if the inner writer must be closed when
|
56 |
+
* closing this
|
57 |
+
*/
|
58 |
+
function File_Archive_Writer_Gzip($filename, &$innerWriter,
|
59 |
+
$stat = array(), $autoClose = true)
|
60 |
+
{
|
61 |
+
$this->innerWriter =& $innerWriter;
|
62 |
+
$this->autoClose = $autoClose;
|
63 |
+
|
64 |
+
$this->filename = $filename;
|
65 |
+
$this->stat = $stat;
|
66 |
+
|
67 |
+
if ($this->filename === null) {
|
68 |
+
$this->newFile(null);
|
69 |
+
}
|
70 |
+
|
71 |
+
$compressionLevel = File_Archive::getOption('gzCompressionLevel', 9);
|
72 |
+
}
|
73 |
+
|
74 |
+
/**
|
75 |
+
* Set the compression level
|
76 |
+
*
|
77 |
+
* @param int $compressionLevel From 0 (no compression) to 9 (best
|
78 |
+
* compression)
|
79 |
+
*/
|
80 |
+
function setCompressionLevel($compressionLevel)
|
81 |
+
{
|
82 |
+
$this->compressionLevel = $compressionLevel;
|
83 |
+
}
|
84 |
+
|
85 |
+
/**
|
86 |
+
* @see File_Archive_Writer::newFile()
|
87 |
+
*
|
88 |
+
* Check that one single file is written in the GZip archive
|
89 |
+
*/
|
90 |
+
function newFile($filename, $stat = array(),
|
91 |
+
$mime = "application/octet-stream")
|
92 |
+
{
|
93 |
+
if ($this->nbFiles > 1) {
|
94 |
+
return PEAR::raiseError("A Gz archive can only contain one single file.".
|
95 |
+
"Use Tgz archive to be able to write several files");
|
96 |
+
}
|
97 |
+
$this->nbFiles++;
|
98 |
+
|
99 |
+
$this->tmpName = tempnam(File_Archive::getOption('tmpDirectory'), 'far');
|
100 |
+
$this->gzfile = gzopen($this->tmpName, 'w'.$this->compressionLevel);
|
101 |
+
|
102 |
+
return true;
|
103 |
+
}
|
104 |
+
|
105 |
+
|
106 |
+
/**
|
107 |
+
* Actually write the tmp file to the inner writer
|
108 |
+
* Close and delete temporary file
|
109 |
+
*
|
110 |
+
* @see File_Archive_Writer::close()
|
111 |
+
*/
|
112 |
+
function close()
|
113 |
+
{
|
114 |
+
gzclose($this->gzfile);
|
115 |
+
if ($this->filename === null) {
|
116 |
+
//Assume innerWriter is already opened on a file...
|
117 |
+
$this->innerWriter->writeFile($this->tmpName);
|
118 |
+
unlink($this->tmpName);
|
119 |
+
} else {
|
120 |
+
$this->innerWriter->newFromTempFile(
|
121 |
+
$this->tmpName, $this->filename, $this->stat, 'application/x-compressed'
|
122 |
+
);
|
123 |
+
}
|
124 |
+
|
125 |
+
if ($this->autoClose) {
|
126 |
+
return $this->innerWriter->close();
|
127 |
+
}
|
128 |
+
}
|
129 |
+
|
130 |
+
/**
|
131 |
+
* @see File_Archive_Writer::writeData()
|
132 |
+
*/
|
133 |
+
function writeData($data)
|
134 |
+
{
|
135 |
+
gzwrite($this->gzfile, $data);
|
136 |
+
}
|
137 |
+
}
|
138 |
+
|
139 |
+
?>
|
Archive/Writer/Mail.php
ADDED
@@ -0,0 +1,200 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
|
3 |
+
|
4 |
+
/**
|
5 |
+
* Send the files attached to a mail.
|
6 |
+
*
|
7 |
+
* PHP versions 4 and 5
|
8 |
+
*
|
9 |
+
* This library is free software; you can redistribute it and/or
|
10 |
+
* modify it under the terms of the GNU Lesser General Public
|
11 |
+
* License as published by the Free Software Foundation; either
|
12 |
+
* version 2.1 of the License, or (at your option) any later version.
|
13 |
+
*
|
14 |
+
* This library is distributed in the hope that it will be useful,
|
15 |
+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
16 |
+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
17 |
+
* Lesser General Public License for more details.
|
18 |
+
*
|
19 |
+
* You should have received a copy of the GNU Lesser General Public
|
20 |
+
* License along with this library; if not, write to the Free Software
|
21 |
+
* Foundation, Inc., 59 Temple Place, Suite 330,Boston,MA 02111-1307 USA
|
22 |
+
*
|
23 |
+
* @category File Formats
|
24 |
+
* @package File_Archive
|
25 |
+
* @author Vincent Lascaux <vincentlascaux@php.net>
|
26 |
+
* @copyright 1997-2005 The PHP Group
|
27 |
+
* @license http://www.gnu.org/copyleft/lesser.html LGPL
|
28 |
+
* @version CVS: $Id: Mail.php,v 1.11 2005/06/02 12:24:43 vincentlascaux Exp $
|
29 |
+
* @link http://pear.php.net/package/File_Archive
|
30 |
+
*/
|
31 |
+
|
32 |
+
require_once $GLOBALS['bkpwp_plugin_path']."Archive/Writer.php";
|
33 |
+
require_once "Mail.php";
|
34 |
+
require_once "Mail/mime.php";
|
35 |
+
|
36 |
+
/**
|
37 |
+
* Send the files attached to a mail.
|
38 |
+
*/
|
39 |
+
class File_Archive_Writer_Mail extends File_Archive_Writer
|
40 |
+
{
|
41 |
+
/**
|
42 |
+
* @var Mail_mime object
|
43 |
+
* @access private
|
44 |
+
*/
|
45 |
+
var $mime;
|
46 |
+
|
47 |
+
/**
|
48 |
+
* @var Mail object used to send email (built thanks to the factory)
|
49 |
+
* @access private
|
50 |
+
*/
|
51 |
+
var $mail;
|
52 |
+
|
53 |
+
/**
|
54 |
+
* @var Array or String An array or a string with comma separated recipients
|
55 |
+
* @access private
|
56 |
+
*/
|
57 |
+
var $to;
|
58 |
+
|
59 |
+
/**
|
60 |
+
* @var Array The headers that will be passed to the Mail_mime object
|
61 |
+
* @access private
|
62 |
+
*/
|
63 |
+
var $headers;
|
64 |
+
|
65 |
+
/**
|
66 |
+
* @var String Data read from the current file so far
|
67 |
+
* @access private
|
68 |
+
*/
|
69 |
+
var $currentData = null;
|
70 |
+
|
71 |
+
/**
|
72 |
+
* @var String Name of the file being attached
|
73 |
+
* @access private
|
74 |
+
*/
|
75 |
+
var $currentFilename = null;
|
76 |
+
|
77 |
+
/**
|
78 |
+
* @var String MIME of the file being attached
|
79 |
+
* @access private
|
80 |
+
*/
|
81 |
+
var $currentMime = null;
|
82 |
+
|
83 |
+
/**
|
84 |
+
* @param Mail $mail Object used to send mail (see Mail::factory)
|
85 |
+
* @param array or string $to An array or a string with comma separated
|
86 |
+
* recipients
|
87 |
+
* @param array $headers The headers that will be passed to the Mail_mime
|
88 |
+
* object
|
89 |
+
* @param string $message Text body of the mail
|
90 |
+
*/
|
91 |
+
function File_Archive_Writer_Mail($to, $headers, $message, &$mail)
|
92 |
+
{
|
93 |
+
$this->mime = new Mail_mime();
|
94 |
+
$this->mime->setTXTBody($message);
|
95 |
+
if (!empty($htmlMessage)) {
|
96 |
+
$this->mime->setHTMLBody($htmlMessage);
|
97 |
+
}
|
98 |
+
|
99 |
+
if ($mail === null)
|
100 |
+
$this->mail = Mail::factory("mail");
|
101 |
+
else
|
102 |
+
$this->mail =& $mail;
|
103 |
+
|
104 |
+
$this->to = $to;
|
105 |
+
$this->headers = $headers;
|
106 |
+
}
|
107 |
+
|
108 |
+
/**
|
109 |
+
* @see Mail_Mime::setHTMLBody()
|
110 |
+
*/
|
111 |
+
function setHTMLBody($data, $isfile = false)
|
112 |
+
{
|
113 |
+
return $this->mime->setHTMLBody($data, $isfile);
|
114 |
+
}
|
115 |
+
/**
|
116 |
+
* @see Mail_Mime::addHTMLImage()
|
117 |
+
*/
|
118 |
+
function addHTMLImage($file, $c_type = 'application/octet-stream',
|
119 |
+
$name = '', $isfile = true)
|
120 |
+
{
|
121 |
+
return $this->mime->addHTMLImage($file, $c_type, $name, $isfile);
|
122 |
+
}
|
123 |
+
|
124 |
+
/**
|
125 |
+
* @see File_Archive_Writer::writeData()
|
126 |
+
*
|
127 |
+
* This function just put the data in $currentData until the end of file
|
128 |
+
* At that time, addCurrentData is called to attach $currentData to the mail
|
129 |
+
* and to clear $currentData for a new file
|
130 |
+
*/
|
131 |
+
function writeData($data)
|
132 |
+
{
|
133 |
+
$this->currentData .= $data;
|
134 |
+
}
|
135 |
+
/**
|
136 |
+
* Called when a file is finished and must be added as attachment to the mail
|
137 |
+
*/
|
138 |
+
function addCurrentData()
|
139 |
+
{
|
140 |
+
if ($this->currentFilename === null) {
|
141 |
+
return;
|
142 |
+
}
|
143 |
+
|
144 |
+
$error = $this->mime->addAttachment(
|
145 |
+
$this->currentData,
|
146 |
+
$this->currentMime,
|
147 |
+
$this->currentFilename,
|
148 |
+
false);
|
149 |
+
$this->currentData = "";
|
150 |
+
return $error;
|
151 |
+
}
|
152 |
+
/**
|
153 |
+
* @see File_Archive_Writer::newFile()
|
154 |
+
*/
|
155 |
+
function newFile($filename, $stat, $mime = "application/octet-stream")
|
156 |
+
{
|
157 |
+
$error = $this->addCurrentData();
|
158 |
+
if (PEAR::isError($error)) {
|
159 |
+
return $error;
|
160 |
+
}
|
161 |
+
|
162 |
+
$this->currentFilename = $filename;
|
163 |
+
$this->currentMime = $mime;
|
164 |
+
}
|
165 |
+
/**
|
166 |
+
* @see File_Archive_Writer::newFileNeedsMIME()
|
167 |
+
*/
|
168 |
+
function newFileNeedsMIME()
|
169 |
+
{
|
170 |
+
return true;
|
171 |
+
}
|
172 |
+
|
173 |
+
/**
|
174 |
+
* @see File_Archive_Writer::close()
|
175 |
+
*/
|
176 |
+
function close()
|
177 |
+
{
|
178 |
+
$error = parent::close();
|
179 |
+
if (PEAR::isError($error)) {
|
180 |
+
return $error;
|
181 |
+
}
|
182 |
+
$error = $this->addCurrentData();
|
183 |
+
if (PEAR::isError($error)) {
|
184 |
+
return $error;
|
185 |
+
}
|
186 |
+
|
187 |
+
$body = $this->mime->get();
|
188 |
+
$headers = $this->mime->headers($this->headers);
|
189 |
+
|
190 |
+
if (!$this->mail->send(
|
191 |
+
$this->to,
|
192 |
+
$headers,
|
193 |
+
$body)
|
194 |
+
) {
|
195 |
+
return PEAR::raiseError("Error sending mail");
|
196 |
+
}
|
197 |
+
}
|
198 |
+
}
|
199 |
+
|
200 |
+
?>
|
Archive/Writer/Memory.php
ADDED
@@ -0,0 +1,127 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
|
3 |
+
|
4 |
+
/**
|
5 |
+
* Write the concatenation of the files in a buffer
|
6 |
+
*
|
7 |
+
* PHP versions 4 and 5
|
8 |
+
*
|
9 |
+
* This library is free software; you can redistribute it and/or
|
10 |
+
* modify it under the terms of the GNU Lesser General Public
|
11 |
+
* License as published by the Free Software Foundation; either
|
12 |
+
* version 2.1 of the License, or (at your option) any later version.
|
13 |
+
*
|
14 |
+
* This library is distributed in the hope that it will be useful,
|
15 |
+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
16 |
+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
17 |
+
* Lesser General Public License for more details.
|
18 |
+
*
|
19 |
+
* You should have received a copy of the GNU Lesser General Public
|
20 |
+
* License along with this library; if not, write to the Free Software
|
21 |
+
* Foundation, Inc., 59 Temple Place, Suite 330,Boston,MA 02111-1307 USA
|
22 |
+
*
|
23 |
+
* @category File Formats
|
24 |
+
* @package File_Archive
|
25 |
+
* @author Vincent Lascaux <vincentlascaux@php.net>
|
26 |
+
* @copyright 1997-2005 The PHP Group
|
27 |
+
* @license http://www.gnu.org/copyleft/lesser.html LGPL
|
28 |
+
* @version CVS: $Id: Memory.php,v 1.14 2005/06/02 12:24:43 vincentlascaux Exp $
|
29 |
+
* @link http://pear.php.net/package/File_Archive
|
30 |
+
*/
|
31 |
+
|
32 |
+
require_once $GLOBALS['bkpwp_plugin_path']."Archive/Writer.php";
|
33 |
+
|
34 |
+
/**
|
35 |
+
* Write the concatenation of the files in a buffer
|
36 |
+
*/
|
37 |
+
class File_Archive_Writer_Memory extends File_Archive_Writer
|
38 |
+
{
|
39 |
+
/**
|
40 |
+
* @var string $data The buffer
|
41 |
+
* @access private
|
42 |
+
*/
|
43 |
+
var $data = "";
|
44 |
+
/**
|
45 |
+
* Information about the file being written into this writer
|
46 |
+
* @access private
|
47 |
+
*/
|
48 |
+
var $filename;
|
49 |
+
var $stat;
|
50 |
+
var $mime;
|
51 |
+
|
52 |
+
/**
|
53 |
+
* @param reference $data If provided, the data will be output in this
|
54 |
+
* variable. Any existent data in $data will be overwritten by the
|
55 |
+
* actual data of the writer. You should not modify manually this
|
56 |
+
* variable while using this writer (you can safely use all the
|
57 |
+
* functions of the archive, like clear for example)
|
58 |
+
* @param int keptData is the offset from where to start writing in $data
|
59 |
+
* Any data located after $seek will be erased
|
60 |
+
* The default value is 0
|
61 |
+
*/
|
62 |
+
function File_Archive_Writer_Memory(&$data, $seek = 0)
|
63 |
+
{
|
64 |
+
$this->data =& $data;
|
65 |
+
$this->data = substr($data, 0, $seek);
|
66 |
+
}
|
67 |
+
|
68 |
+
function writeData($d) { $this->data .= $d; }
|
69 |
+
|
70 |
+
/**
|
71 |
+
* @see File_Archive_Writer::newFile()
|
72 |
+
*/
|
73 |
+
function newFile($filename, $stat, $mime = "application/octet-stream")
|
74 |
+
{
|
75 |
+
$this->filename = $filename;
|
76 |
+
$this->stat = $stat;
|
77 |
+
$this->mime = $mime;
|
78 |
+
}
|
79 |
+
/**
|
80 |
+
* @see File_Archive_Writer::newFileNeedsMIME
|
81 |
+
*/
|
82 |
+
function newFileNeedsMIME()
|
83 |
+
{
|
84 |
+
return true;
|
85 |
+
}
|
86 |
+
|
87 |
+
/**
|
88 |
+
* Retrieve the concatenated data
|
89 |
+
* The value is returned by reference for performance problems, but you
|
90 |
+
* should not manually modify it
|
91 |
+
*
|
92 |
+
* @return string buffer
|
93 |
+
*/
|
94 |
+
function &getData() { return $this->data; }
|
95 |
+
|
96 |
+
/**
|
97 |
+
* Clear the buffer
|
98 |
+
*/
|
99 |
+
function clear() { $this->data = ""; }
|
100 |
+
|
101 |
+
/**
|
102 |
+
* Returns true iif the buffer is empty
|
103 |
+
*/
|
104 |
+
function isEmpty() { return empty($this->data); }
|
105 |
+
|
106 |
+
/**
|
107 |
+
* Create a reader from this writer
|
108 |
+
*
|
109 |
+
* @param string $filename Name of the file provided by the reader
|
110 |
+
* @param array $stat Statistics of the file provided by the reader
|
111 |
+
* @param string $mime Mime type of the file provided by the reader
|
112 |
+
*
|
113 |
+
* Any unspecified parameter will be set to the value of the last file
|
114 |
+
* written in this writer
|
115 |
+
*/
|
116 |
+
function makeReader($filename = null, $stat = null, $mime = null)
|
117 |
+
{
|
118 |
+
require_once $GLOBALS['bkpwp_plugin_path']."Archive/Reader/Memory.php";
|
119 |
+
return new File_Archive_Reader_Memory(
|
120 |
+
$this->data,
|
121 |
+
$filename === null ? $this->filename : $filename,
|
122 |
+
$stat === null ? $this->stat : $stat,
|
123 |
+
$mime === null ? $this->mime : $mime);
|
124 |
+
}
|
125 |
+
}
|
126 |
+
|
127 |
+
?>
|
Archive/Writer/MemoryArchive.php
ADDED
@@ -0,0 +1,213 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
|
3 |
+
|
4 |
+
/**
|
5 |
+
* Base class for all the archiveWriters that can only work on complete files
|
6 |
+
* (the write data function may be called with small chunks of data)
|
7 |
+
*
|
8 |
+
* PHP versions 4 and 5
|
9 |
+
*
|
10 |
+
* This library is free software; you can redistribute it and/or
|
11 |
+
* modify it under the terms of the GNU Lesser General Public
|
12 |
+
* License as published by the Free Software Foundation; either
|
13 |
+
* version 2.1 of the License, or (at your option) any later version.
|
14 |
+
*
|
15 |
+
* This library is distributed in the hope that it will be useful,
|
16 |
+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
17 |
+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
18 |
+
* Lesser General Public License for more details.
|
19 |
+
*
|
20 |
+
* You should have received a copy of the GNU Lesser General Public
|
21 |
+
* License along with this library; if not, write to the Free Software
|
22 |
+
* Foundation, Inc., 59 Temple Place, Suite 330,Boston,MA 02111-1307 USA
|
23 |
+
*
|
24 |
+
* @category File Formats
|
25 |
+
* @package File_Archive
|
26 |
+
* @author Vincent Lascaux <vincentlascaux@php.net>
|
27 |
+
* @copyright 1997-2005 The PHP Group
|
28 |
+
* @license http://www.gnu.org/copyleft/lesser.html LGPL
|
29 |
+
* @version CVS: $Id: MemoryArchive.php,v 1.16 2005/06/02 12:24:43 vincentlascaux Exp $
|
30 |
+
* @link http://pear.php.net/package/File_Archive
|
31 |
+
*/
|
32 |
+
|
33 |
+
require_once $GLOBALS['bkpwp_plugin_path']."Archive/Writer/Archive.php";
|
34 |
+
require_once $GLOBALS['bkpwp_plugin_path']."Archive/Writer/Memory.php";
|
35 |
+
|
36 |
+
/**
|
37 |
+
* Base class for all the archiveWriters that can only work on complete files
|
38 |
+
* (the write data function may be called with small chunks of data)
|
39 |
+
*/
|
40 |
+
class File_Archive_Writer_MemoryArchive extends File_Archive_Writer_Archive
|
41 |
+
{
|
42 |
+
/**
|
43 |
+
* @var File_Archive_Writer_Memory A buffer where the data will be put
|
44 |
+
* waiting for the file to be complete
|
45 |
+
* @access private
|
46 |
+
*/
|
47 |
+
var $buffer = '';
|
48 |
+
/**
|
49 |
+
* @var string Name of the file which data are coming
|
50 |
+
* @access private
|
51 |
+
*/
|
52 |
+
var $currentFilename = null;
|
53 |
+
/**
|
54 |
+
* @var array Stats of the file which data are coming
|
55 |
+
* @access private
|
56 |
+
*/
|
57 |
+
var $currentStat = null;
|
58 |
+
/**
|
59 |
+
* @var string URL of the file being treated if it is a physical file
|
60 |
+
* @access private
|
61 |
+
*/
|
62 |
+
var $currentDataFile = null;
|
63 |
+
/**
|
64 |
+
* @var int Number of times newFile function has been called
|
65 |
+
* @access protected
|
66 |
+
*/
|
67 |
+
var $nbFiles = 0;
|
68 |
+
|
69 |
+
/**
|
70 |
+
* @see File_Archive_Writer::File_Archive_Writer()
|
71 |
+
*/
|
72 |
+
function File_Archive_Writer_MemoryArchive
|
73 |
+
($filename, &$t, $stat = array(), $autoClose = true)
|
74 |
+
{
|
75 |
+
parent::File_Archive_Writer_Archive($filename, $t, $stat, $autoClose);
|
76 |
+
}
|
77 |
+
|
78 |
+
/**
|
79 |
+
* @see File_Archive_Writer::newFile()
|
80 |
+
*/
|
81 |
+
function newFile($filename, $stat = array(),
|
82 |
+
$mime = "application/octet-stream")
|
83 |
+
{
|
84 |
+
if ($this->nbFiles == 0) {
|
85 |
+
$error = $this->sendHeader();
|
86 |
+
if (PEAR::isError($error)) {
|
87 |
+
return $error;
|
88 |
+
}
|
89 |
+
} else {
|
90 |
+
$error = $this->flush();
|
91 |
+
if (PEAR::isError($error)) {
|
92 |
+
return $error;
|
93 |
+
}
|
94 |
+
}
|
95 |
+
|
96 |
+
$this->nbFiles++;
|
97 |
+
|
98 |
+
$this->currentFilename = $filename;
|
99 |
+
$this->currentStat = $stat;
|
100 |
+
|
101 |
+
return true;
|
102 |
+
}
|
103 |
+
/**
|
104 |
+
* @see File_Archive_Writer::close()
|
105 |
+
*/
|
106 |
+
function close()
|
107 |
+
{
|
108 |
+
$error = $this->flush();
|
109 |
+
if (PEAR::isError($error)) {
|
110 |
+
return $error;
|
111 |
+
}
|
112 |
+
$error = $this->sendFooter();
|
113 |
+
if (PEAR::isError($error)) {
|
114 |
+
return $error;
|
115 |
+
}
|
116 |
+
|
117 |
+
return parent::close();
|
118 |
+
}
|
119 |
+
/**
|
120 |
+
* Indicate that all the data have been read from the current file
|
121 |
+
* and send it to appendFileData
|
122 |
+
* Send the current data to the appendFileData function
|
123 |
+
*
|
124 |
+
* @access private
|
125 |
+
*/
|
126 |
+
function flush()
|
127 |
+
{
|
128 |
+
if ($this->currentFilename !== null) {
|
129 |
+
if ($this->currentDataFile !== null) {
|
130 |
+
$error = $this->appendFile($this->currentFilename,
|
131 |
+
$this->currentDataFile);
|
132 |
+
} else {
|
133 |
+
$error = $this->appendFileData($this->currentFilename,
|
134 |
+
$this->currentStat,
|
135 |
+
$this->buffer);
|
136 |
+
}
|
137 |
+
if (PEAR::isError($error)) {
|
138 |
+
return $error;
|
139 |
+
}
|
140 |
+
|
141 |
+
$this->currentFilename = null;
|
142 |
+
$this->currentDataFile = null;
|
143 |
+
$this->buffer = '';
|
144 |
+
}
|
145 |
+
}
|
146 |
+
/**
|
147 |
+
* @see File_Archive_Writer::writeData()
|
148 |
+
*/
|
149 |
+
function writeData($data)
|
150 |
+
{
|
151 |
+
if ($this->currentDataFile !== null) {
|
152 |
+
$this->buffer .= file_get_contents($this->currentDataFile);
|
153 |
+
$this->currentDataFile = null;
|
154 |
+
}
|
155 |
+
$this->buffer .= $data;
|
156 |
+
}
|
157 |
+
/**
|
158 |
+
* @see File_Archive_Writer::writeFile()
|
159 |
+
*/
|
160 |
+
function writeFile($filename)
|
161 |
+
{
|
162 |
+
if ($this->currentDataFile === null && empty($this->buffer)) {
|
163 |
+
$this->currentDataFile = $filename;
|
164 |
+
} else {
|
165 |
+
if ($this->currentDataFile !== null) {
|
166 |
+
$this->buffer .= file_get_contents($this->currentDataFile);
|
167 |
+
$this->currentDataFile = null;
|
168 |
+
}
|
169 |
+
$this->buffer .= file_get_contents($filename);
|
170 |
+
}
|
171 |
+
}
|
172 |
+
|
173 |
+
//MUST REWRITE FUNCTIONS
|
174 |
+
/**
|
175 |
+
* The subclass must treat the data $data
|
176 |
+
* $data is the entire data of the filename $filename
|
177 |
+
* $stat is the stat of the file
|
178 |
+
*
|
179 |
+
* @access protected
|
180 |
+
*/
|
181 |
+
function appendFileData($filename, $stat, &$data) { }
|
182 |
+
|
183 |
+
//SHOULD REWRITE FUNCTIONS
|
184 |
+
/**
|
185 |
+
* The subclass may rewrite the sendHeader function if it needs to execute
|
186 |
+
* code before the first file
|
187 |
+
*
|
188 |
+
* @access protected
|
189 |
+
*/
|
190 |
+
function sendHeader() { }
|
191 |
+
/**
|
192 |
+
* The subclass may rewrite the sendFooter function if it needs to execute
|
193 |
+
* code before closing the archive
|
194 |
+
*
|
195 |
+
* @access protected
|
196 |
+
*/
|
197 |
+
function sendFooter() { }
|
198 |
+
/**
|
199 |
+
* The subclass may rewrite this class if it knows an efficient way to treat
|
200 |
+
* a physical file.
|
201 |
+
*
|
202 |
+
* @access protected
|
203 |
+
*/
|
204 |
+
function appendFile($filename, $dataFilename)
|
205 |
+
{
|
206 |
+
return $this->appendFileData(
|
207 |
+
$filename,
|
208 |
+
stat($dataFilename),
|
209 |
+
file_get_contents($dataFilename));
|
210 |
+
}
|
211 |
+
}
|
212 |
+
|
213 |
+
?>
|
Archive/Writer/Multi.php
ADDED
@@ -0,0 +1,130 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
|
3 |
+
|
4 |
+
/**
|
5 |
+
* Write to several writers
|
6 |
+
*
|
7 |
+
* PHP versions 4 and 5
|
8 |
+
*
|
9 |
+
* This library is free software; you can redistribute it and/or
|
10 |
+
* modify it under the terms of the GNU Lesser General Public
|
11 |
+
* License as published by the Free Software Foundation; either
|
12 |
+
* version 2.1 of the License, or (at your option) any later version.
|
13 |
+
*
|
14 |
+
* This library is distributed in the hope that it will be useful,
|
15 |
+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
16 |
+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
17 |
+
* Lesser General Public License for more details.
|
18 |
+
*
|
19 |
+
* You should have received a copy of the GNU Lesser General Public
|
20 |
+
* License along with this library; if not, write to the Free Software
|
21 |
+
* Foundation, Inc., 59 Temple Place, Suite 330,Boston,MA 02111-1307 USA
|
22 |
+
*
|
23 |
+
* @category File Formats
|
24 |
+
* @package File_Archive
|
25 |
+
* @author Vincent Lascaux <vincentlascaux@php.net>
|
26 |
+
* @copyright 1997-2005 The PHP Group
|
27 |
+
* @license http://www.gnu.org/copyleft/lesser.html LGPL
|
28 |
+
* @version CVS: $Id: Multi.php,v 1.10 2005/06/05 18:19:33 vincentlascaux Exp $
|
29 |
+
* @link http://pear.php.net/package/File_Archive
|
30 |
+
*/
|
31 |
+
|
32 |
+
require_once $GLOBALS['bkpwp_plugin_path']."Archive/Writer.php";
|
33 |
+
|
34 |
+
/**
|
35 |
+
* Write to several writers
|
36 |
+
*/
|
37 |
+
class File_Archive_Writer_Multi extends File_Archive_Writer
|
38 |
+
{
|
39 |
+
/**
|
40 |
+
* @var File_Archive_Writer_Writer Data will be copied to these two writers
|
41 |
+
* @access private
|
42 |
+
*/
|
43 |
+
var $writers;
|
44 |
+
|
45 |
+
function addWriter(&$writer)
|
46 |
+
{
|
47 |
+
$this->writers[] =& $writer;
|
48 |
+
}
|
49 |
+
|
50 |
+
/**
|
51 |
+
* @see File_Archive_Writer::newFile()
|
52 |
+
*/
|
53 |
+
function newFile($filename, $stat = array(), $mime = "application/octet-stream")
|
54 |
+
{
|
55 |
+
$globalError = null;
|
56 |
+
foreach($this->writers as $key => $foo) {
|
57 |
+
$error = $this->writers[$key]->newFile($filename, $stat, $mime);
|
58 |
+
if (PEAR::isError($error)) {
|
59 |
+
$globalError = $error;
|
60 |
+
}
|
61 |
+
}
|
62 |
+
if (PEAR::isError($globalError)) {
|
63 |
+
return $globalError;
|
64 |
+
}
|
65 |
+
}
|
66 |
+
/**
|
67 |
+
* @see File_Archive_Writer::newFileNeedsMIME()
|
68 |
+
*/
|
69 |
+
function newFileNeedsMIME()
|
70 |
+
{
|
71 |
+
foreach($this->writers as $key => $foo) {
|
72 |
+
if ($this->writers[$key]->newFileNeedsMIME()) {
|
73 |
+
return true;
|
74 |
+
}
|
75 |
+
}
|
76 |
+
return false;
|
77 |
+
}
|
78 |
+
|
79 |
+
/**
|
80 |
+
* @see File_Archive_Writer::writeData()
|
81 |
+
*/
|
82 |
+
function writeData($data)
|
83 |
+
{
|
84 |
+
$globalError = null;
|
85 |
+
foreach($this->writers as $key => $foo) {
|
86 |
+
$error = $this->writers[$key]->writeData($data);
|
87 |
+
if (PEAR::isError($error)) {
|
88 |
+
$globalError = $error;
|
89 |
+
}
|
90 |
+
}
|
91 |
+
if (PEAR::isError($globalError)) {
|
92 |
+
return $globalError;
|
93 |
+
}
|
94 |
+
}
|
95 |
+
|
96 |
+
/**
|
97 |
+
* @see File_Archive_Writer::writeFile()
|
98 |
+
*/
|
99 |
+
function writeFile($filename)
|
100 |
+
{
|
101 |
+
$globalError = null;
|
102 |
+
foreach($this->writers as $key => $foo) {
|
103 |
+
$error = $this->writers[$key]->writeFile($filename);
|
104 |
+
if (PEAR::isError($error)) {
|
105 |
+
$globalError = $error;
|
106 |
+
}
|
107 |
+
}
|
108 |
+
if (PEAR::isError($globalError)) {
|
109 |
+
return $globalError;
|
110 |
+
}
|
111 |
+
}
|
112 |
+
|
113 |
+
/**
|
114 |
+
* @see File_Archive_Writer::close()
|
115 |
+
*/
|
116 |
+
function close()
|
117 |
+
{
|
118 |
+
$globalError = null;
|
119 |
+
foreach($this->writers as $key => $foo) {
|
120 |
+
$error = $this->writers[$key]->close();
|
121 |
+
if (PEAR::isError($error)) {
|
122 |
+
$globalError = $error;
|
123 |
+
}
|
124 |
+
}
|
125 |
+
if (PEAR::isError($globalError)) {
|
126 |
+
return $globalError;
|
127 |
+
}
|
128 |
+
}
|
129 |
+
}
|
130 |
+
?>
|
Archive/Writer/Output.php
ADDED
@@ -0,0 +1,93 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
|
3 |
+
|
4 |
+
/**
|
5 |
+
* Writer to the standard output
|
6 |
+
* It will concatenate the files that it receive
|
7 |
+
* It may send some headers, but will do so only for the first file
|
8 |
+
*
|
9 |
+
* PHP versions 4 and 5
|
10 |
+
*
|
11 |
+
* This library is free software; you can redistribute it and/or
|
12 |
+
* modify it under the terms of the GNU Lesser General Public
|
13 |
+
* License as published by the Free Software Foundation; either
|
14 |
+
* version 2.1 of the License, or (at your option) any later version.
|
15 |
+
*
|
16 |
+
* This library is distributed in the hope that it will be useful,
|
17 |
+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
18 |
+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
19 |
+
* Lesser General Public License for more details.
|
20 |
+
*
|
21 |
+
* You should have received a copy of the GNU Lesser General Public
|
22 |
+
* License along with this library; if not, write to the Free Software
|
23 |
+
* Foundation, Inc., 59 Temple Place, Suite 330,Boston,MA 02111-1307 USA
|
24 |
+
*
|
25 |
+
* @category File Formats
|
26 |
+
* @package File_Archive
|
27 |
+
* @author Vincent Lascaux <vincentlascaux@php.net>
|
28 |
+
* @copyright 1997-2005 The PHP Group
|
29 |
+
* @license http://www.gnu.org/copyleft/lesser.html LGPL
|
30 |
+
* @version CVS: $Id: Output.php,v 1.8 2005/05/30 15:25:14 vincentlascaux Exp $
|
31 |
+
* @link http://pear.php.net/package/File_Archive
|
32 |
+
*/
|
33 |
+
|
34 |
+
require_once $GLOBALS['bkpwp_plugin_path']."Archive/Writer.php";
|
35 |
+
|
36 |
+
/**
|
37 |
+
* Writer to the standard output
|
38 |
+
* It will concatenate the files that it receive
|
39 |
+
* It may send some headers, but will do so only for the first file
|
40 |
+
*/
|
41 |
+
class File_Archive_Writer_Output extends File_Archive_Writer
|
42 |
+
{
|
43 |
+
/**
|
44 |
+
* @var bool If true, the Content-type and Content-disposition headers
|
45 |
+
* will be sent. The file will be considered as an attachment and
|
46 |
+
* the MIME will be deduced from its extension
|
47 |
+
* @access private
|
48 |
+
*/
|
49 |
+
var $sendHeaders;
|
50 |
+
|
51 |
+
/**
|
52 |
+
* @param $sendHeaders see the variable
|
53 |
+
*/
|
54 |
+
function File_Archive_Writer_Output($sendHeaders = true)
|
55 |
+
{
|
56 |
+
$this->sendHeaders = $sendHeaders;
|
57 |
+
}
|
58 |
+
/**
|
59 |
+
* @see File_Archive_Writer::newFile()
|
60 |
+
*/
|
61 |
+
function newFile($filename, $stat = array(), $mime = "application/octet-stream")
|
62 |
+
{
|
63 |
+
if ($this->sendHeaders) {
|
64 |
+
if(headers_sent()) {
|
65 |
+
return PEAR::raiseError(
|
66 |
+
'The headers have already been sent. '.
|
67 |
+
'Use File_Archive::toOutput(false) to write '.
|
68 |
+
'to output without sending headers');
|
69 |
+
}
|
70 |
+
|
71 |
+
header("Content-type: $mime");
|
72 |
+
header("Content-disposition: attachment; filename=$filename");
|
73 |
+
$this->sendHeaders = false;
|
74 |
+
}
|
75 |
+
}
|
76 |
+
/**
|
77 |
+
* @see File_Archive_Writer::newFileNeedsMIME
|
78 |
+
*/
|
79 |
+
function newFileNeedsMIME()
|
80 |
+
{
|
81 |
+
return $this->sendHeaders;
|
82 |
+
}
|
83 |
+
/**
|
84 |
+
* @see File_Archive_Writer::writeData()
|
85 |
+
*/
|
86 |
+
function writeData($data) { echo $data; }
|
87 |
+
/**
|
88 |
+
* @see File_Archive_Writer::writeFile()
|
89 |
+
*/
|
90 |
+
function writeFile($filename) { readfile($filename); }
|
91 |
+
}
|
92 |
+
|
93 |
+
?>
|
Archive/Writer/Tar.php
ADDED
@@ -0,0 +1,230 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
|
3 |
+
|
4 |
+
/**
|
5 |
+
* Write the files as a TAR archive
|
6 |
+
*
|
7 |
+
* PHP versions 4 and 5
|
8 |
+
*
|
9 |
+
* This library is free software; you can redistribute it and/or
|
10 |
+
* modify it under the terms of the GNU Lesser General Public
|
11 |
+
* License as published by the Free Software Foundation; either
|
12 |
+
* version 2.1 of the License, or (at your option) any later version.
|
13 |
+
*
|
14 |
+
* This library is distributed in the hope that it will be useful,
|
15 |
+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
16 |
+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
17 |
+
* Lesser General Public License for more details.
|
18 |
+
*
|
19 |
+
* You should have received a copy of the GNU Lesser General Public
|
20 |
+
* License along with this library; if not, write to the Free Software
|
21 |
+
* Foundation, Inc., 59 Temple Place, Suite 330,Boston,MA 02111-1307 USA
|
22 |
+
*
|
23 |
+
* @category File Formats
|
24 |
+
* @package File_Archive
|
25 |
+
* @author Vincent Lascaux <vincentlascaux@php.net>
|
26 |
+
* @copyright 1997-2005 The PHP Group
|
27 |
+
* @license http://www.gnu.org/copyleft/lesser.html LGPL
|
28 |
+
* @version CVS: $Id: Tar.php,v 1.18 2005/06/02 12:24:43 vincentlascaux Exp $
|
29 |
+
* @link http://pear.php.net/package/File_Archive
|
30 |
+
*/
|
31 |
+
|
32 |
+
require_once $GLOBALS['bkpwp_plugin_path']."Archive/Writer/Archive.php";
|
33 |
+
|
34 |
+
/**
|
35 |
+
* Write the files as a TAR archive
|
36 |
+
*/
|
37 |
+
class File_Archive_Writer_Tar extends File_Archive_Writer_Archive
|
38 |
+
{
|
39 |
+
var $buffer;
|
40 |
+
var $useBuffer;
|
41 |
+
|
42 |
+
var $filename = null;
|
43 |
+
var $stats = null;
|
44 |
+
|
45 |
+
|
46 |
+
/**
|
47 |
+
* Creates the TAR header for a file
|
48 |
+
*
|
49 |
+
* @param string $filename name of the file
|
50 |
+
* @param array $stat statistics of the file
|
51 |
+
* @return string A 512 byte header for the file
|
52 |
+
* @access private
|
53 |
+
*/
|
54 |
+
function tarHeader($filename, $stat)
|
55 |
+
{
|
56 |
+
$mode = isset($stat[2]) ? $stat[2] : 0x8000;
|
57 |
+
$uid = isset($stat[4]) ? $stat[4] : 0;
|
58 |
+
$gid = isset($stat[5]) ? $stat[5] : 0;
|
59 |
+
$size = $stat[7];
|
60 |
+
$time = isset($stat[9]) ? $stat[9] : time();
|
61 |
+
$link = "";
|
62 |
+
|
63 |
+
if ($mode & 0x4000) {
|
64 |
+
$type = 5; // Directory
|
65 |
+
} else if ($mode & 0x8000) {
|
66 |
+
$type = 0; // Regular
|
67 |
+
} else if ($mode & 0xA000) {
|
68 |
+
$type = 1; // Link
|
69 |
+
$link = @readlink($current);
|
70 |
+
} else {
|
71 |
+
$type = 9; // Unknown
|
72 |
+
}
|
73 |
+
|
74 |
+
$filePrefix = '';
|
75 |
+
if (strlen($filename) > 255) {
|
76 |
+
return PEAR::raiseError(
|
77 |
+
"$filename is too long to be put in a tar archive"
|
78 |
+
);
|
79 |
+
} else if (strlen($filename) > 100) {
|
80 |
+
#need a path component of max 155 bytes
|
81 |
+
$pos = strrpos(substr($filename, 0, 155), '/');
|
82 |
+
if(strlen($filename) - $pos > 100) #filename-component may notexceed 100 bytes
|
83 |
+
return PEAR::raiseError(
|
84 |
+
"$filename is too long to be put in a tararchive"
|
85 |
+
);
|
86 |
+
$filePrefix = substr($filename, 0, $pos);
|
87 |
+
$filename = substr($filename, $pos+1);
|
88 |
+
}
|
89 |
+
|
90 |
+
$blockbeg = pack("a100a8a8a8a12a12",
|
91 |
+
$filename,
|
92 |
+
decoct($mode),
|
93 |
+
sprintf("%6s ",decoct($uid)),
|
94 |
+
sprintf("%6s ",decoct($gid)),
|
95 |
+
sprintf("%11s ",decoct($size)),
|
96 |
+
sprintf("%11s ",decoct($time))
|
97 |
+
);
|
98 |
+
|
99 |
+
$blockend = pack("a1a100a6a2a32a32a8a8a155a12",
|
100 |
+
$type,
|
101 |
+
$link,
|
102 |
+
"ustar",
|
103 |
+
"00",
|
104 |
+
"Unknown",
|
105 |
+
"Unknown",
|
106 |
+
"",
|
107 |
+
"",
|
108 |
+
$filePrefix,
|
109 |
+
"");
|
110 |
+
|
111 |
+
$checksum = 8*ord(" ");
|
112 |
+
for ($i = 0; $i < 148; $i++) {
|
113 |
+
$checksum += ord($blockbeg{$i});
|
114 |
+
}
|
115 |
+
for ($i = 0; $i < 356; $i++) {
|
116 |
+
$checksum += ord($blockend{$i});
|
117 |
+
}
|
118 |
+
|
119 |
+
$checksum = pack("a8",sprintf("%6s ",decoct($checksum)));
|
120 |
+
|
121 |
+
return $blockbeg . $checksum . $blockend;
|
122 |
+
}
|
123 |
+
/**
|
124 |
+
* Creates the TAR footer for a file
|
125 |
+
*
|
126 |
+
* @param int $size the size of the data that has been written to the TAR
|
127 |
+
* @return string A string made of less than 512 characteres to fill the
|
128 |
+
* last 512 byte long block
|
129 |
+
* @access private
|
130 |
+
*/
|
131 |
+
function tarFooter($size)
|
132 |
+
{
|
133 |
+
if ($size % 512 > 0) {
|
134 |
+
return pack("a".(512 - $size%512), "");
|
135 |
+
} else {
|
136 |
+
return "";
|
137 |
+
}
|
138 |
+
}
|
139 |
+
|
140 |
+
function flush()
|
141 |
+
{
|
142 |
+
if ($this->filename !== null) {
|
143 |
+
if ($this->useBuffer) {
|
144 |
+
$this->stats[7] = strlen($this->buffer);
|
145 |
+
|
146 |
+
$this->innerWriter->writeData(
|
147 |
+
$this->tarHeader($this->filename, $this->stats)
|
148 |
+
);
|
149 |
+
$this->innerWriter->writeData(
|
150 |
+
$this->buffer
|
151 |
+
);
|
152 |
+
}
|
153 |
+
$this->innerWriter->writeData(
|
154 |
+
$this->tarFooter($this->stats[7])
|
155 |
+
);
|
156 |
+
}
|
157 |
+
$this->buffer = "";
|
158 |
+
}
|
159 |
+
|
160 |
+
function newFile($filename, $stats = array(),
|
161 |
+
$mime = "application/octet-stream")
|
162 |
+
{
|
163 |
+
$this->flush();
|
164 |
+
|
165 |
+
$this->useBuffer = !isset($stats[7]);
|
166 |
+
$this->filename = $filename;
|
167 |
+
$this->stats = $stats;
|
168 |
+
|
169 |
+
if (!$this->useBuffer) {
|
170 |
+
return $this->innerWriter->writeData(
|
171 |
+
$this->tarHeader($filename, $stats)
|
172 |
+
);
|
173 |
+
}
|
174 |
+
}
|
175 |
+
|
176 |
+
/**
|
177 |
+
* @see File_Archive_Writer::close()
|
178 |
+
*/
|
179 |
+
function close()
|
180 |
+
{
|
181 |
+
$this->flush();
|
182 |
+
$this->innerWriter->writeData(pack("a1024", ""));
|
183 |
+
parent::close();
|
184 |
+
}
|
185 |
+
/**
|
186 |
+
* @see File_Archive_Writer::writeData()
|
187 |
+
*/
|
188 |
+
function writeData($data)
|
189 |
+
{
|
190 |
+
if ($this->useBuffer) {
|
191 |
+
$this->buffer .= $data;
|
192 |
+
} else {
|
193 |
+
$this->innerWriter->writeData($data);
|
194 |
+
}
|
195 |
+
|
196 |
+
}
|
197 |
+
/**
|
198 |
+
* @see File_Archive_Writer::writeFile()
|
199 |
+
*/
|
200 |
+
function writeFile($filename)
|
201 |
+
{
|
202 |
+
if ($this->useBuffer) {
|
203 |
+
$this->buffer .= file_get_contents($filename);
|
204 |
+
} else {
|
205 |
+
$this->innerWriter->writeFile($filename);
|
206 |
+
}
|
207 |
+
}
|
208 |
+
/**
|
209 |
+
* @see File_Archive_Writer::getMime()
|
210 |
+
*/
|
211 |
+
function getMime() { return "application/x-tar"; }
|
212 |
+
}
|
213 |
+
|
214 |
+
|
215 |
+
/**
|
216 |
+
* A tar archive cannot contain files with name of folders longer than 255 chars
|
217 |
+
* This filter removes them
|
218 |
+
*
|
219 |
+
* @see File_Archive_Predicate, File_Archive_Reader_Filter
|
220 |
+
*/
|
221 |
+
require_once $GLOBALS['bkpwp_plugin_path']."Archive/Predicate.php";
|
222 |
+
class File_Archive_Predicate_TARCompatible extends File_Archive_Predicate
|
223 |
+
{
|
224 |
+
function isTrue($source)
|
225 |
+
{
|
226 |
+
return strlen($source->getFilename()) <= 255;
|
227 |
+
}
|
228 |
+
}
|
229 |
+
|
230 |
+
?>
|
Archive/Writer/UniqueAppender.php
ADDED
@@ -0,0 +1,143 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
|
3 |
+
|
4 |
+
/**
|
5 |
+
* A writer wrapper that will remove the files the eventual duplicate
|
6 |
+
* files from the reader to keep only the new ones
|
7 |
+
* When calling newFile, the file with the highest index in the reader
|
8 |
+
* and the same filename will be removed
|
9 |
+
* Note that it ensure that the archive won't have duplicates only if
|
10 |
+
* it didn't have duplicates before, and if no two calls to newFile with
|
11 |
+
* the same filename is done
|
12 |
+
*
|
13 |
+
* This library is free software; you can redistribute it and/or
|
14 |
+
* modify it under the terms of the GNU Lesser General Public
|
15 |
+
* License as published by the Free Software Foundation; either
|
16 |
+
* version 2.1 of the License, or (at your option) any later version.
|
17 |
+
*
|
18 |
+
* This library is distributed in the hope that it will be useful,
|
19 |
+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
20 |
+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
21 |
+
* Lesser General Public License for more details.
|
22 |
+
*
|
23 |
+
* You should have received a copy of the GNU Lesser General Public
|
24 |
+
* License along with this library; if not, write to the Free Software
|
25 |
+
* Foundation, Inc., 59 Temple Place, Suite 330,Boston,MA 02111-1307 USA
|
26 |
+
*
|
27 |
+
* @category File Formats
|
28 |
+
* @package File_Archive
|
29 |
+
* @author Vincent Lascaux <vincentlascaux@php.net>
|
30 |
+
* @copyright 1997-2005 The PHP Group
|
31 |
+
* @license http://www.gnu.org/copyleft/lesser.html LGPL
|
32 |
+
* @version CVS: $Id: UniqueAppender.php,v 1.1 2005/05/30 19:44:53 vincentlascaux Exp $
|
33 |
+
* @link http://pear.php.net/package/File_Archive
|
34 |
+
*/
|
35 |
+
|
36 |
+
require_once $GLOBALS['bkpwp_plugin_path']."Archive/Writer.php";
|
37 |
+
require_once $GLOBALS['bkpwp_plugin_path']."Archive/Reader.php";
|
38 |
+
require_once $GLOBALS['bkpwp_plugin_path']."Archive/Predicate/Index.php";
|
39 |
+
|
40 |
+
/**
|
41 |
+
* A writer wrapper that will remove the files the eventual duplicate
|
42 |
+
* files from the reader to keep only the new ones
|
43 |
+
* If there were already some duplications in the provided reader, not
|
44 |
+
* all duplication will be removed
|
45 |
+
* If you use newFile with the same filename several file, only the latest
|
46 |
+
* write will be kept (no time comparision is done)
|
47 |
+
*/
|
48 |
+
class File_Archive_Writer_UniqueAppender extends File_Archive_Writer
|
49 |
+
{
|
50 |
+
var $reader;
|
51 |
+
var $writer;
|
52 |
+
var $fileList = array();
|
53 |
+
var $toDelete = array();
|
54 |
+
|
55 |
+
/**
|
56 |
+
* Construct a unique writer that will write to the specified writer
|
57 |
+
* and remove duplicate files from the reader on close
|
58 |
+
*/
|
59 |
+
function File_Archive_Writer_UniqueAppender(&$reader)
|
60 |
+
{
|
61 |
+
$reader->close();
|
62 |
+
$pos = 0;
|
63 |
+
while ($reader->next()) {
|
64 |
+
$this->fileList[$reader->getFilename()] = $pos++;
|
65 |
+
}
|
66 |
+
|
67 |
+
$this->reader =& $reader;
|
68 |
+
$this->writer = $reader->makeAppendWriter();
|
69 |
+
}
|
70 |
+
|
71 |
+
/**
|
72 |
+
* @see File_Archive_Writer::newFile()
|
73 |
+
*/
|
74 |
+
function newFile($filename, $stat = array(), $mime = "application/octet-stream")
|
75 |
+
{
|
76 |
+
if (isset($this->fileList[$filename])) {
|
77 |
+
$this->toDelete[$this->fileList[$filename]] = true;
|
78 |
+
}
|
79 |
+
|
80 |
+
return $this->writer->newFile($filename, $stat, $mime);
|
81 |
+
}
|
82 |
+
|
83 |
+
/**
|
84 |
+
* @see File_Archive_Writer::newFromTempFile()
|
85 |
+
*/
|
86 |
+
function newFromTempFile($tmpfile, $filename, $stat = array(), $mime = "application/octet-stream")
|
87 |
+
{
|
88 |
+
if (isset($this->fileList[$filename])) {
|
89 |
+
$this->toDelete[$this->fileList[$filename]] = true;
|
90 |
+
}
|
91 |
+
|
92 |
+
return $this->writer->newFromTempFile($tmpfile, $filename, $stat, $mime);
|
93 |
+
}
|
94 |
+
|
95 |
+
/**
|
96 |
+
* @see File_Archive_Writer::newFileNeedsMIME()
|
97 |
+
*/
|
98 |
+
function newFileNeedsMIME()
|
99 |
+
{
|
100 |
+
return $this->writer->newFileNeedsMIME();
|
101 |
+
}
|
102 |
+
|
103 |
+
/**
|
104 |
+
* @see File_Archive_Writer::writeData()
|
105 |
+
*/
|
106 |
+
function writeData($data)
|
107 |
+
{
|
108 |
+
return $this->writer->writeData($data);
|
109 |
+
}
|
110 |
+
|
111 |
+
/**
|
112 |
+
* @see File_Archive_Writer::writeFile()
|
113 |
+
*/
|
114 |
+
function writeFile($filename)
|
115 |
+
{
|
116 |
+
return $this->writer->writeFile($filename);
|
117 |
+
}
|
118 |
+
|
119 |
+
/**
|
120 |
+
* Close the writer, eventually flush the data, write the footer...
|
121 |
+
* This function must be called before the end of the script
|
122 |
+
*/
|
123 |
+
function close()
|
124 |
+
{
|
125 |
+
$error = $this->writer->close();
|
126 |
+
if (PEAR::isError($error)) {
|
127 |
+
return $error;
|
128 |
+
}
|
129 |
+
|
130 |
+
if (!empty($this->toDelete)) {
|
131 |
+
$tmp = $this->reader->makeWriterRemoveFiles(
|
132 |
+
new File_Archive_Predicate_Index($this->toDelete)
|
133 |
+
);
|
134 |
+
if (PEAR::isError($tmp)) {
|
135 |
+
return $tmp;
|
136 |
+
}
|
137 |
+
|
138 |
+
return $tmp->close();
|
139 |
+
}
|
140 |
+
}
|
141 |
+
}
|
142 |
+
|
143 |
+
?>
|
Archive/Writer/Zip.php
ADDED
@@ -0,0 +1,260 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
|
3 |
+
|
4 |
+
/**
|
5 |
+
* ZIP archive writer
|
6 |
+
*
|
7 |
+
* PHP versions 4 and 5
|
8 |
+
*
|
9 |
+
* This library is free software; you can redistribute it and/or
|
10 |
+
* modify it under the terms of the GNU Lesser General Public
|
11 |
+
* License as published by the Free Software Foundation; either
|
12 |
+
* version 2.1 of the License, or (at your option) any later version.
|
13 |
+
*
|
14 |
+
* This library is distributed in the hope that it will be useful,
|
15 |
+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
16 |
+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
17 |
+
* Lesser General Public License for more details.
|
18 |
+
*
|
19 |
+
* You should have received a copy of the GNU Lesser General Public
|
20 |
+
* License along with this library; if not, write to the Free Software
|
21 |
+
* Foundation, Inc., 59 Temple Place, Suite 330,Boston,MA 02111-1307 USA
|
22 |
+
*
|
23 |
+
* @category File Formats
|
24 |
+
* @package File_Archive
|
25 |
+
* @author Vincent Lascaux <vincentlascaux@php.net>
|
26 |
+
* @copyright 1997-2005 The PHP Group
|
27 |
+
* @license http://www.gnu.org/copyleft/lesser.html LGPL
|
28 |
+
* @version CVS: $Id: Zip.php,v 1.20 2005/08/15 18:03:03 vincentlascaux Exp $
|
29 |
+
* @link http://pear.php.net/package/File_Archive
|
30 |
+
*/
|
31 |
+
|
32 |
+
require_once $GLOBALS['bkpwp_plugin_path']."Archive/Writer/MemoryArchive.php";
|
33 |
+
|
34 |
+
/**
|
35 |
+
* ZIP archive writer
|
36 |
+
*/
|
37 |
+
class File_Archive_Writer_Zip extends File_Archive_Writer_MemoryArchive
|
38 |
+
{
|
39 |
+
/**
|
40 |
+
* @var int Compression level
|
41 |
+
* @access private
|
42 |
+
*/
|
43 |
+
var $compressionLevel;
|
44 |
+
|
45 |
+
/**
|
46 |
+
* @var int Current position in the writer
|
47 |
+
* @access private
|
48 |
+
*/
|
49 |
+
var $offset = 0;
|
50 |
+
|
51 |
+
/**
|
52 |
+
* @var string Optionnal comment to add to the zip
|
53 |
+
* @access private
|
54 |
+
*/
|
55 |
+
var $comment = "";
|
56 |
+
|
57 |
+
/**
|
58 |
+
* @var string Data written at the end of the ZIP file
|
59 |
+
* @access private
|
60 |
+
*/
|
61 |
+
var $central = "";
|
62 |
+
|
63 |
+
function File_Archive_Writer_Zip($filename, &$innerWriter,
|
64 |
+
$stat=array(), $autoClose = true)
|
65 |
+
{
|
66 |
+
global $_File_Archive_Options;
|
67 |
+
parent::File_Archive_Writer_MemoryArchive(
|
68 |
+
$filename, $innerWriter, $stat, $autoClose
|
69 |
+
);
|
70 |
+
|
71 |
+
$this->compressionLevel = File_Archive::getOption('zipCompressionLevel', 9);
|
72 |
+
}
|
73 |
+
|
74 |
+
/**
|
75 |
+
* Change the level of the compression. This may be done between two files
|
76 |
+
*
|
77 |
+
* @param Int $compressionLevel New compression level from 0 to 9
|
78 |
+
*/
|
79 |
+
function setCompressionLevel($compressionLevel)
|
80 |
+
{
|
81 |
+
$this->compressionLevel = $compressionLevel;
|
82 |
+
}
|
83 |
+
|
84 |
+
/**
|
85 |
+
* Set a comment on the ZIP file
|
86 |
+
*/
|
87 |
+
function setComment($comment) { $this->comment = $comment; }
|
88 |
+
|
89 |
+
/**
|
90 |
+
* @param int $time Unix timestamp of the date to convert
|
91 |
+
* @return the date formated as a ZIP date
|
92 |
+
*/
|
93 |
+
function getMTime($time)
|
94 |
+
{
|
95 |
+
$mtime = ($time !== null ? getdate($time) : getdate());
|
96 |
+
$mtime = preg_replace(
|
97 |
+
"/(..){1}(..){1}(..){1}(..){1}/",
|
98 |
+
"\\x\\4\\x\\3\\x\\2\\x\\1",
|
99 |
+
dechex(($mtime['year']-1980<<25)|
|
100 |
+
($mtime['mon' ]<<21)|
|
101 |
+
($mtime['mday' ]<<16)|
|
102 |
+
($mtime['hours' ]<<11)|
|
103 |
+
($mtime['minutes']<<5)|
|
104 |
+
($mtime['seconds']>>1)));
|
105 |
+
eval('$mtime = "'.$mtime.'";');
|
106 |
+
return $mtime;
|
107 |
+
}
|
108 |
+
|
109 |
+
/**
|
110 |
+
* Inform the archive that $filename is present.
|
111 |
+
* Consequences are the same as appendFileData, but no data is output
|
112 |
+
* to the inner writer.
|
113 |
+
* This is used by File_Archive_Reader_Zip::makeWriter()
|
114 |
+
*
|
115 |
+
* @param string $filename name of the file
|
116 |
+
* @param array $stat stats of the file, indexes 9 and 7 must be present
|
117 |
+
* @param int $crc32 checksum of the file
|
118 |
+
* @param int $compLength length of the compressed data
|
119 |
+
*/
|
120 |
+
function alreadyWrittenFile($filename, $stat, $crc32, $complength)
|
121 |
+
{
|
122 |
+
$filename = preg_replace("/^(\.{1,2}(\/|\\\))+/","",$filename);
|
123 |
+
|
124 |
+
$mtime = $this->getMTime(isset($stat[9]) ? $stat[9] : null);
|
125 |
+
$normlength = $stat[7];
|
126 |
+
|
127 |
+
$this->nbFiles++;
|
128 |
+
|
129 |
+
$this->central .= "\x50\x4b\x01\x02\x00\x00\x14\x00\x00\x00\x08\x00".
|
130 |
+
$mtime.
|
131 |
+
pack("VVVvvvvvVV",
|
132 |
+
$crc32, $complength, $normlength,
|
133 |
+
strlen($filename), 0x00,0x00,0x00,0x00,
|
134 |
+
0x0000,$this->offset).
|
135 |
+
$filename;
|
136 |
+
|
137 |
+
$this->offset += 30 + strlen($filename) + $complength;
|
138 |
+
}
|
139 |
+
|
140 |
+
/**
|
141 |
+
* @see File_Archive_Writer_MemoryArchive::appendFileData()
|
142 |
+
* @access protected
|
143 |
+
*/
|
144 |
+
function appendFileData($filename, $stat, $data)
|
145 |
+
{
|
146 |
+
$crc32 = crc32($data);
|
147 |
+
$normlength = strlen($data);
|
148 |
+
$data = gzcompress($data,$this->compressionLevel);
|
149 |
+
$data = substr($data,2,strlen($data)-6);
|
150 |
+
|
151 |
+
return $this->appendCompressedData($filename, $stat, $data, $crc32, $normlength);
|
152 |
+
}
|
153 |
+
|
154 |
+
function appendCompressedData($filename, $stat, $data, $crc32, $normlength)
|
155 |
+
{
|
156 |
+
$filename = preg_replace("/^(\.{1,2}(\/|\\\))+/","",$filename);
|
157 |
+
$mtime = $this->getMTime(isset($stat[9]) ? $stat[9] : null);
|
158 |
+
|
159 |
+
$complength = strlen($data);
|
160 |
+
|
161 |
+
$zipData = "\x50\x4b\x03\x04\x14\x00\x00\x00\x08\x00".
|
162 |
+
$mtime.
|
163 |
+
pack("VVVvv",
|
164 |
+
$crc32,
|
165 |
+
$complength,
|
166 |
+
$normlength,
|
167 |
+
strlen($filename),
|
168 |
+
0x00).
|
169 |
+
$filename.
|
170 |
+
$data;
|
171 |
+
|
172 |
+
$error = $this->innerWriter->writeData($zipData);
|
173 |
+
if (PEAR::isError($error)) {
|
174 |
+
return $error;
|
175 |
+
}
|
176 |
+
|
177 |
+
$this->central .= "\x50\x4b\x01\x02\x00\x00\x14\x00\x00\x00\x08\x00".
|
178 |
+
$mtime.
|
179 |
+
pack("VVVvvvvvVV",
|
180 |
+
$crc32, $complength, $normlength,
|
181 |
+
strlen($filename), 0x00,0x00,0x00,0x00,
|
182 |
+
0x0000,$this->offset).
|
183 |
+
$filename;
|
184 |
+
|
185 |
+
$this->offset += strlen($zipData);
|
186 |
+
}
|
187 |
+
|
188 |
+
function appendFile($filename, $dataFilename)
|
189 |
+
{
|
190 |
+
//Try to read from the cache
|
191 |
+
$cache = File_Archive::getOption('cache', null);
|
192 |
+
if ($cache !== null && $this->compressionLevel > 0) {
|
193 |
+
$id = realpath($dataFilename);
|
194 |
+
$id = urlencode($id);
|
195 |
+
$id = str_replace('_', '%5F', $id);
|
196 |
+
|
197 |
+
$group = 'FileArchiveZip'.$this->compressionLevel;
|
198 |
+
$mtime = filemtime($dataFilename);
|
199 |
+
|
200 |
+
//Tries to read from cache
|
201 |
+
if (($data = $cache->get($id, $group)) !== false) {
|
202 |
+
$info = unpack('Vmtime/Vcrc/Vnlength', substr($data, 0, 12));
|
203 |
+
$data = substr($data, 12);
|
204 |
+
}
|
205 |
+
|
206 |
+
//If cache failed or file modified since then
|
207 |
+
if ($data === false ||
|
208 |
+
$info['mtime'] != $mtime) {
|
209 |
+
|
210 |
+
$data = file_get_contents($dataFilename);
|
211 |
+
|
212 |
+
$info = array(
|
213 |
+
'crc' => crc32($data),
|
214 |
+
'nlength' => strlen($data),
|
215 |
+
'mtime' => $mtime
|
216 |
+
);
|
217 |
+
|
218 |
+
$data = gzcompress($data,$this->compressionLevel);
|
219 |
+
$data = substr($data,2,strlen($data)-6);
|
220 |
+
$data = pack('VVV', $info['mtime'], $info['crc'], $info['nlength']).$data;
|
221 |
+
$cache->save($data, $id, $group);
|
222 |
+
}
|
223 |
+
|
224 |
+
return $this->appendCompressedData(
|
225 |
+
$filename,
|
226 |
+
stat($dataFilename),
|
227 |
+
$data,
|
228 |
+
$info['crc'],
|
229 |
+
$info['nlength']
|
230 |
+
);
|
231 |
+
|
232 |
+
}
|
233 |
+
|
234 |
+
//If no cache system, use the standard way
|
235 |
+
return parent::appendFile($filename, $dataFilename);
|
236 |
+
}
|
237 |
+
|
238 |
+
/**
|
239 |
+
* @see File_Archive_Writer_MemoryArchive::sendFooter()
|
240 |
+
* @access protected
|
241 |
+
*/
|
242 |
+
function sendFooter()
|
243 |
+
{
|
244 |
+
return $this->innerWriter->writeData(
|
245 |
+
$this->central.
|
246 |
+
"\x50\x4b\x05\x06\x00\x00\x00\x00".
|
247 |
+
pack("vvVVv",
|
248 |
+
$this->nbFiles,$this->nbFiles,
|
249 |
+
strlen($this->central),$this->offset,
|
250 |
+
strlen($this->comment)).
|
251 |
+
$this->comment
|
252 |
+
);
|
253 |
+
}
|
254 |
+
/**
|
255 |
+
* @see File_Archive_Writer::getMime()
|
256 |
+
*/
|
257 |
+
function getMime() { return "application/zip"; }
|
258 |
+
}
|
259 |
+
|
260 |
+
?>
|
PEAR.php
ADDED
@@ -0,0 +1,1112 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
if (class_exists("pear")) {
|
4 |
+
return;
|
5 |
+
}
|
6 |
+
/**
|
7 |
+
* PEAR, the PHP Extension and Application Repository
|
8 |
+
*
|
9 |
+
* PEAR class and PEAR_Error class
|
10 |
+
*
|
11 |
+
* PHP versions 4 and 5
|
12 |
+
*
|
13 |
+
* LICENSE: This source file is subject to version 3.0 of the PHP license
|
14 |
+
* that is available through the world-wide-web at the following URI:
|
15 |
+
* http://www.php.net/license/3_0.txt. If you did not receive a copy of
|
16 |
+
* the PHP License and are unable to obtain it through the web, please
|
17 |
+
* send a note to license@php.net so we can mail you a copy immediately.
|
18 |
+
*
|
19 |
+
* @category pear
|
20 |
+
* @package PEAR
|
21 |
+
* @author Sterling Hughes <sterling@php.net>
|
22 |
+
* @author Stig Bakken <ssb@php.net>
|
23 |
+
* @author Tomas V.V.Cox <cox@idecnet.com>
|
24 |
+
* @author Greg Beaver <cellog@php.net>
|
25 |
+
* @copyright 1997-2006 The PHP Group
|
26 |
+
* @license http://www.php.net/license/3_0.txt PHP License 3.0
|
27 |
+
* @version CVS: $Id: PEAR.php,v 1.101 2006/04/25 02:41:03 cellog Exp $
|
28 |
+
* @link http://pear.php.net/package/PEAR
|
29 |
+
* @since File available since Release 0.1
|
30 |
+
*/
|
31 |
+
|
32 |
+
/**#@+
|
33 |
+
* ERROR constants
|
34 |
+
*/
|
35 |
+
define('PEAR_ERROR_RETURN', 1);
|
36 |
+
define('PEAR_ERROR_PRINT', 2);
|
37 |
+
define('PEAR_ERROR_TRIGGER', 4);
|
38 |
+
define('PEAR_ERROR_DIE', 8);
|
39 |
+
define('PEAR_ERROR_CALLBACK', 16);
|
40 |
+
/**
|
41 |
+
* WARNING: obsolete
|
42 |
+
* @deprecated
|
43 |
+
*/
|
44 |
+
define('PEAR_ERROR_EXCEPTION', 32);
|
45 |
+
/**#@-*/
|
46 |
+
define('PEAR_ZE2', (function_exists('version_compare') &&
|
47 |
+
version_compare(zend_version(), "2-dev", "ge")));
|
48 |
+
|
49 |
+
if (substr(PHP_OS, 0, 3) == 'WIN') {
|
50 |
+
define('OS_WINDOWS', true);
|
51 |
+
define('OS_UNIX', false);
|
52 |
+
define('PEAR_OS', 'Windows');
|
53 |
+
} else {
|
54 |
+
define('OS_WINDOWS', false);
|
55 |
+
define('OS_UNIX', true);
|
56 |
+
define('PEAR_OS', 'Unix'); // blatant assumption
|
57 |
+
}
|
58 |
+
|
59 |
+
// instant backwards compatibility
|
60 |
+
if (!defined('PATH_SEPARATOR')) {
|
61 |
+
if (OS_WINDOWS) {
|
62 |
+
define('PATH_SEPARATOR', ';');
|
63 |
+
} else {
|
64 |
+
define('PATH_SEPARATOR', ':');
|
65 |
+
}
|
66 |
+
}
|
67 |
+
|
68 |
+
$GLOBALS['_PEAR_default_error_mode'] = PEAR_ERROR_RETURN;
|
69 |
+
$GLOBALS['_PEAR_default_error_options'] = E_USER_NOTICE;
|
70 |
+
$GLOBALS['_PEAR_destructor_object_list'] = array();
|
71 |
+
$GLOBALS['_PEAR_shutdown_funcs'] = array();
|
72 |
+
$GLOBALS['_PEAR_error_handler_stack'] = array();
|
73 |
+
|
74 |
+
@ini_set('track_errors', true);
|
75 |
+
|
76 |
+
/**
|
77 |
+
* Base class for other PEAR classes. Provides rudimentary
|
78 |
+
* emulation of destructors.
|
79 |
+
*
|
80 |
+
* If you want a destructor in your class, inherit PEAR and make a
|
81 |
+
* destructor method called _yourclassname (same name as the
|
82 |
+
* constructor, but with a "_" prefix). Also, in your constructor you
|
83 |
+
* have to call the PEAR constructor: $this->PEAR();.
|
84 |
+
* The destructor method will be called without parameters. Note that
|
85 |
+
* at in some SAPI implementations (such as Apache), any output during
|
86 |
+
* the request shutdown (in which destructors are called) seems to be
|
87 |
+
* discarded. If you need to get any debug information from your
|
88 |
+
* destructor, use error_log(), syslog() or something similar.
|
89 |
+
*
|
90 |
+
* IMPORTANT! To use the emulated destructors you need to create the
|
91 |
+
* objects by reference: $obj =& new PEAR_child;
|
92 |
+
*
|
93 |
+
* @category pear
|
94 |
+
* @package PEAR
|
95 |
+
* @author Stig Bakken <ssb@php.net>
|
96 |
+
* @author Tomas V.V. Cox <cox@idecnet.com>
|
97 |
+
* @author Greg Beaver <cellog@php.net>
|
98 |
+
* @copyright 1997-2006 The PHP Group
|
99 |
+
* @license http://www.php.net/license/3_0.txt PHP License 3.0
|
100 |
+
* @version Release: 1.5.3
|
101 |
+
* @link http://pear.php.net/package/PEAR
|
102 |
+
* @see PEAR_Error
|
103 |
+
* @since Class available since PHP 4.0.2
|
104 |
+
* @link http://pear.php.net/manual/en/core.pear.php#core.pear.pear
|
105 |
+
*/
|
106 |
+
class PEAR
|
107 |
+
{
|
108 |
+
// {{{ properties
|
109 |
+
|
110 |
+
/**
|
111 |
+
* Whether to enable internal debug messages.
|
112 |
+
*
|
113 |
+
* @var bool
|
114 |
+
* @access private
|
115 |
+
*/
|
116 |
+
var $_debug = false;
|
117 |
+
|
118 |
+
/**
|
119 |
+
* Default error mode for this object.
|
120 |
+
*
|
121 |
+
* @var int
|
122 |
+
* @access private
|
123 |
+
*/
|
124 |
+
var $_default_error_mode = null;
|
125 |
+
|
126 |
+
/**
|
127 |
+
* Default error options used for this object when error mode
|
128 |
+
* is PEAR_ERROR_TRIGGER.
|
129 |
+
*
|
130 |
+
* @var int
|
131 |
+
* @access private
|
132 |
+
*/
|
133 |
+
var $_default_error_options = null;
|
134 |
+
|
135 |
+
/**
|
136 |
+
* Default error handler (callback) for this object, if error mode is
|
137 |
+
* PEAR_ERROR_CALLBACK.
|
138 |
+
*
|
139 |
+
* @var string
|
140 |
+
* @access private
|
141 |
+
*/
|
142 |
+
var $_default_error_handler = '';
|
143 |
+
|
144 |
+
/**
|
145 |
+
* Which class to use for error objects.
|
146 |
+
*
|
147 |
+
* @var string
|
148 |
+
* @access private
|
149 |
+
*/
|
150 |
+
var $_error_class = 'PEAR_Error';
|
151 |
+
|
152 |
+
/**
|
153 |
+
* An array of expected errors.
|
154 |
+
*
|
155 |
+
* @var array
|
156 |
+
* @access private
|
157 |
+
*/
|
158 |
+
var $_expected_errors = array();
|
159 |
+
|
160 |
+
// }}}
|
161 |
+
|
162 |
+
// {{{ constructor
|
163 |
+
|
164 |
+
/**
|
165 |
+
* Constructor. Registers this object in
|
166 |
+
* $_PEAR_destructor_object_list for destructor emulation if a
|
167 |
+
* destructor object exists.
|
168 |
+
*
|
169 |
+
* @param string $error_class (optional) which class to use for
|
170 |
+
* error objects, defaults to PEAR_Error.
|
171 |
+
* @access public
|
172 |
+
* @return void
|
173 |
+
*/
|
174 |
+
function PEAR($error_class = null)
|
175 |
+
{
|
176 |
+
$classname = strtolower(get_class($this));
|
177 |
+
if ($this->_debug) {
|
178 |
+
print "PEAR constructor called, class=$classname\n";
|
179 |
+
}
|
180 |
+
if ($error_class !== null) {
|
181 |
+
$this->_error_class = $error_class;
|
182 |
+
}
|
183 |
+
while ($classname && strcasecmp($classname, "pear")) {
|
184 |
+
$destructor = "_$classname";
|
185 |
+
if (method_exists($this, $destructor)) {
|
186 |
+
global $_PEAR_destructor_object_list;
|
187 |
+
$_PEAR_destructor_object_list[] = &$this;
|
188 |
+
if (!isset($GLOBALS['_PEAR_SHUTDOWN_REGISTERED'])) {
|
189 |
+
register_shutdown_function("_PEAR_call_destructors");
|
190 |
+
$GLOBALS['_PEAR_SHUTDOWN_REGISTERED'] = true;
|
191 |
+
}
|
192 |
+
break;
|
193 |
+
} else {
|
194 |
+
$classname = get_parent_class($classname);
|
195 |
+
}
|
196 |
+
}
|
197 |
+
}
|
198 |
+
|
199 |
+
// }}}
|
200 |
+
// {{{ destructor
|
201 |
+
|
202 |
+
/**
|
203 |
+
* Destructor (the emulated type of...). Does nothing right now,
|
204 |
+
* but is included for forward compatibility, so subclass
|
205 |
+
* destructors should always call it.
|
206 |
+
*
|
207 |
+
* See the note in the class desciption about output from
|
208 |
+
* destructors.
|
209 |
+
*
|
210 |
+
* @access public
|
211 |
+
* @return void
|
212 |
+
*/
|
213 |
+
function _PEAR() {
|
214 |
+
if ($this->_debug) {
|
215 |
+
printf("PEAR destructor called, class=%s\n", strtolower(get_class($this)));
|
216 |
+
}
|
217 |
+
}
|
218 |
+
|
219 |
+
// }}}
|
220 |
+
// {{{ getStaticProperty()
|
221 |
+
|
222 |
+
/**
|
223 |
+
* If you have a class that's mostly/entirely static, and you need static
|
224 |
+
* properties, you can use this method to simulate them. Eg. in your method(s)
|
225 |
+
* do this: $myVar = &PEAR::getStaticProperty('myclass', 'myVar');
|
226 |
+
* You MUST use a reference, or they will not persist!
|
227 |
+
*
|
228 |
+
* @access public
|
229 |
+
* @param string $class The calling classname, to prevent clashes
|
230 |
+
* @param string $var The variable to retrieve.
|
231 |
+
* @return mixed A reference to the variable. If not set it will be
|
232 |
+
* auto initialised to NULL.
|
233 |
+
*/
|
234 |
+
function &getStaticProperty($class, $var)
|
235 |
+
{
|
236 |
+
static $properties;
|
237 |
+
if (!isset($properties[$class])) {
|
238 |
+
$properties[$class] = array();
|
239 |
+
}
|
240 |
+
if (!array_key_exists($var, $properties[$class])) {
|
241 |
+
$properties[$class][$var] = null;
|
242 |
+
}
|
243 |
+
return $properties[$class][$var];
|
244 |
+
}
|
245 |
+
|
246 |
+
// }}}
|
247 |
+
// {{{ registerShutdownFunc()
|
248 |
+
|
249 |
+
/**
|
250 |
+
* Use this function to register a shutdown method for static
|
251 |
+
* classes.
|
252 |
+
*
|
253 |
+
* @access public
|
254 |
+
* @param mixed $func The function name (or array of class/method) to call
|
255 |
+
* @param mixed $args The arguments to pass to the function
|
256 |
+
* @return void
|
257 |
+
*/
|
258 |
+
function registerShutdownFunc($func, $args = array())
|
259 |
+
{
|
260 |
+
// if we are called statically, there is a potential
|
261 |
+
// that no shutdown func is registered. Bug #6445
|
262 |
+
if (!isset($GLOBALS['_PEAR_SHUTDOWN_REGISTERED'])) {
|
263 |
+
register_shutdown_function("_PEAR_call_destructors");
|
264 |
+
$GLOBALS['_PEAR_SHUTDOWN_REGISTERED'] = true;
|
265 |
+
}
|
266 |
+
$GLOBALS['_PEAR_shutdown_funcs'][] = array($func, $args);
|
267 |
+
}
|
268 |
+
|
269 |
+
// }}}
|
270 |
+
// {{{ isError()
|
271 |
+
|
272 |
+
/**
|
273 |
+
* Tell whether a value is a PEAR error.
|
274 |
+
*
|
275 |
+
* @param mixed $data the value to test
|
276 |
+
* @param int $code if $data is an error object, return true
|
277 |
+
* only if $code is a string and
|
278 |
+
* $obj->getMessage() == $code or
|
279 |
+
* $code is an integer and $obj->getCode() == $code
|
280 |
+
* @access public
|
281 |
+
* @return bool true if parameter is an error
|
282 |
+
*/
|
283 |
+
function isError($data, $code = null)
|
284 |
+
{
|
285 |
+
if (is_a($data, 'PEAR_Error')) {
|
286 |
+
if (is_null($code)) {
|
287 |
+
return true;
|
288 |
+
} elseif (is_string($code)) {
|
289 |
+
return $data->getMessage() == $code;
|
290 |
+
} else {
|
291 |
+
return $data->getCode() == $code;
|
292 |
+
}
|
293 |
+
}
|
294 |
+
return false;
|
295 |
+
}
|
296 |
+
|
297 |
+
// }}}
|
298 |
+
// {{{ setErrorHandling()
|
299 |
+
|
300 |
+
/**
|
301 |
+
* Sets how errors generated by this object should be handled.
|
302 |
+
* Can be invoked both in objects and statically. If called
|
303 |
+
* statically, setErrorHandling sets the default behaviour for all
|
304 |
+
* PEAR objects. If called in an object, setErrorHandling sets
|
305 |
+
* the default behaviour for that object.
|
306 |
+
*
|
307 |
+
* @param int $mode
|
308 |
+
* One of PEAR_ERROR_RETURN, PEAR_ERROR_PRINT,
|
309 |
+
* PEAR_ERROR_TRIGGER, PEAR_ERROR_DIE,
|
310 |
+
* PEAR_ERROR_CALLBACK or PEAR_ERROR_EXCEPTION.
|
311 |
+
*
|
312 |
+
* @param mixed $options
|
313 |
+
* When $mode is PEAR_ERROR_TRIGGER, this is the error level (one
|
314 |
+
* of E_USER_NOTICE, E_USER_WARNING or E_USER_ERROR).
|
315 |
+
*
|
316 |
+
* When $mode is PEAR_ERROR_CALLBACK, this parameter is expected
|
317 |
+
* to be the callback function or method. A callback
|
318 |
+
* function is a string with the name of the function, a
|
319 |
+
* callback method is an array of two elements: the element
|
320 |
+
* at index 0 is the object, and the element at index 1 is
|
321 |
+
* the name of the method to call in the object.
|
322 |
+
*
|
323 |
+
* When $mode is PEAR_ERROR_PRINT or PEAR_ERROR_DIE, this is
|
324 |
+
* a printf format string used when printing the error
|
325 |
+
* message.
|
326 |
+
*
|
327 |
+
* @access public
|
328 |
+
* @return void
|
329 |
+
* @see PEAR_ERROR_RETURN
|
330 |
+
* @see PEAR_ERROR_PRINT
|
331 |
+
* @see PEAR_ERROR_TRIGGER
|
332 |
+
* @see PEAR_ERROR_DIE
|
333 |
+
* @see PEAR_ERROR_CALLBACK
|
334 |
+
* @see PEAR_ERROR_EXCEPTION
|
335 |
+
*
|
336 |
+
* @since PHP 4.0.5
|
337 |
+
*/
|
338 |
+
|
339 |
+
function setErrorHandling($mode = null, $options = null)
|
340 |
+
{
|
341 |
+
if (isset($this) && is_a($this, 'PEAR')) {
|
342 |
+
$setmode = &$this->_default_error_mode;
|
343 |
+
$setoptions = &$this->_default_error_options;
|
344 |
+
} else {
|
345 |
+
$setmode = &$GLOBALS['_PEAR_default_error_mode'];
|
346 |
+
$setoptions = &$GLOBALS['_PEAR_default_error_options'];
|
347 |
+
}
|
348 |
+
|
349 |
+
switch ($mode) {
|
350 |
+
case PEAR_ERROR_EXCEPTION:
|
351 |
+
case PEAR_ERROR_RETURN:
|
352 |
+
case PEAR_ERROR_PRINT:
|
353 |
+
case PEAR_ERROR_TRIGGER:
|
354 |
+
case PEAR_ERROR_DIE:
|
355 |
+
case null:
|
356 |
+
$setmode = $mode;
|
357 |
+
$setoptions = $options;
|
358 |
+
break;
|
359 |
+
|
360 |
+
case PEAR_ERROR_CALLBACK:
|
361 |
+
$setmode = $mode;
|
362 |
+
// class/object method callback
|
363 |
+
if (is_callable($options)) {
|
364 |
+
$setoptions = $options;
|
365 |
+
} else {
|
366 |
+
trigger_error("invalid error callback", E_USER_WARNING);
|
367 |
+
}
|
368 |
+
break;
|
369 |
+
|
370 |
+
default:
|
371 |
+
trigger_error("invalid error mode", E_USER_WARNING);
|
372 |
+
break;
|
373 |
+
}
|
374 |
+
}
|
375 |
+
|
376 |
+
// }}}
|
377 |
+
// {{{ expectError()
|
378 |
+
|
379 |
+
/**
|
380 |
+
* This method is used to tell which errors you expect to get.
|
381 |
+
* Expected errors are always returned with error mode
|
382 |
+
* PEAR_ERROR_RETURN. Expected error codes are stored in a stack,
|
383 |
+
* and this method pushes a new element onto it. The list of
|
384 |
+
* expected errors are in effect until they are popped off the
|
385 |
+
* stack with the popExpect() method.
|
386 |
+
*
|
387 |
+
* Note that this method can not be called statically
|
388 |
+
*
|
389 |
+
* @param mixed $code a single error code or an array of error codes to expect
|
390 |
+
*
|
391 |
+
* @return int the new depth of the "expected errors" stack
|
392 |
+
* @access public
|
393 |
+
*/
|
394 |
+
function expectError($code = '*')
|
395 |
+
{
|
396 |
+
if (is_array($code)) {
|
397 |
+
array_push($this->_expected_errors, $code);
|
398 |
+
} else {
|
399 |
+
array_push($this->_expected_errors, array($code));
|
400 |
+
}
|
401 |
+
return sizeof($this->_expected_errors);
|
402 |
+
}
|
403 |
+
|
404 |
+
// }}}
|
405 |
+
// {{{ popExpect()
|
406 |
+
|
407 |
+
/**
|
408 |
+
* This method pops one element off the expected error codes
|
409 |
+
* stack.
|
410 |
+
*
|
411 |
+
* @return array the list of error codes that were popped
|
412 |
+
*/
|
413 |
+
function popExpect()
|
414 |
+
{
|
415 |
+
return array_pop($this->_expected_errors);
|
416 |
+
}
|
417 |
+
|
418 |
+
// }}}
|
419 |
+
// {{{ _checkDelExpect()
|
420 |
+
|
421 |
+
/**
|
422 |
+
* This method checks unsets an error code if available
|
423 |
+
*
|
424 |
+
* @param mixed error code
|
425 |
+
* @return bool true if the error code was unset, false otherwise
|
426 |
+
* @access private
|
427 |
+
* @since PHP 4.3.0
|
428 |
+
*/
|
429 |
+
function _checkDelExpect($error_code)
|
430 |
+
{
|
431 |
+
$deleted = false;
|
432 |
+
|
433 |
+
foreach ($this->_expected_errors AS $key => $error_array) {
|
434 |
+
if (in_array($error_code, $error_array)) {
|
435 |
+
unset($this->_expected_errors[$key][array_search($error_code, $error_array)]);
|
436 |
+
$deleted = true;
|
437 |
+
}
|
438 |
+
|
439 |
+
// clean up empty arrays
|
440 |
+
if (0 == count($this->_expected_errors[$key])) {
|
441 |
+
unset($this->_expected_errors[$key]);
|
442 |
+
}
|
443 |
+
}
|
444 |
+
return $deleted;
|
445 |
+
}
|
446 |
+
|
447 |
+
// }}}
|
448 |
+
// {{{ delExpect()
|
449 |
+
|
450 |
+
/**
|
451 |
+
* This method deletes all occurences of the specified element from
|
452 |
+
* the expected error codes stack.
|
453 |
+
*
|
454 |
+
* @param mixed $error_code error code that should be deleted
|
455 |
+
* @return mixed list of error codes that were deleted or error
|
456 |
+
* @access public
|
457 |
+
* @since PHP 4.3.0
|
458 |
+
*/
|
459 |
+
function delExpect($error_code)
|
460 |
+
{
|
461 |
+
$deleted = false;
|
462 |
+
|
463 |
+
if ((is_array($error_code) && (0 != count($error_code)))) {
|
464 |
+
// $error_code is a non-empty array here;
|
465 |
+
// we walk through it trying to unset all
|
466 |
+
// values
|
467 |
+
foreach($error_code as $key => $error) {
|
468 |
+
if ($this->_checkDelExpect($error)) {
|
469 |
+
$deleted = true;
|
470 |
+
} else {
|
471 |
+
$deleted = false;
|
472 |
+
}
|
473 |
+
}
|
474 |
+
return $deleted ? true : PEAR::raiseError("The expected error you submitted does not exist"); // IMPROVE ME
|
475 |
+
} elseif (!empty($error_code)) {
|
476 |
+
// $error_code comes alone, trying to unset it
|
477 |
+
if ($this->_checkDelExpect($error_code)) {
|
478 |
+
return true;
|
479 |
+
} else {
|
480 |
+
return PEAR::raiseError("The expected error you submitted does not exist"); // IMPROVE ME
|
481 |
+
}
|
482 |
+
} else {
|
483 |
+
// $error_code is empty
|
484 |
+
return PEAR::raiseError("The expected error you submitted is empty"); // IMPROVE ME
|
485 |
+
}
|
486 |
+
}
|
487 |
+
|
488 |
+
// }}}
|
489 |
+
// {{{ raiseError()
|
490 |
+
|
491 |
+
/**
|
492 |
+
* This method is a wrapper that returns an instance of the
|
493 |
+
* configured error class with this object's default error
|
494 |
+
* handling applied. If the $mode and $options parameters are not
|
495 |
+
* specified, the object's defaults are used.
|
496 |
+
*
|
497 |
+
* @param mixed $message a text error message or a PEAR error object
|
498 |
+
*
|
499 |
+
* @param int $code a numeric error code (it is up to your class
|
500 |
+
* to define these if you want to use codes)
|
501 |
+
*
|
502 |
+
* @param int $mode One of PEAR_ERROR_RETURN, PEAR_ERROR_PRINT,
|
503 |
+
* PEAR_ERROR_TRIGGER, PEAR_ERROR_DIE,
|
504 |
+
* PEAR_ERROR_CALLBACK, PEAR_ERROR_EXCEPTION.
|
505 |
+
*
|
506 |
+
* @param mixed $options If $mode is PEAR_ERROR_TRIGGER, this parameter
|
507 |
+
* specifies the PHP-internal error level (one of
|
508 |
+
* E_USER_NOTICE, E_USER_WARNING or E_USER_ERROR).
|
509 |
+
* If $mode is PEAR_ERROR_CALLBACK, this
|
510 |
+
* parameter specifies the callback function or
|
511 |
+
* method. In other error modes this parameter
|
512 |
+
* is ignored.
|
513 |
+
*
|
514 |
+
* @param string $userinfo If you need to pass along for example debug
|
515 |
+
* information, this parameter is meant for that.
|
516 |
+
*
|
517 |
+
* @param string $error_class The returned error object will be
|
518 |
+
* instantiated from this class, if specified.
|
519 |
+
*
|
520 |
+
* @param bool $skipmsg If true, raiseError will only pass error codes,
|
521 |
+
* the error message parameter will be dropped.
|
522 |
+
*
|
523 |
+
* @access public
|
524 |
+
* @return object a PEAR error object
|
525 |
+
* @see PEAR::setErrorHandling
|
526 |
+
* @since PHP 4.0.5
|
527 |
+
*/
|
528 |
+
function &raiseError($message = null,
|
529 |
+
$code = null,
|
530 |
+
$mode = null,
|
531 |
+
$options = null,
|
532 |
+
$userinfo = null,
|
533 |
+
$error_class = null,
|
534 |
+
$skipmsg = false)
|
535 |
+
{
|
536 |
+
// The error is yet a PEAR error object
|
537 |
+
if (is_object($message)) {
|
538 |
+
$code = $message->getCode();
|
539 |
+
$userinfo = $message->getUserInfo();
|
540 |
+
$error_class = $message->getType();
|
541 |
+
$message->error_message_prefix = '';
|
542 |
+
$message = $message->getMessage();
|
543 |
+
}
|
544 |
+
|
545 |
+
if (isset($this) && isset($this->_expected_errors) && sizeof($this->_expected_errors) > 0 && sizeof($exp = end($this->_expected_errors))) {
|
546 |
+
if ($exp[0] == "*" ||
|
547 |
+
(is_int(reset($exp)) && in_array($code, $exp)) ||
|
548 |
+
(is_string(reset($exp)) && in_array($message, $exp))) {
|
549 |
+
$mode = PEAR_ERROR_RETURN;
|
550 |
+
}
|
551 |
+
}
|
552 |
+
// No mode given, try global ones
|
553 |
+
if ($mode === null) {
|
554 |
+
// Class error handler
|
555 |
+
if (isset($this) && isset($this->_default_error_mode)) {
|
556 |
+
$mode = $this->_default_error_mode;
|
557 |
+
$options = $this->_default_error_options;
|
558 |
+
// Global error handler
|
559 |
+
} elseif (isset($GLOBALS['_PEAR_default_error_mode'])) {
|
560 |
+
$mode = $GLOBALS['_PEAR_default_error_mode'];
|
561 |
+
$options = $GLOBALS['_PEAR_default_error_options'];
|
562 |
+
}
|
563 |
+
}
|
564 |
+
|
565 |
+
if ($error_class !== null) {
|
566 |
+
$ec = $error_class;
|
567 |
+
} elseif (isset($this) && isset($this->_error_class)) {
|
568 |
+
$ec = $this->_error_class;
|
569 |
+
} else {
|
570 |
+
$ec = 'PEAR_Error';
|
571 |
+
}
|
572 |
+
if ($skipmsg) {
|
573 |
+
$a = &new $ec($code, $mode, $options, $userinfo);
|
574 |
+
return $a;
|
575 |
+
} else {
|
576 |
+
$a = &new $ec($message, $code, $mode, $options, $userinfo);
|
577 |
+
return $a;
|
578 |
+
}
|
579 |
+
}
|
580 |
+
|
581 |
+
// }}}
|
582 |
+
// {{{ throwError()
|
583 |
+
|
584 |
+
/**
|
585 |
+
* Simpler form of raiseError with fewer options. In most cases
|
586 |
+
* message, code and userinfo are enough.
|
587 |
+
*
|
588 |
+
* @param string $message
|
589 |
+
*
|
590 |
+
*/
|
591 |
+
function &throwError($message = null,
|
592 |
+
$code = null,
|
593 |
+
$userinfo = null)
|
594 |
+
{
|
595 |
+
if (isset($this) && is_a($this, 'PEAR')) {
|
596 |
+
$a = &$this->raiseError($message, $code, null, null, $userinfo);
|
597 |
+
return $a;
|
598 |
+
} else {
|
599 |
+
$a = &PEAR::raiseError($message, $code, null, null, $userinfo);
|
600 |
+
return $a;
|
601 |
+
}
|
602 |
+
}
|
603 |
+
|
604 |
+
// }}}
|
605 |
+
function staticPushErrorHandling($mode, $options = null)
|
606 |
+
{
|
607 |
+
$stack = &$GLOBALS['_PEAR_error_handler_stack'];
|
608 |
+
$def_mode = &$GLOBALS['_PEAR_default_error_mode'];
|
609 |
+
$def_options = &$GLOBALS['_PEAR_default_error_options'];
|
610 |
+
$stack[] = array($def_mode, $def_options);
|
611 |
+
switch ($mode) {
|
612 |
+
case PEAR_ERROR_EXCEPTION:
|
613 |
+
case PEAR_ERROR_RETURN:
|
614 |
+
case PEAR_ERROR_PRINT:
|
615 |
+
case PEAR_ERROR_TRIGGER:
|
616 |
+
case PEAR_ERROR_DIE:
|
617 |
+
case null:
|
618 |
+
$def_mode = $mode;
|
619 |
+
$def_options = $options;
|
620 |
+
break;
|
621 |
+
|
622 |
+
case PEAR_ERROR_CALLBACK:
|
623 |
+
$def_mode = $mode;
|
624 |
+
// class/object method callback
|
625 |
+
if (is_callable($options)) {
|
626 |
+
$def_options = $options;
|
627 |
+
} else {
|
628 |
+
trigger_error("invalid error callback", E_USER_WARNING);
|
629 |
+
}
|
630 |
+
break;
|
631 |
+
|
632 |
+
default:
|
633 |
+
trigger_error("invalid error mode", E_USER_WARNING);
|
634 |
+
break;
|
635 |
+
}
|
636 |
+
$stack[] = array($mode, $options);
|
637 |
+
return true;
|
638 |
+
}
|
639 |
+
|
640 |
+
function staticPopErrorHandling()
|
641 |
+
{
|
642 |
+
$stack = &$GLOBALS['_PEAR_error_handler_stack'];
|
643 |
+
$setmode = &$GLOBALS['_PEAR_default_error_mode'];
|
644 |
+
$setoptions = &$GLOBALS['_PEAR_default_error_options'];
|
645 |
+
array_pop($stack);
|
646 |
+
list($mode, $options) = $stack[sizeof($stack) - 1];
|
647 |
+
array_pop($stack);
|
648 |
+
switch ($mode) {
|
649 |
+
case PEAR_ERROR_EXCEPTION:
|
650 |
+
case PEAR_ERROR_RETURN:
|
651 |
+
case PEAR_ERROR_PRINT:
|
652 |
+
case PEAR_ERROR_TRIGGER:
|
653 |
+
case PEAR_ERROR_DIE:
|
654 |
+
case null:
|
655 |
+
$setmode = $mode;
|
656 |
+
$setoptions = $options;
|
657 |
+
break;
|
658 |
+
|
659 |
+
case PEAR_ERROR_CALLBACK:
|
660 |
+
$setmode = $mode;
|
661 |
+
// class/object method callback
|
662 |
+
if (is_callable($options)) {
|
663 |
+
$setoptions = $options;
|
664 |
+
} else {
|
665 |
+
trigger_error("invalid error callback", E_USER_WARNING);
|
666 |
+
}
|
667 |
+
break;
|
668 |
+
|
669 |
+
default:
|
670 |
+
trigger_error("invalid error mode", E_USER_WARNING);
|
671 |
+
break;
|
672 |
+
}
|
673 |
+
return true;
|
674 |
+
}
|
675 |
+
|
676 |
+
// {{{ pushErrorHandling()
|
677 |
+
|
678 |
+
/**
|
679 |
+
* Push a new error handler on top of the error handler options stack. With this
|
680 |
+
* you can easily override the actual error handler for some code and restore
|
681 |
+
* it later with popErrorHandling.
|
682 |
+
*
|
683 |
+
* @param mixed $mode (same as setErrorHandling)
|
684 |
+
* @param mixed $options (same as setErrorHandling)
|
685 |
+
*
|
686 |
+
* @return bool Always true
|
687 |
+
*
|
688 |
+
* @see PEAR::setErrorHandling
|
689 |
+
*/
|
690 |
+
function pushErrorHandling($mode, $options = null)
|
691 |
+
{
|
692 |
+
$stack = &$GLOBALS['_PEAR_error_handler_stack'];
|
693 |
+
if (isset($this) && is_a($this, 'PEAR')) {
|
694 |
+
$def_mode = &$this->_default_error_mode;
|
695 |
+
$def_options = &$this->_default_error_options;
|
696 |
+
} else {
|
697 |
+
$def_mode = &$GLOBALS['_PEAR_default_error_mode'];
|
698 |
+
$def_options = &$GLOBALS['_PEAR_default_error_options'];
|
699 |
+
}
|
700 |
+
$stack[] = array($def_mode, $def_options);
|
701 |
+
|
702 |
+
if (isset($this) && is_a($this, 'PEAR')) {
|
703 |
+
$this->setErrorHandling($mode, $options);
|
704 |
+
} else {
|
705 |
+
PEAR::setErrorHandling($mode, $options);
|
706 |
+
}
|
707 |
+
$stack[] = array($mode, $options);
|
708 |
+
return true;
|
709 |
+
}
|
710 |
+
|
711 |
+
// }}}
|
712 |
+
// {{{ popErrorHandling()
|
713 |
+
|
714 |
+
/**
|
715 |
+
* Pop the last error handler used
|
716 |
+
*
|
717 |
+
* @return bool Always true
|
718 |
+
*
|
719 |
+
* @see PEAR::pushErrorHandling
|
720 |
+
*/
|
721 |
+
function popErrorHandling()
|
722 |
+
{
|
723 |
+
$stack = &$GLOBALS['_PEAR_error_handler_stack'];
|
724 |
+
array_pop($stack);
|
725 |
+
list($mode, $options) = $stack[sizeof($stack) - 1];
|
726 |
+
array_pop($stack);
|
727 |
+
if (isset($this) && is_a($this, 'PEAR')) {
|
728 |
+
$this->setErrorHandling($mode, $options);
|
729 |
+
} else {
|
730 |
+
PEAR::setErrorHandling($mode, $options);
|
731 |
+
}
|
732 |
+
return true;
|
733 |
+
}
|
734 |
+
|
735 |
+
// }}}
|
736 |
+
// {{{ loadExtension()
|
737 |
+
|
738 |
+
/**
|
739 |
+
* OS independant PHP extension load. Remember to take care
|
740 |
+
* on the correct extension name for case sensitive OSes.
|
741 |
+
*
|
742 |
+
* @param string $ext The extension name
|
743 |
+
* @return bool Success or not on the dl() call
|
744 |
+
*/
|
745 |
+
function loadExtension($ext)
|
746 |
+
{
|
747 |
+
if (!extension_loaded($ext)) {
|
748 |
+
// if either returns true dl() will produce a FATAL error, stop that
|
749 |
+
if ((ini_get('enable_dl') != 1) || (ini_get('safe_mode') == 1)) {
|
750 |
+
return false;
|
751 |
+
}
|
752 |
+
if (OS_WINDOWS) {
|
753 |
+
$suffix = '.dll';
|
754 |
+
} elseif (PHP_OS == 'HP-UX') {
|
755 |
+
$suffix = '.sl';
|
756 |
+
} elseif (PHP_OS == 'AIX') {
|
757 |
+
$suffix = '.a';
|
758 |
+
} elseif (PHP_OS == 'OSX') {
|
759 |
+
$suffix = '.bundle';
|
760 |
+
} else {
|
761 |
+
$suffix = '.so';
|
762 |
+
}
|
763 |
+
return @dl('php_'.$ext.$suffix) || @dl($ext.$suffix);
|
764 |
+
}
|
765 |
+
return true;
|
766 |
+
}
|
767 |
+
|
768 |
+
// }}}
|
769 |
+
}
|
770 |
+
|
771 |
+
// {{{ _PEAR_call_destructors()
|
772 |
+
|
773 |
+
function _PEAR_call_destructors()
|
774 |
+
{
|
775 |
+
global $_PEAR_destructor_object_list;
|
776 |
+
if (is_array($_PEAR_destructor_object_list) &&
|
777 |
+
sizeof($_PEAR_destructor_object_list))
|
778 |
+
{
|
779 |
+
reset($_PEAR_destructor_object_list);
|
780 |
+
if (PEAR::getStaticProperty('PEAR', 'destructlifo')) {
|
781 |
+
$_PEAR_destructor_object_list = array_reverse($_PEAR_destructor_object_list);
|
782 |
+
}
|
783 |
+
while (list($k, $objref) = each($_PEAR_destructor_object_list)) {
|
784 |
+
$classname = get_class($objref);
|
785 |
+
while ($classname) {
|
786 |
+
$destructor = "_$classname";
|
787 |
+
if (method_exists($objref, $destructor)) {
|
788 |
+
$objref->$destructor();
|
789 |
+
break;
|
790 |
+
} else {
|
791 |
+
$classname = get_parent_class($classname);
|
792 |
+
}
|
793 |
+
}
|
794 |
+
}
|
795 |
+
// Empty the object list to ensure that destructors are
|
796 |
+
// not called more than once.
|
797 |
+
$_PEAR_destructor_object_list = array();
|
798 |
+
}
|
799 |
+
|
800 |
+
// Now call the shutdown functions
|
801 |
+
if (is_array($GLOBALS['_PEAR_shutdown_funcs']) AND !empty($GLOBALS['_PEAR_shutdown_funcs'])) {
|
802 |
+
foreach ($GLOBALS['_PEAR_shutdown_funcs'] as $value) {
|
803 |
+
call_user_func_array($value[0], $value[1]);
|
804 |
+
}
|
805 |
+
}
|
806 |
+
}
|
807 |
+
|
808 |
+
// }}}
|
809 |
+
/**
|
810 |
+
* Standard PEAR error class for PHP 4
|
811 |
+
*
|
812 |
+
* This class is supserseded by {@link PEAR_Exception} in PHP 5
|
813 |
+
*
|
814 |
+
* @category pear
|
815 |
+
* @package PEAR
|
816 |
+
* @author Stig Bakken <ssb@php.net>
|
817 |
+
* @author Tomas V.V. Cox <cox@idecnet.com>
|
818 |
+
* @author Gregory Beaver <cellog@php.net>
|
819 |
+
* @copyright 1997-2006 The PHP Group
|
820 |
+
* @license http://www.php.net/license/3_0.txt PHP License 3.0
|
821 |
+
* @version Release: 1.5.3
|
822 |
+
* @link http://pear.php.net/manual/en/core.pear.pear-error.php
|
823 |
+
* @see PEAR::raiseError(), PEAR::throwError()
|
824 |
+
* @since Class available since PHP 4.0.2
|
825 |
+
*/
|
826 |
+
class PEAR_Error
|
827 |
+
{
|
828 |
+
// {{{ properties
|
829 |
+
|
830 |
+
var $error_message_prefix = '';
|
831 |
+
var $mode = PEAR_ERROR_RETURN;
|
832 |
+
var $level = E_USER_NOTICE;
|
833 |
+
var $code = -1;
|
834 |
+
var $message = '';
|
835 |
+
var $userinfo = '';
|
836 |
+
var $backtrace = null;
|
837 |
+
|
838 |
+
// }}}
|
839 |
+
// {{{ constructor
|
840 |
+
|
841 |
+
/**
|
842 |
+
* PEAR_Error constructor
|
843 |
+
*
|
844 |
+
* @param string $message message
|
845 |
+
*
|
846 |
+
* @param int $code (optional) error code
|
847 |
+
*
|
848 |
+
* @param int $mode (optional) error mode, one of: PEAR_ERROR_RETURN,
|
849 |
+
* PEAR_ERROR_PRINT, PEAR_ERROR_DIE, PEAR_ERROR_TRIGGER,
|
850 |
+
* PEAR_ERROR_CALLBACK or PEAR_ERROR_EXCEPTION
|
851 |
+
*
|
852 |
+
* @param mixed $options (optional) error level, _OR_ in the case of
|
853 |
+
* PEAR_ERROR_CALLBACK, the callback function or object/method
|
854 |
+
* tuple.
|
855 |
+
*
|
856 |
+
* @param string $userinfo (optional) additional user/debug info
|
857 |
+
*
|
858 |
+
* @access public
|
859 |
+
*
|
860 |
+
*/
|
861 |
+
function PEAR_Error($message = 'unknown error', $code = null,
|
862 |
+
$mode = null, $options = null, $userinfo = null)
|
863 |
+
{
|
864 |
+
if ($mode === null) {
|
865 |
+
$mode = PEAR_ERROR_RETURN;
|
866 |
+
}
|
867 |
+
$this->message = $message;
|
868 |
+
$this->code = $code;
|
869 |
+
$this->mode = $mode;
|
870 |
+
$this->userinfo = $userinfo;
|
871 |
+
if (!PEAR::getStaticProperty('PEAR_Error', 'skiptrace')) {
|
872 |
+
$this->backtrace = debug_backtrace();
|
873 |
+
if (isset($this->backtrace[0]) && isset($this->backtrace[0]['object'])) {
|
874 |
+
unset($this->backtrace[0]['object']);
|
875 |
+
}
|
876 |
+
}
|
877 |
+
if ($mode & PEAR_ERROR_CALLBACK) {
|
878 |
+
$this->level = E_USER_NOTICE;
|
879 |
+
$this->callback = $options;
|
880 |
+
} else {
|
881 |
+
if ($options === null) {
|
882 |
+
$options = E_USER_NOTICE;
|
883 |
+
}
|
884 |
+
$this->level = $options;
|
885 |
+
$this->callback = null;
|
886 |
+
}
|
887 |
+
if ($this->mode & PEAR_ERROR_PRINT) {
|
888 |
+
if (is_null($options) || is_int($options)) {
|
889 |
+
$format = "%s";
|
890 |
+
} else {
|
891 |
+
$format = $options;
|
892 |
+
}
|
893 |
+
printf($format, $this->getMessage());
|
894 |
+
}
|
895 |
+
if ($this->mode & PEAR_ERROR_TRIGGER) {
|
896 |
+
trigger_error($this->getMessage(), $this->level);
|
897 |
+
}
|
898 |
+
if ($this->mode & PEAR_ERROR_DIE) {
|
899 |
+
$msg = $this->getMessage();
|
900 |
+
if (is_null($options) || is_int($options)) {
|
901 |
+
$format = "%s";
|
902 |
+
if (substr($msg, -1) != "\n") {
|
903 |
+
$msg .= "\n";
|
904 |
+
}
|
905 |
+
} else {
|
906 |
+
$format = $options;
|
907 |
+
}
|
908 |
+
die(sprintf($format, $msg));
|
909 |
+
}
|
910 |
+
if ($this->mode & PEAR_ERROR_CALLBACK) {
|
911 |
+
if (is_callable($this->callback)) {
|
912 |
+
call_user_func($this->callback, $this);
|
913 |
+
}
|
914 |
+
}
|
915 |
+
if ($this->mode & PEAR_ERROR_EXCEPTION) {
|
916 |
+
trigger_error("PEAR_ERROR_EXCEPTION is obsolete, use class PEAR_Exception for exceptions", E_USER_WARNING);
|
917 |
+
eval('$e = new Exception($this->message, $this->code);throw($e);');
|
918 |
+
}
|
919 |
+
}
|
920 |
+
|
921 |
+
// }}}
|
922 |
+
// {{{ getMode()
|
923 |
+
|
924 |
+
/**
|
925 |
+
* Get the error mode from an error object.
|
926 |
+
*
|
927 |
+
* @return int error mode
|
928 |
+
* @access public
|
929 |
+
*/
|
930 |
+
function getMode() {
|
931 |
+
return $this->mode;
|
932 |
+
}
|
933 |
+
|
934 |
+
// }}}
|
935 |
+
// {{{ getCallback()
|
936 |
+
|
937 |
+
/**
|
938 |
+
* Get the callback function/method from an error object.
|
939 |
+
*
|
940 |
+
* @return mixed callback function or object/method array
|
941 |
+
* @access public
|
942 |
+
*/
|
943 |
+
function getCallback() {
|
944 |
+
return $this->callback;
|
945 |
+
}
|
946 |
+
|
947 |
+
// }}}
|
948 |
+
// {{{ getMessage()
|
949 |
+
|
950 |
+
|
951 |
+
/**
|
952 |
+
* Get the error message from an error object.
|
953 |
+
*
|
954 |
+
* @return string full error message
|
955 |
+
* @access public
|
956 |
+
*/
|
957 |
+
function getMessage()
|
958 |
+
{
|
959 |
+
return ($this->error_message_prefix . $this->message);
|
960 |
+
}
|
961 |
+
|
962 |
+
|
963 |
+
// }}}
|
964 |
+
// {{{ getCode()
|
965 |
+
|
966 |
+
/**
|
967 |
+
* Get error code from an error object
|
968 |
+
*
|
969 |
+
* @return int error code
|
970 |
+
* @access public
|
971 |
+
*/
|
972 |
+
function getCode()
|
973 |
+
{
|
974 |
+
return $this->code;
|
975 |
+
}
|
976 |
+
|
977 |
+
// }}}
|
978 |
+
// {{{ getType()
|
979 |
+
|
980 |
+
/**
|
981 |
+
* Get the name of this error/exception.
|
982 |
+
*
|
983 |
+
* @return string error/exception name (type)
|
984 |
+
* @access public
|
985 |
+
*/
|
986 |
+
function getType()
|
987 |
+
{
|
988 |
+
return get_class($this);
|
989 |
+
}
|
990 |
+
|
991 |
+
// }}}
|
992 |
+
// {{{ getUserInfo()
|
993 |
+
|
994 |
+
/**
|
995 |
+
* Get additional user-supplied information.
|
996 |
+
*
|
997 |
+
* @return string user-supplied information
|
998 |
+
* @access public
|
999 |
+
*/
|
1000 |
+
function getUserInfo()
|
1001 |
+
{
|
1002 |
+
return $this->userinfo;
|
1003 |
+
}
|
1004 |
+
|
1005 |
+
// }}}
|
1006 |
+
// {{{ getDebugInfo()
|
1007 |
+
|
1008 |
+
/**
|
1009 |
+
* Get additional debug information supplied by the application.
|
1010 |
+
*
|
1011 |
+
* @return string debug information
|
1012 |
+
* @access public
|
1013 |
+
*/
|
1014 |
+
function getDebugInfo()
|
1015 |
+
{
|
1016 |
+
return $this->getUserInfo();
|
1017 |
+
}
|
1018 |
+
|
1019 |
+
// }}}
|
1020 |
+
// {{{ getBacktrace()
|
1021 |
+
|
1022 |
+
/**
|
1023 |
+
* Get the call backtrace from where the error was generated.
|
1024 |
+
* Supported with PHP 4.3.0 or newer.
|
1025 |
+
*
|
1026 |
+
* @param int $frame (optional) what frame to fetch
|
1027 |
+
* @return array Backtrace, or NULL if not available.
|
1028 |
+
* @access public
|
1029 |
+
*/
|
1030 |
+
function getBacktrace($frame = null)
|
1031 |
+
{
|
1032 |
+
if (defined('PEAR_IGNORE_BACKTRACE')) {
|
1033 |
+
return null;
|
1034 |
+
}
|
1035 |
+
if ($frame === null) {
|
1036 |
+
return $this->backtrace;
|
1037 |
+
}
|
1038 |
+
return $this->backtrace[$frame];
|
1039 |
+
}
|
1040 |
+
|
1041 |
+
// }}}
|
1042 |
+
// {{{ addUserInfo()
|
1043 |
+
|
1044 |
+
function addUserInfo($info)
|
1045 |
+
{
|
1046 |
+
if (empty($this->userinfo)) {
|
1047 |
+
$this->userinfo = $info;
|
1048 |
+
} else {
|
1049 |
+
$this->userinfo .= " ** $info";
|
1050 |
+
}
|
1051 |
+
}
|
1052 |
+
|
1053 |
+
// }}}
|
1054 |
+
// {{{ toString()
|
1055 |
+
|
1056 |
+
/**
|
1057 |
+
* Make a string representation of this object.
|
1058 |
+
*
|
1059 |
+
* @return string a string with an object summary
|
1060 |
+
* @access public
|
1061 |
+
*/
|
1062 |
+
function toString() {
|
1063 |
+
$modes = array();
|
1064 |
+
$levels = array(E_USER_NOTICE => 'notice',
|
1065 |
+
E_USER_WARNING => 'warning',
|
1066 |
+
E_USER_ERROR => 'error');
|
1067 |
+
if ($this->mode & PEAR_ERROR_CALLBACK) {
|
1068 |
+
if (is_array($this->callback)) {
|
1069 |
+
$callback = (is_object($this->callback[0]) ?
|
1070 |
+
strtolower(get_class($this->callback[0])) :
|
1071 |
+
$this->callback[0]) . '::' .
|
1072 |
+
$this->callback[1];
|
1073 |
+
} else {
|
1074 |
+
$callback = $this->callback;
|
1075 |
+
}
|
1076 |
+
return sprintf('[%s: message="%s" code=%d mode=callback '.
|
1077 |
+
'callback=%s prefix="%s" info="%s"]',
|
1078 |
+
strtolower(get_class($this)), $this->message, $this->code,
|
1079 |
+
$callback, $this->error_message_prefix,
|
1080 |
+
$this->userinfo);
|
1081 |
+
}
|
1082 |
+
if ($this->mode & PEAR_ERROR_PRINT) {
|
1083 |
+
$modes[] = 'print';
|
1084 |
+
}
|
1085 |
+
if ($this->mode & PEAR_ERROR_TRIGGER) {
|
1086 |
+
$modes[] = 'trigger';
|
1087 |
+
}
|
1088 |
+
if ($this->mode & PEAR_ERROR_DIE) {
|
1089 |
+
$modes[] = 'die';
|
1090 |
+
}
|
1091 |
+
if ($this->mode & PEAR_ERROR_RETURN) {
|
1092 |
+
$modes[] = 'return';
|
1093 |
+
}
|
1094 |
+
return sprintf('[%s: message="%s" code=%d mode=%s level=%s '.
|
1095 |
+
'prefix="%s" info="%s"]',
|
1096 |
+
strtolower(get_class($this)), $this->message, $this->code,
|
1097 |
+
implode("|", $modes), $levels[$this->level],
|
1098 |
+
$this->error_message_prefix,
|
1099 |
+
$this->userinfo);
|
1100 |
+
}
|
1101 |
+
|
1102 |
+
// }}}
|
1103 |
+
}
|
1104 |
+
|
1105 |
+
/*
|
1106 |
+
* Local Variables:
|
1107 |
+
* mode: php
|
1108 |
+
* tab-width: 4
|
1109 |
+
* c-basic-offset: 4
|
1110 |
+
* End:
|
1111 |
+
*/
|
1112 |
+
?>
|
Sajax.php
ADDED
@@ -0,0 +1,361 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
if (!isset($GLOBALS['SAJAX_INCLUDED'])) {
|
3 |
+
|
4 |
+
/*
|
5 |
+
* GLOBALS AND DEFAULTS
|
6 |
+
*
|
7 |
+
*/
|
8 |
+
$GLOBALS['sajax_version'] = '0.12';
|
9 |
+
$GLOBALS['sajax_debug_mode'] = 0;
|
10 |
+
$GLOBALS['sajax_export_list'] = array();
|
11 |
+
$GLOBALS['sajax_request_type'] = 'GET';
|
12 |
+
$GLOBALS['sajax_remote_uri'] = '';
|
13 |
+
$GLOBALS['sajax_failure_redirect'] = '';
|
14 |
+
|
15 |
+
/*
|
16 |
+
* CODE
|
17 |
+
*
|
18 |
+
*/
|
19 |
+
|
20 |
+
//
|
21 |
+
// Initialize the Sajax library.
|
22 |
+
//
|
23 |
+
function sajax_init() {
|
24 |
+
}
|
25 |
+
|
26 |
+
//
|
27 |
+
// Helper function to return the script's own URI.
|
28 |
+
//
|
29 |
+
function sajax_get_my_uri() {
|
30 |
+
return $_SERVER["REQUEST_URI"];
|
31 |
+
}
|
32 |
+
$sajax_remote_uri = sajax_get_my_uri();
|
33 |
+
|
34 |
+
//
|
35 |
+
// Helper function to return an eval()-usable representation
|
36 |
+
// of an object in JavaScript.
|
37 |
+
//
|
38 |
+
function sajax_get_js_repr($value) {
|
39 |
+
$type = gettype($value);
|
40 |
+
|
41 |
+
if ($type == "boolean") {
|
42 |
+
return ($value) ? "Boolean(true)" : "Boolean(false)";
|
43 |
+
}
|
44 |
+
elseif ($type == "integer") {
|
45 |
+
return "parseInt($value)";
|
46 |
+
}
|
47 |
+
elseif ($type == "double") {
|
48 |
+
return "parseFloat($value)";
|
49 |
+
}
|
50 |
+
elseif ($type == "array" || $type == "object" ) {
|
51 |
+
//
|
52 |
+
// XXX Arrays with non-numeric indices are not
|
53 |
+
// permitted according to ECMAScript, yet everyone
|
54 |
+
// uses them.. We'll use an object.
|
55 |
+
//
|
56 |
+
$s = "{ ";
|
57 |
+
if ($type == "object") {
|
58 |
+
$value = get_object_vars($value);
|
59 |
+
}
|
60 |
+
foreach ($value as $k=>$v) {
|
61 |
+
$esc_key = sajax_esc($k);
|
62 |
+
if (is_numeric($k))
|
63 |
+
$s .= "$k: " . sajax_get_js_repr($v) . ", ";
|
64 |
+
else
|
65 |
+
$s .= "\"$esc_key\": " . sajax_get_js_repr($v) . ", ";
|
66 |
+
}
|
67 |
+
if (count($value))
|
68 |
+
$s = substr($s, 0, -2);
|
69 |
+
return $s . " }";
|
70 |
+
}
|
71 |
+
else {
|
72 |
+
$esc_val = sajax_esc($value);
|
73 |
+
$s = "'$esc_val'";
|
74 |
+
return $s;
|
75 |
+
}
|
76 |
+
}
|
77 |
+
|
78 |
+
function sajax_handle_client_request() {
|
79 |
+
global $sajax_export_list;
|
80 |
+
|
81 |
+
$mode = "";
|
82 |
+
|
83 |
+
if (! empty($_GET["rs"]))
|
84 |
+
$mode = "get";
|
85 |
+
|
86 |
+
if (!empty($_POST["rs"]))
|
87 |
+
$mode = "post";
|
88 |
+
|
89 |
+
if (empty($mode))
|
90 |
+
return;
|
91 |
+
|
92 |
+
$target = "";
|
93 |
+
|
94 |
+
if ($mode == "get") {
|
95 |
+
// Bust cache in the head
|
96 |
+
header ("Expires: Mon, 26 Jul 1997 05:00:00 GMT"); // Date in the past
|
97 |
+
header ("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT");
|
98 |
+
// always modified
|
99 |
+
header ("Cache-Control: no-cache, must-revalidate"); // HTTP/1.1
|
100 |
+
header ("Pragma: no-cache"); // HTTP/1.0
|
101 |
+
$func_name = $_GET["rs"];
|
102 |
+
if (! empty($_GET["rsargs"]))
|
103 |
+
$args = $_GET["rsargs"];
|
104 |
+
else
|
105 |
+
$args = array();
|
106 |
+
}
|
107 |
+
else {
|
108 |
+
$func_name = $_POST["rs"];
|
109 |
+
if (! empty($_POST["rsargs"]))
|
110 |
+
$args = $_POST["rsargs"];
|
111 |
+
else
|
112 |
+
$args = array();
|
113 |
+
}
|
114 |
+
|
115 |
+
if (! in_array($func_name, $sajax_export_list))
|
116 |
+
echo "-:$func_name not callable";
|
117 |
+
else {
|
118 |
+
echo "+:";
|
119 |
+
$result = call_user_func_array($func_name, $args);
|
120 |
+
echo "var res = " . trim(sajax_get_js_repr($result)) . "; res;";
|
121 |
+
}
|
122 |
+
exit;
|
123 |
+
}
|
124 |
+
|
125 |
+
function sajax_get_common_js() {
|
126 |
+
global $sajax_debug_mode;
|
127 |
+
global $sajax_request_type;
|
128 |
+
global $sajax_remote_uri;
|
129 |
+
global $sajax_failure_redirect;
|
130 |
+
|
131 |
+
$t = strtoupper($sajax_request_type);
|
132 |
+
if ($t != "" && $t != "GET" && $t != "POST")
|
133 |
+
return "// Invalid type: $t.. \n\n";
|
134 |
+
|
135 |
+
ob_start();
|
136 |
+
?>
|
137 |
+
|
138 |
+
// remote scripting library
|
139 |
+
// (c) copyright 2005 modernmethod, inc
|
140 |
+
var sajax_debug_mode = <?php echo $sajax_debug_mode ? "true" : "false"; ?>;
|
141 |
+
var sajax_request_type = "<?php echo $t; ?>";
|
142 |
+
var sajax_target_id = "";
|
143 |
+
var sajax_failure_redirect = "<?php echo $sajax_failure_redirect; ?>";
|
144 |
+
|
145 |
+
function sajax_debug(text) {
|
146 |
+
if (sajax_debug_mode)
|
147 |
+
alert(text);
|
148 |
+
}
|
149 |
+
|
150 |
+
function sajax_init_object() {
|
151 |
+
sajax_debug("sajax_init_object() called..")
|
152 |
+
|
153 |
+
var A;
|
154 |
+
|
155 |
+
var msxmlhttp = new Array(
|
156 |
+
'Msxml2.XMLHTTP.5.0',
|
157 |
+
'Msxml2.XMLHTTP.4.0',
|
158 |
+
'Msxml2.XMLHTTP.3.0',
|
159 |
+
'Msxml2.XMLHTTP',
|
160 |
+
'Microsoft.XMLHTTP');
|
161 |
+
for (var i = 0; i < msxmlhttp.length; i++) {
|
162 |
+
try {
|
163 |
+
A = new ActiveXObject(msxmlhttp[i]);
|
164 |
+
} catch (e) {
|
165 |
+
A = null;
|
166 |
+
}
|
167 |
+
}
|
168 |
+
|
169 |
+
if(!A && typeof XMLHttpRequest != "undefined")
|
170 |
+
A = new XMLHttpRequest();
|
171 |
+
if (!A)
|
172 |
+
sajax_debug("Could not create connection object.");
|
173 |
+
return A;
|
174 |
+
}
|
175 |
+
|
176 |
+
var sajax_requests = new Array();
|
177 |
+
|
178 |
+
function sajax_cancel() {
|
179 |
+
for (var i = 0; i < sajax_requests.length; i++)
|
180 |
+
sajax_requests[i].abort();
|
181 |
+
}
|
182 |
+
|
183 |
+
function sajax_do_call(func_name, args) {
|
184 |
+
var i, x, n;
|
185 |
+
var uri;
|
186 |
+
var post_data;
|
187 |
+
var target_id;
|
188 |
+
|
189 |
+
sajax_debug("in sajax_do_call().." + sajax_request_type + "/" + sajax_target_id);
|
190 |
+
target_id = sajax_target_id;
|
191 |
+
if (typeof(sajax_request_type) == "undefined" || sajax_request_type == "")
|
192 |
+
sajax_request_type = "GET";
|
193 |
+
|
194 |
+
uri = "<?php echo $sajax_remote_uri; ?>";
|
195 |
+
if (sajax_request_type == "GET") {
|
196 |
+
|
197 |
+
if (uri.indexOf("?") == -1)
|
198 |
+
uri += "?rs=" + escape(func_name);
|
199 |
+
else
|
200 |
+
uri += "&rs=" + escape(func_name);
|
201 |
+
uri += "&rst=" + escape(sajax_target_id);
|
202 |
+
uri += "&rsrnd=" + new Date().getTime();
|
203 |
+
|
204 |
+
for (i = 0; i < args.length-1; i++)
|
205 |
+
uri += "&rsargs[]=" + escape(args[i]);
|
206 |
+
|
207 |
+
post_data = null;
|
208 |
+
}
|
209 |
+
else if (sajax_request_type == "POST") {
|
210 |
+
post_data = "rs=" + escape(func_name);
|
211 |
+
post_data += "&rst=" + escape(sajax_target_id);
|
212 |
+
post_data += "&rsrnd=" + new Date().getTime();
|
213 |
+
|
214 |
+
for (i = 0; i < args.length-1; i++)
|
215 |
+
post_data = post_data + "&rsargs[]=" + escape(args[i]);
|
216 |
+
}
|
217 |
+
else {
|
218 |
+
alert("Illegal request type: " + sajax_request_type);
|
219 |
+
}
|
220 |
+
|
221 |
+
x = sajax_init_object();
|
222 |
+
if (x == null) {
|
223 |
+
if (sajax_failure_redirect != "") {
|
224 |
+
location.href = sajax_failure_redirect;
|
225 |
+
return false;
|
226 |
+
} else {
|
227 |
+
sajax_debug("NULL sajax object for user agent:\n" + navigator.userAgent);
|
228 |
+
return false;
|
229 |
+
}
|
230 |
+
} else {
|
231 |
+
x.open(sajax_request_type, uri, true);
|
232 |
+
// window.open(uri);
|
233 |
+
|
234 |
+
sajax_requests[sajax_requests.length] = x;
|
235 |
+
|
236 |
+
if (sajax_request_type == "POST") {
|
237 |
+
x.setRequestHeader("Method", "POST " + uri + " HTTP/1.1");
|
238 |
+
x.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
|
239 |
+
}
|
240 |
+
|
241 |
+
x.onreadystatechange = function() {
|
242 |
+
if (x.readyState != 4)
|
243 |
+
return;
|
244 |
+
|
245 |
+
sajax_debug("received " + x.responseText);
|
246 |
+
|
247 |
+
var status;
|
248 |
+
var data;
|
249 |
+
var txt = x.responseText.replace(/^\s*|\s*$/g,"");
|
250 |
+
status = txt.charAt(0);
|
251 |
+
data = txt.substring(2);
|
252 |
+
|
253 |
+
if (status == "") {
|
254 |
+
// let's just assume this is a pre-response bailout and let it slide for now
|
255 |
+
} else if (status == "-")
|
256 |
+
alert("Error: " + data);
|
257 |
+
else {
|
258 |
+
if (target_id != "")
|
259 |
+
document.getElementById(target_id).innerHTML = eval(data);
|
260 |
+
else {
|
261 |
+
try {
|
262 |
+
var callback;
|
263 |
+
var extra_data = false;
|
264 |
+
if (typeof args[args.length-1] == "object") {
|
265 |
+
callback = args[args.length-1].callback;
|
266 |
+
extra_data = args[args.length-1].extra_data;
|
267 |
+
} else {
|
268 |
+
callback = args[args.length-1];
|
269 |
+
}
|
270 |
+
callback(eval(data), extra_data);
|
271 |
+
} catch (e) {
|
272 |
+
sajax_debug("Caught error " + e + ": Could not eval " + data );
|
273 |
+
}
|
274 |
+
}
|
275 |
+
}
|
276 |
+
}
|
277 |
+
}
|
278 |
+
|
279 |
+
sajax_debug(func_name + " uri = " + uri + "/post = " + post_data);
|
280 |
+
x.send(post_data);
|
281 |
+
sajax_debug(func_name + " waiting..");
|
282 |
+
delete x;
|
283 |
+
return true;
|
284 |
+
}
|
285 |
+
|
286 |
+
<?php
|
287 |
+
$html = ob_get_contents();
|
288 |
+
ob_end_clean();
|
289 |
+
return $html;
|
290 |
+
}
|
291 |
+
|
292 |
+
function sajax_show_common_js() {
|
293 |
+
echo sajax_get_common_js();
|
294 |
+
}
|
295 |
+
|
296 |
+
// javascript escape a value
|
297 |
+
function sajax_esc($val)
|
298 |
+
{
|
299 |
+
$val = str_replace("\\", "\\\\", $val);
|
300 |
+
$val = str_replace("\r", "\\r", $val);
|
301 |
+
$val = str_replace("\n", "\\n", $val);
|
302 |
+
$val = str_replace("'", "\\'", $val);
|
303 |
+
return str_replace('"', '\\"', $val);
|
304 |
+
}
|
305 |
+
|
306 |
+
function sajax_get_one_stub($func_name) {
|
307 |
+
ob_start();
|
308 |
+
?>
|
309 |
+
|
310 |
+
// wrapper for <?php echo $func_name; ?>
|
311 |
+
|
312 |
+
function x_<?php echo $func_name; ?>() {
|
313 |
+
sajax_do_call("<?php echo $func_name; ?>",
|
314 |
+
x_<?php echo $func_name; ?>.arguments);
|
315 |
+
}
|
316 |
+
|
317 |
+
<?php
|
318 |
+
$html = ob_get_contents();
|
319 |
+
ob_end_clean();
|
320 |
+
return $html;
|
321 |
+
}
|
322 |
+
|
323 |
+
function sajax_show_one_stub($func_name) {
|
324 |
+
echo sajax_get_one_stub($func_name);
|
325 |
+
}
|
326 |
+
|
327 |
+
function sajax_export() {
|
328 |
+
global $sajax_export_list;
|
329 |
+
|
330 |
+
$n = func_num_args();
|
331 |
+
for ($i = 0; $i < $n; $i++) {
|
332 |
+
$sajax_export_list[] = func_get_arg($i);
|
333 |
+
}
|
334 |
+
}
|
335 |
+
|
336 |
+
$sajax_js_has_been_shown = 0;
|
337 |
+
function sajax_get_javascript()
|
338 |
+
{
|
339 |
+
global $sajax_js_has_been_shown;
|
340 |
+
global $sajax_export_list;
|
341 |
+
|
342 |
+
$html = "";
|
343 |
+
if (! $sajax_js_has_been_shown) {
|
344 |
+
$html .= sajax_get_common_js();
|
345 |
+
$sajax_js_has_been_shown = 1;
|
346 |
+
}
|
347 |
+
foreach ($sajax_export_list as $func) {
|
348 |
+
$html .= sajax_get_one_stub($func);
|
349 |
+
}
|
350 |
+
return $html;
|
351 |
+
}
|
352 |
+
|
353 |
+
function sajax_show_javascript()
|
354 |
+
{
|
355 |
+
echo sajax_get_javascript();
|
356 |
+
}
|
357 |
+
|
358 |
+
|
359 |
+
$GLOBALS['SAJAX_INCLUDED'] = 1;
|
360 |
+
}
|
361 |
+
?>
|
Type.php
ADDED
@@ -0,0 +1,398 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/* vim: set expandtab tabstop=4 shiftwidth=4: */
|
3 |
+
// +----------------------------------------------------------------------+
|
4 |
+
// | PHP version 4 |
|
5 |
+
// +----------------------------------------------------------------------+
|
6 |
+
// | Copyright (c) 1997-2002 The PHP Group |
|
7 |
+
// +----------------------------------------------------------------------+
|
8 |
+
// | This source file is subject to version 3.0 of the PHP license, |
|
9 |
+
// | that is bundled with this package in the file LICENSE, and is |
|
10 |
+
// | available at through the world-wide-web at |
|
11 |
+
// | http://www.php.net/license/3_0.txt. |
|
12 |
+
// | If you did not receive a copy of the PHP license and are unable to |
|
13 |
+
// | obtain it through the world-wide-web, please send a note to |
|
14 |
+
// | license@php.net so we can mail you a copy immediately. |
|
15 |
+
// +----------------------------------------------------------------------+
|
16 |
+
// | Authors: Ian Eure <ieure@php.net> |
|
17 |
+
// +----------------------------------------------------------------------+
|
18 |
+
//
|
19 |
+
// $Id: Type.php,v 1.2 2004/08/07 22:19:04 ieure Exp $
|
20 |
+
|
21 |
+
|
22 |
+
if (!class_exists("pear")) {
|
23 |
+
require_once $GLOBALS['bkpwp_plugin_path']."PEAR.php";
|
24 |
+
}
|
25 |
+
|
26 |
+
$_fileCmd = &PEAR::getStaticProperty('MIME_Type', 'fileCmd');
|
27 |
+
$_fileCmd = 'file';
|
28 |
+
|
29 |
+
/**
|
30 |
+
* Class for working with MIME types
|
31 |
+
*
|
32 |
+
* @version @version@
|
33 |
+
* @package @package@
|
34 |
+
* @author Ian Eure <ieure@php.net>
|
35 |
+
*/
|
36 |
+
class MIME_Type {
|
37 |
+
/**
|
38 |
+
* The MIME media type
|
39 |
+
*
|
40 |
+
* @var string
|
41 |
+
*/
|
42 |
+
var $media = '';
|
43 |
+
|
44 |
+
/**
|
45 |
+
* The MIME media sub-type
|
46 |
+
*
|
47 |
+
* @var string
|
48 |
+
*/
|
49 |
+
var $subType = '';
|
50 |
+
|
51 |
+
/**
|
52 |
+
* Optional MIME parameters
|
53 |
+
*
|
54 |
+
* @var array
|
55 |
+
*/
|
56 |
+
var $parameters = array();
|
57 |
+
|
58 |
+
/**
|
59 |
+
* List of valid media types
|
60 |
+
*
|
61 |
+
* @var array
|
62 |
+
*/
|
63 |
+
var $validMediaTypes = array(
|
64 |
+
'text',
|
65 |
+
'image',
|
66 |
+
'audio',
|
67 |
+
'video',
|
68 |
+
'application',
|
69 |
+
'multipart',
|
70 |
+
'message'
|
71 |
+
);
|
72 |
+
|
73 |
+
|
74 |
+
/**
|
75 |
+
* Constructor.
|
76 |
+
*
|
77 |
+
* If $type is set, if will be parsed and the appropriate class vars set. If not,
|
78 |
+
* you get an empty class. This is useful, but not quite as useful as parsing a
|
79 |
+
* type.
|
80 |
+
*
|
81 |
+
* @param string $type MIME type
|
82 |
+
* @return void
|
83 |
+
*/
|
84 |
+
function MIME_Type($type = false)
|
85 |
+
{
|
86 |
+
if ($type) {
|
87 |
+
$this->parse($type);
|
88 |
+
}
|
89 |
+
}
|
90 |
+
|
91 |
+
|
92 |
+
/**
|
93 |
+
* Parse a mime-type
|
94 |
+
*
|
95 |
+
* @param $type string MIME type to parse
|
96 |
+
* @return void
|
97 |
+
*/
|
98 |
+
function parse($type)
|
99 |
+
{
|
100 |
+
$this->media = $this->getMedia($type);
|
101 |
+
$this->subType = $this->getSubType($type);
|
102 |
+
if (MIME_Type::hasParameters($type)) {
|
103 |
+
require_once 'MIME/Type/Parameter.php';
|
104 |
+
foreach (MIME_Type::getParameters($type) as $param) {
|
105 |
+
$param = &new MIME_Type_Parameter($param);
|
106 |
+
$this->parameters[$param->name] = $param;
|
107 |
+
}
|
108 |
+
}
|
109 |
+
}
|
110 |
+
|
111 |
+
|
112 |
+
/**
|
113 |
+
* Does this type have any parameters?
|
114 |
+
*
|
115 |
+
* @param $type string MIME type to check
|
116 |
+
* @return boolean true if $type has parameters, false otherwise
|
117 |
+
* @static
|
118 |
+
*/
|
119 |
+
function hasParameters($type)
|
120 |
+
{
|
121 |
+
if (strstr($type, ';')) {
|
122 |
+
return true;
|
123 |
+
}
|
124 |
+
return false;
|
125 |
+
}
|
126 |
+
|
127 |
+
|
128 |
+
/**
|
129 |
+
* Get a MIME type's parameters
|
130 |
+
*
|
131 |
+
* @param $type string MIME type to get parameters of
|
132 |
+
* @return array $type's parameters
|
133 |
+
* @static
|
134 |
+
*/
|
135 |
+
function getParameters($type)
|
136 |
+
{
|
137 |
+
$params = array();
|
138 |
+
$tmp = explode(';', $type);
|
139 |
+
for ($i = 1; $i < count($tmp); $i++) {
|
140 |
+
$params[] = trim($tmp[$i]);
|
141 |
+
}
|
142 |
+
return $params;
|
143 |
+
}
|
144 |
+
|
145 |
+
|
146 |
+
/**
|
147 |
+
* Strip paramaters from a MIME type string
|
148 |
+
*
|
149 |
+
* @param string $type MIME type string
|
150 |
+
* @return string MIME type with parameters removed
|
151 |
+
* @static
|
152 |
+
*/
|
153 |
+
function stripParameters($type)
|
154 |
+
{
|
155 |
+
if (strstr($type, ';')) {
|
156 |
+
return substr($type, 0, strpos($type, ';'));
|
157 |
+
}
|
158 |
+
return $type;
|
159 |
+
}
|
160 |
+
|
161 |
+
|
162 |
+
/**
|
163 |
+
* Get a MIME type's media
|
164 |
+
*
|
165 |
+
* @note 'media' refers to the portion before the first slash
|
166 |
+
* @param $type string MIME type to get media of
|
167 |
+
* @return string $type's media
|
168 |
+
* @static
|
169 |
+
*/
|
170 |
+
function getMedia($type)
|
171 |
+
{
|
172 |
+
$tmp = explode('/', $type);
|
173 |
+
return strtolower($tmp[0]);
|
174 |
+
}
|
175 |
+
|
176 |
+
|
177 |
+
/**
|
178 |
+
* Get a MIME type's subtype
|
179 |
+
*
|
180 |
+
* @param $type string MIME type to get subtype of
|
181 |
+
* @return string $type's subtype
|
182 |
+
* @static
|
183 |
+
*/
|
184 |
+
function getSubType($type)
|
185 |
+
{
|
186 |
+
$tmp = explode('/', $type);
|
187 |
+
$tmp = explode(';', $tmp[1]);
|
188 |
+
return strtolower(trim($tmp[0]));
|
189 |
+
}
|
190 |
+
|
191 |
+
|
192 |
+
/**
|
193 |
+
* Create a textual MIME type from object values
|
194 |
+
*
|
195 |
+
* This function performs the opposite function of parse().
|
196 |
+
*
|
197 |
+
* @return string MIME type string
|
198 |
+
*/
|
199 |
+
function get()
|
200 |
+
{
|
201 |
+
$type = strtolower($this->media.'/'.$this->subType);
|
202 |
+
if (count($this->parameters)) {
|
203 |
+
foreach ($this->parameters as $key => $null) {
|
204 |
+
$type .= '; '.$this->parameters[$key]->get();
|
205 |
+
}
|
206 |
+
}
|
207 |
+
return $type;
|
208 |
+
}
|
209 |
+
|
210 |
+
|
211 |
+
/**
|
212 |
+
* Is this type experimental?
|
213 |
+
*
|
214 |
+
* @note Experimental types are denoted by a leading 'x-' in the media or
|
215 |
+
* subtype, e.g. text/x-vcard or x-world/x-vrml.
|
216 |
+
* @param string $type MIME type to check
|
217 |
+
* @return boolean true if $type is experimental, false otherwise
|
218 |
+
* @static
|
219 |
+
*/
|
220 |
+
function isExperimental($type)
|
221 |
+
{
|
222 |
+
if (substr(MIME_Type::getMedia($type), 0, 2) == 'x-' ||
|
223 |
+
substr(MIME_Type::getSubType($type), 0, 2) == 'x-') {
|
224 |
+
return true;
|
225 |
+
}
|
226 |
+
return false;
|
227 |
+
}
|
228 |
+
|
229 |
+
|
230 |
+
/**
|
231 |
+
* Is this a vendor MIME type?
|
232 |
+
*
|
233 |
+
* @note Vendor types are denoted with a leading 'vnd. in the subtype.
|
234 |
+
* @param string $type MIME type to check
|
235 |
+
* @return boolean true if $type is a vendor type, false otherwise
|
236 |
+
* @static
|
237 |
+
*/
|
238 |
+
function isVendor($type)
|
239 |
+
{
|
240 |
+
if (substr(MIME_Type::getSubType($type), 0, 4) == 'vnd.') {
|
241 |
+
return true;
|
242 |
+
}
|
243 |
+
return false;
|
244 |
+
}
|
245 |
+
|
246 |
+
|
247 |
+
/**
|
248 |
+
* Is this a wildcard type?
|
249 |
+
*
|
250 |
+
* @param string $type MIME type to check
|
251 |
+
* @return boolean true if $type is a wildcard, false otherwise
|
252 |
+
* @static
|
253 |
+
*/
|
254 |
+
function isWildcard($type)
|
255 |
+
{
|
256 |
+
if ($type == '*/*' || MIME_Type::getSubtype($type) == '*') {
|
257 |
+
return true;
|
258 |
+
}
|
259 |
+
return false;
|
260 |
+
}
|
261 |
+
|
262 |
+
|
263 |
+
/**
|
264 |
+
* Perform a wildcard match on a MIME type
|
265 |
+
*
|
266 |
+
* Example:
|
267 |
+
* MIME_Type::wildcardMatch('image/*', 'image/png')
|
268 |
+
*
|
269 |
+
* @param string $card Wildcard to check against
|
270 |
+
* @param string $type MIME type to check
|
271 |
+
* @return boolean true if there was a match, false otherwise
|
272 |
+
*/
|
273 |
+
function wildcardMatch($card, $type)
|
274 |
+
{
|
275 |
+
if (!MIME_Type::isWildcard($card)) {
|
276 |
+
return false;
|
277 |
+
}
|
278 |
+
|
279 |
+
if ($card == '*/*') {
|
280 |
+
return true;
|
281 |
+
}
|
282 |
+
|
283 |
+
if (MIME_Type::getMedia($card) ==
|
284 |
+
MIME_Type::getMedia($type)) {
|
285 |
+
return true;
|
286 |
+
}
|
287 |
+
return false;
|
288 |
+
}
|
289 |
+
|
290 |
+
|
291 |
+
/**
|
292 |
+
* Add a parameter to this type
|
293 |
+
*
|
294 |
+
* @param string $name Attribute name
|
295 |
+
* @param string $value Attribute value
|
296 |
+
* @param string $comment Comment for this parameter
|
297 |
+
* @return void
|
298 |
+
*/
|
299 |
+
function addParameter($name, $value, $comment = false)
|
300 |
+
{
|
301 |
+
$tmp = &new MIME_Type_Parameter;
|
302 |
+
$tmp->name = $name;
|
303 |
+
$tmp->value = $value;
|
304 |
+
$tmp->comment = $comment;
|
305 |
+
$this->parameters[$name] = $tmp;
|
306 |
+
}
|
307 |
+
|
308 |
+
|
309 |
+
/**
|
310 |
+
* Remove a parameter from this type
|
311 |
+
*
|
312 |
+
* @param string $name Parameter name
|
313 |
+
* @return void
|
314 |
+
*/
|
315 |
+
function removeParameter($name)
|
316 |
+
{
|
317 |
+
unset ($this->parameters[$name]);
|
318 |
+
}
|
319 |
+
|
320 |
+
|
321 |
+
/**
|
322 |
+
* Autodetect a file's MIME-type
|
323 |
+
*
|
324 |
+
* This function may be called staticly.
|
325 |
+
*
|
326 |
+
* @param string $file Path to the file to get the type of
|
327 |
+
* @param bool $params Append MIME parameters if true
|
328 |
+
* @return string $file's MIME-type on success, PEAR_Error otherwise
|
329 |
+
* @since 1.0.0beta1
|
330 |
+
* @static
|
331 |
+
*/
|
332 |
+
function autoDetect($file, $params = false)
|
333 |
+
{
|
334 |
+
@include_once 'System/Command.php';
|
335 |
+
if (function_exists('mime_content_type')) {
|
336 |
+
$type = mime_content_type($file);
|
337 |
+
} else if (class_exists('System_Command')) {
|
338 |
+
$type = MIME_Type::_fileAutoDetect($file);
|
339 |
+
} else {
|
340 |
+
return PEAR::raiseError("Sorry, can't autodetect; you need the mime_magic extension or System_Command and 'file' installed to use this function.");
|
341 |
+
}
|
342 |
+
|
343 |
+
// _fileAutoDetect() may have returned an error.
|
344 |
+
if (PEAR::isError($type)) {
|
345 |
+
return $type;
|
346 |
+
}
|
347 |
+
|
348 |
+
// Don't return an empty string
|
349 |
+
if (!$type || !strlen($type)) {
|
350 |
+
return PEAR::raiseError("Sorry, couldn't determine file type.");
|
351 |
+
}
|
352 |
+
|
353 |
+
// Strip parameters if present & requested
|
354 |
+
if (MIME_Type::hasParameters($type) && !$params) {
|
355 |
+
$type = MIME_Type::stripParameters($type);
|
356 |
+
}
|
357 |
+
|
358 |
+
return $type;
|
359 |
+
}
|
360 |
+
|
361 |
+
/**
|
362 |
+
* Autodetect a file's MIME-type with 'file' and System_Command
|
363 |
+
*
|
364 |
+
* This function may be called staticly.
|
365 |
+
*
|
366 |
+
* @param string $file Path to the file to get the type of
|
367 |
+
* @return string $file's MIME-type
|
368 |
+
* @since 1.0.0beta1
|
369 |
+
* @static
|
370 |
+
*/
|
371 |
+
function _fileAutoDetect($file)
|
372 |
+
{
|
373 |
+
// Sanity checks
|
374 |
+
if (!file_exists($file)) {
|
375 |
+
return PEAR::raiseError("File \"$file\" doesn't exist");
|
376 |
+
}
|
377 |
+
|
378 |
+
if (!is_readable($file)) {
|
379 |
+
return PEAR::raiseError("File \"$file\" is not readable");
|
380 |
+
}
|
381 |
+
|
382 |
+
$cmd = new System_Command;
|
383 |
+
|
384 |
+
|
385 |
+
// Make sure we have the 'file' command.
|
386 |
+
$fileCmd = PEAR::getStaticProperty('MIME_Type', 'fileCmd');
|
387 |
+
if (!$cmd->which($fileCmd)) {
|
388 |
+
unset($cmd);
|
389 |
+
return PEAR::raiseError("Can't find file command \"{$fileCmd}\"");
|
390 |
+
}
|
391 |
+
|
392 |
+
$cmd->pushCommand($fileCmd, "-bi '{$file}'");
|
393 |
+
$res = $cmd->execute();
|
394 |
+
unset($cmd);
|
395 |
+
|
396 |
+
return $res;
|
397 |
+
}
|
398 |
+
}
|
backupwordpress.php
ADDED
@@ -0,0 +1,81 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/*
|
3 |
+
Plugin Name: BackUpWordPress
|
4 |
+
Plugin URI: http://wordpress.designpraxis.at
|
5 |
+
Description: Manage <a href="admin.php?page=backupwordpress/backupwordpress.php">WordPress Backups</a>. Beta Release. Please help testing and give me feedback under the comments section of <a href="http://wordpress.designpraxis.at/plugins/backupwordpress/">the Plugin page</a>. Backup DB, Files & Folders, use .tar.gz, .zip, Exclude List, etc.
|
6 |
+
Author: Roland Rust
|
7 |
+
Version: 0.1.2
|
8 |
+
Author URI: http://wordpress.designpraxis.at
|
9 |
+
*/
|
10 |
+
|
11 |
+
/*
|
12 |
+
Notes:
|
13 |
+
backupwordpress\Archive\Writer\Tar.php has been debugged around line 80 to handle long filenames according to http://pear.php.net/bugs/bug.php?id=10144&edit=3
|
14 |
+
*/
|
15 |
+
|
16 |
+
/*
|
17 |
+
|
18 |
+
Changelog:
|
19 |
+
|
20 |
+
Changes in 0.1.2:
|
21 |
+
- bug fixed: Backup-Now doesn't call Sajax
|
22 |
+
- bkpwp_delete_old() refactored
|
23 |
+
- bug fixed: table data is not dumped
|
24 |
+
|
25 |
+
*/
|
26 |
+
|
27 |
+
/* Copyright 2007 Roland Rust (email : wordpress@designpraxis.at)
|
28 |
+
|
29 |
+
This program is free software; you can redistribute it and/or modify
|
30 |
+
it under the terms of the GNU General Public License as published by
|
31 |
+
the Free Software Foundation; either version 2 of the License, or
|
32 |
+
(at your option) any later version.
|
33 |
+
|
34 |
+
This program is distributed in the hope that it will be useful,
|
35 |
+
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
36 |
+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
37 |
+
GNU General Public License for more details.
|
38 |
+
|
39 |
+
You should have received a copy of the GNU General Public License
|
40 |
+
along with this program; if not, write to the Free Software
|
41 |
+
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
42 |
+
*/
|
43 |
+
//return;
|
44 |
+
$GLOBALS['bkpwp_plugin_path'] = ABSPATH."wp-content/plugins/backupwordpress/";
|
45 |
+
|
46 |
+
// get the functions
|
47 |
+
require_once($GLOBALS['bkpwp_plugin_path']."functions.php");
|
48 |
+
// require_once the required PEAR::FILE_ARCHIVE package for files backup
|
49 |
+
require_once $GLOBALS['bkpwp_plugin_path']."Archive.php";
|
50 |
+
require_once $GLOBALS['bkpwp_plugin_path']."Type.php";
|
51 |
+
// BackUpWordPress classes
|
52 |
+
require_once($GLOBALS['bkpwp_plugin_path']."bkpwp-classes/interface.php");
|
53 |
+
require_once($GLOBALS['bkpwp_plugin_path']."bkpwp-classes/options.php");
|
54 |
+
require_once($GLOBALS['bkpwp_plugin_path']."bkpwp-classes/manage_backups.php");
|
55 |
+
require_once($GLOBALS['bkpwp_plugin_path']."bkpwp-classes/schedule.php");
|
56 |
+
require_once($GLOBALS['bkpwp_plugin_path']."functions-interface.php");
|
57 |
+
|
58 |
+
// Plugin activation and deactivation e.g.: set 'manage bkpwp' capabilities to admin
|
59 |
+
add_action('activate_backupwordpress/backupwordpress.php', 'bkpwp_activate');
|
60 |
+
add_action('deactivate_backupwordpress/backupwordpress.php', 'bkpwp_exit');
|
61 |
+
|
62 |
+
// set up ajax stuff on init, to prevent header oputput
|
63 |
+
add_action('init', 'bkpwp_download_files');
|
64 |
+
add_action('init', 'bkpwp_setup');
|
65 |
+
add_action('init', 'bkpwp_sajax_do');
|
66 |
+
|
67 |
+
// cron jobs with wordpress' pseude-cron: add special reccurences
|
68 |
+
add_filter('cron_schedules', 'bkpwp_more_reccurences');
|
69 |
+
|
70 |
+
add_action('bkpwp_schedule_bkpwp_hook','bkpwp_schedule_bkpwp');
|
71 |
+
|
72 |
+
if (eregi("backupwordpress",$_REQUEST['page'])) {
|
73 |
+
add_action('admin_head', 'bkpwp_sajax_js');
|
74 |
+
}
|
75 |
+
if (eregi("backupwordpress",$_REQUEST['page']) || $_SERVER['REQUEST_URI'] == "/wp-admin/index.php") {
|
76 |
+
add_action('admin_head', 'bkpwp_load_css_and_js');
|
77 |
+
}
|
78 |
+
|
79 |
+
add_action('admin_menu', 'bkpwp_add_menu');
|
80 |
+
add_action('activity_box_end', 'bkpwp_latest_activity',0);
|
81 |
+
?>
|
bigdump/bigdump.php
ADDED
@@ -0,0 +1,1030 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
// BigDump ver. 0.28b from 2007-06-08
|
4 |
+
// Staggered import of an large MySQL Dump (like phpMyAdmin 2.x Dump)
|
5 |
+
// Even through the webservers with hard runtime limit and those in safe mode
|
6 |
+
// Works fine with Internet Explorer 7.0 and Firefox 2.x
|
7 |
+
|
8 |
+
// Author: Alexey Ozerov (alexey at ozerov dot de)
|
9 |
+
// AJAX & CSV functionalities: Krzysiek Herod (kr81uni at wp dot pl)
|
10 |
+
// Copyright: GPL (C) 2003-2007
|
11 |
+
// More Infos: http://www.ozerov.de/bigdump.php
|
12 |
+
|
13 |
+
// This program is free software; you can redistribute it and/or modify it under the
|
14 |
+
// terms of the GNU General Public License as published by the Free Software Foundation;
|
15 |
+
// either version 2 of the License, or (at your option) any later version.
|
16 |
+
|
17 |
+
// THIS SCRIPT IS PROVIDED AS IS, WITHOUT ANY WARRANTY OR GUARANTEE OF ANY KIND
|
18 |
+
|
19 |
+
// USAGE
|
20 |
+
|
21 |
+
// 1. Adjust the database configuration in this file
|
22 |
+
// 2. Drop the old tables on the target database if your dump doesn't contain "DROP TABLE"
|
23 |
+
// 3. Create the working directory (e.g. dump) on your web-server
|
24 |
+
// 4. Upload bigdump.php and your dump files (.sql, .gz) via FTP to the working directory
|
25 |
+
// 5. Run the bigdump.php from your browser via URL like http://www.yourdomain.com/dump/bigdump.php
|
26 |
+
// 6. BigDump can start the next import session automatically if you enable the JavaScript
|
27 |
+
// 7. Wait for the script to finish, do not close the browser window
|
28 |
+
// 8. IMPORTANT: Remove bigdump.php and your dump files from the web-server
|
29 |
+
|
30 |
+
// If Timeout errors still occure you may need to adjust the $linepersession setting in this file
|
31 |
+
|
32 |
+
// LAST CHANGES
|
33 |
+
|
34 |
+
// *** Improved error message for file open errors
|
35 |
+
// *** Handle CSV files (you have to specify $csv_insert_table)
|
36 |
+
// *** Restart script in the background using AJAX
|
37 |
+
|
38 |
+
// Database configuration
|
39 |
+
|
40 |
+
// dprx-modified-start
|
41 |
+
require_once('../../../../wp-config.php');
|
42 |
+
global $table_prefix,$wpdb;
|
43 |
+
// dprx-modified-end
|
44 |
+
|
45 |
+
$db_server = DB_HOST;
|
46 |
+
$db_name = DB_NAME;
|
47 |
+
$db_username = DB_USER;
|
48 |
+
$db_password = DB_PASSWORD;
|
49 |
+
|
50 |
+
// Other Settings
|
51 |
+
|
52 |
+
$csv_insert_table = ''; // Destination table for CSV files
|
53 |
+
$ajax = true; // AJAX mode: import will be done without refreshing the website
|
54 |
+
$filename = ''; // Specify the dump filename to suppress the file selection dialog
|
55 |
+
$linespersession = 3000; // Lines to be executed per one import session
|
56 |
+
$delaypersession = 0; // You can specify a sleep time in milliseconds after each session
|
57 |
+
// Works only if JavaScript is activated. Use to reduce server overrun
|
58 |
+
|
59 |
+
// Allowed comment delimiters: lines starting with these strings will be dropped by BigDump
|
60 |
+
|
61 |
+
$comment[]='#'; // Standard comment lines are dropped by default
|
62 |
+
$comment[]='-- ';
|
63 |
+
// $comment[]='---'; // Uncomment this line if using proprietary dump created by outdated mysqldump
|
64 |
+
// $comment[]='/*!'; // Or add your own string to leave out other proprietary things
|
65 |
+
|
66 |
+
|
67 |
+
// Connection character set should be the same as the dump file character set (utf8, latin1, cp1251, koi8r etc.)
|
68 |
+
// See http://dev.mysql.com/doc/refman/5.0/en/charset-charsets.html for the full list
|
69 |
+
|
70 |
+
// dprx-modified-start
|
71 |
+
$db_connection_charset = DB_CHARSET;
|
72 |
+
// dprx-modified-end
|
73 |
+
|
74 |
+
|
75 |
+
// *******************************************************************************************
|
76 |
+
// If not familiar with PHP please don't change anything below this line
|
77 |
+
// *******************************************************************************************
|
78 |
+
|
79 |
+
if ($ajax)
|
80 |
+
ob_start();
|
81 |
+
|
82 |
+
define ('VERSION','0.28b');
|
83 |
+
define ('DATA_CHUNK_LENGTH',16384); // How many chars are read per time
|
84 |
+
define ('MAX_QUERY_LINES',300); // How many lines may be considered to be one query (except text lines)
|
85 |
+
define ('TESTMODE',false); // Set to true to process the file without actually accessing the database
|
86 |
+
|
87 |
+
header("Expires: Mon, 1 Dec 2003 01:00:00 GMT");
|
88 |
+
header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT");
|
89 |
+
header("Cache-Control: no-store, no-cache, must-revalidate");
|
90 |
+
header("Cache-Control: post-check=0, pre-check=0", false);
|
91 |
+
header("Pragma: no-cache");
|
92 |
+
|
93 |
+
@ini_set('auto_detect_line_endings', true);
|
94 |
+
@set_time_limit(0);
|
95 |
+
|
96 |
+
// Clean and strip anything we don't want from user's input [0.27b]
|
97 |
+
|
98 |
+
foreach ($_REQUEST as $key => $val)
|
99 |
+
{
|
100 |
+
$val = preg_replace("/[^_A-Za-z0-9-\.&=]/i",'', $val);
|
101 |
+
$_REQUEST[$key] = $val;
|
102 |
+
}
|
103 |
+
|
104 |
+
?>
|
105 |
+
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
|
106 |
+
<html>
|
107 |
+
<head>
|
108 |
+
<title>BigDump ver. <?php echo (VERSION); ?></title>
|
109 |
+
<meta http-equiv="CONTENT-TYPE" content="text/html; charset=iso-8859-1"/>
|
110 |
+
<meta http-equiv="CONTENT-LANGUAGE" content="EN"/>
|
111 |
+
|
112 |
+
<meta http-equiv="Cache-Control" content="no-cache/"/>
|
113 |
+
<meta http-equiv="Pragma" content="no-cache"/>
|
114 |
+
<meta http-equiv="Expires" content="-1"/>
|
115 |
+
|
116 |
+
<style type="text/css">
|
117 |
+
<!--
|
118 |
+
|
119 |
+
body
|
120 |
+
{ background-color:#FFFFF0;
|
121 |
+
}
|
122 |
+
|
123 |
+
h1
|
124 |
+
{ font-size:20px;
|
125 |
+
line-height:24px;
|
126 |
+
font-family:Arial,Helvetica,sans-serif;
|
127 |
+
margin-top:5px;
|
128 |
+
margin-bottom:5px;
|
129 |
+
}
|
130 |
+
|
131 |
+
p,td,th
|
132 |
+
{ font-size:14px;
|
133 |
+
line-height:18px;
|
134 |
+
font-family:Arial,Helvetica,sans-serif;
|
135 |
+
margin-top:5px;
|
136 |
+
margin-bottom:5px;
|
137 |
+
text-align:justify;
|
138 |
+
vertical-align:top;
|
139 |
+
}
|
140 |
+
|
141 |
+
p.centr
|
142 |
+
{
|
143 |
+
text-align:center;
|
144 |
+
}
|
145 |
+
|
146 |
+
p.smlcentr
|
147 |
+
{ font-size:10px;
|
148 |
+
line-height:14px;
|
149 |
+
text-align:center;
|
150 |
+
}
|
151 |
+
|
152 |
+
p.error
|
153 |
+
{ color:#FF0000;
|
154 |
+
font-weight:bold;
|
155 |
+
}
|
156 |
+
|
157 |
+
p.success
|
158 |
+
{ color:#00DD00;
|
159 |
+
font-weight:bold;
|
160 |
+
}
|
161 |
+
|
162 |
+
p.successcentr
|
163 |
+
{ color:#00DD00;
|
164 |
+
background-color:#DDDDFF;
|
165 |
+
font-weight:bold;
|
166 |
+
text-align:center;
|
167 |
+
}
|
168 |
+
|
169 |
+
td
|
170 |
+
{ background-color:#F8F8F8;
|
171 |
+
text-align:left;
|
172 |
+
}
|
173 |
+
|
174 |
+
td.transparent
|
175 |
+
{ background-color:#FFFFF0;
|
176 |
+
}
|
177 |
+
|
178 |
+
th
|
179 |
+
{ font-weight:bold;
|
180 |
+
color:#FFFFFF;
|
181 |
+
background-color:#AAAAEE;
|
182 |
+
text-align:left;
|
183 |
+
}
|
184 |
+
|
185 |
+
td.right
|
186 |
+
{ text-align:right;
|
187 |
+
}
|
188 |
+
|
189 |
+
form
|
190 |
+
{ margin-top:5px;
|
191 |
+
margin-bottom:5px;
|
192 |
+
}
|
193 |
+
|
194 |
+
div.skin1
|
195 |
+
{
|
196 |
+
border-color:#3333EE;
|
197 |
+
border-width:5px;
|
198 |
+
border-style:solid;
|
199 |
+
background-color:#AAAAEE;
|
200 |
+
text-align:center;
|
201 |
+
vertical-align:middle;
|
202 |
+
padding:3px;
|
203 |
+
margin:1px;
|
204 |
+
}
|
205 |
+
|
206 |
+
td.bg3
|
207 |
+
{ background-color:#EEEE99;
|
208 |
+
text-align:left;
|
209 |
+
vertical-align:top;
|
210 |
+
width:20%;
|
211 |
+
}
|
212 |
+
|
213 |
+
th.bg4
|
214 |
+
{ background-color:#EEAA55;
|
215 |
+
text-align:left;
|
216 |
+
vertical-align:top;
|
217 |
+
width:20%;
|
218 |
+
}
|
219 |
+
|
220 |
+
td.bgpctbar
|
221 |
+
{ background-color:#EEEEAA;
|
222 |
+
text-align:left;
|
223 |
+
vertical-align:middle;
|
224 |
+
width:80%;
|
225 |
+
}
|
226 |
+
|
227 |
+
-->
|
228 |
+
</style>
|
229 |
+
|
230 |
+
</head>
|
231 |
+
|
232 |
+
<body>
|
233 |
+
|
234 |
+
<center>
|
235 |
+
|
236 |
+
<table width="780" cellspacing="0" cellpadding="0">
|
237 |
+
<tr><td class="transparent">
|
238 |
+
|
239 |
+
<!-- <h1>BigDump: Staggered MySQL Dump Importer ver. <?php echo (VERSION); ?></h1> -->
|
240 |
+
|
241 |
+
<?php
|
242 |
+
|
243 |
+
function skin_open() {
|
244 |
+
echo ('<div class="skin1">');
|
245 |
+
}
|
246 |
+
|
247 |
+
function skin_close() {
|
248 |
+
echo ('</div>');
|
249 |
+
}
|
250 |
+
|
251 |
+
skin_open();
|
252 |
+
echo ('<h1>BigDump: Staggered MySQL Dump Importer v'.VERSION.'</h1>');
|
253 |
+
skin_close();
|
254 |
+
|
255 |
+
$error = false;
|
256 |
+
$file = false;
|
257 |
+
|
258 |
+
// Check PHP version
|
259 |
+
|
260 |
+
if (!$error && !function_exists('version_compare'))
|
261 |
+
{ echo ("<p class=\"error\">PHP version 4.1.0 is required for BigDump to proceed. You have PHP ".phpversion()." installed. Sorry!</p>\n");
|
262 |
+
$error=true;
|
263 |
+
}
|
264 |
+
|
265 |
+
// Calculate PHP max upload size (handle settings like 10M or 100K)
|
266 |
+
|
267 |
+
if (!$error)
|
268 |
+
{ $upload_max_filesize=ini_get("upload_max_filesize");
|
269 |
+
if (eregi("([0-9]+)K",$upload_max_filesize,$tempregs)) $upload_max_filesize=$tempregs[1]*1024;
|
270 |
+
if (eregi("([0-9]+)M",$upload_max_filesize,$tempregs)) $upload_max_filesize=$tempregs[1]*1024*1024;
|
271 |
+
if (eregi("([0-9]+)G",$upload_max_filesize,$tempregs)) $upload_max_filesize=$tempregs[1]*1024*1024*1024;
|
272 |
+
}
|
273 |
+
|
274 |
+
// Get the current directory
|
275 |
+
|
276 |
+
if (isset($_SERVER["CGIA"]))
|
277 |
+
$upload_dir=dirname($_SERVER["CGIA"]);
|
278 |
+
else if (isset($_SERVER["ORIG_SCRIPT_FILENAME"]))
|
279 |
+
$upload_dir=dirname($_SERVER["ORIG_SCRIPT_FILENAME"]);
|
280 |
+
else if (isset($_SERVER["PATH_TRANSLATED"]))
|
281 |
+
$upload_dir=dirname($_SERVER["PATH_TRANSLATED"]);
|
282 |
+
else
|
283 |
+
$upload_dir=dirname($_SERVER["SCRIPT_FILENAME"]);
|
284 |
+
|
285 |
+
|
286 |
+
// dprx-modified-start
|
287 |
+
$upload_dir = get_option("bkpwppath");
|
288 |
+
// dprx-modified-end
|
289 |
+
|
290 |
+
|
291 |
+
// Handle file upload
|
292 |
+
|
293 |
+
if (!$error && isset($_REQUEST["uploadbutton"]))
|
294 |
+
{ if (is_uploaded_file($_FILES["dumpfile"]["tmp_name"]) && ($_FILES["dumpfile"]["error"])==0)
|
295 |
+
{
|
296 |
+
$uploaded_filename=str_replace(" ","_",$_FILES["dumpfile"]["name"]);
|
297 |
+
$uploaded_filename=preg_replace("/[^_A-Za-z0-9-\.]/i",'',$uploaded_filename);
|
298 |
+
$uploaded_filepath=str_replace("\\","/",$upload_dir."/".$uploaded_filename);
|
299 |
+
|
300 |
+
if (file_exists($uploaded_filename))
|
301 |
+
{ echo ("<p class=\"error\">File $uploaded_filename already exist! Delete and upload again!</p>\n");
|
302 |
+
}
|
303 |
+
else if (!eregi("(\.(sql|gz|csv))$",$uploaded_filename))
|
304 |
+
{ echo ("<p class=\"error\">You may only upload .sql .gz or .csv files.</p>\n");
|
305 |
+
}
|
306 |
+
else if (!@move_uploaded_file($_FILES["dumpfile"]["tmp_name"],$uploaded_filepath))
|
307 |
+
{ echo ("<p class=\"error\">Error moving uploaded file ".$_FILES["dumpfile"]["tmp_name"]." to the $uploaded_filepath</p>\n");
|
308 |
+
echo ("<p>Check the directory permissions for $upload_dir (must be 777)!</p>\n");
|
309 |
+
}
|
310 |
+
else
|
311 |
+
{ echo ("<p class=\"success\">Uploaded file saved as $uploaded_filename</p>\n");
|
312 |
+
}
|
313 |
+
}
|
314 |
+
else
|
315 |
+
{ echo ("<p class=\"error\">Error uploading file ".$_FILES["dumpfile"]["name"]."</p>\n");
|
316 |
+
}
|
317 |
+
}
|
318 |
+
|
319 |
+
|
320 |
+
// Handle file deletion (delete only in the current directory for security reasons)
|
321 |
+
|
322 |
+
if (!$error && isset($_REQUEST["delete"]) && $_REQUEST["delete"]!=basename($_SERVER["SCRIPT_FILENAME"]))
|
323 |
+
{ if (eregi("(\.(sql|gz|csv))$",$_REQUEST["delete"]) && @unlink(basename($_REQUEST["delete"])))
|
324 |
+
echo ("<p class=\"success\">".$_REQUEST["delete"]." was removed successfully</p>\n");
|
325 |
+
else
|
326 |
+
echo ("<p class=\"error\">Can't remove ".$_REQUEST["delete"]."</p>\n");
|
327 |
+
}
|
328 |
+
|
329 |
+
|
330 |
+
// Connect to the database
|
331 |
+
|
332 |
+
if (!$error && !TESTMODE)
|
333 |
+
{ $dbconnection = @mysql_connect($db_server,$db_username,$db_password);
|
334 |
+
if ($dbconnection)
|
335 |
+
$db = mysql_select_db($db_name);
|
336 |
+
if (!$dbconnection || !$db)
|
337 |
+
{ echo ("<p class=\"error\">Database connection failed due to ".mysql_error()."</p>\n");
|
338 |
+
echo ("<p>Edit the database settings in ".$_SERVER["SCRIPT_FILENAME"]." or contact your database provider</p>\n");
|
339 |
+
$error=true;
|
340 |
+
}
|
341 |
+
if (!$error && $db_connection_charset!=='')
|
342 |
+
@mysql_query("SET NAMES $db_connection_charset", $dbconnection);
|
343 |
+
}
|
344 |
+
else
|
345 |
+
{ $dbconnection = false;
|
346 |
+
}
|
347 |
+
|
348 |
+
|
349 |
+
// List uploaded files in multifile mode
|
350 |
+
|
351 |
+
if (!$error && !isset($_REQUEST["fn"]) && $filename=="")
|
352 |
+
{ if ($dirhandle = opendir($upload_dir))
|
353 |
+
{ $dirhead=false;
|
354 |
+
while (false !== ($dirfile = readdir($dirhandle)))
|
355 |
+
{ if ($dirfile != "." && $dirfile != ".." && $dirfile!=basename($_SERVER["SCRIPT_FILENAME"]))
|
356 |
+
{ if (!$dirhead)
|
357 |
+
{ echo ("<table width=\"100%\" cellspacing=\"2\" cellpadding=\"2\">\n");
|
358 |
+
echo ("<tr><th>Filename</th><th>Size</th><th>Date&Time</th><th>Type</th><th> </th><th> </th>\n");
|
359 |
+
$dirhead=true;
|
360 |
+
}
|
361 |
+
// dprx-modified-start
|
362 |
+
if ($dirfile != "bkpwp_restore.sql") { continue; }
|
363 |
+
// dprx-modified-end
|
364 |
+
|
365 |
+
echo ("<tr><td>$dirfile</td><td class=\"right\">".filesize($dirfile)."</td><td>".date ("Y-m-d H:i:s", filemtime($dirfile))."</td>");
|
366 |
+
|
367 |
+
if (eregi("\.sql$",$dirfile))
|
368 |
+
echo ("<td>SQL</td>");
|
369 |
+
elseif (eregi("\.gz$",$dirfile))
|
370 |
+
echo ("<td>GZip</td>");
|
371 |
+
elseif (eregi("\.csv$",$dirfile))
|
372 |
+
echo ("<td>CSV</td>");
|
373 |
+
else
|
374 |
+
echo ("<td>Misc</td>");
|
375 |
+
|
376 |
+
if ((eregi("\.gz$",$dirfile) && function_exists("gzopen")) || eregi("\.sql$",$dirfile) || eregi("\.csv$",$dirfile))
|
377 |
+
echo ("<td><a href=\"".$_SERVER["PHP_SELF"]."?start=1&fn=$dirfile&foffset=0&totalqueries=0\">Start Import</a> into $db_name at $db_server</td>\n <td><a href=\"".$_SERVER["PHP_SELF"]."?delete=$dirfile\">Delete file</a></td></tr>\n");
|
378 |
+
else
|
379 |
+
echo ("<td> </td>\n <td> </td></tr>\n");
|
380 |
+
}
|
381 |
+
|
382 |
+
}
|
383 |
+
if ($dirhead) echo ("</table>\n");
|
384 |
+
else echo ("<p>No uploaded files found in the working directory</p>\n");
|
385 |
+
closedir($dirhandle);
|
386 |
+
}
|
387 |
+
else
|
388 |
+
{ echo ("<p class=\"error\">Error listing directory $upload_dir</p>\n");
|
389 |
+
$error=true;
|
390 |
+
}
|
391 |
+
}
|
392 |
+
|
393 |
+
|
394 |
+
// Single file mode
|
395 |
+
|
396 |
+
if (!$error && !isset ($_REQUEST["fn"]) && $filename!="")
|
397 |
+
{ echo ("<p><a href=\"".$_SERVER["PHP_SELF"]."?start=1&fn=$filename&foffset=0&totalqueries=0\">Start Import</a> from $filename into $db_name at $db_server</p>\n");
|
398 |
+
}
|
399 |
+
|
400 |
+
|
401 |
+
// File Upload Form
|
402 |
+
|
403 |
+
if (!$error && !isset($_REQUEST["fn"]) && $filename=="")
|
404 |
+
{
|
405 |
+
|
406 |
+
// Test permissions on working directory
|
407 |
+
|
408 |
+
do { $tempfilename=time().".tmp"; } while (file_exists($tempfilename));
|
409 |
+
if (!($tempfile=@fopen($tempfilename,"w")))
|
410 |
+
{ echo ("<p>Upload form disabled. Permissions for the working directory <i>$upload_dir</i> <b>must be set to 777</b> in order ");
|
411 |
+
echo ("to upload files from here. Alternatively you can upload your dump files via FTP.</p>\n");
|
412 |
+
}
|
413 |
+
else
|
414 |
+
{ fclose($tempfile);
|
415 |
+
unlink ($tempfilename);
|
416 |
+
|
417 |
+
echo ("<p>You can now upload your dump file up to $upload_max_filesize bytes (".round ($upload_max_filesize/1024/1024)." Mbytes) ");
|
418 |
+
echo ("directly from your browser to the server. Alternatively you can upload your dump files of any size via FTP.</p>\n");
|
419 |
+
?>
|
420 |
+
<form method="POST" action="<?php echo ($_SERVER["PHP_SELF"]); ?>" enctype="multipart/form-data">
|
421 |
+
<input type="hidden" name="MAX_FILE_SIZE" value="$upload_max_filesize">
|
422 |
+
<p>Dump file: <input type="file" name="dumpfile" accept="*/*" size=60"></p>
|
423 |
+
<p><input type="submit" name="uploadbutton" value="Upload"></p>
|
424 |
+
</form>
|
425 |
+
<?php
|
426 |
+
}
|
427 |
+
}
|
428 |
+
|
429 |
+
// Print the current mySQL connection charset
|
430 |
+
|
431 |
+
if (!$error && !TESTMODE && !isset($_REQUEST["fn"]) && $filename=="")
|
432 |
+
{
|
433 |
+
$result = mysql_query("SHOW VARIABLES LIKE 'character_set_connection';");
|
434 |
+
$row = mysql_fetch_assoc($result);
|
435 |
+
if ($row)
|
436 |
+
{ $charset = $row['Value'];
|
437 |
+
echo ("<p>Note: The current mySQL connection charset is <i>$charset</i>. Your dump file must be encoded in <i>$charset</i> in order to avoid problems with non-latin characters. You can change the connection charset using the \$db_connection_charset variable in bigdump.php</p>\n");
|
438 |
+
}
|
439 |
+
}
|
440 |
+
|
441 |
+
// Open the file
|
442 |
+
|
443 |
+
if (!$error && isset($_REQUEST["fn"]))
|
444 |
+
{
|
445 |
+
|
446 |
+
// Recognize GZip filename
|
447 |
+
|
448 |
+
if (eregi("\.gz$",$_REQUEST["fn"]))
|
449 |
+
$gzipmode=true;
|
450 |
+
else
|
451 |
+
$gzipmode=false;
|
452 |
+
// dprx-modified-start
|
453 |
+
if ((!$gzipmode && !$file=fopen($upload_dir."/".$_REQUEST["fn"],"rt")) || ($gzipmode && !$file=gzopen($upload_dir."/".$_REQUEST["fn"],"rt")))
|
454 |
+
//if ((!$gzipmode && !$file=fopen($_REQUEST["fn"],"rt")) || ($gzipmode && !$file=gzopen($_REQUEST["fn"],"rt")))
|
455 |
+
// dprx-modified-end
|
456 |
+
{ echo ("<p class=\"error\">Can't open ".$_REQUEST["fn"]." for import</p>\n");
|
457 |
+
echo ("<p>Please, check that your dump file name contains only alphanumerical characters, and rename it accordingly, for example: ".
|
458 |
+
$_REQUEST["fn"]." .<br>Or, you have to upload the ".$_REQUEST["fn"]." to the server</p>\n");
|
459 |
+
$error=true;
|
460 |
+
}
|
461 |
+
|
462 |
+
// Get the file size (can't do it fast on gzipped files, no idea how)
|
463 |
+
|
464 |
+
else if ((!$gzipmode && fseek($file, 0, SEEK_END)==0) || ($gzipmode && gzseek($file, 0)==0))
|
465 |
+
{ if (!$gzipmode) $filesize = ftell($file);
|
466 |
+
else $filesize = gztell($file); // Always zero, ignore
|
467 |
+
}
|
468 |
+
else
|
469 |
+
{ echo ("<p class=\"error\">I can't get the filesize of ".$_REQUEST["fn"]."</p>\n");
|
470 |
+
$error=true;
|
471 |
+
}
|
472 |
+
}
|
473 |
+
|
474 |
+
// *******************************************************************************************
|
475 |
+
// START IMPORT SESSION HERE
|
476 |
+
// *******************************************************************************************
|
477 |
+
|
478 |
+
if (!$error && isset($_REQUEST["start"]) && isset($_REQUEST["foffset"]) && eregi("(\.(sql|gz|csv))$",$_REQUEST["fn"]))
|
479 |
+
{
|
480 |
+
|
481 |
+
// Check start and foffset are numeric values
|
482 |
+
|
483 |
+
if (!is_numeric($_REQUEST["start"]) || !is_numeric($_REQUEST["foffset"]))
|
484 |
+
{ echo ("<p class=\"error\">UNEXPECTED: Non-numeric values for start and foffset</p>\n");
|
485 |
+
$error=true;
|
486 |
+
}
|
487 |
+
|
488 |
+
if (!$error)
|
489 |
+
{ $_REQUEST["start"] = floor($_REQUEST["start"]);
|
490 |
+
$_REQUEST["foffset"] = floor($_REQUEST["foffset"]);
|
491 |
+
skin_open();
|
492 |
+
if (TESTMODE)
|
493 |
+
echo ("<p class=\"centr\">TEST MODE ENABLED</p>\n");
|
494 |
+
echo ("<p class=\"centr\">Processing file: <b>".$_REQUEST["fn"]."</b></p>\n");
|
495 |
+
echo ("<p class=\"smlcentr\">Starting from line: ".$_REQUEST["start"]."</p>\n");
|
496 |
+
skin_close();
|
497 |
+
}
|
498 |
+
|
499 |
+
// Check $_REQUEST["foffset"] upon $filesize (can't do it on gzipped files)
|
500 |
+
|
501 |
+
if (!$error && !$gzipmode && $_REQUEST["foffset"]>$filesize)
|
502 |
+
{ echo ("<p class=\"error\">UNEXPECTED: Can't set file pointer behind the end of file</p>\n");
|
503 |
+
$error=true;
|
504 |
+
}
|
505 |
+
|
506 |
+
// Set file pointer to $_REQUEST["foffset"]
|
507 |
+
|
508 |
+
if (!$error && ((!$gzipmode && fseek($file, $_REQUEST["foffset"])!=0) || ($gzipmode && gzseek($file, $_REQUEST["foffset"])!=0)))
|
509 |
+
{ echo ("<p class=\"error\">UNEXPECTED: Can't set file pointer to offset: ".$_REQUEST["foffset"]."</p>\n");
|
510 |
+
$error=true;
|
511 |
+
}
|
512 |
+
|
513 |
+
// Start processing queries from $file
|
514 |
+
|
515 |
+
if (!$error)
|
516 |
+
{ $query="";
|
517 |
+
$queries=0;
|
518 |
+
$totalqueries=$_REQUEST["totalqueries"];
|
519 |
+
$linenumber=$_REQUEST["start"];
|
520 |
+
$querylines=0;
|
521 |
+
$inparents=false;
|
522 |
+
|
523 |
+
// Stay processing as long as the $linespersession is not reached or the query is still incomplete
|
524 |
+
|
525 |
+
while ($linenumber<$_REQUEST["start"]+$linespersession || $query!="")
|
526 |
+
{
|
527 |
+
|
528 |
+
// Read the whole next line
|
529 |
+
|
530 |
+
$dumpline = "";
|
531 |
+
while (!feof($file) && substr ($dumpline, -1) != "\n")
|
532 |
+
{ if (!$gzipmode)
|
533 |
+
$dumpline .= fgets($file, DATA_CHUNK_LENGTH);
|
534 |
+
else
|
535 |
+
$dumpline .= gzgets($file, DATA_CHUNK_LENGTH);
|
536 |
+
}
|
537 |
+
if ($dumpline==="") break;
|
538 |
+
|
539 |
+
|
540 |
+
// Stop if csv file is used, but $csv_insert_table is not set
|
541 |
+
if (($csv_insert_table == "") && (eregi("(\.csv)$",$_REQUEST["fn"])))
|
542 |
+
{
|
543 |
+
echo ("<p class=\"error\">Stopped at the line $linenumber. </p>");
|
544 |
+
echo ('<p>At this place the current query is from csv file, but $csv_insert_table was not set.');
|
545 |
+
echo ("You have to tell where you want to send your data.</p>\n");
|
546 |
+
$error=true;
|
547 |
+
break;
|
548 |
+
}
|
549 |
+
|
550 |
+
// Create an SQL query from CSV line
|
551 |
+
|
552 |
+
if (($csv_insert_table != "") && (eregi("(\.csv)$",$_REQUEST["fn"])))
|
553 |
+
$dumpline = 'INSERT INTO '.$csv_insert_table.' VALUES ('.$dumpline.');';
|
554 |
+
|
555 |
+
// Handle DOS and Mac encoded linebreaks (I don't know if it will work on Win32 or Mac Servers)
|
556 |
+
|
557 |
+
$dumpline=str_replace("\r\n", "\n", $dumpline);
|
558 |
+
$dumpline=str_replace("\r", "\n", $dumpline);
|
559 |
+
|
560 |
+
// DIAGNOSTIC
|
561 |
+
// echo ("<p>Line $linenumber: $dumpline</p>\n");
|
562 |
+
|
563 |
+
// Skip comments and blank lines only if NOT in parents
|
564 |
+
|
565 |
+
if (!$inparents)
|
566 |
+
{ $skipline=false;
|
567 |
+
reset($comment);
|
568 |
+
foreach ($comment as $comment_value)
|
569 |
+
{ if (!$inparents && (trim($dumpline)=="" || strpos ($dumpline, $comment_value) === 0))
|
570 |
+
{ $skipline=true;
|
571 |
+
break;
|
572 |
+
}
|
573 |
+
}
|
574 |
+
if ($skipline)
|
575 |
+
{ $linenumber++;
|
576 |
+
continue;
|
577 |
+
}
|
578 |
+
}
|
579 |
+
|
580 |
+
// Remove double back-slashes from the dumpline prior to count the quotes ('\\' can only be within strings)
|
581 |
+
|
582 |
+
$dumpline_deslashed = str_replace ("\\\\","",$dumpline);
|
583 |
+
|
584 |
+
// Count ' and \' in the dumpline to avoid query break within a text field ending by ;
|
585 |
+
// Please don't use double quotes ('"')to surround strings, it wont work
|
586 |
+
|
587 |
+
$parents=substr_count ($dumpline_deslashed, "'")-substr_count ($dumpline_deslashed, "\\'");
|
588 |
+
if ($parents % 2 != 0)
|
589 |
+
$inparents=!$inparents;
|
590 |
+
|
591 |
+
// Add the line to query
|
592 |
+
|
593 |
+
$query .= $dumpline;
|
594 |
+
|
595 |
+
// Don't count the line if in parents (text fields may include unlimited linebreaks)
|
596 |
+
|
597 |
+
if (!$inparents)
|
598 |
+
$querylines++;
|
599 |
+
|
600 |
+
// Stop if query contains more lines as defined by MAX_QUERY_LINES
|
601 |
+
|
602 |
+
if ($querylines>MAX_QUERY_LINES)
|
603 |
+
{
|
604 |
+
echo ("<p class=\"error\">Stopped at the line $linenumber. </p>");
|
605 |
+
echo ("<p>At this place the current query includes more than ".MAX_QUERY_LINES." dump lines. That can happen if your dump file was ");
|
606 |
+
echo ("created by some tool which doesn't place a semicolon followed by a linebreak at the end of each query, or if your dump contains ");
|
607 |
+
echo ("extended inserts. Please read the BigDump FAQs for more infos.</p>\n");
|
608 |
+
$error=true;
|
609 |
+
break;
|
610 |
+
}
|
611 |
+
|
612 |
+
// Execute query if end of query detected (; as last character) AND NOT in parents
|
613 |
+
|
614 |
+
if (ereg(";$",trim($dumpline)) && !$inparents)
|
615 |
+
{ if (!TESTMODE && !mysql_query(trim($query), $dbconnection))
|
616 |
+
{ echo ("<p class=\"error\">Error at the line $linenumber: ". trim($dumpline)."</p>\n");
|
617 |
+
echo ("<p>Query: ".trim(nl2br(htmlentities($query)))."</p>\n");
|
618 |
+
echo ("<p>MySQL: ".mysql_error()."</p>\n");
|
619 |
+
$error=true;
|
620 |
+
break;
|
621 |
+
}
|
622 |
+
$totalqueries++;
|
623 |
+
$queries++;
|
624 |
+
$query="";
|
625 |
+
$querylines=0;
|
626 |
+
}
|
627 |
+
$linenumber++;
|
628 |
+
}
|
629 |
+
}
|
630 |
+
|
631 |
+
// Get the current file position
|
632 |
+
|
633 |
+
if (!$error)
|
634 |
+
{ if (!$gzipmode)
|
635 |
+
$foffset = ftell($file);
|
636 |
+
else
|
637 |
+
$foffset = gztell($file);
|
638 |
+
if (!$foffset)
|
639 |
+
{ echo ("<p class=\"error\">UNEXPECTED: Can't read the file pointer offset</p>\n");
|
640 |
+
$error=true;
|
641 |
+
}
|
642 |
+
}
|
643 |
+
|
644 |
+
// Print statistics
|
645 |
+
|
646 |
+
skin_open();
|
647 |
+
|
648 |
+
// echo ("<p class=\"centr\"><b>Statistics</b></p>\n");
|
649 |
+
|
650 |
+
if (!$error)
|
651 |
+
{
|
652 |
+
$lines_this = $linenumber-$_REQUEST["start"];
|
653 |
+
$lines_done = $linenumber-1;
|
654 |
+
$lines_togo = ' ? ';
|
655 |
+
$lines_tota = ' ? ';
|
656 |
+
|
657 |
+
$queries_this = $queries;
|
658 |
+
$queries_done = $totalqueries;
|
659 |
+
$queries_togo = ' ? ';
|
660 |
+
$queries_tota = ' ? ';
|
661 |
+
|
662 |
+
$bytes_this = $foffset-$_REQUEST["foffset"];
|
663 |
+
$bytes_done = $foffset;
|
664 |
+
$kbytes_this = round($bytes_this/1024,2);
|
665 |
+
$kbytes_done = round($bytes_done/1024,2);
|
666 |
+
$mbytes_this = round($kbytes_this/1024,2);
|
667 |
+
$mbytes_done = round($kbytes_done/1024,2);
|
668 |
+
|
669 |
+
if (!$gzipmode)
|
670 |
+
{
|
671 |
+
$bytes_togo = $filesize-$foffset;
|
672 |
+
$bytes_tota = $filesize;
|
673 |
+
$kbytes_togo = round($bytes_togo/1024,2);
|
674 |
+
$kbytes_tota = round($bytes_tota/1024,2);
|
675 |
+
$mbytes_togo = round($kbytes_togo/1024,2);
|
676 |
+
$mbytes_tota = round($kbytes_tota/1024,2);
|
677 |
+
|
678 |
+
$pct_this = ceil($bytes_this/$filesize*100);
|
679 |
+
$pct_done = ceil($foffset/$filesize*100);
|
680 |
+
$pct_togo = 100 - $pct_done;
|
681 |
+
$pct_tota = 100;
|
682 |
+
|
683 |
+
if ($bytes_togo==0)
|
684 |
+
{ $lines_togo = '0';
|
685 |
+
$lines_tota = $linenumber-1;
|
686 |
+
$queries_togo = '0';
|
687 |
+
$queries_tota = $totalqueries;
|
688 |
+
}
|
689 |
+
|
690 |
+
$pct_bar = "<div style=\"height:15px;width:$pct_done%;background-color:#000080;margin:0px;\"></div>";
|
691 |
+
}
|
692 |
+
else
|
693 |
+
{
|
694 |
+
$bytes_togo = ' ? ';
|
695 |
+
$bytes_tota = ' ? ';
|
696 |
+
$kbytes_togo = ' ? ';
|
697 |
+
$kbytes_tota = ' ? ';
|
698 |
+
$mbytes_togo = ' ? ';
|
699 |
+
$mbytes_tota = ' ? ';
|
700 |
+
|
701 |
+
$pct_this = ' ? ';
|
702 |
+
$pct_done = ' ? ';
|
703 |
+
$pct_togo = ' ? ';
|
704 |
+
$pct_tota = 100;
|
705 |
+
$pct_bar = str_replace(' ',' ','<tt>[ Not available for gzipped files ]</tt>');
|
706 |
+
}
|
707 |
+
|
708 |
+
echo ("
|
709 |
+
<center>
|
710 |
+
<table width=\"520\" border=\"0\" cellpadding=\"3\" cellspacing=\"1\">
|
711 |
+
<tr><th class=\"bg4\"> </th><th class=\"bg4\">Session</th><th class=\"bg4\">Done</th><th class=\"bg4\">To go</th><th class=\"bg4\">Total</th></tr>
|
712 |
+
<tr><th class=\"bg4\">Lines</th><td class=\"bg3\">$lines_this</td><td class=\"bg3\">$lines_done</td><td class=\"bg3\">$lines_togo</td><td class=\"bg3\">$lines_tota</td></tr>
|
713 |
+
<tr><th class=\"bg4\">Queries</th><td class=\"bg3\">$queries_this</td><td class=\"bg3\">$queries_done</td><td class=\"bg3\">$queries_togo</td><td class=\"bg3\">$queries_tota</td></tr>
|
714 |
+
<tr><th class=\"bg4\">Bytes</th><td class=\"bg3\">$bytes_this</td><td class=\"bg3\">$bytes_done</td><td class=\"bg3\">$bytes_togo</td><td class=\"bg3\">$bytes_tota</td></tr>
|
715 |
+
<tr><th class=\"bg4\">KB</th><td class=\"bg3\">$kbytes_this</td><td class=\"bg3\">$kbytes_done</td><td class=\"bg3\">$kbytes_togo</td><td class=\"bg3\">$kbytes_tota</td></tr>
|
716 |
+
<tr><th class=\"bg4\">MB</th><td class=\"bg3\">$mbytes_this</td><td class=\"bg3\">$mbytes_done</td><td class=\"bg3\">$mbytes_togo</td><td class=\"bg3\">$mbytes_tota</td></tr>
|
717 |
+
<tr><th class=\"bg4\">%</th><td class=\"bg3\">$pct_this</td><td class=\"bg3\">$pct_done</td><td class=\"bg3\">$pct_togo</td><td class=\"bg3\">$pct_tota</td></tr>
|
718 |
+
<tr><th class=\"bg4\">% bar</th><td class=\"bgpctbar\" colspan=\"4\">$pct_bar</td></tr>
|
719 |
+
</table>
|
720 |
+
</center>
|
721 |
+
\n");
|
722 |
+
|
723 |
+
// Finish message and restart the script
|
724 |
+
|
725 |
+
if ($linenumber<$_REQUEST["start"]+$linespersession)
|
726 |
+
{ echo ("<p class=\"successcentr\">Congratulations: End of file reached, assuming OK</p>\n");
|
727 |
+
echo ("<p class=\"centr\">Thank you for using this tool! Please rate <a href=\"http://www.hotscripts.com/Detailed/20922.html\" target=\"_blank\">Bigdump at Hotscripts.com</a></p>\n");
|
728 |
+
echo ("<p class=\"centr\">You can send me some bucks or euros as appreciation <a href=\"http://www.ozerov.de/bigdump.php\" target=\"_blank\">via PayPal</a></p>\n");
|
729 |
+
$error=true;
|
730 |
+
}
|
731 |
+
else
|
732 |
+
{ if ($delaypersession!=0)
|
733 |
+
echo ("<p class=\"centr\">Now I'm <b>waiting $delaypersession milliseconds</b> before starting next session...</p>\n");
|
734 |
+
if (!$ajax)
|
735 |
+
echo ("<script language=\"JavaScript\" type=\"text/javascript\">window.setTimeout('location.href=\"".$_SERVER["PHP_SELF"]."?start=$linenumber&fn=".$_REQUEST["fn"]."&foffset=$foffset&totalqueries=$totalqueries\";',500+$delaypersession);</script>\n");
|
736 |
+
echo ("<noscript>\n");
|
737 |
+
echo ("<p class=\"centr\"><a href=\"".$_SERVER["PHP_SELF"]."?start=$linenumber&fn=".$_REQUEST["fn"]."&foffset=$foffset&totalqueries=$totalqueries\">Continue from the line $linenumber</a> (Enable JavaScript to do it automatically)</p>\n");
|
738 |
+
echo ("</noscript>\n");
|
739 |
+
|
740 |
+
echo ("<p class=\"centr\">Press <b><a href=\"".$_SERVER["PHP_SELF"]."\">STOP</a></b> to abort the import <b>OR WAIT!</b></p>\n");
|
741 |
+
}
|
742 |
+
}
|
743 |
+
else
|
744 |
+
echo ("<p class=\"error\">Stopped on error</p>\n");
|
745 |
+
|
746 |
+
skin_close();
|
747 |
+
|
748 |
+
}
|
749 |
+
|
750 |
+
if ($error)
|
751 |
+
echo ("<p class=\"centr\"><a href=\"".$_SERVER["PHP_SELF"]."\">Start from the beginning</a> (DROP the old tables before restarting)</p>\n");
|
752 |
+
|
753 |
+
if ($dbconnection) mysql_close();
|
754 |
+
if ($file && !$gzipmode) fclose($file);
|
755 |
+
else if ($file && $gzipmode) gzclose($file);
|
756 |
+
|
757 |
+
?>
|
758 |
+
|
759 |
+
<p class="centr">2003-2007 <a href="mailto:alexey@ozerov.de">Alexey Ozerov</a> - <a href="http://www.ozerov.de/bigdump.php" target="_blank">BigDump Home</a></p>
|
760 |
+
|
761 |
+
</td></tr></table>
|
762 |
+
|
763 |
+
</center>
|
764 |
+
|
765 |
+
</body>
|
766 |
+
</html>
|
767 |
+
|
768 |
+
<?php
|
769 |
+
|
770 |
+
// *******************************************************************************************
|
771 |
+
// AJAX functionality starts here
|
772 |
+
// *******************************************************************************************
|
773 |
+
|
774 |
+
// Handle special situations (errors, and finish)
|
775 |
+
|
776 |
+
if ($error)
|
777 |
+
{
|
778 |
+
$out1 = ob_get_contents();
|
779 |
+
ob_end_clean();
|
780 |
+
echo $out1;
|
781 |
+
die;
|
782 |
+
}
|
783 |
+
|
784 |
+
// Creates responses (XML only or web page)
|
785 |
+
|
786 |
+
if (($ajax) && isset($_REQUEST['start']))
|
787 |
+
{
|
788 |
+
if (isset($_REQUEST['ajaxrequest']))
|
789 |
+
{ ob_end_clean();
|
790 |
+
create_xml_response();
|
791 |
+
die;
|
792 |
+
}
|
793 |
+
else
|
794 |
+
{
|
795 |
+
create_ajax_script();
|
796 |
+
}
|
797 |
+
}
|
798 |
+
ob_flush();
|
799 |
+
|
800 |
+
// *******************************************************************************************
|
801 |
+
// AJAX utilities
|
802 |
+
// *******************************************************************************************
|
803 |
+
|
804 |
+
function create_xml_response()
|
805 |
+
{
|
806 |
+
global $linenumber, $foffset, $totalqueries,
|
807 |
+
$lines_this, $lines_done, $lines_togo, $lines_tota,
|
808 |
+
$queries_this, $queries_done, $queries_togo, $queries_tota,
|
809 |
+
$bytes_this, $bytes_done, $bytes_togo, $bytes_tota,
|
810 |
+
$kbytes_this, $kbytes_done, $kbytes_togo, $kbytes_tota,
|
811 |
+
$mbytes_this, $mbytes_done, $mbytes_togo, $mbytes_tota,
|
812 |
+
$pct_this, $pct_done, $pct_togo, $pct_tota,$pct_bar;
|
813 |
+
//echo "Content-type: application/xml; charset='iso-8859-1'";
|
814 |
+
header('Content-Type: application/xml');
|
815 |
+
header('Cache-Control: no-cache');
|
816 |
+
/*
|
817 |
+
echo '<?xml version="1.0"?>'."\n";
|
818 |
+
echo '<root>'."\n";
|
819 |
+
echo 'cos'."\n";
|
820 |
+
echo '</root>'."\n";
|
821 |
+
*/
|
822 |
+
|
823 |
+
echo '<?xml version="1.0" encoding="ISO-8859-1"?>';
|
824 |
+
echo "<root>";
|
825 |
+
// data - for calculations
|
826 |
+
echo "<linenumber>";
|
827 |
+
echo "$linenumber";
|
828 |
+
echo "</linenumber>";
|
829 |
+
echo "<foffset>";
|
830 |
+
echo "$foffset";
|
831 |
+
echo "</foffset>";
|
832 |
+
echo "<fn>";
|
833 |
+
echo '"'.$_REQUEST['fn'].'"';
|
834 |
+
echo "</fn>";
|
835 |
+
echo "<totalqueries>";
|
836 |
+
echo "$totalqueries";
|
837 |
+
echo "</totalqueries>";
|
838 |
+
// results - for form update
|
839 |
+
echo "<elem1>";
|
840 |
+
echo "$lines_this";
|
841 |
+
echo "</elem1>";
|
842 |
+
echo "<elem2>";
|
843 |
+
echo "$lines_done";
|
844 |
+
echo "</elem2>";
|
845 |
+
echo "<elem3>";
|
846 |
+
echo "$lines_togo";
|
847 |
+
echo "</elem3>";
|
848 |
+
echo "<elem4>";
|
849 |
+
echo "$lines_tota";
|
850 |
+
echo "</elem4>";
|
851 |
+
|
852 |
+
echo "<elem5>";
|
853 |
+
echo "$queries_this";
|
854 |
+
echo "</elem5>";
|
855 |
+
echo "<elem6>";
|
856 |
+
echo "$queries_done";
|
857 |
+
echo "</elem6>";
|
858 |
+
echo "<elem7>";
|
859 |
+
echo "$queries_togo";
|
860 |
+
echo "</elem7>";
|
861 |
+
echo "<elem8>";
|
862 |
+
echo "$queries_tota";
|
863 |
+
echo "</elem8>";
|
864 |
+
|
865 |
+
echo "<elem9>";
|
866 |
+
echo "$bytes_this";
|
867 |
+
echo "</elem9>";
|
868 |
+
echo "<elem10>";
|
869 |
+
echo "$bytes_done";
|
870 |
+
echo "</elem10>";
|
871 |
+
echo "<elem11>";
|
872 |
+
echo "$bytes_togo";
|
873 |
+
echo "</elem11>";
|
874 |
+
echo "<elem12>";
|
875 |
+
echo "$bytes_tota";
|
876 |
+
echo "</elem12>";
|
877 |
+
|
878 |
+
echo "<elem13>";
|
879 |
+
echo "$kbytes_this";
|
880 |
+
echo "</elem13>";
|
881 |
+
echo "<elem14>";
|
882 |
+
echo "$kbytes_done";
|
883 |
+
echo "</elem14>";
|
884 |
+
echo "<elem15>";
|
885 |
+
echo "$kbytes_togo";
|
886 |
+
echo "</elem15>";
|
887 |
+
echo "<elem16>";
|
888 |
+
echo "$kbytes_tota";
|
889 |
+
echo "</elem16>";
|
890 |
+
|
891 |
+
echo "<elem17>";
|
892 |
+
echo "$mbytes_this";
|
893 |
+
echo "</elem17>";
|
894 |
+
echo "<elem18>";
|
895 |
+
echo "$mbytes_done";
|
896 |
+
echo "</elem18>";
|
897 |
+
echo "<elem19>";
|
898 |
+
echo "$mbytes_togo";
|
899 |
+
echo "</elem19>";
|
900 |
+
echo "<elem20>";
|
901 |
+
echo "$mbytes_tota";
|
902 |
+
echo "</elem20>";
|
903 |
+
|
904 |
+
echo "<elem21>";
|
905 |
+
echo "$pct_this";
|
906 |
+
echo "</elem21>";
|
907 |
+
echo "<elem22>";
|
908 |
+
echo "$pct_done";
|
909 |
+
echo "</elem22>";
|
910 |
+
echo "<elem23>";
|
911 |
+
echo "$pct_togo";
|
912 |
+
echo "</elem23>";
|
913 |
+
echo "<elem24>";
|
914 |
+
echo "$pct_tota";
|
915 |
+
echo "</elem24>";
|
916 |
+
|
917 |
+
// converting html to normal text
|
918 |
+
$pct_bar = htmlentities($pct_bar);
|
919 |
+
echo "<elem_bar>";
|
920 |
+
echo "$pct_bar";
|
921 |
+
echo "</elem_bar>";
|
922 |
+
|
923 |
+
echo "</root>";
|
924 |
+
|
925 |
+
}
|
926 |
+
|
927 |
+
function create_ajax_script()
|
928 |
+
{
|
929 |
+
global $linenumber, $foffset, $totalqueries, $delaypersession;
|
930 |
+
?>
|
931 |
+
<script type="text/javascript" language="javascript">
|
932 |
+
|
933 |
+
// creates next action url (upload page, or XML response)
|
934 |
+
function get_url(linenumber,fn,foffset,totalqueries) {
|
935 |
+
return "<?php echo $_SERVER['PHP_SELF'] ?>"+
|
936 |
+
"?start="+linenumber+"&fn="+fn+"&foffset="+
|
937 |
+
foffset+"&totalqueries="+totalqueries+"&ajaxrequest=true";
|
938 |
+
}
|
939 |
+
|
940 |
+
// extracts text from XML element (itemname must be unique)
|
941 |
+
function get_xml_data(itemname,xmld) {
|
942 |
+
return xmld.getElementsByTagName(itemname).item(0).firstChild.data;
|
943 |
+
}
|
944 |
+
|
945 |
+
// action url (upload page)
|
946 |
+
var url_request = get_url(<?php echo $linenumber.',"'.$_REQUEST["fn"].'",'.$foffset.','.$totalqueries;?>);
|
947 |
+
var http_request = false;
|
948 |
+
|
949 |
+
function makeRequest(url) {
|
950 |
+
http_request = false;
|
951 |
+
if (window.XMLHttpRequest) {
|
952 |
+
// Mozilla,...
|
953 |
+
http_request = new XMLHttpRequest();
|
954 |
+
if (http_request.overrideMimeType) {
|
955 |
+
http_request.overrideMimeType("text/xml");
|
956 |
+
}
|
957 |
+
} else if (window.ActiveXObject) {
|
958 |
+
// IE
|
959 |
+
try {
|
960 |
+
http_request = new ActiveXObject("Msxml2.XMLHTTP");
|
961 |
+
} catch(e) {
|
962 |
+
try {
|
963 |
+
http_request = new ActiveXObject("Microsoft.XMLHTTP");
|
964 |
+
} catch(e) {}
|
965 |
+
}
|
966 |
+
}
|
967 |
+
if (!http_request) {
|
968 |
+
alert("Cannot create an XMLHTTP instance");
|
969 |
+
return false;
|
970 |
+
}
|
971 |
+
http_request.onreadystatechange = server_response;
|
972 |
+
http_request.open("GET", url, true);
|
973 |
+
http_request.send(null);
|
974 |
+
}
|
975 |
+
|
976 |
+
function server_response()
|
977 |
+
{
|
978 |
+
|
979 |
+
// waiting for correct response
|
980 |
+
if (http_request.readyState != 4)
|
981 |
+
return;
|
982 |
+
if (http_request.status != 200) {
|
983 |
+
alert("Page unavailable, or wrong url!")
|
984 |
+
return;
|
985 |
+
}
|
986 |
+
|
987 |
+
// r = xml response
|
988 |
+
var r = http_request.responseXML;
|
989 |
+
|
990 |
+
//if received not XML but HTML with new page to show
|
991 |
+
if (r.getElementsByTagName('root').length == 0) { //*
|
992 |
+
var text = http_request.responseText;
|
993 |
+
document.open();
|
994 |
+
document.write(text);
|
995 |
+
document.close();
|
996 |
+
return;
|
997 |
+
}
|
998 |
+
|
999 |
+
// update "Starting from line: "
|
1000 |
+
document.getElementsByTagName('p').item(1).innerHTML =
|
1001 |
+
"Starting from line: " +
|
1002 |
+
r.getElementsByTagName('linenumber').item(0).firstChild.nodeValue;
|
1003 |
+
|
1004 |
+
// update table with new values
|
1005 |
+
for(i = 1; i <= 24; i++) {
|
1006 |
+
document.getElementsByTagName('td').item(i).firstChild.data =
|
1007 |
+
get_xml_data('elem'+i,r);
|
1008 |
+
}
|
1009 |
+
|
1010 |
+
// update color bar
|
1011 |
+
document.getElementsByTagName('td').item(25).innerHTML =
|
1012 |
+
r.getElementsByTagName('elem_bar').item(0).firstChild.nodeValue;
|
1013 |
+
|
1014 |
+
// action url (XML response)
|
1015 |
+
url_request = get_url(
|
1016 |
+
get_xml_data('linenumber',r),
|
1017 |
+
get_xml_data('fn',r),
|
1018 |
+
get_xml_data('foffset',r),
|
1019 |
+
get_xml_data('totalqueries',r));
|
1020 |
+
|
1021 |
+
// ask for XML response
|
1022 |
+
window.setTimeout("makeRequest(url_request)",500+<?php echo $delaypersession; ?>);
|
1023 |
+
}
|
1024 |
+
// ask for upload page
|
1025 |
+
window.setTimeout("makeRequest(url_request)",500+<?php echo $delaypersession; ?>);
|
1026 |
+
</script>
|
1027 |
+
<?php
|
1028 |
+
}
|
1029 |
+
|
1030 |
+
?>
|
bkpwp-classes/interface.php
ADDED
@@ -0,0 +1,49 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class BKPWP_INIT {
|
4 |
+
|
5 |
+
function BKPWP_INIT() {
|
6 |
+
}
|
7 |
+
|
8 |
+
function bkpwp_check_prerequisites() {
|
9 |
+
if (!current_user_can('manage bkpwp')) {
|
10 |
+
return false;
|
11 |
+
}
|
12 |
+
|
13 |
+
$bkpwppath = get_option("bkpwppath");
|
14 |
+
if (!is_writable($bkpwppath)) {
|
15 |
+
$notconfigured = 1;
|
16 |
+
}
|
17 |
+
if (!isset($notconfigured)) {
|
18 |
+
return false;
|
19 |
+
} else {
|
20 |
+
return true;
|
21 |
+
}
|
22 |
+
}
|
23 |
+
}
|
24 |
+
|
25 |
+
class BKPWP_INTERFACE {
|
26 |
+
|
27 |
+
function BKPWP_INTERFACE() {
|
28 |
+
}
|
29 |
+
|
30 |
+
function menu() {
|
31 |
+
$init = new BKPWP_INIT();
|
32 |
+
$options = new BKPWP_OPTIONS();
|
33 |
+
if($init->bkpwp_check_prerequisites()) {
|
34 |
+
add_menu_page(__("BackUpWordPress","bkpwp"), __("BackUpWordPress","bkpwp"), 9, 'backupwordpress/backupwordpress.php', 'bkpwp_load_menu_page');
|
35 |
+
add_submenu_page('backupwordpress/backupwordpress.php', __("Options","bkpwp"), __("Options","bkpwp"), 9, 'bkpwp_options', 'bkpwp_load_menu_page' );
|
36 |
+
add_submenu_page('backupwordpress/backupwordpress.php', __("Help","bkpwp"), __("Help","bkpwp"), 9, 'bkpwp_help', 'bkpwp_load_menu_page' );
|
37 |
+
} else {
|
38 |
+
add_menu_page(__("BackUpWordPress","bkpwp"), __("BackUpWordPress","bkpwp"), 9, 'backupwordpress/backupwordpress.php', 'bkpwp_load_menu_page');
|
39 |
+
if(!$options->bkpwp_easy_mode()) {
|
40 |
+
add_submenu_page('backupwordpress/backupwordpress.php', __("Backup Presets","bkpwp"), __("Backup Presets","bkpwp"), 9, 'bkpwp_manage_presets', 'bkpwp_load_menu_page');
|
41 |
+
add_submenu_page('backupwordpress/backupwordpress.php', __("Scheduled Backups","bkpwp"), __("Scheduled Backups","bkpwp"), 9, 'bkpwp_schedule', 'bkpwp_load_menu_page');
|
42 |
+
}
|
43 |
+
add_submenu_page('backupwordpress/backupwordpress.php', __("Options","bkpwp"), __("Options","bkpwp"), 9, 'bkpwp_options', 'bkpwp_load_menu_page' );
|
44 |
+
add_submenu_page('backupwordpress/backupwordpress.php', __("Help","bkpwp"), __("Help","bkpwp"), 9, 'bkpwp_help', 'bkpwp_load_menu_page' );
|
45 |
+
}
|
46 |
+
}
|
47 |
+
}
|
48 |
+
|
49 |
+
?>
|
bkpwp-classes/manage_backups.php
ADDED
@@ -0,0 +1,876 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
|
4 |
+
|
5 |
+
class BKPWP_BACKUP_ARCHIVE {
|
6 |
+
|
7 |
+
function BKPWP_BACKUP_ARCHIVE() {
|
8 |
+
}
|
9 |
+
|
10 |
+
function bkpwp_view_backup_info($backup,$values="") {
|
11 |
+
$ret = "";
|
12 |
+
$backup = base64_decode($backup);
|
13 |
+
$ret .= "<h5>".__("BackUp Archive Path and Filename","bkpwp")."</h5>";
|
14 |
+
$ret .= $backup;
|
15 |
+
$ret .= "<h5>".__("BackUp Logfile","bkpwp")."</h5>";
|
16 |
+
$backuplog = eregi_replace(get_option("bkpwppath"),get_option("bkpwppath")."/logs",$backup).".txt";
|
17 |
+
if (!empty($values)) {
|
18 |
+
$values = array();
|
19 |
+
if(file_exists($backup)) {
|
20 |
+
$values['filesize'] = bkpwp_size_readable(filesize($backup));
|
21 |
+
} else {
|
22 |
+
$values['filesize'] = $backup." ".__("does not exist.","bkpwp");
|
23 |
+
}
|
24 |
+
if(file_exists($backuplog)) {
|
25 |
+
$lines = file($backuplog);
|
26 |
+
foreach($lines as $line_num => $line) {
|
27 |
+
if (eregi("Preset:",$line)) {
|
28 |
+
$p=explode(":",$line);
|
29 |
+
$values['preset'] = $p[1];
|
30 |
+
}
|
31 |
+
if (eregi("Schedule:",$line)) {
|
32 |
+
$values['runby'] = __("scheduled","bkpwp");
|
33 |
+
}
|
34 |
+
}
|
35 |
+
}
|
36 |
+
return $values;
|
37 |
+
}
|
38 |
+
if(file_exists($backuplog)) {
|
39 |
+
$lines = file($backuplog);
|
40 |
+
foreach($lines as $line_num => $line) {
|
41 |
+
$ret .= __("Line","bkpwp")."# ".sprintf("%02d",$line_num)." ".$line."<br />";
|
42 |
+
}
|
43 |
+
} else {
|
44 |
+
$ret = __("BackUpWordPress Logfile does not exist:","bkpwp")." ".$backuplog;
|
45 |
+
}
|
46 |
+
return $ret;
|
47 |
+
}
|
48 |
+
|
49 |
+
function bkpwp_get_backup_row($f,$alternate) {
|
50 |
+
$backup->options = new BKPWP_OPTIONS();
|
51 |
+
$info = new BKPWP_BACKUP_ARCHIVE();
|
52 |
+
$info = $info->bkpwp_view_backup_info(base64_encode($f['file']),1);
|
53 |
+
//if (!file_exists($f['file'])) { return; }
|
54 |
+
$type = $backup->options->bkpwp_get_backup_type($f['filename']);
|
55 |
+
if ($alternate != "new_row") {
|
56 |
+
?>
|
57 |
+
<tr id="bkpwp_manage_backups_row_<?php echo base64_encode($f['file']); ?>" class="bkpwp_manage_backups_row <?php echo $alternate; ?>">
|
58 |
+
<?php
|
59 |
+
}
|
60 |
+
?>
|
61 |
+
<th scope="row"><?php
|
62 |
+
echo date(get_option('date_format'),filemtime($f['file']))." ".date("H:i",filemtime($f['file']));
|
63 |
+
?></th>
|
64 |
+
<?php if (!$backup->options->bkpwp_easy_mode()) { ?>
|
65 |
+
<td>
|
66 |
+
<?php
|
67 |
+
echo " <b>".$type."</b>";
|
68 |
+
?>
|
69 |
+
</td>
|
70 |
+
<td>
|
71 |
+
<?php
|
72 |
+
echo " <b>".$info['preset']."</b>";
|
73 |
+
if (!empty($info['runby'])) {
|
74 |
+
echo " - ".$info['runby'];
|
75 |
+
}
|
76 |
+
?>
|
77 |
+
</td>
|
78 |
+
<?php } ?>
|
79 |
+
<td>
|
80 |
+
<?php
|
81 |
+
echo bkpwp_size_readable(filesize($f['file']))."";
|
82 |
+
?>
|
83 |
+
</td>
|
84 |
+
<td style="text-align: center;">
|
85 |
+
<?php
|
86 |
+
echo " <a href=\"admin.php?page=backupwordpress/backupwordpress.php&bkpwp_download=".base64_encode($f['file'])."\">".__("download","bkpwp")."</a>";
|
87 |
+
?>
|
88 |
+
</td>
|
89 |
+
<?php if (!$backup->options->bkpwp_easy_mode()) { ?>
|
90 |
+
<td style="text-align: center;">
|
91 |
+
<?php
|
92 |
+
echo " <a href=\"javascript:void(0)\"
|
93 |
+
onclick=\"bkpwp_js_loading('".__("View Backup Information","bkpwp")."');
|
94 |
+
sajax_target_id = 'bkpwp_action_buffer';
|
95 |
+
x_bkpwp_ajax_view_backup('".base64_encode($f['file'])."','');
|
96 |
+
sajax_target_id = '';\">".__("view","bkpwp")."</a>";
|
97 |
+
?>
|
98 |
+
</td>
|
99 |
+
<td style="text-align: center;">
|
100 |
+
<?php
|
101 |
+
echo " <a href=\"admin.php?page=backupwordpress/backupwordpress.php&bkpwp_mail=".base64_encode($f['file'])."\">".__("mail","bkpwp")."</a>";
|
102 |
+
?>
|
103 |
+
</td>
|
104 |
+
<?php } ?>
|
105 |
+
<td style="text-align: center;">
|
106 |
+
<?php
|
107 |
+
echo " <a href=\"admin.php?page=backupwordpress/backupwordpress.php&bkpwp_restore=".base64_encode($f['file'])."\">".__("restore","bkpwp")."</a>";
|
108 |
+
?>
|
109 |
+
</td>
|
110 |
+
<?php if (!$backup->options->bkpwp_easy_mode()) { ?>
|
111 |
+
<td style="text-align: center;">
|
112 |
+
<?php
|
113 |
+
echo " <a href=\"admin.php?page=backupwordpress/backupwordpress.php&bkpwp_delete=".base64_encode($f['file'])."\">".__("delete","bkpwp")."</a>";
|
114 |
+
?>
|
115 |
+
</td>
|
116 |
+
<?php } ?>
|
117 |
+
<?php
|
118 |
+
if ($alternate != "new_row") {
|
119 |
+
?>
|
120 |
+
</tr>
|
121 |
+
<?php
|
122 |
+
}
|
123 |
+
}
|
124 |
+
|
125 |
+
}
|
126 |
+
|
127 |
+
class BKPWP_BACKUP {
|
128 |
+
|
129 |
+
function BKPWP_BACKUP() {
|
130 |
+
}
|
131 |
+
|
132 |
+
function bkpwp_backquote($a_name)
|
133 |
+
{
|
134 |
+
/*
|
135 |
+
Add backqouotes to tables and db-names in
|
136 |
+
SQL queries. Taken from phpMyAdmin.
|
137 |
+
*/
|
138 |
+
if (!empty($a_name) && $a_name != '*') {
|
139 |
+
if (is_array($a_name)) {
|
140 |
+
$result = array();
|
141 |
+
reset($a_name);
|
142 |
+
while(list($key, $val) = each($a_name)) {
|
143 |
+
$result[$key] = '`' . $val . '`';
|
144 |
+
}
|
145 |
+
return $result;
|
146 |
+
} else {
|
147 |
+
return '`' . $a_name . '`';
|
148 |
+
}
|
149 |
+
} else {
|
150 |
+
return $a_name;
|
151 |
+
}
|
152 |
+
} // function backquote($a_name, $do_it = TRUE)
|
153 |
+
|
154 |
+
function bkpwp_make_sql($table,$log)
|
155 |
+
{
|
156 |
+
/*
|
157 |
+
Reads the Database table in $table and creates
|
158 |
+
SQL Statements for recreating structure and data
|
159 |
+
Taken partially from phpMyAdmin and partially from
|
160 |
+
Alain Wolf, Zurich - Switzerland
|
161 |
+
Website: http://restkultur.ch/personal/wolf/scripts/db_backup/
|
162 |
+
*/
|
163 |
+
|
164 |
+
$sql_statements = "";
|
165 |
+
|
166 |
+
// Add SQL statement to drop existing table
|
167 |
+
$sql_statements .= "\n";
|
168 |
+
$sql_statements .= "\n";
|
169 |
+
$sql_statements .= "#\n";
|
170 |
+
$sql_statements .= "# Delete any existing table " . $this->bkpwp_backquote($table) . "\n";
|
171 |
+
$sql_statements .= "#\n";
|
172 |
+
$sql_statements .= "\n";
|
173 |
+
$sql_statements .= "DROP TABLE IF EXISTS " . $this->bkpwp_backquote($table) . ";\n";
|
174 |
+
|
175 |
+
// Table structure
|
176 |
+
|
177 |
+
// Comment in SQL-file
|
178 |
+
$sql_statements .= "\n";
|
179 |
+
$sql_statements .= "\n";
|
180 |
+
$sql_statements .= "#\n";
|
181 |
+
$sql_statements .= "# Table structure of table " . $this->bkpwp_backquote($table) . "\n";
|
182 |
+
$sql_statements .= "#\n";
|
183 |
+
$sql_statements .= "\n";
|
184 |
+
|
185 |
+
// Get table structure
|
186 |
+
$query = "SHOW CREATE TABLE " . $this->bkpwp_backquote($table);
|
187 |
+
$result = mysql_query($query, $GLOBALS["db_connect"]);
|
188 |
+
if ($result == FALSE) {
|
189 |
+
$log['logfile'][] = $this->bkpwp_logtimestamp().": ".__("Error getting table structure of ","bkpwp").$table."! ".mysql_errno() . ": " . mysql_error()." ".$this->bkpwp_logtimestamp();
|
190 |
+
$this->bkpwp_write_log($log);
|
191 |
+
} else {
|
192 |
+
if (mysql_num_rows($result) > 0) {
|
193 |
+
$sql_create_arr = mysql_fetch_array($result);
|
194 |
+
$sql_statements .= $sql_create_arr[1];
|
195 |
+
}
|
196 |
+
mysql_free_result($result);
|
197 |
+
$sql_statements .= " ;";
|
198 |
+
} // ($result == FALSE)
|
199 |
+
|
200 |
+
// Table data contents
|
201 |
+
|
202 |
+
// Get table contents
|
203 |
+
$query = "SELECT * FROM " . $this->bkpwp_backquote($table);
|
204 |
+
$result = mysql_query($query, $GLOBALS["db_connect"]);
|
205 |
+
if ($result == FALSE) {
|
206 |
+
$log['logfile'][] = $this->bkpwp_logtimestamp().": ".__("Error getting records of ","bkpwp").$table."! ".mysql_errno() . ": " . mysql_error()." ".$this->bkpwp_logtimestamp();
|
207 |
+
$this->bkpwp_write_log($log);
|
208 |
+
} else {
|
209 |
+
$fields_cnt = mysql_num_fields($result);
|
210 |
+
$rows_cnt = mysql_num_rows($result);
|
211 |
+
} // if ($result == FALSE)
|
212 |
+
|
213 |
+
// Comment in SQL-file
|
214 |
+
$sql_statements .= "\n";
|
215 |
+
$sql_statements .= "\n";
|
216 |
+
$sql_statements .= "#\n";
|
217 |
+
$sql_statements .= "# Data contents of table " . $table . " (" . $rows_cnt . " records)\n";
|
218 |
+
$sql_statements .= "#\n";
|
219 |
+
|
220 |
+
// Checks whether the field is an integer or not
|
221 |
+
for ($j = 0; $j < $fields_cnt; $j++) {
|
222 |
+
$field_set[$j] = $this->bkpwp_backquote(mysql_field_name($result, $j));
|
223 |
+
$type = mysql_field_type($result, $j);
|
224 |
+
if ($type == 'tinyint' || $type == 'smallint' || $type == 'mediumint' || $type == 'int' ||
|
225 |
+
$type == 'bigint' ||$type == 'timestamp') {
|
226 |
+
$field_num[$j] = TRUE;
|
227 |
+
} else {
|
228 |
+
$field_num[$j] = FALSE;
|
229 |
+
}
|
230 |
+
} // end for
|
231 |
+
|
232 |
+
// Sets the scheme
|
233 |
+
$entries = 'INSERT INTO ' . $this->bkpwp_backquote($table) . ' VALUES (';
|
234 |
+
$search = array("\x00", "\x0a", "\x0d", "\x1a"); //\x08\\x09, not required
|
235 |
+
$replace = array('\0', '\n', '\r', '\Z');
|
236 |
+
$current_row = 0;
|
237 |
+
while ($row = mysql_fetch_row($result)) {
|
238 |
+
$current_row++;
|
239 |
+
for ($j = 0; $j < $fields_cnt; $j++) {
|
240 |
+
if (!isset($row[$j])) {
|
241 |
+
$values[] = 'NULL';
|
242 |
+
} else if ($row[$j] == '0' || $row[$j] != '') {
|
243 |
+
// a number
|
244 |
+
if ($field_num[$j]) {
|
245 |
+
$values[] = $row[$j];
|
246 |
+
}
|
247 |
+
else {
|
248 |
+
$values[] = "'" . str_replace($search, $replace, $this->bkpwp_sql_addslashes($row[$j])) . "'";
|
249 |
+
} //if ($field_num[$j])
|
250 |
+
} else {
|
251 |
+
$values[] = "''";
|
252 |
+
} // if (!isset($row[$j]))
|
253 |
+
} // for ($j = 0; $j < $fields_cnt; $j++)
|
254 |
+
$sql_statements .= " \n" . $entries . implode(', ', $values) . ') ;';
|
255 |
+
unset($values);
|
256 |
+
} // while ($row = mysql_fetch_row($result))
|
257 |
+
mysql_free_result($result);
|
258 |
+
|
259 |
+
// Create footer/closing comment in SQL-file
|
260 |
+
$sql_statements .= "\n";
|
261 |
+
$sql_statements .= "#\n";
|
262 |
+
$sql_statements .= "# End of data contents of table " . $table . "\n";
|
263 |
+
$sql_statements .= "# --------------------------------------------------------\n";
|
264 |
+
$sql_statements .= "\n";
|
265 |
+
return $sql_statements;
|
266 |
+
} //function make_sql($table)
|
267 |
+
|
268 |
+
function bkpwp_sql_addslashes($a_string = '', $is_like = FALSE)
|
269 |
+
{
|
270 |
+
/*
|
271 |
+
Better addslashes for SQL queries.
|
272 |
+
Taken from phpMyAdmin.
|
273 |
+
*/
|
274 |
+
if ($is_like) {
|
275 |
+
$a_string = str_replace('\\', '\\\\\\\\', $a_string);
|
276 |
+
} else {
|
277 |
+
$a_string = str_replace('\\', '\\\\', $a_string);
|
278 |
+
}
|
279 |
+
$a_string = str_replace('\'', '\\\'', $a_string);
|
280 |
+
|
281 |
+
return $a_string;
|
282 |
+
} // function sql_addslashes($a_string = '', $is_like = FALSE)
|
283 |
+
|
284 |
+
function bkpwp_mysql($path,$log) {
|
285 |
+
if (!$GLOBALS['db_connect'] = @mysql_pconnect(DB_HOST, DB_USER, DB_PASSWORD)) {
|
286 |
+
$log['logfile'][] = $this->bkpwp_logtimestamp().": ".__("Could not connect to MySQL server! ","bkpwp"). mysql_error()." ".$this->bkpwp_logtimestamp();
|
287 |
+
$this->bkpwp_write_log($log);
|
288 |
+
}
|
289 |
+
$log['logfile'][] = $this->bkpwp_logtimestamp().": ".__("MySQL server connected successfully ","bkpwp")." ".$this->bkpwp_logtimestamp();
|
290 |
+
$this->bkpwp_write_log($log);
|
291 |
+
mysql_select_db(DB_NAME,$GLOBALS['db_connect']);
|
292 |
+
$file_name = "wordpress.sql";
|
293 |
+
//Begin new backup of MySql
|
294 |
+
$tables = mysql_list_tables(DB_NAME);
|
295 |
+
if (!isset($tables) > 0) {
|
296 |
+
$log['logfile'][] = $this->bkpwp_logtimestamp().": ".__("Could not select db ","bkpwp").DB_NAME." ".$this->bkpwp_logtimestamp();
|
297 |
+
$this->bkpwp_write_log($log);
|
298 |
+
}
|
299 |
+
$sql_file = "# WordPress : ".get_bloginfo("url")." MySQL database backup\n";
|
300 |
+
$sql_file .= "#\n";
|
301 |
+
$sql_file .= "# Generated: " . date("l j. F Y H:i T") . "\n";
|
302 |
+
$sql_file .= "# Hostname: " . DB_HOST . "\n";
|
303 |
+
$sql_file .= "# Database: " . $this->bkpwp_backquote(DB_NAME) . "\n";
|
304 |
+
$sql_file .= "# --------------------------------------------------------\n";
|
305 |
+
for ($i = 0; $i < mysql_num_rows($tables); $i++) {
|
306 |
+
$curr_table = mysql_tablename($tables, $i);
|
307 |
+
// Increase script execution time-limit to 15 min for every table.
|
308 |
+
if ( !ini_get('safe_mode')) @set_time_limit(15*60);
|
309 |
+
// Create the SQL statements
|
310 |
+
$sql_file .= "# --------------------------------------------------------\n";
|
311 |
+
$sql_file .= "# Table: " . $this->bkpwp_backquote($curr_table) . "\n";
|
312 |
+
$sql_file .= "# --------------------------------------------------------\n";
|
313 |
+
$sql_file .= $this->bkpwp_make_sql($curr_table,$log);
|
314 |
+
}
|
315 |
+
$cachefp = fopen($path."/".$file_name, "w");
|
316 |
+
fwrite($cachefp, $sql_file);
|
317 |
+
if (file_exists($path."/".$file_name)) {
|
318 |
+
$log['logfile'][] = $this->bkpwp_logtimestamp().": ".$path."/".$file_name." created ".$this->bkpwp_logtimestamp();
|
319 |
+
$this->bkpwp_write_log($log);
|
320 |
+
return true;
|
321 |
+
} else {
|
322 |
+
$log['logfile'][] = $this->bkpwp_logtimestamp().": ".$path."/".$file_name." could not be created ".$this->bkpwp_logtimestamp();
|
323 |
+
$this->bkpwp_write_log($log);
|
324 |
+
}
|
325 |
+
return false;
|
326 |
+
}
|
327 |
+
|
328 |
+
function bkpwp_calculate($preset) {
|
329 |
+
if ($preset['bkpwp_preset_options']['bkpwp_sql_only'] == 1) {
|
330 |
+
$ret = "<p>".__("Database Only Backup with this Preset. No Disk Files will be backed up.","bkpwp")."</p>";
|
331 |
+
return $ret;
|
332 |
+
}
|
333 |
+
$options = new BKPWP_OPTIONS();
|
334 |
+
clearstatcache(); //get rid of cached filesizes...
|
335 |
+
$dir = bkpwp_conform_dir(ABSPATH);
|
336 |
+
$options->excludelist = $preset['bkpwp_preset_options']['bkpwp_excludelist'];
|
337 |
+
$files = $options->bkpwp_ls($dir);
|
338 |
+
$filesize = 0;
|
339 |
+
foreach($files as $f) {
|
340 |
+
$str = bkpwp_conform_dir($f,true);
|
341 |
+
$thisf = filesize($f);
|
342 |
+
$filesize = $filesize+$thisf;
|
343 |
+
//echo $str.": ".bkpwp_size_readable($thisf)." (".bkpwp_size_readable($filesize).")\\n";
|
344 |
+
}
|
345 |
+
update_option("bkpwp_calculation",bkpwp_size_readable($filesize));
|
346 |
+
$ret = "<p>".__("Your Wordpress files backuped with preset","bkpwp")." <b>".$preset['bkpwp_preset_name']."</b> ".__(" use","bkpwp")." ";
|
347 |
+
$ret .= "<b>".bkpwp_size_readable($filesize)."</b> ".__("of disk space.","bkpwp")."<br />";
|
348 |
+
$ret .= "".__("Depending on the type of these files, the resulting Backup Archive filesize can be reduced by more than 70%.","bkpwp")."</p>";
|
349 |
+
return $ret;
|
350 |
+
}
|
351 |
+
|
352 |
+
function bkpwp_logtimestamp() {
|
353 |
+
return date(get_option('date_format'))." ".date("H:i:s");
|
354 |
+
}
|
355 |
+
|
356 |
+
function bkpwp_do_backup($preset) {
|
357 |
+
$options = new BKPWP_OPTIONS();
|
358 |
+
$log = array();
|
359 |
+
// get the desired archive type from preset
|
360 |
+
$type = $preset['bkpwp_preset_options']['bkpwp_archive_type'];
|
361 |
+
$sqlonly = $preset['bkpwp_preset_options']['bkpwp_sql_only'];
|
362 |
+
$options->excludelist = $preset['bkpwp_preset_options']['bkpwp_excludelist'];
|
363 |
+
|
364 |
+
$datestamp = date("Y-m-d-H-i-s");
|
365 |
+
// temporary directory name
|
366 |
+
$backup_tmp_dir = get_option("bkpwppath")."/".$datestamp;
|
367 |
+
|
368 |
+
// filename for the backup archive
|
369 |
+
if ($sqlonly == 1) {
|
370 |
+
$backup_filename .= "-sql";
|
371 |
+
} else {
|
372 |
+
$backup_filename .= "-full";
|
373 |
+
}
|
374 |
+
|
375 |
+
$backup_filename .= ".".$type;
|
376 |
+
$backup_filename_short = $datestamp.$backup_filename;
|
377 |
+
$backup_filename = $backup_tmp_dir.$backup_filename;
|
378 |
+
$log['filename'] = $backup_filename_short;
|
379 |
+
$log['logfile'] = array();
|
380 |
+
$log['preset'] = $preset['bkpwp_preset_name'];
|
381 |
+
$log['schedule'] = $preset['bkpwp_schedule'];
|
382 |
+
$time_start = microtime(true);
|
383 |
+
|
384 |
+
// count milliseconds
|
385 |
+
$log['logfile'][] = $this->bkpwp_logtimestamp().": ".__("BackUpWordPress starting at","bkpwp")." ".$this->bkpwp_logtimestamp();
|
386 |
+
|
387 |
+
// create a temporary directory
|
388 |
+
if (!is_dir($backup_tmp_dir)) {
|
389 |
+
if (!mkdir($backup_tmp_dir)) {
|
390 |
+
$log['logfile'][] = $this->bkpwp_logtimestamp().": ".__("BackUpWordPress temporary Directory","bkpwp")." '".$backup_tmp_dir."' ".__("could not be created","bkpwp");
|
391 |
+
} else {
|
392 |
+
$log['logfile'][] = $this->bkpwp_logtimestamp().": ".__("BackUpWordPress temporary Directory","bkpwp")." '".$backup_tmp_dir."' ".__("created","bkpwp");
|
393 |
+
}
|
394 |
+
}
|
395 |
+
$this->bkpwp_write_log($log);
|
396 |
+
if ($sqlonly != 1) {
|
397 |
+
// subdirectory of wordpress files
|
398 |
+
$wordpress_files = $backup_tmp_dir."/wordpress_files";
|
399 |
+
if (!is_dir($wordpress_files)) {
|
400 |
+
if (!mkdir($wordpress_files)) {
|
401 |
+
$log['logfile'][] = $this->bkpwp_logtimestamp().": ".__("BackUpWordPress temporary Directory","bkpwp")." '".$wordpress_files."' ".__("could not be created","bkpwp");
|
402 |
+
} else {
|
403 |
+
$log['logfile'][] = $this->bkpwp_logtimestamp().": ".__("BackUpWordPress temporary Directory","bkpwp")." '".$wordpress_files."' ".__("created","bkpwp");
|
404 |
+
}
|
405 |
+
$this->bkpwp_write_log($log);
|
406 |
+
}
|
407 |
+
}
|
408 |
+
|
409 |
+
$db_dump = $this->bkpwp_mysql($backup_tmp_dir,$log);
|
410 |
+
|
411 |
+
if(!$db_dump) {
|
412 |
+
$log['logfile'][] = $this->bkpwp_logtimestamp().": ".__("SQL Dump could not be created.","bkpwp");
|
413 |
+
} else {
|
414 |
+
$log['logfile'][] = $this->bkpwp_logtimestamp().": ".__("SQL Dump created.","bkpwp");
|
415 |
+
}
|
416 |
+
$this->bkpwp_write_log($log);
|
417 |
+
if ($sqlonly != 1) {
|
418 |
+
// create a temporary directory of files to backup
|
419 |
+
$dir = bkpwp_conform_dir(ABSPATH);
|
420 |
+
$files = $options->bkpwp_ls($dir);
|
421 |
+
$files_copied = 0;
|
422 |
+
$subdirs_created = 0;
|
423 |
+
$i=1; // the sql at least
|
424 |
+
foreach ($files as $f) {
|
425 |
+
if (is_dir($f)) {
|
426 |
+
if (!mkdir($wordpress_files.bkpwp_conform_dir($f, true))) {
|
427 |
+
return __("Failed to make directory","bkpwp");
|
428 |
+
} else {
|
429 |
+
$subdirs_created++;
|
430 |
+
}
|
431 |
+
} elseif(file_exists($f)) {
|
432 |
+
if (!copy($f,$wordpress_files.bkpwp_conform_dir($f, true))) {
|
433 |
+
return __("Failed to copy","bkpwp");
|
434 |
+
} else {
|
435 |
+
$files_copied++;
|
436 |
+
}
|
437 |
+
}
|
438 |
+
$i++;
|
439 |
+
}
|
440 |
+
$log['logfile'][] = $this->bkpwp_logtimestamp().": ".$subdirs_created." ".__("Temporary Subdirectories copied sucessfully","bkpwp");
|
441 |
+
$log['logfile'][] = $this->bkpwp_logtimestamp().": ".$files_copied." ".__("Temporary Files copied sucessfully","bkpwp");
|
442 |
+
}
|
443 |
+
// create backup archive file
|
444 |
+
$archive_backup = new File_Archive();
|
445 |
+
$archive_backup->setOption("tmpDirectory",get_option("bkpwppath"));
|
446 |
+
$archive_backup->extract($backup_tmp_dir,File_Archive::toArchive($backup_filename, File_Archive::toFiles()));
|
447 |
+
if (!file_exists($backup_filename)) {
|
448 |
+
return __("Failed to create backup archive","bkpwp");
|
449 |
+
} else {
|
450 |
+
$log['logfile'][] = $this->bkpwp_logtimestamp().": ".__("Archive File created/compressed successfully:","bkpwp")." ".$backup_filename;
|
451 |
+
}
|
452 |
+
|
453 |
+
$deleted_files_count = $this->bkpwp_rmdirtree($backup_tmp_dir);
|
454 |
+
$log['logfile'][] = $this->bkpwp_logtimestamp().": ".count($deleted_files_count)." ".__("Temporary Directories and Files deleted successfully","bkpwp");
|
455 |
+
$deleted_oldarchives_count = $this->bkpwp_delete_old();
|
456 |
+
if ($deleted_oldarchives_count > 0) {
|
457 |
+
$log['logfile'][] = $this->bkpwp_logtimestamp().": ".$deleted_oldarchives_count." ".__("Old BackUpWordPress Archives deleted successfully","bkpwp");
|
458 |
+
} else {
|
459 |
+
$log['logfile'][] = $this->bkpwp_logtimestamp().": ".__("No old BackUpWordPress Archives to delete","bkpwp");
|
460 |
+
}
|
461 |
+
|
462 |
+
|
463 |
+
$time_end = microtime(true);
|
464 |
+
$time = $time_end - $time_start;
|
465 |
+
$log['logfile'][] = $this->bkpwp_logtimestamp().": ".__("BackUpWordPress done at","bkpwp")." ".$this->bkpwp_logtimestamp();
|
466 |
+
$log['logfile'][] = $this->bkpwp_logtimestamp().": ".__("BackUpWordPress was running for","bkpwp")." ".round($time,2)." ".__("Seconds","bkpwp");
|
467 |
+
|
468 |
+
// write the log
|
469 |
+
$this->bkpwp_write_log($log);
|
470 |
+
$backup = array("file" => $backup_filename,
|
471 |
+
"filename" => $backup_filename_short);
|
472 |
+
// start the output
|
473 |
+
$backuprow = new BKPWP_BACKUP_ARCHIVE();
|
474 |
+
ob_start();
|
475 |
+
$backuprow->bkpwp_get_backup_row($backup,"new_row");
|
476 |
+
$out = ob_get_contents();
|
477 |
+
ob_end_clean();
|
478 |
+
|
479 |
+
// mail it if bkpwp_automail is set
|
480 |
+
$bkpwp_automail = get_option("bkpwp_automail");
|
481 |
+
$bkpwp_automail_maxsize = get_option("bkpwp_automail_maxsize");
|
482 |
+
if (!empty($bkpwp_automail)) {
|
483 |
+
$allowed_bytes = $bkpwp_automail_maxsize*1024*1024;
|
484 |
+
$logdump = nl2br($this->bkpwp_write_log($log,1));
|
485 |
+
$logdump .= $allowed_bytes.":".filesize($backup_filename)." - ".$backup_filename."<br />\n";
|
486 |
+
if ($this->is_readable_for_mailout($backup_filename)) {
|
487 |
+
$logdump .= "Backup file is readable.<br />\n";
|
488 |
+
}
|
489 |
+
if ($allowed_bytes >= filesize($backup_filename)) {
|
490 |
+
bkpwp_mail_now(base64_encode($backup_filename), $logdump);
|
491 |
+
} else {
|
492 |
+
bkpwp_mail_now("", $logdump);
|
493 |
+
}
|
494 |
+
}
|
495 |
+
// send autput
|
496 |
+
return $out;
|
497 |
+
}
|
498 |
+
|
499 |
+
function is_readable_for_mailout($file,$count=0) {
|
500 |
+
if ($count > 24) {
|
501 |
+
return false;
|
502 |
+
}
|
503 |
+
if (!is_readable($file)) {
|
504 |
+
$count++;
|
505 |
+
sleep(2);
|
506 |
+
is_readable_for_mailout($file,$count);
|
507 |
+
}
|
508 |
+
return true;
|
509 |
+
}
|
510 |
+
|
511 |
+
//Since looks like the Windows ACLs bug "wont fix" (see http://bugs.php.net/bug.php?id=27609)
|
512 |
+
function is__writable($path) {
|
513 |
+
|
514 |
+
if ($path{strlen($path)-1}=='/')
|
515 |
+
return $this->is__writable($path.uniqid(mt_rand()).'.tmp');
|
516 |
+
|
517 |
+
if (file_exists($path)) {
|
518 |
+
if (!($f = @fopen($path, 'r+')))
|
519 |
+
return false;
|
520 |
+
fclose($f);
|
521 |
+
return true;
|
522 |
+
}
|
523 |
+
|
524 |
+
if (!($f = @fopen($path, 'w')))
|
525 |
+
return false;
|
526 |
+
fclose($f);
|
527 |
+
unlink($path);
|
528 |
+
return true;
|
529 |
+
}
|
530 |
+
|
531 |
+
function bkpwp_write_log($log,$return="") {
|
532 |
+
if (!is_array($log)) { return; }
|
533 |
+
$logdir = get_option("bkpwppath")."/logs";
|
534 |
+
if (!is_dir($logdir)) {
|
535 |
+
mkdir($logdir);
|
536 |
+
}
|
537 |
+
$logname = $logdir."/".$log['filename'].".txt";
|
538 |
+
$logfile = "";
|
539 |
+
$logfile .= "Preset: ".$log['preset']."\n";
|
540 |
+
if (!empty($log['schedule'])) {
|
541 |
+
$logfile .= "Schedule: ".$log['schedule']."\n";
|
542 |
+
}
|
543 |
+
if (is_array($log['logfile'])) {
|
544 |
+
foreach($log['logfile'] as $l) {
|
545 |
+
if (is_array($l)) { $l = serialize($l);}
|
546 |
+
$logfile .= "## ".$l."\n";
|
547 |
+
}
|
548 |
+
if (!empty($return)) {
|
549 |
+
return $logfile;
|
550 |
+
}
|
551 |
+
// actually write the log
|
552 |
+
if ($this->is__writable($logname)) {
|
553 |
+
if (!$handle = fopen($logname, "a")) {
|
554 |
+
return __("Logfile could not be opened for writing: ","bkpwp").$logname;
|
555 |
+
exit;
|
556 |
+
}
|
557 |
+
if (!fwrite($handle, $logfile)) {
|
558 |
+
return __("Logfile not writable: ","bkpwp").$logname;
|
559 |
+
exit;
|
560 |
+
}
|
561 |
+
fclose($handle);
|
562 |
+
return true;
|
563 |
+
} else {
|
564 |
+
return __("Logfile not writable: ","bkpwp").$logname;
|
565 |
+
}
|
566 |
+
}
|
567 |
+
}
|
568 |
+
|
569 |
+
function bkpwp_rmdirtree($dirname) {
|
570 |
+
if (!eregi(bkpwp_conform_dir(ABSPATH),bkpwp_conform_dir($dirname))) {
|
571 |
+
return;
|
572 |
+
}
|
573 |
+
if (is_dir($dirname)) { //Operate on dirs only
|
574 |
+
$result=array();
|
575 |
+
if (substr($dirname,-1)!='/') {$dirname.='/';} //Append slash if necessary
|
576 |
+
$handle = opendir($dirname);
|
577 |
+
while (false !== ($file = readdir($handle))) {
|
578 |
+
if ($file!='.' && $file!= '..') { //Ignore . and ..
|
579 |
+
$path = $dirname.$file;
|
580 |
+
if (is_dir($path)) { //Recurse if subdir, Delete if file
|
581 |
+
$result=array_merge($result,$this->bkpwp_rmdirtree($path));
|
582 |
+
}else{
|
583 |
+
unlink($path);
|
584 |
+
$result[].=$path;
|
585 |
+
}
|
586 |
+
}
|
587 |
+
}
|
588 |
+
closedir($handle);
|
589 |
+
rmdir($dirname); //Remove dir
|
590 |
+
$result[] .= $dirname;
|
591 |
+
return $result; //Return array of deleted items
|
592 |
+
} else {
|
593 |
+
return false; //Return false if attempting to operate on a file
|
594 |
+
}
|
595 |
+
}
|
596 |
+
|
597 |
+
function bkpwp_delete_old() {
|
598 |
+
$backups = new BKPWP_MANAGE();
|
599 |
+
$unlinkcount = 0;
|
600 |
+
$files = $backups->bkpwp_get_backups();
|
601 |
+
if (count($files) <= get_option('bkpwp_max_backups')) {
|
602 |
+
return;
|
603 |
+
} else {
|
604 |
+
$i = 1;
|
605 |
+
foreach($files as $f) {
|
606 |
+
if ($i > get_option('bkpwp_max_backups')) {
|
607 |
+
unlink($f['file']);
|
608 |
+
$unlinkcount++;
|
609 |
+
}
|
610 |
+
$i++;
|
611 |
+
}
|
612 |
+
}
|
613 |
+
if ($unlinkcount > 0) {
|
614 |
+
return $unlinkcount;
|
615 |
+
}
|
616 |
+
return false;
|
617 |
+
}
|
618 |
+
|
619 |
+
}
|
620 |
+
|
621 |
+
class BKPWP_MANAGE {
|
622 |
+
|
623 |
+
function BKPWP_MANAGE() {
|
624 |
+
}
|
625 |
+
|
626 |
+
function bkpwp_get_presets() {
|
627 |
+
$user = $GLOBALS['userdata']->user_login;
|
628 |
+
if(empty($user)) { $user = "admin"; }
|
629 |
+
$presets = get_option("bkpwp_presets");
|
630 |
+
if(!is_array($presets[$user]['bkpwp_presets'])) {
|
631 |
+
return array();
|
632 |
+
} else {
|
633 |
+
return $presets[$user]['bkpwp_presets'];
|
634 |
+
}
|
635 |
+
}
|
636 |
+
|
637 |
+
function bkpwp_update_presets($userpresets) {
|
638 |
+
$presets = get_option("bkpwp_presets");
|
639 |
+
$user = $GLOBALS['userdata']->user_login;
|
640 |
+
if(empty($user)) { $user = "admin"; }
|
641 |
+
$presets[$user]['bkpwp_presets'] = $userpresets;
|
642 |
+
update_option("bkpwp_presets",$presets);
|
643 |
+
}
|
644 |
+
|
645 |
+
function bkpwp_load_preset($preset) {
|
646 |
+
$options = new BKPWP_OPTIONS();
|
647 |
+
$ret = "<div style=\"border: 1px solid #ccc; padding:10px; margin-bottom:20px;\">";
|
648 |
+
$ret .= "<h4>Configure or Create Backup Preset</h4><p>";
|
649 |
+
$ret .= "<label for=\"mod_bkpwp_preset_name\">".__("Preset Name","bkpwp")." </label>";
|
650 |
+
$ret .= "<input type=\"text\" name=\"mod_bkpwp_preset_name\" id=\"mod_bkpwp_preset_name\" value=\"".$preset['bkpwp_preset_name']."\" /></p>";
|
651 |
+
|
652 |
+
$ret .= "<p><label for=\"mod_bkpwp_archive_type\">".__("Archive Type","bkpwp")." </label><select name=\"mod_bkpwp_archive_type\" id=\"mod_bkpwp_archive_type\">";
|
653 |
+
$archive_types = get_option("bkpwp_archive_types");
|
654 |
+
if (is_array($archive_types)) {
|
655 |
+
foreach ($archive_types as $type) {
|
656 |
+
$ret .= "<option value=\"".$type."\" ";
|
657 |
+
if ($preset['bkpwp_preset_options']['bkpwp_archive_type'] == $type) {
|
658 |
+
$ret .= " selected";
|
659 |
+
}
|
660 |
+
$ret .= ">".$type."</option>";
|
661 |
+
}
|
662 |
+
}
|
663 |
+
$ret .= "</select></p>";
|
664 |
+
|
665 |
+
if($preset['bkpwp_preset_options']['bkpwp_sql_only'] == 1) {
|
666 |
+
$fullinit = " style=\"display: none;\"";
|
667 |
+
}
|
668 |
+
$ret .= "<div id=\"full_only\"".$fullinit.">";
|
669 |
+
$lists = $options->bkpwp_get_excludelists();
|
670 |
+
if (is_array($lists)) {
|
671 |
+
$ret .= "<p>".__("Exclude List","bkpwp")." <select name=\"mod_bkpwp_excludelist\" id=\"mod_bkpwp_excludelist\">";
|
672 |
+
$ret .= "<option value=\"\">".__("None","bkpwp")."</option>";
|
673 |
+
foreach ($lists as $l) {
|
674 |
+
$ret .= "<option value=\"".$l['listname']."\" ";
|
675 |
+
if ($preset['bkpwp_preset_options']['bkpwp_excludelist'] == $l['listname']) {
|
676 |
+
$ret .= " selected";
|
677 |
+
}
|
678 |
+
$ret .= ">".$l['listname']."</option>";
|
679 |
+
}
|
680 |
+
$ret .= "</select>";
|
681 |
+
$ret .= " <a href=\"admin.php?page=bkpwp-backup-options&excludelistname=".$preset['bkpwp_preset_options']['bkpwp_excludelist']."#excludelist\">".__("Configure","bkpwp")." »</a>";
|
682 |
+
$ret .= "</p>";
|
683 |
+
}
|
684 |
+
$ret .= "</div>";
|
685 |
+
|
686 |
+
$ret .= "<p><label for=\"mod_bkpwp_sql_only\"><input type=\"checkbox\" name=\"mod_bkpwp_sql_only\" id=\"mod_bkpwp_sql_only\" value=\"1\"";
|
687 |
+
if ($preset['bkpwp_preset_options']['bkpwp_sql_only'] == 1) {
|
688 |
+
$ret .= " checked";
|
689 |
+
}
|
690 |
+
$ret .= " onclick=\"if (document.getElementById('mod_bkpwp_sql_only').checked == false) { document.getElementById('mod_bkpwp_sql_only').value=''; document.getElementById('full_only').style.display='block'; } else { document.getElementById('mod_bkpwp_sql_only').value=1; document.getElementById('full_only').style.display='none'; }\" /> ".__("SQL only","bkpwp")."</label></p>";
|
691 |
+
$ret .= "<p><input type=\"button\" class=\"button\" value=\"".__("Save Preset","bkpwp")."\" onclick=\"bkpwp_js_loading('".__("Saving Preset","bkpwp")."'); sajax_target_id = 'bkpwp_action_buffer'; save_preset(); sajax_target_id = ''; return false;\" /></p>";
|
692 |
+
if ($preset['bkpwp_preset_options']['default'] == 1) {
|
693 |
+
$ret .= "<p>".__("You can not overwrite this default preset. Please save changes with a new Preset Name.","bkpwp")."</p>";
|
694 |
+
}
|
695 |
+
$ret .= "</div>";
|
696 |
+
return $ret;
|
697 |
+
}
|
698 |
+
|
699 |
+
function bkpwp_view_preset($preset) {
|
700 |
+
$backup = new BKPWP_BACKUP();
|
701 |
+
$options = new BKPWP_OPTIONS();
|
702 |
+
$ret = "<div>";
|
703 |
+
if (!empty($preset['bkpwp_preset_options']['bkpwp_excludelist'])) {
|
704 |
+
$ret .= "<p>".__("Omitted Folders and Files when using","bkpwp")." <b>".$preset['bkpwp_preset_name']."</b></p>";
|
705 |
+
$ret .= "<p>";
|
706 |
+
$ret .= $options->bkpwp_ajax_shownobfiles($preset['bkpwp_preset_options']['bkpwp_excludelist']);
|
707 |
+
$ret .= "</p>";
|
708 |
+
}
|
709 |
+
$ret .= $backup->bkpwp_calculate($preset);
|
710 |
+
$ret .= "</div>";
|
711 |
+
return $ret;
|
712 |
+
}
|
713 |
+
|
714 |
+
function bkpwp_delete_preset($name) {
|
715 |
+
$apresets = $this->bkpwp_get_presets();
|
716 |
+
$presets= array();
|
717 |
+
foreach($apresets as $p) {
|
718 |
+
if ($p['bkpwp_preset_name'] != $name) {
|
719 |
+
$presets[] = $p;
|
720 |
+
} else {
|
721 |
+
if ($p['bkpwp_preset_options']['default'] == 1) {
|
722 |
+
return __("You can not delete this default preset.","bkpwp");
|
723 |
+
}
|
724 |
+
}
|
725 |
+
}
|
726 |
+
$this->bkpwp_update_presets($presets);
|
727 |
+
return "<div id=\"message\" class=\"updated fade\"><p>".__("Preset deleted.","bkpwp")."</p></div>";
|
728 |
+
}
|
729 |
+
|
730 |
+
function bkpwp_save_preset($name="",$archive_type="",$excludelist="",$sql_only="") {
|
731 |
+
if (empty($name)) {
|
732 |
+
$name = "Preset".date("Y-m-d-H-i-s");
|
733 |
+
}
|
734 |
+
$apresets = $this->bkpwp_get_presets();
|
735 |
+
$presets= array();
|
736 |
+
foreach($apresets as $p) {
|
737 |
+
if ($p['bkpwp_preset_name'] != $name) {
|
738 |
+
$presets[] = $p;
|
739 |
+
} else {
|
740 |
+
if ($p['bkpwp_preset_options']['default'] == 1) {
|
741 |
+
return __("You can not overwrite this default preset. Please save changes with a new Preset Name.","bkpwp");
|
742 |
+
}
|
743 |
+
}
|
744 |
+
}
|
745 |
+
|
746 |
+
$options = array("bkpwp_archive_type" => $archive_type,
|
747 |
+
"bkpwp_sql_only" => $sql_only,
|
748 |
+
"bkpwp_excludelist" => $excludelist);
|
749 |
+
$presets[] = array("bkpwp_preset_name" => $name,
|
750 |
+
"bkpwp_preset_options" => $options);
|
751 |
+
|
752 |
+
/* ob_start();
|
753 |
+
echo "<pre>";
|
754 |
+
print_r($presets);
|
755 |
+
echo "</pre>";
|
756 |
+
$out = ob_get_contents();
|
757 |
+
ob_end_clean(); */
|
758 |
+
//return $out;
|
759 |
+
$this->bkpwp_update_presets($presets);
|
760 |
+
return "<div id=\"message\" class=\"updated fade\"><p>".__("Preset saved.","bkpwp")."</p></div>";
|
761 |
+
}
|
762 |
+
|
763 |
+
function bkpwp_get_preset($name="") {
|
764 |
+
if (empty($name)) {
|
765 |
+
$name = "full backup";
|
766 |
+
}
|
767 |
+
$user = $GLOBALS['userdata']->user_login;
|
768 |
+
if(empty($user)) { $user = "admin"; }
|
769 |
+
$presets = get_option("bkpwp_presets");
|
770 |
+
$apresets = $presets[$user]['bkpwp_presets'];
|
771 |
+
foreach($apresets as $p) {
|
772 |
+
if ($p['bkpwp_preset_name'] == $name) {
|
773 |
+
return $p;
|
774 |
+
}
|
775 |
+
}
|
776 |
+
}
|
777 |
+
|
778 |
+
function bkpwp_max_views() {
|
779 |
+
$maxview = get_option('bkpwp_listmax_backups');
|
780 |
+
if (!empty($_REQUEST['bkpwp_show_all'])) {
|
781 |
+
$maxview = 999;
|
782 |
+
}
|
783 |
+
return $maxview;
|
784 |
+
}
|
785 |
+
|
786 |
+
function bkpwp_get_backups() {
|
787 |
+
$files = array();
|
788 |
+
$bkpwppath = get_option("bkpwppath");
|
789 |
+
if (!is_writable($bkpwppath)) {
|
790 |
+
return;
|
791 |
+
}
|
792 |
+
$restorefile = $bkpwppath."/bkpwp_restore.sql";
|
793 |
+
if (file_exists($restorefile)) {
|
794 |
+
unlink($restorefile);
|
795 |
+
}
|
796 |
+
if ($handle = opendir($bkpwppath)) {
|
797 |
+
while (false !== ($file = readdir($handle))) {
|
798 |
+
if (($file != ".") && ($file != "..") && !is_dir($bkpwppath."/".$file)) {
|
799 |
+
$files[] = array("file" => $bkpwppath."/".$file,
|
800 |
+
"filename" => $file);
|
801 |
+
}
|
802 |
+
}
|
803 |
+
closedir($handle);
|
804 |
+
}
|
805 |
+
if (count($files) < 1) { return; }
|
806 |
+
foreach ($files as $key => $row) {
|
807 |
+
$filename[$key] = $row['filename'];
|
808 |
+
}
|
809 |
+
array_multisort($filename, SORT_DESC, $files);
|
810 |
+
return $files;
|
811 |
+
}
|
812 |
+
}
|
813 |
+
|
814 |
+
|
815 |
+
require(ABSPATH."wp-includes/class-phpmailer.php");
|
816 |
+
class backupwordpressMailer extends PHPMailer {
|
817 |
+
// Set default variables for all new objects
|
818 |
+
//var $From = $GLOBALS['userdata']->user_email;
|
819 |
+
var $FromName = "BackUpWordPress";
|
820 |
+
/*
|
821 |
+
var $Host = "";
|
822 |
+
var $Username = ''; // SMTP username
|
823 |
+
var $Password = ''; // SMTP password
|
824 |
+
var $SMTPAuth = true; */
|
825 |
+
var $Mailer = "mail";
|
826 |
+
var $WordWrap = 75;
|
827 |
+
}
|
828 |
+
|
829 |
+
function bkpwp_mail_now($file="", $bkpwpinfo="") {
|
830 |
+
ob_start();
|
831 |
+
include_once($GLOBALS['bkpwp_plugin_path']."bkpwp-pages/bkpwp_footer.php");
|
832 |
+
$text_html = ob_get_contents();
|
833 |
+
ob_end_clean();
|
834 |
+
|
835 |
+
ob_start();
|
836 |
+
include_once($GLOBALS['bkpwp_plugin_path']."bkpwp-pages/bkpwp_mail_footer.php");
|
837 |
+
$text_plain = ob_get_contents();
|
838 |
+
ob_end_clean();
|
839 |
+
|
840 |
+
// Instantiate your new class
|
841 |
+
$mail = new backupwordpressMailer;
|
842 |
+
$mail->IsHTML(true);
|
843 |
+
|
844 |
+
// Now you only need to add the necessary stuff
|
845 |
+
|
846 |
+
$email = get_option("bkpwp_automail_address");
|
847 |
+
$name = get_option("bkpwp_automail_receiver");
|
848 |
+
|
849 |
+
$mail->AddAddress($email, $name);
|
850 |
+
$mail->From = $email;
|
851 |
+
$mail->FromName = __("BackUpWordPress","bkpwp")." ".get_bloginfo("url");
|
852 |
+
$mail->Subject = __("BackUpWordPress","bkpwp")." ".get_bloginfo("url");
|
853 |
+
$mail->Body = "<html><body>";
|
854 |
+
$mail->Body .= __("Your requested Backup","bkpwp");
|
855 |
+
if (empty($file)) {
|
856 |
+
$mail->Body .= __("This Backup exceeded","bkpwp")." ".get_option("bkpwp_automail_maxsize")." ".__("MB (megabytes)","bkpwp")."<br /><br />\n\n";
|
857 |
+
$mail->Body .= __("Please download it from your WordPress administration backend.","bkpwp")."<br /><br />\n\n";
|
858 |
+
}
|
859 |
+
|
860 |
+
$mail->Body .= $bkpwpinfo;
|
861 |
+
$mail->Body .= $text_html;
|
862 |
+
$mail->Body .= "</body></html>";
|
863 |
+
$mail->AltBody = strip_tags($text_plain);
|
864 |
+
|
865 |
+
if (!empty($file)) {
|
866 |
+
$mail->AddAttachment(base64_decode($file)); // optional name
|
867 |
+
}
|
868 |
+
|
869 |
+
if(!$mail->Send()){
|
870 |
+
echo $mail->ErrorInfo;
|
871 |
+
return false;
|
872 |
+
} else {
|
873 |
+
return true;
|
874 |
+
}
|
875 |
+
}
|
876 |
+
?>
|
bkpwp-classes/options.php
ADDED
@@ -0,0 +1,449 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class BKPWP_OPTIONS {
|
4 |
+
|
5 |
+
var $bkpwp_default_backup_path = '/wp-content/backup';
|
6 |
+
|
7 |
+
function BKPWP_OPTIONS() {
|
8 |
+
}
|
9 |
+
|
10 |
+
function bkpwp_easy_mode() {
|
11 |
+
$easy_mode = get_option("bkpwp_easy_mode");
|
12 |
+
$user = $GLOBALS['userdata']->user_login;
|
13 |
+
if(empty($user)) { $user = "admin"; }
|
14 |
+
if ($easy_mode[$user] == 1) {
|
15 |
+
return true;
|
16 |
+
} else {
|
17 |
+
return false;
|
18 |
+
}
|
19 |
+
}
|
20 |
+
|
21 |
+
function bkpwp_handle_modeswitch() {
|
22 |
+
if (!empty($_REQUEST['bkpwp_modeswitch'])) {
|
23 |
+
$user = $GLOBALS['userdata']->user_login;
|
24 |
+
if(empty($user)) { $user = "admin"; }
|
25 |
+
if (!$this->bkpwp_easy_mode()) {
|
26 |
+
$easy_mode[$user] = 1;
|
27 |
+
} else {
|
28 |
+
$easy_mode[$user] = "";
|
29 |
+
}
|
30 |
+
|
31 |
+
update_option("bkpwp_easy_mode",$easy_mode);
|
32 |
+
}
|
33 |
+
}
|
34 |
+
|
35 |
+
function bkpwp_path() {
|
36 |
+
return get_option("bkpwppath");
|
37 |
+
}
|
38 |
+
|
39 |
+
function bkpwp_options_edit() {
|
40 |
+
if (!current_user_can('manage bkpwp')) {
|
41 |
+
return false;
|
42 |
+
}
|
43 |
+
return true;
|
44 |
+
}
|
45 |
+
|
46 |
+
function bkpwp_delete_option($option) {
|
47 |
+
delete_option($option);
|
48 |
+
}
|
49 |
+
|
50 |
+
function bkpwp_update_option($name,$value) {
|
51 |
+
update_option($name,$value);
|
52 |
+
}
|
53 |
+
|
54 |
+
function bkpwp_handle_backup_path($suppress_msg=0) {
|
55 |
+
if (!$this->bkpwp_options_edit()) {
|
56 |
+
bkpwp_display_message(__("You do not have sufficent privileges to do Full Backups.","bkpwp"));
|
57 |
+
return;
|
58 |
+
}
|
59 |
+
if (!empty($_REQUEST['bkpwppath'])) {
|
60 |
+
if ($this->bkpwp_easy_mode()){
|
61 |
+
$_REQUEST['bkpwppath'] = bkpwp_conform_dir(ABSPATH).$_REQUEST['bkpwppath'];
|
62 |
+
}
|
63 |
+
if (!eregi(bkpwp_conform_dir(ABSPATH),$_REQUEST['bkpwppath'])) {
|
64 |
+
delete_option("bkpwppath");
|
65 |
+
$msg = __("Path is not within your webroot. Please specify a writable directory inside ","bkpwp").bkpwp_conform_dir(ABSPATH).".";
|
66 |
+
bkpwp_display_message($msg);
|
67 |
+
} else {
|
68 |
+
if (!is_dir($_REQUEST['bkpwppath'])) {
|
69 |
+
if (!mkdir($_REQUEST['bkpwppath'])) {
|
70 |
+
$this->bkpwp_delete_option("bkpwppath");
|
71 |
+
$msg = __("Wrong Backup Path. Directory does not exist and this script was not able to create it.","bkpwp");
|
72 |
+
bkpwp_display_message($msg);
|
73 |
+
} else {
|
74 |
+
$this->bkpwp_update_option("bkpwppath",$_REQUEST['bkpwppath']);
|
75 |
+
$msg = __("Directory did not exist but this script was able to create it.","bkpwp");
|
76 |
+
bkpwp_display_message($msg);
|
77 |
+
}
|
78 |
+
} elseif (!is_writable($_REQUEST['bkpwppath'])) {
|
79 |
+
$this->bkpwp_delete_option("bkpwppath");
|
80 |
+
$msg = __("Directory does exist but is not writable by the webserver. Check directory permissions (e.g.: chmod 777).","bkpwp");
|
81 |
+
bkpwp_display_message($msg);
|
82 |
+
} else {
|
83 |
+
$this->bkpwp_update_option("bkpwppath",$_REQUEST['bkpwppath']);
|
84 |
+
bkpwp_display_message(__("Backup Path saved.","bkpwp")." <a href=\"admin.php?page=".$_REQUEST['page']."\">".__("Continue","bkpwp")." »</a>");
|
85 |
+
|
86 |
+
}
|
87 |
+
}
|
88 |
+
}
|
89 |
+
if (!is_writable($this->bkpwp_path()) && empty($_REQUEST['bkpwppath'])) {
|
90 |
+
$msg = __("Please configure the Backup path first. The field below should allready be filled with a recommendation for that option.","bkpwp");
|
91 |
+
if ($suppress_msg == 0) {
|
92 |
+
bkpwp_display_message($msg);
|
93 |
+
}
|
94 |
+
}
|
95 |
+
}
|
96 |
+
|
97 |
+
function bkpwp_check_path() {
|
98 |
+
if (!$this->bkpwp_easy_mode()){
|
99 |
+
echo $this->bkpwp_path();
|
100 |
+
} else {
|
101 |
+
if (!is_writable($this->bkpwp_path())) {
|
102 |
+
echo $this->bkpwp_default_backup_path;
|
103 |
+
} else {
|
104 |
+
echo eregi_replace(bkpwp_conform_dir(ABSPATH),"",$this->bkpwp_path());
|
105 |
+
}
|
106 |
+
}
|
107 |
+
}
|
108 |
+
|
109 |
+
function bkpwp_handle_backup_settings() {
|
110 |
+
if (!empty($_REQUEST['bkpwp_backup_options'])) {
|
111 |
+
$this->bkpwp_update_option("bkpwp_max_backups",$_REQUEST['bkpwp_max_backups']);
|
112 |
+
bkpwp_display_message(__("Settings saved.","bkpwp"));
|
113 |
+
}
|
114 |
+
}
|
115 |
+
|
116 |
+
function bkpwp_handle_backup_automail() {
|
117 |
+
if (!empty($_REQUEST['bkpwp_automailsettings'])) {
|
118 |
+
if (!empty($_REQUEST['bkpwp_automail'])) {
|
119 |
+
$this->bkpwp_update_option("bkpwp_automail",$_REQUEST['bkpwp_automail']);
|
120 |
+
$this->bkpwp_update_option("bkpwp_automail_address",$GLOBALS['userdata']->user_email);
|
121 |
+
$this->bkpwp_update_option("bkpwp_automail_receiver",$GLOBALS['userdata']->user_nicename);
|
122 |
+
if (!empty($_REQUEST['bkpwp_automail_maxsize'])) {
|
123 |
+
$this->bkpwp_update_option("bkpwp_automail_maxsize",$_REQUEST['bkpwp_automail_maxsize']);
|
124 |
+
}
|
125 |
+
bkpwp_display_message(__("Settings saved.","bkpwp"));
|
126 |
+
} else {
|
127 |
+
$this->bkpwp_delete_option("bkpwp_automail_maxsize");
|
128 |
+
$this->bkpwp_delete_option("bkpwp_automail_address");
|
129 |
+
$this->bkpwp_delete_option("bkpwp_automail_receiver");
|
130 |
+
$this->bkpwp_delete_option("bkpwp_automail");
|
131 |
+
}
|
132 |
+
}
|
133 |
+
}
|
134 |
+
|
135 |
+
function bkpwp_handle_backup_excludelists() {
|
136 |
+
if (!empty($_REQUEST['nobackup']) && !empty($_REQUEST['excludelist'])) {
|
137 |
+
$this->bkpwp_excludelist();
|
138 |
+
bkpwp_display_message(__("New Backup Exclude List saved:","bkpwp")." ".$_REQUEST['excludelistname']);
|
139 |
+
} elseif (!empty($_REQUEST['nobackupchange']) && !empty($_REQUEST['excludelist'])) {
|
140 |
+
$this->bkpwp_excludelist();
|
141 |
+
bkpwp_display_message(__("Backup Exclude List saved:","bkpwp")." ".$_REQUEST['excludelistname']);
|
142 |
+
} elseif (!empty($_REQUEST['nobackupdelete']) && !empty($_REQUEST['excludelist'])) {
|
143 |
+
$this->bkpwp_delete_excludelist($_REQUEST['excludelistname']);
|
144 |
+
bkpwp_display_message(__("Backup Exclude List deleted:","bkpwp")." ".$_REQUEST['excludelistname']);
|
145 |
+
}
|
146 |
+
}
|
147 |
+
|
148 |
+
function bkpwp_ls_exclusions($dir,$files=array()) {
|
149 |
+
$d = opendir($dir);
|
150 |
+
while ($file = readdir($d)) {
|
151 |
+
if ($file == '.' || $file == '..') { continue; }
|
152 |
+
$getfile = $this->bkpwp_match_excludelist($dir,$file);
|
153 |
+
if (!empty($getfile)) {
|
154 |
+
$files[] = $getfile;
|
155 |
+
}
|
156 |
+
if (is_dir($dir.'/'.$file)) {
|
157 |
+
if (!empty($getfile)) {
|
158 |
+
continue;
|
159 |
+
}
|
160 |
+
$files = $this->bkpwp_ls_exclusions($dir.'/'.$file, $files);
|
161 |
+
}
|
162 |
+
}
|
163 |
+
return $files;
|
164 |
+
}
|
165 |
+
|
166 |
+
function bkpwp_ajax_shownobfiles($listname,$dir="") {
|
167 |
+
if (empty($dir)) {
|
168 |
+
$dir = bkpwp_conform_dir(ABSPATH);
|
169 |
+
}
|
170 |
+
$this->excludelist = urldecode($listname);
|
171 |
+
$ret = "";
|
172 |
+
$files = $this->bkpwp_ls_exclusions($dir);
|
173 |
+
$stringmatches = array();
|
174 |
+
|
175 |
+
|
176 |
+
$ret .= "<p>";
|
177 |
+
$ret .= __("Folders","bkpwp")."<br />";
|
178 |
+
foreach($files as $f) {
|
179 |
+
if (is_dir($f['file'])) {
|
180 |
+
$ret .= "<b>".$f['file']."</b>: ".__("matched by","bkpwp")." ".$f['match']." -> ".$f['value']."<br />";
|
181 |
+
} else {
|
182 |
+
if ($f['match'] == "string") {
|
183 |
+
$t = $f['value'];
|
184 |
+
$stringmatches[$t]++;
|
185 |
+
}
|
186 |
+
}
|
187 |
+
}
|
188 |
+
$ret .= "</p>";
|
189 |
+
|
190 |
+
if (count($stringmatches) > 0) {
|
191 |
+
$ret .= "<p>";
|
192 |
+
$ret .= __("Files","bkpwp")."<br />";
|
193 |
+
foreach($stringmatches as $s=>$t) {
|
194 |
+
$ret .= "<b>".$t."</b> ".__("files matched by","bkpwp")." ".$s."<br />";
|
195 |
+
}
|
196 |
+
$ret .= "</p>";
|
197 |
+
}
|
198 |
+
|
199 |
+
return $ret;
|
200 |
+
}
|
201 |
+
|
202 |
+
function bkpwp_ls($dir,$files=array()) {
|
203 |
+
$d = opendir($dir);
|
204 |
+
$j=0;
|
205 |
+
while ($file = readdir($d)) {
|
206 |
+
if ($file == '.' || $file == '..') { continue; }
|
207 |
+
$getfile = $this->bkpwp_match_excludelist($dir,$file);
|
208 |
+
if (!empty($getfile)) {
|
209 |
+
continue;
|
210 |
+
}
|
211 |
+
$files[] = $dir.'/'.$file;
|
212 |
+
if (is_dir($dir.'/'.$file)) {
|
213 |
+
if (!empty($getfile)) {
|
214 |
+
continue;
|
215 |
+
}
|
216 |
+
$files = $this->bkpwp_ls($dir.'/'.$file,$files); $j++;
|
217 |
+
}
|
218 |
+
}
|
219 |
+
return $files;
|
220 |
+
}
|
221 |
+
|
222 |
+
function bkpwp_match_excludelist($dir,$file) {
|
223 |
+
$nobfiles = $this->bkpwp_get_excludelist($this->excludelist);
|
224 |
+
$nobfiles['list'][] = get_option("bkpwppath");
|
225 |
+
if (is_array($nobfiles['list'])) {
|
226 |
+
foreach($nobfiles['list'] as $n) {
|
227 |
+
if (empty($n)) { continue; }
|
228 |
+
$ifpath = str_replace("\\","/",$n);
|
229 |
+
$absolutefilepath = str_replace("\\","/",$dir.'/'.$file);
|
230 |
+
$relativefilepath = str_replace(ABSPATH,"",$absolutefilepath);
|
231 |
+
if (($ifpath == $absolutefilepath) || ($ifpath == $relativefilepath)) {
|
232 |
+
return array('file' => $dir.'/'.$file, 'match' => 'path', 'value' => $n);
|
233 |
+
} elseif (!strpos("/",$ifpath) && stristr($file,$n)) {
|
234 |
+
return array('file' => $dir.'/'.$file, 'match' => 'string', 'value' => $n);
|
235 |
+
}
|
236 |
+
}
|
237 |
+
}
|
238 |
+
return false;
|
239 |
+
}
|
240 |
+
|
241 |
+
function bkpwp_get_excludelists() {
|
242 |
+
$allnobs = get_option("bkpwp_excludelists");
|
243 |
+
$user = $GLOBALS['userdata']->user_login;
|
244 |
+
if(empty($user)) { $user = "admin"; }
|
245 |
+
return $allnobs[$user];
|
246 |
+
}
|
247 |
+
|
248 |
+
function bkpwp_get_excludelist($listname) {
|
249 |
+
$usernoblists = $this->bkpwp_get_excludelists();
|
250 |
+
foreach($usernoblists as $f) {
|
251 |
+
if ($f['listname'] == $listname) {
|
252 |
+
return $f;
|
253 |
+
}
|
254 |
+
}
|
255 |
+
}
|
256 |
+
|
257 |
+
function bkpwp_excludelist_tochange() {
|
258 |
+
if (!empty($_REQUEST['excludelist_to_change'])) {
|
259 |
+
return $this->bkpwp_get_excludelist($_REQUEST['excludelist_to_change']);
|
260 |
+
}
|
261 |
+
|
262 |
+
if (!empty($_REQUEST['excludelistname'])) {
|
263 |
+
return $this->bkpwp_get_excludelist($_REQUEST['excludelistname']);
|
264 |
+
}
|
265 |
+
}
|
266 |
+
|
267 |
+
function bkpwp_delete_excludelist($listname) {
|
268 |
+
$allnobst = get_option("bkpwp_excludelists");
|
269 |
+
$user = $GLOBALS['userdata']->user_login;
|
270 |
+
if(empty($user)) { $user = "admin"; }
|
271 |
+
$allnobs = array();
|
272 |
+
if (!is_array($allnobst[$user])) {
|
273 |
+
$allnobst[$user] = array();
|
274 |
+
}
|
275 |
+
foreach ($allnobst[$user] as $a) {
|
276 |
+
if ($a['listname'] != $listname) {
|
277 |
+
$allnobs[$user][] = $a;
|
278 |
+
}
|
279 |
+
}
|
280 |
+
|
281 |
+
update_option("bkpwp_excludelists",$allnobs);
|
282 |
+
}
|
283 |
+
|
284 |
+
function bkpwp_save_excludelist($list,$listname,$listtype) {
|
285 |
+
$allnobst = get_option("bkpwp_excludelists");
|
286 |
+
$user = $GLOBALS['userdata']->user_login;
|
287 |
+
if(empty($user)) { $user = "admin"; }
|
288 |
+
$allnobs = array();
|
289 |
+
if (!is_array($allnobst[$user])) {
|
290 |
+
$allnobst[$user] = array();
|
291 |
+
}
|
292 |
+
foreach ($allnobst[$user] as $a) {
|
293 |
+
if ($a['listname'] != $listname) {
|
294 |
+
$allnobs[$user][] = $a;
|
295 |
+
}
|
296 |
+
}
|
297 |
+
$allnobs[$user][] = array("listname" => $listname,
|
298 |
+
"listtype" => $listtype,
|
299 |
+
"list" => $list);
|
300 |
+
|
301 |
+
update_option("bkpwp_excludelists",$allnobs);
|
302 |
+
}
|
303 |
+
|
304 |
+
function bkpwp_excludelist($excludelist="",$excludelistname="",$excludelisttype="") {
|
305 |
+
$list = array();
|
306 |
+
$list[] = $this->bkpwp_path();
|
307 |
+
if (!empty($_REQUEST['excludelist'])) {
|
308 |
+
$excludelist = $_REQUEST['excludelist'];
|
309 |
+
}
|
310 |
+
foreach($excludelist as $r) {
|
311 |
+
if (eregi(",",$r)) {
|
312 |
+
$re=explode(",",$r);
|
313 |
+
foreach($re as $e) {
|
314 |
+
if (!empty($e)) {
|
315 |
+
$list[] = $e;
|
316 |
+
}
|
317 |
+
}
|
318 |
+
} else {
|
319 |
+
if (!empty($r)) {
|
320 |
+
$list[] = $r;
|
321 |
+
}
|
322 |
+
}
|
323 |
+
}
|
324 |
+
$list = array_unique($list);
|
325 |
+
if (!empty($_REQUEST['excludelistname'])) {
|
326 |
+
$excludelistname = $_REQUEST['excludelistname'];
|
327 |
+
}
|
328 |
+
if (empty($excludelistname)) {
|
329 |
+
$excludelistname = "excl_".date("Y-m-d-H-i-s");
|
330 |
+
}
|
331 |
+
$this->bkpwp_save_excludelist($list,$excludelistname,$excludelisttype);
|
332 |
+
}
|
333 |
+
|
334 |
+
function bkpwp_check_compression_type($archive_types_wishlist) {
|
335 |
+
$a = array();
|
336 |
+
foreach($archive_types_wishlist as $at) {
|
337 |
+
if (function_exists($at['func']) || empty($at['func'])) {
|
338 |
+
$a[] = $at['ext'];
|
339 |
+
}
|
340 |
+
}
|
341 |
+
return $a;
|
342 |
+
}
|
343 |
+
|
344 |
+
function bkpwp_default_archive_types() {
|
345 |
+
// a wishlist of compression types
|
346 |
+
$archive_types_wishlist = array();
|
347 |
+
$archive_types_wishlist[] = array("ext" => "zip", "func" => ""); // pear package file_archive's own
|
348 |
+
$archive_types_wishlist[] = array("ext" => "tgz", "func" => "gzopen");
|
349 |
+
$archive_types_wishlist[] = array("ext" => "tar.gz", "func" => "gzopen");
|
350 |
+
$archive_types_wishlist[] = array("ext" => "tar", "func" => ""); // pear package file_archive's own
|
351 |
+
$archive_types_wishlist[] = array("ext" => "tar.bz2", "func" => "bzopen");
|
352 |
+
|
353 |
+
// run a check if the respective compression is supported by this php installation
|
354 |
+
$archive_types = $this->bkpwp_check_compression_type($archive_types_wishlist);
|
355 |
+
update_option("bkpwp_archive_types",$archive_types);
|
356 |
+
}
|
357 |
+
|
358 |
+
function bkpwp_get_backup_type($f) {
|
359 |
+
$ex = explode(".",$f);
|
360 |
+
$ex = explode("-",$ex[0]);
|
361 |
+
$type = $ex[6];
|
362 |
+
if (eregi("_adv",$type)) {
|
363 |
+
$type = eregi_replace("_adv","",$type);
|
364 |
+
$type .= " - advanced";
|
365 |
+
}
|
366 |
+
return $type;
|
367 |
+
}
|
368 |
+
|
369 |
+
function bkpwp_default_excludelists() {
|
370 |
+
$defaults = new BKPWP_OPTIONS();
|
371 |
+
$presetso = new BKPWP_MANAGE();
|
372 |
+
// Excludelists Defaults
|
373 |
+
$excludelist[] = ".tmp,~,.bak,#";
|
374 |
+
$excludelistname = "temporary and autosave files";
|
375 |
+
$excludelisttype = "default";
|
376 |
+
$defaults->bkpwp_excludelist($excludelist,$excludelistname,$excludelisttype);
|
377 |
+
}
|
378 |
+
|
379 |
+
function bkpwp_default_presets() {
|
380 |
+
// Preset defaults
|
381 |
+
// is set for the current user.
|
382 |
+
//update_option("bkpwp_presets","");
|
383 |
+
$presetso = new BKPWP_MANAGE();
|
384 |
+
$presets = $presetso->bkpwp_get_presets();
|
385 |
+
if (count($presets) < 1) {
|
386 |
+
$presets = array();
|
387 |
+
// full backup
|
388 |
+
$options = array("bkpwp_archive_type" => 'tar.gz',
|
389 |
+
"default" => 1,
|
390 |
+
"bkpwp_excludelist" => $excludelistname);
|
391 |
+
$presets[] = array("bkpwp_preset_name" => "full backup",
|
392 |
+
"bkpwp_preset_options" => $options);
|
393 |
+
// sql only
|
394 |
+
$options = array("bkpwp_sql_only" => 1,
|
395 |
+
"bkpwp_archive_type" => 'tar.gz',
|
396 |
+
"default" => 1);
|
397 |
+
$presets[] = array("bkpwp_preset_name" => "sql only",
|
398 |
+
"bkpwp_preset_options" => $options);
|
399 |
+
$presetso->bkpwp_update_presets($presets);
|
400 |
+
}
|
401 |
+
}
|
402 |
+
|
403 |
+
function bkpwp_default_schedules() {
|
404 |
+
|
405 |
+
// scheduling defaults
|
406 |
+
$schedules = get_option("bkpwp_schedules");
|
407 |
+
if (!is_array($schedules)) {
|
408 |
+
$schedules = array();
|
409 |
+
$schedules[] = array("preset" => "full backup",
|
410 |
+
"status" => "inactive",
|
411 |
+
"reccurrence" => 'bkpwp_weekly',
|
412 |
+
"info" => __("Full Backup Weekly","bkpwp"),
|
413 |
+
"default" => 1,
|
414 |
+
"created" => date("Y-m-d-H-i-s"));
|
415 |
+
sleep(2);
|
416 |
+
$schedules[] = array("preset" => "sql only",
|
417 |
+
"status" => "inactive",
|
418 |
+
"reccurrence" => 'bkpwp_daily',
|
419 |
+
"info" => __("SQL Only Backup Daily","bkpwp"),
|
420 |
+
"default" => 1,
|
421 |
+
"created" => date("Y-m-d-H-i-s"));
|
422 |
+
update_option("bkpwp_schedules",$schedules);
|
423 |
+
}
|
424 |
+
}
|
425 |
+
|
426 |
+
function bkpwp_set_defaults() {
|
427 |
+
// set a few options
|
428 |
+
update_option('bkpwp_listmax_backups',15);
|
429 |
+
update_option('bkpwp_max_backups',10);
|
430 |
+
update_option("bkpwp_domain","bkpwp");
|
431 |
+
update_option("bkpwp_domain_path","wp-content/plugins/bkpwp/locale");
|
432 |
+
|
433 |
+
$user = $GLOBALS['userdata']->user_login;
|
434 |
+
if(empty($user)) { $user = "admin"; }
|
435 |
+
if (!$this->bkpwp_easy_mode()) {
|
436 |
+
$easy_mode[$user] = 1;
|
437 |
+
} else {
|
438 |
+
$easy_mode[$user] = "";
|
439 |
+
}
|
440 |
+
|
441 |
+
update_option("bkpwp_easy_mode",$easy_mode);
|
442 |
+
|
443 |
+
$this->bkpwp_default_archive_types();
|
444 |
+
$this->bkpwp_default_excludelists();
|
445 |
+
$this->bkpwp_default_presets();
|
446 |
+
$this->bkpwp_default_schedules();
|
447 |
+
}
|
448 |
+
}
|
449 |
+
?>
|
bkpwp-classes/schedule.php
ADDED
@@ -0,0 +1,86 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class BKPWP_SCHEDULE {
|
4 |
+
|
5 |
+
function BKPWP_SCHEDULE() {
|
6 |
+
}
|
7 |
+
|
8 |
+
function bkpwp_get_options_by_created($created) {
|
9 |
+
$schedules = get_option("bkpwp_schedules");
|
10 |
+
if (is_array($schedules)) {
|
11 |
+
foreach($schedules as $s) {
|
12 |
+
if ($s['created'] == $created) {
|
13 |
+
return $s;
|
14 |
+
}
|
15 |
+
}
|
16 |
+
}
|
17 |
+
}
|
18 |
+
|
19 |
+
function bkpwp_delete_schedule_by_created($created) {
|
20 |
+
$schedules = get_option("bkpwp_schedules");
|
21 |
+
$newschedules = array();
|
22 |
+
foreach($schedules as $s) {
|
23 |
+
if ($s['created'] == $created) {
|
24 |
+
$timestamp = wp_next_scheduled("bkpwp_schedule_bkpwp_hook",$s);
|
25 |
+
if(!empty($timestamp)) {
|
26 |
+
wp_unschedule_event($timestamp,"bkpwp_schedule_bkpwp_hook",$s);
|
27 |
+
}
|
28 |
+
$ret = 1;
|
29 |
+
} else {
|
30 |
+
$newschedules[] = $s;
|
31 |
+
}
|
32 |
+
}
|
33 |
+
update_option("bkpwp_schedules",$newschedules);
|
34 |
+
if (empty($ret)) { return false; }
|
35 |
+
return $ret;
|
36 |
+
}
|
37 |
+
|
38 |
+
function bkpwp_toggle_schedule($created) {
|
39 |
+
$schedules = get_option("bkpwp_schedules");
|
40 |
+
$newschedules = array();
|
41 |
+
$bkpwp_reccurrences = get_option("bkpwp_reccurrences");
|
42 |
+
foreach($schedules as $s) {
|
43 |
+
if ($s['created'] == $created) {
|
44 |
+
if ($s['status'] == "active") {
|
45 |
+
$timestamp = wp_next_scheduled("bkpwp_schedule_bkpwp_hook",$s);
|
46 |
+
if(!empty($timestamp)) {
|
47 |
+
wp_unschedule_event($timestamp,"bkpwp_schedule_bkpwp_hook",$s);
|
48 |
+
$s['status'] = "inactive";
|
49 |
+
$ret = "inactive";
|
50 |
+
} else {
|
51 |
+
return false;
|
52 |
+
}
|
53 |
+
} else {
|
54 |
+
$recc = $s['reccurrence'];
|
55 |
+
$s['status'] = "active";
|
56 |
+
wp_schedule_event(time()+$bkpwp_reccurrences[$recc]['interval'], $s['reccurrence'], 'bkpwp_schedule_bkpwp_hook',$s);
|
57 |
+
$ret = "active";
|
58 |
+
}
|
59 |
+
}
|
60 |
+
$newschedules[] = $s;
|
61 |
+
}
|
62 |
+
update_option("bkpwp_schedules",$newschedules);
|
63 |
+
if (empty($ret)) { return false; }
|
64 |
+
return $ret;
|
65 |
+
}
|
66 |
+
|
67 |
+
function bkpwp_test_schedule() {
|
68 |
+
$schedules = get_option("bkpwp_schedules");
|
69 |
+
$test = array("preset" => "sql only",
|
70 |
+
"status" => "active",
|
71 |
+
"reccurrence" => '',
|
72 |
+
"info" => __("Test schedule running in 30 seconds","bkpwp"),
|
73 |
+
"default" => '',
|
74 |
+
"created" => date("Y-m-d-H-i-s"));
|
75 |
+
$schedules[] = $test;
|
76 |
+
if (!wp_next_scheduled('bkpwp_schedule_bkpwp_hook', $test)) {
|
77 |
+
wp_schedule_single_event(time()+30, 'bkpwp_schedule_bkpwp_hook', $test);
|
78 |
+
update_option("bkpwp_schedules",$schedules);
|
79 |
+
return true;
|
80 |
+
} else {
|
81 |
+
return false;
|
82 |
+
}
|
83 |
+
}
|
84 |
+
}
|
85 |
+
|
86 |
+
?>
|
bkpwp-pages/bkpwp_footer.php
ADDED
@@ -0,0 +1,28 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<div class="wrap">
|
2 |
+
<p>
|
3 |
+
<?php _e("Running into Troubles? Features to suggest?","bkpwp"); ?>
|
4 |
+
<a href="http://wordpress.designpraxis.at/">
|
5 |
+
<?php _e("Drop me a line","bkpwp"); ?> »
|
6 |
+
</a>
|
7 |
+
</p>
|
8 |
+
<div style="display: block; height:30px;">
|
9 |
+
<div style="float:left; font-size: 16px; padding:5px 5px 5px 0;">
|
10 |
+
<?php _e("Do you like this Plugin?","bkpwp"); ?>
|
11 |
+
<?php _e("Consider to","bkpwp"); ?>
|
12 |
+
</div>
|
13 |
+
<div style="float:left;">
|
14 |
+
<form action="https://www.paypal.com/cgi-bin/webscr" method="post">
|
15 |
+
<input type="hidden" name="cmd" value="_xclick">
|
16 |
+
<input type="hidden" name="business" value="rol@rm-r.at">
|
17 |
+
<input type="hidden" name="no_shipping" value="0">
|
18 |
+
<input type="hidden" name="no_note" value="1">
|
19 |
+
<input type="hidden" name="currency_code" value="EUR">
|
20 |
+
<input type="hidden" name="tax" value="0">
|
21 |
+
<input type="hidden" name="lc" value="AT">
|
22 |
+
<input type="hidden" name="bn" value="PP-DonationsBF">
|
23 |
+
<input type="image" src="https://www.paypal.com/en_US/i/btn/x-click-but21.gif" border="0" name="submit" alt="Please donate via PayPal!">
|
24 |
+
<img alt="" border="0" src="https://www.paypal.com/en_US/i/scr/pixel.gif" width="1" height="1">
|
25 |
+
</form>
|
26 |
+
</div>
|
27 |
+
</div>
|
28 |
+
</div>
|
bkpwp-pages/bkpwp_help.php
ADDED
@@ -0,0 +1,209 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
$options = new BKPWP_OPTIONS();
|
3 |
+
?>
|
4 |
+
<div class="wrap">
|
5 |
+
<a name="help_top"></a>
|
6 |
+
<h2><?php _e("BackUpWordPress Help","bkpwp"); ?></h2>
|
7 |
+
|
8 |
+
<?php if (!$options->bkpwp_easy_mode()) { ?>
|
9 |
+
<?php bkpwp_help_zeitgeist(); ?>
|
10 |
+
<a name="help_manage_backups"></a>
|
11 |
+
<?php } ?>
|
12 |
+
|
13 |
+
<h3><?php _e("Manage Backups","bkpwp"); ?></h3>
|
14 |
+
<?php if (!$options->bkpwp_easy_mode()) { ?>
|
15 |
+
<a href="#help_top"><?php _e("Help Index","bkpwp"); ?></a>
|
16 |
+
<?php } ?>
|
17 |
+
<p>
|
18 |
+
<?php _e("BackUpWordPress creates backup archives within a backup repository.
|
19 |
+
It saves all your WordPress files as well as your Database for recovery purposes.","bkpwp"); ?>
|
20 |
+
</p>
|
21 |
+
<?php if ($options->bkpwp_easy_mode()) { ?>
|
22 |
+
<p>
|
23 |
+
<?php
|
24 |
+
_e("BackUpWordPress keeps a number of","bkpwp");
|
25 |
+
echo " ".get_option("bkpwp_max_backups")." ";
|
26 |
+
_e("backup archives in the backup repository.","bkpwp");
|
27 |
+
echo " ";
|
28 |
+
_e("As soon as this amount of backup archives in the repository is reached,
|
29 |
+
every next backup will cause the oldest backup archive to be deleted.","bkpwp");
|
30 |
+
?>
|
31 |
+
</p>
|
32 |
+
<p>
|
33 |
+
<?php _e("There are two ways of doing backups:","bkpwp"); ?>
|
34 |
+
<ol>
|
35 |
+
<li><?php _e("You can run BackUpWordPress manually by hitting the \"BackUpWordPress Now\" button.","bkpwp"); ?></li>
|
36 |
+
<p><?php _e("This will create a full backup of your WordPress installation. Depending on the amount and size of your files it might take a while.","bkpwp"); ?></p>
|
37 |
+
<li><?php _e("You can download your backups for archiving purposes","bkpwp"); ?></li>
|
38 |
+
<li><?php _e("You can restore your database and/or files","bkpwp"); ?></li>
|
39 |
+
</ol>
|
40 |
+
</p>
|
41 |
+
<p>
|
42 |
+
<?php _e("For more information, please swith to ","bkpwp"); ?>
|
43 |
+
<a href="admin.php?page=<?php echo $_REQUEST['page']; ?>&bkpwp_modeswitch=1"><?php _e("AdvancedMode","bkpwp"); ?> »</a>
|
44 |
+
</p>
|
45 |
+
<?php } else { ?>
|
46 |
+
<p>
|
47 |
+
<?php
|
48 |
+
_e("By default, BackUpWordPress keeps a number of","bkpwp");
|
49 |
+
echo " ".get_option("bkpwp_max_backups")." ";
|
50 |
+
_e("backup archives in the backup repository. You can alter this number within the Advanced Backup Settings. ","bkpwp");?>
|
51 |
+
<br /><a href="admin.php?page=bkpwp-backup-options#backup_options"><?php _e("Configure","bkpwp"); ?> »</a>
|
52 |
+
</p>
|
53 |
+
<p>
|
54 |
+
<?php _e("As soon as this amount of backup archives in the repository is reached,
|
55 |
+
every next backup will cause the oldest backup archive to be deleted.","bkpwp");
|
56 |
+
?>
|
57 |
+
</p>
|
58 |
+
<p>
|
59 |
+
<?php _e("Basically, there are two ways of doing backups:","bkpwp"); ?>
|
60 |
+
<ol>
|
61 |
+
<li><?php _e("You can run BackUpWordPress manually by hitting the \"BackUpWordPress Now\" button.","bkpwp"); ?></li>
|
62 |
+
<li><?php _e("You can activate scheduling, which will run weekly backups of your databse and monthly backups of your WordPress installations directory and file structure automatically.","bkpwp"); ?></li>
|
63 |
+
</ol>
|
64 |
+
</p>
|
65 |
+
<p>
|
66 |
+
<?php _e("Both methods allow you to use Presets.
|
67 |
+
BackUpWordPress comes preconfigured with two Presets.
|
68 |
+
One for a Database-only Backup, the other for a full backup including your WordPress file structure.
|
69 |
+
BackUpWordPress makes use of these two Presets when running in EasyMode.","bkpwp");
|
70 |
+
?>
|
71 |
+
</p>
|
72 |
+
<p>
|
73 |
+
<?php _e("What can you do with your BackUpWordPress backup archives?","bkpwp"); ?>
|
74 |
+
<ul>
|
75 |
+
<li><?php _e("You can download BackUpWordPress archives","bkpwp"); ?></li>
|
76 |
+
<p><?php _e("For security reasons, not all of your WordPress files and directories are writeable by the webserver.
|
77 |
+
Therefore, for a full recovery, you might have to unpack a downloaded backup archive and upload the containig files via FTP,
|
78 |
+
just as you did when installing WordPress for the first time. Overwriting existing files on the webserver will set your
|
79 |
+
Wordpress installation back to the state when your backup archive was saved.","bkpwp"); ?></p>
|
80 |
+
<li><?php _e("\"view\" gives you extended information about the archive file and Backup Process (Log).","bkpwp"); ?></li>
|
81 |
+
<li><?php _e("You can send yourself an email containing Backup Archive Files.","bkpwp"); ?></li>
|
82 |
+
<li><?php _e("You can restore your WordPress Blog or parts of it.","bkpwp"); ?></li>
|
83 |
+
<li><?php _e("And you can simply delete unused Backup archive files.","bkpwp"); ?></li>
|
84 |
+
</ul>
|
85 |
+
<?php _e("Is your Wordpress installation getting really big?
|
86 |
+
Does your wp-content/uploads directory hold a huge amount of Files?","bkpwp");
|
87 |
+
?>
|
88 |
+
<br />
|
89 |
+
<?php _e("Consider hitting the \"Recalculate Used Disk Space\" button!
|
90 |
+
This way you can estimate how long BackUpWordPress will run and how big the resulting backup archive file will be.","bkpwp"); ?>
|
91 |
+
</p>
|
92 |
+
<p>
|
93 |
+
<?php _e("This plugin my give you a better overview:","bkpwp"); ?> <a href="http://wordpress.designpraxis.at/plugins/disk-usage/">Disk Usage</a>
|
94 |
+
</p>
|
95 |
+
<p>
|
96 |
+
<?php _e("Looking for a less komplex Solution? Please swith to ","bkpwp"); ?>
|
97 |
+
<br /><a href="admin.php?page=<?php echo $_REQUEST['page']; ?>&bkpwp_modeswitch=1"><?php _e("EasyMode","bkpwp"); ?> »</a>
|
98 |
+
</p>
|
99 |
+
<?php } ?>
|
100 |
+
|
101 |
+
|
102 |
+
<?php if (!$options->bkpwp_easy_mode()) { ?>
|
103 |
+
<a name="help_manage_presets"></a>
|
104 |
+
<h3><?php _e("Manage Backup Presets","bkpwp"); ?></h3>
|
105 |
+
<a href="#help_top"><?php _e("Help Index","bkpwp"); ?></a>
|
106 |
+
|
107 |
+
<p>
|
108 |
+
<?php _e("BackUpWordPress Presets consist of a handful of options:","bkpwp"); ?>
|
109 |
+
<ol>
|
110 |
+
<li><?php _e("Archive Type","bkpwp"); ?></li>
|
111 |
+
<p><?php _e("Sets the archive file type and compression.","bkpwp"); ?></p>
|
112 |
+
<li><?php _e("Exclude List","bkpwp"); ?></li>
|
113 |
+
<p><?php _e("Exclude Lists can be configured seperately.","bkpwp"); ?></p>
|
114 |
+
<li><?php _e("SQL only","bkpwp"); ?></li>
|
115 |
+
<p><?php _e("Database backup. Files and Folders (and thus Exclude Lists) are ignored.","bkpwp"); ?></p>
|
116 |
+
</ol>
|
117 |
+
</p>
|
118 |
+
<p>
|
119 |
+
<?php _e("At install, BackUpWordPress checks for available compression types available on your webserver.
|
120 |
+
If you are missing archiv file types there, contact your webserver's admin.","bkpwp");
|
121 |
+
?>
|
122 |
+
<br />
|
123 |
+
<?php _e("Note: .tgz, .tar and .tar.gz archive file types store Unix file and directory Permissions.
|
124 |
+
If your WordPress installation is hosted on a *nix system and you need resulting BackUpWodPress archives
|
125 |
+
for recovering purposes ther or want to migrate to another *nix host, .zip is not an option.","bkpwp");
|
126 |
+
?>
|
127 |
+
<br />
|
128 |
+
<?php _e("You cannot delete default Presets, but you can alter them and save with a new Preset name.","bkpwp");
|
129 |
+
?>
|
130 |
+
<br />
|
131 |
+
<?php _e("The \"view\" action will give you a preview on what will be backed up with this preset.","bkpwp");
|
132 |
+
?>
|
133 |
+
</p>
|
134 |
+
<p>
|
135 |
+
<?php _e("Satisfied with Defaults? Consider switching to ","bkpwp"); ?>
|
136 |
+
<br /><a href="admin.php?page=<?php echo $_REQUEST['page']; ?>&bkpwp_modeswitch=1"><?php _e("EasyMode","bkpwp"); ?> »</a>
|
137 |
+
</p>
|
138 |
+
<?php } ?>
|
139 |
+
|
140 |
+
<?php if (!$options->bkpwp_easy_mode()) { ?>
|
141 |
+
<a name="help_manage_schedules"></a>
|
142 |
+
<h3><?php _e("Manage Backup Schedules","bkpwp"); ?></h3>
|
143 |
+
<a href="#help_top"><?php _e("Help Index","bkpwp"); ?></a>
|
144 |
+
|
145 |
+
<p>
|
146 |
+
<?php _e("BackUpWordPress Schedules gives you the following options:","bkpwp"); ?>
|
147 |
+
<ol>
|
148 |
+
<li><?php _e("Reset Default Schedules","bkpwp"); ?></li>
|
149 |
+
<p><?php _e("Resets all schedules to default.","bkpwp"); ?></p>
|
150 |
+
<li><?php _e("Test Schedules","bkpwp"); ?></li>
|
151 |
+
<p><?php _e("You can set a single shedule without recurrence doing a SQL-only Backup just to test Scheduling.","bkpwp"); ?></p>
|
152 |
+
<li><?php _e("Activate/Deactivate Schedules","bkpwp"); ?></li>
|
153 |
+
<p><?php _e("Activation status can be set on any Schedule.","bkpwp"); ?></p>
|
154 |
+
<li><?php _e("Delete Schedules","bkpwp"); ?></li>
|
155 |
+
</ol>
|
156 |
+
</p>
|
157 |
+
<p>
|
158 |
+
<?php _e("Note for WordPress plugin developers: Try and analyze","bkpwp"); ?> <a href="http://wordpress.designpraxis.at/plugins/cron-demo/">Cron Developers Demo</a>. <?php _e("Cron Developers Demo is a plugin created for the sole purpose of demonstrationg the pseudo-cron feature built into WordPress","bkpwp"); ?>.
|
159 |
+
</p>
|
160 |
+
<p>
|
161 |
+
<p>
|
162 |
+
<?php _e("Satisfied with default Schedules? Consider switching to ","bkpwp"); ?>
|
163 |
+
<br /><a href="admin.php?page=<?php echo $_REQUEST['page']; ?>&bkpwp_modeswitch=1"><?php _e("EasyMode","bkpwp"); ?> »</a>
|
164 |
+
</p>
|
165 |
+
|
166 |
+
<?php } ?>
|
167 |
+
|
168 |
+
<a name="help_options"></a>
|
169 |
+
<h3><?php _e("BackUpWordPress Settings","bkpwp"); ?></h3>
|
170 |
+
|
171 |
+
<?php if ($options->bkpwp_easy_mode()) { ?>
|
172 |
+
<p>
|
173 |
+
<ol>
|
174 |
+
<li><?php _e("Backup Path","bkpwp"); ?></li>
|
175 |
+
<p><?php _e("Set the directory where your backups will be stored.","bkpwp"); ?></p>
|
176 |
+
<li><?php _e("Basic Scheduling","bkpwp"); ?></li>
|
177 |
+
<p><?php _e("Turn scheduled Backups on or off.","bkpwp"); ?></p>
|
178 |
+
<li><?php _e("Mail Setup","bkpwp"); ?></li>
|
179 |
+
<p><?php _e("Activate or deactivate Backup email notification.","bkpwp"); ?></p>
|
180 |
+
</ol>
|
181 |
+
</p>
|
182 |
+
<p>
|
183 |
+
<?php _e("For more options, please swith to ","bkpwp"); ?>
|
184 |
+
<a href="admin.php?page=<?php echo $_REQUEST['page']; ?>&bkpwp_modeswitch=1"><?php _e("AdvancedMode","bkpwp"); ?> »</a>
|
185 |
+
</p>
|
186 |
+
|
187 |
+
<?php } else { ?>
|
188 |
+
<a href="#help_top"><?php _e("Help Index","bkpwp"); ?></a>
|
189 |
+
<p>
|
190 |
+
<ol>
|
191 |
+
<li><?php _e("Backup Path","bkpwp"); ?></li>
|
192 |
+
<p><?php _e("Set the directory where your backups will be stored.","bkpwp"); ?></p>
|
193 |
+
<li><?php _e("Basic Scheduling","bkpwp"); ?></li>
|
194 |
+
<p><?php _e("is a shortcut for scheduling defaults.","bkpwp"); ?></p>
|
195 |
+
<li><?php _e("Mail Setup","bkpwp"); ?></li>
|
196 |
+
<p><?php _e("Activate or deactivate Backup email notification.","bkpwp"); ?></p>
|
197 |
+
<li><?php _e("Backup Storage","bkpwp"); ?></li>
|
198 |
+
<p><?php _e("Set the number of Backups to keep.","bkpwp"); ?></p>
|
199 |
+
<li><?php _e("Exclude Lists","bkpwp"); ?></li>
|
200 |
+
<p><?php _e("Configure Exclude Lists for use with your presets.","bkpwp"); ?></p>
|
201 |
+
</ol>
|
202 |
+
</p>
|
203 |
+
<p>
|
204 |
+
<?php _e("Too many Settings? Consider switching to ","bkpwp"); ?>
|
205 |
+
<br /><a href="admin.php?page=<?php echo $_REQUEST['page']; ?>&bkpwp_modeswitch=1"><?php _e("EasyMode","bkpwp"); ?> »</a>
|
206 |
+
</p>
|
207 |
+
|
208 |
+
<?php } ?>
|
209 |
+
</div>
|
bkpwp-pages/bkpwp_mail_footer.php
ADDED
@@ -0,0 +1,4 @@
|
|
|
|
|
|
|
|
|
1 |
+
<?php _e("Are you happy with this plugin? Looking for more plugins?","bkpwp"); ?>
|
2 |
+
<?php _e("Visit my site and consider to donate","bkpwp"); ?> http://wordpress.designpraxis.at/
|
3 |
+
<?php _e("Running into Troubles? Features to suggest?","bkpwp"); ?>
|
4 |
+
<?php _e("Drop me a line","bkpwp"); ?> http://wordpress.designpraxis.at/service/
|
bkpwp-pages/bkpwp_manage_backups.php
ADDED
@@ -0,0 +1,365 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
$backups = new BKPWP_MANAGE();
|
3 |
+
$backups->options = new BKPWP_OPTIONS();
|
4 |
+
$backup_archives = $backups->bkpwp_get_backups();
|
5 |
+
|
6 |
+
function bkpwp_restore() {
|
7 |
+
if (empty($_REQUEST['bkpwp_restore_now'])) {
|
8 |
+
?>
|
9 |
+
<div id="message" class="updated fade">
|
10 |
+
<p><?php
|
11 |
+
if (!eregi("-sql.tar.gz",base64_decode($_REQUEST['bkpwp_restore']))) {
|
12 |
+
_e("For this version of BackUpWordPress it is only possible to restore the database itself.","bkpwp");
|
13 |
+
echo "<br />";
|
14 |
+
_e("For restoring uploaded Files, Plugins etc. we recommend downloading this archive and upload the respective files to your WordPress installations via FTP.","bkpwp");
|
15 |
+
} else {
|
16 |
+
_e("You are going to restore your database from the following archive now:","bkpwp")." ";
|
17 |
+
_e("If you proceed, you will leave your WordPress Admin Area and enter the bigdump utility, where your entire database is beeing restored.","bkpwp");
|
18 |
+
}
|
19 |
+
?></p>
|
20 |
+
<p>
|
21 |
+
<?php
|
22 |
+
echo base64_decode($_REQUEST['bkpwp_restore']);
|
23 |
+
?>
|
24 |
+
<form name="form1" method="post" action="">
|
25 |
+
<input type="hidden" name="bkpwp_restore" value="<?php echo $_REQUEST['bkpwp_restore']; ?>" />
|
26 |
+
<p style="text-align:left" class="submit">
|
27 |
+
<input type="submit" name="bkpwp_restore_now" value="<?php _e("Restore the Database","bkpwp"); ?> »" />
|
28 |
+
<?php
|
29 |
+
if (!eregi("-sql.tar.gz",base64_decode($_REQUEST['bkpwp_restore']))) {
|
30 |
+
?>
|
31 |
+
<a href="admin.php?page=backupwordpress/backupwordpress.php&bkpwp_download=<?php echo $_REQUEST['bkpwp_restore']; ?>"><?php _e("Download the Backup Archive for Files Recovery","bkpwp"); ?> »</a>
|
32 |
+
<?php
|
33 |
+
}
|
34 |
+
?>
|
35 |
+
</p>
|
36 |
+
</form>
|
37 |
+
</p><br />
|
38 |
+
</div><br />
|
39 |
+
<?php
|
40 |
+
} else {
|
41 |
+
if(!eregi(get_option("bkpwppath"),base64_decode($_REQUEST['bkpwp_restore']))) {
|
42 |
+
// must be one of those in here!
|
43 |
+
return;
|
44 |
+
}
|
45 |
+
$source = File_Archive::read(base64_decode($_REQUEST['bkpwp_restore'])."/");
|
46 |
+
$error = array();
|
47 |
+
if (!empty($source)) {
|
48 |
+
$source->close(); //Move back to the begining of the source
|
49 |
+
while($source->next()) {
|
50 |
+
if (eregi(".sql",$source->getFilename())) {
|
51 |
+
//$filename = $source->getFilename();
|
52 |
+
$restoresql = $source->getData();
|
53 |
+
$bkpwppath = get_option("bkpwppath");
|
54 |
+
$filename = $bkpwppath."/bkpwp_restore.sql";
|
55 |
+
// delete an existing file
|
56 |
+
if (is_readable($filename)) {
|
57 |
+
unlink($filename);
|
58 |
+
}
|
59 |
+
// write the new restore dump
|
60 |
+
if (!$handle = fopen($filename, "a")) {
|
61 |
+
$error[] = $filename." ".__("cannot be opened from","bkpwp")." ".$bkpwppath."/";
|
62 |
+
}
|
63 |
+
if (!fwrite($handle, $restoresql)) {
|
64 |
+
$error[] = $filename." ".__("cannot be written to","bkpwp")." ".$bkpwppath."/";
|
65 |
+
}
|
66 |
+
// success
|
67 |
+
fclose($handle);
|
68 |
+
break;
|
69 |
+
}
|
70 |
+
}
|
71 |
+
}
|
72 |
+
if (is_readable($filename)) {
|
73 |
+
//restore with bigdump
|
74 |
+
?>
|
75 |
+
<p><b><?php _e("Please do not reload the page until bigdump has done its job!","bkpwp"); ?></b></p>
|
76 |
+
<iframe width="100%" height="500" style="border:none;" src="<?php echo get_bloginfo("wpurl")."/wp-content/plugins/backupwordpress/bigdump/bigdump.php?start=1&fn=bkpwp_restore.sql&foffset=0&totalqueries=0"; ?>"></iframe>
|
77 |
+
<?php
|
78 |
+
exit;
|
79 |
+
}
|
80 |
+
|
81 |
+
if (count($error) > 0) {
|
82 |
+
?>
|
83 |
+
<div id="message" class="updated fade">
|
84 |
+
<p><?php _e("Some Errors occured while restoring from backup archive","bkpwp"); ?>:</p>
|
85 |
+
<p>
|
86 |
+
<?php
|
87 |
+
foreach($error as $e) {
|
88 |
+
echo $e."<br />";
|
89 |
+
}
|
90 |
+
?>
|
91 |
+
</p>
|
92 |
+
</div><br />
|
93 |
+
<?php
|
94 |
+
} elseif (!empty($restoresql) && (count($error) < 1)) {
|
95 |
+
?>
|
96 |
+
<div id="message" class="updated fade">
|
97 |
+
<p><?php _e("Backup file restored sucessfully from archive: ","bkpwp"); ?>:</p>
|
98 |
+
<p>
|
99 |
+
<?php
|
100 |
+
echo base64_decode($_REQUEST['bkpwp_restore']);
|
101 |
+
?>
|
102 |
+
</p>
|
103 |
+
</div><br />
|
104 |
+
<?php
|
105 |
+
} else {
|
106 |
+
?>
|
107 |
+
<div id="message" class="updated fade">
|
108 |
+
<p><?php _e("Recovery ERROR","bkpwp"); ?>:</p>
|
109 |
+
<p>
|
110 |
+
<?php _e("Backup Archive could not be read.","bkpwp"); ?>
|
111 |
+
</p>
|
112 |
+
</div><br />
|
113 |
+
<?php
|
114 |
+
}
|
115 |
+
}
|
116 |
+
}
|
117 |
+
|
118 |
+
function bkpwp_delete() {
|
119 |
+
if (empty($_REQUEST['bkpwp_delete_now'])) {
|
120 |
+
?>
|
121 |
+
<div id="message" class="updated fade">
|
122 |
+
<p><?php _e("Do you want to delete the backup archive","bkpwp"); ?></p>
|
123 |
+
<p>
|
124 |
+
<?php
|
125 |
+
echo base64_decode($_REQUEST['bkpwp_delete']);
|
126 |
+
?>
|
127 |
+
<form name="form1" method="post" action="">
|
128 |
+
<input type="hidden" name="bkpwp_delete" value="<?php echo $_REQUEST['bkpwp_delete']; ?>" />
|
129 |
+
<p style="text-align:left" class="submit">
|
130 |
+
<input type="submit" name="bkpwp_delete_now" value="<?php _e("delete","bkpwp"); ?> »" />
|
131 |
+
</p>
|
132 |
+
</form>
|
133 |
+
</p><br />
|
134 |
+
</div><br />
|
135 |
+
<?php
|
136 |
+
} else {
|
137 |
+
if(!eregi(get_option("bkpwppath"),base64_decode($_REQUEST['bkpwp_delete']))) {
|
138 |
+
// must be one of those in here!
|
139 |
+
return;
|
140 |
+
}
|
141 |
+
if (unlink(base64_decode($_REQUEST['bkpwp_delete']))) {
|
142 |
+
?>
|
143 |
+
<div id="message" class="updated fade">
|
144 |
+
<p><?php _e("Backup file deleted sucessfully","bkpwp"); ?>:</p>
|
145 |
+
<p>
|
146 |
+
<?php
|
147 |
+
echo base64_decode($_REQUEST['bkpwp_delete']);
|
148 |
+
?>
|
149 |
+
</p>
|
150 |
+
</div><br />
|
151 |
+
<?php
|
152 |
+
} else {
|
153 |
+
?>
|
154 |
+
<div id="message" class="updated fade">
|
155 |
+
<p><?php _e("Backup file deletion failed","bkpwp"); ?>:</p>
|
156 |
+
<p>
|
157 |
+
<?php
|
158 |
+
echo base64_decode($_REQUEST['bkpwp_delete']);
|
159 |
+
?>
|
160 |
+
</p>
|
161 |
+
</div><br />
|
162 |
+
<?php
|
163 |
+
}
|
164 |
+
}
|
165 |
+
}
|
166 |
+
|
167 |
+
function bkpwp_mail() {
|
168 |
+
|
169 |
+
$backupinfo = new BKPWP_BACKUP_ARCHIVE();
|
170 |
+
$info = $backupinfo->bkpwp_view_backup_info($_REQUEST['bkpwp_mail'],1);
|
171 |
+
$bkpwp_automail = get_option("bkpwp_automail");
|
172 |
+
$bkpwp_automail_maxsize = get_option("bkpwp_automail_maxsize");
|
173 |
+
if (empty($_REQUEST['bkpwp_mail_now']) && eregi("MB",$info['filesize'])) {
|
174 |
+
?>
|
175 |
+
<div id="message" class="updated fade">
|
176 |
+
<p><?php _e("The BackUp Archive File you want to send is","bkpwp"); echo " <b>".$info['filesize']."</b> "; _e("large","bkpwp"); echo ".<br />"; ?>
|
177 |
+
<?php _e("Do you really want to send this file by email?","bkpwp"); ?></p>
|
178 |
+
<p>
|
179 |
+
<?php
|
180 |
+
echo base64_decode($_REQUEST['bkpwp_mail']);
|
181 |
+
?>
|
182 |
+
<form name="form1" method="post" action="">
|
183 |
+
<input type="hidden" name="bkpwp_mail" value="<?php echo $_REQUEST['bkpwp_mail']; ?>" />
|
184 |
+
<p style="text-align:left" class="submit">
|
185 |
+
<input type="submit" name="bkpwp_mail_now" value="<?php _e("send","bkpwp"); ?> »" />
|
186 |
+
</p>
|
187 |
+
</form>
|
188 |
+
</p><br />
|
189 |
+
</div><br />
|
190 |
+
<?php
|
191 |
+
} else {
|
192 |
+
if (!empty($bkpwp_automail)) {
|
193 |
+
if ($bkpwp_automail_maxsize <= filesize(base64_decode($_REQUEST['bkpwp_mail']))) {
|
194 |
+
$mailed = bkpwp_mail_now($_REQUEST['bkpwp_mail']);
|
195 |
+
} else {
|
196 |
+
$mailed = bkpwp_mail_now("");
|
197 |
+
}
|
198 |
+
}
|
199 |
+
if(isset($mailed)) {
|
200 |
+
?>
|
201 |
+
<div id="message" class="updated fade">
|
202 |
+
<p><?php _e("Backup has been sent","bkpwp"); ?></p>
|
203 |
+
<p>
|
204 |
+
<?php
|
205 |
+
echo base64_decode($_REQUEST['bkpwp_mail']);
|
206 |
+
?>
|
207 |
+
</p>
|
208 |
+
</div><br />
|
209 |
+
<?php
|
210 |
+
} else {
|
211 |
+
?>
|
212 |
+
<div id="message" class="updated fade">
|
213 |
+
<p><?php _e("Error sending Backup by mail","bkpwp"); ?></p>
|
214 |
+
<p>
|
215 |
+
<?php
|
216 |
+
echo base64_decode($_REQUEST['bkpwp_mail']);
|
217 |
+
?>
|
218 |
+
</p>
|
219 |
+
</div><br />
|
220 |
+
<?php
|
221 |
+
}
|
222 |
+
}
|
223 |
+
}
|
224 |
+
|
225 |
+
?>
|
226 |
+
<div class="wrap">
|
227 |
+
<?php
|
228 |
+
if (count($backup_archives) < 1) {
|
229 |
+
echo "<h4>".__("No Backups yet","bkpwp").".</h4>";
|
230 |
+
$bwpwp_path = $backups->options->bkpwp_path();
|
231 |
+
if (empty($bwpwp_path)) {
|
232 |
+
echo "<a href=\"admin.php?page=bkpwp_options\">".__("Start by configuring the Options","bkpwp")."</a>";
|
233 |
+
return;
|
234 |
+
}
|
235 |
+
}
|
236 |
+
?>
|
237 |
+
<h2><?php _e("Manage Backups","bkpwp"); ?></h2>
|
238 |
+
<script type="text/javascript">
|
239 |
+
<!-- ajax call to the actual backup function -->
|
240 |
+
function do_create() {
|
241 |
+
var preset;
|
242 |
+
<?php if (!$backups->options->bkpwp_easy_mode()) { ?>
|
243 |
+
preset = document.getElementById('bkpwp_preset').options[document.getElementById('bkpwp_preset').selectedIndex].value;
|
244 |
+
<?php } else { ?>
|
245 |
+
preset = "full backup";
|
246 |
+
<?php } ?>
|
247 |
+
document.getElementById('bkpwp_manage_backups_newrow').style.display="table-row";
|
248 |
+
document.getElementById('bkpwp_manage_backups_newrow').innerHTML="<th scope=\"row\"><?php echo date(get_option('date_format'))." ".date("H:i"); ?></th><td colspan=\"<?php if (!$backups->options->bkpwp_easy_mode()) { echo "8"; } else { echo "3"; } ?>\"><img src='<?php bloginfo("url"); ?>/wp-content/plugins/backupwordpress/images/loading.gif' /> <?php _e("Creating backup. Please wait."); ?></td>";
|
249 |
+
sajax_target_id = 'bkpwp_manage_backups_newrow';
|
250 |
+
x_bkpwp_ajax_create(preset,'');
|
251 |
+
}
|
252 |
+
|
253 |
+
<!-- ajax call for calculating disk space usage -->
|
254 |
+
function calculate() {
|
255 |
+
var preset;
|
256 |
+
<?php if (!$backups->options->bkpwp_easy_mode()) { ?>
|
257 |
+
preset = document.getElementById('bkpwp_preset').options[document.getElementById('bkpwp_preset').selectedIndex].value;
|
258 |
+
<?php } else { ?>
|
259 |
+
preset = "full backup";
|
260 |
+
<?php } ?>
|
261 |
+
x_bkpwp_ajax_calculater(preset,'');
|
262 |
+
}
|
263 |
+
|
264 |
+
<!-- displays a loading text information while doing ajax requests -->
|
265 |
+
function bkpwp_js_loading(str) {
|
266 |
+
document.getElementById('bkpwp_actions').style.display = 'block';
|
267 |
+
is_loading('bkpwp_action_buffer');
|
268 |
+
sajax_target_id = 'bkpwp_action_buffer';
|
269 |
+
document.getElementById('bkpwp_action_title').innerHTML="<h4>" + str + "</h4>";
|
270 |
+
}
|
271 |
+
</script>
|
272 |
+
<div id="bkpwp_actions" style="display:none;">
|
273 |
+
<div id="bkpwp_action_title"></div>
|
274 |
+
<div id="bkpwp_action_buffer"></div>
|
275 |
+
</div>
|
276 |
+
<?php if (!$backups->options->bkpwp_easy_mode()) { ?>
|
277 |
+
<?php $presets = $backups->bkpwp_get_presets();
|
278 |
+
if (is_array($presets)) { ?>
|
279 |
+
<p>
|
280 |
+
<?php _e("Select a Preset.","bkpwp"); ?>
|
281 |
+
<select name="bkpwp_preset" id="bkpwp_preset">
|
282 |
+
<?php
|
283 |
+
foreach ($presets as $p) {
|
284 |
+
echo "<option value=\"".$p['bkpwp_preset_name']."\">".$p['bkpwp_preset_name']."</option>";
|
285 |
+
}
|
286 |
+
?>
|
287 |
+
</select> <a href="admin.php?page=bkpwp_manage_presets"><?php _e("Configure","bkpwp"); ?> »</a>
|
288 |
+
</p>
|
289 |
+
<?php }
|
290 |
+
} ?>
|
291 |
+
<button class="button" onclick="do_create(); sajax_target_id = ''; return false;"><?php _e("BackUp WordPress Now","bkpwp"); ?> »</button>
|
292 |
+
<?php if (!$backups->options->bkpwp_easy_mode()) { ?>
|
293 |
+
<button class="button" onclick="bkpwp_js_loading('<?php _e("Calculating used disk space","bkpwp"); ?>'); calculate(); sajax_target_id = ''; return false;"><?php _e("Recalculate Used Disk Space","bkpwp"); ?> »</button>
|
294 |
+
<?php } ?>
|
295 |
+
|
296 |
+
|
297 |
+
<?php
|
298 |
+
/* delete the backup (but leave the logfile for a while!) */
|
299 |
+
if (!empty($_REQUEST['bkpwp_delete'])) {
|
300 |
+
bkpwp_delete();
|
301 |
+
}
|
302 |
+
/* mail the backup to someone */
|
303 |
+
if (!empty($_REQUEST['bkpwp_mail'])) {
|
304 |
+
bkpwp_mail();
|
305 |
+
}
|
306 |
+
if (!empty($_REQUEST['bkpwp_restore'])) {
|
307 |
+
bkpwp_restore();
|
308 |
+
}
|
309 |
+
?>
|
310 |
+
|
311 |
+
<br /><br />
|
312 |
+
<?php if (!$backups->options->bkpwp_easy_mode()) { ?>
|
313 |
+
<?php _e("Your configuration is set to a maximum of","bkpwp"); ?>
|
314 |
+
<?php echo get_option('bkpwp_max_backups'); ?>
|
315 |
+
<?php _e("Backups.","bkpwp"); ?>
|
316 |
+
<a href="admin.php?page=bkpwp_options#backup_options"><?php _e("Configure","bkpwp"); ?> »</a>
|
317 |
+
<br /><br />
|
318 |
+
<?php } ?>
|
319 |
+
<?php if (count($backup_archives) > $backups->bkpwp_max_views()) { ?>
|
320 |
+
<?php _e("displaying the last","bkpwp"); ?>
|
321 |
+
<?php echo $backups->bkpwp_max_views(); ?>
|
322 |
+
<?php _e("Backups.","bkpwp"); ?>
|
323 |
+
<?php echo count($backup_archives); ?>
|
324 |
+
<?php _e("Backups at all.","bkpwp"); ?>
|
325 |
+
<a href="admin.php?page=<?php echo $_REQUEST['page']; ?>&bkpwp_show_all=1"><?php _e("Show all","bkpwp"); ?> »</a>
|
326 |
+
<br /><br />
|
327 |
+
<?php } ?>
|
328 |
+
<table class="widefat" id="bkpwp_manage_backups_table">
|
329 |
+
<thead>
|
330 |
+
<tr>
|
331 |
+
<th scope="col"><?php _e("Date/Time","bkpwp"); ?></th>
|
332 |
+
<?php if (!$backups->options->bkpwp_easy_mode()) { ?>
|
333 |
+
<th scope="col"><?php _e("Type","bkpwp"); ?></th>
|
334 |
+
<th scope="col"><?php _e("Preset","bkpwp"); ?></th>
|
335 |
+
<?php } ?>
|
336 |
+
<th scope="col"><?php _e("Size","bkpwp"); ?></th>
|
337 |
+
<th style="text-align: center;" colspan="5" scope="col"><?php _e("Action","bkpwp"); ?></th>
|
338 |
+
</tr>
|
339 |
+
</thead>
|
340 |
+
<tbody id="the-list">
|
341 |
+
<?php
|
342 |
+
$alternate = "alternate";
|
343 |
+
?>
|
344 |
+
<tr class="<?php echo $alternate; ?> bkpwp_manage_backups_newrow" id="bkpwp_manage_backups_newrow" style="display:none;">
|
345 |
+
<td colspan="7">
|
346 |
+
</td>
|
347 |
+
</tr>
|
348 |
+
<?php
|
349 |
+
$i=0;
|
350 |
+
foreach ($backup_archives as $f) {
|
351 |
+
if (!file_exists($f['file'])) {
|
352 |
+
continue;
|
353 |
+
}
|
354 |
+
if ($i > $backups->bkpwp_max_views()) {
|
355 |
+
break;
|
356 |
+
}
|
357 |
+
if ($alternate == "") { $alternate = "alternate"; } else { $alternate = ""; }
|
358 |
+
$backup = new BKPWP_BACKUP_ARCHIVE();
|
359 |
+
$backup->bkpwp_get_backup_row($f,$alternate);
|
360 |
+
$i++;
|
361 |
+
}
|
362 |
+
?>
|
363 |
+
</tbody>
|
364 |
+
</table>
|
365 |
+
</div>
|
bkpwp-pages/bkpwp_manage_presets.php
ADDED
@@ -0,0 +1,156 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
function bkpwp_presetlist() {
|
4 |
+
|
5 |
+
$backups = new BKPWP_MANAGE();
|
6 |
+
$backups->options = new BKPWP_OPTIONS();
|
7 |
+
|
8 |
+
$presets = $backups->bkpwp_get_presets();
|
9 |
+
|
10 |
+
if ($backups->options->bkpwp_easy_mode()) { return; }
|
11 |
+
if (!is_array($presets)) { return; }
|
12 |
+
|
13 |
+
if (!empty($_REQUEST['mod_bkpwp_preset_name'])) {
|
14 |
+
$preset = $backups->bkpwp_get_preset($_REQUEST['mod_bkpwp_preset_name']);
|
15 |
+
echo $backups->bkpwp_load_preset($preset);
|
16 |
+
}
|
17 |
+
|
18 |
+
/* delete the backup (but leave the logfile for a while!) */
|
19 |
+
if (!empty($_REQUEST['bkpwp_delete_preset'])) {
|
20 |
+
$backups->bkpwp_delete_preset(urldecode($_REQUEST['bkpwp_delete_preset']));
|
21 |
+
}
|
22 |
+
?>
|
23 |
+
<table class="widefat">
|
24 |
+
<thead>
|
25 |
+
<tr>
|
26 |
+
<th scope="col"><?php _e("Preset Name","bkpwp"); ?></th>
|
27 |
+
<th scope="col"><?php _e("Archive Type","bkpwp"); ?></th>
|
28 |
+
<th scope="col"><?php _e("Exclude List","bkpwp"); ?></th>
|
29 |
+
<th scope="col"><?php _e("SQL/Full","bkpwp"); ?></th>
|
30 |
+
<th style="text-align: center;" colspan="3" scope="col"><?php _e("Action","bkpwp"); ?></th>
|
31 |
+
</tr>
|
32 |
+
</thead>
|
33 |
+
<tbody id="the-list">
|
34 |
+
<?php
|
35 |
+
$alternate = "alternate";
|
36 |
+
$i=0;
|
37 |
+
|
38 |
+
foreach($presets as $p) {
|
39 |
+
|
40 |
+
if ($alternate == "") { $alternate = "alternate"; } else { $alternate = ""; }
|
41 |
+
?>
|
42 |
+
<tr class="<?php echo $alternate; ?>">
|
43 |
+
<th scope="row"><?php
|
44 |
+
echo $p['bkpwp_preset_name'];
|
45 |
+
?></th>
|
46 |
+
<td>
|
47 |
+
<?php
|
48 |
+
echo $p['bkpwp_preset_options']['bkpwp_archive_type'];
|
49 |
+
?>
|
50 |
+
</td>
|
51 |
+
<td>
|
52 |
+
<?php
|
53 |
+
if ($p['bkpwp_preset_options']['bkpwp_sql_only'] != 1) {
|
54 |
+
echo $p['bkpwp_preset_options']['bkpwp_excludelist'];
|
55 |
+
} else {
|
56 |
+
echo " ";
|
57 |
+
}
|
58 |
+
?>
|
59 |
+
</td>
|
60 |
+
<td>
|
61 |
+
<?php
|
62 |
+
if ($p['bkpwp_preset_options']['bkpwp_sql_only'] == 1) {
|
63 |
+
echo "sql";
|
64 |
+
} else {
|
65 |
+
echo "full";
|
66 |
+
}
|
67 |
+
?>
|
68 |
+
</td>
|
69 |
+
<td style="text-align: center;">
|
70 |
+
<?php
|
71 |
+
echo " <a href=\"javascript:void(0)\"
|
72 |
+
onclick=\"is_loading('bkpwp_preset_options');
|
73 |
+
sajax_target_id = 'bkpwp_preset_options';
|
74 |
+
x_bkpwp_ajax_load_preset('".$p['bkpwp_preset_name']."','');
|
75 |
+
sajax_target_id = '';\">".__("edit","bkpwp")."</a>";
|
76 |
+
?>
|
77 |
+
</td>
|
78 |
+
<td style="text-align: center;">
|
79 |
+
<?php
|
80 |
+
echo " <a href=\"javascript:void(0)\"
|
81 |
+
onclick=\"is_loading('bkpwp_preset_options');
|
82 |
+
sajax_target_id = 'bkpwp_preset_options';
|
83 |
+
x_bkpwp_ajax_view_preset('".$p['bkpwp_preset_name']."','');
|
84 |
+
sajax_target_id = '';\">".__("view","bkpwp")."</a>";
|
85 |
+
?>
|
86 |
+
</td>
|
87 |
+
<td style="text-align: center;">
|
88 |
+
<?php
|
89 |
+
if ($p['bkpwp_preset_options']['default'] != 1) {
|
90 |
+
echo " <a href=\"admin.php?page=bkpwp-backup-presets-page&bkpwp_delete_preset=".$p['bkpwp_preset_name']."\">".__("delete","bkpwp")."</a>";
|
91 |
+
} else {
|
92 |
+
echo __("default","bkpwp");
|
93 |
+
}
|
94 |
+
?>
|
95 |
+
</td>
|
96 |
+
<?php
|
97 |
+
?>
|
98 |
+
</tr>
|
99 |
+
<?php
|
100 |
+
$i++;
|
101 |
+
}
|
102 |
+
?>
|
103 |
+
</tbody>
|
104 |
+
</table>
|
105 |
+
<?php
|
106 |
+
}
|
107 |
+
|
108 |
+
?>
|
109 |
+
<div class="wrap">
|
110 |
+
<script type="text/javascript">
|
111 |
+
|
112 |
+
function save_preset() {
|
113 |
+
var name;
|
114 |
+
var archive_type;
|
115 |
+
var excludelist;
|
116 |
+
var sql_only;
|
117 |
+
name = document.getElementById('mod_bkpwp_preset_name').value;
|
118 |
+
archive_type = document.getElementById('mod_bkpwp_archive_type').value;
|
119 |
+
excludelist = document.getElementById('mod_bkpwp_excludelist').value;
|
120 |
+
sql_only = document.getElementById('mod_bkpwp_sql_only').value;
|
121 |
+
x_bkpwp_ajax_save_preset(name,archive_type,excludelist,sql_only,"");
|
122 |
+
}
|
123 |
+
|
124 |
+
function delete_preset() {
|
125 |
+
var name;
|
126 |
+
name = document.getElementById('mod_bkpwp_preset_name').value;
|
127 |
+
x_bkpwp_ajax_delete_preset(name,"");
|
128 |
+
}
|
129 |
+
|
130 |
+
function is_loading(divid) {
|
131 |
+
document.getElementById(divid).innerHTML="<img src='<?php bloginfo("url"); ?>/wp-content/plugins/backupwordpress/images/loading.gif' />";
|
132 |
+
}
|
133 |
+
<!-- displays a loading text information while doing ajax requests -->
|
134 |
+
function bkpwp_js_loading(str) {
|
135 |
+
document.getElementById('bkpwp_actions').style.display = 'block';
|
136 |
+
is_loading('bkpwp_action_buffer');
|
137 |
+
sajax_target_id = 'bkpwp_action_buffer';
|
138 |
+
document.getElementById('bkpwp_action_title').innerHTML="<h4>" + str + "</h4>";
|
139 |
+
}
|
140 |
+
</script>
|
141 |
+
<?php
|
142 |
+
|
143 |
+
echo "<h2>".__("Manage Backup Presets","bkpwp")."</h2>";
|
144 |
+
?>
|
145 |
+
<p><?php _e("To create a new backup preset, edit one of the defaults and save with a new preset name.","bkpwp"); ?></p>
|
146 |
+
<div id="bkpwp_actions" style="display:none;">
|
147 |
+
<div id="bkpwp_action_title"></div>
|
148 |
+
<div id="bkpwp_action_buffer"></div>
|
149 |
+
</div>
|
150 |
+
<div id="bkpwp_preset_options" style="display:block; margin-bottom: 10px;">
|
151 |
+
</div>
|
152 |
+
<?php
|
153 |
+
bkpwp_presetlist();
|
154 |
+
|
155 |
+
?>
|
156 |
+
</div>
|
bkpwp-pages/bkpwp_options.php
ADDED
@@ -0,0 +1,220 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
$options = new BKPWP_OPTIONS();
|
3 |
+
$bkpwppath = get_option("bkpwppath");
|
4 |
+
?>
|
5 |
+
<div class="wrap">
|
6 |
+
<?php
|
7 |
+
if (!empty($_REQUEST['bkpwp_toggle_schedule_active'])) {
|
8 |
+
?>
|
9 |
+
<div id="message" class="updated fade">
|
10 |
+
<p><?php
|
11 |
+
$schedule = new BKPWP_SCHEDULE();
|
12 |
+
$ret = $schedule->bkpwp_toggle_schedule($_REQUEST['bkpwp_toggle_schedule_active']);
|
13 |
+
if($ret) {
|
14 |
+
_e("Schedule activity status set to","bkpwp");
|
15 |
+
echo " <b>";
|
16 |
+
if ($ret == "active") {
|
17 |
+
_e("active","bkpwp");
|
18 |
+
} else {
|
19 |
+
_e("inactive","bkpwp");
|
20 |
+
}
|
21 |
+
echo "</b>";
|
22 |
+
} else {
|
23 |
+
_e("Schedule activity status could not be set","bkpwp");
|
24 |
+
}
|
25 |
+
?></p>
|
26 |
+
</div>
|
27 |
+
<p />
|
28 |
+
<?php
|
29 |
+
}
|
30 |
+
if (!empty($bkpwppath)) {
|
31 |
+
if ($options->bkpwp_easy_mode()) { ?>
|
32 |
+
<?php _e("You are running BackUpWordPress in ","bkpwp"); ?>
|
33 |
+
<h2><?php _e("EasyMode","bkpwp"); ?>.</h2>
|
34 |
+
<?php _e("Configuration options below","bkpwp"); ?>.
|
35 |
+
<?php _e("For more options, please swith to ","bkpwp"); ?>
|
36 |
+
<a href="admin.php?page=<?php echo $_REQUEST['page']; ?>&bkpwp_modeswitch=1"><?php _e("AdvancedMode","bkpwp"); ?> »</a>
|
37 |
+
<?php } else { ?>
|
38 |
+
<?php _e("You are running BackUpWordPress in ","bkpwp"); ?>
|
39 |
+
<h2><?php _e("AdvancedMode","bkpwp"); ?>.</h2>
|
40 |
+
<?php _e("Configuration options below","bkpwp"); ?>.
|
41 |
+
<?php _e("For less options, please swith to ","bkpwp"); ?>
|
42 |
+
<a href="admin.php?page=<?php echo $_REQUEST['page']; ?>&bkpwp_modeswitch=1"><?php _e("EasyMode","bkpwp"); ?> »</a>
|
43 |
+
<?php }
|
44 |
+
}
|
45 |
+
?>
|
46 |
+
<?php $options->bkpwp_handle_backup_path(); ?>
|
47 |
+
<h2><?php _e("Backup Path","bkpwp"); ?></h2>
|
48 |
+
<p>
|
49 |
+
<?php _e("This is where all your backups go","bkpwp"); ?>
|
50 |
+
<form name="form1" method="post" action="admin.php?page=<?php echo $_REQUEST['page']; ?>">
|
51 |
+
<fieldset>
|
52 |
+
<?php if ($options->bkpwp_easy_mode()) { echo bkpwp_conform_dir(ABSPATH); } ?>
|
53 |
+
<input type="text" size="50" value="<?php $options->bkpwp_check_path(); ?>" name="bkpwppath" />
|
54 |
+
<input type="submit" class="button" value="<?php _e("save","bkpwp"); ?>" />
|
55 |
+
</fieldset>
|
56 |
+
</form>
|
57 |
+
</p>
|
58 |
+
<?php
|
59 |
+
if (!empty($bkpwppath)) {
|
60 |
+
?>
|
61 |
+
<a name="backup_options"></a>
|
62 |
+
<?php $options->bkpwp_handle_backup_settings(); ?>
|
63 |
+
<h2><?php _e("Basic Scheduling","bkpwp"); ?></h2>
|
64 |
+
<p>
|
65 |
+
<?php _e("Do you want BackUpWordPress to be scheduled and run automatically?","bkpwp"); ?>
|
66 |
+
</p>
|
67 |
+
<p>
|
68 |
+
<?php
|
69 |
+
$schedules = get_option("bkpwp_schedules");
|
70 |
+
if (is_array($schedules)) {
|
71 |
+
foreach($schedules as $s) {
|
72 |
+
if ($s['default'] != 1) { continue; }
|
73 |
+
if (!empty($s['status'])) {
|
74 |
+
echo __("Backup Type","bkpwp").": ".$s['info'].": ";
|
75 |
+
if ($s['status'] == "inactive") {
|
76 |
+
echo __("is not activated","bkpwp")." <a href=\"admin.php?page=".$_REQUEST['page']."&bkpwp_toggle_schedule_active=".$s['created']."\">".__("activate","bkpwp")." »</a>";
|
77 |
+
} else {
|
78 |
+
echo __("is currently set to active","bkpwp")." <a href=\"admin.php?page=".$_REQUEST['page']."&bkpwp_toggle_schedule_active=".$s['created']."\">".__("deactivate","bkpwp")." »</a>";
|
79 |
+
}
|
80 |
+
}
|
81 |
+
echo "<br />";
|
82 |
+
}
|
83 |
+
}
|
84 |
+
?>
|
85 |
+
</p>
|
86 |
+
<a name="backup_automail"></a>
|
87 |
+
<?php
|
88 |
+
$options->bkpwp_handle_backup_automail();
|
89 |
+
$bkpwp_automail = get_option("bkpwp_automail");
|
90 |
+
?>
|
91 |
+
<h2><?php _e("Mail Setup","bkpwp"); ?></h2>
|
92 |
+
<p>
|
93 |
+
<?php _e("Do you want to receive your backups automatically by email?","bkpwp"); ?>
|
94 |
+
<form name="form1" method="post" action="admin.php?page=<?php echo $_REQUEST['page']; ?>">
|
95 |
+
<fieldset>
|
96 |
+
<?php if ($options->bkpwp_easy_mode()) { } ?>
|
97 |
+
<p><?php _e("Mail to:","bkpwp"); ?><b> <?php echo $GLOBALS['userdata']->user_email; ?></b></p>
|
98 |
+
<p><input type="checkbox" size="50" value="1" name="bkpwp_automail" <?php if(!empty($bkpwp_automail)) { echo " checked"; } ?> />
|
99 |
+
<?php _e("Yes, send me my backups","bkpwp"); ?></p>
|
100 |
+
<p><?php _e("as long as they are smaller than","bkpwp"); ?>
|
101 |
+
<input type="text" size="4" value="<?php echo get_option("bkpwp_automail_maxsize"); ?>" name="bkpwp_automail_maxsize" />
|
102 |
+
<?php _e("MB (megabytes)","bkpwp"); ?></p>
|
103 |
+
<input type="submit" class="button" name="bkpwp_automailsettings" value="<?php _e("save","bkpwp"); ?>" />
|
104 |
+
</fieldset>
|
105 |
+
</form>
|
106 |
+
</p>
|
107 |
+
<?php
|
108 |
+
}
|
109 |
+
?>
|
110 |
+
|
111 |
+
<?php if (!$options->bkpwp_easy_mode()) { // AdvancedMode
|
112 |
+
?>
|
113 |
+
<a name="backup_options"></a>
|
114 |
+
<?php $options->bkpwp_handle_backup_settings(); ?>
|
115 |
+
<legend><h2><?php _e("Backup Storage","bkpwp"); ?></h2></legend>
|
116 |
+
<p>
|
117 |
+
<?php _e("How many Backups do you want to keep?","bkpwp"); ?>
|
118 |
+
<form name="form1" method="post" action="admin.php?page=<?php echo $_REQUEST['page']; ?>">
|
119 |
+
<fieldset>
|
120 |
+
<label for"bkpwp_max_backups">
|
121 |
+
<?php _e("maximum Backups","bkpwp"); ?> <input type="text" size="3" value="<?php
|
122 |
+
echo get_option("bkpwp_max_backups"); ?>" name="bkpwp_max_backups" id="bkpwp_max_backups" />
|
123 |
+
</label>
|
124 |
+
<p style="text-align:left" class="submit">
|
125 |
+
<input type="submit" name="bkpwp_backup_options" value="<?php _e("save","bkpwp"); ?>" />
|
126 |
+
</p>
|
127 |
+
</fieldset>
|
128 |
+
</form>
|
129 |
+
</p>
|
130 |
+
|
131 |
+
<a name="excludelist"></a>
|
132 |
+
<legend><h2><?php _e("Exclude Lists","bkpwp"); ?></h2></legend>
|
133 |
+
</p>
|
134 |
+
<?php $options->bkpwp_handle_backup_excludelists(); ?>
|
135 |
+
<?php
|
136 |
+
if (is_array($options->bkpwp_get_excludelists())) {
|
137 |
+
if (!empty($_REQUEST['excludelist_to_change'])) {
|
138 |
+
$listn = $_REQUEST['excludelist_to_change'];
|
139 |
+
}
|
140 |
+
if (!empty($_REQUEST['excludelistname'])) {
|
141 |
+
$listn = $_REQUEST['excludelistname'];
|
142 |
+
}
|
143 |
+
?>
|
144 |
+
<script type="text/javascript">
|
145 |
+
function do_show_nobfiles() {
|
146 |
+
x_bkpwp_ajax_shownobfiles('<?php echo urlencode($listn); ?>',"","");
|
147 |
+
}
|
148 |
+
function loading_shownobfiles() {
|
149 |
+
document.getElementById('bkpwp_actions').style.display="block";
|
150 |
+
document.getElementById('bkpwp_action_title').innerHTML="<br /><?php _e("Files & Folders that will NOT (!) be included in the Backup when using ","bkpwp"); echo $_REQUEST['excludelist_to_change']; ?><br /><br />";
|
151 |
+
document.getElementById('bkpwp_action_buffer').innerHTML="<img src='<?php bloginfo("url"); ?>/wp-content/plugins/backupwordpress/images/loading.gif' />";
|
152 |
+
}
|
153 |
+
</script>
|
154 |
+
<div id="bkpwp_actions" style="display:none;">
|
155 |
+
<div id="bkpwp_action_title"></div>
|
156 |
+
<div id="bkpwp_action_buffer"></div>
|
157 |
+
<br /><br />
|
158 |
+
</div>
|
159 |
+
<?php
|
160 |
+
}
|
161 |
+
?>
|
162 |
+
<?php if (is_array($options->bkpwp_get_excludelists())) { ?>
|
163 |
+
<form name="form_excl_lists" method="post" action="admin.php?page=<?php echo $_REQUEST['page']; ?>#excludelist">
|
164 |
+
<?php } ?>
|
165 |
+
<form name="form1" method="post" action="admin.php?page=<?php echo $_REQUEST['page']; ?>#excludelist">
|
166 |
+
<fieldset>
|
167 |
+
<?php _e("Edit an existing Exclude List","bkpwp"); ?>
|
168 |
+
<select name="excludelist_to_change" onchange="document.form_excl_lists.submit();">
|
169 |
+
<option value=""><?php _e("Please select","bkpwp"); ?></option>
|
170 |
+
<?php foreach($options->bkpwp_get_excludelists() as $f) { ?>
|
171 |
+
<option value="<?php echo $f['listname']; ?>"<?php
|
172 |
+
if ($listn == $f['listname']) {
|
173 |
+
echo " selected";
|
174 |
+
}
|
175 |
+
?>><?php echo $f['listname']; ?></option>
|
176 |
+
<?php } ?>
|
177 |
+
</select>
|
178 |
+
</form><br /><br />
|
179 |
+
<?php if (!empty($_REQUEST['excludelist_to_change']) || !empty($_REQUEST['excludelistname'])) {
|
180 |
+
$list = $options->bkpwp_excludelist_tochange();
|
181 |
+
?>
|
182 |
+
|
183 |
+
<?php if ($list['listtype'] != "default") { ?>
|
184 |
+
<b><?php _e("Exclude List Name","bkpwp"); ?></b>
|
185 |
+
<p><input type="text" value="<?php echo $list['listname']; ?>" name="excludelistname" size="20" /></p>
|
186 |
+
<?php
|
187 |
+
}
|
188 |
+
if (is_array($list['list'])) {
|
189 |
+
_e("Files to exclude","bkpwp");
|
190 |
+
?><br /><?php
|
191 |
+
foreach($list['list'] as $f) {
|
192 |
+
if ($f != $options->bkpwp_path()) {
|
193 |
+
?>
|
194 |
+
<input type="text" name="excludelist[]" value="<?php echo $f; ?>" size="50" />*<br />
|
195 |
+
<?php }
|
196 |
+
}
|
197 |
+
}?>
|
198 |
+
<?php if ($list['listtype'] != "default") { ?>
|
199 |
+
<p style="text-align:left" class="submit"><input name="nobackupchange" type="submit" value="<?php _e("save","bkpwp"); ?>" /> <input name="nobackupdelete" type="submit" value="<?php _e("delete","bkpwp"); ?>" />
|
200 |
+
<?php } else { ?>
|
201 |
+
<p><?php _e("this is a Default Exclude List","bkpwp"); ?>
|
202 |
+
<?php } ?>
|
203 |
+
<button class="button" onclick="loading_shownobfiles(); sajax_target_id = 'bkpwp_action_buffer'; do_show_nobfiles(); sajax_target_id = ''; return false;">» <?php _e("Show excluded files","bkpwp"); ?></button>
|
204 |
+
</p>
|
205 |
+
<?php } else { ?>
|
206 |
+
<h4><?php _e("New Exclude List","bkpwp"); ?></h4>
|
207 |
+
<?php _e("Name","bkpwp"); ?> <input type="text" name="excludelistname" size="20" /><br />
|
208 |
+
<?php _e("Files to exclude","bkpwp"); ?> <input type="text" name="excludelist[]" size="50" />*<br />
|
209 |
+
<p style="text-align:left" class="submit"><input name="nobackup" type="submit" value="<?php _e("save","bkpwp"); ?>" /></p>
|
210 |
+
<?php } ?>
|
211 |
+
</fieldset>
|
212 |
+
</form>
|
213 |
+
*<?php _e("enter an <b>absolute or relative path</b> to your folders/ files not to backup","bkpwp"); ?><br />
|
214 |
+
<?php _e("or <b>just names or file-extensions (.php, .txt) which should match files</b>","bkpwp"); ?>,<br />
|
215 |
+
<?php _e("no need to take care of the <b>backup folder</b>, it <b>will be excluded anyways","bkpwp"); ?></b>.<br />
|
216 |
+
<?php _e("Seperate with commas.","bkpwp"); ?><br/><br/>
|
217 |
+
</p>
|
218 |
+
<?php } ?>
|
219 |
+
</div>
|
220 |
+
|
bkpwp-pages/bkpwp_schedule.php
ADDED
@@ -0,0 +1,250 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
function bkpwp_schedulelist($bkpwppath) {
|
4 |
+
//delete_option("cron");
|
5 |
+
echo "<h2>".__("Manage Backup Schedules","bkpwp")."</h2>";
|
6 |
+
echo "<p>".__("Info: Creating custom schedules is on the wishlist for BackUpWordPress 2.0.","bkpwp")."</p>";
|
7 |
+
?>
|
8 |
+
<form name="form1" method="post" action="admin.php?page=<?php echo $_REQUEST['page']; ?>">
|
9 |
+
<fieldset>
|
10 |
+
<input class="button" type="submit" name="bkpwp_reset_schedules" value="<?php _e("reset default schedules","bkpwp"); ?> »" />
|
11 |
+
<input class="button" type="submit" name="bkpwp_test_schedule" value="<?php _e("test schedules","bkpwp"); ?> »" />
|
12 |
+
</fieldset>
|
13 |
+
</form>
|
14 |
+
<?php
|
15 |
+
$crons = get_option("cron");
|
16 |
+
if (!is_array($crons)) {
|
17 |
+
return;
|
18 |
+
}
|
19 |
+
$schedules = get_option("bkpwp_schedules");
|
20 |
+
?>
|
21 |
+
<table class="widefat">
|
22 |
+
<thead>
|
23 |
+
<tr>
|
24 |
+
<th style="text-align: center;" scope="col"><?php _e("Last run","bkpwp"); ?></th>
|
25 |
+
<th style="text-align: center;" scope="col"><?php _e("Next run","bkpwp"); ?></th>
|
26 |
+
<th style="text-align: center;" scope="col"><?php _e("Countdown","bkpwp"); ?></th>
|
27 |
+
<th scope="col"><?php _e("Backup Preset","bkpwp"); ?></th>
|
28 |
+
<th scope="col"><?php _e("Reccurrence","bkpwp"); ?></th>
|
29 |
+
<th style="text-align: center;" colspan="3" scope="col"><?php _e("Action","bkpwp"); ?></th>
|
30 |
+
</tr>
|
31 |
+
</thead>
|
32 |
+
<tbody id="the-list">
|
33 |
+
<?php
|
34 |
+
$alternate = "alternate";
|
35 |
+
$i=1;
|
36 |
+
foreach ($schedules as $options) {
|
37 |
+
$timestamp = wp_next_scheduled("bkpwp_schedule_bkpwp_hook",$options);
|
38 |
+
if ($alternate == "") { $alternate = "alternate"; } else { $alternate = ""; }
|
39 |
+
?>
|
40 |
+
<tr class="<?php echo $alternate; ?>">
|
41 |
+
<th style="text-align: center;" scope="row"><?php
|
42 |
+
if (!empty($options['lastrun'])) {
|
43 |
+
echo date(get_option('date_format'),strtotime($options['lastrun']))." ".date("H:i",strtotime($options['lastrun']));
|
44 |
+
} else {
|
45 |
+
__("Not Yet","bkpwp");
|
46 |
+
}
|
47 |
+
?></th>
|
48 |
+
<td>
|
49 |
+
<?php
|
50 |
+
if (!empty($timestamp)) {
|
51 |
+
echo date(get_option('date_format'),$timestamp)." ".date("H:i",$timestamp);
|
52 |
+
}
|
53 |
+
?>
|
54 |
+
</td>
|
55 |
+
<td>
|
56 |
+
<?php
|
57 |
+
$now = time();
|
58 |
+
$d = $timestamp - $now;
|
59 |
+
if (!empty($timestamp)) { ?>
|
60 |
+
<div id="countdowncontainer<?php echo $timestamp; ?>"></div>
|
61 |
+
<script type="text/javascript">
|
62 |
+
var futuredate=new cdtime("countdowncontainer<?php echo $timestamp; ?>", "<?php echo date("F j, Y H:i:s",$timestamp); ?>")
|
63 |
+
<?php
|
64 |
+
if ($d > "90000") {
|
65 |
+
?>
|
66 |
+
futuredate.displaycountdown("days", formatresultsd)
|
67 |
+
<?php
|
68 |
+
} else {
|
69 |
+
?>
|
70 |
+
futuredate.displaycountdown("hours", formatresultsh)
|
71 |
+
<?php
|
72 |
+
}
|
73 |
+
?>
|
74 |
+
</script>
|
75 |
+
<?php } else {
|
76 |
+
if ($options['status'] == "inactive") {
|
77 |
+
_e("Backup inactive.","bkpwp");
|
78 |
+
} else {
|
79 |
+
_e("Backup done.","bkpwp");
|
80 |
+
}
|
81 |
+
} ?>
|
82 |
+
</td>
|
83 |
+
<td>
|
84 |
+
<?php
|
85 |
+
echo $options['preset'];
|
86 |
+
?>
|
87 |
+
</td>
|
88 |
+
<td>
|
89 |
+
<?php
|
90 |
+
echo $options['info'];
|
91 |
+
?>
|
92 |
+
</td>
|
93 |
+
<td style="text-align: center;">
|
94 |
+
<?php
|
95 |
+
if (!empty($options['status'])) {
|
96 |
+
if ($options['status'] == "inactive") {
|
97 |
+
echo " <a href=\"admin.php?page=".$_REQUEST['page']."&bkpwp_toggle_schedule_active=".$options['created']."\">".__("activate","bkpwp")."</a>";
|
98 |
+
} else {
|
99 |
+
echo " <a href=\"admin.php?page=".$_REQUEST['page']."&bkpwp_toggle_schedule_active=".$options['created']."\">".__("deactivate","bkpwp")."</a>";
|
100 |
+
}
|
101 |
+
}
|
102 |
+
?>
|
103 |
+
</td>
|
104 |
+
<?php
|
105 |
+
/*
|
106 |
+
wishlist for 2.0
|
107 |
+
if (!empty($options['status'])) {
|
108 |
+
echo " <a href=\"admin.php?page=".$_REQUEST['page']."&bkpwp_edit_schedule=".$i."\">".__("edit","bkpwp")."</a>";
|
109 |
+
} */
|
110 |
+
?>
|
111 |
+
<td style="text-align: center;">
|
112 |
+
<?php
|
113 |
+
echo " <a href=\"admin.php?page=".$_REQUEST['page']."&bkpwp_delete_schedule=".$options['created']."\">".__("delete","bkpwp")."</a>";
|
114 |
+
?>
|
115 |
+
</td>
|
116 |
+
<?php
|
117 |
+
?>
|
118 |
+
</tr>
|
119 |
+
<?php
|
120 |
+
if (!empty($options['status'])) {
|
121 |
+
$i++;
|
122 |
+
}
|
123 |
+
}
|
124 |
+
?>
|
125 |
+
</tbody>
|
126 |
+
</table>
|
127 |
+
<?php
|
128 |
+
}
|
129 |
+
|
130 |
+
$bkpwppath = get_option("bkpwppath");
|
131 |
+
?>
|
132 |
+
<div class="wrap">
|
133 |
+
<?php
|
134 |
+
if (!empty($_REQUEST['bkpwp_delete_schedule'])) {
|
135 |
+
?>
|
136 |
+
<div id="message" class="updated fade">
|
137 |
+
<p><?php
|
138 |
+
$schedule = new BKPWP_SCHEDULE();
|
139 |
+
$ret = $schedule->bkpwp_delete_schedule_by_created($_REQUEST['bkpwp_delete_schedule']);
|
140 |
+
if($ret == 1) {
|
141 |
+
_e("Schedule deleted.","bkpwp");
|
142 |
+
} else {
|
143 |
+
_e("Schedule could not be deleted.","bkpwp");
|
144 |
+
}
|
145 |
+
?></p>
|
146 |
+
</div>
|
147 |
+
<?php
|
148 |
+
}
|
149 |
+
if (!empty($_REQUEST['bkpwp_toggle_schedule_active'])) {
|
150 |
+
?>
|
151 |
+
<div id="message" class="updated fade">
|
152 |
+
<p><?php
|
153 |
+
$schedule = new BKPWP_SCHEDULE();
|
154 |
+
$ret = $schedule->bkpwp_toggle_schedule($_REQUEST['bkpwp_toggle_schedule_active']);
|
155 |
+
if($ret) {
|
156 |
+
_e("Schedule activity status set to","bkpwp");
|
157 |
+
echo " <b>";
|
158 |
+
if ($ret == "active") {
|
159 |
+
_e("active","bkpwp");
|
160 |
+
} else {
|
161 |
+
_e("inactive","bkpwp");
|
162 |
+
}
|
163 |
+
echo "</b>";
|
164 |
+
} else {
|
165 |
+
_e("Schedule activity status could not be set","bkpwp");
|
166 |
+
}
|
167 |
+
?></p>
|
168 |
+
</div>
|
169 |
+
<?php
|
170 |
+
}
|
171 |
+
if (!empty($_REQUEST['bkpwp_reset_schedules'])) {
|
172 |
+
wp_clear_scheduled_hook("bkpwp_schedule_bkpwp_hook");
|
173 |
+
delete_option("bkpwp_schedules");
|
174 |
+
$options = new BKPWP_OPTIONS();
|
175 |
+
$options->bkpwp_default_schedules();
|
176 |
+
?>
|
177 |
+
<div id="message" class="updated fade">
|
178 |
+
<p><?php _e("Schedules reset to defaults. Please be patient, scheduling may take a few seconds to show up in the list below.","bkpwp"); ?></p>
|
179 |
+
</div>
|
180 |
+
<?php
|
181 |
+
}
|
182 |
+
if (!empty($_REQUEST['bkpwp_test_schedule'])) {
|
183 |
+
$schedule = new BKPWP_SCHEDULE();
|
184 |
+
?>
|
185 |
+
<div id="message" class="updated fade">
|
186 |
+
<p><?php
|
187 |
+
if ($schedule->bkpwp_test_schedule()) {
|
188 |
+
_e("A schedule without reccurrence for one single Database Backup has been set up
|
189 |
+
and should execute with the first hit your Blog receives after 30 Seconds from now.","bkpwp");
|
190 |
+
} else {
|
191 |
+
_e("Testing schedules failed.","bkpwp");
|
192 |
+
}
|
193 |
+
?></p>
|
194 |
+
</div>
|
195 |
+
<?php
|
196 |
+
}
|
197 |
+
|
198 |
+
if (!empty($_REQUEST['bkpwp_delete'])) {
|
199 |
+
if (empty($_REQUEST['bkpwp_delete_now'])) {
|
200 |
+
?>
|
201 |
+
<div id="message" class="updated fade">
|
202 |
+
<p><?php _e("Do you want to delete the backup archive","bkpwp"); ?></p>
|
203 |
+
<p>
|
204 |
+
<?php
|
205 |
+
echo base64_decode($_REQUEST['bkpwp_delete']);
|
206 |
+
?>
|
207 |
+
<form name="form1" method="post" action="">
|
208 |
+
<input type="hidden" name="bkpwp_delete" value="<?php echo $_REQUEST['bkpwp_delete']; ?>" />
|
209 |
+
<input type="submit" name="bkpwp_delete_now" value="» <?php _e("go on, delete","bkpwp"); ?>" />
|
210 |
+
</form>
|
211 |
+
</p><br />
|
212 |
+
</div><br />
|
213 |
+
<?php
|
214 |
+
} else {
|
215 |
+
if(!eregi(get_option("bkpwppath"),base64_decode($_REQUEST['bkpwp_delete']))) {
|
216 |
+
// must be one of those in here!
|
217 |
+
return;
|
218 |
+
}
|
219 |
+
if (unlink(base64_decode($_REQUEST['bkpwp_delete']))) {
|
220 |
+
?>
|
221 |
+
<div id="message" class="updated fade">
|
222 |
+
<p><?php _e("Backup file deleted sucessfully","bkpwp"); ?>:</p>
|
223 |
+
<p>
|
224 |
+
<?php
|
225 |
+
echo base64_decode($_REQUEST['bkpwp_delete']);
|
226 |
+
?>
|
227 |
+
</p>
|
228 |
+
</div><br />
|
229 |
+
<?php
|
230 |
+
} else {
|
231 |
+
?>
|
232 |
+
<div id="message" class="updated fade">
|
233 |
+
<p><?php _e("Backup file deletion failed","bkpwp"); ?>:</p>
|
234 |
+
<p>
|
235 |
+
<?php
|
236 |
+
echo base64_decode($_REQUEST['bkpwp_delete']);
|
237 |
+
?>
|
238 |
+
</p>
|
239 |
+
</div><br />
|
240 |
+
<?php
|
241 |
+
}
|
242 |
+
}
|
243 |
+
}
|
244 |
+
|
245 |
+
if (!empty($bkpwppath) && is_dir($bkpwppath)) {
|
246 |
+
bkpwp_schedulelist($bkpwppath);
|
247 |
+
}
|
248 |
+
|
249 |
+
?>
|
250 |
+
</div>
|
functions-interface.php
ADDED
@@ -0,0 +1,225 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
function bkpwp_display_message($msg) {
|
4 |
+
?>
|
5 |
+
<div id="message" class="updated fade"><p><?php
|
6 |
+
if (is_array($msg)) {
|
7 |
+
foreach ($msg as $m) {
|
8 |
+
echo $m."<br />";
|
9 |
+
}
|
10 |
+
} else {
|
11 |
+
echo $msg;
|
12 |
+
}?></p>
|
13 |
+
</div>
|
14 |
+
<br />
|
15 |
+
<?php
|
16 |
+
}
|
17 |
+
|
18 |
+
function bkpwp_display_console() {
|
19 |
+
?>
|
20 |
+
<textarea id="bkpwp_console"></textarea><br /><br />
|
21 |
+
<?php
|
22 |
+
flush();
|
23 |
+
}
|
24 |
+
|
25 |
+
function bkpwp_console($msg,$all=true) {
|
26 |
+
echo "<script>
|
27 |
+
var objDiv = document.getElementById('bkpwp_console');
|
28 |
+
objDiv.value ";
|
29 |
+
if ($all == true) {
|
30 |
+
echo "+";
|
31 |
+
} else {
|
32 |
+
$msg = "[...]".$msg;
|
33 |
+
}
|
34 |
+
echo "= '".$msg."';
|
35 |
+
objDiv.scrollTop = objDiv.scrollHeight;
|
36 |
+
currentTime();</script>";
|
37 |
+
flush();
|
38 |
+
}
|
39 |
+
|
40 |
+
function bkpwp_sajax_do() {
|
41 |
+
// maybe some other module has sajax allready built in? (zenphoto, cforms,...)
|
42 |
+
if (!function_exists("sajax_handle_client_request")) {
|
43 |
+
require_once $GLOBALS['bkpwp_plugin_path']."Sajax.php";
|
44 |
+
}
|
45 |
+
//$GLOBALS['sajax_debug_mode'] = 1;
|
46 |
+
|
47 |
+
sajax_init();
|
48 |
+
sajax_export("bkpwp_ajax_calculater",
|
49 |
+
"bkpwp_ajax_create",
|
50 |
+
"bkpwp_ajax_shownobfiles",
|
51 |
+
"bkpwp_ajax_load_preset",
|
52 |
+
"bkpwp_ajax_view_preset",
|
53 |
+
"bkpwp_ajax_view_backup",
|
54 |
+
"bkpwp_ajax_save_preset",
|
55 |
+
"bkpwp_ajax_delete_preset",
|
56 |
+
"bkpwp_reload_table");
|
57 |
+
sajax_handle_client_request();
|
58 |
+
}
|
59 |
+
|
60 |
+
function bkpwp_sajax_js() {
|
61 |
+
bkpwp_sajax_do();
|
62 |
+
?>
|
63 |
+
<script>
|
64 |
+
<?php
|
65 |
+
sajax_show_javascript();
|
66 |
+
?>
|
67 |
+
</script>
|
68 |
+
<?php
|
69 |
+
}
|
70 |
+
|
71 |
+
function bkpwp_load_css_and_js() {
|
72 |
+
echo "<style type='text/css'>
|
73 |
+
h2 {
|
74 |
+
padding-top: 20px;
|
75 |
+
}
|
76 |
+
legend {
|
77 |
+
font-weight: bold;
|
78 |
+
}
|
79 |
+
input[type=submit] {
|
80 |
+
cursor: pointer;
|
81 |
+
}
|
82 |
+
.error {
|
83 |
+
color: red;
|
84 |
+
}
|
85 |
+
.success {
|
86 |
+
color: green;
|
87 |
+
}
|
88 |
+
#bkpwp_console {
|
89 |
+
font-family: monospace;
|
90 |
+
color:#EEE;
|
91 |
+
width: 750px; min-height: 120px;
|
92 |
+
background: #000;
|
93 |
+
border: 1px solid lime;
|
94 |
+
}
|
95 |
+
.bkpwp_manage_backups_newrow {
|
96 |
+
background: #99FF66;
|
97 |
+
}
|
98 |
+
</style>
|
99 |
+
";
|
100 |
+
?>
|
101 |
+
<script type="text/javascript">
|
102 |
+
|
103 |
+
var startTime=new Date();
|
104 |
+
|
105 |
+
function currentTime(){
|
106 |
+
var a=Math.floor((new Date()-startTime)/100)/10;
|
107 |
+
if (a%1==0) a+=".0";
|
108 |
+
document.getElementById("endTime").innerHTML=a;
|
109 |
+
}
|
110 |
+
|
111 |
+
<!-- displays a loading animation while doing ajax requests -->
|
112 |
+
function is_loading(divid) {
|
113 |
+
document.getElementById(divid).style.display = 'block';
|
114 |
+
document.getElementById(divid).innerHTML="<img src='<?php bloginfo("url"); ?>/wp-content/plugins/backupwordpress/images/loading.gif' />";
|
115 |
+
}
|
116 |
+
</script>
|
117 |
+
|
118 |
+
<script type="text/javascript">
|
119 |
+
|
120 |
+
/***********************************************
|
121 |
+
* Dynamic Countdown script- © Dynamic Drive (http://www.dynamicdrive.com)
|
122 |
+
* This notice MUST stay intact for legal use
|
123 |
+
* Visit http://www.dynamicdrive.com/ for this script and 100s more.
|
124 |
+
***********************************************/
|
125 |
+
|
126 |
+
function cdtime(container, targetdate){
|
127 |
+
if (!document.getElementById || !document.getElementById(container)) return
|
128 |
+
this.container=document.getElementById(container)
|
129 |
+
this.currentTime=new Date("<?php echo date("F j, Y H:i:s"); ?>")
|
130 |
+
this.targetdate=new Date(targetdate)
|
131 |
+
this.timesup=false
|
132 |
+
this.updateTime()
|
133 |
+
}
|
134 |
+
|
135 |
+
cdtime.prototype.updateTime=function(){
|
136 |
+
var thisobj=this
|
137 |
+
this.currentTime.setSeconds(this.currentTime.getSeconds()+1)
|
138 |
+
setTimeout(function(){thisobj.updateTime()}, 1000) //update time every second
|
139 |
+
}
|
140 |
+
|
141 |
+
cdtime.prototype.displaycountdown=function(baseunit, functionref){
|
142 |
+
this.baseunit=baseunit
|
143 |
+
this.formatresults=functionref
|
144 |
+
this.showresults()
|
145 |
+
}
|
146 |
+
|
147 |
+
cdtime.prototype.showresults=function(){
|
148 |
+
var thisobj=this
|
149 |
+
|
150 |
+
|
151 |
+
var timediff=(this.targetdate-this.currentTime)/1000 //difference btw target date and current date, in seconds
|
152 |
+
if (timediff<0){ //if time is up
|
153 |
+
this.timesup=true
|
154 |
+
this.container.innerHTML=this.formatresults()
|
155 |
+
return
|
156 |
+
}
|
157 |
+
var oneMinute=60 //minute unit in seconds
|
158 |
+
var oneHour=60*60 //hour unit in seconds
|
159 |
+
var oneDay=60*60*24 //day unit in seconds
|
160 |
+
var dayfield=Math.floor(timediff/oneDay)
|
161 |
+
var hourfield=Math.floor((timediff-dayfield*oneDay)/oneHour)
|
162 |
+
var minutefield=Math.floor((timediff-dayfield*oneDay-hourfield*oneHour)/oneMinute)
|
163 |
+
var secondfield=Math.floor((timediff-dayfield*oneDay-hourfield*oneHour-minutefield*oneMinute))
|
164 |
+
if (this.baseunit=="hours"){ //if base unit is hours, set "hourfield" to be topmost level
|
165 |
+
hourfield=dayfield*24+hourfield
|
166 |
+
dayfield="n/a"
|
167 |
+
}
|
168 |
+
else if (this.baseunit=="minutes"){ //if base unit is minutes, set "minutefield" to be topmost level
|
169 |
+
minutefield=dayfield*24*60+hourfield*60+minutefield
|
170 |
+
dayfield=hourfield="n/a"
|
171 |
+
}
|
172 |
+
else if (this.baseunit=="seconds"){ //if base unit is seconds, set "secondfield" to be topmost level
|
173 |
+
var secondfield=timediff
|
174 |
+
dayfield=hourfield=minutefield="n/a"
|
175 |
+
}
|
176 |
+
this.container.innerHTML=this.formatresults(dayfield, hourfield, minutefield, secondfield)
|
177 |
+
setTimeout(function(){thisobj.showresults()}, 1000) //update results every second
|
178 |
+
}
|
179 |
+
|
180 |
+
/////CUSTOM FORMAT OUTPUT FUNCTIONS BELOW//////////////////////////////
|
181 |
+
|
182 |
+
//Create your own custom format function to pass into cdtime.displaycountdown()
|
183 |
+
//Use arguments[0] to access "Days" left
|
184 |
+
//Use arguments[1] to access "Hours" left
|
185 |
+
//Use arguments[2] to access "Minutes" left
|
186 |
+
//Use arguments[3] to access "Seconds" left
|
187 |
+
|
188 |
+
//The values of these arguments may change depending on the "baseunit" parameter of cdtime.displaycountdown()
|
189 |
+
//For example, if "baseunit" is set to "hours", arguments[0] becomes meaningless and contains "n/a"
|
190 |
+
//For example, if "baseunit" is set to "minutes", arguments[0] and arguments[1] become meaningless etc
|
191 |
+
|
192 |
+
|
193 |
+
function formatresultsh(){
|
194 |
+
if (this.timesup==false){//if target date/time not yet met
|
195 |
+
var displaystring=arguments[1]+" h "+arguments[2]+"' "+arguments[3]+"''"
|
196 |
+
} else { //else if target date/time met
|
197 |
+
var displaystring = "<?php _e("scheduling...","bkpwp");?>"
|
198 |
+
}
|
199 |
+
return displaystring
|
200 |
+
}
|
201 |
+
|
202 |
+
function formatresultsd(){
|
203 |
+
if (this.timesup==false){//if target date/time not yet met
|
204 |
+
var displaystring=arguments[0]+" days "+arguments[1]+"h"
|
205 |
+
} else { //else if target date/time met
|
206 |
+
var displaystring = "<?php _e("scheduling...","bkpwp");?>"
|
207 |
+
}
|
208 |
+
return displaystring
|
209 |
+
}
|
210 |
+
|
211 |
+
function formatresultsdh(){
|
212 |
+
if (this.timesup==false){//if target date/time not yet met
|
213 |
+
var displaystring=arguments[0]+" days "+arguments[1]+"h "+arguments[2]+"' "+arguments[3]+"''"
|
214 |
+
} else { //else if target date/time met
|
215 |
+
var displaystring = "<?php _e("scheduling...","bkpwp");?>"
|
216 |
+
}
|
217 |
+
return displaystring
|
218 |
+
}
|
219 |
+
|
220 |
+
</script>
|
221 |
+
|
222 |
+
|
223 |
+
<?php
|
224 |
+
}
|
225 |
+
?>
|
functions.php
ADDED
@@ -0,0 +1,307 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
function bkpwp_activate() {
|
4 |
+
$role = get_role('administrator');
|
5 |
+
if(!$role->has_cap('manage bkpwp')) {
|
6 |
+
$role->add_cap('manage bkpwp');
|
7 |
+
}
|
8 |
+
$options = new BKPWP_OPTIONS();
|
9 |
+
$options->bkpwp_set_defaults();
|
10 |
+
}
|
11 |
+
|
12 |
+
function bkpwp_exit() {
|
13 |
+
//clear hooks for those
|
14 |
+
wp_clear_scheduled_hook("bkpwp_schedule_bkpwp_hook");
|
15 |
+
//delete all options
|
16 |
+
delete_option("bkpwp_schedules");
|
17 |
+
delete_option("bkpwppath");
|
18 |
+
delete_option("bkpwp_presets");
|
19 |
+
delete_option('bkpwp_listmax_backups');
|
20 |
+
delete_option("bkpwp_domain");
|
21 |
+
delete_option("bkpwp_domain_path");
|
22 |
+
delete_option("bkpwp_archive_types");
|
23 |
+
delete_option("bkpwp_easy_mode");
|
24 |
+
delete_option("bkpwp_excludelists");
|
25 |
+
delete_option("bkpwp_reccurrences");
|
26 |
+
delete_option("bkpwp_calculation");
|
27 |
+
delete_option("bkpwp_max_backups");
|
28 |
+
delete_option("bkpwp_listmax_backups");
|
29 |
+
delete_option("bkpwp_automail");
|
30 |
+
delete_option("bkpwp_automail_maxsize");
|
31 |
+
delete_option("bkpwp_automail_address");
|
32 |
+
delete_option("bkpwp_automail_receiver");
|
33 |
+
}
|
34 |
+
|
35 |
+
function bkpwp_setup() {
|
36 |
+
if(current_user_can('manage bkpwp')) {
|
37 |
+
|
38 |
+
$locale = get_locale();
|
39 |
+
$mofile = dirname(__FILE__) . "/locale/".$locale.".mo";
|
40 |
+
load_textdomain('bkpwp', $mofile);
|
41 |
+
|
42 |
+
get_currentuserinfo();
|
43 |
+
$options = new BKPWP_OPTIONS();
|
44 |
+
$options->bkpwp_handle_modeswitch();
|
45 |
+
}
|
46 |
+
}
|
47 |
+
|
48 |
+
function bkpwp_load_menu_page() {
|
49 |
+
if (!empty($_REQUEST['page']) && file_exists($GLOBALS['bkpwp_plugin_path']."bkpwp-pages/".$_REQUEST['page'].".php")) {
|
50 |
+
include_once($GLOBALS['bkpwp_plugin_path']."bkpwp-pages/".$_REQUEST['page'].".php");
|
51 |
+
} else {
|
52 |
+
include_once($GLOBALS['bkpwp_plugin_path']."bkpwp-pages/bkpwp_manage_backups.php");
|
53 |
+
}
|
54 |
+
include_once($GLOBALS['bkpwp_plugin_path']."bkpwp-pages/bkpwp_footer.php");
|
55 |
+
}
|
56 |
+
|
57 |
+
function bkpwp_add_menu() {
|
58 |
+
$interface = new BKPWP_INTERFACE();
|
59 |
+
$interface->menu();
|
60 |
+
}
|
61 |
+
|
62 |
+
function bkpwp_help_zeitgeist() {
|
63 |
+
$options = new BKPWP_OPTIONS();
|
64 |
+
?>
|
65 |
+
<div id="zeitgeist">
|
66 |
+
<b><?php _e("BackUpWordPress Help Index","bkpwp"); ?></b>
|
67 |
+
<p>
|
68 |
+
<?php _e("Looking for a less komplex Solution? Please swith to ","bkpwp"); ?>
|
69 |
+
<?php if (!$options->bkpwp_easy_mode()) { ?>
|
70 |
+
<a href="admin.php?page=<?php echo $_REQUEST['page']; ?>&bkpwp_modeswitch=1"><?php _e("EasyMode","bkpwp"); ?> »</a>
|
71 |
+
<?php } else { ?>
|
72 |
+
<a href="admin.php?page=<?php echo $_REQUEST['page']; ?>&bkpwp_modeswitch=1"><?php _e("AdvancedMode","bkpwp"); ?> »</a>
|
73 |
+
<?php } ?>
|
74 |
+
</p>
|
75 |
+
<p>
|
76 |
+
<ul>
|
77 |
+
<li><a href="admin.php?page=bkpwp_help#help_manage_backups"><?php _e("Manage Backups","bkpwp"); ?></a></li>
|
78 |
+
<li><a href="admin.php?page=bkpwp_help#help_manage_presets"><?php _e("Manage Backup Presets","bkpwp"); ?></a></li>
|
79 |
+
<li><a href="admin.php?page=bkpwp_help#help_manage_schedules"><?php _e("Manage Backup Schedules","bkpwp"); ?></a></li>
|
80 |
+
<li><a href="admin.php?page=bkpwp_help#help_options"><?php _e("Options","bkpwp"); ?></a></li>
|
81 |
+
</ul>
|
82 |
+
</p>
|
83 |
+
</div>
|
84 |
+
<?php
|
85 |
+
}
|
86 |
+
|
87 |
+
function bkpwp_latest_activity() {
|
88 |
+
echo "<h3>".__("BackUpWordPress","bkpwp")." <a href=\"admin.php?page=backupwordpress/backupwordpress.php\">»</a></h3>";
|
89 |
+
echo "<p><a href=\"http://wordpress.designpraxis.at/\">".__("Check for a new version of BackUpWordPress!","bkpwp")."</a></p>";
|
90 |
+
echo "<p><b>".__("Latest Backups","bkpwp")."</b>:</p>";
|
91 |
+
$backup = new BKPWP_MANAGE();
|
92 |
+
$backups = $backup->bkpwp_get_backups();
|
93 |
+
if(count($backups) > 0) {
|
94 |
+
echo "<ul style=\"list-style: none;\">";
|
95 |
+
$i=0;
|
96 |
+
foreach ($backups as $f) {
|
97 |
+
if (!file_exists($f['file'])) {
|
98 |
+
continue;
|
99 |
+
}
|
100 |
+
$info = new BKPWP_BACKUP_ARCHIVE();
|
101 |
+
$info = $info->bkpwp_view_backup_info(base64_encode($f['file']),1);
|
102 |
+
echo "<li><a href=\"admin.php?page=backupwordpress/backupwordpress.php&bkpwp_download=".base64_encode($f['file'])."\"><img src=\"".get_bloginfo("wpurl")."/wp-content/plugins/backupwordpress/images/disk.png\" alt=\"download\" title=\"Download Backup\" /></a> ";
|
103 |
+
echo date(get_option('date_format'),filemtime($f['file']))." ".date("H:i",filemtime($f['file']));
|
104 |
+
echo ": ";
|
105 |
+
echo "<b>".$info['filesize']."</b> ";
|
106 |
+
echo "</li>";
|
107 |
+
$i++;
|
108 |
+
if ($i > 2) { break; }
|
109 |
+
}
|
110 |
+
echo "</ul>";
|
111 |
+
}
|
112 |
+
|
113 |
+
$schedules = get_option("bkpwp_schedules");
|
114 |
+
if(count($schedules) < 1) { return; }
|
115 |
+
echo "<b>".__("Next scheduled Backup","bkpwp")."</b>: ";
|
116 |
+
$sarray = array();
|
117 |
+
foreach ($schedules as $options) {
|
118 |
+
if ($options['status'] == "active") {
|
119 |
+
$timestamp = wp_next_scheduled("bkpwp_schedule_bkpwp_hook",$options);
|
120 |
+
$sarray[$timestamp] = $options['info'];
|
121 |
+
}
|
122 |
+
}
|
123 |
+
if(count($sarray) < 1) { echo __("Schedules inactive","bkpwp"); }
|
124 |
+
arsort ($sarray);
|
125 |
+
foreach ($sarray as $key => $value) {
|
126 |
+
echo $value;
|
127 |
+
?>
|
128 |
+
<div id="countdowncontainer<?php echo $key; ?>"></div>
|
129 |
+
<script type="text/javascript">
|
130 |
+
var futuredate=new cdtime("countdowncontainer<?php echo $key; ?>", "<?php echo date("F j, Y H:i:s",$key); ?>")
|
131 |
+
futuredate.displaycountdown("days", formatresultsdh)
|
132 |
+
</script>
|
133 |
+
<?php
|
134 |
+
break;
|
135 |
+
}
|
136 |
+
}
|
137 |
+
|
138 |
+
function bkpwp_conform_dir($dir,$rel=false) {
|
139 |
+
$dir = str_replace("\\","/",$dir);
|
140 |
+
if (substr($dir,-1) == "/") {
|
141 |
+
$dir = substr($dir,0,-1);
|
142 |
+
}
|
143 |
+
if ($rel == true) {
|
144 |
+
$dir = str_replace(bkpwp_conform_dir(ABSPATH),"",$dir);
|
145 |
+
}
|
146 |
+
return $dir;
|
147 |
+
}
|
148 |
+
|
149 |
+
function bkpwp_size_readable($size, $unit = null, $retstring = null, $si = true) {
|
150 |
+
// Units
|
151 |
+
if ($si === true) {
|
152 |
+
$sizes = array('B', 'kB', 'MB', 'GB', 'TB', 'PB');
|
153 |
+
$mod = 1000;
|
154 |
+
} else {
|
155 |
+
$sizes = array('B', 'KiB', 'MiB', 'GiB', 'TiB', 'PiB');
|
156 |
+
$mod = 1024;
|
157 |
+
}
|
158 |
+
$ii = count($sizes) - 1;
|
159 |
+
|
160 |
+
// Max unit
|
161 |
+
$unit = array_search((string) $unit, $sizes);
|
162 |
+
if ($unit === null || $unit === false) {
|
163 |
+
$unit = $ii;
|
164 |
+
}
|
165 |
+
|
166 |
+
// Return string
|
167 |
+
if ($retstring === null) {
|
168 |
+
$retstring = '%01.2f %s';
|
169 |
+
}
|
170 |
+
|
171 |
+
// Loop
|
172 |
+
$i = 0;
|
173 |
+
while ($unit != $i && $size >= 1024 && $i < $ii) {
|
174 |
+
$size /= $mod;
|
175 |
+
$i++;
|
176 |
+
}
|
177 |
+
|
178 |
+
return sprintf($retstring, $size, $sizes[$i]);
|
179 |
+
}
|
180 |
+
|
181 |
+
function bkpwp_ajax_create($preset="") {
|
182 |
+
$backup = new BKPWP_BACKUP();
|
183 |
+
$backup->preset = new BKPWP_MANAGE();
|
184 |
+
$preset = $backup->preset->bkpwp_get_preset($preset);
|
185 |
+
$ret = $backup->bkpwp_do_backup($preset);
|
186 |
+
return $ret;
|
187 |
+
}
|
188 |
+
|
189 |
+
function bkpwp_ajax_view_backup($backupfile) {
|
190 |
+
$backup = new BKPWP_BACKUP_ARCHIVE();
|
191 |
+
$ret = $backup->bkpwp_view_backup_info($backupfile);
|
192 |
+
return $ret;
|
193 |
+
}
|
194 |
+
|
195 |
+
function bkpwp_ajax_view_preset($preset="") {
|
196 |
+
$backup = new BKPWP_MANAGE();
|
197 |
+
$preset = $backup->bkpwp_get_preset($preset);
|
198 |
+
$ret = $backup->bkpwp_view_preset($preset);
|
199 |
+
return $ret;
|
200 |
+
}
|
201 |
+
|
202 |
+
function bkpwp_ajax_load_preset($preset="") {
|
203 |
+
$backup = new BKPWP_MANAGE();
|
204 |
+
$preset = $backup->bkpwp_get_preset($preset);
|
205 |
+
$ret = $backup->bkpwp_load_preset($preset);
|
206 |
+
return $ret;
|
207 |
+
}
|
208 |
+
|
209 |
+
function bkpwp_ajax_shownobfiles($excludelist) {
|
210 |
+
$options = new BKPWP_OPTIONS();
|
211 |
+
$ret = $options->bkpwp_ajax_shownobfiles($excludelist);
|
212 |
+
return $ret;
|
213 |
+
}
|
214 |
+
|
215 |
+
function bkpwp_ajax_save_preset($name="",$archive_type="",$excludelist="",$sql_only="") {
|
216 |
+
$backup = new BKPWP_MANAGE();
|
217 |
+
$ret = $backup->bkpwp_save_preset($name,$archive_type,$excludelist,$sql_only);
|
218 |
+
return $ret;
|
219 |
+
}
|
220 |
+
|
221 |
+
function bkpwp_ajax_delete_preset($name) {
|
222 |
+
$backup = new BKPWP_MANAGE();
|
223 |
+
$ret = $backup->bkpwp_delete_preset($name);
|
224 |
+
return $ret;
|
225 |
+
}
|
226 |
+
|
227 |
+
function bkpwp_ajax_calculater($preset="") {
|
228 |
+
$backup = new BKPWP_BACKUP();
|
229 |
+
$backup->preset = new BKPWP_MANAGE();
|
230 |
+
$preset = $backup->preset->bkpwp_get_preset($preset);
|
231 |
+
$ret = $backup->bkpwp_calculate($preset);
|
232 |
+
return $ret;
|
233 |
+
}
|
234 |
+
|
235 |
+
function bkpwp_more_reccurences($recc) {
|
236 |
+
$bkpwp_reccurrences = get_option("bkpwp_reccurrences");
|
237 |
+
if(empty($bkpwp_reccurrences)) {
|
238 |
+
// scheduling reccurrences
|
239 |
+
$bkpwp_reccurrences = array(
|
240 |
+
'bkpwp_weekly' => array('interval' => 604800, 'display' => 'every week'),
|
241 |
+
'bkpwp_daily' => array('interval' => 86400, 'display' => 'every day')
|
242 |
+
);
|
243 |
+
update_option("bkpwp_reccurrences",$bkpwp_reccurrences);
|
244 |
+
$bkpwp_reccurrences = get_option("bkpwp_reccurrences");
|
245 |
+
}
|
246 |
+
foreach ($bkpwp_reccurrences as $key => $value) {
|
247 |
+
$recc[$key] = $value;
|
248 |
+
}
|
249 |
+
return $recc;
|
250 |
+
}
|
251 |
+
|
252 |
+
function bkpwp_schedule_bkpwp($options) {
|
253 |
+
|
254 |
+
$backup = new BKPWP_BACKUP();
|
255 |
+
$backup->preset = new BKPWP_MANAGE();
|
256 |
+
$preset = $backup->preset->bkpwp_get_preset($options);
|
257 |
+
$preset['bkpwp_schedule'] = "scheduled";
|
258 |
+
$backup->bkpwp_do_backup($preset);
|
259 |
+
$schedules['lastrun'] = date("Y-m-d H:i");
|
260 |
+
}
|
261 |
+
|
262 |
+
function bkpwp_download_files() {
|
263 |
+
if (!empty($_REQUEST['bkpwp_download'])) {
|
264 |
+
$file = base64_decode($_REQUEST['bkpwp_download']);
|
265 |
+
bkpwp_send_file($file);
|
266 |
+
}
|
267 |
+
}
|
268 |
+
|
269 |
+
function bkpwp_send_file($path) {
|
270 |
+
session_write_close();
|
271 |
+
ob_end_clean();
|
272 |
+
if (!is_file($path) || connection_status()!=0)
|
273 |
+
return(FALSE);
|
274 |
+
|
275 |
+
//to prevent long file from getting cut off from //max_execution_time
|
276 |
+
|
277 |
+
set_time_limit(0);
|
278 |
+
|
279 |
+
$name=basename($path);
|
280 |
+
|
281 |
+
//filenames in IE containing dots will screw up the
|
282 |
+
//filename unless we add this
|
283 |
+
|
284 |
+
if (strstr($_SERVER['HTTP_USER_AGENT'], "MSIE"))
|
285 |
+
$name = preg_replace('/\./', '%2e', $name, substr_count($name, '.') - 1);
|
286 |
+
|
287 |
+
//required, or it might try to send the serving //document instead of the file
|
288 |
+
|
289 |
+
header("Cache-Control: ");
|
290 |
+
header("Pragma: ");
|
291 |
+
header("Content-Type: application/octet-stream");
|
292 |
+
header("Content-Length: " .(string)(filesize($path)) );
|
293 |
+
header('Content-Disposition: attachment; filename="'.$name.'"');
|
294 |
+
header("Content-Transfer-Encoding: binary\n");
|
295 |
+
|
296 |
+
if($file = fopen($path, 'rb')){
|
297 |
+
while( (!feof($file)) && (connection_status()==0) ){
|
298 |
+
print(fread($file, 1024*8));
|
299 |
+
flush();
|
300 |
+
}
|
301 |
+
fclose($file);
|
302 |
+
}
|
303 |
+
return((connection_status()==0) and !connection_aborted());
|
304 |
+
}
|
305 |
+
|
306 |
+
|
307 |
+
?>
|
images/disk.png
ADDED
Binary file
|
images/loading.gif
ADDED
Binary file
|
locale/de_DE.mo
ADDED
Binary file
|
locale/de_DE.po
ADDED
@@ -0,0 +1,1151 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
msgid ""
|
2 |
+
msgstr ""
|
3 |
+
"Project-Id-Version: BackUpWordPress\n"
|
4 |
+
"POT-Creation-Date: \n"
|
5 |
+
"PO-Revision-Date: 2007-09-02 22:46+0100\n"
|
6 |
+
"Last-Translator: rr <rol@rm-r.at>\n"
|
7 |
+
"Language-Team: Roland Rust <wordpress@designpraxis.at>\n"
|
8 |
+
"MIME-Version: 1.0\n"
|
9 |
+
"Content-Type: text/plain; charset=utf-8\n"
|
10 |
+
"Content-Transfer-Encoding: 8bit\n"
|
11 |
+
"X-Poedit-Language: German\n"
|
12 |
+
"X-Poedit-Country: AUSTRIA\n"
|
13 |
+
"X-Poedit-KeywordsList: __;_e\n"
|
14 |
+
"X-Poedit-Basepath: E:\\www.designpraxis.at\\wordpress\\wp-content\\plugins\\\n"
|
15 |
+
"X-Poedit-SearchPath-0: BackUpWP\n"
|
16 |
+
|
17 |
+
#: BackUpWP/functions.php:62
|
18 |
+
msgid "BackUpWordPress Help Index"
|
19 |
+
msgstr "BackUpWordPress Hilfe Index"
|
20 |
+
|
21 |
+
#: BackUpWP/functions.php:64
|
22 |
+
#: BackUpWP/bkpwp-pages/bkpwp_help.php:96
|
23 |
+
msgid "Looking for a less komplex Solution? Please swith to "
|
24 |
+
msgstr "Suchen Sie nach einer einfacheren Lösung? Wechseln Sie in den"
|
25 |
+
|
26 |
+
#: BackUpWP/functions.php:66
|
27 |
+
#: BackUpWP/bkpwp-pages/bkpwp_options.php:33
|
28 |
+
#: BackUpWP/bkpwp-pages/bkpwp_options.php:42
|
29 |
+
#: BackUpWP/bkpwp-pages/bkpwp_help.php:97
|
30 |
+
#: BackUpWP/bkpwp-pages/bkpwp_help.php:136
|
31 |
+
#: BackUpWP/bkpwp-pages/bkpwp_help.php:163
|
32 |
+
#: BackUpWP/bkpwp-pages/bkpwp_help.php:205
|
33 |
+
msgid "EasyMode"
|
34 |
+
msgstr "EasyMode"
|
35 |
+
|
36 |
+
#: BackUpWP/functions.php:68
|
37 |
+
#: BackUpWP/bkpwp-pages/bkpwp_options.php:36
|
38 |
+
#: BackUpWP/bkpwp-pages/bkpwp_options.php:39
|
39 |
+
#: BackUpWP/bkpwp-pages/bkpwp_help.php:43
|
40 |
+
#: BackUpWP/bkpwp-pages/bkpwp_help.php:184
|
41 |
+
msgid "AdvancedMode"
|
42 |
+
msgstr "AdvancedMode"
|
43 |
+
|
44 |
+
#: BackUpWP/functions.php:73
|
45 |
+
#: BackUpWP/bkpwp-pages/bkpwp_manage_backups.php:237
|
46 |
+
#: BackUpWP/bkpwp-pages/bkpwp_help.php:13
|
47 |
+
msgid "Manage Backups"
|
48 |
+
msgstr "Backups Verwalten"
|
49 |
+
|
50 |
+
#: BackUpWP/functions.php:74
|
51 |
+
#: BackUpWP/bkpwp-pages/bkpwp_manage_presets.php:143
|
52 |
+
#: BackUpWP/bkpwp-pages/bkpwp_help.php:104
|
53 |
+
msgid "Manage Backup Presets"
|
54 |
+
msgstr "Backup Voreinstellungen Verwalten"
|
55 |
+
|
56 |
+
#: BackUpWP/functions.php:75
|
57 |
+
#: BackUpWP/bkpwp-pages/bkpwp_schedule.php:5
|
58 |
+
#: BackUpWP/bkpwp-pages/bkpwp_help.php:142
|
59 |
+
msgid "Manage Backup Schedules"
|
60 |
+
msgstr "Backup Zeitpläne Verwalten"
|
61 |
+
|
62 |
+
#: BackUpWP/functions.php:76
|
63 |
+
#: BackUpWP/bkpwp-classes/interface.php:35
|
64 |
+
#: BackUpWP/bkpwp-classes/interface.php:43
|
65 |
+
msgid "Options"
|
66 |
+
msgstr "Optionen"
|
67 |
+
|
68 |
+
#: BackUpWP/functions.php:84
|
69 |
+
#: BackUpWP/bkpwp-classes/interface.php:34
|
70 |
+
#: BackUpWP/bkpwp-classes/interface.php:38
|
71 |
+
#: BackUpWP/bkpwp-classes/manage_backups.php:859
|
72 |
+
#: BackUpWP/bkpwp-classes/manage_backups.php:860
|
73 |
+
msgid "BackUpWordPress"
|
74 |
+
msgstr "BackUpWordPress"
|
75 |
+
|
76 |
+
#: BackUpWP/functions.php:85
|
77 |
+
msgid "Check for a new version of BackUpWordPress!"
|
78 |
+
msgstr "Hier gibt es die neueste Version von BackUpWordPress!"
|
79 |
+
|
80 |
+
#: BackUpWP/functions.php:86
|
81 |
+
msgid "Latest Backups"
|
82 |
+
msgstr "Letze Backups"
|
83 |
+
|
84 |
+
#: BackUpWP/functions.php:111
|
85 |
+
msgid "Next scheduled Backup"
|
86 |
+
msgstr "Nächstes geplantes Backup"
|
87 |
+
|
88 |
+
#: BackUpWP/functions.php:119
|
89 |
+
msgid "Schedules inactive"
|
90 |
+
msgstr "Zeitpläne inaktiv"
|
91 |
+
|
92 |
+
#: BackUpWP/functions-interface.php:197
|
93 |
+
#: BackUpWP/functions-interface.php:206
|
94 |
+
#: BackUpWP/functions-interface.php:215
|
95 |
+
msgid "scheduling..."
|
96 |
+
msgstr "Zeitplan wird erstellt..."
|
97 |
+
|
98 |
+
#: BackUpWP/bkpwp-classes/interface.php:36
|
99 |
+
#: BackUpWP/bkpwp-classes/interface.php:44
|
100 |
+
msgid "Help"
|
101 |
+
msgstr "Hilfe"
|
102 |
+
|
103 |
+
#: BackUpWP/bkpwp-classes/interface.php:40
|
104 |
+
msgid "Backup Presets"
|
105 |
+
msgstr "Backup Voreinstellungen"
|
106 |
+
|
107 |
+
#: BackUpWP/bkpwp-classes/interface.php:41
|
108 |
+
msgid "Scheduled Backups"
|
109 |
+
msgstr "Geplante Backups"
|
110 |
+
|
111 |
+
#: BackUpWP/bkpwp-classes/schedule.php:72
|
112 |
+
msgid "Test schedule running in 30 seconds"
|
113 |
+
msgstr "zeitgeplantes Testbackup läuft in 30 Sekunden an"
|
114 |
+
|
115 |
+
#: BackUpWP/bkpwp-classes/options.php:56
|
116 |
+
msgid "You do not have sufficent privileges to do Full Backups."
|
117 |
+
msgstr "Sie haben nicht die ausreichende Berechtigung um Backups zu erstellen"
|
118 |
+
|
119 |
+
#: BackUpWP/bkpwp-classes/options.php:65
|
120 |
+
msgid "Path is not within your webroot. Please specify a writable directory inside "
|
121 |
+
msgstr "Dieser Pfad liegt nicht innerhalb Ihres Web-Wurzelverzeichnisses. Spezifizieren Sie bitte ein für den Webserver schreibbares Verzeichniss innerhalb von"
|
122 |
+
|
123 |
+
#: BackUpWP/bkpwp-classes/options.php:71
|
124 |
+
msgid "Wrong Backup Path. Directory does not exist and this script was not able to create it."
|
125 |
+
msgstr "Falscher Backup Pfad. Das Verzeichnis existiert nicht und das Skript war nicht in der Lage es anzulegen."
|
126 |
+
|
127 |
+
#: BackUpWP/bkpwp-classes/options.php:75
|
128 |
+
msgid "Directory did not exist but this script was able to create it."
|
129 |
+
msgstr "Das Verzeichnis existierte nicht, aber das Skript hat es erstellen können."
|
130 |
+
|
131 |
+
#: BackUpWP/bkpwp-classes/options.php:80
|
132 |
+
msgid "Directory does exist but is not writable by the webserver. Check directory permissions (e.g.: chmod 777)."
|
133 |
+
msgstr "Das Verzeichnis existiert, is aber für den Webserver nicht schreibbar."
|
134 |
+
|
135 |
+
#: BackUpWP/bkpwp-classes/options.php:84
|
136 |
+
msgid "Backup Path saved."
|
137 |
+
msgstr "Backup Pfad gespeichert."
|
138 |
+
|
139 |
+
#: BackUpWP/bkpwp-classes/options.php:84
|
140 |
+
msgid "Continue"
|
141 |
+
msgstr "Weiter"
|
142 |
+
|
143 |
+
#: BackUpWP/bkpwp-classes/options.php:90
|
144 |
+
msgid "Please configure the Backup path first. The field below should allready be filled with a recommendation for that option."
|
145 |
+
msgstr "Bitte spezifizieren Sie das Backup-Verzeichnis zuerst. Das untenstehende Feld sollte bereits eine Empfehlung für das Verzeichnis beinhalten."
|
146 |
+
|
147 |
+
#: BackUpWP/bkpwp-classes/options.php:112
|
148 |
+
#: BackUpWP/bkpwp-classes/options.php:125
|
149 |
+
msgid "Settings saved."
|
150 |
+
msgstr "Einstellungen gespeichert."
|
151 |
+
|
152 |
+
#: BackUpWP/bkpwp-classes/options.php:138
|
153 |
+
msgid "New Backup Exclude List saved:"
|
154 |
+
msgstr "Neue Ausschlussliste gespeichert:"
|
155 |
+
|
156 |
+
#: BackUpWP/bkpwp-classes/options.php:141
|
157 |
+
msgid "Backup Exclude List saved:"
|
158 |
+
msgstr "Backup Ausschlussliste gespeichert:"
|
159 |
+
|
160 |
+
#: BackUpWP/bkpwp-classes/options.php:144
|
161 |
+
msgid "Backup Exclude List deleted:"
|
162 |
+
msgstr "Backup Ausschlussliste gelöscht:"
|
163 |
+
|
164 |
+
#: BackUpWP/bkpwp-classes/options.php:177
|
165 |
+
msgid "Folders"
|
166 |
+
msgstr "Verzeichnisse"
|
167 |
+
|
168 |
+
#: BackUpWP/bkpwp-classes/options.php:180
|
169 |
+
msgid "matched by"
|
170 |
+
msgstr "übereinstimmend mit"
|
171 |
+
|
172 |
+
#: BackUpWP/bkpwp-classes/options.php:192
|
173 |
+
msgid "Files"
|
174 |
+
msgstr "Dateien"
|
175 |
+
|
176 |
+
#: BackUpWP/bkpwp-classes/options.php:194
|
177 |
+
msgid "files matched by"
|
178 |
+
msgstr "Dateien übereinstimmend mit"
|
179 |
+
|
180 |
+
#: BackUpWP/bkpwp-classes/options.php:412
|
181 |
+
msgid "Full Backup Weekly"
|
182 |
+
msgstr "Vollständiges wöchentliches Backup"
|
183 |
+
|
184 |
+
#: BackUpWP/bkpwp-classes/options.php:419
|
185 |
+
msgid "SQL Only Backup Daily"
|
186 |
+
msgstr "tägliches SQL Backup"
|
187 |
+
|
188 |
+
#: BackUpWP/bkpwp-classes/manage_backups.php:13
|
189 |
+
msgid "BackUp Archive Path and Filename"
|
190 |
+
msgstr "Backup Archiv Pfad und Dateiname"
|
191 |
+
|
192 |
+
#: BackUpWP/bkpwp-classes/manage_backups.php:15
|
193 |
+
msgid "BackUp Logfile"
|
194 |
+
msgstr "Backup Log Datei"
|
195 |
+
|
196 |
+
#: BackUpWP/bkpwp-classes/manage_backups.php:22
|
197 |
+
msgid "does not exist."
|
198 |
+
msgstr "existiert nicht"
|
199 |
+
|
200 |
+
#: BackUpWP/bkpwp-classes/manage_backups.php:32
|
201 |
+
msgid "scheduled"
|
202 |
+
msgstr "geplant"
|
203 |
+
|
204 |
+
#: BackUpWP/bkpwp-classes/manage_backups.php:41
|
205 |
+
msgid "Line"
|
206 |
+
msgstr "Zeile"
|
207 |
+
|
208 |
+
#: BackUpWP/bkpwp-classes/manage_backups.php:44
|
209 |
+
msgid "BackUpWordPress Logfile does not exist:"
|
210 |
+
msgstr "BackUpWordPress Log Datei existiert nicht:"
|
211 |
+
|
212 |
+
#: BackUpWP/bkpwp-classes/manage_backups.php:86
|
213 |
+
msgid "download"
|
214 |
+
msgstr "herunterladen"
|
215 |
+
|
216 |
+
#: BackUpWP/bkpwp-classes/manage_backups.php:93
|
217 |
+
msgid "View Backup Information"
|
218 |
+
msgstr "Backup Informationen anzeigen"
|
219 |
+
|
220 |
+
#: BackUpWP/bkpwp-classes/manage_backups.php:96
|
221 |
+
#: BackUpWP/bkpwp-pages/bkpwp_manage_presets.php:84
|
222 |
+
msgid "view"
|
223 |
+
msgstr "ansehen"
|
224 |
+
|
225 |
+
#: BackUpWP/bkpwp-classes/manage_backups.php:101
|
226 |
+
msgid "mail"
|
227 |
+
msgstr "mailen"
|
228 |
+
|
229 |
+
#: BackUpWP/bkpwp-classes/manage_backups.php:107
|
230 |
+
msgid "restore"
|
231 |
+
msgstr "wiederherstellen"
|
232 |
+
|
233 |
+
#: BackUpWP/bkpwp-classes/manage_backups.php:113
|
234 |
+
#: BackUpWP/bkpwp-pages/bkpwp_manage_presets.php:90
|
235 |
+
#: BackUpWP/bkpwp-pages/bkpwp_manage_backups.php:130
|
236 |
+
#: BackUpWP/bkpwp-pages/bkpwp_options.php:199
|
237 |
+
#: BackUpWP/bkpwp-pages/bkpwp_schedule.php:113
|
238 |
+
msgid "delete"
|
239 |
+
msgstr "löschen"
|
240 |
+
|
241 |
+
#: BackUpWP/bkpwp-classes/manage_backups.php:189
|
242 |
+
msgid "Error getting table structure of "
|
243 |
+
msgstr "Fehler beim erstellen der Tabellenstruktur von"
|
244 |
+
|
245 |
+
#: BackUpWP/bkpwp-classes/manage_backups.php:206
|
246 |
+
msgid "Error getting records of "
|
247 |
+
msgstr "Fehler beim erstellen der Datensätze von"
|
248 |
+
|
249 |
+
#: BackUpWP/bkpwp-classes/manage_backups.php:286
|
250 |
+
msgid "Could not connect to MySQL server! "
|
251 |
+
msgstr "Konnte den Mysql Datenbankserver nicht erreichen!"
|
252 |
+
|
253 |
+
#: BackUpWP/bkpwp-classes/manage_backups.php:289
|
254 |
+
msgid "MySQL server connected successfully "
|
255 |
+
msgstr "MySQL Server erfolgerich verbunden"
|
256 |
+
|
257 |
+
#: BackUpWP/bkpwp-classes/manage_backups.php:296
|
258 |
+
msgid "Could not select db "
|
259 |
+
msgstr "Konnte die Datenbank nicht auswählen"
|
260 |
+
|
261 |
+
#: BackUpWP/bkpwp-classes/manage_backups.php:329
|
262 |
+
msgid "Database Only Backup with this Preset. No Disk Files will be backed up."
|
263 |
+
msgstr "Dieses Preset unterstützt ausschliesslich das Backup der Datenbank. Es werden keine Dateien gesichert."
|
264 |
+
|
265 |
+
#: BackUpWP/bkpwp-classes/manage_backups.php:345
|
266 |
+
msgid "Your Wordpress files backuped with preset"
|
267 |
+
msgstr "Ihre WordPress Dateien, gesichert mit dem Preset"
|
268 |
+
|
269 |
+
#: BackUpWP/bkpwp-classes/manage_backups.php:345
|
270 |
+
msgid " use"
|
271 |
+
msgstr "verbrauchen"
|
272 |
+
|
273 |
+
#: BackUpWP/bkpwp-classes/manage_backups.php:346
|
274 |
+
msgid "of disk space."
|
275 |
+
msgstr "Speicherplatz."
|
276 |
+
|
277 |
+
#: BackUpWP/bkpwp-classes/manage_backups.php:347
|
278 |
+
msgid "Depending on the type of these files, the resulting Backup Archive filesize can be reduced by more than 70%."
|
279 |
+
msgstr "Abhängig von der Art der Dateien, kann das resultierende Backup-Archiv mehr als 70% weniger Speicher verbrauchen."
|
280 |
+
|
281 |
+
#: BackUpWP/bkpwp-classes/manage_backups.php:384
|
282 |
+
msgid "BackUpWordPress starting at"
|
283 |
+
msgstr "BackUpWordPress startete um"
|
284 |
+
|
285 |
+
#: BackUpWP/bkpwp-classes/manage_backups.php:389
|
286 |
+
#: BackUpWP/bkpwp-classes/manage_backups.php:391
|
287 |
+
#: BackUpWP/bkpwp-classes/manage_backups.php:400
|
288 |
+
#: BackUpWP/bkpwp-classes/manage_backups.php:402
|
289 |
+
msgid "BackUpWordPress temporary Directory"
|
290 |
+
msgstr "BackUpWordPress temporäres Verzeichnis"
|
291 |
+
|
292 |
+
#: BackUpWP/bkpwp-classes/manage_backups.php:389
|
293 |
+
#: BackUpWP/bkpwp-classes/manage_backups.php:400
|
294 |
+
msgid "could not be created"
|
295 |
+
msgstr "konnte nicht angelegt werden"
|
296 |
+
|
297 |
+
#: BackUpWP/bkpwp-classes/manage_backups.php:391
|
298 |
+
#: BackUpWP/bkpwp-classes/manage_backups.php:402
|
299 |
+
msgid "created"
|
300 |
+
msgstr "angelegt"
|
301 |
+
|
302 |
+
#: BackUpWP/bkpwp-classes/manage_backups.php:411
|
303 |
+
msgid "SQL Dump could not be created."
|
304 |
+
msgstr "SQL Dump konnte nicht erstellt werden."
|
305 |
+
|
306 |
+
#: BackUpWP/bkpwp-classes/manage_backups.php:413
|
307 |
+
msgid "SQL Dump created."
|
308 |
+
msgstr "SQL Dump erstellt."
|
309 |
+
|
310 |
+
#: BackUpWP/bkpwp-classes/manage_backups.php:426
|
311 |
+
msgid "Failed to make directory"
|
312 |
+
msgstr "Verzeichnis konnte nicht erstellt werden"
|
313 |
+
|
314 |
+
#: BackUpWP/bkpwp-classes/manage_backups.php:432
|
315 |
+
msgid "Failed to copy"
|
316 |
+
msgstr "Kopierfehler"
|
317 |
+
|
318 |
+
#: BackUpWP/bkpwp-classes/manage_backups.php:439
|
319 |
+
msgid "Temporary Subdirectories copied sucessfully"
|
320 |
+
msgstr "temporäre Unterverzeichnisse erfolgreich kopiert"
|
321 |
+
|
322 |
+
#: BackUpWP/bkpwp-classes/manage_backups.php:440
|
323 |
+
msgid "Temporary Files copied sucessfully"
|
324 |
+
msgstr "temporäre Dateien erfolgreich kopiert"
|
325 |
+
|
326 |
+
#: BackUpWP/bkpwp-classes/manage_backups.php:447
|
327 |
+
msgid "Failed to create backup archive"
|
328 |
+
msgstr "Backup Archiv konnte nicht erstellt werden"
|
329 |
+
|
330 |
+
#: BackUpWP/bkpwp-classes/manage_backups.php:449
|
331 |
+
msgid "Archive File created/compressed successfully:"
|
332 |
+
msgstr "Archiv Datei erfolgreich erstellet/komprimiert:"
|
333 |
+
|
334 |
+
#: BackUpWP/bkpwp-classes/manage_backups.php:453
|
335 |
+
msgid "Temporary Directories and Files deleted successfully"
|
336 |
+
msgstr "temporäre Verzeichnisse und Dateien erfolgreich gelöscht"
|
337 |
+
|
338 |
+
#: BackUpWP/bkpwp-classes/manage_backups.php:456
|
339 |
+
msgid "Old BackUpWordPress Archives deleted successfully"
|
340 |
+
msgstr "Veraltete Backup Archive erfolgreich gelöscht"
|
341 |
+
|
342 |
+
#: BackUpWP/bkpwp-classes/manage_backups.php:458
|
343 |
+
msgid "No old BackUpWordPress Archives to delete"
|
344 |
+
msgstr "Es gibt keine veralteten BackUpWordPress Archive zu löschen."
|
345 |
+
|
346 |
+
#: BackUpWP/bkpwp-classes/manage_backups.php:464
|
347 |
+
msgid "BackUpWordPress done at"
|
348 |
+
msgstr "BackUpWordPress beendet am"
|
349 |
+
|
350 |
+
#: BackUpWP/bkpwp-classes/manage_backups.php:465
|
351 |
+
msgid "BackUpWordPress was running for"
|
352 |
+
msgstr "BackUpWordPress lief für"
|
353 |
+
|
354 |
+
#: BackUpWP/bkpwp-classes/manage_backups.php:465
|
355 |
+
msgid "Seconds"
|
356 |
+
msgstr "Sekunden"
|
357 |
+
|
358 |
+
#: BackUpWP/bkpwp-classes/manage_backups.php:553
|
359 |
+
msgid "Logfile could not be opened for writing: "
|
360 |
+
msgstr "Lof Datei konnte nicht zum schreiben geöffnet werden:"
|
361 |
+
|
362 |
+
#: BackUpWP/bkpwp-classes/manage_backups.php:557
|
363 |
+
#: BackUpWP/bkpwp-classes/manage_backups.php:563
|
364 |
+
msgid "Logfile not writable: "
|
365 |
+
msgstr "Log Datei nicht schreibbar:"
|
366 |
+
|
367 |
+
#: BackUpWP/bkpwp-classes/manage_backups.php:657
|
368 |
+
#: BackUpWP/bkpwp-pages/bkpwp_manage_presets.php:26
|
369 |
+
msgid "Preset Name"
|
370 |
+
msgstr "Name der Voreinstellung"
|
371 |
+
|
372 |
+
#: BackUpWP/bkpwp-classes/manage_backups.php:660
|
373 |
+
#: BackUpWP/bkpwp-pages/bkpwp_manage_presets.php:27
|
374 |
+
#: BackUpWP/bkpwp-pages/bkpwp_help.php:110
|
375 |
+
msgid "Archive Type"
|
376 |
+
msgstr "Archiv Typus"
|
377 |
+
|
378 |
+
#: BackUpWP/bkpwp-classes/manage_backups.php:679
|
379 |
+
#: BackUpWP/bkpwp-pages/bkpwp_manage_presets.php:28
|
380 |
+
#: BackUpWP/bkpwp-pages/bkpwp_help.php:112
|
381 |
+
msgid "Exclude List"
|
382 |
+
msgstr "Ausschlussliste"
|
383 |
+
|
384 |
+
#: BackUpWP/bkpwp-classes/manage_backups.php:680
|
385 |
+
msgid "None"
|
386 |
+
msgstr "Keine"
|
387 |
+
|
388 |
+
#: BackUpWP/bkpwp-classes/manage_backups.php:689
|
389 |
+
#: BackUpWP/bkpwp-pages/bkpwp_manage_backups.php:287
|
390 |
+
#: BackUpWP/bkpwp-pages/bkpwp_manage_backups.php:317
|
391 |
+
#: BackUpWP/bkpwp-pages/bkpwp_help.php:51
|
392 |
+
msgid "Configure"
|
393 |
+
msgstr "Konfigurieren"
|
394 |
+
|
395 |
+
#: BackUpWP/bkpwp-classes/manage_backups.php:698
|
396 |
+
#: BackUpWP/bkpwp-pages/bkpwp_help.php:114
|
397 |
+
msgid "SQL only"
|
398 |
+
msgstr "nur SQL"
|
399 |
+
|
400 |
+
#: BackUpWP/bkpwp-classes/manage_backups.php:699
|
401 |
+
msgid "Save Preset"
|
402 |
+
msgstr "Voreinstellung speichern"
|
403 |
+
|
404 |
+
#: BackUpWP/bkpwp-classes/manage_backups.php:699
|
405 |
+
msgid "Saving Preset"
|
406 |
+
msgstr "Voreinstellung wird gespeichert"
|
407 |
+
|
408 |
+
#: BackUpWP/bkpwp-classes/manage_backups.php:701
|
409 |
+
#: BackUpWP/bkpwp-classes/manage_backups.php:749
|
410 |
+
msgid "You can not overwrite this default preset. Please save changes with a new Preset Name."
|
411 |
+
msgstr "Dieses Preset kann nicht überschrieben werden. Bitte wählen Sie einen anderen Namen für die Voreinstellung."
|
412 |
+
|
413 |
+
#: BackUpWP/bkpwp-classes/manage_backups.php:712
|
414 |
+
msgid "Omitted Folders and Files when using"
|
415 |
+
msgstr "Verzeichnisse und Dateien, die übersprungen werden mit "
|
416 |
+
|
417 |
+
#: BackUpWP/bkpwp-classes/manage_backups.php:730
|
418 |
+
msgid "You can not delete this default preset."
|
419 |
+
msgstr "Diese Voreinstellung kann nciht geläscht werden."
|
420 |
+
|
421 |
+
#: BackUpWP/bkpwp-classes/manage_backups.php:735
|
422 |
+
msgid "Preset deleted."
|
423 |
+
msgstr "Voreinstellung gelöscht."
|
424 |
+
|
425 |
+
#: BackUpWP/bkpwp-classes/manage_backups.php:768
|
426 |
+
msgid "Preset saved."
|
427 |
+
msgstr "Voreinstellung gespeichert."
|
428 |
+
|
429 |
+
#: BackUpWP/bkpwp-classes/manage_backups.php:862
|
430 |
+
msgid "Your requested Backup"
|
431 |
+
msgstr "Ihr gewünschtes Backup"
|
432 |
+
|
433 |
+
#: BackUpWP/bkpwp-classes/manage_backups.php:864
|
434 |
+
msgid "This Backup exceeded"
|
435 |
+
msgstr "Dieses Backup überschreitet"
|
436 |
+
|
437 |
+
#: BackUpWP/bkpwp-classes/manage_backups.php:864
|
438 |
+
#: BackUpWP/bkpwp-pages/bkpwp_options.php:102
|
439 |
+
msgid "MB (megabytes)"
|
440 |
+
msgstr "MB (megabytes)"
|
441 |
+
|
442 |
+
#: BackUpWP/bkpwp-classes/manage_backups.php:865
|
443 |
+
msgid "Please download it from your WordPress administration backend."
|
444 |
+
msgstr "Bitte laden SIe es aus dem WordPress Administrations Backend herunter."
|
445 |
+
|
446 |
+
#: BackUpWP/bkpwp-pages/bkpwp_footer.php:3
|
447 |
+
#: BackUpWP/bkpwp-pages/bkpwp_mail_footer.php:3
|
448 |
+
msgid "Running into Troubles? Features to suggest?"
|
449 |
+
msgstr "Haben Sie Schwierigkeiten mit dem Plugin? Haben Sie Verbesserungsvorschläge?"
|
450 |
+
|
451 |
+
#: BackUpWP/bkpwp-pages/bkpwp_footer.php:5
|
452 |
+
#: BackUpWP/bkpwp-pages/bkpwp_mail_footer.php:4
|
453 |
+
msgid "Drop me a line"
|
454 |
+
msgstr "Schreiben Sie mir"
|
455 |
+
|
456 |
+
#: BackUpWP/bkpwp-pages/bkpwp_footer.php:10
|
457 |
+
msgid "Do you like this Plugin?"
|
458 |
+
msgstr "Finden Sie dieses Plugin nützlich?"
|
459 |
+
|
460 |
+
#: BackUpWP/bkpwp-pages/bkpwp_footer.php:11
|
461 |
+
msgid "Consider to"
|
462 |
+
msgstr "unterstützen Sie unsere Arbeit"
|
463 |
+
|
464 |
+
#: BackUpWP/bkpwp-pages/bkpwp_mail_footer.php:1
|
465 |
+
msgid "Are you happy with this plugin? Looking for more plugins?"
|
466 |
+
msgstr "Sind sie zufrieden mit diesem Plugin? Suchen sie andere Plugins?"
|
467 |
+
|
468 |
+
#: BackUpWP/bkpwp-pages/bkpwp_mail_footer.php:2
|
469 |
+
msgid "Visit my site and consider to donate"
|
470 |
+
msgstr "Besuchen Sie meine Seite und unterstützen Sie unsere Arbeit"
|
471 |
+
|
472 |
+
#: BackUpWP/bkpwp-pages/bkpwp_manage_presets.php:29
|
473 |
+
msgid "SQL/Full"
|
474 |
+
msgstr "SQL/Vollständig"
|
475 |
+
|
476 |
+
#: BackUpWP/bkpwp-pages/bkpwp_manage_presets.php:30
|
477 |
+
#: BackUpWP/bkpwp-pages/bkpwp_manage_backups.php:338
|
478 |
+
#: BackUpWP/bkpwp-pages/bkpwp_schedule.php:29
|
479 |
+
msgid "Action"
|
480 |
+
msgstr "Aktionen"
|
481 |
+
|
482 |
+
#: BackUpWP/bkpwp-pages/bkpwp_manage_presets.php:75
|
483 |
+
msgid "edit"
|
484 |
+
msgstr "ändern"
|
485 |
+
|
486 |
+
#: BackUpWP/bkpwp-pages/bkpwp_manage_presets.php:92
|
487 |
+
msgid "default"
|
488 |
+
msgstr "voreingestellt"
|
489 |
+
|
490 |
+
#: BackUpWP/bkpwp-pages/bkpwp_manage_presets.php:145
|
491 |
+
msgid "To create a new backup preset, edit one of the defaults and save with a new preset name."
|
492 |
+
msgstr "Um eine neue Backup Voreinstellung anzulegen, ändern SIe einfach eine der bestehenden und speichern Sie sie unter neuem Namen."
|
493 |
+
|
494 |
+
#: BackUpWP/bkpwp-pages/bkpwp_manage_backups.php:12
|
495 |
+
msgid "For this version of BackUpWordPress it is only possible to restore the database itself."
|
496 |
+
msgstr "Diese Version von BackUpWordPress ermöglicht leider nur das wiederherstellen der Datenbank."
|
497 |
+
|
498 |
+
#: BackUpWP/bkpwp-pages/bkpwp_manage_backups.php:14
|
499 |
+
msgid "For restoring uploaded Files, Plugins etc. we recommend downloading this archive and upload the respective files to your WordPress installations via FTP."
|
500 |
+
msgstr "Wenn Sie Upload-Dateien, Plugins, etc. wiederherstellen möchten, empfehlen wir, das Backup-Archiv herunterzuladen und die Dateien via FTP auf den Server zu transferieren."
|
501 |
+
|
502 |
+
#: BackUpWP/bkpwp-pages/bkpwp_manage_backups.php:16
|
503 |
+
msgid "You are going to restore your database from the following archive now:"
|
504 |
+
msgstr "Sie werden nun Ihre Datenbank aus folgendem Archiv wiederherstellen:"
|
505 |
+
|
506 |
+
#: BackUpWP/bkpwp-pages/bkpwp_manage_backups.php:17
|
507 |
+
msgid "If you proceed, you will leave your WordPress Admin Area and enter the bigdump utility, where your entire database is beeing restored."
|
508 |
+
msgstr "Wenn Sie fortfahren, wird das Werkzeug bigdump gestartet, welches Ihre Datenbank wiederherstellt."
|
509 |
+
|
510 |
+
#: BackUpWP/bkpwp-pages/bkpwp_manage_backups.php:27
|
511 |
+
msgid "Restore the Database"
|
512 |
+
msgstr "Datenbank wiederherstellen"
|
513 |
+
|
514 |
+
#: BackUpWP/bkpwp-pages/bkpwp_manage_backups.php:31
|
515 |
+
msgid "Download the Backup Archive for Files Recovery"
|
516 |
+
msgstr "Backup Archiv herunterladen, um die Dateien wiederherstellen zu können"
|
517 |
+
|
518 |
+
#: BackUpWP/bkpwp-pages/bkpwp_manage_backups.php:61
|
519 |
+
msgid "cannot be opened from"
|
520 |
+
msgstr "konnte nicht geöffnet werden von"
|
521 |
+
|
522 |
+
#: BackUpWP/bkpwp-pages/bkpwp_manage_backups.php:64
|
523 |
+
msgid "cannot be written to"
|
524 |
+
msgstr "konnte nicht geschrieben werden"
|
525 |
+
|
526 |
+
#: BackUpWP/bkpwp-pages/bkpwp_manage_backups.php:75
|
527 |
+
msgid "Please do not reload the page until bigdump has done its job!"
|
528 |
+
msgstr "Bitte landen Sie diese Seite nicht neu, bis bigdump seine Arbeit erledigt hat!"
|
529 |
+
|
530 |
+
#: BackUpWP/bkpwp-pages/bkpwp_manage_backups.php:84
|
531 |
+
msgid "Some Errors occured while restoring from backup archive"
|
532 |
+
msgstr "Einige Fehler sind beim wiederherstellen des Backup Archivs passiert"
|
533 |
+
|
534 |
+
#: BackUpWP/bkpwp-pages/bkpwp_manage_backups.php:97
|
535 |
+
msgid "Backup file restored sucessfully from archive: "
|
536 |
+
msgstr "Backup Datei erfolgreoch aus folgendem Archiv wiederhergestellt:"
|
537 |
+
|
538 |
+
#: BackUpWP/bkpwp-pages/bkpwp_manage_backups.php:108
|
539 |
+
msgid "Recovery ERROR"
|
540 |
+
msgstr "Wiederherstellungsfehler."
|
541 |
+
|
542 |
+
#: BackUpWP/bkpwp-pages/bkpwp_manage_backups.php:110
|
543 |
+
msgid "Backup Archive could not be read."
|
544 |
+
msgstr "Backup Archiv konnte nicht gelesen werden."
|
545 |
+
|
546 |
+
#: BackUpWP/bkpwp-pages/bkpwp_manage_backups.php:122
|
547 |
+
#: BackUpWP/bkpwp-pages/bkpwp_schedule.php:202
|
548 |
+
msgid "Do you want to delete the backup archive"
|
549 |
+
msgstr "Soll das Backup Archiv gelöscht werden?"
|
550 |
+
|
551 |
+
#: BackUpWP/bkpwp-pages/bkpwp_manage_backups.php:144
|
552 |
+
#: BackUpWP/bkpwp-pages/bkpwp_schedule.php:222
|
553 |
+
msgid "Backup file deleted sucessfully"
|
554 |
+
msgstr "Backup Archiv erfolgreich gelöscht"
|
555 |
+
|
556 |
+
#: BackUpWP/bkpwp-pages/bkpwp_manage_backups.php:155
|
557 |
+
#: BackUpWP/bkpwp-pages/bkpwp_schedule.php:233
|
558 |
+
msgid "Backup file deletion failed"
|
559 |
+
msgstr "Backup Datei konnte nicht gelöscht werden"
|
560 |
+
|
561 |
+
#: BackUpWP/bkpwp-pages/bkpwp_manage_backups.php:176
|
562 |
+
msgid "The BackUp Archive File you want to send is"
|
563 |
+
msgstr "Die Backup Datei, die verschickt werden soll ist"
|
564 |
+
|
565 |
+
#: BackUpWP/bkpwp-pages/bkpwp_manage_backups.php:176
|
566 |
+
msgid "large"
|
567 |
+
msgstr "groß"
|
568 |
+
|
569 |
+
#: BackUpWP/bkpwp-pages/bkpwp_manage_backups.php:177
|
570 |
+
msgid "Do you really want to send this file by email?"
|
571 |
+
msgstr "Soll SIe wirklich per Email versendet werden?"
|
572 |
+
|
573 |
+
#: BackUpWP/bkpwp-pages/bkpwp_manage_backups.php:185
|
574 |
+
msgid "send"
|
575 |
+
msgstr "Senden"
|
576 |
+
|
577 |
+
#: BackUpWP/bkpwp-pages/bkpwp_manage_backups.php:202
|
578 |
+
msgid "Backup has been sent"
|
579 |
+
msgstr "Backup gesendet"
|
580 |
+
|
581 |
+
#: BackUpWP/bkpwp-pages/bkpwp_manage_backups.php:213
|
582 |
+
msgid "Error sending Backup by mail"
|
583 |
+
msgstr "Fehler beim versenden der Backup Datei."
|
584 |
+
|
585 |
+
#: BackUpWP/bkpwp-pages/bkpwp_manage_backups.php:229
|
586 |
+
msgid "No Backups yet"
|
587 |
+
msgstr "keine Backups vorhanden"
|
588 |
+
|
589 |
+
#: BackUpWP/bkpwp-pages/bkpwp_manage_backups.php:232
|
590 |
+
msgid "Start by configuring the Options"
|
591 |
+
msgstr "Beginnen Sie damit, die Konfigurationsoptionen einzustellen"
|
592 |
+
|
593 |
+
#: BackUpWP/bkpwp-pages/bkpwp_manage_backups.php:248
|
594 |
+
msgid "Creating backup. Please wait."
|
595 |
+
msgstr "Backup wird erstellt. Bitte warten."
|
596 |
+
|
597 |
+
#: BackUpWP/bkpwp-pages/bkpwp_manage_backups.php:280
|
598 |
+
msgid "Select a Preset."
|
599 |
+
msgstr "bitte eine Voreinstellung auswählen."
|
600 |
+
|
601 |
+
#: BackUpWP/bkpwp-pages/bkpwp_manage_backups.php:291
|
602 |
+
msgid "BackUp WordPress Now"
|
603 |
+
msgstr "BackUpWordPress Jetzt"
|
604 |
+
|
605 |
+
#: BackUpWP/bkpwp-pages/bkpwp_manage_backups.php:293
|
606 |
+
msgid "Calculating used disk space"
|
607 |
+
msgstr "Speicherverbrauch wird gemessen."
|
608 |
+
|
609 |
+
#: BackUpWP/bkpwp-pages/bkpwp_manage_backups.php:293
|
610 |
+
msgid "Recalculate Used Disk Space"
|
611 |
+
msgstr "Speicherverbrauch wird nochmals gemessen"
|
612 |
+
|
613 |
+
#: BackUpWP/bkpwp-pages/bkpwp_manage_backups.php:314
|
614 |
+
msgid "Your configuration is set to a maximum of"
|
615 |
+
msgstr "Ihre Konfiguration ist eingestellt auf ein Maximum von"
|
616 |
+
|
617 |
+
#: BackUpWP/bkpwp-pages/bkpwp_manage_backups.php:316
|
618 |
+
#: BackUpWP/bkpwp-pages/bkpwp_manage_backups.php:323
|
619 |
+
msgid "Backups."
|
620 |
+
msgstr "Backups."
|
621 |
+
|
622 |
+
#: BackUpWP/bkpwp-pages/bkpwp_manage_backups.php:321
|
623 |
+
msgid "displaying the last"
|
624 |
+
msgstr "es werden die letzten angezeigt"
|
625 |
+
|
626 |
+
#: BackUpWP/bkpwp-pages/bkpwp_manage_backups.php:325
|
627 |
+
msgid "Backups at all."
|
628 |
+
msgstr "Backups vorhanden."
|
629 |
+
|
630 |
+
#: BackUpWP/bkpwp-pages/bkpwp_manage_backups.php:326
|
631 |
+
msgid "Show all"
|
632 |
+
msgstr "Alle anzeigen"
|
633 |
+
|
634 |
+
#: BackUpWP/bkpwp-pages/bkpwp_manage_backups.php:332
|
635 |
+
msgid "Date/Time"
|
636 |
+
msgstr "Datum/Uhrzeit"
|
637 |
+
|
638 |
+
#: BackUpWP/bkpwp-pages/bkpwp_manage_backups.php:334
|
639 |
+
msgid "Type"
|
640 |
+
msgstr "Typ"
|
641 |
+
|
642 |
+
#: BackUpWP/bkpwp-pages/bkpwp_manage_backups.php:335
|
643 |
+
msgid "Preset"
|
644 |
+
msgstr "Voreinstellung"
|
645 |
+
|
646 |
+
#: BackUpWP/bkpwp-pages/bkpwp_manage_backups.php:337
|
647 |
+
msgid "Size"
|
648 |
+
msgstr "Größe"
|
649 |
+
|
650 |
+
#: BackUpWP/bkpwp-pages/bkpwp_options.php:14
|
651 |
+
#: BackUpWP/bkpwp-pages/bkpwp_schedule.php:156
|
652 |
+
msgid "Schedule activity status set to"
|
653 |
+
msgstr "Zeitplan Status gesetzt auf"
|
654 |
+
|
655 |
+
#: BackUpWP/bkpwp-pages/bkpwp_options.php:17
|
656 |
+
#: BackUpWP/bkpwp-pages/bkpwp_schedule.php:159
|
657 |
+
msgid "active"
|
658 |
+
msgstr "aktiv"
|
659 |
+
|
660 |
+
#: BackUpWP/bkpwp-pages/bkpwp_options.php:19
|
661 |
+
#: BackUpWP/bkpwp-pages/bkpwp_schedule.php:161
|
662 |
+
msgid "inactive"
|
663 |
+
msgstr "inaktiv"
|
664 |
+
|
665 |
+
#: BackUpWP/bkpwp-pages/bkpwp_options.php:23
|
666 |
+
#: BackUpWP/bkpwp-pages/bkpwp_schedule.php:165
|
667 |
+
msgid "Schedule activity status could not be set"
|
668 |
+
msgstr "Zeitplan Status konnte nicht gesetzt werden"
|
669 |
+
|
670 |
+
#: BackUpWP/bkpwp-pages/bkpwp_options.php:32
|
671 |
+
#: BackUpWP/bkpwp-pages/bkpwp_options.php:38
|
672 |
+
msgid "You are running BackUpWordPress in "
|
673 |
+
msgstr "Sie verwenden BackUpWordPress im"
|
674 |
+
|
675 |
+
#: BackUpWP/bkpwp-pages/bkpwp_options.php:34
|
676 |
+
#: BackUpWP/bkpwp-pages/bkpwp_options.php:40
|
677 |
+
msgid "Configuration options below"
|
678 |
+
msgstr "Konfigurationsoptionen untenstehend"
|
679 |
+
|
680 |
+
#: BackUpWP/bkpwp-pages/bkpwp_options.php:35
|
681 |
+
#: BackUpWP/bkpwp-pages/bkpwp_help.php:183
|
682 |
+
msgid "For more options, please swith to "
|
683 |
+
msgstr "Für mehr Optionen, wechseln Sie bitte in den"
|
684 |
+
|
685 |
+
#: BackUpWP/bkpwp-pages/bkpwp_options.php:41
|
686 |
+
msgid "For less options, please swith to "
|
687 |
+
msgstr "Für weniger Optionen wechseln SIe bitte in den"
|
688 |
+
|
689 |
+
#: BackUpWP/bkpwp-pages/bkpwp_options.php:47
|
690 |
+
#: BackUpWP/bkpwp-pages/bkpwp_help.php:174
|
691 |
+
#: BackUpWP/bkpwp-pages/bkpwp_help.php:191
|
692 |
+
msgid "Backup Path"
|
693 |
+
msgstr "Backup Pfad"
|
694 |
+
|
695 |
+
#: BackUpWP/bkpwp-pages/bkpwp_options.php:49
|
696 |
+
msgid "This is where all your backups go"
|
697 |
+
msgstr "Hier werden Ihre Backups gespeichert"
|
698 |
+
|
699 |
+
#: BackUpWP/bkpwp-pages/bkpwp_options.php:54
|
700 |
+
#: BackUpWP/bkpwp-pages/bkpwp_options.php:103
|
701 |
+
#: BackUpWP/bkpwp-pages/bkpwp_options.php:125
|
702 |
+
#: BackUpWP/bkpwp-pages/bkpwp_options.php:199
|
703 |
+
#: BackUpWP/bkpwp-pages/bkpwp_options.php:209
|
704 |
+
msgid "save"
|
705 |
+
msgstr "speichern"
|
706 |
+
|
707 |
+
#: BackUpWP/bkpwp-pages/bkpwp_options.php:63
|
708 |
+
#: BackUpWP/bkpwp-pages/bkpwp_help.php:176
|
709 |
+
#: BackUpWP/bkpwp-pages/bkpwp_help.php:193
|
710 |
+
msgid "Basic Scheduling"
|
711 |
+
msgstr "Einfacher Zeitplan"
|
712 |
+
|
713 |
+
#: BackUpWP/bkpwp-pages/bkpwp_options.php:65
|
714 |
+
msgid "Do you want BackUpWordPress to be scheduled and run automatically?"
|
715 |
+
msgstr "Möchten Sie, dass BackUpWordPress nach einem Zeitplan automatische Backups anfertigt?"
|
716 |
+
|
717 |
+
#: BackUpWP/bkpwp-pages/bkpwp_options.php:74
|
718 |
+
msgid "Backup Type"
|
719 |
+
msgstr "Backup Art"
|
720 |
+
|
721 |
+
#: BackUpWP/bkpwp-pages/bkpwp_options.php:76
|
722 |
+
msgid "is not activated"
|
723 |
+
msgstr "ist nicht aktiviert"
|
724 |
+
|
725 |
+
#: BackUpWP/bkpwp-pages/bkpwp_options.php:76
|
726 |
+
#: BackUpWP/bkpwp-pages/bkpwp_schedule.php:97
|
727 |
+
msgid "activate"
|
728 |
+
msgstr "aktiviert"
|
729 |
+
|
730 |
+
#: BackUpWP/bkpwp-pages/bkpwp_options.php:78
|
731 |
+
msgid "is currently set to active"
|
732 |
+
msgstr "ist momentan aktiviert"
|
733 |
+
|
734 |
+
#: BackUpWP/bkpwp-pages/bkpwp_options.php:78
|
735 |
+
#: BackUpWP/bkpwp-pages/bkpwp_schedule.php:99
|
736 |
+
msgid "deactivate"
|
737 |
+
msgstr "deaktivieren"
|
738 |
+
|
739 |
+
#: BackUpWP/bkpwp-pages/bkpwp_options.php:91
|
740 |
+
#: BackUpWP/bkpwp-pages/bkpwp_help.php:178
|
741 |
+
#: BackUpWP/bkpwp-pages/bkpwp_help.php:195
|
742 |
+
msgid "Mail Setup"
|
743 |
+
msgstr "Email Einstellungen"
|
744 |
+
|
745 |
+
#: BackUpWP/bkpwp-pages/bkpwp_options.php:93
|
746 |
+
msgid "Do you want to receive your backups automatically by email?"
|
747 |
+
msgstr "Möchten Sie Backups automatisch per email erhalten?"
|
748 |
+
|
749 |
+
#: BackUpWP/bkpwp-pages/bkpwp_options.php:97
|
750 |
+
msgid "Mail to:"
|
751 |
+
msgstr "Email an:"
|
752 |
+
|
753 |
+
#: BackUpWP/bkpwp-pages/bkpwp_options.php:99
|
754 |
+
msgid "Yes, send me my backups"
|
755 |
+
msgstr "Ja, ich möchte Backups per email erhalten"
|
756 |
+
|
757 |
+
#: BackUpWP/bkpwp-pages/bkpwp_options.php:100
|
758 |
+
msgid "as long as they are smaller than"
|
759 |
+
msgstr "wenn SIe kleiner sind als"
|
760 |
+
|
761 |
+
#: BackUpWP/bkpwp-pages/bkpwp_options.php:115
|
762 |
+
#: BackUpWP/bkpwp-pages/bkpwp_help.php:197
|
763 |
+
msgid "Backup Storage"
|
764 |
+
msgstr "Backup Speicher"
|
765 |
+
|
766 |
+
#: BackUpWP/bkpwp-pages/bkpwp_options.php:117
|
767 |
+
msgid "How many Backups do you want to keep?"
|
768 |
+
msgstr "Wie viele Backups sollen gespeichert werden?"
|
769 |
+
|
770 |
+
#: BackUpWP/bkpwp-pages/bkpwp_options.php:121
|
771 |
+
msgid "maximum Backups"
|
772 |
+
msgstr "maximal Backups"
|
773 |
+
|
774 |
+
#: BackUpWP/bkpwp-pages/bkpwp_options.php:132
|
775 |
+
#: BackUpWP/bkpwp-pages/bkpwp_help.php:199
|
776 |
+
msgid "Exclude Lists"
|
777 |
+
msgstr "Ausschlusslisten"
|
778 |
+
|
779 |
+
#: BackUpWP/bkpwp-pages/bkpwp_options.php:150
|
780 |
+
msgid "Files & Folders that will NOT (!) be included in the Backup when using "
|
781 |
+
msgstr "Dateien & Verzeichnisse, die NICHT(!) im Backup enthalten sein weden, wenn"
|
782 |
+
|
783 |
+
#: BackUpWP/bkpwp-pages/bkpwp_options.php:167
|
784 |
+
msgid "Edit an existing Exclude List"
|
785 |
+
msgstr "eine bestehende Ausschlussliste ändern"
|
786 |
+
|
787 |
+
#: BackUpWP/bkpwp-pages/bkpwp_options.php:169
|
788 |
+
msgid "Please select"
|
789 |
+
msgstr "Bitte auswählen"
|
790 |
+
|
791 |
+
#: BackUpWP/bkpwp-pages/bkpwp_options.php:184
|
792 |
+
msgid "Exclude List Name"
|
793 |
+
msgstr "Name der Ausschlussliste"
|
794 |
+
|
795 |
+
#: BackUpWP/bkpwp-pages/bkpwp_options.php:189
|
796 |
+
#: BackUpWP/bkpwp-pages/bkpwp_options.php:208
|
797 |
+
msgid "Files to exclude"
|
798 |
+
msgstr "Dateien, die ausgeschlossen werden"
|
799 |
+
|
800 |
+
#: BackUpWP/bkpwp-pages/bkpwp_options.php:201
|
801 |
+
msgid "this is a Default Exclude List"
|
802 |
+
msgstr "Dies ist eine voreingestellte Ausschlussliste"
|
803 |
+
|
804 |
+
#: BackUpWP/bkpwp-pages/bkpwp_options.php:203
|
805 |
+
msgid "Show excluded files"
|
806 |
+
msgstr "ausgeschlossenen Dateien anzeigen"
|
807 |
+
|
808 |
+
#: BackUpWP/bkpwp-pages/bkpwp_options.php:206
|
809 |
+
msgid "New Exclude List"
|
810 |
+
msgstr "Neue Ausschlussliste"
|
811 |
+
|
812 |
+
#: BackUpWP/bkpwp-pages/bkpwp_options.php:207
|
813 |
+
msgid "Name"
|
814 |
+
msgstr "Name"
|
815 |
+
|
816 |
+
#: BackUpWP/bkpwp-pages/bkpwp_options.php:213
|
817 |
+
msgid "enter an <b>absolute or relative path</b> to your folders/ files not to backup"
|
818 |
+
msgstr "geben Sie einen <b>absoluten oder relativen</b> Pfad zu ihren Verzeichnissen /Dateien an, die nicht gesichert werden sollen"
|
819 |
+
|
820 |
+
#: BackUpWP/bkpwp-pages/bkpwp_options.php:214
|
821 |
+
msgid "or <b>just names or file-extensions (.php, .txt) which should match files</b>"
|
822 |
+
msgstr "oder geben Sie <b>nur Namen oder Dateiendungen (.php,.txt)</b> an, welceh zu den ausgeschlossenen Dateien passen"
|
823 |
+
|
824 |
+
#: BackUpWP/bkpwp-pages/bkpwp_options.php:215
|
825 |
+
msgid "no need to take care of the <b>backup folder</b>, it <b>will be excluded anyways"
|
826 |
+
msgstr "Das Backup-Verzeichnis selbst ist bereits berücksichtigt."
|
827 |
+
|
828 |
+
#: BackUpWP/bkpwp-pages/bkpwp_options.php:216
|
829 |
+
msgid "Seperate with commas."
|
830 |
+
msgstr "Mit Kommas getrennt eingeben."
|
831 |
+
|
832 |
+
#: BackUpWP/bkpwp-pages/bkpwp_schedule.php:6
|
833 |
+
msgid "Info: Creating custom schedules is on the wishlist for BackUpWordPress 2.0."
|
834 |
+
msgstr "Information: Eigene Zeitpläne zu erstellen ist auf der Wunschliste für die nächste Version von BackUpWordPress"
|
835 |
+
|
836 |
+
#: BackUpWP/bkpwp-pages/bkpwp_schedule.php:10
|
837 |
+
msgid "reset default schedules"
|
838 |
+
msgstr "voreingestellte Zeipläne wiederherstellen"
|
839 |
+
|
840 |
+
#: BackUpWP/bkpwp-pages/bkpwp_schedule.php:11
|
841 |
+
msgid "test schedules"
|
842 |
+
msgstr "Zeitplan testen"
|
843 |
+
|
844 |
+
#: BackUpWP/bkpwp-pages/bkpwp_schedule.php:24
|
845 |
+
msgid "Last run"
|
846 |
+
msgstr "letzter Lauf"
|
847 |
+
|
848 |
+
#: BackUpWP/bkpwp-pages/bkpwp_schedule.php:25
|
849 |
+
msgid "Next run"
|
850 |
+
msgstr "nächster Lauf"
|
851 |
+
|
852 |
+
#: BackUpWP/bkpwp-pages/bkpwp_schedule.php:26
|
853 |
+
msgid "Countdown"
|
854 |
+
msgstr "Countdown"
|
855 |
+
|
856 |
+
#: BackUpWP/bkpwp-pages/bkpwp_schedule.php:27
|
857 |
+
msgid "Backup Preset"
|
858 |
+
msgstr "Backup Voreinstellung"
|
859 |
+
|
860 |
+
#: BackUpWP/bkpwp-pages/bkpwp_schedule.php:28
|
861 |
+
msgid "Reccurrence"
|
862 |
+
msgstr "Wiederholung"
|
863 |
+
|
864 |
+
#: BackUpWP/bkpwp-pages/bkpwp_schedule.php:45
|
865 |
+
msgid "Not Yet"
|
866 |
+
msgstr "noch nicht"
|
867 |
+
|
868 |
+
#: BackUpWP/bkpwp-pages/bkpwp_schedule.php:77
|
869 |
+
msgid "Backup inactive."
|
870 |
+
msgstr "Backup ist inaktiv."
|
871 |
+
|
872 |
+
#: BackUpWP/bkpwp-pages/bkpwp_schedule.php:79
|
873 |
+
msgid "Backup done."
|
874 |
+
msgstr "Backup erstellt."
|
875 |
+
|
876 |
+
#: BackUpWP/bkpwp-pages/bkpwp_schedule.php:141
|
877 |
+
msgid "Schedule deleted."
|
878 |
+
msgstr "Zeitplan gelöscht."
|
879 |
+
|
880 |
+
#: BackUpWP/bkpwp-pages/bkpwp_schedule.php:143
|
881 |
+
msgid "Schedule could not be deleted."
|
882 |
+
msgstr "Zeitplan konnte nicht gelöscht werden."
|
883 |
+
|
884 |
+
#: BackUpWP/bkpwp-pages/bkpwp_schedule.php:178
|
885 |
+
msgid "Schedules reset to defaults. Please be patient, scheduling may take a few seconds to show up in the list below."
|
886 |
+
msgstr "Zeitpläne sind auf die Voreinstellung zurückgesetzt worden. Bitte etwas Geduld, es kann ein paar Sekunden dauern, bis die Einträge in der Liste wieder aufscheinen."
|
887 |
+
|
888 |
+
#: BackUpWP/bkpwp-pages/bkpwp_schedule.php:188
|
889 |
+
msgid ""
|
890 |
+
"A schedule without reccurrence for one single Database Backup has been set up \n"
|
891 |
+
"\t\t\tand should execute with the first hit your Blog receives after 30 Seconds from now."
|
892 |
+
msgstr ""
|
893 |
+
"Ein Zeitplan ohne Wiederholung für ein einzelnes Datenbankbackup ist erstellt woedern \n"
|
894 |
+
"\t\t\tund sollte mit dem ersten hit auf Ihre Webseite innerhalb von 30 Sekunden durchgeführt werden."
|
895 |
+
|
896 |
+
#: BackUpWP/bkpwp-pages/bkpwp_schedule.php:191
|
897 |
+
msgid "Testing schedules failed."
|
898 |
+
msgstr "Testzeitplan fehlerhaft."
|
899 |
+
|
900 |
+
#: BackUpWP/bkpwp-pages/bkpwp_schedule.php:209
|
901 |
+
msgid "go on, delete"
|
902 |
+
msgstr "weiter, löschen"
|
903 |
+
|
904 |
+
#: BackUpWP/bkpwp-pages/bkpwp_help.php:6
|
905 |
+
msgid "BackUpWordPress Help"
|
906 |
+
msgstr "BackUpWordPress Hilfe"
|
907 |
+
|
908 |
+
#: BackUpWP/bkpwp-pages/bkpwp_help.php:15
|
909 |
+
#: BackUpWP/bkpwp-pages/bkpwp_help.php:105
|
910 |
+
#: BackUpWP/bkpwp-pages/bkpwp_help.php:143
|
911 |
+
#: BackUpWP/bkpwp-pages/bkpwp_help.php:188
|
912 |
+
msgid "Help Index"
|
913 |
+
msgstr "Hile Index"
|
914 |
+
|
915 |
+
#: BackUpWP/bkpwp-pages/bkpwp_help.php:18
|
916 |
+
msgid ""
|
917 |
+
"BackUpWordPress creates backup archives within a backup repository. \n"
|
918 |
+
"\t\t\t\tIt saves all your WordPress files as well as your Database for recovery purposes."
|
919 |
+
msgstr "BackUpWordPress erstellt Backup Archive in einem Backup Verzeichnis. BackUpWordPress speichert sowohl Datenbank als auch Dateien zum Zweck einer Wiederherstellung."
|
920 |
+
|
921 |
+
#: BackUpWP/bkpwp-pages/bkpwp_help.php:24
|
922 |
+
msgid "BackUpWordPress keeps a number of"
|
923 |
+
msgstr "BackUpWordPress speichert "
|
924 |
+
|
925 |
+
#: BackUpWP/bkpwp-pages/bkpwp_help.php:26
|
926 |
+
msgid "backup archives in the backup repository."
|
927 |
+
msgstr "Backup Archive im Backup Verzeichnis."
|
928 |
+
|
929 |
+
#: BackUpWP/bkpwp-pages/bkpwp_help.php:28
|
930 |
+
#: BackUpWP/bkpwp-pages/bkpwp_help.php:54
|
931 |
+
msgid ""
|
932 |
+
"As soon as this amount of backup archives in the repository is reached, \n"
|
933 |
+
"\t\t\t\tevery next backup will cause the oldest backup archive to be deleted."
|
934 |
+
msgstr "Sobald diese Anzahl an Backup Archiven erreicht ist, wird das jeweils älteste Archiv gelöscht."
|
935 |
+
|
936 |
+
#: BackUpWP/bkpwp-pages/bkpwp_help.php:33
|
937 |
+
msgid "There are two ways of doing backups:"
|
938 |
+
msgstr "Es gibt zwei Methoden, Backup Archive zu erstellen:"
|
939 |
+
|
940 |
+
#: BackUpWP/bkpwp-pages/bkpwp_help.php:35
|
941 |
+
#: BackUpWP/bkpwp-pages/bkpwp_help.php:61
|
942 |
+
msgid "You can run BackUpWordPress manually by hitting the \"BackUpWordPress Now\" button."
|
943 |
+
msgstr "BackUpWordPress kann manuell Ausgeführt werden."
|
944 |
+
|
945 |
+
#: BackUpWP/bkpwp-pages/bkpwp_help.php:36
|
946 |
+
msgid "This will create a full backup of your WordPress installation. Depending on the amount and size of your files it might take a while."
|
947 |
+
msgstr "Dies erstellt ein vollständiges Backup Ihrer WordPress Installation. Abhängig von der Menge und der Größe der Dateien, kann das eine ganze Weile dauern."
|
948 |
+
|
949 |
+
#: BackUpWP/bkpwp-pages/bkpwp_help.php:37
|
950 |
+
msgid "You can download your backups for archiving purposes"
|
951 |
+
msgstr "Sie können die Backups zu Archivierungszwecken vom Server laden."
|
952 |
+
|
953 |
+
#: BackUpWP/bkpwp-pages/bkpwp_help.php:38
|
954 |
+
msgid "You can restore your database and/or files"
|
955 |
+
msgstr "Sie können die Datenbank und/oder Dateien wiederherstellen"
|
956 |
+
|
957 |
+
#: BackUpWP/bkpwp-pages/bkpwp_help.php:42
|
958 |
+
msgid "For more information, please swith to "
|
959 |
+
msgstr "Für mehr Information wechseln Sie bitte in den"
|
960 |
+
|
961 |
+
#: BackUpWP/bkpwp-pages/bkpwp_help.php:48
|
962 |
+
msgid "By default, BackUpWordPress keeps a number of"
|
963 |
+
msgstr "Voreingestellt behält BackUpWordPress"
|
964 |
+
|
965 |
+
#: BackUpWP/bkpwp-pages/bkpwp_help.php:50
|
966 |
+
msgid "backup archives in the backup repository. You can alter this number within the Advanced Backup Settings. "
|
967 |
+
msgstr "Backup Archive im Backup Verzeichnis. Diese Zahl kann in den Konfigurationseinstellungen geändert werden."
|
968 |
+
|
969 |
+
#: BackUpWP/bkpwp-pages/bkpwp_help.php:59
|
970 |
+
msgid "Basically, there are two ways of doing backups:"
|
971 |
+
msgstr "Grundsätzlich gibt es zwei Möglichkeiten, Backups zu erstellen:"
|
972 |
+
|
973 |
+
#: BackUpWP/bkpwp-pages/bkpwp_help.php:62
|
974 |
+
msgid "You can activate scheduling, which will run weekly backups of your databse and monthly backups of your WordPress installations directory and file structure automatically."
|
975 |
+
msgstr "Sie können Zeitpläne aktivieren, die tägliche Backups der Datenbank und wöchentliche Backups der Dateistrukur automatisch erstellen."
|
976 |
+
|
977 |
+
#: BackUpWP/bkpwp-pages/bkpwp_help.php:66
|
978 |
+
msgid ""
|
979 |
+
"Both methods allow you to use Presets. \n"
|
980 |
+
"\t\t\t\tBackUpWordPress comes preconfigured with two Presets. \n"
|
981 |
+
"\t\t\t\tOne for a Database-only Backup, the other for a full backup including your WordPress file structure.\n"
|
982 |
+
"\t\t\t\tBackUpWordPress makes use of these two Presets when running in EasyMode."
|
983 |
+
msgstr "Beide Methoden verwenden Voreinstellungen. BackUpWordPress verfügt über zwei voreingestellte Voreinstellungen. Eines um reine Datenbank Backups zu erstellen und eines, um ein vollständiges Backup der WordPress Installation zu erstellen. Diese Voreinstellungen werden auch im EasyMode eingesetzt."
|
984 |
+
|
985 |
+
#: BackUpWP/bkpwp-pages/bkpwp_help.php:73
|
986 |
+
msgid "What can you do with your BackUpWordPress backup archives?"
|
987 |
+
msgstr "Was können SIe mit Ihren Backup Archiven machen?"
|
988 |
+
|
989 |
+
#: BackUpWP/bkpwp-pages/bkpwp_help.php:75
|
990 |
+
msgid "You can download BackUpWordPress archives"
|
991 |
+
msgstr "Sie können die Archiv Dateien vom Server herunterladen"
|
992 |
+
|
993 |
+
#: BackUpWP/bkpwp-pages/bkpwp_help.php:76
|
994 |
+
msgid ""
|
995 |
+
"For security reasons, not all of your WordPress files and directories are writeable by the webserver.\n"
|
996 |
+
"\t\t\t\t\tTherefore, for a full recovery, you might have to unpack a downloaded backup archive and upload the containig files via FTP, \n"
|
997 |
+
"\t\t\t\t\tjust as you did when installing WordPress for the first time. Overwriting existing files on the webserver will set your \n"
|
998 |
+
"\t\t\t\t\tWordpress installation back to the state when your backup archive was saved."
|
999 |
+
msgstr "Aus Sicherheitsgründen sind nicht alle Ihre Datein und Verzeichnisse für den Webserver schreibbar. Um eine WordPRess installation vollständig wiederherzustellen müssen Sie womöglich ein Backup-Archiv lokal entpacken und die Dateien per FTP wieder auf den Server laden."
|
1000 |
+
|
1001 |
+
#: BackUpWP/bkpwp-pages/bkpwp_help.php:80
|
1002 |
+
msgid "\"view\" gives you extended information about the archive file and Backup Process (Log)."
|
1003 |
+
msgstr "\"anzeigen\" zeigt ausführliche Informationen über das Backup-Archiv und seinen Erstellungsprozess (Log) an."
|
1004 |
+
|
1005 |
+
#: BackUpWP/bkpwp-pages/bkpwp_help.php:81
|
1006 |
+
msgid "You can send yourself an email containing Backup Archive Files."
|
1007 |
+
msgstr "Sie können an sich selbst eine email mit dem Backup-Archiv senden."
|
1008 |
+
|
1009 |
+
#: BackUpWP/bkpwp-pages/bkpwp_help.php:82
|
1010 |
+
msgid "You can restore your WordPress Blog or parts of it."
|
1011 |
+
msgstr "Sie können ihre Webseite odr Teile davon aus einem Backup Archiv wiederherstellen."
|
1012 |
+
|
1013 |
+
#: BackUpWP/bkpwp-pages/bkpwp_help.php:83
|
1014 |
+
msgid "And you can simply delete unused Backup archive files."
|
1015 |
+
msgstr "Und Sie können nicht mehr benötigter Backup-Dateien einfach von Server löschen."
|
1016 |
+
|
1017 |
+
#: BackUpWP/bkpwp-pages/bkpwp_help.php:85
|
1018 |
+
msgid ""
|
1019 |
+
"Is your Wordpress installation getting really big?\n"
|
1020 |
+
"\t\t\t\tDoes your wp-content/uploads directory hold a huge amount of Files?"
|
1021 |
+
msgstr "Wird Ihre WordPress installation langsam zu groß? Sind relativ viele Dateien unter wp-content/Uploads vorhanden?"
|
1022 |
+
|
1023 |
+
#: BackUpWP/bkpwp-pages/bkpwp_help.php:89
|
1024 |
+
msgid ""
|
1025 |
+
"Consider hitting the \"Recalculate Used Disk Space\" button! \n"
|
1026 |
+
"\t\t\tThis way you can estimate how long BackUpWordPress will run and how big the resulting backup archive file will be."
|
1027 |
+
msgstr "Dann können Sie eine Berechnung des verbrauchten Speicherplatzes durchführen und anhand dessen kalkulieren, wieviel Speicherplatz das resultierende Backup-Archiv verbrauchen wird."
|
1028 |
+
|
1029 |
+
#: BackUpWP/bkpwp-pages/bkpwp_help.php:93
|
1030 |
+
msgid "This plugin my give you a better overview:"
|
1031 |
+
msgstr "Dieses Plugin könnte da vielleicht auch nützlich sein."
|
1032 |
+
|
1033 |
+
#: BackUpWP/bkpwp-pages/bkpwp_help.php:108
|
1034 |
+
msgid "BackUpWordPress Presets consist of a handful of options:"
|
1035 |
+
msgstr "BackUpWordPress Voreinstellungen bestehen aus einer handvoll Optionen:"
|
1036 |
+
|
1037 |
+
#: BackUpWP/bkpwp-pages/bkpwp_help.php:111
|
1038 |
+
msgid "Sets the archive file type and compression."
|
1039 |
+
msgstr "Setzt Archiv Dateityp und Komprimierung."
|
1040 |
+
|
1041 |
+
#: BackUpWP/bkpwp-pages/bkpwp_help.php:113
|
1042 |
+
msgid "Exclude Lists can be configured seperately."
|
1043 |
+
msgstr "Ausschlusslisten können separat konfiguriert werden."
|
1044 |
+
|
1045 |
+
#: BackUpWP/bkpwp-pages/bkpwp_help.php:115
|
1046 |
+
msgid "Database backup. Files and Folders (and thus Exclude Lists) are ignored."
|
1047 |
+
msgstr "Datenbank Backup. Dateien ud Verzeichnisse (und daher auch Ausschlusslisten) werden ignoriert."
|
1048 |
+
|
1049 |
+
#: BackUpWP/bkpwp-pages/bkpwp_help.php:119
|
1050 |
+
msgid ""
|
1051 |
+
"At install, BackUpWordPress checks for available compression types available on your webserver.\n"
|
1052 |
+
"\t\t\t\tIf you are missing archiv file types there, contact your webserver's admin."
|
1053 |
+
msgstr "Bei der Aktivierung von BackUpWordPress, wird überprüft, welche Komprimierungsmethoden zur Verfügung stehen. Sollten Sie Archiv-Typen hier vermissen, wenden SIe sich bitte an Ihren Systemadministrator."
|
1054 |
+
|
1055 |
+
#: BackUpWP/bkpwp-pages/bkpwp_help.php:123
|
1056 |
+
msgid ""
|
1057 |
+
"Note: .tgz, .tar and .tar.gz archive file types store Unix file and directory Permissions. \n"
|
1058 |
+
"\t\t\t\tIf your WordPress installation is hosted on a *nix system and you need resulting BackUpWodPress archives\n"
|
1059 |
+
"\t\t\t\tfor recovering purposes ther or want to migrate to another *nix host, .zip is not an option."
|
1060 |
+
msgstr "Beachten Sie: .tgz, .tar und .tar,gz Archiv Typen speichern auch die Datei und Verzeichnisberechtigungen. Wenn Ihre WordPress instelletion auf eine *nix Sysem gehostet wird, ist .zip keinen empfohlene Einstellung."
|
1061 |
+
|
1062 |
+
#: BackUpWP/bkpwp-pages/bkpwp_help.php:128
|
1063 |
+
msgid "You cannot delete default Presets, but you can alter them and save with a new Preset name."
|
1064 |
+
msgstr "Voreingestellte Voreinstellungen können nicht gelöscht weden, aber sie können geändert und unter einem neuen Namen gespeichert werden."
|
1065 |
+
|
1066 |
+
#: BackUpWP/bkpwp-pages/bkpwp_help.php:131
|
1067 |
+
msgid "The \"view\" action will give you a preview on what will be backed up with this preset."
|
1068 |
+
msgstr "\"Anzeigen\" ergibt eine Ansicht von Dateien, welche Dateien mit dieser Voreinstellung gesichert werden."
|
1069 |
+
|
1070 |
+
#: BackUpWP/bkpwp-pages/bkpwp_help.php:135
|
1071 |
+
msgid "Satisfied with Defaults? Consider switching to "
|
1072 |
+
msgstr "Die VOreinstellungen genügen Ihnen vollauf? Wechseln Sie in den"
|
1073 |
+
|
1074 |
+
#: BackUpWP/bkpwp-pages/bkpwp_help.php:146
|
1075 |
+
msgid "BackUpWordPress Schedules gives you the following options:"
|
1076 |
+
msgstr "BackUpWordPress Zeitpläne haben folgende Optionen:"
|
1077 |
+
|
1078 |
+
#: BackUpWP/bkpwp-pages/bkpwp_help.php:148
|
1079 |
+
msgid "Reset Default Schedules"
|
1080 |
+
msgstr "voreingestellte Zeitpläne wiederherstellen"
|
1081 |
+
|
1082 |
+
#: BackUpWP/bkpwp-pages/bkpwp_help.php:149
|
1083 |
+
msgid "Resets all schedules to default."
|
1084 |
+
msgstr "Stellt die Voreinstellungen für die Zeitpläne wieder her"
|
1085 |
+
|
1086 |
+
#: BackUpWP/bkpwp-pages/bkpwp_help.php:150
|
1087 |
+
msgid "Test Schedules"
|
1088 |
+
msgstr "Zeitpläne testen"
|
1089 |
+
|
1090 |
+
#: BackUpWP/bkpwp-pages/bkpwp_help.php:151
|
1091 |
+
msgid "You can set a single shedule without recurrence doing a SQL-only Backup just to test Scheduling."
|
1092 |
+
msgstr "Hier können Sie einen einzelnen Zeioplan ohne Wiederholung erstellen, wlecher ein Datenbankbackup ausführt."
|
1093 |
+
|
1094 |
+
#: BackUpWP/bkpwp-pages/bkpwp_help.php:152
|
1095 |
+
msgid "Activate/Deactivate Schedules"
|
1096 |
+
msgstr "Zeitplänen aktivieren/deaktivieren"
|
1097 |
+
|
1098 |
+
#: BackUpWP/bkpwp-pages/bkpwp_help.php:153
|
1099 |
+
msgid "Activation status can be set on any Schedule."
|
1100 |
+
msgstr "Dieser Status kann für jeden Zeitplan gesetzt weden."
|
1101 |
+
|
1102 |
+
#: BackUpWP/bkpwp-pages/bkpwp_help.php:154
|
1103 |
+
msgid "Delete Schedules"
|
1104 |
+
msgstr "Zeitpläne löschen"
|
1105 |
+
|
1106 |
+
#: BackUpWP/bkpwp-pages/bkpwp_help.php:158
|
1107 |
+
msgid "Note for WordPress plugin developers: Try and analyze"
|
1108 |
+
msgstr "Info für WordPress Entwickler: Probieren und analysiern Sie"
|
1109 |
+
|
1110 |
+
#: BackUpWP/bkpwp-pages/bkpwp_help.php:158
|
1111 |
+
msgid "Cron Developers Demo is a plugin created for the sole purpose of demonstrationg the pseudo-cron feature built into WordPress"
|
1112 |
+
msgstr "Cron Developer Demo ist zu dem alleinigen Zweck kreiert worden, um das WordPress eigene pseudo-Cron Feature zu demonstrieren."
|
1113 |
+
|
1114 |
+
#: BackUpWP/bkpwp-pages/bkpwp_help.php:162
|
1115 |
+
msgid "Satisfied with default Schedules? Consider switching to "
|
1116 |
+
msgstr "Sie sind mit den voreingestellen Zeitplänen zufrieden? Wechseln Sie in den"
|
1117 |
+
|
1118 |
+
#: BackUpWP/bkpwp-pages/bkpwp_help.php:169
|
1119 |
+
msgid "BackUpWordPress Settings"
|
1120 |
+
msgstr "BackUpWordPress Einstellungen"
|
1121 |
+
|
1122 |
+
#: BackUpWP/bkpwp-pages/bkpwp_help.php:175
|
1123 |
+
#: BackUpWP/bkpwp-pages/bkpwp_help.php:192
|
1124 |
+
msgid "Set the directory where your backups will be stored."
|
1125 |
+
msgstr "Setzten Sie das Verzeichnis, in dem Ihre Backups gespeichert werden sollen."
|
1126 |
+
|
1127 |
+
#: BackUpWP/bkpwp-pages/bkpwp_help.php:177
|
1128 |
+
msgid "Turn scheduled Backups on or off."
|
1129 |
+
msgstr "Zeitpläne aktivieren und deaktivieren."
|
1130 |
+
|
1131 |
+
#: BackUpWP/bkpwp-pages/bkpwp_help.php:179
|
1132 |
+
#: BackUpWP/bkpwp-pages/bkpwp_help.php:196
|
1133 |
+
msgid "Activate or deactivate Backup email notification."
|
1134 |
+
msgstr "Email-Benachrichtigung bei neu erstellen Backups aktivieren und deaktivieren."
|
1135 |
+
|
1136 |
+
#: BackUpWP/bkpwp-pages/bkpwp_help.php:194
|
1137 |
+
msgid "is a shortcut for scheduling defaults."
|
1138 |
+
msgstr "ist eine Abkürzung zu den Zeitplan Voreinstellungen"
|
1139 |
+
|
1140 |
+
#: BackUpWP/bkpwp-pages/bkpwp_help.php:198
|
1141 |
+
msgid "Set the number of Backups to keep."
|
1142 |
+
msgstr "Setzen Sie die Anzahl der Backups die gespeichert bleiben sollen."
|
1143 |
+
|
1144 |
+
#: BackUpWP/bkpwp-pages/bkpwp_help.php:200
|
1145 |
+
msgid "Configure Exclude Lists for use with your presets."
|
1146 |
+
msgstr "Konfigurieren Sie eigene Ausschlusslisten zur Verwendung mit Ihren Voreinstellungen."
|
1147 |
+
|
1148 |
+
#: BackUpWP/bkpwp-pages/bkpwp_help.php:204
|
1149 |
+
msgid "Too many Settings? Consider switching to "
|
1150 |
+
msgstr "Zu viele Optionen? Wechseln Sie in den"
|
1151 |
+
|
readme.txt
ADDED
@@ -0,0 +1,60 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
=== BackUpWordPress ===
|
2 |
+
Contributors: wpdprx
|
3 |
+
Donate link: http://wordpress.designpraxis.at/
|
4 |
+
Tags: Backup, database, diectory, uploads, images, db, recovery
|
5 |
+
Requires at least: 2.1
|
6 |
+
Tested up to: 2.2.2
|
7 |
+
Stable tag: trunk
|
8 |
+
|
9 |
+
BackUpWordPress is a Backup & Recovery Suite for your WordPress website. This Plugin allows you to backup database as well as files and comes with a rich set of options.
|
10 |
+
|
11 |
+
|
12 |
+
== Description ==
|
13 |
+
|
14 |
+
Features:
|
15 |
+
|
16 |
+
EasyMode:
|
17 |
+
|
18 |
+
+ Switch between EasyMode and AdvancedMode
|
19 |
+
+ Database backup as well as directory structure including uploaded files, plugins, etc.
|
20 |
+
+ Set up Mail notification on new backups
|
21 |
+
+ Trigger backup manually
|
22 |
+
+ Set basic schedules for your backups
|
23 |
+
+ restore backups
|
24 |
+
+ download backups
|
25 |
+
+ Help page
|
26 |
+
+ Language Support for english and german(deutsch)
|
27 |
+
|
28 |
+
more option in AdvancedMode:
|
29 |
+
|
30 |
+
+ Set and manage custom schedules
|
31 |
+
+ Check disk space
|
32 |
+
+ View backup Logs
|
33 |
+
+ Delete backups manually
|
34 |
+
+ Manage backup presets
|
35 |
+
+ Manage exclude-lists for use with these presets
|
36 |
+
|
37 |
+
|
38 |
+
== Installation ==
|
39 |
+
|
40 |
+
1. Download, unzip and upload to your WordPress plugins directory
|
41 |
+
2. activate the plugin within you WordPress Administration Backend
|
42 |
+
3. Go to BackUpWordPress in your Administration Backend
|
43 |
+
|
44 |
+
|
45 |
+
== Screenshots ==
|
46 |
+
|
47 |
+
1. Manage your Backups
|
48 |
+
2. Switch between EasyMode and AdvancedMode
|
49 |
+
3. Activate scheduling of your backups
|
50 |
+
4. Receive email notifications on new backups
|
51 |
+
5. Dashboard activity box view
|
52 |
+
|
53 |
+
== Notes ==
|
54 |
+
|
55 |
+
BackUpWordPress utilizes several Open Source Tools:
|
56 |
+
|
57 |
+
+ [PEAR](http://pear.php.net/package/PEAR/)
|
58 |
+
+ [FILE_ARCHIVE](http://pear.php.net/package/File_Archive) for compression/decompression
|
59 |
+
+ [bigdump](http://www.ozerov.de/bigdump.php) for staggered sql import
|
60 |
+
+ [Sajax](http://www.modernmethod.com/sajax/) for ajax support
|
screenshot-1.png
ADDED
Binary file
|
screenshot-2.png
ADDED
Binary file
|
screenshot-3.png
ADDED
Binary file
|
screenshot-4.png
ADDED
Binary file
|
screenshot-5.png
ADDED
Binary file
|