BackUpWordPress - Version 1.0

Version Description

Download this release

Release Info

Developer willmot
Plugin Icon 128x128 BackUpWordPress
Version 1.0
Comparing to
See all releases

Code changes from version 0.4.5 to 1.0

Files changed (94) hide show
  1. Archive.php +0 -1405
  2. Archive/Predicate.php +0 -57
  3. Archive/Predicate/And.php +0 -87
  4. Archive/Predicate/Current.php +0 -52
  5. Archive/Predicate/Custom.php +0 -88
  6. Archive/Predicate/Duplicate.php +0 -116
  7. Archive/Predicate/Ereg.php +0 -59
  8. Archive/Predicate/Eregi.php +0 -61
  9. Archive/Predicate/Extension.php +0 -71
  10. Archive/Predicate/False.php +0 -47
  11. Archive/Predicate/Index.php +0 -62
  12. Archive/Predicate/MIME.php +0 -75
  13. Archive/Predicate/MaxDepth.php +0 -63
  14. Archive/Predicate/MinSize.php +0 -59
  15. Archive/Predicate/MinTime.php +0 -63
  16. Archive/Predicate/Not.php +0 -55
  17. Archive/Predicate/Or.php +0 -85
  18. Archive/Predicate/True.php +0 -45
  19. Archive/Reader.php +0 -416
  20. Archive/Reader/Ar.php +0 -387
  21. Archive/Reader/Archive.php +0 -98
  22. Archive/Reader/Bzip2.php +0 -254
  23. Archive/Reader/Cache.php +0 -262
  24. Archive/Reader/ChangeName.php +0 -212
  25. Archive/Reader/Concat.php +0 -187
  26. Archive/Reader/Directory.php +0 -220
  27. Archive/Reader/File.php +0 -296
  28. Archive/Reader/Filter.php +0 -90
  29. Archive/Reader/Gzip.php +0 -276
  30. Archive/Reader/Memory.php +0 -227
  31. Archive/Reader/MimeList.php +0 -939
  32. Archive/Reader/Multi.php +0 -95
  33. Archive/Reader/Relay.php +0 -134
  34. Archive/Reader/Select.php +0 -63
  35. Archive/Reader/Tar.php +0 -355
  36. Archive/Reader/Uncompress.php +0 -312
  37. Archive/Reader/Zip.php +0 -493
  38. Archive/Writer.php +0 -119
  39. Archive/Writer/AddBaseName.php +0 -102
  40. Archive/Writer/Ar.php +0 -204
  41. Archive/Writer/Archive.php +0 -99
  42. Archive/Writer/Bzip2.php +0 -137
  43. Archive/Writer/Files.php +0 -250
  44. Archive/Writer/Gzip.php +0 -139
  45. Archive/Writer/Mail.php +0 -200
  46. Archive/Writer/Memory.php +0 -127
  47. Archive/Writer/MemoryArchive.php +0 -213
  48. Archive/Writer/Multi.php +0 -130
  49. Archive/Writer/Output.php +0 -93
  50. Archive/Writer/Tar.php +0 -230
  51. Archive/Writer/UniqueAppender.php +0 -143
  52. Archive/Writer/Zip.php +0 -260
  53. PEAR.php +0 -1112
  54. Type.php +0 -398
  55. admin.actions.php +72 -0
  56. admin.menus.php +18 -0
  57. admin.page.php +106 -0
  58. assets/hmbkp.css +3 -0
  59. assets/hmbkp.js +29 -0
  60. backupwordpress.php +0 -106
  61. bigdump/bigdump.php +0 -1033
  62. bkpwp-classes/interface.php +0 -49
  63. bkpwp-classes/manage_backups.php +0 -1114
  64. bkpwp-classes/options.php +0 -466
  65. bkpwp-classes/schedule.php +0 -116
  66. bkpwp-pages/bkpwp_footer.php +0 -28
  67. bkpwp-pages/bkpwp_help.php +0 -209
  68. bkpwp-pages/bkpwp_mail_footer.php +0 -4
  69. bkpwp-pages/bkpwp_manage_backups.php +0 -436
  70. bkpwp-pages/bkpwp_manage_presets.php +0 -151
  71. bkpwp-pages/bkpwp_options.php +0 -231
  72. bkpwp-pages/bkpwp_schedule.php +0 -287
  73. functions-interface.php +0 -165
  74. functions.php +0 -387
  75. functions/backup.files.fallback.functions.php +22 -0
  76. functions/backup.files.functions.php +151 -0
  77. functions/backup.functions.php +182 -0
  78. functions/backup.log.functions.php +59 -0
  79. functions/backup.mysql.fallback.functions.php +308 -0
  80. functions/backup.mysql.functions.php +84 -0
  81. functions/core.functions.php +334 -0
  82. functions/interface.functions.php +32 -0
  83. functions/settings.functions.php +55 -0
  84. images/disk.png +0 -0
  85. images/loading.gif +0 -0
  86. locale/de_DE.mo +0 -0
  87. locale/de_DE.po +0 -1151
  88. plugin.php +96 -0
  89. readme.txt +19 -128
  90. screenshot-1.png +0 -0
  91. screenshot-2.png +0 -0
  92. screenshot-3.png +0 -0
  93. screenshot-4.png +0 -0
  94. screenshot-5.png +0 -0
Archive.php DELETED
@@ -1,1405 +0,0 @@
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 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 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 BKPWP_PLUGIN_PATH.'Archive/Reader/Filter.php';
352
- require_once 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 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 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 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 BKPWP_PLUGIN_PATH.'Archive/Reader/Gzip.php';
670
- return new File_Archive_Reader_Gzip($source, $sourceOpened);
671
-
672
- case 'zip':
673
- require_once 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 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 BKPWP_PLUGIN_PATH.'Archive/Reader/Ar.php';
684
- return new File_Archive_Reader_Ar($source, $sourceOpened);
685
-
686
- /* case 'cab':
687
- require_once 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 DELETED
@@ -1,57 +0,0 @@
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 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 DELETED
@@ -1,87 +0,0 @@
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 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 DELETED
@@ -1,52 +0,0 @@
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 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 DELETED
@@ -1,88 +0,0 @@
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 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 DELETED
@@ -1,116 +0,0 @@
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 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 DELETED
@@ -1,59 +0,0 @@
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 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 DELETED
@@ -1,61 +0,0 @@
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 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 DELETED
@@ -1,71 +0,0 @@
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 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 DELETED
@@ -1,47 +0,0 @@
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 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 DELETED
@@ -1,62 +0,0 @@
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 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 DELETED
@@ -1,75 +0,0 @@
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 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 DELETED
@@ -1,63 +0,0 @@
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 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 DELETED
@@ -1,59 +0,0 @@
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 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 DELETED
@@ -1,63 +0,0 @@
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 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 DELETED
@@ -1,55 +0,0 @@
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 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 DELETED
@@ -1,85 +0,0 @@
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 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 DELETED
@@ -1,45 +0,0 @@
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 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 DELETED
@@ -1,416 +0,0 @@
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 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 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 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 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 DELETED
@@ -1,387 +0,0 @@
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 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 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 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 DELETED
@@ -1,98 +0,0 @@
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 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 DELETED
@@ -1,254 +0,0 @@
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 BKPWP_PLUGIN_PATH."Archive/Reader/Archive.php";
33
- require_once 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 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 DELETED
@@ -1,262 +0,0 @@
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 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 DELETED
@@ -1,212 +0,0 @@
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 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 DELETED
@@ -1,187 +0,0 @@
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 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 DELETED
@@ -1,220 +0,0 @@
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 BKPWP_PLUGIN_PATH."Archive/Reader/Relay.php";
33
- require_once 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 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 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 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 DELETED
@@ -1,296 +0,0 @@
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 BKPWP_PLUGIN_PATH."Archive/Reader.php";
33
- require_once 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 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 DELETED
@@ -1,90 +0,0 @@
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 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 DELETED
@@ -1,276 +0,0 @@
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 BKPWP_PLUGIN_PATH."Archive/Reader/Archive.php";
33
- require_once 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 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 DELETED
@@ -1,227 +0,0 @@
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 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 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 DELETED
@@ -1,939 +0,0 @@
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 DELETED
@@ -1,95 +0,0 @@
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 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 DELETED
@@ -1,134 +0,0 @@
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 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 DELETED
@@ -1,63 +0,0 @@
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 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 DELETED
@@ -1,355 +0,0 @@
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 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 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 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 DELETED
@@ -1,312 +0,0 @@
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 BKPWP_PLUGIN_PATH."Archive/Reader.php";
33
- require_once 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 DELETED
@@ -1,493 +0,0 @@
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 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 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 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 DELETED
@@ -1,119 +0,0 @@
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 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 DELETED
@@ -1,102 +0,0 @@
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 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 DELETED
@@ -1,204 +0,0 @@
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 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 DELETED
@@ -1,99 +0,0 @@
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 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 DELETED
@@ -1,137 +0,0 @@
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 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 DELETED
@@ -1,250 +0,0 @@
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 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 DELETED
@@ -1,139 +0,0 @@
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 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 DELETED
@@ -1,200 +0,0 @@
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 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 DELETED
@@ -1,127 +0,0 @@
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 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 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 DELETED
@@ -1,213 +0,0 @@
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 BKPWP_PLUGIN_PATH."Archive/Writer/Archive.php";
34
- require_once 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 DELETED
@@ -1,130 +0,0 @@
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 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 DELETED
@@ -1,93 +0,0 @@
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 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 DELETED
@@ -1,230 +0,0 @@
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 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 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 DELETED
@@ -1,143 +0,0 @@
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 BKPWP_PLUGIN_PATH."Archive/Writer.php";
37
- require_once BKPWP_PLUGIN_PATH."Archive/Reader.php";
38
- require_once 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 DELETED
@@ -1,260 +0,0 @@
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 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 DELETED
@@ -1,1112 +0,0 @@
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
- ?>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
Type.php DELETED
@@ -1,398 +0,0 @@
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 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
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
admin.actions.php ADDED
@@ -0,0 +1,72 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * Delete the backup and then redirect
5
+ * back to the backups page
6
+ */
7
+ function hmbkp_request_delete_backup() {
8
+
9
+ if ( !isset( $_GET['hmbkp_delete'] ) || empty( $_GET['hmbkp_delete'] ) )
10
+ return false;
11
+
12
+ hmbkp_delete_backup( $_GET['hmbkp_delete'] );
13
+
14
+ wp_redirect( remove_query_arg( 'hmbkp_delete' ) );
15
+ exit;
16
+
17
+ }
18
+ add_action( 'load-tools_page_humanmade_backups', 'hmbkp_request_delete_backup' );
19
+
20
+ /**
21
+ * Schedule a one time backup and then
22
+ * redirect back to the backups page
23
+ */
24
+ function hmbkp_request_do_backup() {
25
+
26
+ // Are we sure
27
+ if ( !isset( $_GET['action'] ) || $_GET['action'] !== 'hmbkp_backup_now' || hmbkp_is_in_progress() || !is_writable( hmbkp_path() ) || !is_dir( hmbkp_path() ) )
28
+ return false;
29
+
30
+ $options = array(
31
+ 'preset' => 'full backup',
32
+ 'info' => __( 'Single Backup', 'hmbkp' ),
33
+ 'created' => time()
34
+ );
35
+
36
+ update_option( 'hmbkp_running', microtime( true ) );
37
+
38
+ wp_schedule_single_event( time(), 'hmbkp_schedule_backup_hook', $options );
39
+
40
+ spawn_cron();
41
+
42
+ wp_redirect( remove_query_arg( 'action' ) );
43
+ exit;
44
+
45
+ }
46
+ add_action( 'load-tools_page_humanmade_backups', 'hmbkp_request_do_backup' );
47
+
48
+ /**
49
+ * Send the download file to the browser and
50
+ * then redirect back to the backups page
51
+ */
52
+ function hmbkp_request_download_backup() {
53
+
54
+ if ( !isset( $_GET['hmbkp_download'] ) || empty( $_GET['hmbkp_download'] ) )
55
+ return false;
56
+
57
+ hmbkp_send_file( base64_decode( $_GET['hmbkp_download'] ) );
58
+
59
+ }
60
+ add_action( 'load-tools_page_humanmade_backups', 'hmbkp_request_download_backup' );
61
+
62
+ function hmbkp_ajax_is_backup_in_progress() {
63
+ echo (int) hmbkp_is_in_progress();
64
+ exit;
65
+ }
66
+ add_action( 'wp_ajax_hmbkp_is_in_progress', 'hmbkp_ajax_is_backup_in_progress' );
67
+
68
+ function hmbkp_ajax_calculate_backup_size() {
69
+ echo hmbkp_calculate();
70
+ exit;
71
+ }
72
+ add_action( 'wp_ajax_hmbkp_calculate', 'hmbkp_ajax_calculate_backup_size' );
admin.menus.php ADDED
@@ -0,0 +1,18 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * Add the backups menu item
5
+ * to the tools menu
6
+ */
7
+ function hmbkp_admin_menu() {
8
+ add_management_page( __( 'Manage Backups','hmbkp' ), __( 'Backups','hmbkp' ), 'manage_options', 'humanmade_backups', 'hmbkp_manage_backups' );
9
+ }
10
+ add_action( 'admin_menu', 'hmbkp_admin_menu' );
11
+
12
+ /**
13
+ * Load the backups admin page
14
+ * when the menu option is clicked
15
+ */
16
+ function hmbkp_manage_backups() {
17
+ require_once( HMBKP_PLUGIN_PATH . '/admin.page.php' );
18
+ }
admin.page.php ADDED
@@ -0,0 +1,106 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php $schedules = get_option( 'hmbkp_schedules' ); ?>
2
+
3
+ <div class="wrap<?php if ( hmbkp_is_in_progress() ) { ?> hmbkp_running<?php } ?>">
4
+
5
+ <h2>
6
+
7
+ <?php _e( 'Manage Backups', 'hmbkp' ); ?>
8
+
9
+ <?php if ( hmbkp_is_in_progress() ) : ?>
10
+ <a class="button add-new-h2" <?php disabled( true ); ?>><img src="<?php echo site_url( 'wp-admin/images/wpspin_light.gif' ); ?>" width="16" height="16" /><?php _e( 'Backup Running', 'hmbkp' ); ?></a>
11
+
12
+ <?php elseif ( !is_writable( hmbkp_path() ) || !is_dir( hmbkp_path() ) ) : ?>
13
+ <a class="button add-new-h2" <?php disabled( true ); ?>><?php _e( 'Backup Now', 'hmbkp' ); ?></a>
14
+
15
+ <?php else : ?>
16
+ <a class="button add-new-h2" href="tools.php?page=<?php echo $_GET['page']; ?>&amp;action=hmbkp_backup_now"><?php _e( 'Backup Now', 'hmbkp' ); ?></a>
17
+
18
+ <?php endif; ?>
19
+
20
+ </h2>
21
+
22
+ <?php if ( is_dir( hmbkp_path() ) && is_writable( hmbkp_path() ) ) : ?>
23
+
24
+ <p>
25
+ <?php printf( __( 'Your %s &amp; %s will be automatically backed up every day at %s to %s.', 'hmbkp' ), '<code>' . __( 'database', 'hmbkp' ) . '</code>', '<code>' . __( 'files', 'hmbkp' ) . '</code>', '<code>' . date( 'H:i', wp_next_scheduled( 'hmbkp_schedule_backup_hook', $schedules['default'] ) ) . '</code>', '<code>' . trailingslashit( hmbkp_path() ) . '</code>' ); ?>
26
+ <span class="hmbkp_estimated-size"><?php printf( __( 'Each backup will be approximately %s.', 'hmbkp' ), '<code>Calculating Size...</code>' ); ?></span>
27
+ </p>
28
+
29
+ <?php $backup_archives = hmbkp_get_backups();
30
+ if ( count( $backup_archives ) ) : ?>
31
+
32
+ <h4><?php _e( 'Completed Backups', 'hmbkp' ); ?></h4>
33
+
34
+ <table class="widefat" id="hmbkp_manage_backups_table">
35
+ <thead>
36
+ <tr>
37
+ <th scope="col"><?php _e( 'Date &amp; Time', 'hmbkp' ); ?></th>
38
+ <th scope="col"><?php _e( 'Size', 'hmbkp' ); ?></th>
39
+ <th scope="col"><?php _e( 'Actions', 'hmbkp' ); ?></th>
40
+ </tr>
41
+ </thead>
42
+
43
+ <tbody id="the-list">
44
+
45
+ <?php foreach ( (array) $backup_archives as $file ) :
46
+
47
+ if ( !file_exists( $file['file'] ) )
48
+ continue;
49
+
50
+ hmbkp_get_backup_row( $file );
51
+
52
+ endforeach; ?>
53
+
54
+ </tbody>
55
+ </table>
56
+
57
+ <?php endif; ?>
58
+
59
+ <?php if ( count( $backup_archives ) >= get_option( 'hmbkp_max_backups' ) ) : ?>
60
+
61
+ <p class="howto"><?php printf( _n( '* Only the latest backup is saved.', '* Only the latest %d backups are saved.', get_option( 'hmbkp_max_backups' ), 'hmbkp' ) ); ?></p>
62
+
63
+ <?php endif; ?>
64
+
65
+ <h4><?php _e( 'Compatibility', 'hmbkp' ); ?></h4>
66
+
67
+ <?php if ( !hmbkp_zip_path() || !hmbkp_mysqldump_path() ) : ?>
68
+ <p><?php _e( 'You can increase the speed and reliability of your backups by resolving the items below. Your backups will still work fine if you don\'t.', 'hmnkp' ); ?></p>
69
+ <?php endif; ?>
70
+
71
+ <?php if ( !hmbkp_zip_path() ) : ?>
72
+
73
+ <p>&#10007; <?php printf( __( 'We couldn\'t find the %s command on your server.', 'hmbkp' ), '<code>zip</code>' ); ?></p>
74
+
75
+ <p><?php printf( __( 'You can fix this by adding %s to your %s file. run %s on your server to find the path or ask your server administrator.', 'hmbkp' ), '<code>' . define( 'HMBKP_ZIP_PATH', __( 'path to the zip command', 'hmbkp' ) ) . '</code>', '<code>wp-config.php</code>', '<code>which zip</code>' ); ?></p>
76
+
77
+ <?php else : ?>
78
+ <p>&#10003; <?php printf( __( 'Your files are being backed up using the %s command.', 'hmbkp' ), '<code>' . hmbkp_zip_path() . '</code>' ); ?></p>
79
+
80
+ <?php endif; ?>
81
+
82
+ <?php if ( !hmbkp_mysqldump_path() ) : ?>
83
+ <p>&#10007; <?php printf( __( 'We couldn\'t find the %s command on your server.', 'hmbkp' ), '<code>mysqldump</code>' ); ?></p>
84
+ <p><?php printf( __( 'You can fix this by adding %s to your %s file. run %s on your server to find the path or ask your server administrator.', 'hmbkp' ), '<code>' . define( 'HMBKP_MYSQLDUMP_PATH', __( 'path to the mysqldump command' ) ) . '</code>', '<code>wp-config.php</code>', '<code>which mysqldump</code>' ); ?></p>
85
+ <?php else : ?>
86
+ <p>&#10003; <?php printf( __( 'Your database is being backed up using the %s command.', 'hmbkp' ), '<code>' . hmbkp_mysqldump_path() . '</code>' ); ?></p>
87
+ <?php endif; ?>
88
+
89
+ <?php if ( defined( 'HMBKP_PATH' ) && HMBKP_PATH ) :
90
+ if ( !is_dir( HMBKP_PATH ) || !is_writable( HMBKP_PATH ) ) : ?>
91
+ <p>&#10007; <code><?php echo HMBKP_PATH; ?></code><?php printf( __( 'doesn\'t exist or isn\'t writable. your backups will be saved to %s.', 'hmbkp' ), '<code>' . hmbkp_path() . '</code>' ); ?></p>
92
+
93
+ <?php else : ?>
94
+ <p>&#10003; <?php printf( __( 'Your backups are being saved to %s.', 'hmbkp' ), '<code>' . hmbkp_path() . '</code>' ); ?></p>
95
+
96
+ <?php endif; ?>
97
+ <?php endif ; ?>
98
+
99
+ <?php else : ?>
100
+
101
+ <p><strong><?php _e( 'You need to fix the issues detailed above before BackUpWordPress can start.', 'hmbkp' ); ?></strong></p>
102
+ <?php endif; ?>
103
+
104
+ <p class="howto"><?php printf( __( 'If you need help getting things working you are more than welcome to email us at %s and we\'ll do what we can.', 'hmbkp' ), '<a href="mailto:support@humanmade.co.uk">support@humanmade.co.uk</a>' ); ?></p>
105
+
106
+ </div>
assets/hmbkp.css ADDED
@@ -0,0 +1,3 @@
 
 
 
1
+ .hmbkp_running .add-new-h2 img { margin: 0 3px -4px -9px; opacity: 0.3; }
2
+ .button.disabled, .button[disabled], .button[disabled="disabled"] { cursor: default; }
3
+ .button.disabled:active, .button[disabled]:active, .button[disabled="disabled"]:active { background: #F2F2F2 url(../../../../wp-admin/images/white-grad.png) repeat-x; }
assets/hmbkp.js ADDED
@@ -0,0 +1,29 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ jQuery( document ).ready( function( $ ) {
2
+
3
+ if ( $( '.hmbkp_running' ).size() ) {
4
+ hmbkpRedirectOnBackupComplete();
5
+ }
6
+
7
+ $.get( ajaxurl, { 'action' : 'hmbkp_calculate' },
8
+ function( data ) {
9
+ $( '.hmbkp_estimated-size code' ).removeClass( 'calculating' );
10
+ $( '.hmbkp_estimated-size code' ).fadeOut( function() {
11
+ $( this ).empty().append( data );
12
+ } ).fadeIn();
13
+ }
14
+ );
15
+
16
+ } );
17
+
18
+ function hmbkpRedirectOnBackupComplete() {
19
+
20
+ jQuery.get( ajaxurl, { 'action' : 'hmbkp_is_in_progress' },
21
+ function( data ) {
22
+ if ( data == 0 )
23
+ location.reload( true );
24
+ else
25
+ setTimeout( 'hmbkpRedirectOnBackupComplete();', 1000 );
26
+ }
27
+ );
28
+
29
+ }
backupwordpress.php DELETED
@@ -1,106 +0,0 @@
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.4.5
8
- Author URI: http://wordpress.designpraxis.at
9
- */
10
-
11
- /* Copyright 2007 Roland Rust (email : wordpress@designpraxis.at)
12
-
13
- This program is free software; you can redistribute it and/or modify
14
- it under the terms of the GNU General Public License as published by
15
- the Free Software Foundation; either version 2 of the License, or
16
- (at your option) any later version.
17
-
18
- This program 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
21
- GNU General Public License for more details.
22
-
23
- You should have received a copy of the GNU General Public License
24
- along with this program; if not, write to the Free Software
25
- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
26
- */
27
- define("BKPWP_PLUGIN_PATH", ABSPATH."wp-content/plugins/backupwordpress/");
28
- define("BKPWP_VERSION", "0.4.5");
29
-
30
- // get the functions
31
- require_once(BKPWP_PLUGIN_PATH."functions.php");
32
- // require_once the required PEAR::FILE_ARCHIVE package for files backup
33
- require_once BKPWP_PLUGIN_PATH."Archive.php";
34
- require_once BKPWP_PLUGIN_PATH."Type.php";
35
- // BackUpWordPress classes
36
- require_once(BKPWP_PLUGIN_PATH."bkpwp-classes/interface.php");
37
- require_once(BKPWP_PLUGIN_PATH."bkpwp-classes/options.php");
38
- require_once(BKPWP_PLUGIN_PATH."bkpwp-classes/manage_backups.php");
39
- require_once(BKPWP_PLUGIN_PATH."bkpwp-classes/schedule.php");
40
- require_once(BKPWP_PLUGIN_PATH."functions-interface.php");
41
-
42
- // Plugin activation and deactivation e.g.: set 'manage bkpwp' capabilities to admin
43
- add_action('activate_backupwordpress/backupwordpress.php', 'bkpwp_activate');
44
- add_action('deactivate_backupwordpress/backupwordpress.php', 'bkpwp_exit');
45
-
46
- // set up ajax stuff on init, to prevent header oputput
47
- add_action('init', 'bkpwp_download_files');
48
- add_action('init', 'bkpwp_setup');
49
- add_action('init', 'bkpwp_security_check');
50
- add_action('init', 'bkpwp_proceed_unfinished');
51
-
52
- // cron jobs with wordpress' pseude-cron: add special reccurences
53
- add_filter('cron_schedules', 'bkpwp_more_reccurences');
54
-
55
- add_action('bkpwp_schedule_bkpwp_hook','bkpwp_schedule_bkpwp');
56
- add_action('bkpwp_finish_bkpwp_hook','bkpwp_finish_bkpwp');
57
-
58
- // ajax new: prototype replaces sajax
59
- if (eregi("backupwordpress",$_REQUEST['page']) || eregi("bkpwp",$_REQUEST['page'])) {
60
- wp_enqueue_script('prototype');
61
- if (!empty($_POST['bkpwp_calculate_preset'])) {
62
- echo bkpwp_ajax_calculater($_POST['bkpwp_calculate_preset']); exit;
63
- }
64
- if (!empty($_POST['bkpwp_docreate_preset'])) {
65
- echo bkpwp_ajax_create($_POST['bkpwp_docreate_preset']); exit;
66
- }
67
- if (!empty($_POST['bkpwp_view_backup'])) {
68
- echo bkpwp_ajax_view_backup($_POST['bkpwp_view_backup']); exit;
69
- }
70
- if (!empty($_POST['bkpwp_view_excludelist'])) {
71
- echo bkpwp_ajax_shownobfiles($_POST['bkpwp_view_excludelist']); exit;
72
- }
73
- if (!empty($_POST['bkpwp_load_preset'])) {
74
- echo bkpwp_ajax_load_preset($_POST['bkpwp_load_preset']); exit;
75
- }
76
- if (!empty($_POST['bkpwp_view_preset'])) {
77
- echo bkpwp_ajax_view_preset($_POST['bkpwp_view_preset']); exit;
78
- }
79
- if (!empty($_POST['bkpwp_delete_preset'])) {
80
- echo bkpwp_ajax_delete_preset($_POST['bkpwp_delete_preset']); exit;
81
- }
82
- if (!empty($_POST['bkpwp_save_preset'])) {
83
- echo bkpwp_ajax_save_preset($_POST['bkpwp_save_preset'],$_POST['bkpwp_preset_archive_type'],$_POST['bkpwp_excludelist'],$_POST['bkpwp_sql_only']); exit;
84
- }
85
- }
86
- if (eregi("backupwordpress",$_REQUEST['page']) || eregi("bkpwp",$_REQUEST['page']) || $_SERVER['REQUEST_URI'] == "/wp-admin/index.php" || $_SERVER['REQUEST_URI'] == "/wp-admin/") {
87
- add_action('admin_head', 'bkpwp_load_css_and_js');
88
- }
89
- add_action('admin_menu', 'bkpwp_add_menu');
90
- add_action('activity_box_end', 'bkpwp_latest_activity',0);
91
-
92
- // debug code. how do we get rid of the eaccelerator problem causing a redeclare error fpr pear?
93
- /* if (eregi("backupwordpress",$_REQUEST['page']) || eregi("bkpwp",$_REQUEST['page'])) {
94
- //@ini_set('eaccelerator.enable',0)
95
- if ((ini_get('eaccelerator.enable') == 1)) {
96
- echo "eAcc is running";
97
- }
98
- if (!in_array("PEAR", get_declared_classes())) {
99
- echo "<pre>";
100
- //print_r(get_declared_classes());
101
- require_once BKPWP_PLUGIN_PATH."PEAR.php";
102
- echo "</pre>";
103
- }
104
- //print_r(get_declared_classes());
105
- } */
106
- ?>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
bigdump/bigdump.php DELETED
@@ -1,1033 +0,0 @@
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
- if (!current_user_can("manage_backups")) {
43
- die ("Access denied.");
44
- }
45
- global $table_prefix,$wpdb;
46
- // dprx-modified-end
47
-
48
- $db_server = DB_HOST;
49
- $db_name = DB_NAME;
50
- $db_username = DB_USER;
51
- $db_password = DB_PASSWORD;
52
-
53
- // Other Settings
54
-
55
- $csv_insert_table = ''; // Destination table for CSV files
56
- $ajax = true; // AJAX mode: import will be done without refreshing the website
57
- $filename = ''; // Specify the dump filename to suppress the file selection dialog
58
- $linespersession = 3000; // Lines to be executed per one import session
59
- $delaypersession = 0; // You can specify a sleep time in milliseconds after each session
60
- // Works only if JavaScript is activated. Use to reduce server overrun
61
-
62
- // Allowed comment delimiters: lines starting with these strings will be dropped by BigDump
63
-
64
- $comment[]='#'; // Standard comment lines are dropped by default
65
- $comment[]='-- ';
66
- // $comment[]='---'; // Uncomment this line if using proprietary dump created by outdated mysqldump
67
- // $comment[]='/*!'; // Or add your own string to leave out other proprietary things
68
-
69
-
70
- // Connection character set should be the same as the dump file character set (utf8, latin1, cp1251, koi8r etc.)
71
- // See http://dev.mysql.com/doc/refman/5.0/en/charset-charsets.html for the full list
72
-
73
- // dprx-modified-start
74
- $db_connection_charset = DB_CHARSET;
75
- // dprx-modified-end
76
-
77
-
78
- // *******************************************************************************************
79
- // If not familiar with PHP please don't change anything below this line
80
- // *******************************************************************************************
81
-
82
- if ($ajax)
83
- ob_start();
84
-
85
- define ('VERSION','0.28b');
86
- define ('DATA_CHUNK_LENGTH',16384); // How many chars are read per time
87
- define ('MAX_QUERY_LINES',300); // How many lines may be considered to be one query (except text lines)
88
- define ('TESTMODE',false); // Set to true to process the file without actually accessing the database
89
-
90
- header("Expires: Mon, 1 Dec 2003 01:00:00 GMT");
91
- header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT");
92
- header("Cache-Control: no-store, no-cache, must-revalidate");
93
- header("Cache-Control: post-check=0, pre-check=0", false);
94
- header("Pragma: no-cache");
95
-
96
- @ini_set('auto_detect_line_endings', true);
97
- @set_time_limit(0);
98
-
99
- // Clean and strip anything we don't want from user's input [0.27b]
100
-
101
- foreach ($_REQUEST as $key => $val)
102
- {
103
- $val = preg_replace("/[^_A-Za-z0-9-\.&=]/i",'', $val);
104
- $_REQUEST[$key] = $val;
105
- }
106
-
107
- ?>
108
- <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
109
- <html>
110
- <head>
111
- <title>BigDump ver. <?php echo (VERSION); ?></title>
112
- <meta http-equiv="CONTENT-TYPE" content="text/html; charset=iso-8859-1"/>
113
- <meta http-equiv="CONTENT-LANGUAGE" content="EN"/>
114
-
115
- <meta http-equiv="Cache-Control" content="no-cache/"/>
116
- <meta http-equiv="Pragma" content="no-cache"/>
117
- <meta http-equiv="Expires" content="-1"/>
118
-
119
- <style type="text/css">
120
- <!--
121
-
122
- body
123
- { background-color:#FFFFF0;
124
- }
125
-
126
- h1
127
- { font-size:20px;
128
- line-height:24px;
129
- font-family:Arial,Helvetica,sans-serif;
130
- margin-top:5px;
131
- margin-bottom:5px;
132
- }
133
-
134
- p,td,th
135
- { font-size:14px;
136
- line-height:18px;
137
- font-family:Arial,Helvetica,sans-serif;
138
- margin-top:5px;
139
- margin-bottom:5px;
140
- text-align:justify;
141
- vertical-align:top;
142
- }
143
-
144
- p.centr
145
- {
146
- text-align:center;
147
- }
148
-
149
- p.smlcentr
150
- { font-size:10px;
151
- line-height:14px;
152
- text-align:center;
153
- }
154
-
155
- p.error
156
- { color:#FF0000;
157
- font-weight:bold;
158
- }
159
-
160
- p.success
161
- { color:#00DD00;
162
- font-weight:bold;
163
- }
164
-
165
- p.successcentr
166
- { color:#00DD00;
167
- background-color:#DDDDFF;
168
- font-weight:bold;
169
- text-align:center;
170
- }
171
-
172
- td
173
- { background-color:#F8F8F8;
174
- text-align:left;
175
- }
176
-
177
- td.transparent
178
- { background-color:#FFFFF0;
179
- }
180
-
181
- th
182
- { font-weight:bold;
183
- color:#FFFFFF;
184
- background-color:#AAAAEE;
185
- text-align:left;
186
- }
187
-
188
- td.right
189
- { text-align:right;
190
- }
191
-
192
- form
193
- { margin-top:5px;
194
- margin-bottom:5px;
195
- }
196
-
197
- div.skin1
198
- {
199
- border-color:#3333EE;
200
- border-width:5px;
201
- border-style:solid;
202
- background-color:#AAAAEE;
203
- text-align:center;
204
- vertical-align:middle;
205
- padding:3px;
206
- margin:1px;
207
- }
208
-
209
- td.bg3
210
- { background-color:#EEEE99;
211
- text-align:left;
212
- vertical-align:top;
213
- width:20%;
214
- }
215
-
216
- th.bg4
217
- { background-color:#EEAA55;
218
- text-align:left;
219
- vertical-align:top;
220
- width:20%;
221
- }
222
-
223
- td.bgpctbar
224
- { background-color:#EEEEAA;
225
- text-align:left;
226
- vertical-align:middle;
227
- width:80%;
228
- }
229
-
230
- -->
231
- </style>
232
-
233
- </head>
234
-
235
- <body>
236
-
237
- <center>
238
-
239
- <table width="780" cellspacing="0" cellpadding="0">
240
- <tr><td class="transparent">
241
-
242
- <!-- <h1>BigDump: Staggered MySQL Dump Importer ver. <?php echo (VERSION); ?></h1> -->
243
-
244
- <?php
245
-
246
- function skin_open() {
247
- echo ('<div class="skin1">');
248
- }
249
-
250
- function skin_close() {
251
- echo ('</div>');
252
- }
253
-
254
- skin_open();
255
- echo ('<h1>BigDump: Staggered MySQL Dump Importer v'.VERSION.'</h1>');
256
- skin_close();
257
-
258
- $error = false;
259
- $file = false;
260
-
261
- // Check PHP version
262
-
263
- if (!$error && !function_exists('version_compare'))
264
- { echo ("<p class=\"error\">PHP version 4.1.0 is required for BigDump to proceed. You have PHP ".phpversion()." installed. Sorry!</p>\n");
265
- $error=true;
266
- }
267
-
268
- // Calculate PHP max upload size (handle settings like 10M or 100K)
269
-
270
- if (!$error)
271
- { $upload_max_filesize=ini_get("upload_max_filesize");
272
- if (eregi("([0-9]+)K",$upload_max_filesize,$tempregs)) $upload_max_filesize=$tempregs[1]*1024;
273
- if (eregi("([0-9]+)M",$upload_max_filesize,$tempregs)) $upload_max_filesize=$tempregs[1]*1024*1024;
274
- if (eregi("([0-9]+)G",$upload_max_filesize,$tempregs)) $upload_max_filesize=$tempregs[1]*1024*1024*1024;
275
- }
276
-
277
- // Get the current directory
278
-
279
- if (isset($_SERVER["CGIA"]))
280
- $upload_dir=dirname($_SERVER["CGIA"]);
281
- else if (isset($_SERVER["ORIG_SCRIPT_FILENAME"]))
282
- $upload_dir=dirname($_SERVER["ORIG_SCRIPT_FILENAME"]);
283
- else if (isset($_SERVER["PATH_TRANSLATED"]))
284
- $upload_dir=dirname($_SERVER["PATH_TRANSLATED"]);
285
- else
286
- $upload_dir=dirname($_SERVER["SCRIPT_FILENAME"]);
287
-
288
-
289
- // dprx-modified-start
290
- $upload_dir = get_option("bkpwppath");
291
- // dprx-modified-end
292
-
293
-
294
- // Handle file upload
295
-
296
- if (!$error && isset($_REQUEST["uploadbutton"]))
297
- { if (is_uploaded_file($_FILES["dumpfile"]["tmp_name"]) && ($_FILES["dumpfile"]["error"])==0)
298
- {
299
- $uploaded_filename=str_replace(" ","_",$_FILES["dumpfile"]["name"]);
300
- $uploaded_filename=preg_replace("/[^_A-Za-z0-9-\.]/i",'',$uploaded_filename);
301
- $uploaded_filepath=str_replace("\\","/",$upload_dir."/".$uploaded_filename);
302
-
303
- if (file_exists($uploaded_filename))
304
- { echo ("<p class=\"error\">File $uploaded_filename already exist! Delete and upload again!</p>\n");
305
- }
306
- else if (!eregi("(\.(sql|gz|csv))$",$uploaded_filename))
307
- { echo ("<p class=\"error\">You may only upload .sql .gz or .csv files.</p>\n");
308
- }
309
- else if (!@move_uploaded_file($_FILES["dumpfile"]["tmp_name"],$uploaded_filepath))
310
- { echo ("<p class=\"error\">Error moving uploaded file ".$_FILES["dumpfile"]["tmp_name"]." to the $uploaded_filepath</p>\n");
311
- echo ("<p>Check the directory permissions for $upload_dir (must be 777)!</p>\n");
312
- }
313
- else
314
- { echo ("<p class=\"success\">Uploaded file saved as $uploaded_filename</p>\n");
315
- }
316
- }
317
- else
318
- { echo ("<p class=\"error\">Error uploading file ".$_FILES["dumpfile"]["name"]."</p>\n");
319
- }
320
- }
321
-
322
-
323
- // Handle file deletion (delete only in the current directory for security reasons)
324
-
325
- if (!$error && isset($_REQUEST["delete"]) && $_REQUEST["delete"]!=basename($_SERVER["SCRIPT_FILENAME"]))
326
- { if (eregi("(\.(sql|gz|csv))$",$_REQUEST["delete"]) && @unlink(basename($_REQUEST["delete"])))
327
- echo ("<p class=\"success\">".$_REQUEST["delete"]." was removed successfully</p>\n");
328
- else
329
- echo ("<p class=\"error\">Can't remove ".$_REQUEST["delete"]."</p>\n");
330
- }
331
-
332
-
333
- // Connect to the database
334
-
335
- if (!$error && !TESTMODE)
336
- { $dbconnection = @mysql_connect($db_server,$db_username,$db_password);
337
- if ($dbconnection)
338
- $db = mysql_select_db($db_name);
339
- if (!$dbconnection || !$db)
340
- { echo ("<p class=\"error\">Database connection failed due to ".mysql_error()."</p>\n");
341
- echo ("<p>Edit the database settings in ".$_SERVER["SCRIPT_FILENAME"]." or contact your database provider</p>\n");
342
- $error=true;
343
- }
344
- if (!$error && $db_connection_charset!=='')
345
- @mysql_query("SET NAMES $db_connection_charset", $dbconnection);
346
- }
347
- else
348
- { $dbconnection = false;
349
- }
350
-
351
-
352
- // List uploaded files in multifile mode
353
-
354
- if (!$error && !isset($_REQUEST["fn"]) && $filename=="")
355
- { if ($dirhandle = opendir($upload_dir))
356
- { $dirhead=false;
357
- while (false !== ($dirfile = readdir($dirhandle)))
358
- { if ($dirfile != "." && $dirfile != ".." && $dirfile!=basename($_SERVER["SCRIPT_FILENAME"]))
359
- { if (!$dirhead)
360
- { echo ("<table width=\"100%\" cellspacing=\"2\" cellpadding=\"2\">\n");
361
- echo ("<tr><th>Filename</th><th>Size</th><th>Date&amp;Time</th><th>Type</th><th>&nbsp;</th><th>&nbsp;</th>\n");
362
- $dirhead=true;
363
- }
364
- // dprx-modified-start
365
- if ($dirfile != "bkpwp_restore.sql") { continue; }
366
- // dprx-modified-end
367
-
368
- echo ("<tr><td>$dirfile</td><td class=\"right\">".filesize($dirfile)."</td><td>".date ("Y-m-d H:i:s", filemtime($dirfile))."</td>");
369
-
370
- if (eregi("\.sql$",$dirfile))
371
- echo ("<td>SQL</td>");
372
- elseif (eregi("\.gz$",$dirfile))
373
- echo ("<td>GZip</td>");
374
- elseif (eregi("\.csv$",$dirfile))
375
- echo ("<td>CSV</td>");
376
- else
377
- echo ("<td>Misc</td>");
378
-
379
- if ((eregi("\.gz$",$dirfile) && function_exists("gzopen")) || eregi("\.sql$",$dirfile) || eregi("\.csv$",$dirfile))
380
- echo ("<td><a href=\"".$_SERVER["PHP_SELF"]."?start=1&amp;fn=$dirfile&amp;foffset=0&amp;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");
381
- else
382
- echo ("<td>&nbsp;</td>\n <td>&nbsp;</td></tr>\n");
383
- }
384
-
385
- }
386
- if ($dirhead) echo ("</table>\n");
387
- else echo ("<p>No uploaded files found in the working directory</p>\n");
388
- closedir($dirhandle);
389
- }
390
- else
391
- { echo ("<p class=\"error\">Error listing directory $upload_dir</p>\n");
392
- $error=true;
393
- }
394
- }
395
-
396
-
397
- // Single file mode
398
-
399
- if (!$error && !isset ($_REQUEST["fn"]) && $filename!="")
400
- { echo ("<p><a href=\"".$_SERVER["PHP_SELF"]."?start=1&amp;fn=$filename&amp;foffset=0&amp;totalqueries=0\">Start Import</a> from $filename into $db_name at $db_server</p>\n");
401
- }
402
-
403
-
404
- // File Upload Form
405
-
406
- if (!$error && !isset($_REQUEST["fn"]) && $filename=="")
407
- {
408
-
409
- // Test permissions on working directory
410
-
411
- do { $tempfilename=time().".tmp"; } while (file_exists($tempfilename));
412
- if (!($tempfile=@fopen($tempfilename,"w")))
413
- { echo ("<p>Upload form disabled. Permissions for the working directory <i>$upload_dir</i> <b>must be set to 777</b> in order ");
414
- echo ("to upload files from here. Alternatively you can upload your dump files via FTP.</p>\n");
415
- }
416
- else
417
- { fclose($tempfile);
418
- unlink ($tempfilename);
419
-
420
- echo ("<p>You can now upload your dump file up to $upload_max_filesize bytes (".round ($upload_max_filesize/1024/1024)." Mbytes) ");
421
- echo ("directly from your browser to the server. Alternatively you can upload your dump files of any size via FTP.</p>\n");
422
- ?>
423
- <form method="POST" action="<?php echo ($_SERVER["PHP_SELF"]); ?>" enctype="multipart/form-data">
424
- <input type="hidden" name="MAX_FILE_SIZE" value="$upload_max_filesize">
425
- <p>Dump file: <input type="file" name="dumpfile" accept="*/*" size=60"></p>
426
- <p><input type="submit" name="uploadbutton" value="Upload"></p>
427
- </form>
428
- <?php
429
- }
430
- }
431
-
432
- // Print the current mySQL connection charset
433
-
434
- if (!$error && !TESTMODE && !isset($_REQUEST["fn"]) && $filename=="")
435
- {
436
- $result = mysql_query("SHOW VARIABLES LIKE 'character_set_connection';");
437
- $row = mysql_fetch_assoc($result);
438
- if ($row)
439
- { $charset = $row['Value'];
440
- 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");
441
- }
442
- }
443
-
444
- // Open the file
445
-
446
- if (!$error && isset($_REQUEST["fn"]))
447
- {
448
-
449
- // Recognize GZip filename
450
-
451
- if (eregi("\.gz$",$_REQUEST["fn"]))
452
- $gzipmode=true;
453
- else
454
- $gzipmode=false;
455
- // dprx-modified-start
456
- if ((!$gzipmode && !$file=fopen($upload_dir."/".$_REQUEST["fn"],"rt")) || ($gzipmode && !$file=gzopen($upload_dir."/".$_REQUEST["fn"],"rt")))
457
- //if ((!$gzipmode && !$file=fopen($_REQUEST["fn"],"rt")) || ($gzipmode && !$file=gzopen($_REQUEST["fn"],"rt")))
458
- // dprx-modified-end
459
- { echo ("<p class=\"error\">Can't open ".$_REQUEST["fn"]." for import</p>\n");
460
- echo ("<p>Please, check that your dump file name contains only alphanumerical characters, and rename it accordingly, for example: ".
461
- $_REQUEST["fn"]." .<br>Or, you have to upload the ".$_REQUEST["fn"]." to the server</p>\n");
462
- $error=true;
463
- }
464
-
465
- // Get the file size (can't do it fast on gzipped files, no idea how)
466
-
467
- else if ((!$gzipmode && fseek($file, 0, SEEK_END)==0) || ($gzipmode && gzseek($file, 0)==0))
468
- { if (!$gzipmode) $filesize = ftell($file);
469
- else $filesize = gztell($file); // Always zero, ignore
470
- }
471
- else
472
- { echo ("<p class=\"error\">I can't get the filesize of ".$_REQUEST["fn"]."</p>\n");
473
- $error=true;
474
- }
475
- }
476
-
477
- // *******************************************************************************************
478
- // START IMPORT SESSION HERE
479
- // *******************************************************************************************
480
-
481
- if (!$error && isset($_REQUEST["start"]) && isset($_REQUEST["foffset"]) && eregi("(\.(sql|gz|csv))$",$_REQUEST["fn"]))
482
- {
483
-
484
- // Check start and foffset are numeric values
485
-
486
- if (!is_numeric($_REQUEST["start"]) || !is_numeric($_REQUEST["foffset"]))
487
- { echo ("<p class=\"error\">UNEXPECTED: Non-numeric values for start and foffset</p>\n");
488
- $error=true;
489
- }
490
-
491
- if (!$error)
492
- { $_REQUEST["start"] = floor($_REQUEST["start"]);
493
- $_REQUEST["foffset"] = floor($_REQUEST["foffset"]);
494
- skin_open();
495
- if (TESTMODE)
496
- echo ("<p class=\"centr\">TEST MODE ENABLED</p>\n");
497
- echo ("<p class=\"centr\">Processing file: <b>".$_REQUEST["fn"]."</b></p>\n");
498
- echo ("<p class=\"smlcentr\">Starting from line: ".$_REQUEST["start"]."</p>\n");
499
- skin_close();
500
- }
501
-
502
- // Check $_REQUEST["foffset"] upon $filesize (can't do it on gzipped files)
503
-
504
- if (!$error && !$gzipmode && $_REQUEST["foffset"]>$filesize)
505
- { echo ("<p class=\"error\">UNEXPECTED: Can't set file pointer behind the end of file</p>\n");
506
- $error=true;
507
- }
508
-
509
- // Set file pointer to $_REQUEST["foffset"]
510
-
511
- if (!$error && ((!$gzipmode && fseek($file, $_REQUEST["foffset"])!=0) || ($gzipmode && gzseek($file, $_REQUEST["foffset"])!=0)))
512
- { echo ("<p class=\"error\">UNEXPECTED: Can't set file pointer to offset: ".$_REQUEST["foffset"]."</p>\n");
513
- $error=true;
514
- }
515
-
516
- // Start processing queries from $file
517
-
518
- if (!$error)
519
- { $query="";
520
- $queries=0;
521
- $totalqueries=$_REQUEST["totalqueries"];
522
- $linenumber=$_REQUEST["start"];
523
- $querylines=0;
524
- $inparents=false;
525
-
526
- // Stay processing as long as the $linespersession is not reached or the query is still incomplete
527
-
528
- while ($linenumber<$_REQUEST["start"]+$linespersession || $query!="")
529
- {
530
-
531
- // Read the whole next line
532
-
533
- $dumpline = "";
534
- while (!feof($file) && substr ($dumpline, -1) != "\n")
535
- { if (!$gzipmode)
536
- $dumpline .= fgets($file, DATA_CHUNK_LENGTH);
537
- else
538
- $dumpline .= gzgets($file, DATA_CHUNK_LENGTH);
539
- }
540
- if ($dumpline==="") break;
541
-
542
-
543
- // Stop if csv file is used, but $csv_insert_table is not set
544
- if (($csv_insert_table == "") && (eregi("(\.csv)$",$_REQUEST["fn"])))
545
- {
546
- echo ("<p class=\"error\">Stopped at the line $linenumber. </p>");
547
- echo ('<p>At this place the current query is from csv file, but $csv_insert_table was not set.');
548
- echo ("You have to tell where you want to send your data.</p>\n");
549
- $error=true;
550
- break;
551
- }
552
-
553
- // Create an SQL query from CSV line
554
-
555
- if (($csv_insert_table != "") && (eregi("(\.csv)$",$_REQUEST["fn"])))
556
- $dumpline = 'INSERT INTO '.$csv_insert_table.' VALUES ('.$dumpline.');';
557
-
558
- // Handle DOS and Mac encoded linebreaks (I don't know if it will work on Win32 or Mac Servers)
559
-
560
- $dumpline=str_replace("\r\n", "\n", $dumpline);
561
- $dumpline=str_replace("\r", "\n", $dumpline);
562
-
563
- // DIAGNOSTIC
564
- // echo ("<p>Line $linenumber: $dumpline</p>\n");
565
-
566
- // Skip comments and blank lines only if NOT in parents
567
-
568
- if (!$inparents)
569
- { $skipline=false;
570
- reset($comment);
571
- foreach ($comment as $comment_value)
572
- { if (!$inparents && (trim($dumpline)=="" || strpos ($dumpline, $comment_value) === 0))
573
- { $skipline=true;
574
- break;
575
- }
576
- }
577
- if ($skipline)
578
- { $linenumber++;
579
- continue;
580
- }
581
- }
582
-
583
- // Remove double back-slashes from the dumpline prior to count the quotes ('\\' can only be within strings)
584
-
585
- $dumpline_deslashed = str_replace ("\\\\","",$dumpline);
586
-
587
- // Count ' and \' in the dumpline to avoid query break within a text field ending by ;
588
- // Please don't use double quotes ('"')to surround strings, it wont work
589
-
590
- $parents=substr_count ($dumpline_deslashed, "'")-substr_count ($dumpline_deslashed, "\\'");
591
- if ($parents % 2 != 0)
592
- $inparents=!$inparents;
593
-
594
- // Add the line to query
595
-
596
- $query .= $dumpline;
597
-
598
- // Don't count the line if in parents (text fields may include unlimited linebreaks)
599
-
600
- if (!$inparents)
601
- $querylines++;
602
-
603
- // Stop if query contains more lines as defined by MAX_QUERY_LINES
604
-
605
- if ($querylines>MAX_QUERY_LINES)
606
- {
607
- echo ("<p class=\"error\">Stopped at the line $linenumber. </p>");
608
- echo ("<p>At this place the current query includes more than ".MAX_QUERY_LINES." dump lines. That can happen if your dump file was ");
609
- 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 ");
610
- echo ("extended inserts. Please read the BigDump FAQs for more infos.</p>\n");
611
- $error=true;
612
- break;
613
- }
614
-
615
- // Execute query if end of query detected (; as last character) AND NOT in parents
616
-
617
- if (ereg(";$",trim($dumpline)) && !$inparents)
618
- { if (!TESTMODE && !mysql_query(trim($query), $dbconnection))
619
- { echo ("<p class=\"error\">Error at the line $linenumber: ". trim($dumpline)."</p>\n");
620
- echo ("<p>Query: ".trim(nl2br(htmlentities($query)))."</p>\n");
621
- echo ("<p>MySQL: ".mysql_error()."</p>\n");
622
- $error=true;
623
- break;
624
- }
625
- $totalqueries++;
626
- $queries++;
627
- $query="";
628
- $querylines=0;
629
- }
630
- $linenumber++;
631
- }
632
- }
633
-
634
- // Get the current file position
635
-
636
- if (!$error)
637
- { if (!$gzipmode)
638
- $foffset = ftell($file);
639
- else
640
- $foffset = gztell($file);
641
- if (!$foffset)
642
- { echo ("<p class=\"error\">UNEXPECTED: Can't read the file pointer offset</p>\n");
643
- $error=true;
644
- }
645
- }
646
-
647
- // Print statistics
648
-
649
- skin_open();
650
-
651
- // echo ("<p class=\"centr\"><b>Statistics</b></p>\n");
652
-
653
- if (!$error)
654
- {
655
- $lines_this = $linenumber-$_REQUEST["start"];
656
- $lines_done = $linenumber-1;
657
- $lines_togo = ' ? ';
658
- $lines_tota = ' ? ';
659
-
660
- $queries_this = $queries;
661
- $queries_done = $totalqueries;
662
- $queries_togo = ' ? ';
663
- $queries_tota = ' ? ';
664
-
665
- $bytes_this = $foffset-$_REQUEST["foffset"];
666
- $bytes_done = $foffset;
667
- $kbytes_this = round($bytes_this/1024,2);
668
- $kbytes_done = round($bytes_done/1024,2);
669
- $mbytes_this = round($kbytes_this/1024,2);
670
- $mbytes_done = round($kbytes_done/1024,2);
671
-
672
- if (!$gzipmode)
673
- {
674
- $bytes_togo = $filesize-$foffset;
675
- $bytes_tota = $filesize;
676
- $kbytes_togo = round($bytes_togo/1024,2);
677
- $kbytes_tota = round($bytes_tota/1024,2);
678
- $mbytes_togo = round($kbytes_togo/1024,2);
679
- $mbytes_tota = round($kbytes_tota/1024,2);
680
-
681
- $pct_this = ceil($bytes_this/$filesize*100);
682
- $pct_done = ceil($foffset/$filesize*100);
683
- $pct_togo = 100 - $pct_done;
684
- $pct_tota = 100;
685
-
686
- if ($bytes_togo==0)
687
- { $lines_togo = '0';
688
- $lines_tota = $linenumber-1;
689
- $queries_togo = '0';
690
- $queries_tota = $totalqueries;
691
- }
692
-
693
- $pct_bar = "<div style=\"height:15px;width:$pct_done%;background-color:#000080;margin:0px;\"></div>";
694
- }
695
- else
696
- {
697
- $bytes_togo = ' ? ';
698
- $bytes_tota = ' ? ';
699
- $kbytes_togo = ' ? ';
700
- $kbytes_tota = ' ? ';
701
- $mbytes_togo = ' ? ';
702
- $mbytes_tota = ' ? ';
703
-
704
- $pct_this = ' ? ';
705
- $pct_done = ' ? ';
706
- $pct_togo = ' ? ';
707
- $pct_tota = 100;
708
- $pct_bar = str_replace(' ','&nbsp;','<tt>[ Not available for gzipped files ]</tt>');
709
- }
710
-
711
- echo ("
712
- <center>
713
- <table width=\"520\" border=\"0\" cellpadding=\"3\" cellspacing=\"1\">
714
- <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>
715
- <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>
716
- <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>
717
- <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>
718
- <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>
719
- <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>
720
- <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>
721
- <tr><th class=\"bg4\">% bar</th><td class=\"bgpctbar\" colspan=\"4\">$pct_bar</td></tr>
722
- </table>
723
- </center>
724
- \n");
725
-
726
- // Finish message and restart the script
727
-
728
- if ($linenumber<$_REQUEST["start"]+$linespersession)
729
- { echo ("<p class=\"successcentr\">Congratulations: End of file reached, assuming OK</p>\n");
730
- 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");
731
- 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");
732
- $error=true;
733
- }
734
- else
735
- { if ($delaypersession!=0)
736
- echo ("<p class=\"centr\">Now I'm <b>waiting $delaypersession milliseconds</b> before starting next session...</p>\n");
737
- if (!$ajax)
738
- 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");
739
- echo ("<noscript>\n");
740
- echo ("<p class=\"centr\"><a href=\"".$_SERVER["PHP_SELF"]."?start=$linenumber&amp;fn=".$_REQUEST["fn"]."&amp;foffset=$foffset&amp;totalqueries=$totalqueries\">Continue from the line $linenumber</a> (Enable JavaScript to do it automatically)</p>\n");
741
- echo ("</noscript>\n");
742
-
743
- echo ("<p class=\"centr\">Press <b><a href=\"".$_SERVER["PHP_SELF"]."\">STOP</a></b> to abort the import <b>OR WAIT!</b></p>\n");
744
- }
745
- }
746
- else
747
- echo ("<p class=\"error\">Stopped on error</p>\n");
748
-
749
- skin_close();
750
-
751
- }
752
-
753
- if ($error)
754
- echo ("<p class=\"centr\"><a href=\"".$_SERVER["PHP_SELF"]."\">Start from the beginning</a> (DROP the old tables before restarting)</p>\n");
755
-
756
- if ($dbconnection) mysql_close();
757
- if ($file && !$gzipmode) fclose($file);
758
- else if ($file && $gzipmode) gzclose($file);
759
-
760
- ?>
761
-
762
- <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>
763
-
764
- </td></tr></table>
765
-
766
- </center>
767
-
768
- </body>
769
- </html>
770
-
771
- <?php
772
-
773
- // *******************************************************************************************
774
- // AJAX functionality starts here
775
- // *******************************************************************************************
776
-
777
- // Handle special situations (errors, and finish)
778
-
779
- if ($error)
780
- {
781
- $out1 = ob_get_contents();
782
- ob_end_clean();
783
- echo $out1;
784
- die;
785
- }
786
-
787
- // Creates responses (XML only or web page)
788
-
789
- if (($ajax) && isset($_REQUEST['start']))
790
- {
791
- if (isset($_REQUEST['ajaxrequest']))
792
- { ob_end_clean();
793
- create_xml_response();
794
- die;
795
- }
796
- else
797
- {
798
- create_ajax_script();
799
- }
800
- }
801
- ob_flush();
802
-
803
- // *******************************************************************************************
804
- // AJAX utilities
805
- // *******************************************************************************************
806
-
807
- function create_xml_response()
808
- {
809
- global $linenumber, $foffset, $totalqueries,
810
- $lines_this, $lines_done, $lines_togo, $lines_tota,
811
- $queries_this, $queries_done, $queries_togo, $queries_tota,
812
- $bytes_this, $bytes_done, $bytes_togo, $bytes_tota,
813
- $kbytes_this, $kbytes_done, $kbytes_togo, $kbytes_tota,
814
- $mbytes_this, $mbytes_done, $mbytes_togo, $mbytes_tota,
815
- $pct_this, $pct_done, $pct_togo, $pct_tota,$pct_bar;
816
- //echo "Content-type: application/xml; charset='iso-8859-1'";
817
- header('Content-Type: application/xml');
818
- header('Cache-Control: no-cache');
819
- /*
820
- echo '<?xml version="1.0"?>'."\n";
821
- echo '<root>'."\n";
822
- echo 'cos'."\n";
823
- echo '</root>'."\n";
824
- */
825
-
826
- echo '<?xml version="1.0" encoding="ISO-8859-1"?>';
827
- echo "<root>";
828
- // data - for calculations
829
- echo "<linenumber>";
830
- echo "$linenumber";
831
- echo "</linenumber>";
832
- echo "<foffset>";
833
- echo "$foffset";
834
- echo "</foffset>";
835
- echo "<fn>";
836
- echo '"'.$_REQUEST['fn'].'"';
837
- echo "</fn>";
838
- echo "<totalqueries>";
839
- echo "$totalqueries";
840
- echo "</totalqueries>";
841
- // results - for form update
842
- echo "<elem1>";
843
- echo "$lines_this";
844
- echo "</elem1>";
845
- echo "<elem2>";
846
- echo "$lines_done";
847
- echo "</elem2>";
848
- echo "<elem3>";
849
- echo "$lines_togo";
850
- echo "</elem3>";
851
- echo "<elem4>";
852
- echo "$lines_tota";
853
- echo "</elem4>";
854
-
855
- echo "<elem5>";
856
- echo "$queries_this";
857
- echo "</elem5>";
858
- echo "<elem6>";
859
- echo "$queries_done";
860
- echo "</elem6>";
861
- echo "<elem7>";
862
- echo "$queries_togo";
863
- echo "</elem7>";
864
- echo "<elem8>";
865
- echo "$queries_tota";
866
- echo "</elem8>";
867
-
868
- echo "<elem9>";
869
- echo "$bytes_this";
870
- echo "</elem9>";
871
- echo "<elem10>";
872
- echo "$bytes_done";
873
- echo "</elem10>";
874
- echo "<elem11>";
875
- echo "$bytes_togo";
876
- echo "</elem11>";
877
- echo "<elem12>";
878
- echo "$bytes_tota";
879
- echo "</elem12>";
880
-
881
- echo "<elem13>";
882
- echo "$kbytes_this";
883
- echo "</elem13>";
884
- echo "<elem14>";
885
- echo "$kbytes_done";
886
- echo "</elem14>";
887
- echo "<elem15>";
888
- echo "$kbytes_togo";
889
- echo "</elem15>";
890
- echo "<elem16>";
891
- echo "$kbytes_tota";
892
- echo "</elem16>";
893
-
894
- echo "<elem17>";
895
- echo "$mbytes_this";
896
- echo "</elem17>";
897
- echo "<elem18>";
898
- echo "$mbytes_done";
899
- echo "</elem18>";
900
- echo "<elem19>";
901
- echo "$mbytes_togo";
902
- echo "</elem19>";
903
- echo "<elem20>";
904
- echo "$mbytes_tota";
905
- echo "</elem20>";
906
-
907
- echo "<elem21>";
908
- echo "$pct_this";
909
- echo "</elem21>";
910
- echo "<elem22>";
911
- echo "$pct_done";
912
- echo "</elem22>";
913
- echo "<elem23>";
914
- echo "$pct_togo";
915
- echo "</elem23>";
916
- echo "<elem24>";
917
- echo "$pct_tota";
918
- echo "</elem24>";
919
-
920
- // converting html to normal text
921
- $pct_bar = htmlentities($pct_bar);
922
- echo "<elem_bar>";
923
- echo "$pct_bar";
924
- echo "</elem_bar>";
925
-
926
- echo "</root>";
927
-
928
- }
929
-
930
- function create_ajax_script()
931
- {
932
- global $linenumber, $foffset, $totalqueries, $delaypersession;
933
- ?>
934
- <script type="text/javascript" language="javascript">
935
-
936
- // creates next action url (upload page, or XML response)
937
- function get_url(linenumber,fn,foffset,totalqueries) {
938
- return "<?php echo $_SERVER['PHP_SELF'] ?>"+
939
- "?start="+linenumber+"&fn="+fn+"&foffset="+
940
- foffset+"&totalqueries="+totalqueries+"&ajaxrequest=true";
941
- }
942
-
943
- // extracts text from XML element (itemname must be unique)
944
- function get_xml_data(itemname,xmld) {
945
- return xmld.getElementsByTagName(itemname).item(0).firstChild.data;
946
- }
947
-
948
- // action url (upload page)
949
- var url_request = get_url(<?php echo $linenumber.',"'.$_REQUEST["fn"].'",'.$foffset.','.$totalqueries;?>);
950
- var http_request = false;
951
-
952
- function makeRequest(url) {
953
- http_request = false;
954
- if (window.XMLHttpRequest) {
955
- // Mozilla,...
956
- http_request = new XMLHttpRequest();
957
- if (http_request.overrideMimeType) {
958
- http_request.overrideMimeType("text/xml");
959
- }
960
- } else if (window.ActiveXObject) {
961
- // IE
962
- try {
963
- http_request = new ActiveXObject("Msxml2.XMLHTTP");
964
- } catch(e) {
965
- try {
966
- http_request = new ActiveXObject("Microsoft.XMLHTTP");
967
- } catch(e) {}
968
- }
969
- }
970
- if (!http_request) {
971
- alert("Cannot create an XMLHTTP instance");
972
- return false;
973
- }
974
- http_request.onreadystatechange = server_response;
975
- http_request.open("GET", url, true);
976
- http_request.send(null);
977
- }
978
-
979
- function server_response()
980
- {
981
-
982
- // waiting for correct response
983
- if (http_request.readyState != 4)
984
- return;
985
- if (http_request.status != 200) {
986
- alert("Page unavailable, or wrong url!")
987
- return;
988
- }
989
-
990
- // r = xml response
991
- var r = http_request.responseXML;
992
-
993
- //if received not XML but HTML with new page to show
994
- if (r.getElementsByTagName('root').length == 0) { //*
995
- var text = http_request.responseText;
996
- document.open();
997
- document.write(text);
998
- document.close();
999
- return;
1000
- }
1001
-
1002
- // update "Starting from line: "
1003
- document.getElementsByTagName('p').item(1).innerHTML =
1004
- "Starting from line: " +
1005
- r.getElementsByTagName('linenumber').item(0).firstChild.nodeValue;
1006
-
1007
- // update table with new values
1008
- for(i = 1; i <= 24; i++) {
1009
- document.getElementsByTagName('td').item(i).firstChild.data =
1010
- get_xml_data('elem'+i,r);
1011
- }
1012
-
1013
- // update color bar
1014
- document.getElementsByTagName('td').item(25).innerHTML =
1015
- r.getElementsByTagName('elem_bar').item(0).firstChild.nodeValue;
1016
-
1017
- // action url (XML response)
1018
- url_request = get_url(
1019
- get_xml_data('linenumber',r),
1020
- get_xml_data('fn',r),
1021
- get_xml_data('foffset',r),
1022
- get_xml_data('totalqueries',r));
1023
-
1024
- // ask for XML response
1025
- window.setTimeout("makeRequest(url_request)",500+<?php echo $delaypersession; ?>);
1026
- }
1027
- // ask for upload page
1028
- window.setTimeout("makeRequest(url_request)",500+<?php echo $delaypersession; ?>);
1029
- </script>
1030
- <?php
1031
- }
1032
-
1033
- ?>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
bkpwp-classes/interface.php DELETED
@@ -1,49 +0,0 @@
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 DELETED
@@ -1,1114 +0,0 @@
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
- $p=explode(":",$line);
33
- $values['runby'] = $p[1];
34
- }
35
- }
36
- }
37
- return $values;
38
- }
39
- if(file_exists($backuplog)) {
40
- $lines = file($backuplog);
41
- foreach($lines as $line_num => $line) {
42
- $ret .= __("Line","bkpwp")."# ".sprintf("%02d",$line_num)." ".$line."<br />";
43
- }
44
- } else {
45
- $ret = __("BackUpWordPress Logfile does not exist:","bkpwp")." ".$backuplog;
46
- }
47
- return $ret;
48
- }
49
-
50
- function bkpwp_get_backup_row($f,$alternate) {
51
- $backup->options = new BKPWP_OPTIONS();
52
- $info = new BKPWP_BACKUP_ARCHIVE();
53
- $info = $info->bkpwp_view_backup_info(base64_encode($f['file']),1);
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
- <td>
65
- <?php
66
- echo " <b>".$type."</b>";
67
- if (!empty($info['runby'])) {
68
- echo " - ".$info['runby'];
69
- }
70
- ?>
71
- </td>
72
- <?php if (!$backup->options->bkpwp_easy_mode()) { ?>
73
- <td>
74
- <?php
75
- echo " <b>".$info['preset']."</b>";
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&amp;bkpwp_download=".base64_encode($f['file'])."\">".__("download","bkpwp")."</a>";
87
- ?>
88
- </td>
89
- <td style="text-align: center;">
90
- <?php if (!empty($info['preset'])) { ?>
91
- <?php if (!$backup->options->bkpwp_easy_mode()) { ?>
92
- <?php
93
- echo " <a href=\"javascript:void(0)\"
94
- onclick=\"bkpwp_js_loading('".__("View Backup Information","bkpwp")."');
95
- ajax = new Ajax.Updater(
96
- 'bkpwp_action_buffer', // DIV id must be declared before the method was called
97
- '".get_bloginfo("wpurl")."/wp-admin/admin.php?page=backupwordpress/backupwordpress.php"."',
98
- {
99
- method:'post',
100
- postBody:'bkpwp_view_backup=".base64_encode($f['file'])."'
101
- });\">".__("view","bkpwp")."</a>";
102
- ?>
103
- </td>
104
- <td style="text-align: center;">
105
- <?php
106
- echo " <a href=\"admin.php?page=backupwordpress/backupwordpress.php&amp;bkpwp_mail=".base64_encode($f['file'])."\">".__("mail","bkpwp")."</a>";
107
- ?>
108
- </td>
109
- <?php } ?>
110
- <td style="text-align: center;">
111
- <?php
112
- echo " <a href=\"admin.php?page=backupwordpress/backupwordpress.php&amp;bkpwp_restore=".base64_encode($f['file'])."\">".__("restore","bkpwp")."</a>";
113
- ?>
114
- </td>
115
- <?php if (!$backup->options->bkpwp_easy_mode()) { ?>
116
- <td style="text-align: center;">
117
- <?php
118
- echo " <a href=\"admin.php?page=backupwordpress/backupwordpress.php&amp;bkpwp_delete=".base64_encode($f['file'])."\">".__("delete","bkpwp")."</a>";
119
- ?>
120
- </td>
121
- <?php } ?>
122
- <?php } else { ?>
123
- <?php echo "".__("Your Backup is being processed.","bkpwp").""; ?>
124
- <?php } ?>
125
- <?php
126
- if ($alternate != "new_row") {
127
- ?>
128
- </tr>
129
- <?php
130
- }
131
- }
132
-
133
- }
134
-
135
- class BKPWP_BACKUP {
136
-
137
- function BKPWP_BACKUP() {
138
- }
139
-
140
- function bkpwp_backquote($a_name)
141
- {
142
- /*
143
- Add backquotes to tables and db-names in
144
- SQL queries. Taken from phpMyAdmin.
145
- */
146
- if (!empty($a_name) && $a_name != '*') {
147
- if (is_array($a_name)) {
148
- $result = array();
149
- reset($a_name);
150
- while(list($key, $val) = each($a_name)) {
151
- $result[$key] = '`' . $val . '`';
152
- }
153
- return $result;
154
- } else {
155
- return '`' . $a_name . '`';
156
- }
157
- } else {
158
- return $a_name;
159
- }
160
- } // function backquote($a_name, $do_it = TRUE)
161
-
162
- function bkpwp_make_sql($path,$sql_file,$table,$status,$log)
163
- {
164
- /*
165
- Reads the Database table in $table and creates
166
- SQL Statements for recreating structure and data
167
- Taken partially from phpMyAdmin and partially from
168
- Alain Wolf, Zurich - Switzerland
169
- Website: http://restkultur.ch/personal/wolf/scripts/db_backup/
170
- */
171
-
172
- $sql_file = "";
173
-
174
- // Add SQL statement to drop existing table
175
- $sql_file .= "\n";
176
- $sql_file .= "\n";
177
- $sql_file .= "#\n";
178
- $sql_file .= "# Delete any existing table " . $this->bkpwp_backquote($table) . "\n";
179
- $sql_file .= "#\n";
180
- $sql_file .= "\n";
181
- $sql_file .= "DROP TABLE IF EXISTS " . $this->bkpwp_backquote($table) . ";\n";
182
-
183
- // Table structure
184
-
185
- // Comment in SQL-file
186
- $sql_file .= "\n";
187
- $sql_file .= "\n";
188
- $sql_file .= "#\n";
189
- $sql_file .= "# Table structure of table " . $this->bkpwp_backquote($table) . "\n";
190
- $sql_file .= "#\n";
191
- $sql_file .= "\n";
192
-
193
- // Get table structure
194
- $query = "SHOW CREATE TABLE " . $this->bkpwp_backquote($table);
195
- $result = mysql_query($query, $GLOBALS["db_connect"]);
196
- if ($result == FALSE) {
197
- $log['logfile'][] = $this->bkpwp_logtimestamp().": ".__("Error getting table structure of ","bkpwp").$table."! ".mysql_errno() . ": " . mysql_error()." ".$this->bkpwp_logtimestamp();
198
- $this->bkpwp_write_log($log); unset($log['logfile']);
199
- } else {
200
- if (mysql_num_rows($result) > 0) {
201
- $sql_create_arr = mysql_fetch_array($result);
202
- $sql_file .= $sql_create_arr[1];
203
- }
204
- mysql_free_result($result);
205
- $sql_file .= " ;";
206
- } // ($result == FALSE)
207
-
208
- // Table data contents
209
-
210
- // Get table contents
211
- $query = "SELECT * FROM " . $this->bkpwp_backquote($table);
212
- $result = mysql_query($query, $GLOBALS["db_connect"]);
213
- if ($result == FALSE) {
214
- $log['logfile'][] = $this->bkpwp_logtimestamp().": ".__("Error getting records of ","bkpwp").$table."! ".mysql_errno() . ": " . mysql_error()." ".$this->bkpwp_logtimestamp();
215
- $this->bkpwp_write_log($log); unset($log['logfile']);
216
- } else {
217
- $fields_cnt = mysql_num_fields($result);
218
- $rows_cnt = mysql_num_rows($result);
219
- } // if ($result == FALSE)
220
-
221
- // Comment in SQL-file
222
- $sql_file .= "\n";
223
- $sql_file .= "\n";
224
- $sql_file .= "#\n";
225
- $sql_file .= "# Data contents of table " . $table . " (" . $rows_cnt . " records)\n";
226
- $sql_file .= "#\n";
227
-
228
- // Checks whether the field is an integer or not
229
- for ($j = 0; $j < $fields_cnt; $j++) {
230
- $field_set[$j] = $this->bkpwp_backquote(mysql_field_name($result, $j));
231
- $type = mysql_field_type($result, $j);
232
- if ($type == 'tinyint' || $type == 'smallint' || $type == 'mediumint' || $type == 'int' ||
233
- $type == 'bigint' ||$type == 'timestamp') {
234
- $field_num[$j] = TRUE;
235
- } else {
236
- $field_num[$j] = FALSE;
237
- }
238
- } // end for
239
-
240
- // Sets the scheme
241
- $entries = 'INSERT INTO ' . $this->bkpwp_backquote($table) . ' VALUES (';
242
- $search = array("\x00", "\x0a", "\x0d", "\x1a"); //\x08\\x09, not required
243
- $replace = array('\0', '\n', '\r', '\Z');
244
- $current_row = 0;
245
- $batch_write = 0;
246
- while ($row = mysql_fetch_row($result)) {
247
- $current_row++;
248
-
249
- //test
250
- // if (empty($status) && ($table == "crawlt_ip_data") && ($current_row == 287)) {
251
- // sleep(200);
252
- // }
253
-
254
- // if we have to continue an unfinished backup
255
- if (!empty($status) && empty($continue_backup)) {
256
- $statusarr = get_option("bkpwp_status");
257
- if ($statusarr['type'] == "sqltable_row") {
258
- if ($statusarr['point'] == $table."-".$current_row) {
259
- $continue_backup = 1;
260
- continue;
261
- } else {
262
- continue;
263
- }
264
- }
265
- }
266
-
267
- // build the statement
268
- for ($j = 0; $j < $fields_cnt; $j++) {
269
- if (!isset($row[$j])) {
270
- $values[] = 'NULL';
271
- } else if ($row[$j] == '0' || $row[$j] != '') {
272
- // a number
273
- if ($field_num[$j]) {
274
- $values[] = $row[$j];
275
- }
276
- else {
277
- $values[] = "'" . str_replace($search, $replace, $this->bkpwp_sql_addslashes($row[$j])) . "'";
278
- } //if ($field_num[$j])
279
- } else {
280
- $values[] = "''";
281
- } // if (!isset($row[$j]))
282
- } // for ($j = 0; $j < $fields_cnt; $j++)
283
- $sql_file .= " \n" . $entries . implode(', ', $values) . ') ;';
284
-
285
-
286
- // write the rows in batches of 100
287
- if ($batch_write == 100) {
288
- $batch_write = 0;
289
- $this->bkpwp_write_sql($path,$sql_file);
290
- $sql_file = "";
291
- $name = str_replace(get_option("bkpwppath")."/","",$path);
292
- $this->bkpwp_set_status($name,'sqltable_row',$table."-".$current_row);
293
- unset($status);
294
- }
295
- $batch_write++;
296
-
297
- unset($values);
298
- } // while ($row = mysql_fetch_row($result))
299
- mysql_free_result($result);
300
-
301
- // Create footer/closing comment in SQL-file
302
- $sql_file .= "\n";
303
- $sql_file .= "#\n";
304
- $sql_file .= "# End of data contents of table " . $table . "\n";
305
- $sql_file .= "# --------------------------------------------------------\n";
306
- $sql_file .= "\n";
307
-
308
- if (empty($status) || !empty($continue_backup)) {
309
- $this->bkpwp_write_sql($path,$sql_file);
310
- $sql_file = "";
311
- $name = str_replace(get_option("bkpwppath")."/","",$path);
312
- $this->bkpwp_set_status($name,'sqltable',$table);
313
- }
314
- } //function make_sql($table)
315
-
316
- function bkpwp_sql_addslashes($a_string = '', $is_like = FALSE)
317
- {
318
- /*
319
- Better addslashes for SQL queries.
320
- Taken from phpMyAdmin.
321
- */
322
- if ($is_like) {
323
- $a_string = str_replace('\\', '\\\\\\\\', $a_string);
324
- } else {
325
- $a_string = str_replace('\\', '\\\\', $a_string);
326
- }
327
- $a_string = str_replace('\'', '\\\'', $a_string);
328
-
329
- return $a_string;
330
- } // function sql_addslashes($a_string = '', $is_like = FALSE)
331
-
332
- function bkpwp_mysql($path,$status="",$log) {
333
- if (!$GLOBALS['db_connect'] = @mysql_pconnect(DB_HOST, DB_USER, DB_PASSWORD)) {
334
- $log['logfile'][] = $this->bkpwp_logtimestamp().": ".__("Could not connect to MySQL server! ","bkpwp"). mysql_error()." ".$this->bkpwp_logtimestamp();
335
- $this->bkpwp_write_log($log); unset($log['logfile']);
336
- }
337
- $log['logfile'][] = $this->bkpwp_logtimestamp().": ".__("MySQL server connected successfully ","bkpwp")." ".$this->bkpwp_logtimestamp();
338
- $this->bkpwp_write_log($log); unset($log['logfile']);
339
- mysql_select_db(DB_NAME,$GLOBALS['db_connect']);
340
-
341
- //Begin new backup of MySql
342
- $tables = mysql_list_tables(DB_NAME);
343
- if (!isset($tables) > 0) {
344
- $log['logfile'][] = $this->bkpwp_logtimestamp().": ".__("Could not select db ","bkpwp").DB_NAME." ".$this->bkpwp_logtimestamp();
345
- $this->bkpwp_write_log($log); unset($log['logfile']);
346
- }
347
- $sql_file = "# WordPress : ".get_bloginfo("url")." MySQL database backup\n";
348
- $sql_file .= "#\n";
349
- $sql_file .= "# Generated: " . date("l j. F Y H:i T") . "\n";
350
- $sql_file .= "# Hostname: " . DB_HOST . "\n";
351
- $sql_file .= "# Database: " . $this->bkpwp_backquote(DB_NAME) . "\n";
352
- $sql_file .= "# --------------------------------------------------------\n";
353
- if (empty($status)) {
354
- $this->bkpwp_write_sql($path,$sql_file);
355
- $sql_file = "";
356
- }
357
- for ($i = 0; $i < mysql_num_rows($tables); $i++) {
358
- $curr_table = mysql_tablename($tables, $i);
359
- if (!empty($status) && empty($continue_backup)) {
360
- $statusarr = get_option("bkpwp_status");
361
- if ($statusarr['type'] == "sqltable_row") {
362
- $continue_backup = 1;
363
- } elseif ($statusarr['point'] == $curr_table) {
364
- $continue_backup = 1;
365
- continue;
366
- } else {
367
- continue;
368
- }
369
- }
370
- // Increase script execution time-limit to 15 min for every table.
371
- if ( !ini_get('safe_mode')) @set_time_limit(15*60);
372
- // Create the SQL statements
373
- $sql_file .= "# --------------------------------------------------------\n";
374
- $sql_file .= "# Table: " . $this->bkpwp_backquote($curr_table) . "\n";
375
- $sql_file .= "# --------------------------------------------------------\n";
376
- $this->bkpwp_make_sql($path,$sql_file,$curr_table,$status,$log);
377
-
378
- $log['logfile'][] = $this->bkpwp_logtimestamp().": sql-dump for ".$curr_table." created ".$this->bkpwp_logtimestamp();
379
- $this->bkpwp_write_log($log); unset($log['logfile']);
380
- }
381
- }
382
-
383
- function bkpwp_calculate($preset) {
384
- $sql = 'SHOW TABLE STATUS FROM ' . DB_NAME;
385
- $res = @$GLOBALS['wpdb']->get_results($sql, ARRAY_A);
386
- $sum_free = 0;
387
- $sum_data = 0;
388
- foreach($res as $r) {
389
- $sum_free = $sum_free + $r['Data_free'];
390
- $sum_data = $sum_data + $r['Data_length'];
391
- }
392
- $ret = "<p>";
393
- $ret .= __("Your Database holds.","bkpwp")." "
394
- .bkpwp_size_readable($sum_data)." "
395
- .__("of Data","dprx_opt").".<br />";
396
-
397
-
398
- if ($preset['bkpwp_preset_options']['bkpwp_sql_only'] == 1) {
399
- $ret .= __("The resulting Backup Archive will be about","dprx_opt")." <b> ".bkpwp_size_readable(($sum_data/2.5))."</b>.</p>";
400
- $ret .= "<p>".__("Database Only Backup with this Preset. No Disk Files will be backed up.","bkpwp")."</p>";
401
- return $ret;
402
- }
403
-
404
- $options = new BKPWP_OPTIONS();
405
- clearstatcache(); //get rid of cached filesizes...
406
- $dir = bkpwp_conform_dir(ABSPATH);
407
- $options->excludelist = $preset['bkpwp_preset_options']['bkpwp_excludelist'];
408
- $files = $options->bkpwp_ls($dir);
409
- $filesize = 0;
410
- foreach($files as $f) {
411
- $str = bkpwp_conform_dir($f,true);
412
- $thisf = filesize($f);
413
- $filesize = $filesize+$thisf;
414
- //echo $str.": ".bkpwp_size_readable($thisf)." (".bkpwp_size_readable($filesize).")\\n";
415
- }
416
- update_option("bkpwp_calculation",bkpwp_size_readable($filesize));
417
- $ret .= __("Your Wordpress files in this backup use","bkpwp")." ";
418
- $ret .= bkpwp_size_readable($filesize)." ".__("of disk space.","bkpwp")."<br />";
419
- $ret .= "".__("Your Backup Archive filesize saved with preset","bkpwp")." <b>".$preset['bkpwp_preset_name']."</b> ".__("will be about","bkpwp")." <b>".bkpwp_size_readable((($sum_data+$filesize)/1.9))."</b>.</p>";
420
- return $ret;
421
- }
422
-
423
- function bkpwp_logtimestamp() {
424
- return date(get_option('date_format'))." ".date("H:i:s");
425
- }
426
-
427
- function bkpwp_set_status($name,$type,$point) {
428
- $new_backup_status = array("name" => $name, "time" => time(), "type" => $type, "point" => $point);
429
- update_option("bkpwp_status",$new_backup_status);
430
- }
431
-
432
- function bkpwp_do_backup($preset,$status="") {
433
- $options = new BKPWP_OPTIONS();
434
- $presets = new BKPWP_MANAGE();
435
- $log = array();
436
- // get the desired archive type from preset
437
- if (!empty($status)) {
438
- $preset = get_option("bkpwp_status_config");
439
- }
440
-
441
- // load the full backup preset if none is set
442
- if (empty($preset)) {
443
- $preset = $presets->bkpwp_get_preset("full backup");
444
- }
445
-
446
- $type = $preset['bkpwp_preset_options']['bkpwp_archive_type'];
447
- $sqlonly = $preset['bkpwp_preset_options']['bkpwp_sql_only'];
448
- $options->excludelist = $preset['bkpwp_preset_options']['bkpwp_excludelist'];
449
- update_option("bkpwp_status_config",$preset);
450
-
451
- $datestamp = date("Y-m-d-H-i-s");
452
- // or: load the name of the unfinished backup's temporary directory
453
- if (!empty($status)) {
454
- $datestamp = $status;
455
- if (!is_dir(get_option("bkpwppath")."/".$datestamp)) {
456
- return;
457
- }
458
- }
459
- // temporary directory name
460
- $backup_tmp_dir = get_option("bkpwppath")."/".$datestamp;
461
-
462
- // filename for the backup archive
463
- if ($sqlonly == 1) {
464
- $backup_filename .= "-sql";
465
- } else {
466
- $backup_filename .= "-full";
467
- }
468
-
469
- $backup_filename .= ".".$type;
470
- $backup_filename_short = $datestamp.$backup_filename;
471
- $backup_filename = $backup_tmp_dir.$backup_filename;
472
- $log['filename'] = $backup_filename_short;
473
- $log['logfile'] = array();
474
- $log['preset'] = $preset['bkpwp_preset_name'];
475
- $log['schedule'] = $preset['bkpwp_schedule'];
476
- if ($preset['bkpwp_schedule'] != __("manually","bkpwp")) {
477
- $preset['bkpwp_preset_options']['bkpwp_lastrun'] = time();
478
- $presets->bkpwp_update_preset($preset);
479
- }
480
- $time_start = microtime(true);
481
-
482
- // count milliseconds
483
- $log['logfile'][] = $this->bkpwp_logtimestamp().": ".__("BackUpWordPress starting at","bkpwp")." ".$this->bkpwp_logtimestamp();
484
- $log['logfile'][] = $this->bkpwp_logtimestamp().": ".__("BackUpWordPress using Preset","bkpwp")." ".$log['preset'];
485
-
486
- // create a temporary directory
487
- if (!is_dir($backup_tmp_dir)) {
488
- if (!mkdir($backup_tmp_dir,0777)) {
489
- $log['logfile'][] = $this->bkpwp_logtimestamp().": ".__("BackUpWordPress temporary Directory","bkpwp")." '".$backup_tmp_dir."' ".__("could not be created","bkpwp");
490
- } else {
491
- $log['logfile'][] = $this->bkpwp_logtimestamp().": ".__("BackUpWordPress temporary Directory","bkpwp")." '".$backup_tmp_dir."' ".__("created","bkpwp");
492
- }
493
- } else {
494
- $log['logfile'][] = $this->bkpwp_logtimestamp().": ".__("BackUpWordPress temporary Directory","bkpwp")." '".$backup_tmp_dir."' ".__("exists. Proceeding with unfinished backup.","bkpwp");
495
- }
496
- $this->bkpwp_write_log($log); unset($log['logfile']);
497
-
498
- if ($sqlonly != 1) {
499
- // subdirectory of wordpress files
500
- $wordpress_files = $backup_tmp_dir."/wordpress_files";
501
- if (!is_dir($wordpress_files)) {
502
- if (!mkdir($wordpress_files,0777)) {
503
- $log['logfile'][] = $this->bkpwp_logtimestamp().": ".__("BackUpWordPress temporary Directory","bkpwp")." '".$wordpress_files."' ".__("could not be created","bkpwp");
504
- } else {
505
- $log['logfile'][] = $this->bkpwp_logtimestamp().": ".__("BackUpWordPress temporary Directory","bkpwp")." '".$wordpress_files."' ".__("created","bkpwp");
506
- }
507
- $this->bkpwp_write_log($log); unset($log['logfile']);
508
- }
509
- }
510
-
511
- $this->bkpwp_mysql($backup_tmp_dir,$status,$log);
512
-
513
- if(!file_exists($backup_tmp_dir."/wordpress.sql")) {
514
- $log['logfile'][] = $this->bkpwp_logtimestamp().": ".__("SQL Dump could not be created.","bkpwp");
515
- } else {
516
- $log['logfile'][] = $this->bkpwp_logtimestamp().": ".__("SQL Dump created.","bkpwp");
517
- }
518
- $this->bkpwp_write_log($log); unset($log['logfile']);
519
- if ($sqlonly != 1) {
520
- // create a temporary directory of files to backup
521
- $dir = bkpwp_conform_dir(ABSPATH);
522
- $files = $options->bkpwp_ls($dir);
523
- $files_copied = 0;
524
- $batch = 0;
525
- $subdirs_created = 0;
526
- $i=1; // the sql at least
527
- foreach ($files as $f) {
528
- if (is_dir($f)) {
529
- if (!mkdir($wordpress_files.bkpwp_conform_dir($f, true),0777)) {
530
- if (!is_dir($wordpress_files.bkpwp_conform_dir($f, true))) {
531
- $log['logfile'][] = $this->bkpwp_logtimestamp().": ".__("Failed to make directory","bkpwp").": ".$f;
532
- }
533
- } else {
534
- $subdirs_created++;
535
- }
536
- } elseif(file_exists($f)) {
537
- // where did we leave?
538
- if (!empty($status) && empty($continue_backup)) {
539
- $statusarr = get_option("bkpwp_status");
540
- if ($statusarr['point'] == $f) {
541
- $continue_backup = 1;
542
- continue;
543
- } else {
544
- continue;
545
- }
546
- }
547
-
548
- // set a marker ever 100
549
- if ($batch == 100) {
550
- $this->bkpwp_set_status($datestamp,'file',$f);
551
- $batch = 0;
552
- }
553
- $files_copied++;
554
- if (file_exists($wordpress_files.bkpwp_conform_dir($f, true))) {
555
- unlink($wordpress_files.bkpwp_conform_dir($f, true));
556
- }
557
- // now copy...
558
- if (!copy($f,$wordpress_files.bkpwp_conform_dir($f, true))) {
559
- $log['logfile'][] = $this->bkpwp_logtimestamp().": ".__("Failed to copy file","bkpwp").": ".$f;
560
- }
561
- $batch++;
562
- //test
563
- /*
564
- if (empty($status) && ($files_copied == 135)) {
565
- sleep(200);
566
- }
567
- */
568
-
569
- }
570
- $i++;
571
- }
572
- $log['logfile'][] = $this->bkpwp_logtimestamp().": ".$subdirs_created." ".__("Temporary Subdirectories copied sucessfully","bkpwp");
573
- $log['logfile'][] = $this->bkpwp_logtimestamp().": ".$files_copied." ".__("Temporary Files copied sucessfully","bkpwp");
574
- }
575
- // create backup archive file
576
- $archive_backup = new File_Archive();
577
- $archive_backup->setOption("tmpDirectory",get_option("bkpwppath"));
578
- $archive_backup->extract($backup_tmp_dir,File_Archive::toArchive($backup_filename, File_Archive::toFiles()));
579
- if (!chmod($backup_filename, 0777)) {
580
- $log['logfile'][] = $this->bkpwp_logtimestamp().": ".__("Backup Archive Permissions changed to 0777","bkpwp")." ".$backup_filename;
581
- } else {
582
- $log['logfile'][] = $this->bkpwp_logtimestamp().": ".__("Failed to change backup archive permissions","bkpwp")." ".$backup_filename;
583
- }
584
- if (!file_exists($backup_filename)) {
585
- $log['logfile'][] = $this->bkpwp_logtimestamp().": ".__("Failed to create backup archive","bkpwp")." ".$backup_filename;
586
- } else {
587
- $log['logfile'][] = $this->bkpwp_logtimestamp().": ".__("Archive File created/compressed successfully:","bkpwp")." ".$backup_filename;
588
- }
589
-
590
- $deleted_files_count = $this->bkpwp_rmdirtree($backup_tmp_dir);
591
- $log['logfile'][] = $this->bkpwp_logtimestamp().": ".count($deleted_files_count)." ".__("Temporary Directories and Files deleted successfully","bkpwp");
592
-
593
- $deleted_oldarchives_count = $this->bkpwp_delete_old();
594
- if ($deleted_oldarchives_count > 0) {
595
- $log['logfile'][] = $this->bkpwp_logtimestamp().": ".$deleted_oldarchives_count." ".__("Old BackUpWordPress Archives deleted successfully","bkpwp");
596
- } else {
597
- $log['logfile'][] = $this->bkpwp_logtimestamp().": ".__("No old BackUpWordPress Archives to delete","bkpwp");
598
- }
599
-
600
- $deleted_oldlogfiles_count = $this->bkpwp_delete_oldlogs();
601
- if ($deleted_oldlogfiles_count > 0) {
602
- $log['logfile'][] = $this->bkpwp_logtimestamp().": ".$deleted_oldlogfiles_count." ".__("Old BackUpWordPress Log Files deleted successfully","bkpwp");
603
- } else {
604
- $log['logfile'][] = $this->bkpwp_logtimestamp().": ".__("No old BackUpWordPress Log Files to delete","bkpwp");
605
- }
606
-
607
-
608
- $time_end = microtime(true);
609
- $time = $time_end - $time_start;
610
- $log['logfile'][] = $this->bkpwp_logtimestamp().": ".__("BackUpWordPress done at","bkpwp")." ".$this->bkpwp_logtimestamp();
611
- $log['logfile'][] = $this->bkpwp_logtimestamp().": ".__("BackUpWordPress was running for","bkpwp")." ".round($time,2)." ".__("Seconds","bkpwp");
612
-
613
- // write the log
614
- $this->bkpwp_write_log($log); unset($log['logfile']);
615
-
616
- // dont need the status anymore
617
- delete_option("bkpwp_status");
618
- delete_option("bkpwp_status_config");
619
-
620
-
621
- $backup = array("file" => $backup_filename,
622
- "filename" => $backup_filename_short);
623
- // start the output
624
- $backuprow = new BKPWP_BACKUP_ARCHIVE();
625
- $out = "<table class=\"widefat\">";
626
- ob_start();
627
- $backuprow->bkpwp_get_backup_row($backup,"new_row");
628
- $out .= ob_get_contents();
629
- ob_end_clean();
630
- $out .= "</table>";
631
-
632
- // mail it if bkpwp_automail is set
633
- $bkpwp_automail = get_option("bkpwp_automail");
634
- $bkpwp_automail_maxsize = get_option("bkpwp_automail_maxsize");
635
- if (!empty($bkpwp_automail)) {
636
- $allowed_bytes = $bkpwp_automail_maxsize*1024*1024;
637
- $logdump = nl2br($this->bkpwp_write_log($log,1));
638
- $logdump .= $allowed_bytes.":".filesize($backup_filename)." - ".$backup_filename."<br />\n";
639
- if ($this->is_readable_for_mailout($backup_filename)) {
640
- $logdump .= "Backup file is readable.<br />\n";
641
- }
642
- if ($allowed_bytes >= filesize($backup_filename)) {
643
- bkpwp_mail_now(base64_encode($backup_filename), $logdump);
644
- } else {
645
- bkpwp_mail_now("", $logdump);
646
- }
647
- }
648
- // send autput
649
- return $out;
650
- }
651
-
652
- function is_readable_for_mailout($file,$count=0) {
653
- if ($count > 24) {
654
- return false;
655
- }
656
- if (!is_readable($file)) {
657
- $count++;
658
- sleep(2);
659
- is_readable_for_mailout($file,$count);
660
- }
661
- return true;
662
- }
663
-
664
- //Since looks like the Windows ACLs bug "wont fix" (see http://bugs.php.net/bug.php?id=27609)
665
- function is__writable($path) {
666
-
667
- if ($path{strlen($path)-1}=='/')
668
- return $this->is__writable($path.uniqid(mt_rand()).'.tmp');
669
-
670
- if (file_exists($path)) {
671
- if (!($f = @fopen($path, 'r+')))
672
- return false;
673
- fclose($f);
674
- return true;
675
- }
676
-
677
- if (!($f = @fopen($path, 'w')))
678
- return false;
679
- fclose($f);
680
- unlink($path);
681
- return true;
682
- }
683
-
684
- function bkpwp_write_sql($sqldir,$sql) {
685
- $sqlname = $sqldir."/wordpress.sql";
686
- // actually write the sql file
687
- if ($this->is__writable($sqlname)) {
688
- if (!$handle = fopen($sqlname, "a")) {
689
- $log['logfile'][] = $this->bkpwp_logtimestamp().": ".__("SQLfile could not be opened for writing: ","bkpwp").$sqlname;
690
- $this->bkpwp_write_log($log); unset($log['logfile']);
691
- return;
692
- }
693
- if (!fwrite($handle, $sql)) {
694
- $log['logfile'][] = $this->bkpwp_logtimestamp().": ".__("SQLfile not writable: ","bkpwp").$sqlname;
695
- $this->bkpwp_write_log($log); unset($log['logfile']);
696
- return;
697
- }
698
- $log['logfile'][] = $this->bkpwp_logtimestamp().": ".__("successfully written to SQLfile: ","bkpwp").$sqlname;
699
- $this->bkpwp_write_log($log); unset($log['logfile']);
700
- fclose($handle);
701
- return true;
702
- } else {
703
- $log['logfile'][] = $this->bkpwp_logtimestamp().": ".__("SQLfile not writable: ","bkpwp").$sqlname;
704
- $this->bkpwp_write_log($log); unset($log['logfile']);
705
- }
706
- }
707
-
708
- function bkpwp_write_log($log,$return="") {
709
- if (!is_array($log)) { return; }
710
- $logdir = get_option("bkpwppath")."/logs";
711
- if (!is_dir($logdir)) {
712
- mkdir($logdir,0777);
713
- }
714
- $logname = $logdir."/".$log['filename'].".txt";
715
- $logfile = "";
716
- if (!file_exists($logname)) {
717
- if (!empty($log['preset'])) {
718
- $logfile .= "Preset: ".$log['preset']."\n";
719
- }
720
- if (!empty($log['schedule'])) {
721
- $logfile .= "Schedule: ".$log['schedule']."\n";
722
- }
723
- // write some environmental information for debuging purposes
724
- $logfile .= "WordPress Version: ".$GLOBALS['wp_version']."\n";
725
- $logfile .= "BackUpWordPress Version: ".BKPWP_VERSION."\n";
726
- }
727
- if (is_array($log['logfile'])) {
728
- foreach($log['logfile'] as $l) {
729
- if (is_array($l)) { $l = serialize($l);}
730
- $logfile .= "## ".$l."\n";
731
- }
732
- if (!empty($return)) {
733
- return $logfile;
734
- }
735
- // actually write the log
736
- if ($this->is__writable($logname)) {
737
- if (!$handle = fopen($logname, "a")) {
738
- return __("Logfile could not be opened for writing: ","bkpwp").$logname;
739
- }
740
- if (!fwrite($handle, $logfile)) {
741
- return __("Logfile not writable: ","bkpwp").$logname;
742
- }
743
- fclose($handle);
744
- return true;
745
- } else {
746
- return __("Logfile not writable: ","bkpwp").$logname;
747
- }
748
- }
749
- }
750
-
751
- function bkpwp_rmdirtree($dirname) {
752
- if (!eregi(bkpwp_conform_dir(ABSPATH),bkpwp_conform_dir($dirname))) {
753
- return;
754
- }
755
- if (is_dir($dirname)) { //Operate on dirs only
756
- $result=array();
757
- if (substr($dirname,-1)!='/') {$dirname.='/';} //Append slash if necessary
758
- $handle = opendir($dirname);
759
- while (false !== ($file = readdir($handle))) {
760
- if ($file!='.' && $file!= '..') { //Ignore . and ..
761
- $path = $dirname.$file;
762
- if (is_dir($path)) { //Recurse if subdir, Delete if file
763
- $result=array_merge($result,$this->bkpwp_rmdirtree($path));
764
- }else{
765
- unlink($path);
766
- $result[].=$path;
767
- }
768
- }
769
- }
770
- closedir($handle);
771
- rmdir($dirname); //Remove dir
772
- $result[] .= $dirname;
773
- return $result; //Return array of deleted items
774
- } else {
775
- return false; //Return false if attempting to operate on a file
776
- }
777
- }
778
-
779
- function bkpwp_delete_old() {
780
- $backups = new BKPWP_MANAGE();
781
- $unlinkcount = 0;
782
- $files = $backups->bkpwp_get_backups();
783
- if (count($files) <= get_option('bkpwp_max_backups')) {
784
- return;
785
- } else {
786
- $i = 1;
787
- foreach($files as $f) {
788
- if ($i > get_option('bkpwp_max_backups')) {
789
- unlink($f['file']);
790
- $unlinkcount++;
791
- }
792
- $i++;
793
- }
794
- }
795
- if ($unlinkcount > 0) {
796
- return $unlinkcount;
797
- }
798
- return false;
799
- }
800
-
801
- function bkpwp_delete_oldlogs() {
802
- $backups = new BKPWP_MANAGE();
803
- $unlinkcount = 0;
804
- $files = $backups->bkpwp_get_logs();
805
- $num = get_option('bkpwp_max_backups')*10;
806
- if (count($files) <= $num) {
807
- return;
808
- } else {
809
- $i = 1;
810
- foreach($files as $f) {
811
- if ($i > $num) {
812
- unlink($f['file']);
813
- $unlinkcount++;
814
- }
815
- $i++;
816
- }
817
- }
818
- if ($unlinkcount > 0) {
819
- return $unlinkcount;
820
- }
821
- return false;
822
- }
823
-
824
- }
825
-
826
- class BKPWP_MANAGE {
827
-
828
- function BKPWP_MANAGE() {
829
- }
830
-
831
- function bkpwp_get_presets() {
832
- $user = $GLOBALS['userdata']->user_login;
833
- if(empty($user)) { $user = "admin"; }
834
- $presets = get_option("bkpwp_presets");
835
- if(!is_array($presets[$user]['bkpwp_presets'])) {
836
- return array();
837
- } else {
838
- return $presets[$user]['bkpwp_presets'];
839
- }
840
- }
841
-
842
- function bkpwp_update_presets($userpresets) {
843
- $presets = get_option("bkpwp_presets");
844
- $user = $GLOBALS['userdata']->user_login;
845
- if(empty($user)) { $user = "admin"; }
846
- $presets[$user]['bkpwp_presets'] = $userpresets;
847
- update_option("bkpwp_presets",$presets);
848
- }
849
-
850
- function bkpwp_load_preset($preset) {
851
- $options = new BKPWP_OPTIONS();
852
- $ret = "<div style=\"border: 1px solid #ccc; padding:10px; margin-bottom:20px;\">";
853
- $ret .= "<form method=\"post\" action=\"admin.php?page=bkpwp_manage_presets\">";
854
- /*if ($preset['bkpwp_preset_options']['default'] == 1) {
855
- $ret .= "<div id=\"message\" class=\"updated fade\"><p>".__("You can not overwrite this default preset. Please save changes with a new Preset Name.","bkpwp")."</p></div>";
856
- }
857
- */
858
- $ret .= "<h4>Configure or Create Backup Preset</h4><p>";
859
- $ret .= "<label for=\"mod_bkpwp_preset_name\">".__("Preset Name","bkpwp")." </label>";
860
- $ret .= "<input type=\"text\" name=\"mod_bkpwp_preset_name\" id=\"mod_bkpwp_preset_name\" value=\"".$preset['bkpwp_preset_name']."\" /></p>";
861
-
862
- $ret .= "<p><label for=\"mod_bkpwp_archive_type\">".__("Archive Type","bkpwp")." </label><select name=\"mod_bkpwp_archive_type\" id=\"mod_bkpwp_archive_type\">";
863
- $archive_types = get_option("bkpwp_archive_types");
864
- if (is_array($archive_types)) {
865
- foreach ($archive_types as $type) {
866
- $ret .= "<option value=\"".$type."\" ";
867
- if ($preset['bkpwp_preset_options']['bkpwp_archive_type'] == $type) {
868
- $ret .= " selected";
869
- }
870
- $ret .= ">".$type."</option>";
871
- }
872
- }
873
- $ret .= "</select></p>";
874
-
875
- if($preset['bkpwp_preset_options']['bkpwp_sql_only'] == 1) {
876
- $fullinit = " style=\"display: none;\"";
877
- }
878
- $ret .= "<div id=\"full_only\"".$fullinit.">";
879
- $lists = $options->bkpwp_get_excludelists();
880
- if (is_array($lists)) {
881
- $ret .= "<p>".__("Exclude List","bkpwp")." <select name=\"mod_bkpwp_excludelist\" id=\"mod_bkpwp_excludelist\">";
882
- $ret .= "<option value=\"\">".__("None","bkpwp")."</option>";
883
- foreach ($lists as $l) {
884
- $ret .= "<option value=\"".$l['listname']."\" ";
885
- if ($preset['bkpwp_preset_options']['bkpwp_excludelist'] == $l['listname']) {
886
- $ret .= " selected";
887
- }
888
- $ret .= ">".$l['listname']."</option>";
889
- }
890
- $ret .= "</select>";
891
- $ret .= " <a href=\"admin.php?page=bkpwp-backup-options&excludelistname=".$preset['bkpwp_preset_options']['bkpwp_excludelist']."#excludelist\">".__("Configure","bkpwp")." &raquo;</a>";
892
- $ret .= "</p>";
893
- }
894
- $ret .= "</div>";
895
-
896
- $ret .= "<p><label for=\"mod_bkpwp_sql_only\"><input type=\"checkbox\" name=\"mod_bkpwp_sql_only\" id=\"mod_bkpwp_sql_only\" value=\"1\"";
897
- if ($preset['bkpwp_preset_options']['bkpwp_sql_only'] == 1) {
898
- $ret .= " checked";
899
- }
900
- $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>";
901
- $ret .= "<p><input type=\"submit\" class=\"button\" value=\"".__("Save Preset","bkpwp")."\" /></p>";
902
- $ret .= "</form></div>";
903
- return $ret;
904
- }
905
-
906
- function bkpwp_view_preset($preset) {
907
- $backup = new BKPWP_BACKUP();
908
- $options = new BKPWP_OPTIONS();
909
- $ret = "<div>";
910
- if (!empty($preset['bkpwp_preset_options']['bkpwp_excludelist'])) {
911
- $ret .= "<p>".__("Omitted Folders and Files when using","bkpwp")." <b>".$preset['bkpwp_preset_name']."</b></p>";
912
- $ret .= "<p>";
913
- $ret .= $options->bkpwp_ajax_shownobfiles($preset['bkpwp_preset_options']['bkpwp_excludelist']);
914
- $ret .= "</p>";
915
- }
916
- $ret .= $backup->bkpwp_calculate($preset);
917
- $ret .= "</div>";
918
- return $ret;
919
- }
920
-
921
- function bkpwp_delete_preset($name) {
922
- $apresets = $this->bkpwp_get_presets();
923
- $presets= array();
924
- foreach($apresets as $p) {
925
- if ($p['bkpwp_preset_name'] != $name) {
926
- $presets[] = $p;
927
- } else {
928
- if ($p['bkpwp_preset_options']['default'] == 1) {
929
- return __("You can not delete this default preset.","bkpwp");
930
- }
931
- }
932
- }
933
- $this->bkpwp_update_presets($presets);
934
- return "<div id=\"message\" class=\"updated fade\"><p>".__("Preset deleted.","bkpwp")."</p></div>";
935
- }
936
-
937
- function bkpwp_update_preset($preset) {
938
- $apresets = $this->bkpwp_get_presets();
939
- $presets= array();
940
- foreach($apresets as $p) {
941
- if ($p['bkpwp_preset_name'] != $preset['bkpwp_preset_name']) {
942
- $presets[] = $p;
943
- } else {
944
- $presets[] = $preset;
945
- }
946
- }
947
- $this->bkpwp_update_presets($presets);
948
- }
949
-
950
- function bkpwp_save_preset($name="",$archive_type="",$excludelist="",$sql_only="", $lastrun="") {
951
- if (empty($name)) {
952
- $name = "Preset".date("Y-m-d-H-i-s");
953
- }
954
- $apresets = $this->bkpwp_get_presets();
955
- $presets= array();
956
- foreach($apresets as $p) {
957
- if ($p['bkpwp_preset_name'] != $name) {
958
- $presets[] = $p;
959
- } else {
960
- if ($p['bkpwp_preset_options']['default'] == 1) {
961
- return "<div id=\"message\" class=\"updated fade\"><p>".__("You can not overwrite this default preset. Please save changes with a new Preset Name.","bkpwp")."</p></div>";
962
- }
963
- }
964
- }
965
-
966
- $options = array("bkpwp_archive_type" => $archive_type,
967
- "bkpwp_sql_only" => $sql_only,
968
- "bkpwp_excludelist" => $excludelist,
969
- "bkpwp_lastrun" => $lastrun);
970
- $presets[] = array("bkpwp_preset_name" => $name,
971
- "bkpwp_preset_options" => $options);
972
-
973
- $this->bkpwp_update_presets($presets);
974
- return "<div id=\"message\" class=\"updated fade\"><p>".__("Preset saved.","bkpwp")."</p></div>";
975
- }
976
-
977
- function bkpwp_get_preset($name="") {
978
- if (empty($name)) {
979
- $name = "full backup";
980
- }
981
- $user = $GLOBALS['userdata']->user_login;
982
- if(empty($user)) { $user = get_option("bkpwp_install_user"); }
983
- $presets = get_option("bkpwp_presets");
984
- $apresets = $presets[$user]['bkpwp_presets'];
985
- foreach($apresets as $p) {
986
- if ($p['bkpwp_preset_name'] == $name) {
987
- return $p;
988
- }
989
- }
990
- }
991
-
992
- function bkpwp_max_views() {
993
- $maxview = get_option('bkpwp_listmax_backups');
994
- if (!empty($_REQUEST['bkpwp_show_all'])) {
995
- $maxview = 999;
996
- }
997
- return $maxview;
998
- }
999
-
1000
- function bkpwp_get_backups() {
1001
- $files = array();
1002
- $bkpwppath = get_option("bkpwppath");
1003
- if (!is_writable($bkpwppath)) {
1004
- return;
1005
- }
1006
- $restorefile = $bkpwppath."/bkpwp_restore.sql";
1007
- if (file_exists($restorefile)) {
1008
- unlink($restorefile);
1009
- }
1010
- if ($handle = opendir($bkpwppath)) {
1011
- while (false !== ($file = readdir($handle))) {
1012
- if ((substr($file,0,1) != ".") && !is_dir($bkpwppath."/".$file)) {
1013
- $files[] = array("file" => $bkpwppath."/".$file,
1014
- "filename" => $file);
1015
- }
1016
- }
1017
- closedir($handle);
1018
- }
1019
- if (count($files) < 1) { return; }
1020
- foreach ($files as $key => $row) {
1021
- $filename[$key] = $row['filename'];
1022
- }
1023
- array_multisort($filename, SORT_DESC, $files);
1024
- return $files;
1025
- }
1026
-
1027
- function bkpwp_get_logs() {
1028
- $files = array();
1029
- $bkpwppath = get_option("bkpwppath")."/logs";
1030
- if (!is_writable($bkpwppath)) {
1031
- return;
1032
- }
1033
- if ($handle = opendir($bkpwppath)) {
1034
- while (false !== ($file = readdir($handle))) {
1035
- if (($file != ".") && ($file != "..") && !is_dir($bkpwppath."/".$file)) {
1036
- $files[] = array("file" => $bkpwppath."/".$file,
1037
- "filename" => $file);
1038
- }
1039
- }
1040
- closedir($handle);
1041
- }
1042
- if (count($files) < 1) { return; }
1043
- foreach ($files as $key => $row) {
1044
- $filename[$key] = $row['filename'];
1045
- }
1046
- array_multisort($filename, SORT_DESC, $files);
1047
- return $files;
1048
- }
1049
- }
1050
-
1051
-
1052
- require(ABSPATH."wp-includes/class-phpmailer.php");
1053
- class backupwordpressMailer extends PHPMailer {
1054
- // Set default variables for all new objects
1055
- //var $From = $GLOBALS['userdata']->user_email;
1056
- var $FromName = "BackUpWordPress";
1057
- /*
1058
- var $Host = "";
1059
- var $Username = ''; // SMTP username
1060
- var $Password = ''; // SMTP password
1061
- var $SMTPAuth = true; */
1062
- var $Mailer = "mail";
1063
- var $WordWrap = 75;
1064
- }
1065
-
1066
- function bkpwp_mail_now($file="", $bkpwpinfo="") {
1067
- ob_start();
1068
- include_once(BKPWP_PLUGIN_PATH."bkpwp-pages/bkpwp_footer.php");
1069
- $text_html = ob_get_contents();
1070
- ob_end_clean();
1071
-
1072
- ob_start();
1073
- include_once(BKPWP_PLUGIN_PATH."bkpwp-pages/bkpwp_mail_footer.php");
1074
- $text_plain = ob_get_contents();
1075
- ob_end_clean();
1076
-
1077
- // Instantiate your new class
1078
- $mail = new backupwordpressMailer;
1079
- $mail->IsHTML(true);
1080
-
1081
- // Now you only need to add the necessary stuff
1082
-
1083
- $email = get_option("bkpwp_automail_address");
1084
- $em = explode (",",$email);
1085
- foreach($em as $e) {
1086
- $mail->AddAddress(trim($e), "Backup Admin");
1087
- }
1088
- $mail->From = get_option("bkpwp_automail_from");
1089
- $mail->FromName = __("BackUpWordPress","bkpwp")." ".get_bloginfo("url");
1090
- $mail->Subject = __("BackUpWordPress","bkpwp")." ".get_bloginfo("url");
1091
- $mail->Body = "<html><body>";
1092
- $mail->Body .= __("Your requested Backup","bkpwp");
1093
- if (empty($file)) {
1094
- $mail->Body .= __("This Backup exceeded","bkpwp")." ".get_option("bkpwp_automail_maxsize")." ".__("MB (megabytes)","bkpwp")."<br /><br />\n\n";
1095
- $mail->Body .= __("Please download it from your WordPress administration backend.","bkpwp")."<br /><br />\n\n";
1096
- }
1097
-
1098
- $mail->Body .= $bkpwpinfo;
1099
- $mail->Body .= $text_html;
1100
- $mail->Body .= "</body></html>";
1101
- $mail->AltBody = strip_tags($text_plain);
1102
-
1103
- if (!empty($file)) {
1104
- $mail->AddAttachment(base64_decode($file)); // optional name
1105
- }
1106
-
1107
- if(!$mail->Send()){
1108
- echo $mail->ErrorInfo;
1109
- return false;
1110
- } else {
1111
- return true;
1112
- }
1113
- }
1114
- ?>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
bkpwp-classes/options.php DELETED
@@ -1,466 +0,0 @@
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
- } elseif (bkpwp_conform_dir($_REQUEST['bkpwppath']) == bkpwp_conform_dir(ABSPATH)."/wp-content") {
68
- delete_option("bkpwppath");
69
- $msg = __("Do not use your wp-content directory for backup storage. Specify a writable directory inside ","bkpwp").bkpwp_conform_dir(ABSPATH)." that doen't need to be accessible by unauthenticated users.";
70
- bkpwp_display_message($msg);
71
- } else {
72
- if (!is_dir($_REQUEST['bkpwppath'])) {
73
- if (!mkdir($_REQUEST['bkpwppath'],0777)) {
74
- $this->bkpwp_delete_option("bkpwppath");
75
- $msg = __("Wrong Backup Path. Directory does not exist and this script was not able to create it.","bkpwp");
76
- bkpwp_display_message($msg);
77
- } else {
78
- $this->bkpwp_update_option("bkpwppath",$_REQUEST['bkpwppath']);
79
- $msg = __("Directory did not exist but this script was able to create it.","bkpwp");
80
- bkpwp_display_message($msg." <a href=\"admin.php?page=".$_REQUEST['page']."\">".__("Continue","bkpwp")." &raquo;</a>");
81
- }
82
- } elseif (!is_writable($_REQUEST['bkpwppath'])) {
83
- $this->bkpwp_delete_option("bkpwppath");
84
- $msg = __("Directory does exist but is not writable by the webserver. Check directory permissions (e.g.: chmod 777).","bkpwp");
85
- bkpwp_display_message($msg);
86
- } else {
87
- $this->bkpwp_update_option("bkpwppath",$_REQUEST['bkpwppath']);
88
- bkpwp_display_message(__("Backup Path saved.","bkpwp")." <a href=\"admin.php?page=".$_REQUEST['page']."\">".__("Continue","bkpwp")." &raquo;</a>");
89
-
90
- }
91
- }
92
- }
93
- if (!is_writable($this->bkpwp_path()) && empty($_REQUEST['bkpwppath'])) {
94
- $msg = __("Please configure the Backup path first. The field below should allready be filled with a recommendation for that option.","bkpwp");
95
- if ($suppress_msg == 0) {
96
- bkpwp_display_message($msg);
97
- }
98
- }
99
- }
100
-
101
- function bkpwp_check_path() {
102
- if (!$this->bkpwp_easy_mode()){
103
- echo $this->bkpwp_path();
104
- } else {
105
- if (!is_writable($this->bkpwp_path())) {
106
- echo $this->bkpwp_default_backup_path;
107
- } else {
108
- echo eregi_replace(bkpwp_conform_dir(ABSPATH),"",$this->bkpwp_path());
109
- }
110
- }
111
- }
112
-
113
- function bkpwp_handle_backup_settings() {
114
- if (!empty($_REQUEST['bkpwp_backup_options'])) {
115
- $this->bkpwp_update_option("bkpwp_max_backups",$_REQUEST['bkpwp_max_backups']);
116
- bkpwp_display_message(__("Settings saved.","bkpwp"));
117
- }
118
- }
119
-
120
- function bkpwp_handle_backup_automail() {
121
- if (!empty($_REQUEST['bkpwp_automailsettings'])) {
122
- if (!empty($_REQUEST['bkpwp_automail'])) {
123
- $this->bkpwp_update_option("bkpwp_automail",$_REQUEST['bkpwp_automail']);
124
- if (empty($_REQUEST['bkpwp_automail_address'])) {
125
- $_REQUEST['bkpwp_automail_address'] = $GLOBALS['userdata']->user_email;
126
- }
127
- $this->bkpwp_update_option("bkpwp_automail_address",$_REQUEST['bkpwp_automail_address']);
128
- $this->bkpwp_update_option("bkpwp_automail_from",$GLOBALS['userdata']->user_email);
129
- $this->bkpwp_update_option("bkpwp_automail_receiver",$GLOBALS['userdata']->user_nicename);
130
- if (!empty($_REQUEST['bkpwp_automail_maxsize'])) {
131
- $this->bkpwp_update_option("bkpwp_automail_maxsize",$_REQUEST['bkpwp_automail_maxsize']);
132
- }
133
- bkpwp_display_message(__("Settings saved.","bkpwp"));
134
- } else {
135
- $this->bkpwp_delete_option("bkpwp_automail_maxsize");
136
- $this->bkpwp_delete_option("bkpwp_automail_address");
137
- $this->bkpwp_delete_option("bkpwp_automail_receiver");
138
- $this->bkpwp_delete_option("bkpwp_automail");
139
- }
140
- }
141
- }
142
-
143
- function bkpwp_handle_backup_excludelists() {
144
- if (!empty($_REQUEST['nobackup']) && !empty($_REQUEST['excludelist'])) {
145
- $this->bkpwp_excludelist();
146
- bkpwp_display_message(__("New Backup Exclude List saved:","bkpwp")." ".$_REQUEST['excludelistname']);
147
- } elseif (!empty($_REQUEST['nobackupchange']) && !empty($_REQUEST['excludelist'])) {
148
- $this->bkpwp_excludelist();
149
- bkpwp_display_message(__("Backup Exclude List saved:","bkpwp")." ".$_REQUEST['excludelistname']);
150
- } elseif (!empty($_REQUEST['nobackupdelete']) && !empty($_REQUEST['excludelist'])) {
151
- $this->bkpwp_delete_excludelist($_REQUEST['excludelistname']);
152
- bkpwp_display_message(__("Backup Exclude List deleted:","bkpwp")." ".$_REQUEST['excludelistname']);
153
- }
154
- }
155
-
156
- function bkpwp_ls_exclusions($dir,$files=array()) {
157
- $d = opendir($dir);
158
- while ($file = readdir($d)) {
159
- if ($file == '.' || $file == '..') { continue; }
160
- $getfile = $this->bkpwp_match_excludelist($dir,$file);
161
- if (!empty($getfile)) {
162
- $files[] = $getfile;
163
- }
164
- if (is_dir($dir.'/'.$file)) {
165
- if (!empty($getfile)) {
166
- continue;
167
- }
168
- $files = $this->bkpwp_ls_exclusions($dir.'/'.$file, $files);
169
- }
170
- }
171
- return $files;
172
- }
173
-
174
- function bkpwp_ajax_shownobfiles($listname,$dir="") {
175
- if (empty($dir)) {
176
- $dir = bkpwp_conform_dir(ABSPATH);
177
- }
178
- $this->excludelist = urldecode($listname);
179
- $ret = "";
180
- $files = $this->bkpwp_ls_exclusions($dir);
181
- $stringmatches = array();
182
-
183
-
184
- $ret .= "<p>";
185
- $ret .= __("Folders","bkpwp")."<br />";
186
- foreach($files as $f) {
187
- if (is_dir($f['file'])) {
188
- $ret .= "<b>".$f['file']."</b>: ".__("matched by","bkpwp")." ".$f['match']." -> ".$f['value']."<br />";
189
- } else {
190
- if ($f['match'] == "string") {
191
- $t = $f['value'];
192
- $stringmatches[$t]++;
193
- }
194
- }
195
- }
196
- $ret .= "</p>";
197
-
198
- if (count($stringmatches) > 0) {
199
- $ret .= "<p>";
200
- $ret .= __("Files","bkpwp")."<br />";
201
- foreach($stringmatches as $s=>$t) {
202
- $ret .= "<b>".$t."</b> ".__("files matched by","bkpwp")." ".$s."<br />";
203
- }
204
- $ret .= "</p>";
205
- }
206
-
207
- return $ret;
208
- }
209
-
210
- function bkpwp_ls($dir,$files=array()) {
211
- $d = opendir($dir);
212
- $j=0;
213
- while ($file = readdir($d)) {
214
- if ($file == '.' || $file == '..') { continue; }
215
- $getfile = $this->bkpwp_match_excludelist($dir,$file);
216
- if (!empty($getfile)) {
217
- continue;
218
- }
219
- $files[] = $dir.'/'.$file;
220
- if (is_dir($dir.'/'.$file)) {
221
- if (!empty($getfile)) {
222
- continue;
223
- }
224
- $files = $this->bkpwp_ls($dir.'/'.$file,$files); $j++;
225
- }
226
- }
227
- return $files;
228
- }
229
-
230
- function bkpwp_match_excludelist($dir,$file) {
231
- $nobfiles = $this->bkpwp_get_excludelist($this->excludelist);
232
- $nobfiles['list'][] = get_option("bkpwppath");
233
- if (is_array($nobfiles['list'])) {
234
- foreach($nobfiles['list'] as $n) {
235
- if (empty($n)) { continue; }
236
- $ifpath = str_replace("\\","/",$n);
237
- $absolutefilepath = str_replace("\\","/",$dir.'/'.$file);
238
- $relativefilepath = str_replace(ABSPATH,"",$absolutefilepath);
239
- if (($ifpath == $absolutefilepath) || ($ifpath == $relativefilepath)) {
240
- return array('file' => $dir.'/'.$file, 'match' => 'path', 'value' => $n);
241
- } elseif (!strpos("/",$ifpath) && stristr($file,$n)) {
242
- return array('file' => $dir.'/'.$file, 'match' => 'string', 'value' => $n);
243
- }
244
- }
245
- }
246
- return false;
247
- }
248
-
249
- function bkpwp_get_excludelists() {
250
- $allnobs = get_option("bkpwp_excludelists");
251
- $user = $GLOBALS['userdata']->user_login;
252
- if(empty($user)) { $user = "admin"; }
253
- return $allnobs[$user];
254
- }
255
-
256
- function bkpwp_get_excludelist($listname) {
257
- $usernoblists = $this->bkpwp_get_excludelists();
258
- if(!is_array($usernoblists)) { return; }
259
- foreach($usernoblists as $f) {
260
- if ($f['listname'] == $listname) {
261
- return $f;
262
- }
263
- }
264
- }
265
-
266
- function bkpwp_excludelist_tochange() {
267
- if (!empty($_REQUEST['excludelist_to_change'])) {
268
- return $this->bkpwp_get_excludelist($_REQUEST['excludelist_to_change']);
269
- }
270
-
271
- if (!empty($_REQUEST['excludelistname'])) {
272
- return $this->bkpwp_get_excludelist($_REQUEST['excludelistname']);
273
- }
274
- }
275
-
276
- function bkpwp_delete_excludelist($listname) {
277
- $allnobst = get_option("bkpwp_excludelists");
278
- $user = $GLOBALS['userdata']->user_login;
279
- if(empty($user)) { $user = "admin"; }
280
- $allnobs = array();
281
- if (!is_array($allnobst[$user])) {
282
- $allnobst[$user] = array();
283
- }
284
- foreach ($allnobst[$user] as $a) {
285
- if ($a['listname'] != $listname) {
286
- $allnobs[$user][] = $a;
287
- }
288
- }
289
-
290
- update_option("bkpwp_excludelists",$allnobs);
291
- }
292
-
293
- function bkpwp_save_excludelist($list,$listname,$listtype) {
294
- $allnobst = get_option("bkpwp_excludelists");
295
- $user = $GLOBALS['userdata']->user_login;
296
- if(empty($user)) { $user = "admin"; }
297
- $allnobs = array();
298
- if (!is_array($allnobst[$user])) {
299
- $allnobst[$user] = array();
300
- }
301
- foreach ($allnobst[$user] as $a) {
302
- if ($a['listname'] != $listname) {
303
- $allnobs[$user][] = $a;
304
- }
305
- }
306
- $allnobs[$user][] = array("listname" => $listname,
307
- "listtype" => $listtype,
308
- "list" => $list);
309
-
310
- update_option("bkpwp_excludelists",$allnobs);
311
- }
312
-
313
- function bkpwp_excludelist($excludelist="",$excludelistname="",$excludelisttype="") {
314
- $list = array();
315
- $list[] = $this->bkpwp_path();
316
- if (!empty($_REQUEST['excludelist'])) {
317
- $excludelist = $_REQUEST['excludelist'];
318
- }
319
- foreach($excludelist as $r) {
320
- if (eregi(",",$r)) {
321
- $re=explode(",",$r);
322
- foreach($re as $e) {
323
- if (!empty($e)) {
324
- $list[] = $e;
325
- }
326
- }
327
- } else {
328
- if (!empty($r)) {
329
- $list[] = $r;
330
- }
331
- }
332
- }
333
- $list = array_unique($list);
334
- if (!empty($_REQUEST['excludelistname'])) {
335
- $excludelistname = $_REQUEST['excludelistname'];
336
- }
337
- if (empty($excludelistname)) {
338
- $excludelistname = "excl_".date("Y-m-d-H-i-s");
339
- }
340
- $this->bkpwp_save_excludelist($list,$excludelistname,$excludelisttype);
341
- }
342
-
343
- function bkpwp_check_compression_type($archive_types_wishlist) {
344
- $a = array();
345
- foreach($archive_types_wishlist as $at) {
346
- if (function_exists($at['func']) || empty($at['func'])) {
347
- $a[] = $at['ext'];
348
- }
349
- }
350
- return $a;
351
- }
352
-
353
- function bkpwp_add_capabilities() {
354
- global $wp_roles;
355
- $wp_roles->add_cap('administrator','manage_backups', true);
356
- $wp_roles->add_cap('administrator','download_backups', true);
357
- }
358
-
359
- function bkpwp_default_archive_types() {
360
- // a wishlist of compression types
361
- $archive_types_wishlist = array();
362
- $archive_types_wishlist[] = array("ext" => "zip", "func" => ""); // pear package file_archive's own
363
- $archive_types_wishlist[] = array("ext" => "tgz", "func" => "gzopen");
364
- $archive_types_wishlist[] = array("ext" => "tar.gz", "func" => "gzopen");
365
- $archive_types_wishlist[] = array("ext" => "tar", "func" => ""); // pear package file_archive's own
366
- $archive_types_wishlist[] = array("ext" => "tar.bz2", "func" => "bzopen");
367
-
368
- // run a check if the respective compression is supported by this php installation
369
- $archive_types = $this->bkpwp_check_compression_type($archive_types_wishlist);
370
- update_option("bkpwp_archive_types",$archive_types);
371
- }
372
-
373
- function bkpwp_get_backup_type($f) {
374
- $ex = explode(".",$f);
375
- $ex = explode("-",$ex[0]);
376
- $type = $ex[6];
377
- if (eregi("_adv",$type)) {
378
- $type = eregi_replace("_adv","",$type);
379
- $type .= " - advanced";
380
- }
381
- return $type;
382
- }
383
-
384
- function bkpwp_default_excludelists() {
385
- $defaults = new BKPWP_OPTIONS();
386
- $presetso = new BKPWP_MANAGE();
387
- // Excludelists Defaults
388
- $excludelist[] = ".tmp,~,.bak,#";
389
- $excludelistname = "temporary and autosave files";
390
- $excludelisttype = "default";
391
- $defaults->bkpwp_excludelist($excludelist,$excludelistname,$excludelisttype);
392
- }
393
-
394
- function bkpwp_default_presets() {
395
- // Preset defaults
396
- // is set for the current user.
397
- //update_option("bkpwp_presets","");
398
- $presetso = new BKPWP_MANAGE();
399
- $presets = $presetso->bkpwp_get_presets();
400
- if (count($presets) < 1) {
401
- $presets = array();
402
- // full backup
403
- $options = array("bkpwp_archive_type" => 'tar.gz',
404
- "default" => 1,
405
- "bkpwp_excludelist" => $excludelistname);
406
- $presets[] = array("bkpwp_preset_name" => "full backup",
407
- "bkpwp_preset_options" => $options);
408
- // sql only
409
- $options = array("bkpwp_sql_only" => 1,
410
- "bkpwp_archive_type" => 'tar.gz',
411
- "default" => 1);
412
- $presets[] = array("bkpwp_preset_name" => "sql only",
413
- "bkpwp_preset_options" => $options);
414
- $presetso->bkpwp_update_presets($presets);
415
- }
416
- }
417
-
418
- function bkpwp_default_schedules() {
419
-
420
- // scheduling defaults
421
- $schedules = get_option("bkpwp_schedules");
422
- if (!is_array($schedules)) {
423
- $schedules = array();
424
- $schedules[] = array("preset" => "full backup",
425
- "status" => "inactive",
426
- "reccurrence" => 'bkpwp_weekly',
427
- "info" => __("Full Backup Weekly","bkpwp"),
428
- "default" => 1,
429
- "created" => date("Y-m-d-H-i-s"));
430
- sleep(2);
431
- $schedules[] = array("preset" => "sql only",
432
- "status" => "inactive",
433
- "reccurrence" => 'bkpwp_daily',
434
- "info" => __("SQL Only Backup Daily","bkpwp"),
435
- "default" => 1,
436
- "created" => date("Y-m-d-H-i-s"));
437
- update_option("bkpwp_schedules",$schedules);
438
- }
439
- }
440
-
441
- function bkpwp_set_defaults() {
442
- // set a few options
443
- update_option('bkpwp_listmax_backups',15);
444
- update_option('bkpwp_max_backups',10);
445
- update_option("bkpwp_domain","bkpwp");
446
- update_option("bkpwp_install_user",$GLOBALS['userdata']->user_login);
447
- update_option("bkpwp_domain_path","wp-content/plugins/bkpwp/locale");
448
-
449
- $user = $GLOBALS['userdata']->user_login;
450
- if(empty($user)) { $user = "admin"; }
451
- if (!$this->bkpwp_easy_mode()) {
452
- $easy_mode[$user] = 1;
453
- } else {
454
- $easy_mode[$user] = "";
455
- }
456
-
457
- update_option("bkpwp_easy_mode",$easy_mode);
458
-
459
- $this->bkpwp_default_archive_types();
460
- $this->bkpwp_default_excludelists();
461
- $this->bkpwp_default_presets();
462
- $this->bkpwp_default_schedules();
463
- $this->bkpwp_add_capabilities();
464
- }
465
- }
466
- ?>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
bkpwp-classes/schedule.php DELETED
@@ -1,116 +0,0 @@
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_update_schedule($options) {
20
- $schedules = get_option("bkpwp_schedules");
21
- $newschedules = array();
22
- foreach($schedules as $s) {
23
- if ($s['created'] == $options['created']) {
24
- $s = $options;
25
- }
26
- $newschedules = $s;
27
- }
28
- update_option("bkpwp_schedules",$newschedules);
29
- }
30
-
31
- function bkpwp_delete_schedule_by_created($created) {
32
- $schedules = get_option("bkpwp_schedules");
33
- $newschedules = array();
34
- foreach($schedules as $s) {
35
- if ($s['created'] == $created) {
36
- $timestamp = wp_next_scheduled("bkpwp_schedule_bkpwp_hook",$s);
37
- if(!empty($timestamp)) {
38
- wp_unschedule_event($timestamp,"bkpwp_schedule_bkpwp_hook",$s);
39
- }
40
- $ret = 1;
41
- } else {
42
- $newschedules[] = $s;
43
- }
44
- }
45
- update_option("bkpwp_schedules",$newschedules);
46
- if (empty($ret)) { return false; }
47
- return $ret;
48
- }
49
-
50
-
51
- function bkpwp_unset_schedules() {
52
- $crons = get_option("cron");
53
- if (is_array($crons)) {
54
- foreach($crons as $timestamp => $cron) {
55
- if (!is_array($cron)) { continue; }
56
- foreach($cron as $hook => $options) {
57
- if($hook == "bkpwp_schedule_bkpwp_hook") {
58
- foreach ($options as $key=>$value) {
59
- wp_unschedule_event($timestamp,$hook,$value['args']);
60
- }
61
- }
62
- }
63
- }
64
- }
65
- }
66
-
67
-
68
- function bkpwp_toggle_schedule($created) {
69
- $schedules = get_option("bkpwp_schedules");
70
- $newschedules = array();
71
- $bkpwp_reccurrences = get_option("bkpwp_reccurrences");
72
- foreach($schedules as $s) {
73
- if ($s['created'] == $created) {
74
- if ($s['status'] == "active") {
75
- $timestamp = wp_next_scheduled("bkpwp_schedule_bkpwp_hook",$s);
76
- if(!empty($timestamp)) {
77
- wp_unschedule_event($timestamp,"bkpwp_schedule_bkpwp_hook",$s);
78
- $s['status'] = "inactive";
79
- $ret = "inactive";
80
- } else {
81
- return false;
82
- }
83
- } else {
84
- $recc = $s['reccurrence'];
85
- $s['status'] = "active";
86
- wp_schedule_event(time()+$bkpwp_reccurrences[$recc]['interval'], $s['reccurrence'], 'bkpwp_schedule_bkpwp_hook',$s);
87
- $ret = "active";
88
- }
89
- }
90
- $newschedules[] = $s;
91
- }
92
- update_option("bkpwp_schedules",$newschedules);
93
- if (empty($ret)) { return false; }
94
- return $ret;
95
- }
96
-
97
- function bkpwp_test_schedule() {
98
- $schedules = get_option("bkpwp_schedules");
99
- $test = array("preset" => "sql only",
100
- "status" => "active",
101
- "reccurrence" => '',
102
- "info" => __("Test schedule running in 30 seconds","bkpwp"),
103
- "default" => '',
104
- "created" => date("Y-m-d-H-i-s"));
105
- $schedules[] = $test;
106
- if (!wp_next_scheduled('bkpwp_schedule_bkpwp_hook', $test)) {
107
- wp_schedule_single_event(time()+30, 'bkpwp_schedule_bkpwp_hook', $test);
108
- update_option("bkpwp_schedules",$schedules);
109
- return true;
110
- } else {
111
- return false;
112
- }
113
- }
114
- }
115
-
116
- ?>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
bkpwp-pages/bkpwp_footer.php DELETED
@@ -1,28 +0,0 @@
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"); ?> &raquo;
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 DELETED
@@ -1,209 +0,0 @@
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"); ?> &raquo;</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_options#backup_options"><?php _e("Configure","bkpwp"); ?> &raquo;</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"); ?> &raquo;</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"); ?> &raquo;</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"); ?> &raquo;</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"); ?> &raquo;</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"); ?> &raquo;</a>
206
- </p>
207
-
208
- <?php } ?>
209
- </div>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
bkpwp-pages/bkpwp_mail_footer.php DELETED
@@ -1,4 +0,0 @@
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 DELETED
@@ -1,436 +0,0 @@
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"); ?> &raquo;" />
28
- <?php
29
- if (!eregi("-sql.tar.gz",base64_decode($_REQUEST['bkpwp_restore']))) {
30
- ?>
31
- <a href="admin.php?page=backupwordpress/backupwordpress.php&amp;bkpwp_download=<?php echo $_REQUEST['bkpwp_restore']; ?>"><?php _e("Download the Backup Archive for Files Recovery","bkpwp"); ?> &raquo;</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" id="bkpwp_delete_submit" value="<?php _e("delete","bkpwp"); ?> &raquo;" />
131
- <script type="text/javascript">
132
- document.getElementById('bkpwp_delete_submit').focus();
133
- </script>
134
- </p>
135
- </form>
136
- </p><br />
137
- </div><br />
138
- <?php
139
- } else {
140
- if(!eregi(get_option("bkpwppath"),base64_decode($_REQUEST['bkpwp_delete']))) {
141
- // must be one of those in here!
142
- return;
143
- }
144
- if (unlink(base64_decode($_REQUEST['bkpwp_delete']))) {
145
- ?>
146
- <div id="message" class="updated fade">
147
- <p><?php _e("Backup file deleted sucessfully","bkpwp"); ?>:</p>
148
- <p>
149
- <?php
150
- echo base64_decode($_REQUEST['bkpwp_delete']);
151
- ?>
152
- </p>
153
- </div><br />
154
- <?php
155
- } else {
156
- ?>
157
- <div id="message" class="updated fade">
158
- <p><?php _e("Backup file deletion failed","bkpwp"); ?>:</p>
159
- <p>
160
- <?php
161
- echo base64_decode($_REQUEST['bkpwp_delete']);
162
- ?>
163
- </p>
164
- </div><br />
165
- <?php
166
- }
167
- }
168
- }
169
-
170
- function bkpwp_mail() {
171
-
172
- $backupinfo = new BKPWP_BACKUP_ARCHIVE();
173
- $info = $backupinfo->bkpwp_view_backup_info($_REQUEST['bkpwp_mail'],1);
174
- $bkpwp_automail = get_option("bkpwp_automail");
175
- $bkpwp_automail_maxsize = get_option("bkpwp_automail_maxsize");
176
- if (empty($_REQUEST['bkpwp_mail_now']) && eregi("MB",$info['filesize'])) {
177
- ?>
178
- <div id="message" class="updated fade">
179
- <p><?php _e("The BackUp Archive File you want to send is","bkpwp"); echo " <b>".$info['filesize']."</b> "; _e("large","bkpwp"); echo ".<br />"; ?>
180
- <?php _e("Do you really want to send this file by email?","bkpwp"); ?></p>
181
- <p>
182
- <?php
183
- echo base64_decode($_REQUEST['bkpwp_mail']);
184
- ?>
185
- <form name="form1" method="post" action="">
186
- <input type="hidden" name="bkpwp_mail" value="<?php echo $_REQUEST['bkpwp_mail']; ?>" />
187
- <p style="text-align:left" class="submit">
188
- <input type="submit" name="bkpwp_mail_now" value="<?php _e("send","bkpwp"); ?> &raquo;" />
189
- </p>
190
- </form>
191
- </p><br />
192
- </div><br />
193
- <?php
194
- } else {
195
- if (!empty($bkpwp_automail)) {
196
- if ($bkpwp_automail_maxsize <= filesize(base64_decode($_REQUEST['bkpwp_mail']))) {
197
- $mailed = bkpwp_mail_now($_REQUEST['bkpwp_mail']);
198
- } else {
199
- $mailed = bkpwp_mail_now("");
200
- }
201
- }
202
- if(isset($mailed)) {
203
- ?>
204
- <div id="message" class="updated fade">
205
- <p><?php _e("Backup has been sent","bkpwp"); ?></p>
206
- <p>
207
- <?php
208
- echo base64_decode($_REQUEST['bkpwp_mail']);
209
- ?>
210
- </p>
211
- </div><br />
212
- <?php
213
- } else {
214
- ?>
215
- <div id="message" class="updated fade">
216
- <p><?php _e("Error sending Backup by mail","bkpwp"); ?></p>
217
- <p>
218
- <?php
219
- echo base64_decode($_REQUEST['bkpwp_mail']);
220
- ?>
221
- </p>
222
- </div><br />
223
- <?php
224
- }
225
- }
226
- }
227
-
228
- ?>
229
- <div class="wrap">
230
- <?php
231
- if (count($backup_archives) < 1) {
232
- echo "<h4>".__("No Backups yet","bkpwp").".</h4>";
233
- $bwpwp_path = $backups->options->bkpwp_path();
234
- if (empty($bwpwp_path)) {
235
- echo "<a href=\"admin.php?page=bkpwp_options\">".__("Start by configuring the Options","bkpwp")."</a>";
236
- return;
237
- }
238
- }
239
- ?>
240
- <h2><?php _e("Manage Backups","bkpwp"); ?></h2>
241
- <script type="text/javascript">
242
-
243
- <!-- ajax call to the actual backup function -->
244
- function do_create2() {
245
- var preset;
246
- <?php if (!$backups->options->bkpwp_easy_mode()) { ?>
247
- preset = document.getElementById('bkpwp_preset').options[document.getElementById('bkpwp_preset').selectedIndex].value;
248
- <?php } else { ?>
249
- preset = "full backup";
250
- <?php } ?>
251
- ajax = new Ajax.Updater(
252
- 'bkpwp_action_buffer', // DIV id must be declared before the method was called
253
- '<?php echo get_bloginfo("wpurl")."/wp-admin/admin.php?page=backupwordpress/backupwordpress.php"; ?>', // URL
254
- { // options
255
- method:'post',
256
- postBody:'bkpwp_docreate_preset='+preset
257
- });
258
- }
259
-
260
- <!-- ajax call for calculating disk space usage -->
261
- function calculate2() {
262
- var preset;
263
- <?php if (!$backups->options->bkpwp_easy_mode()) { ?>
264
- preset = document.getElementById('bkpwp_preset').options[document.getElementById('bkpwp_preset').selectedIndex].value;
265
- <?php } else { ?>
266
- preset = "full backup";
267
- <?php } ?>
268
- ajax = new Ajax.Updater(
269
- 'bkpwp_action_buffer', // DIV id must be declared before the method was called
270
- '<?php echo get_bloginfo("wpurl")."/wp-admin/admin.php?page=backupwordpress/backupwordpress.php"; ?>', // URL
271
- { // options
272
- method:'post',
273
- postBody:'bkpwp_calculate_preset='+preset
274
- });
275
- }
276
-
277
- <!-- displays a loading text information while doing ajax requests -->
278
- function bkpwp_js_loading(str) {
279
- document.getElementById('bkpwp_actions').style.display = 'block';
280
- is_loading('bkpwp_action_buffer');
281
- document.getElementById('bkpwp_action_title').innerHTML="<h4>" + str + "</h4>";
282
- }
283
- </script>
284
- <?php
285
-
286
- if (bkpwp_check_unfinished_backup()) {
287
- $status = get_option("bkpwp_status");
288
- ?>
289
- <div id="message" class="updated fade">
290
- <p>
291
- <?php
292
- _e("Last Action of BackUpWordPress: ","bkpwp");
293
- _e("Creating Backup Archive: ","bkpwp");
294
- echo " ".$status['name'].". ";
295
- if ($status['type'] == "sqltable") {
296
- _e("Saving Database Table ","bkpwp");
297
- echo $status['point']." ";
298
- } elseif ($status['type'] == "sqltable_row") {
299
- $d = explode("-",$status['point']);
300
- _e("Saving data rows from table ","bkpwp");
301
- echo $d[0].". ";
302
- _e("Currently saving entries from row number","bkpwp");
303
- echo " ".$d[1]." ";
304
- } elseif ($status['type'] == "file") {
305
- _e("Saving File ","bkpwp");
306
- echo str_replace(get_option("bkpwp_path"),"",$status['point'])." ";
307
- }
308
- _e("at ","bkpwp");
309
- echo date(get_option('date_format'),$status['time'])." ".date("H:i:s",$status['time'])."</p><p>";
310
-
311
- $sincet = bkpwp_date_diff($status['time'],time());
312
- $since .= $sincet['days']." ".__("days","bkpwp")." ";
313
- $since .= $sincet['hours']." ".__("hours","bkpwp")." ";
314
- $since .= $sincet['minutes']." ".__("minutes","bkpwp")." ";
315
- $since .= $sincet['seconds']." ".__("seconds","bkpwp");
316
- _e("BackUpWordPress did not proceed with the current task since","bkpwp");
317
- echo " ".$since;
318
- ?>
319
- </p>
320
- <p>
321
- <?php
322
- if (($status['time']+30) < time()) {
323
- _e("BackUpWordPress tries to proceed with this unfinished backup.");
324
- echo " ";
325
- _e("On a WordPress website with low traffic, reload the page a few times, to trigger the action.");
326
- echo "</p><p>";
327
- _e("If nothing happens for more than 5 minutes, deaktivate the plugin, install the newest version and activate again.","bkpwp");
328
- } else {
329
- _e("Please be patient.","bkpwp");
330
- }
331
- ?>
332
- </p>
333
- <p>
334
- </p>
335
- </div>
336
- <?php
337
- } else {
338
- ?>
339
- <div id="bkpwp_actions" style="display:none;">
340
- <div id="bkpwp_action_title"></div>
341
- <div id="bkpwp_action_buffer"></div>
342
- </div>
343
- <?php if (!$backups->options->bkpwp_easy_mode()) { ?>
344
- <?php $presets = $backups->bkpwp_get_presets();
345
- if (is_array($presets)) { ?>
346
- <p>
347
- <?php _e("Select a Preset.","bkpwp"); ?>
348
- <select name="bkpwp_preset" id="bkpwp_preset">
349
- <?php
350
- foreach ($presets as $p) {
351
- echo "<option value=\"".$p['bkpwp_preset_name']."\">".$p['bkpwp_preset_name']."</option>";
352
- }
353
- ?>
354
- </select> <a href="admin.php?page=bkpwp_manage_presets"><?php _e("Configure","bkpwp"); ?> &raquo;</a>
355
- </p>
356
- <?php }
357
- } ?>
358
- <button class="button" onclick="bkpwp_js_loading('<?php _e("Your backup is being processed.","bkpwp"); ?>'); do_create2(); return false;"><?php _e("BackUp WordPress Now","bkpwp"); ?> &raquo;</button>
359
- <?php if (!$backups->options->bkpwp_easy_mode()) { ?>
360
- <button class="button" onclick="bkpwp_js_loading('<?php _e("Calculating used disk space","bkpwp"); ?>'); calculate2(); return false;"><?php _e("Recalculate Used Disk Space","bkpwp"); ?> &raquo;</button>
361
- <?php }
362
- } ?>
363
-
364
-
365
- <?php
366
- /* delete the backup (but leave the logfile for a while!) */
367
- if (!empty($_REQUEST['bkpwp_delete'])) {
368
- bkpwp_delete();
369
- }
370
- /* mail the backup to someone */
371
- if (!empty($_REQUEST['bkpwp_mail'])) {
372
- bkpwp_mail();
373
- }
374
- if (!empty($_REQUEST['bkpwp_restore'])) {
375
- bkpwp_restore();
376
- }
377
-
378
- ?>
379
-
380
- <br /><br />
381
- <?php if (!$backups->options->bkpwp_easy_mode()) { ?>
382
- <?php _e("Your configuration is set to a maximum of","bkpwp"); ?>
383
- <?php echo get_option('bkpwp_max_backups'); ?>
384
- <?php _e("Backups.","bkpwp"); ?>
385
- <a href="admin.php?page=bkpwp_options#backup_options"><?php _e("Configure","bkpwp"); ?> &raquo;</a>
386
- <br /><br />
387
- <?php } ?>
388
- <?php if (count($backup_archives) > $backups->bkpwp_max_views()) { ?>
389
- <?php _e("displaying the last","bkpwp"); ?>
390
- <?php echo $backups->bkpwp_max_views(); ?>
391
- <?php _e("Backups.","bkpwp"); ?>
392
- <?php echo count($backup_archives); ?>
393
- <?php _e("Backups at all.","bkpwp"); ?>
394
- <a href="admin.php?page=<?php echo $_REQUEST['page']; ?>&amp;bkpwp_show_all=1"><?php _e("Show all","bkpwp"); ?> &raquo;</a>
395
- <br /><br />
396
- <?php } ?>
397
- <table class="widefat" id="bkpwp_manage_backups_table">
398
- <thead>
399
- <tr>
400
- <th scope="col"><?php _e("Date/Time","bkpwp"); ?></th>
401
- <th scope="col"><?php _e("Type","bkpwp"); ?></th>
402
- <?php if (!$backups->options->bkpwp_easy_mode()) { ?>
403
- <th scope="col"><?php _e("Preset","bkpwp"); ?></th>
404
- <?php } ?>
405
- <th scope="col"><?php _e("Size","bkpwp"); ?></th>
406
- <th style="text-align: center;" colspan="5" scope="col"><?php _e("Action","bkpwp"); ?></th>
407
- </tr>
408
- </thead>
409
- <tbody id="the-list">
410
- <?php
411
- $alternate = "alternate";
412
- ?>
413
- <tr class="<?php echo $alternate; ?> bkpwp_manage_backups_newrow" id="bkpwp_manage_backups_newrow" style="display:none;">
414
- <td colspan="7">
415
- </td>
416
- </tr>
417
- <?php
418
- $i=0;
419
- if (is_array($backup_archives)) {
420
- foreach ($backup_archives as $f) {
421
- if (!file_exists($f['file'])) {
422
- continue;
423
- }
424
- if ($i > $backups->bkpwp_max_views()) {
425
- break;
426
- }
427
- if ($alternate == "") { $alternate = "alternate"; } else { $alternate = ""; }
428
- $backup = new BKPWP_BACKUP_ARCHIVE();
429
- $backup->bkpwp_get_backup_row($f,$alternate);
430
- $i++;
431
- }
432
- }
433
- ?>
434
- </tbody>
435
- </table>
436
- </div>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
bkpwp-pages/bkpwp_manage_presets.php DELETED
@@ -1,151 +0,0 @@
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
- if (!empty($_REQUEST['mod_bkpwp_preset_name'])) {
24
- echo $backups->bkpwp_save_preset($_REQUEST['mod_bkpwp_preset_name'],$_REQUEST['mod_bkpwp_archive_type'],$_REQUEST['mod_bkpwp_excludelist'],$_REQUEST['mod_bkpwp_sql_only']);
25
- $backups = new BKPWP_MANAGE();
26
- $backups->options = new BKPWP_OPTIONS();
27
- $presets = $backups->bkpwp_get_presets();
28
- }
29
- ?>
30
- <table class="widefat">
31
- <thead>
32
- <tr>
33
- <th scope="col"><?php _e("Preset Name","bkpwp"); ?></th>
34
- <th scope="col"><?php _e("Archive Type","bkpwp"); ?></th>
35
- <th scope="col"><?php _e("Exclude List","bkpwp"); ?></th>
36
- <th scope="col"><?php _e("SQL/Full","bkpwp"); ?></th>
37
- <th style="text-align: center;" colspan="3" scope="col"><?php _e("Action","bkpwp"); ?></th>
38
- </tr>
39
- </thead>
40
- <tbody id="the-list">
41
- <?php
42
- $alternate = "alternate";
43
- $i=0;
44
-
45
- foreach($presets as $p) {
46
-
47
- if ($alternate == "") { $alternate = "alternate"; } else { $alternate = ""; }
48
- ?>
49
- <tr class="<?php echo $alternate; ?>">
50
- <th scope="row"><?php
51
- echo $p['bkpwp_preset_name'];
52
- ?></th>
53
- <td>
54
- <?php
55
- echo $p['bkpwp_preset_options']['bkpwp_archive_type'];
56
- ?>
57
- </td>
58
- <td>
59
- <?php
60
- if ($p['bkpwp_preset_options']['bkpwp_sql_only'] != 1) {
61
- echo $p['bkpwp_preset_options']['bkpwp_excludelist'];
62
- } else {
63
- echo "&nbsp;";
64
- }
65
- ?>
66
- </td>
67
- <td>
68
- <?php
69
- if ($p['bkpwp_preset_options']['bkpwp_sql_only'] == 1) {
70
- echo "sql";
71
- } else {
72
- echo "full";
73
- }
74
- ?>
75
- </td>
76
- <td style="text-align: center;">
77
- <?php
78
- echo " <a href=\"javascript:void(0)\"
79
- onclick=\"is_loading('bkpwp_action_buffer');
80
- ajax = new Ajax.Updater(
81
- 'bkpwp_action_buffer',
82
- '".get_bloginfo("wpurl")."/wp-admin/admin.php?page=backupwordpress/backupwordpress.php"."',
83
- {
84
- method:'post',
85
- postBody:'bkpwp_load_preset=".$p['bkpwp_preset_name']."'
86
- });\">".__("edit","bkpwp")."</a>";
87
- ?>
88
- </td>
89
- <td style="text-align: center;">
90
- <?php
91
- echo " <a href=\"javascript:void(0)\"
92
- onclick=\"is_loading('bkpwp_action_buffer');
93
- ajax = new Ajax.Updater(
94
- 'bkpwp_action_buffer',
95
- '".get_bloginfo("wpurl")."/wp-admin/admin.php?page=backupwordpress/backupwordpress.php"."',
96
- {
97
- method:'post',
98
- postBody:'bkpwp_view_preset=".$p['bkpwp_preset_name']."'
99
- });\">".__("view","bkpwp")."</a>";
100
- ?>
101
- </td>
102
- <td style="text-align: center;">
103
- <?php
104
- if ($p['bkpwp_preset_options']['default'] != 1) {
105
- echo " <a href=\"admin.php?page=bkpwp_manage_presets&amp;bkpwp_delete_preset=".$p['bkpwp_preset_name']."\">".__("delete","bkpwp")."</a>";
106
- } else {
107
- echo __("default","bkpwp");
108
- }
109
- ?>
110
- </td>
111
- <?php
112
- ?>
113
- </tr>
114
- <?php
115
- $i++;
116
- }
117
- ?>
118
- </tbody>
119
- </table>
120
- <?php
121
- }
122
-
123
- ?>
124
- <div class="wrap">
125
- <script type="text/javascript">
126
- function is_loading(divid) {
127
- document.getElementById('bkpwp_actions').style.display = 'block';
128
- document.getElementById(divid).innerHTML="<img src='<?php bloginfo("url"); ?>/wp-content/plugins/backupwordpress/images/loading.gif' />";
129
- }
130
- <!-- displays a loading text information while doing ajax requests -->
131
- function bkpwp_js_loading(str) {
132
- is_loading('bkpwp_action_buffer');
133
- document.getElementById('bkpwp_action_title').innerHTML="<h4>" + str + "</h4>";
134
- }
135
- </script>
136
- <?php
137
-
138
- echo "<h2>".__("Manage Backup Presets","bkpwp")."</h2>";
139
- ?>
140
- <p><?php _e("To create a new backup preset, edit one of the defaults and save with a new preset name.","bkpwp"); ?></p>
141
- <div id="bkpwp_actions" style="display:none;">
142
- <div id="bkpwp_action_title"></div>
143
- <div id="bkpwp_action_buffer"></div>
144
- </div>
145
- <div id="bkpwp_preset_options" style="display:block; margin-bottom: 10px;">
146
- </div>
147
- <?php
148
- bkpwp_presetlist();
149
-
150
- ?>
151
- </div>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
bkpwp-pages/bkpwp_options.php DELETED
@@ -1,231 +0,0 @@
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"); ?> &raquo;</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"); ?> &raquo;</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']."&amp;bkpwp_toggle_schedule_active=".$s['created']."\">".__("activate","bkpwp")." &raquo;</a>";
77
- } else {
78
- echo __("is currently set to active","bkpwp")." <a href=\"admin.php?page=".$_REQUEST['page']."&amp;bkpwp_toggle_schedule_active=".$s['created']."\">".__("deactivate","bkpwp")." &raquo;</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
- $bkpwp_automail_address = get_option("bkpwp_automail_address");
91
- ?>
92
- <h2><?php _e("Mail Setup","bkpwp"); ?></h2>
93
- <p>
94
- <?php _e("Do you want to receive your backups automatically by email?","bkpwp"); ?>
95
- <form name="form1" method="post" action="admin.php?page=<?php echo $_REQUEST['page']; ?>">
96
- <fieldset>
97
- <?php if ($options->bkpwp_easy_mode()) { } ?>
98
- <p><?php _e("Mail to:","bkpwp"); ?><b> <?php _e("Please seperate multiple email addresses with kommas.","bkpwp"); ?></p>
99
- <p><input type="text" size="55" value="<?php if (empty($bkpwp_automail_address)) { echo $GLOBALS['userdata']->user_email; } else { echo $bkpwp_automail_address; } ?>" name="bkpwp_automail_address" /></b></p>
100
- <p><input type="checkbox" size="50" value="1" name="bkpwp_automail" <?php if(!empty($bkpwp_automail)) { echo " checked"; } ?> />
101
- <?php _e("Yes, send me my backups","bkpwp"); ?></p>
102
- <p><?php _e("as long as they are smaller than","bkpwp"); ?>
103
- <input type="text" size="4" value="<?php echo get_option("bkpwp_automail_maxsize"); ?>" name="bkpwp_automail_maxsize" />
104
- <?php _e("MB (megabytes)","bkpwp"); ?></p>
105
- <input type="submit" class="button" name="bkpwp_automailsettings" value="<?php _e("save","bkpwp"); ?>" />
106
- </fieldset>
107
- </form>
108
- </p>
109
- <?php
110
- }
111
- ?>
112
-
113
- <?php if (!$options->bkpwp_easy_mode()) { // AdvancedMode
114
- ?>
115
- <a name="backup_options"></a>
116
- <?php $options->bkpwp_handle_backup_settings(); ?>
117
- <legend><h2><?php _e("Backup Storage","bkpwp"); ?></h2></legend>
118
- <p>
119
- <?php _e("How many Backups do you want to keep?","bkpwp"); ?>
120
- <form name="form1" method="post" action="admin.php?page=<?php echo $_REQUEST['page']; ?>">
121
- <fieldset>
122
- <label for"bkpwp_max_backups">
123
- <?php _e("maximum Backups","bkpwp"); ?> <input type="text" size="3" value="<?php
124
- echo get_option("bkpwp_max_backups"); ?>" name="bkpwp_max_backups" id="bkpwp_max_backups" />
125
- </label>
126
- <p style="text-align:left" class="submit">
127
- <input type="submit" name="bkpwp_backup_options" value="<?php _e("save","bkpwp"); ?>" />
128
- </p>
129
- </fieldset>
130
- </form>
131
- </p>
132
-
133
- <a name="excludelist"></a>
134
- <legend><h2><?php _e("Exclude Lists","bkpwp"); ?></h2></legend>
135
- </p>
136
- <?php $options->bkpwp_handle_backup_excludelists(); ?>
137
- <?php
138
- if (is_array($options->bkpwp_get_excludelists())) {
139
- if (!empty($_REQUEST['excludelist_to_change'])) {
140
- $listn = $_REQUEST['excludelist_to_change'];
141
- }
142
- if (!empty($_REQUEST['excludelistname'])) {
143
- $listn = $_REQUEST['excludelistname'];
144
- }
145
- ?>
146
- <script type="text/javascript">
147
- function do_show_nobfiles() {
148
- x_bkpwp_ajax_shownobfiles('<?php echo urlencode($listn); ?>',"","");
149
- }
150
- function do_show_nobfiles2() {
151
- ajax = new Ajax.Updater(
152
- 'bkpwp_action_buffer', // DIV id must be declared before the method was called
153
- '<?php echo get_bloginfo("wpurl")."/wp-admin/admin.php?page=backupwordpress/backupwordpress.php"; ?>', // URL
154
- { // options
155
- method:'post',
156
- postBody:'bkpwp_view_excludelist=<?php echo $listn; ?>'
157
- });
158
- }
159
- function loading_shownobfiles() {
160
- document.getElementById('bkpwp_actions').style.display="block";
161
- document.getElementById('bkpwp_action_title').innerHTML="<br /><?php _e("Files &amp; Folders that will NOT (!) be included in the Backup when using ","bkpwp"); echo $_REQUEST['excludelist_to_change']; ?><br /><br />";
162
- document.getElementById('bkpwp_action_buffer').innerHTML="<img src='<?php bloginfo("wpurl"); ?>/wp-content/plugins/backupwordpress/images/loading.gif' />";
163
- }
164
- </script>
165
- <div id="bkpwp_actions" style="display:none;">
166
- <div id="bkpwp_action_title"></div>
167
- <div id="bkpwp_action_buffer"></div>
168
- <br /><br />
169
- </div>
170
- <?php
171
- }
172
- ?>
173
- <?php if (is_array($options->bkpwp_get_excludelists())) { ?>
174
- <form name="form_excl_lists" method="post" action="admin.php?page=<?php echo $_REQUEST['page']; ?>#excludelist">
175
- <?php } ?>
176
- <form name="form1" method="post" action="admin.php?page=<?php echo $_REQUEST['page']; ?>#excludelist">
177
- <fieldset>
178
- <?php _e("Edit an existing Exclude List","bkpwp"); ?>
179
- <select name="excludelist_to_change" onchange="document.form_excl_lists.submit();">
180
- <option value=""><?php _e("Please select","bkpwp"); ?></option>
181
- <?php foreach($options->bkpwp_get_excludelists() as $f) { ?>
182
- <option value="<?php echo $f['listname']; ?>"<?php
183
- if ($listn == $f['listname']) {
184
- echo " selected";
185
- }
186
- ?>><?php echo $f['listname']; ?></option>
187
- <?php } ?>
188
- </select>
189
- </form><br /><br />
190
- <?php if (!empty($_REQUEST['excludelist_to_change']) || !empty($_REQUEST['excludelistname'])) {
191
- $list = $options->bkpwp_excludelist_tochange();
192
- ?>
193
-
194
- <?php if ($list['listtype'] != "default") { ?>
195
- <b><?php _e("Exclude List Name","bkpwp"); ?></b>
196
- <p><input type="text" value="<?php echo $list['listname']; ?>" name="excludelistname" size="20" /></p>
197
- <?php
198
- }
199
- if (is_array($list['list'])) {
200
- _e("Files to exclude","bkpwp");
201
- ?><br /><?php
202
- foreach($list['list'] as $f) {
203
- if ($f != $options->bkpwp_path()) {
204
- ?>
205
- <input type="text" name="excludelist[]" value="<?php echo $f; ?>" size="50" />*<br />
206
- <?php }
207
- }
208
- }?>
209
- <?php if ($list['listtype'] != "default") { ?>
210
- <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"); ?>" />
211
- <?php } else { ?>
212
- <p><?php _e("this is a Default Exclude List","bkpwp"); ?>
213
- <?php } ?>
214
- <button class="button" onclick="loading_shownobfiles(); do_show_nobfiles2(); return false;">&raquo; <?php _e("Show excluded files","bkpwp"); ?></button>
215
- </p>
216
- <?php } else { ?>
217
- <h4><?php _e("New Exclude List","bkpwp"); ?></h4>
218
- <?php _e("Name","bkpwp"); ?> <input type="text" name="excludelistname" size="20" /><br />
219
- <?php _e("Files to exclude","bkpwp"); ?> <input type="text" name="excludelist[]" size="50" />*<br />
220
- <p style="text-align:left" class="submit"><input name="nobackup" type="submit" value="<?php _e("save","bkpwp"); ?>" /></p>
221
- <?php } ?>
222
- </fieldset>
223
- </form>
224
- *<?php _e("enter an <b>absolute or relative path</b> to your folders/ files not to backup","bkpwp"); ?><br />
225
- <?php _e("or <b>just names or file-extensions (.php, .txt) which should match files</b>","bkpwp"); ?>,<br />
226
- <?php _e("no need to take care of the <b>backup folder</b>, it <b>will be excluded anyways","bkpwp"); ?></b>.<br />
227
- <?php _e("Seperate with commas.","bkpwp"); ?><br/><br/>
228
- </p>
229
- <?php } ?>
230
- </div>
231
-
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
bkpwp-pages/bkpwp_schedule.php DELETED
@@ -1,287 +0,0 @@
1
- <?php
2
- function bkpwp_schedulelist($bkpwppath) {
3
- $backups = new BKPWP_MANAGE();
4
- $backups->options = new BKPWP_OPTIONS();
5
-
6
- echo "<h2>".__("Manage Backup Schedules","bkpwp")."</h2>";
7
- echo "<p>".__("Info: Creating custom schedules is on the wishlist for BackUpWordPress 2.0.","bkpwp")."</p>";
8
- ?>
9
- <script type="text/javascript">
10
-
11
- <!-- ajax call for calculating disk space usage -->
12
- function calculate2() {
13
- var preset;
14
- <?php if (!$backups->options->bkpwp_easy_mode()) { ?>
15
- preset = document.getElementById('bkpwp_preset').value;
16
- <?php } else { ?>
17
- preset = "full backup";
18
- <?php } ?>
19
- ajax = new Ajax.Updater(
20
- 'bkpwp_action_buffer', // DIV id must be declared before the method was called
21
- '<?php echo get_bloginfo("wpurl")."/wp-admin/admin.php?page=backupwordpress/backupwordpress.php"; ?>', // URL
22
- { // options
23
- method:'post',
24
- postBody:'bkpwp_calculate_preset='+preset
25
- });
26
- }
27
-
28
- <!-- displays a loading text information while doing ajax requests -->
29
- function bkpwp_js_loading(str) {
30
- document.getElementById('bkpwp_actions').style.display = 'block';
31
- is_loading('bkpwp_action_buffer');
32
- document.getElementById('bkpwp_action_title').innerHTML="<h4>" + str + "</h4>";
33
- }
34
- </script>
35
- <div id="bkpwp_actions" style="display:none;">
36
- <div id="bkpwp_action_title"></div>
37
- <div id="bkpwp_action_buffer"></div>
38
- </div>
39
- <input type="hidden" name="bkpwp_preset" id="bkpwp_preset" value="" />
40
-
41
- <form name="form1" method="post" action="admin.php?page=<?php echo $_REQUEST['page']; ?>">
42
- <fieldset>
43
- <input class="button" type="submit" name="bkpwp_reset_schedules" value="<?php _e("reset default schedules","bkpwp"); ?> &raquo;" />
44
- <input class="button" type="submit" name="bkpwp_test_schedule" value="<?php _e("test schedules","bkpwp"); ?> &raquo;" />
45
- </fieldset>
46
- </form>
47
- <?php
48
- $schedules = get_option("bkpwp_schedules");
49
- ?>
50
- <table class="widefat">
51
- <thead>
52
- <tr>
53
- <th style="text-align: center;" scope="col"><?php _e("Last run","bkpwp"); ?></th>
54
- <th style="text-align: center;" scope="col"><?php _e("Next run","bkpwp"); ?></th>
55
- <th style="text-align: center;" scope="col"><?php _e("Countdown","bkpwp"); ?></th>
56
- <th scope="col"><?php _e("Backup Preset","bkpwp"); ?></th>
57
- <th scope="col"><?php _e("Reccurrence","bkpwp"); ?></th>
58
- <th style="text-align: center;" colspan="3" scope="col"><?php _e("Action","bkpwp"); ?></th>
59
- </tr>
60
- </thead>
61
- <tbody id="the-list">
62
- <?php
63
- $alternate = "alternate";
64
- $i=1;
65
- foreach ($schedules as $options) {
66
- $timestamp = wp_next_scheduled("bkpwp_schedule_bkpwp_hook",$options);
67
- if ($alternate == "") { $alternate = "alternate"; } else { $alternate = ""; }
68
- ?>
69
- <tr class="<?php echo $alternate; ?>">
70
- <th style="text-align: center;" scope="row"><?php
71
- $preset = $backups->bkpwp_get_preset($options['preset']);
72
- if (!empty($preset['bkpwp_preset_options']['bkpwp_lastrun'])) {
73
- echo date(get_option('date_format'),$preset['bkpwp_preset_options']['bkpwp_lastrun'])." ".date("H:i",$preset['bkpwp_preset_options']['bkpwp_lastrun']);
74
- } else {
75
- _e("Not Yet","bkpwp");
76
- }
77
- ?></th>
78
- <td>
79
- <?php
80
- if (!empty($timestamp)) {
81
- echo date(get_option('date_format'),$timestamp)." ".date("H:i",$timestamp);
82
- }
83
- ?>
84
- </td>
85
- <td>
86
- <?php
87
- $now = time();
88
- $d = $timestamp - $now;
89
- if (!empty($timestamp)) { ?>
90
- <div id="countdowncontainer<?php echo $timestamp; ?>"></div>
91
- <script type="text/javascript">
92
- var futuredate=new cdtime("countdowncontainer<?php echo $timestamp; ?>", "<?php echo date("F j, Y H:i:s",$timestamp); ?>")
93
- <?php
94
- if ($d > "90000") {
95
- ?>
96
- futuredate.displaycountdown("days", formatresultsd)
97
- <?php
98
- } else {
99
- ?>
100
- futuredate.displaycountdown("hours", formatresultsh)
101
- <?php
102
- }
103
- ?>
104
- </script>
105
- <?php } else {
106
- if ($options['status'] == "inactive") {
107
- _e("Backup inactive.","bkpwp");
108
- } else {
109
- _e("Backup done.","bkpwp");
110
- }
111
- } ?>
112
- </td>
113
- <td>
114
- <?php
115
- echo $options['preset'];
116
- ?>
117
- <a title="<?php _e("Recalculate Backup size","bkpwp"); ?>"
118
- href="javascript:void(0);"
119
- onclick="document.getElementById('bkpwp_preset').value='<?php echo $options['preset']; ?>'; bkpwp_js_loading('<?php _e("Calculating file sizes","bkpwp"); ?>'); calculate2(); return false;">&raquo;</a>
120
- </td>
121
- <td>
122
- <?php
123
- echo $options['info'];
124
- ?>
125
- </td>
126
- <td style="text-align: center;">
127
- <?php
128
- if (!empty($options['status'])) {
129
- if ($options['status'] == "inactive") {
130
- echo " <a href=\"admin.php?page=".$_REQUEST['page']."&amp;bkpwp_toggle_schedule_active=".$options['created']."\">".__("activate","bkpwp")."</a>";
131
- } else {
132
- echo " <a href=\"admin.php?page=".$_REQUEST['page']."&amp;bkpwp_toggle_schedule_active=".$options['created']."\">".__("deactivate","bkpwp")."</a>";
133
- }
134
- }
135
- ?>
136
- </td>
137
- <?php
138
- /*
139
- wishlist for 2.0
140
- if (!empty($options['status'])) {
141
- echo " <a href=\"admin.php?page=".$_REQUEST['page']."&amp;bkpwp_edit_schedule=".$i."\">".__("edit","bkpwp")."</a>";
142
- } */
143
- ?>
144
- <td style="text-align: center;">
145
- <?php
146
- echo " <a href=\"admin.php?page=".$_REQUEST['page']."&amp;bkpwp_delete_schedule=".$options['created']."\">".__("delete","bkpwp")."</a>";
147
- ?>
148
- </td>
149
- <?php
150
- ?>
151
- </tr>
152
- <?php
153
- if (!empty($options['status'])) {
154
- $i++;
155
- }
156
- }
157
- ?>
158
- </tbody>
159
- </table>
160
- <?php
161
- }
162
-
163
- $bkpwppath = get_option("bkpwppath");
164
- ?>
165
- <div class="wrap">
166
- <?php
167
- if (!empty($_REQUEST['bkpwp_delete_schedule'])) {
168
- ?>
169
- <div id="message" class="updated fade">
170
- <p><?php
171
- $schedule = new BKPWP_SCHEDULE();
172
- $ret = $schedule->bkpwp_delete_schedule_by_created($_REQUEST['bkpwp_delete_schedule']);
173
- if($ret == 1) {
174
- _e("Schedule deleted.","bkpwp");
175
- } else {
176
- _e("Schedule could not be deleted.","bkpwp");
177
- }
178
- ?></p>
179
- </div>
180
- <?php
181
- }
182
- if (!empty($_REQUEST['bkpwp_toggle_schedule_active'])) {
183
- ?>
184
- <div id="message" class="updated fade">
185
- <p><?php
186
- $schedule = new BKPWP_SCHEDULE();
187
- $ret = $schedule->bkpwp_toggle_schedule($_REQUEST['bkpwp_toggle_schedule_active']);
188
- if($ret) {
189
- _e("Schedule activity status set to","bkpwp");
190
- echo " <b>";
191
- if ($ret == "active") {
192
- _e("active","bkpwp");
193
- } else {
194
- _e("inactive","bkpwp");
195
- }
196
- echo "</b>";
197
- } else {
198
- _e("Schedule activity status could not be set","bkpwp");
199
- }
200
- ?></p>
201
- </div>
202
- <?php
203
- }
204
- if (!empty($_REQUEST['bkpwp_reset_schedules'])) {
205
- // for some reason wp_clear_scheduled_hook("bkpwp_schedule_bkpwp_hook") doesn't work
206
- //wp_clear_scheduled_hook("bkpwp_schedule_bkpwp_hook");
207
- $schedule = new BKPWP_SCHEDULE();
208
- $schedule->bkpwp_unset_schedules();
209
-
210
- delete_option("bkpwp_schedules");
211
- $options = new BKPWP_OPTIONS();
212
- $options->bkpwp_default_schedules();
213
- ?>
214
- <div id="message" class="updated fade">
215
- <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>
216
- </div>
217
- <?php
218
- }
219
- if (!empty($_REQUEST['bkpwp_test_schedule'])) {
220
- $schedule = new BKPWP_SCHEDULE();
221
- ?>
222
- <div id="message" class="updated fade">
223
- <p><?php
224
- if ($schedule->bkpwp_test_schedule()) {
225
- _e("A schedule without reccurrence for one single Database Backup has been set up
226
- and should execute with the first hit your Blog receives after 30 Seconds from now.","bkpwp");
227
- } else {
228
- _e("Testing schedules failed.","bkpwp");
229
- }
230
- ?></p>
231
- </div>
232
- <?php
233
- }
234
-
235
- if (!empty($_REQUEST['bkpwp_delete'])) {
236
- if (empty($_REQUEST['bkpwp_delete_now'])) {
237
- ?>
238
- <div id="message" class="updated fade">
239
- <p><?php _e("Do you want to delete the backup archive","bkpwp"); ?></p>
240
- <p>
241
- <?php
242
- echo base64_decode($_REQUEST['bkpwp_delete']);
243
- ?>
244
- <form name="form1" method="post" action="">
245
- <input type="hidden" name="bkpwp_delete" value="<?php echo $_REQUEST['bkpwp_delete']; ?>" />
246
- <input type="submit" name="bkpwp_delete_now" value="&raquo; <?php _e("go on, delete","bkpwp"); ?>" />
247
- </form>
248
- </p><br />
249
- </div><br />
250
- <?php
251
- } else {
252
- if(!eregi(get_option("bkpwppath"),base64_decode($_REQUEST['bkpwp_delete']))) {
253
- // must be one of those in here!
254
- return;
255
- }
256
- if (unlink(base64_decode($_REQUEST['bkpwp_delete']))) {
257
- ?>
258
- <div id="message" class="updated fade">
259
- <p><?php _e("Backup file deleted sucessfully","bkpwp"); ?>:</p>
260
- <p>
261
- <?php
262
- echo base64_decode($_REQUEST['bkpwp_delete']);
263
- ?>
264
- </p>
265
- </div><br />
266
- <?php
267
- } else {
268
- ?>
269
- <div id="message" class="updated fade">
270
- <p><?php _e("Backup file deletion failed","bkpwp"); ?>:</p>
271
- <p>
272
- <?php
273
- echo base64_decode($_REQUEST['bkpwp_delete']);
274
- ?>
275
- </p>
276
- </div><br />
277
- <?php
278
- }
279
- }
280
- }
281
-
282
- if (!empty($bkpwppath) && is_dir($bkpwppath)) {
283
- bkpwp_schedulelist($bkpwppath);
284
- }
285
-
286
- ?>
287
- </div>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
functions-interface.php DELETED
@@ -1,165 +0,0 @@
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_load_css_and_js() {
19
- echo "<style type='text/css'>
20
- h2 {
21
- padding-top: 20px;
22
- }
23
- legend {
24
- font-weight: bold;
25
- }
26
- input[type=submit] {
27
- cursor: pointer;
28
- }
29
- .error {
30
- color: red;
31
- }
32
- .success {
33
- color: green;
34
- }
35
- .bkpwp_manage_backups_newrow {
36
- background: #99FF66;
37
- }
38
- </style>
39
- ";
40
- ?>
41
- <script type="text/javascript">
42
-
43
- var startTime=new Date();
44
-
45
- function currentTime(){
46
- var a=Math.floor((new Date()-startTime)/100)/10;
47
- if (a%1==0) a+=".0";
48
- document.getElementById("endTime").innerHTML=a;
49
- }
50
-
51
- <!-- displays a loading animation while doing ajax requests -->
52
- function is_loading(divid) {
53
- document.getElementById(divid).style.display = 'block';
54
- document.getElementById(divid).innerHTML="<img src='<?php bloginfo("wpurl"); ?>/wp-content/plugins/backupwordpress/images/loading.gif' />";
55
- }
56
- </script>
57
-
58
- <script type="text/javascript">
59
-
60
- /***********************************************
61
- * Dynamic Countdown script- © Dynamic Drive (http://www.dynamicdrive.com)
62
- * This notice MUST stay intact for legal use
63
- * Visit http://www.dynamicdrive.com/ for this script and 100s more.
64
- ***********************************************/
65
-
66
- function cdtime(container, targetdate){
67
- if (!document.getElementById || !document.getElementById(container)) return
68
- this.container=document.getElementById(container)
69
- this.currentTime=new Date("<?php echo date("F j, Y H:i:s"); ?>")
70
- this.targetdate=new Date(targetdate)
71
- this.timesup=false
72
- this.updateTime()
73
- }
74
-
75
- cdtime.prototype.updateTime=function(){
76
- var thisobj=this
77
- this.currentTime.setSeconds(this.currentTime.getSeconds()+1)
78
- setTimeout(function(){thisobj.updateTime()}, 1000) //update time every second
79
- }
80
-
81
- cdtime.prototype.displaycountdown=function(baseunit, functionref){
82
- this.baseunit=baseunit
83
- this.formatresults=functionref
84
- this.showresults()
85
- }
86
-
87
- cdtime.prototype.showresults=function(){
88
- var thisobj=this
89
-
90
-
91
- var timediff=(this.targetdate-this.currentTime)/1000 //difference btw target date and current date, in seconds
92
- if (timediff<0){ //if time is up
93
- this.timesup=true
94
- this.container.innerHTML=this.formatresults()
95
- return
96
- }
97
- var oneMinute=60 //minute unit in seconds
98
- var oneHour=60*60 //hour unit in seconds
99
- var oneDay=60*60*24 //day unit in seconds
100
- var dayfield=Math.floor(timediff/oneDay)
101
- var hourfield=Math.floor((timediff-dayfield*oneDay)/oneHour)
102
- var minutefield=Math.floor((timediff-dayfield*oneDay-hourfield*oneHour)/oneMinute)
103
- var secondfield=Math.floor((timediff-dayfield*oneDay-hourfield*oneHour-minutefield*oneMinute))
104
- if (this.baseunit=="hours"){ //if base unit is hours, set "hourfield" to be topmost level
105
- hourfield=dayfield*24+hourfield
106
- dayfield="n/a"
107
- }
108
- else if (this.baseunit=="minutes"){ //if base unit is minutes, set "minutefield" to be topmost level
109
- minutefield=dayfield*24*60+hourfield*60+minutefield
110
- dayfield=hourfield="n/a"
111
- }
112
- else if (this.baseunit=="seconds"){ //if base unit is seconds, set "secondfield" to be topmost level
113
- var secondfield=timediff
114
- dayfield=hourfield=minutefield="n/a"
115
- }
116
- this.container.innerHTML=this.formatresults(dayfield, hourfield, minutefield, secondfield)
117
- setTimeout(function(){thisobj.showresults()}, 1000) //update results every second
118
- }
119
-
120
- /////CUSTOM FORMAT OUTPUT FUNCTIONS BELOW//////////////////////////////
121
-
122
- //Create your own custom format function to pass into cdtime.displaycountdown()
123
- //Use arguments[0] to access "Days" left
124
- //Use arguments[1] to access "Hours" left
125
- //Use arguments[2] to access "Minutes" left
126
- //Use arguments[3] to access "Seconds" left
127
-
128
- //The values of these arguments may change depending on the "baseunit" parameter of cdtime.displaycountdown()
129
- //For example, if "baseunit" is set to "hours", arguments[0] becomes meaningless and contains "n/a"
130
- //For example, if "baseunit" is set to "minutes", arguments[0] and arguments[1] become meaningless etc
131
-
132
-
133
- function formatresultsh(){
134
- if (this.timesup==false){//if target date/time not yet met
135
- var displaystring=arguments[1]+" h "+arguments[2]+"' "+arguments[3]+"''"
136
- } else { //else if target date/time met
137
- var displaystring = "<?php _e("scheduling...","bkpwp");?>"
138
- }
139
- return displaystring
140
- }
141
-
142
- function formatresultsd(){
143
- if (this.timesup==false){//if target date/time not yet met
144
- var displaystring=arguments[0]+" days "+arguments[1]+"h"
145
- } else { //else if target date/time met
146
- var displaystring = "<?php _e("scheduling...","bkpwp");?>"
147
- }
148
- return displaystring
149
- }
150
-
151
- function formatresultsdh(){
152
- if (this.timesup==false){//if target date/time not yet met
153
- var displaystring=arguments[0]+" days "+arguments[1]+"h "+arguments[2]+"' "+arguments[3]+"''"
154
- } else { //else if target date/time met
155
- var displaystring = "<?php _e("scheduling...","bkpwp");?>"
156
- }
157
- return displaystring
158
- }
159
-
160
- </script>
161
-
162
-
163
- <?php
164
- }
165
- ?>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
functions.php DELETED
@@ -1,387 +0,0 @@
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_reccurrences");
25
- delete_option("bkpwp_calculation");
26
- delete_option("bkpwp_listmax_backups");
27
- delete_option("bkpwp_automail");
28
- delete_option("bkpwp_automail_maxsize");
29
- delete_option("bkpwp_status");
30
- delete_option("bkpwp_status_config");
31
-
32
- // configuration options to keep
33
- //delete_option("bkpwp_excludelists");
34
- //delete_option("bkpwp_max_backups");
35
- //delete_option("bkpwp_automail_address");
36
- //delete_option("bkpwp_automail_receiver");
37
- //delete_option("bkpwp_automail_from");
38
- }
39
-
40
- function bkpwp_setup() {
41
- if(current_user_can('manage bkpwp')) {
42
-
43
- $locale = get_locale();
44
- $mofile = dirname(__FILE__) . "/locale/".$locale.".mo";
45
- load_textdomain('bkpwp', $mofile);
46
-
47
- get_currentuserinfo();
48
- $options = new BKPWP_OPTIONS();
49
- $options->bkpwp_handle_modeswitch();
50
- }
51
- }
52
-
53
- function bkpwp_load_menu_page() {
54
- if (!empty($_REQUEST['page']) && file_exists(BKPWP_PLUGIN_PATH."bkpwp-pages/".$_REQUEST['page'].".php")) {
55
- include_once(BKPWP_PLUGIN_PATH."bkpwp-pages/".$_REQUEST['page'].".php");
56
- } else {
57
- include_once(BKPWP_PLUGIN_PATH."bkpwp-pages/bkpwp_manage_backups.php");
58
- }
59
- include_once(BKPWP_PLUGIN_PATH."bkpwp-pages/bkpwp_footer.php");
60
- }
61
-
62
- function bkpwp_add_menu() {
63
- $interface = new BKPWP_INTERFACE();
64
- $interface->menu();
65
- }
66
-
67
- function bkpwp_help_zeitgeist() {
68
- $options = new BKPWP_OPTIONS();
69
- ?>
70
- <div id="zeitgeist">
71
- <b><?php _e("BackUpWordPress Help Index","bkpwp"); ?></b>
72
- <p>
73
- <?php _e("Looking for a less komplex Solution? Please swith to ","bkpwp"); ?>
74
- <?php if (!$options->bkpwp_easy_mode()) { ?>
75
- <a href="admin.php?page=<?php echo $_REQUEST['page']; ?>&bkpwp_modeswitch=1"><?php _e("EasyMode","bkpwp"); ?> &raquo;</a>
76
- <?php } else { ?>
77
- <a href="admin.php?page=<?php echo $_REQUEST['page']; ?>&bkpwp_modeswitch=1"><?php _e("AdvancedMode","bkpwp"); ?> &raquo;</a>
78
- <?php } ?>
79
- </p>
80
- <p>
81
- <ul>
82
- <li><a href="admin.php?page=bkpwp_help#help_manage_backups"><?php _e("Manage Backups","bkpwp"); ?></a></li>
83
- <li><a href="admin.php?page=bkpwp_help#help_manage_presets"><?php _e("Manage Backup Presets","bkpwp"); ?></a></li>
84
- <li><a href="admin.php?page=bkpwp_help#help_manage_schedules"><?php _e("Manage Backup Schedules","bkpwp"); ?></a></li>
85
- <li><a href="admin.php?page=bkpwp_help#help_options"><?php _e("Options","bkpwp"); ?></a></li>
86
- </ul>
87
- </p>
88
- </div>
89
- <?php
90
- }
91
-
92
- function bkpwp_check_unfinished_backup() {
93
- $status = get_option("bkpwp_status");
94
- if (!empty($status)) {
95
- if (!is_dir(get_option("bkpwppath")."/".$status['name'])) {
96
- return false;
97
- }
98
- if (($status['time']-5) < time()) {
99
- return true;
100
- }
101
- }
102
- return false;
103
- }
104
-
105
- function bkpwp_proceed_unfinished() {
106
- // no unfinished backup
107
- if(!bkpwp_check_unfinished_backup()) {
108
- return;
109
- }
110
-
111
- $status = get_option("bkpwp_status");
112
-
113
- // no working directory
114
- if (!is_dir(get_option("bkpwppath")."/".$status['name'])) {
115
- return;
116
- }
117
- // wait a little
118
- $timeout = ini_get("max_execution_time")-5;
119
- if (($status['time']+$timeout) > time()) {
120
- return;
121
- }
122
-
123
- // okay, schedule that one for finishing up
124
- if (!wp_next_scheduled('bkpwp_finish_bkpwp_hook', $status)) {
125
- wp_schedule_single_event(time(), 'bkpwp_finish_bkpwp_hook', $status);
126
- return;
127
- }
128
- }
129
-
130
- function bkpwp_date_diff($earlierDate, $laterDate) {
131
- //returns an array of numeric values representing days, hours, minutes & seconds respectively
132
- $ret=array('days'=>0,'hours'=>0,'minutes'=>0,'seconds'=>0);
133
-
134
- $totalsec = $laterDate - $earlierDate;
135
- if ($totalsec >= 86400) {
136
- $ret['days'] = floor($totalsec/86400);
137
- $totalsec = $totalsec % 86400;
138
- }
139
- if ($totalsec >= 3600) {
140
- $ret['hours'] = floor($totalsec/3600);
141
- $totalsec = $totalsec % 3600;
142
- }
143
- if ($totalsec >= 60) {
144
- $ret['minutes'] = floor($totalsec/60);
145
- }
146
- $ret['seconds'] = $totalsec % 60;
147
- return $ret;
148
- }
149
-
150
- function bkpwp_latest_activity() {
151
- if(current_user_can('manage bkpwp')) {
152
- echo "<h3>".__("BackUpWordPress","bkpwp")." <a href=\"admin.php?page=backupwordpress/backupwordpress.php\">&raquo;</a></h3>";
153
- echo "<p><a href=\"http://wordpress.designpraxis.at/\">".__("Check for a new version of BackUpWordPress!","bkpwp")."</a></p>";
154
- if (bkpwp_check_unfinished_backup()) {
155
- echo "<span style=\"color:red\">".__("You have unfinished Backups!","bkpwp")." <a href=\"admin.php?page=backupwordpress/backupwordpress.php\">".__("Please finish them manually","bkpwp")." &raquo;</a></span>";
156
- }
157
- echo "<p><b>".__("Latest Backups","bkpwp")."</b>:</p>";
158
- $backup = new BKPWP_MANAGE();
159
- $backups = $backup->bkpwp_get_backups();
160
- if(count($backups) > 0) {
161
- echo "<ul style=\"list-style: none;\">";
162
- $i=0;
163
- foreach ($backups as $f) {
164
- if (!file_exists($f['file'])) {
165
- continue;
166
- }
167
- $info = new BKPWP_BACKUP_ARCHIVE();
168
- $info = $info->bkpwp_view_backup_info(base64_encode($f['file']),1);
169
- echo "<li><a href=\"admin.php?page=backupwordpress/backupwordpress.php&amp;bkpwp_download=".base64_encode($f['file'])."\"><img src=\"".get_bloginfo("wpurl")."/wp-content/plugins/backupwordpress/images/disk.png\" alt=\"download\" title=\"Download Backup\" /></a> ";
170
- echo date(get_option('date_format'),filemtime($f['file']))." ".date("H:i",filemtime($f['file']));
171
- echo ": ";
172
- echo "<b>".$info['filesize']."</b> ";
173
- echo "</li>";
174
- $i++;
175
- if ($i > 2) { break; }
176
- }
177
- echo "</ul>";
178
- }
179
-
180
- $schedules = get_option("bkpwp_schedules");
181
- if(count($schedules) < 1) { return; }
182
- echo "<b>".__("Next scheduled Backup","bkpwp")."</b>: ";
183
- $sarray = array();
184
- foreach ($schedules as $options) {
185
- if ($options['status'] == "active") {
186
- $timestamp = wp_next_scheduled("bkpwp_schedule_bkpwp_hook",$options);
187
- $sarray[$timestamp] = $options['info'];
188
- }
189
- }
190
- if(count($sarray) < 1) { echo __("Schedules inactive","bkpwp"); }
191
- arsort ($sarray);
192
- foreach ($sarray as $key => $value) {
193
- echo $value;
194
- ?>
195
- <div id="countdowncontainer<?php echo $key; ?>"></div>
196
- <script type="text/javascript">
197
- var futuredate=new cdtime("countdowncontainer<?php echo $key; ?>", "<?php echo date("F j, Y H:i:s",$key); ?>")
198
- futuredate.displaycountdown("days", formatresultsdh)
199
- </script>
200
- <?php
201
- break;
202
- }
203
- }
204
- }
205
-
206
- function bkpwp_conform_dir($dir,$rel=false) {
207
- $dir = str_replace("\\","/",$dir);
208
- if (substr($dir,-1) == "/") {
209
- $dir = substr($dir,0,-1);
210
- }
211
- if ($rel == true) {
212
- $dir = str_replace(bkpwp_conform_dir(ABSPATH),"",$dir);
213
- }
214
- return $dir;
215
- }
216
-
217
- function bkpwp_size_readable($size, $unit = null, $retstring = null, $si = true) {
218
- // Units
219
- if ($si === true) {
220
- $sizes = array('B', 'kB', 'MB', 'GB', 'TB', 'PB');
221
- $mod = 1000;
222
- } else {
223
- $sizes = array('B', 'KiB', 'MiB', 'GiB', 'TiB', 'PiB');
224
- $mod = 1024;
225
- }
226
- $ii = count($sizes) - 1;
227
-
228
- // Max unit
229
- $unit = array_search((string) $unit, $sizes);
230
- if ($unit === null || $unit === false) {
231
- $unit = $ii;
232
- }
233
-
234
- // Return string
235
- if ($retstring === null) {
236
- $retstring = '%01.2f %s';
237
- }
238
-
239
- // Loop
240
- $i = 0;
241
- while ($unit != $i && $size >= 1024 && $i < $ii) {
242
- $size /= $mod;
243
- $i++;
244
- }
245
-
246
- return sprintf($retstring, $size, $sizes[$i]);
247
- }
248
-
249
- function bkpwp_ajax_create($preset="") {
250
- $backup = new BKPWP_BACKUP();
251
- $backup->preset = new BKPWP_MANAGE();
252
- $preset = $backup->preset->bkpwp_get_preset($preset);
253
- $preset['bkpwp_schedule'] = __("manually","bkpwp");
254
- $ret = $backup->bkpwp_do_backup($preset);
255
- return $ret;
256
- }
257
-
258
- function bkpwp_ajax_view_backup($backupfile) {
259
- $backup = new BKPWP_BACKUP_ARCHIVE();
260
- $ret = $backup->bkpwp_view_backup_info($backupfile);
261
- return $ret;
262
- }
263
-
264
- function bkpwp_ajax_view_preset($preset="") {
265
- $backup = new BKPWP_MANAGE();
266
- $preset = $backup->bkpwp_get_preset($preset);
267
- $ret = $backup->bkpwp_view_preset($preset);
268
- return $ret;
269
- }
270
-
271
- function bkpwp_ajax_load_preset($preset="") {
272
- $backup = new BKPWP_MANAGE();
273
- $preset = $backup->bkpwp_get_preset($preset);
274
- $ret = $backup->bkpwp_load_preset($preset);
275
- return $ret;
276
- }
277
-
278
- function bkpwp_ajax_shownobfiles($excludelist) {
279
- $options = new BKPWP_OPTIONS();
280
- $ret = $options->bkpwp_ajax_shownobfiles($excludelist);
281
- return $ret;
282
- }
283
-
284
- function bkpwp_ajax_calculater($preset="") {
285
- $backup = new BKPWP_BACKUP();
286
- $backup->preset = new BKPWP_MANAGE();
287
- $preset = $backup->preset->bkpwp_get_preset($preset);
288
- $ret = $backup->bkpwp_calculate($preset);
289
- return $ret;
290
- }
291
-
292
- function bkpwp_more_reccurences($recc) {
293
- $bkpwp_reccurrences = get_option("bkpwp_reccurrences");
294
- if(empty($bkpwp_reccurrences)) {
295
- // scheduling reccurrences
296
- $bkpwp_reccurrences = array(
297
- 'bkpwp_weekly' => array('interval' => 604800, 'display' => 'every week'),
298
- 'bkpwp_daily' => array('interval' => 86400, 'display' => 'every day')
299
- );
300
- update_option("bkpwp_reccurrences",$bkpwp_reccurrences);
301
- $bkpwp_reccurrences = get_option("bkpwp_reccurrences");
302
- }
303
- foreach ($bkpwp_reccurrences as $key => $value) {
304
- $recc[$key] = $value;
305
- }
306
- return $recc;
307
- }
308
-
309
- function bkpwp_finish_bkpwp($status) {
310
- $backup = new BKPWP_BACKUP();
311
- $backup->bkpwp_do_backup("",$status);
312
- }
313
-
314
- function bkpwp_schedule_bkpwp($options) {
315
-
316
- $backup = new BKPWP_BACKUP();
317
- $backup->preset = new BKPWP_MANAGE();
318
- $preset = $backup->preset->bkpwp_get_preset($options);
319
- $preset['bkpwp_schedule'] = "scheduled";
320
- $backup->bkpwp_do_backup($preset);
321
- $schedules['lastrun'] = date("Y-m-d H:i");
322
- }
323
-
324
- function bkpwp_download_files() {
325
- if (!empty($_REQUEST['bkpwp_download'])) {
326
- if (!current_user_can("download_backups")) {
327
- die("Permission denied");
328
- }
329
- $file = base64_decode($_REQUEST['bkpwp_download']);
330
- bkpwp_send_file($file);
331
- }
332
- }
333
-
334
- function bkpwp_send_file($path) {
335
- session_write_close();
336
- ob_end_clean();
337
- if (!is_file($path) || connection_status()!=0)
338
- return(FALSE);
339
-
340
- //to prevent long file from getting cut off from //max_execution_time
341
-
342
- @set_time_limit(0);
343
-
344
- $name=basename($path);
345
-
346
- //filenames in IE containing dots will screw up the
347
- //filename unless we add this
348
-
349
- if (strstr($_SERVER['HTTP_USER_AGENT'], "MSIE"))
350
- $name = preg_replace('/\./', '%2e', $name, substr_count($name, '.') - 1);
351
-
352
- //required, or it might try to send the serving //document instead of the file
353
-
354
- header("Cache-Control: ");
355
- header("Pragma: ");
356
- header("Content-Type: application/octet-stream");
357
- header("Content-Length: " .(string)(filesize($path)) );
358
- header('Content-Disposition: attachment; filename="'.$name.'"');
359
- header("Content-Transfer-Encoding: binary\n");
360
-
361
- if($file = fopen($path, 'rb')){
362
- while( (!feof($file)) && (connection_status()==0) ){
363
- print(fread($file, 1024*8));
364
- flush();
365
- }
366
- fclose($file);
367
- }
368
- return((connection_status()==0) and !connection_aborted());
369
- }
370
-
371
- function bkpwp_security_check() {
372
- // secure the backup directory with .htaccess
373
- // deny from all
374
- $path = get_option("bkpwppath");
375
- if (empty($path)) { return; }
376
- $filename = $path."/.htaccess";
377
- if (!$handle = fopen($filename, 'w')) {
378
- echo "Cannot open file ($filename)";
379
- // should be checked at configuration
380
- }
381
- if (fwrite($handle, "deny from all") === FALSE) {
382
- echo "Cannot write to file ($filename)";
383
- // todo: warn the blog owner
384
- }
385
- fclose($handle);
386
- }
387
- ?>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
functions/backup.files.fallback.functions.php ADDED
@@ -0,0 +1,22 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * Fallback for creating zip archive if zip command is
5
+ * unnavailable.
6
+ *
7
+ * Uses the PCLZIP library that ships with WordPress
8
+ *
9
+ * @todo support zipArchive
10
+ * @param string $backup_tmp_dir
11
+ * @param string $backup_filepath
12
+ * @return void
13
+ */
14
+ function hmbkp_archive_files_fallback( $backup_tmp_dir, $backup_filepath ) {
15
+
16
+ // Try PCLZIP
17
+ require_once( ABSPATH . 'wp-admin/includes/class-pclzip.php' );
18
+
19
+ $archive = new PclZip( $backup_filepath );
20
+ $result = $archive->create( $backup_tmp_dir );
21
+
22
+ }
functions/backup.files.functions.php ADDED
@@ -0,0 +1,151 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * Copy the whole site to the temporary directory and
5
+ * then zip it all up
6
+ *
7
+ * @param string $backup_tmp_dir
8
+ * @param array $log
9
+ * @param string $backup_filename
10
+ * @return void
11
+ */
12
+ function hmbkp_backup_files( $backup_tmp_dir, $log, $backup_filename ) {
13
+
14
+ $backup_filepath = trailingslashit( hmbkp_path() ) . $backup_filename;
15
+ $wordpress_files = $backup_tmp_dir . '/wordpress_files';
16
+
17
+ if ( !is_dir( $wordpress_files ) ) :
18
+
19
+ if ( !mkdir( $wordpress_files, 0777 ) )
20
+ $log['logfile'][] = sprintf( __( 'The temporary directory %s could not be created', 'hmbkp' ), $wordpress_files );
21
+ else
22
+ $log['logfile'][] = sprintf( __( 'Temporary directory created', 'hmbkp' ), $wordpress_files );
23
+
24
+ hmbkp_write_log( $log );
25
+
26
+ endif;
27
+
28
+ // Copy the whole site to the temporary directory
29
+ $files = hmbkp_ls( hmbkp_conform_dir( ABSPATH ) );
30
+
31
+ $files_copied = $subdirs_created = 0;
32
+ $i = 1;
33
+
34
+ foreach ( (array) $files as $f ) :
35
+
36
+ if ( is_dir( $f ) ) :
37
+
38
+ if ( !mkdir( $wordpress_files . hmbkp_conform_dir( $f, true ), 0755 ) ) :
39
+
40
+ if ( !is_dir( $wordpress_files . hmbkp_conform_dir( $f, true ) ) ) {
41
+ $log['logfile'][] = __( 'Failed to make directory', 'hmbkp' ) . ': ' . $f;
42
+ }
43
+
44
+ else
45
+ $subdirs_created++;
46
+
47
+ endif;
48
+
49
+ elseif ( file_exists( $f ) ) :
50
+
51
+ $files_copied++;
52
+
53
+ if ( file_exists( $wordpress_files . hmbkp_conform_dir( $f, true ) ) )
54
+ unlink( $wordpress_files . hmbkp_conform_dir( $f, true ) );
55
+
56
+ // Copy the file
57
+ if ( !copy( $f, $wordpress_files . hmbkp_conform_dir( $f, true ) ) )
58
+ $log['logfile'][] = __( 'Failed to copy file', 'hmbkp' ) . ': ' . $f;
59
+
60
+ endif;
61
+
62
+ $i++;
63
+ endforeach;
64
+
65
+ $log['logfile'][] = $subdirs_created . ' ' . __( 'temporary sub-directories copied sucessfully', 'hmbkp' );
66
+ $log['logfile'][] = $files_copied . ' ' . __( 'temporary files copied sucessfully', 'hmbkp' );
67
+
68
+ // Zip up the files
69
+ hmbkp_archive_files( $backup_tmp_dir, $backup_filepath );
70
+
71
+ // Make sure the archive exists
72
+ if ( !file_exists( $backup_filepath ) )
73
+ $log['logfile'][] = __( 'Failed to create backup archive', 'hmbkp' ) . ' ' . $backup_filename;
74
+
75
+ else
76
+ $log['logfile'][] = __( 'Archive created successfully:', 'hmbkp' ) . ' ' . $backup_filename;
77
+
78
+ $log['logfile'][] = count( hmbkp_rmdirtree( $backup_tmp_dir ) ) . ' ' . __( 'Temporary file and directories deleted successfully', 'hmbkp' );
79
+
80
+ hmbkp_write_log( $log );
81
+
82
+ }
83
+
84
+ /**
85
+ * Zip up all the files in the tmp directory.
86
+ *
87
+ * Attempts to use the shell zip command, if
88
+ * thats not available then it fallsback on
89
+ * PHP zip classes.
90
+ *
91
+ * @param string $backup_tmp_dir
92
+ * @param string $backup_filepath
93
+ * @return void
94
+ */
95
+ function hmbkp_archive_files( $backup_tmp_dir, $backup_filepath ) {
96
+
97
+ // Do we have the path to the zip command
98
+ if ( hmbkp_zip_path() )
99
+ shell_exec( 'cd ' . escapeshellarg( $backup_tmp_dir ) . ' && zip -r ' . escapeshellarg( $backup_filepath ) . ' ./' );
100
+
101
+ else
102
+ hmbkp_archive_files_fallback( $backup_tmp_dir, $backup_filepath );
103
+
104
+ }
105
+
106
+ /**
107
+ * Attempt to work out the path to the zip command
108
+ *
109
+ * Can be overridden by defining HMBKP_ZIP_PATH in
110
+ * wp-config.php.
111
+ *
112
+ * @return string $path on success, empty string on failure
113
+ */
114
+ function hmbkp_zip_path() {
115
+
116
+ $path = '';
117
+
118
+ // List of possible zip locations
119
+ $zip_locations = array(
120
+ 'zip',
121
+ '/usr/bin/zip'
122
+ );
123
+
124
+ // Allow the path to be overridden
125
+ if ( defined( 'HMBKP_ZIP_PATH' ) && HMBKP_ZIP_PATH )
126
+ array_unshift( $zip_locations, HMBKP_ZIP_PATH );
127
+
128
+ // If we don't have a path set
129
+ if ( !$path = get_option( 'hmbkp_zip_path' ) ) :
130
+
131
+ // Try to find out where zip is
132
+ foreach ( $zip_locations as $location )
133
+ if ( shell_exec( 'which ' . $location ) )
134
+ $path = $location;
135
+
136
+ // Save it for later
137
+ if ( $path )
138
+ update_option( 'hmbkp_zip_path', $path );
139
+
140
+ endif;
141
+
142
+ // Check again incase the saved path has stopped working for some reason
143
+ if ( $path && !shell_exec( 'which ' . $path ) ) :
144
+ delete_option( 'hmbkp_zip_path' );
145
+ return hmbkp_zip_path();
146
+
147
+ endif;
148
+
149
+ return $path;
150
+
151
+ }
functions/backup.functions.php ADDED
@@ -0,0 +1,182 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * Backup database and files
5
+ *
6
+ * Creates a temporary directory containing a copy of all files
7
+ * and a dump of the database. Then zip that up and delete the temporary files
8
+ *
9
+ * @uses hmbkp_backup_mysql
10
+ * @uses hmbkp_backup_files
11
+ * @uses hmbkp_delete_old_backups
12
+ */
13
+ function hmbkp_do_backup() {
14
+
15
+ $time_start = microtime( true );
16
+
17
+ $log['filename'] = date( 'Y-m-d-H-i-s' ) . '.zip';
18
+
19
+ update_option( 'hmbkp_running', $log['filename'] );
20
+
21
+ // Raise the memory limit
22
+ ini_set( 'memory_limit', apply_filters( 'admin_memory_limit', '256M' ) );
23
+
24
+ // start the log
25
+ $log['logfile'] = array();
26
+
27
+ // Create a temporary directory for this backup
28
+ $backup_tmp_dir = hmbkp_create_tmp_dir( $log );
29
+
30
+ // Backup database
31
+ hmbkp_backup_mysql( $backup_tmp_dir, $log );
32
+
33
+ // Backup files
34
+ hmbkp_backup_files( $backup_tmp_dir, $log, $log['filename'] );
35
+
36
+ // Delete any old backup files
37
+ hmbkp_delete_old_backups( $log );
38
+
39
+ $log['logfile'][] = sprintf( __( 'Backup done at %d', 'hmbkp' ), hmbkp_timestamp() );
40
+ $log['logfile'][] = sprintf( __( 'Backup was running for %d Seconds', 'hmbkp' ), round( microtime( true ) - $time_start, 2 ) );
41
+
42
+ hmbkp_write_log( $log );
43
+
44
+ delete_option( 'hmbkp_running' );
45
+
46
+ }
47
+
48
+ /**
49
+ * Deletes old backup files
50
+ *
51
+ * @see hmbkp_set_defaults for default number of backups
52
+ * to be kept.
53
+ */
54
+ function hmbkp_delete_old_backups( $log ) {
55
+
56
+ $files = hmbkp_get_backups();
57
+
58
+ if ( count( $files ) <= get_option( 'hmbkp_max_backups' ) )
59
+ return;
60
+
61
+ $unlinkcount = 0;
62
+
63
+ foreach ( $files as $key => $f ) :
64
+
65
+ if ( ( $key + 1 ) > get_option( 'hmbkp_max_backups' ) ) :
66
+ hmbkp_delete_backup( base64_encode( $f['file'] ) );
67
+ $unlinkcount++;
68
+
69
+ endif;
70
+
71
+ endforeach;
72
+
73
+ if ( $unlinkcount )
74
+ $log['logfile'][] = sprintf( __( '%d old backup deleted.', 'hmbkp' ), $unlinkcount );
75
+
76
+ else
77
+ $log['logfile'][] = __( 'No old backups to delete.', 'hmbkp' );
78
+
79
+ }
80
+
81
+ /**
82
+ * Returns an array of backup files
83
+ *
84
+ * @todo support when backups directory changes
85
+ */
86
+ function hmbkp_get_backups() {
87
+
88
+ $files = array();
89
+
90
+ $hmbkp_path = hmbkp_path();
91
+
92
+ if ( !is_writable( $hmbkp_path ) )
93
+ return;
94
+
95
+ if ( $handle = opendir( $hmbkp_path ) ) :
96
+
97
+ while ( false !== ( $file = readdir( $handle ) ) )
98
+ if ( ( substr( $file, 0, 1 ) != '.' ) && !is_dir( trailingslashit( $hmbkp_path ) . $file ) )
99
+ $files[] = array( 'file' => trailingslashit( $hmbkp_path ) . $file, 'filename' => $file);
100
+
101
+ closedir( $handle );
102
+
103
+ endif;
104
+
105
+ if ( count( $files ) < 1 )
106
+ return;
107
+
108
+ foreach ( $files as $key => $row )
109
+ $filename[$key] = $row['filename'];
110
+
111
+ array_multisort( $filename, SORT_DESC, $files );
112
+
113
+ return $files;
114
+ }
115
+
116
+ /**
117
+ * Fire the backup on schedule
118
+ *
119
+ * @param mixed $options
120
+ */
121
+ function hmbkp_schedule_backup( $options ) {
122
+ hmbkp_do_backup();
123
+ }
124
+
125
+ /**
126
+ * Delete a backup file and it's associated logs
127
+ *
128
+ * @param $file base64 encoded filename
129
+ */
130
+ function hmbkp_delete_backup( $file ) {
131
+
132
+ $file = base64_decode( $file );
133
+
134
+ // Delete the file
135
+ if ( strpos( $file, hmbkp_path() ) !== false || strpos( $file, WP_CONTENT_DIR . '/backups' ) !== false )
136
+ unlink( $file );
137
+
138
+ // Handle changed backups directory
139
+ $log = str_replace( hmbkp_path(), trailingslashit( hmbkp_path() ) . 'logs/', $file );
140
+ $log = str_replace( WP_CONTENT_DIR . '/backups', WP_CONTENT_DIR . '/backups/logs/', $log );
141
+
142
+ // Delete the log
143
+ if ( file_exists( $log . '.log' ) )
144
+ unlink( $log . '.log' );
145
+
146
+ // Delete the mysqldump log
147
+ if ( file_exists( str_replace( '.zip', '', $log ) . '-mysqldump.log' ) )
148
+ unlink( str_replace( '.zip', '', $log ) . '-mysqldump.log' );
149
+
150
+ }
151
+
152
+
153
+ function hmbkp_create_tmp_dir( $log ) {
154
+
155
+ // Temporary directory name
156
+ $backup_tmp_dir = trailingslashit( hmbkp_path() ) . date( 'Y-m-d-H-i-s' );
157
+
158
+ $log['logfile'][] = __( 'Backup starting at', 'hmbkp' ) . ' ' . hmbkp_timestamp() ;
159
+
160
+ // Create the temp backup directory
161
+ if ( !is_dir( $backup_tmp_dir ) ) :
162
+
163
+ if ( !mkdir( $backup_tmp_dir, 0777 ) )
164
+ $log['logfile'][] = sprintf( __( 'Backup temporary directory %s could not be created', 'hmbkp' ), $backup_tmp_dir );
165
+
166
+ else
167
+ $log['logfile'][] = sprintf( __( 'Backup temporary directory %s created', 'hmbkp' ), $backup_tmp_dir );
168
+
169
+ else :
170
+ $log['logfile'][] = sprintf( __( 'Backup temporary directory %s exists.', 'hmbkp' ), $backup_tmp_dir );
171
+
172
+ endif;
173
+
174
+ hmbkp_write_log( $log );
175
+
176
+ return $backup_tmp_dir;
177
+
178
+ }
179
+
180
+ function hmbkp_is_in_progress() {
181
+ return (bool) get_option( 'hmbkp_running' );
182
+ }
functions/backup.log.functions.php ADDED
@@ -0,0 +1,59 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * hmbkp_write_log function.
5
+ *
6
+ * @param array $log
7
+ * @param string $return. (default: "")
8
+ */
9
+ function hmbkp_write_log( &$log ) {
10
+
11
+ global $wp_version;
12
+
13
+ $time = hmbkp_timestamp();
14
+
15
+ if ( !is_array( $log ) )
16
+ return;
17
+
18
+ $logdir = trailingslashit( hmbkp_path() ) . 'logs';
19
+
20
+ if ( !is_dir( $logdir ) )
21
+ mkdir( $logdir, 0755 );
22
+
23
+ $logname = $logdir . '/' . $log['filename'] . '.log';
24
+ $logfile = '';
25
+
26
+ if ( !file_exists( $logname ) ) :
27
+
28
+ // Write some environmental information for debugging purposes
29
+ $logfile .= "WordPress Version: " . $wp_version . "\n";
30
+
31
+ endif;
32
+
33
+ if ( is_array( $log['logfile'] ) ) :
34
+
35
+ foreach ( $log['logfile'] as $l ) :
36
+
37
+ if ( is_array( $l ) )
38
+ $l = serialize( $l );
39
+
40
+ $logfile .= "## " . hmbkp_timestamp() . ' : ' . $l . "\n";
41
+
42
+ endforeach;
43
+
44
+ // Write the log
45
+ if ( !$handle = fopen( $logname, 'a' ) )
46
+ error_log( 'Logfile could not be opened for writing: ' . $logname );
47
+
48
+ if ( !fwrite( $handle, $logfile ) )
49
+ error_log( 'Logfile not writable: ' . $logname );
50
+
51
+ fclose( $handle );
52
+
53
+ $log['logfile'] = array();
54
+
55
+ return true;
56
+
57
+ endif;
58
+
59
+ }
functions/backup.mysql.fallback.functions.php ADDED
@@ -0,0 +1,308 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * hmbkp_backquote function.
5
+ *
6
+ * Add backquotes to tables and db-names inSQL queries. Taken from phpMyAdmin.
7
+ *
8
+ * @access public
9
+ * @param mixed $a_name
10
+ * @return void
11
+ */
12
+ function hmbkp_backquote( $a_name ) {
13
+
14
+ if ( !empty( $a_name ) && $a_name != '*' ) :
15
+
16
+ if ( is_array( $a_name ) ) :
17
+ $result = array();
18
+ reset( $a_name );
19
+
20
+ while ( list( $key, $val ) = each( $a_name ) )
21
+ $result[$key] = '`' . $val . '`';
22
+
23
+ return $result;
24
+
25
+ else :
26
+ return '`' . $a_name . '`';
27
+
28
+ endif;
29
+
30
+ else :
31
+ return $a_name;
32
+ endif;
33
+ }
34
+
35
+ /**
36
+ * hmbkp_make_sql function.
37
+ *
38
+ * Reads the Database table in $table and creates
39
+ * SQL Statements for recreating structure and data
40
+ * Taken partially from phpMyAdmin and partially from
41
+ * Alain Wolf, Zurich - Switzerland
42
+ * Website: http://restkultur.ch/personal/wolf/scripts/db_backup/
43
+ *
44
+ * @access public
45
+ * @param string $path
46
+ * @param mixed $sql_file
47
+ * @param mixed $table
48
+ * @param mixed $log
49
+ * @return void
50
+ */
51
+ function hmbkp_make_sql( $path, $sql_file, $table, $log ) {
52
+
53
+ // Add SQL statement to drop existing table
54
+ $sql_file = "\n";
55
+ $sql_file .= "\n";
56
+ $sql_file .= "#\n";
57
+ $sql_file .= "# Delete any existing table " . hmbkp_backquote( $table ) . "\n";
58
+ $sql_file .= "#\n";
59
+ $sql_file .= "\n";
60
+ $sql_file .= "DROP TABLE IF EXISTS " . hmbkp_backquote( $table ) . ";\n";
61
+
62
+ /* Table Structure */
63
+
64
+ // Comment in SQL-file
65
+ $sql_file .= "\n";
66
+ $sql_file .= "\n";
67
+ $sql_file .= "#\n";
68
+ $sql_file .= "# Table structure of table " . hmbkp_backquote( $table ) . "\n";
69
+ $sql_file .= "#\n";
70
+ $sql_file .= "\n";
71
+
72
+ // Get table structure
73
+ $query = 'SHOW CREATE TABLE ' . hmbkp_backquote( $table );
74
+ $result = mysql_query( $query, $GLOBALS['db_connect'] );
75
+
76
+ if ( $result == false ) :
77
+ $log['logfile'][] = __( 'Error getting table structure of ', 'hmbkp' ) . $table . '! ' . mysql_errno() . ': ' . mysql_error();
78
+ hmbkp_write_log( $log );
79
+
80
+ else :
81
+ if ( mysql_num_rows( $result ) > 0 ) :
82
+ $sql_create_arr = mysql_fetch_array( $result );
83
+ $sql_file .= $sql_create_arr[1];
84
+ endif;
85
+
86
+ mysql_free_result( $result );
87
+ $sql_file .= ' ;';
88
+
89
+ endif;
90
+
91
+ /* Table Contents */
92
+
93
+ // Get table contents
94
+ $query = 'SELECT * FROM ' . hmbkp_backquote( $table );
95
+ $result = mysql_query( $query, $GLOBALS['db_connect'] );
96
+
97
+ if ( $result == false ) :
98
+ $log['logfile'][] = __( 'Error getting records of ', 'hmbkp' ) . $table . '! ' . mysql_errno() . ': ' . mysql_error();
99
+ hmbkp_write_log( $log );
100
+
101
+ else :
102
+ $fields_cnt = mysql_num_fields( $result );
103
+ $rows_cnt = mysql_num_rows( $result );
104
+ endif;
105
+
106
+ // Comment in SQL-file
107
+ $sql_file .= "\n";
108
+ $sql_file .= "\n";
109
+ $sql_file .= "#\n";
110
+ $sql_file .= "# Data contents of table " . $table . " (" . $rows_cnt . " records)\n";
111
+ $sql_file .= "#\n";
112
+
113
+ // Checks whether the field is an integer or not
114
+ for ( $j = 0; $j < $fields_cnt; $j++ ) :
115
+ $field_set[$j] = hmbkp_backquote( mysql_field_name( $result, $j ) );
116
+ $type = mysql_field_type( $result, $j );
117
+
118
+ if ( $type == 'tinyint' || $type == 'smallint' || $type == 'mediumint' || $type == 'int' || $type == 'bigint' ||$type == 'timestamp')
119
+ $field_num[$j] = true;
120
+ else
121
+ $field_num[$j] = false;
122
+
123
+ endfor;
124
+
125
+ // Sets the scheme
126
+ $entries = 'INSERT INTO ' . hmbkp_backquote($table) . ' VALUES (';
127
+ $search = array( '\x00', '\x0a', '\x0d', '\x1a' ); //\x08\\x09, not required
128
+ $replace = array( '\0', '\n', '\r', '\Z' );
129
+ $current_row = 0;
130
+ $batch_write = 0;
131
+
132
+ while ( $row = mysql_fetch_row( $result ) ) :
133
+ $current_row++;
134
+
135
+ // build the statement
136
+ for ( $j = 0; $j < $fields_cnt; $j++ ) :
137
+
138
+ if ( !isset($row[$j] ) ) :
139
+ $values[] = 'NULL';
140
+
141
+ elseif ( $row[$j] == '0' || $row[$j] != '' ) :
142
+
143
+ // a number
144
+ if ( $field_num[$j] )
145
+ $values[] = $row[$j];
146
+
147
+ else
148
+ $values[] = "'" . str_replace( $search, $replace, hmbkp_sql_addslashes( $row[$j] ) ) . "'";
149
+
150
+ else :
151
+ $values[] = "''";
152
+ endif;
153
+
154
+ endfor;
155
+
156
+ $sql_file .= " \n" . $entries . implode( ', ', $values ) . ") ;";
157
+
158
+ // write the rows in batches of 100
159
+ if ( $batch_write == 100 ) :
160
+ $batch_write = 0;
161
+ hmbkp_write_sql( $path, $sql_file, $log );
162
+ $sql_file = '';
163
+ endif;
164
+
165
+ $batch_write++;
166
+
167
+ unset( $values );
168
+
169
+ endwhile;
170
+
171
+ mysql_free_result( $result );
172
+
173
+ // Create footer/closing comment in SQL-file
174
+ $sql_file .= "\n";
175
+ $sql_file .= "#\n";
176
+ $sql_file .= "# End of data contents of table " . $table . "\n";
177
+ $sql_file .= "# --------------------------------------------------------\n";
178
+ $sql_file .= "\n";
179
+
180
+ hmbkp_write_sql( $path, $sql_file, $log );
181
+
182
+ }
183
+
184
+ /**
185
+ * hmbkp_sql_addslashes function.
186
+ *
187
+ * Better addslashes for SQL queries.
188
+ * Taken from phpMyAdmin.
189
+ *
190
+ * @access public
191
+ * @param string $a_string. (default: '')
192
+ * @param bool $is_like. (default: false)
193
+ * @return void
194
+ */
195
+ function hmbkp_sql_addslashes( $a_string = '', $is_like = false ) {
196
+
197
+ if ( $is_like )
198
+ $a_string = str_replace( '\\', '\\\\\\\\', $a_string );
199
+
200
+ else
201
+ $a_string = str_replace( '\\', '\\\\', $a_string );
202
+
203
+ $a_string = str_replace( '\'', '\\\'', $a_string );
204
+
205
+ return $a_string;
206
+ }
207
+
208
+ /**
209
+ * hmbkp_mysql function.
210
+ *
211
+ * @access public
212
+ * @param mixed $path
213
+ * @param mixed $log
214
+ * @return void
215
+ */
216
+ function hmbkp_backup_mysql_fallback( $path, $log ) {
217
+
218
+ if ( !$GLOBALS['db_connect'] = @mysql_pconnect( DB_HOST, DB_USER, DB_PASSWORD ) ) :
219
+ $log['logfile'][] = __( 'Could not connect to MySQL server! ', 'hmbkp' ) . mysql_error();
220
+ hmbkp_write_log( $log );
221
+ endif;
222
+
223
+ $log['logfile'][] = __( 'MySQL server connected successfully ', 'hmbkp' );
224
+ hmbkp_write_log( $log );
225
+
226
+ mysql_select_db( DB_NAME, $GLOBALS['db_connect'] );
227
+
228
+ // Begin new backup of MySql
229
+ $tables = mysql_list_tables( DB_NAME );
230
+
231
+ if ( !isset($tables) > 0 ) :
232
+ $log['logfile'][] = __( 'Could not select db ', 'hmbkp') . DB_NAME;
233
+ hmbkp_write_log( $log );
234
+ endif;
235
+
236
+ $sql_file = "# WordPress : " . get_bloginfo( 'url' ) . " MySQL database backup\n";
237
+ $sql_file .= "#\n";
238
+ $sql_file .= "# Generated: " . date( 'l j. F Y H:i T' ) . "\n";
239
+ $sql_file .= "# Hostname: " . DB_HOST . "\n";
240
+ $sql_file .= "# Database: " . hmbkp_backquote( DB_NAME ) . "\n";
241
+ $sql_file .= "# --------------------------------------------------------\n";
242
+
243
+ for ( $i = 0; $i < mysql_num_rows( $tables ); $i++ ) :
244
+
245
+ $curr_table = mysql_tablename( $tables, $i );
246
+
247
+ // Increase script execution time-limit to 15 min for every table.
248
+ if ( !ini_get( 'safe_mode' ) )
249
+ @set_time_limit( 15 * 60 );
250
+
251
+ // Create the SQL statements
252
+ $sql_file .= "# --------------------------------------------------------\n";
253
+ $sql_file .= "# Table: " . hmbkp_backquote( $curr_table ) . "\n";
254
+ $sql_file .= "# --------------------------------------------------------\n";
255
+ hmbkp_make_sql( $path, $sql_file, $curr_table, $log );
256
+
257
+ $log['logfile'][] = 'sql-dump for ' . $curr_table . ' created';
258
+ hmbkp_write_log( $log );
259
+ endfor;
260
+
261
+ if ( !file_exists( $path . '/wordpress.sql' ) )
262
+ $log['logfile'][] = __( 'SQL Dump could not be created.', 'hmbkp' );
263
+
264
+ else
265
+ $log['logfile'][] = __( 'SQL Dump created.', 'hmbkp' );
266
+
267
+ hmbkp_write_log( $log );
268
+
269
+ }
270
+
271
+ /**
272
+ * hmbkp_write_sql function.
273
+ *
274
+ * @param mixed $sqldir
275
+ * @param mixed $sql
276
+ * @param mixed $log
277
+ */
278
+ function hmbkp_write_sql( $sqldir, $sql, $log ) {
279
+
280
+ $sqlname = $sqldir . '/wordpress.sql';
281
+
282
+ // Actually write the sql file
283
+ if ( is_writable( $sqlname ) || !file_exists( $sqlname ) ) :
284
+
285
+ if ( !$handle = fopen( $sqlname, 'a' ) ) :
286
+ $log['logfile'][] = __( 'SQLfile could not be opened for writing: ', 'hmbkp' ) . $sqlname;
287
+ hmbkp_write_log( $log );
288
+ return;
289
+ endif;
290
+
291
+ if ( !fwrite( $handle, $sql ) ) :
292
+ $log['logfile'][] = __( 'SQLfile not writable: ', 'hmbkp' ) . $sqlname;
293
+ hmbkp_write_log( $log );
294
+ return;
295
+ endif;
296
+
297
+ $log['logfile'][] = __( 'successfully written to SQLfile: ', 'hmbkp' ) . $sqlname;
298
+ hmbkp_write_log( $log );
299
+ fclose( $handle );
300
+
301
+ return true;
302
+
303
+ else :
304
+ $log['logfile'][] = __( 'SQLfile not writable: ', 'hmbkp' ) . $sqlname;
305
+ hmbkp_write_log( $log );
306
+
307
+ endif;
308
+ }
functions/backup.mysql.functions.php ADDED
@@ -0,0 +1,84 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * Create the mysql backup
5
+ *
6
+ * Uses mysqldump if available, fallsback to PHP
7
+ * if not.
8
+ *
9
+ * @param string $backup_tmp_dir
10
+ * @param array $log
11
+ * @return void
12
+ */
13
+ function hmbkp_backup_mysql( $backup_tmp_dir, $log ) {
14
+
15
+ // Use mysqldump if we can
16
+ if ( hmbkp_mysqldump_path() )
17
+ shell_exec(
18
+ escapeshellarg( hmbkp_mysqldump_path() )
19
+ . ' --no-create-db '
20
+ .' -u ' . escapeshellarg( DB_USER )
21
+ .' -p' . escapeshellarg( DB_PASSWORD )
22
+ .' -h ' . escapeshellarg( DB_HOST )
23
+ .' -r ' . escapeshellarg( $backup_tmp_dir . '/wordpress.sql' ) . ' ' . escapeshellarg( DB_NAME )
24
+ . ' 1> ' . escapeshellarg( str_replace( hmbkp_path(), trailingslashit( hmbkp_path() ) . 'logs/', $backup_tmp_dir ) . '-mysqldump.log' ) .' 2>&1'
25
+ );
26
+
27
+ // Fallback to using PHP if not
28
+ else
29
+ hmbkp_backup_mysql_fallback( $backup_tmp_dir, $log );
30
+
31
+ }
32
+
33
+ /**
34
+ * Attempt to work out the path to mysqldump
35
+ *
36
+ * Can be overridden by defining HMBKP_MYSQLDUMP_PATH in
37
+ * wp-config.php.
38
+ *
39
+ * @return string $path on success, empty string on failure
40
+ */
41
+ function hmbkp_mysqldump_path() {
42
+
43
+ $path = '';
44
+
45
+ // List of possible mysqldump locations
46
+ $mysqldump_locations = array(
47
+ 'mysqldump',
48
+ '/usr/local/bin/mysqldump',
49
+ '/usr/local/mysql/bin/mysqldump',
50
+ '/usr/mysql/bin/mysqldump',
51
+ '/usr/bin/mysqldump',
52
+ '/opt/local/lib/mysql6/bin/mysqldump',
53
+ '/opt/local/lib/mysql5/bin/mysqldump',
54
+ '/opt/local/lib/mysql4/bin/mysqldump'
55
+ );
56
+
57
+ // Allow the path to be overridden
58
+ if ( defined( 'HMBKP_MYSQLDUMP_PATH' ) && HMBKP_MYSQLDUMP_PATH )
59
+ array_unshift( $mysqldump_locations, HMBKP_MYSQLDUMP_PATH );
60
+
61
+ // If we don't have a path set
62
+ if ( !$path = get_option( 'hmbkp_mysqldump_path' ) ) :
63
+
64
+ // Try to find out where mysqldump is
65
+ foreach ( $mysqldump_locations as $location )
66
+ if ( shell_exec( 'which ' . $location ) )
67
+ $path = $location;
68
+
69
+ // Save it for later
70
+ if ( $path )
71
+ update_option( 'hmbkp_mysqldump_path', $path );
72
+
73
+ endif;
74
+
75
+ // Check again incase the saved path has stopped working for some reason
76
+ if ( $path && !shell_exec( 'which ' . $path ) ) :
77
+ delete_option( 'hmbkp_mysqldump_path' );
78
+ return hmbkp_mysqldump_path();
79
+
80
+ endif;
81
+
82
+ return $path;
83
+
84
+ }
functions/core.functions.php ADDED
@@ -0,0 +1,334 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * Setup the default options on plugin activation
5
+ *
6
+ * @return void
7
+ */
8
+ function hmbkp_activate() {
9
+ hmbkp_set_defaults();
10
+ }
11
+
12
+ /**
13
+ * Cleanup on plugin deactivation
14
+ *
15
+ * Removes options and clears all cron schedules
16
+ *
17
+ * @todo remove all hmbkp_ options
18
+ * @todo remove all old bkpwp_ options
19
+ * @return void
20
+ */
21
+ function hmbkp_deactivate() {
22
+
23
+ // Clear crons
24
+ wp_clear_scheduled_hook( 'hmbkp_schedule_backup_hook' );
25
+
26
+ }
27
+
28
+
29
+ /**
30
+ * Handles anything that needs to be
31
+ * done when the plugin is updated
32
+ *
33
+ * @return void
34
+ */
35
+ function hmbkp_update() {
36
+
37
+ // Update from backUpWordPress
38
+ if ( get_option( 'bkpwp_max_backups' ) ) :
39
+
40
+ // Carry over the custom path
41
+ if ( $legacy_path = get_option( 'bkpwppath' ) )
42
+ update_option( 'hmbkp_path', $legacy_path );
43
+
44
+ // Options to remove
45
+ $legacy_options = array(
46
+ 'bkpwp_archive_types',
47
+ 'bkpwp_automail_from',
48
+ 'bkpwp_domain',
49
+ 'bkpwp_domain_path',
50
+ 'bkpwp_easy_mode',
51
+ 'bkpwp_excludelists',
52
+ 'bkpwp_install_user',
53
+ 'bkpwp_listmax_backups',
54
+ 'bkpwp_max_backups',
55
+ 'bkpwp_presets',
56
+ 'bkpwp_reccurrences',
57
+ 'bkpwp_schedules',
58
+ 'bkpwp_calculation',
59
+ 'bkpwppath',
60
+ 'bkpwp_status_config',
61
+ 'bkpwp_status'
62
+ );
63
+
64
+ foreach ( $legacy_options as $option )
65
+ delete_option( $option );
66
+
67
+ global $wp_roles;
68
+
69
+ $wp_roles->remove_cap( 'administrator','manage_backups' );
70
+ $wp_roles->remove_cap( 'administrator','download_backups' );
71
+
72
+ wp_clear_scheduled_hook( 'bkpwp_schedule_bkpwp_hook' );
73
+
74
+ endif;
75
+
76
+ }
77
+
78
+ /**
79
+ * Simply wrapper function for creating timestamps
80
+ *
81
+ * @return timestamp
82
+ */
83
+ function hmbkp_timestamp() {
84
+ return date( get_option( 'date_format' ) ) . ' ' . date( 'H:i:s' );
85
+ }
86
+
87
+ /**
88
+ * Sanitize a directory path
89
+ *
90
+ * @param string $dir
91
+ * @param bool $rel. (default: false)
92
+ * @return void
93
+ */
94
+ function hmbkp_conform_dir( $dir, $rel = false ) {
95
+
96
+ $dir = str_replace( '\\', '/', $dir );
97
+ $dir = str_replace( '//', '/', $dir );
98
+
99
+ $dir = untrailingslashit( $dir );
100
+
101
+ if ( $rel == true )
102
+ $dir = str_replace( hmbkp_conform_dir( ABSPATH ), '', $dir );
103
+
104
+ return $dir;
105
+ }
106
+
107
+ /**
108
+ * Take a file size and return a human readable
109
+ * version
110
+ *
111
+ * @param int $size
112
+ * @param string $unit. (default: null)
113
+ * @param string $retstring. (default: null)
114
+ * @param bool $si. (default: true)
115
+ * @return int
116
+ */
117
+ function hmbkp_size_readable( $size, $unit = null, $retstring = '%01.2f %s', $si = true ) {
118
+
119
+ // Units
120
+ if ( $si === true ) :
121
+ $sizes = array( 'B', 'kB', 'MB', 'GB', 'TB', 'PB' );
122
+ $mod = 1000;
123
+
124
+ else :
125
+ $sizes = array('B', 'KiB', 'MiB', 'GiB', 'TiB', 'PiB');
126
+ $mod = 1024;
127
+
128
+ endif;
129
+
130
+ $ii = count( $sizes ) - 1;
131
+
132
+ // Max unit
133
+ $unit = array_search( (string) $unit, $sizes );
134
+
135
+ if ( is_null( $unit ) || $unit === false )
136
+ $unit = $ii;
137
+
138
+ // Loop
139
+ $i = 0;
140
+
141
+ while ( $unit != $i && $size >= 1024 && $i < $ii ) {
142
+ $size /= $mod;
143
+ $i++;
144
+ }
145
+
146
+ return sprintf( $retstring, $size, $sizes[$i] );
147
+ }
148
+
149
+ /**
150
+ * Add daily as a cron schedule choice
151
+ *
152
+ * @param array $recc
153
+ * @return array $recc
154
+ */
155
+ function hmbkp_more_reccurences( $recc ) {
156
+
157
+ $hmbkp_reccurrences = array(
158
+ 'hmbkp_daily' => array( 'interval' => 86400, 'display' => 'every day' )
159
+ );
160
+
161
+ return array_merge( $recc, $hmbkp_reccurrences );
162
+ }
163
+
164
+ /**
165
+ * Send a flie to the browser for download
166
+ *
167
+ * @param string $path
168
+ * @return void
169
+ */
170
+ function hmbkp_send_file( $path ) {
171
+
172
+ session_write_close();
173
+
174
+ ob_end_clean();
175
+
176
+ if ( !is_file( $path ) || connection_status() != 0 )
177
+ return false;
178
+
179
+ // Overide max_execution_time
180
+ set_time_limit( 0 );
181
+
182
+ $name = basename( $path );
183
+
184
+ // Filenames in IE containing dots will screw up the filename unless we add this
185
+ if ( strstr( $_SERVER['HTTP_USER_AGENT'], 'MSIE' ) )
186
+ $name = preg_replace( '/\./', '%2e', $name, substr_count( $name, '.' ) - 1 );
187
+
188
+ // Force
189
+ header( 'Cache-Control: ' );
190
+ header( 'Pragma: ' );
191
+ header( 'Content-Type: application/octet-stream' );
192
+ header( 'Content-Length: ' . (string) ( filesize( $path ) ) );
193
+ header( 'Content-Disposition: attachment; filename=" ' . $name . '"' );
194
+ header( 'Content-Transfer-Encoding: binary\n' );
195
+
196
+ if ( $file = fopen( $path, 'rb' ) ) :
197
+
198
+ while ( ( !feof( $file ) ) && ( connection_status() == 0) ) :
199
+
200
+ print( fread( $file, 1024 * 8 ) );
201
+ flush();
202
+
203
+ endwhile;
204
+
205
+ fclose( $file );
206
+
207
+ endif;
208
+
209
+ return ( connection_status() == 0 ) and !connection_aborted();
210
+ }
211
+
212
+ /**
213
+ * Takes a directory and returns an array of files.
214
+ * Does traverse sub-directories
215
+ *
216
+ * @param string $dir
217
+ * @param array $files. (default: array())
218
+ * @return arrat $files
219
+ */
220
+ function hmbkp_ls( $dir, $files = array() ) {
221
+
222
+ $d = opendir( $dir );
223
+
224
+ if ( strpos( $dir, hmbkp_path() ) !== false )
225
+ return $files;
226
+
227
+ while ( $file = readdir( $d ) ) :
228
+
229
+ // Ignore current dir and containing dir as well as files in the backups dir
230
+ if ( $file == '.' || $file == '..' || strpos( trailingslashit( $dir ) . $file, hmbkp_path() ) !== false || strpos( trailingslashit( $dir ) . $file, WP_CONTENT_DIR . '/backups' ) !== false )
231
+ continue;
232
+
233
+ $files[] = trailingslashit( $dir ) . $file;
234
+
235
+ if ( is_dir( trailingslashit( $dir ) . $file ) )
236
+ $files = hmbkp_ls( trailingslashit( $dir ) . $file, $files );
237
+
238
+ endwhile;
239
+
240
+ return $files;
241
+ }
242
+
243
+ /**
244
+ * Recursively delete a directory including
245
+ * all the files and sub-directories.
246
+ *
247
+ * @param string $dirname
248
+ */
249
+ function hmbkp_rmdirtree( $dirname ) {
250
+
251
+ if ( !is_dir( $dirname ) )
252
+ return false;
253
+
254
+ $result = array();
255
+
256
+ $dirname = trailingslashit( $dirname );
257
+
258
+ $handle = opendir( $dirname );
259
+
260
+ while ( false !== ( $file = readdir( $handle ) ) ) :
261
+
262
+ // Ignore . and ..
263
+ if ( $file != '.' && $file != '..' ) :
264
+
265
+ $path = $dirname . $file;
266
+
267
+ // Recurse if subdir, Delete if file
268
+ if ( is_dir( $path ) ) :
269
+ $result = array_merge( $result, hmbkp_rmdirtree( $path ) );
270
+
271
+ else :
272
+ unlink( $path );
273
+ $result[] .= $path;
274
+
275
+ endif;
276
+
277
+ endif;
278
+
279
+ endwhile;
280
+
281
+ closedir( $handle );
282
+
283
+ rmdir( $dirname );
284
+
285
+ $result[] .= $dirname;
286
+
287
+ return $result;
288
+
289
+ }
290
+
291
+ /**
292
+ * Calculate the size of the backup
293
+ *
294
+ * Doesn't currently take into account for
295
+ * compression
296
+ *
297
+ * @return string
298
+ */
299
+ function hmbkp_calculate() {
300
+
301
+ ini_set( 'memory_limit', apply_filters( 'admin_memory_limit', '256M' ) );
302
+
303
+ // Check cache
304
+ if ( $filesize = get_transient( 'hmbkp_estimated_filesize' ) )
305
+ return hmbkp_size_readable( $filesize );
306
+
307
+ global $wpdb;
308
+
309
+ $sql = 'SHOW TABLE STATUS FROM ' . DB_NAME;
310
+ $res = $wpdb->get_results( $sql, ARRAY_A );
311
+ $sum_free = $sum_data = $filesize = 0;
312
+
313
+ foreach ( $res as $r ) :
314
+ $sum_free += $r['Data_free'];
315
+ $sum_data += $r['Data_length'];
316
+ endforeach;
317
+
318
+ // Get rid of any cached filesizes
319
+ clearstatcache();
320
+
321
+ $dir = hmbkp_conform_dir( ABSPATH );
322
+ $files = hmbkp_ls( $dir );
323
+
324
+ foreach ( $files as $f ) :
325
+ $str = hmbkp_conform_dir( $f, true );
326
+ $filesize += filesize( $f );
327
+ endforeach;
328
+
329
+ // Cache in a transient for a day
330
+ set_transient( 'hmbkp_estimated_filesize', $filesize, 86400 );
331
+
332
+ return hmbkp_size_readable( $filesize );
333
+
334
+ }
functions/interface.functions.php ADDED
@@ -0,0 +1,32 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * hmbkp_get_backup_row function.
4
+ *
5
+ * @param mixed $file
6
+ * @param mixed $alternate
7
+ * @return void
8
+ */
9
+ function hmbkp_get_backup_row( $file ) {
10
+
11
+ $encode = base64_encode( $file['file'] ); ?>
12
+
13
+ <tr id="hmbkp_manage_backups_row_<?php echo $encode; ?>" class="hmbkp_manage_backups_row">
14
+
15
+ <th scope="row">
16
+ <?php echo date( get_option('date_format'), filemtime( $file['file'] ) ) . ' ' . date( 'H:i', filemtime($file['file'] ) ); ?>
17
+ </th>
18
+
19
+ <td>
20
+ <?php echo hmbkp_size_readable( filesize( $file['file'] ) ); ?>
21
+ </td>
22
+
23
+ <td>
24
+
25
+ <a href="tools.php?page=humanmade_backups&amp;hmbkp_download=<?php echo $encode; ?>"><?php _e( 'Download', 'hmbkp' ); ?></a> |
26
+ <a href="tools.php?page=humanmade_backups&amp;hmbkp_delete=<?php echo $encode ?>"><?php _e( 'Delete', 'hmbkp' ); ?></a>
27
+
28
+ </td>
29
+
30
+ </tr>
31
+
32
+ <?php }
functions/settings.functions.php ADDED
@@ -0,0 +1,55 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * hmbkp_set_defaults function.
5
+ *
6
+ * @return void
7
+ */
8
+ function hmbkp_set_defaults() {
9
+
10
+ update_option( 'hmbkp_max_backups', 10 );
11
+
12
+ hmbkp_default_schedule();
13
+ }
14
+
15
+ /**
16
+ * hmbkp_default_schedules function.
17
+ *
18
+ * @return void
19
+ */
20
+ function hmbkp_default_schedule() {
21
+ wp_schedule_event( strtotime( '2300' ), 'hmbkp_daily', 'hmbkp_schedule_backup_hook' );
22
+ }
23
+
24
+
25
+ /**
26
+ * hmbkp_path function.
27
+ */
28
+ function hmbkp_path() {
29
+
30
+ $path = get_option( 'hmbkp_path' );
31
+
32
+ // Allow the backups path to be defined
33
+ if ( defined( 'HMBKP_PATH' ) && HMBKP_PATH )
34
+ $path = HMBKP_PATH;
35
+
36
+ // If the dir doesn't exist or isn't writable then use wp-content/backups instead
37
+ if ( ( !$path || !is_writable( $path ) ) && $path != WP_CONTENT_DIR . '/backups' ) :
38
+ $path = WP_CONTENT_DIR . '/backups';
39
+ update_option( 'hmbkp_path', $path );
40
+ endif;
41
+
42
+ // Create the backups directory if it doesn't exist
43
+ if ( is_writable( WP_CONTENT_DIR ) && !is_dir( $path ) )
44
+ mkdir( $path, 0755 );
45
+
46
+ // Secure the directory with a .htaccess file
47
+ $htaccess = $path . '/.htaccess';
48
+
49
+ if ( !file_exists( $htaccess ) && is_writable( $path ) ) :
50
+ require_once( ABSPATH . '/wp-admin/includes/misc.php' );
51
+ insert_with_markers( $htaccess, 'BackUpWordPress', array( 'deny from all' ) );
52
+ endif;
53
+
54
+ return $path;
55
+ }
images/disk.png DELETED
Binary file
images/loading.gif DELETED
Binary file
locale/de_DE.mo DELETED
Binary file
locale/de_DE.po DELETED
@@ -1,1151 +0,0 @@
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 &amp; Folders that will NOT (!) be included in the Backup when using "
781
- msgstr "Dateien &amp; 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
-
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
plugin.php ADDED
@@ -0,0 +1,96 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /*
4
+ Plugin Name: BackUpWordPress
5
+ Plugin URI: http://humanmade.co.uk/
6
+ Description: Simple automated backups of your WordPress powered website.
7
+ Author: Human Made Limited
8
+ Version: 1.0
9
+ Author URI: http://humanmade.co.uk/
10
+ */
11
+
12
+ /* Copyright 2011 Human Made Limited (email : hello@humanmade.co.uk)
13
+
14
+ This program is free software; you can redistribute it and/or modify
15
+ it under the terms of the GNU General Public License as published by
16
+ the Free Software Foundation; either version 2 of the License, or
17
+ (at your option) any later version.
18
+
19
+ This program is distributed in the hope that it will be useful,
20
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
21
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22
+ GNU General Public License for more details.
23
+
24
+ You should have received a copy of the GNU General Public License
25
+ along with this program; if not, write to the Free Software
26
+ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
27
+ */
28
+
29
+ // TODO use wp_filesystem
30
+ // TODO try to use zipArchive before pclzip
31
+ // TODO get rid of schedules
32
+
33
+ define( 'HMBKP_PLUGIN_PATH', WP_PLUGIN_DIR .'/humanmade.backup' );
34
+ define( 'HMBKP_PLUGIN_URL', WP_PLUGIN_URL .'/humanmade.backup' );
35
+
36
+ // Load the admin actions file
37
+ function hmbkp_actions() {
38
+
39
+ hmbkp_update();
40
+
41
+ require_once( HMBKP_PLUGIN_PATH . '/admin.actions.php' );
42
+
43
+ if ( isset( $_GET['page'] ) && $_GET['page'] == 'humanmade_backups' ) :
44
+ wp_enqueue_script( 'hmbkp', HMBKP_PLUGIN_URL . '/assets/hmbkp.js' );
45
+ wp_enqueue_style( 'hmbkp', HMBKP_PLUGIN_URL . '/assets/hmbkp.css' );
46
+ endif;
47
+
48
+ }
49
+ add_action( 'admin_init', 'hmbkp_actions' );
50
+
51
+ // Load the admin menu
52
+ require_once( HMBKP_PLUGIN_PATH . '/admin.menus.php' );
53
+
54
+ // Load the core functions
55
+ require_once( HMBKP_PLUGIN_PATH . '/functions/core.functions.php' );
56
+ require_once( HMBKP_PLUGIN_PATH . '/functions/interface.functions.php' );
57
+ require_once( HMBKP_PLUGIN_PATH . '/functions/settings.functions.php' );
58
+ require_once( HMBKP_PLUGIN_PATH . '/functions/backup.log.functions.php' );
59
+ require_once( HMBKP_PLUGIN_PATH . '/functions/backup.functions.php' );
60
+ require_once( HMBKP_PLUGIN_PATH . '/functions/backup.mysql.functions.php' );
61
+ require_once( HMBKP_PLUGIN_PATH . '/functions/backup.files.functions.php' );
62
+ require_once( HMBKP_PLUGIN_PATH . '/functions/backup.mysql.fallback.functions.php' );
63
+ require_once( HMBKP_PLUGIN_PATH . '/functions/backup.files.fallback.functions.php' );
64
+
65
+ // Plugin activation and deactivation
66
+ add_action( 'activate_humanmade.backup/plugin.php', 'hmbkp_activate' );
67
+ add_action( 'deactivate_humanmade.backup/plugin.php', 'hmbkp_deactivate' );
68
+
69
+ // Add more cron schedules
70
+ add_filter( 'cron_schedules', 'hmbkp_more_reccurences' );
71
+
72
+ // Cron hook for backups
73
+ add_action( 'hmbkp_schedule_backup_hook', 'hmbkp_schedule_backup' );
74
+
75
+ // Make sure backups dir exists and is writable
76
+ if ( !is_dir( hmbkp_path() ) ) :
77
+
78
+ function hmbkp_path_exists_warning() {
79
+ $php_user = exec( 'whoami' );
80
+ $php_group = reset( explode( ' ', exec( 'groups' ) ) );
81
+ echo '<div id="hmbkp-warning" class="updated fade"><p><strong>' . __( 'BackUpWordPress has detected a problem.' ) . '</strong> ' . sprintf( __( 'The backups directory can\'t be created because your %s directory isn\'t writable, run %s or %s or create the folder yourself.' ), '<code>wp-content</code>', '<code>chown ' . $php_user . ':' . $php_group . ' ' . WP_CONTENT_DIR . '</code>', '<code>chmod 777 ' . WP_CONTENT_DIR . '</code>' ) . '</p></div>';
82
+ }
83
+ add_action( 'admin_notices', 'hmbkp_path_exists_warning' );
84
+
85
+ endif;
86
+
87
+ if ( is_dir( hmbkp_path() ) && !is_writable( hmbkp_path() ) ) :
88
+
89
+ function hmbkp_writable_path_warning() {
90
+ $php_user = exec( 'whoami' );
91
+ $php_group = reset( explode( ' ', exec( 'groups' ) ) );
92
+ echo '<div id="hmbkp-warning" class="updated fade"><p><strong>' . __( 'BackUpWordPress has detected a problem.' ) . '</strong> ' . sprintf( __( 'Your backups directory isn\'t writable. run %s or %s or set the permissions yourself.' ), '<code>chown -R ' . $php_user . ':' . $php_group . ' ' . hmbkp_path() . '</code>', '<code>chmod -R 777 ' . hmbkp_path() . '</code>' ) . '</p></div>';
93
+ }
94
+ add_action( 'admin_notices', 'hmbkp_writable_path_warning' );
95
+
96
+ endif; ?>
readme.txt CHANGED
@@ -1,145 +1,36 @@
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.3.1
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
- == Features ==
12
-
13
- EasyMode:
14
-
15
- + Switch between EasyMode and AdvancedMode
16
- + Database backup as well as directory structure including uploaded files, plugins, etc.
17
- + Set up Mail notification on new backups
18
- + Trigger backup manually
19
- + Set basic schedules for your backups
20
- + restore backups
21
- + staggered SQL import when restoring
22
- + automatically continue unfinished backups in background
23
- + download backups
24
- + Help page
25
- + Language Support for english and german(deutsch)
26
-
27
- more option in AdvancedMode:
28
-
29
- + Set and manage custom schedules
30
- + Check disk space
31
- + View backup Logs
32
- + Delete backups manually
33
- + Manage backup presets
34
- + Manage exclude-lists for use with these presets
35
 
36
  == Installation ==
37
 
38
- 1. Download, unzip and upload to your WordPress plugins directory
39
- 2. activate the plugin within you WordPress Administration Backend
40
- 3. Go to BackUpWordPress in your Administration Backend
41
-
42
- == Support Forum ==
43
-
44
- For support questions, please search and post at our Support forum:
45
- [WordPress Designpraxis Forum](http://wpforum.designpraxis.at)
46
 
47
- == Screenshots ==
48
-
49
- 1. Manage your Backups
50
- 2. Switch between EasyMode and AdvancedMode
51
- 3. Activate scheduling of your backups
52
- 4. Receive email notifications on new backups
53
- 5. Dashboard activity box view
54
 
55
- == Notes ==
56
 
57
- BackUpWordPress utilizes several Open Source Tools:
58
-
59
- + [PEAR](http://pear.php.net/package/PEAR/)
60
- + [FILE_ARCHIVE](http://pear.php.net/package/File_Archive) for compression/decompression
61
- + [bigdump](http://www.ozerov.de/bigdump.php) for staggered sql import
62
 
63
- Some pieces of code have been modified:
64
 
65
- + 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
66
 
67
  == Changelog ==
68
 
 
69
 
70
- Changelog:
71
-
72
- Changes in 0.4.5
73
- + fix prevents users from setting wp-content as backup repository. The directory must be one that can be secured with .htaccess.
74
- + fixes the default admin issue reported here: http://wpforum.designpraxis.at/topic/error-invalid-argument-supplied-for-foreach-?replies=2#post-322
75
-
76
- Changes in 0.4.4
77
- + another even more important security fix.
78
-
79
- Changes in 0.4.3
80
- + security fix for RFI vulnerability reported on http://www.milw0rm.com/exploits/4593
81
-
82
- Changes in 0.4.2
83
- + prevent unpriviledged users from seeing the BackUpWordPress Dashboard
84
-
85
- Changes in 0.4.1
86
- + added test for empty array in bkpwp_get_excludelist()
87
- + all mkdir() calls use mode 0777
88
- + backup archive permissions chage to 0777 (should solve issues with users not being able to delete archive files)
89
-
90
-
91
- Changes in 0.3.2:
92
- + added capabilities manage_backups and download_backups
93
- + backup repository secured by .htaccess
94
-
95
- Changes in 0.2.7:
96
-
97
- + manage presets. link to configure excludelists corrected
98
- + require_once instead of require for class-phpmailer.php
99
- + Sajax is replaces by prototype. this resolves the "backup hangs" bug on hosts with hardened php (register_globals: off, safe_mode: on, etc.)
100
-
101
- Changes in 0.2.6:
102
-
103
- + unable to delete backup presets bug fixed
104
-
105
- Changes in 0.2.5:
106
-
107
- + some smaller improvements
108
 
109
- Changes in 0.2.4:
110
-
111
- + Internet Explorer ajax issue with not being able to do backups manually fixed
112
-
113
- Changes in 0.2.3:
114
-
115
- + Mailing options: multiple email addresses supported
116
- + Backup file size reports also display the size of the database
117
- + Backup archive filesize is estimated
118
- + schedule table rows display the lastrun-timestamp of the last running backup
119
-
120
- Changes in 0.2.2:
121
-
122
- + Manage Backups now display the type, either scheduled or manual for Advanced as well as EasyMode
123
- + logfile prints out WordPress and BackUpWordPress version for easier posting at http://wpforum.designpraxis.at/
124
- + BackUpWordPress displays "Your backup is being processed" instead of the actions links on the Manage Backups screen as long as archiving is not finished
125
-
126
- Changes in 0.2.1:
127
-
128
- + old Logfiles are deleted. 10 times the amount of the configured amount of backups to keep is kept.
129
- + feature: backups are done in kind of a staggered process: if BackUpWordPress runs into a server side time-out, BackUpWordPress tries to trigger an single scheduled event for finishing the task. Corresponding dialoques appear on the *Manage Backups* - screen.
130
-
131
- Changes in 0.1.4:
132
-
133
- + @set_time_limit(0) in functions.php line 277 supresses the 'Cannot set time limit in safe mode' warning
134
- + dialoques streamlined: e.g. when you click "delete" on a backup archive, you just need to hit enter to delete it
135
-
136
- Changes in 0.1.3:
137
-
138
- + ajax problems fixed
139
- + schedules last run timestamp fixed
140
 
141
- Changes in 0.1.2:
142
-
143
- + bug fixed: Backup-Now doesn't call Sajax
144
- + bkpwp_delete_old() refactored
145
- + bug fixed: table data is not dumped
1
  === BackUpWordPress ===
2
+ Contributors: willmot, humanmade
3
+ Tags: backup
4
+ Requires at least: 3.0
5
+ Tested up to: 3.1
6
+ Stable tag: 0.4.5
 
7
 
8
+ Simple automated backups of your WordPress powered website.
9
 
10
+ BackUp WordPress will back up your entire site including your database and all your files once every day.
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
11
 
12
  == Installation ==
13
 
14
+ 1. Install BackUpWordPress either via the WordPress.org plugin directory, or by uploading the files to your server
15
+ 2. Activate the plugin
16
+ 3. Sit back and relax safe in the knowledge that your complete site will be backed up every day at 11:00
 
 
 
 
 
17
 
18
+ The plugin will try to use the `mysqldump` and `zip` commands via shell if they are available, using these will greatly improve the time it takes to back up your site. You can point the plugin in the right direction by defining `HMBKP_ZIP_PATH` and `HMBKP_MYSQLDUMP_PATH` in your `wp-config.php`
 
 
 
 
 
 
19
 
20
+ == Support ==
21
 
22
+ Contact hello@humanmade.co.uk for help and support
 
 
 
 
23
 
24
+ == Screenshots ==
25
 
26
+ 1. Simple Automated Backups
27
 
28
  == Changelog ==
29
 
30
+ #### 1.0
31
 
32
+ 1.0 represents a total rewrite & rethink of the BackUpWordPress plugin with a focus on making it "Just Work". The management and development of the plugin has been taken over by [humanmade](http://humanmade.co.uk) the chaps behind [WP Remote](https://wpremote.com)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
33
 
34
+ #### Previous
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
35
 
36
+ Version 0.4.5 and previous were developed by [wpdprx](http://profiles.wordpress.org/users/wpdprx/)
 
 
 
 
screenshot-1.png CHANGED
Binary file
screenshot-2.png DELETED
Binary file
screenshot-3.png DELETED
Binary file
screenshot-4.png DELETED
Binary file
screenshot-5.png DELETED
Binary file