[geeklog-cvs] geeklog: Cosmetics - no code changes
geeklog-cvs at lists.geeklog.net
geeklog-cvs at lists.geeklog.net
Sun Apr 5 12:53:48 EDT 2009
details: http://project.geeklog.net/cgi-bin/hgweb.cgi/rev/d3735195c25d
changeset: 6896:d3735195c25d
user: Dirk Haun <dirk at haun-online.de>
date: Sun Apr 05 18:44:34 2009 +0200
description:
Cosmetics - no code changes
diffstat:
1 file changed, 79 insertions(+), 80 deletions(-)
system/classes/unpacker.class.php | 159 ++++++++++++++++++-------------------
diffs (truncated from 369 to 300 lines):
diff -r 72931c2ab9fe -r d3735195c25d system/classes/unpacker.class.php
--- a/system/classes/unpacker.class.php Sun Apr 05 18:35:52 2009 +0200
+++ b/system/classes/unpacker.class.php Sun Apr 05 18:44:34 2009 +0200
@@ -1,48 +1,47 @@
<?php
-/*Reminder: always indent with 4 spaces (no tabs). */
-//+---------------------------------------------------------------------------+
-//| Geeklog 1.6 |
-//+---------------------------------------------------------------------------+
-//| unpacker.php |
-//| |
-//| unpacker - archive libs wrapper |
-//| This class wraps calls to pecl Zip, pear Zip, pear Tar, using the best |
-//| package available to unpack or list information about the archive. |
-//+---------------------------------------------------------------------------+
-//| Copyright (C) 2009 by the following authors: |
-//| |
-//| Authors: Justin Carlson - justin DOT carlson AT gmail DOT com |
-//+---------------------------------------------------------------------------+
-//| |
-//| This program is free software; you can redistribute it and/or |
-//| modify it under the terms of the GNU General Public License |
-//| as published by the Free Software Foundation; either version 2 |
-//| of the License, or (at your option) any later version. |
-//| |
-//| This program is distributed in the hope that it will be useful, |
-//| but WITHOUT ANY WARRANTY; without even the implied warranty of |
-//| MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
-//| GNU General Public License for more details. |
-//| |
-//| You should have received a copy of the GNU General Public License |
-//| along with this program; if not, write to the Free Software Foundation, |
-//| Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
-//| |
-//+---------------------------------------------------------------------------+
-
+/* Reminder: always indent with 4 spaces (no tabs). */
+// +---------------------------------------------------------------------------+
+// | Geeklog 1.6 |
+// +---------------------------------------------------------------------------+
+// | unpacker.class.php |
+// | |
+// | unpacker - archive libs wrapper |
+// | This class wraps calls to pecl Zip, pear Zip, pear Tar, using the best |
+// | package available to unpack or list information about the archive. |
+// +---------------------------------------------------------------------------+
+// | Copyright (C) 2009 by the following authors: |
+// | |
+// | Authors: Justin Carlson - justin DOT carlson AT gmail DOT com |
+// +---------------------------------------------------------------------------+
+// | |
+// | This program is free software; you can redistribute it and/or |
+// | modify it under the terms of the GNU General Public License |
+// | as published by the Free Software Foundation; either version 2 |
+// | of the License, or (at your option) any later version. |
+// | |
+// | This program is distributed in the hope that it will be useful, |
+// | but WITHOUT ANY WARRANTY; without even the implied warranty of |
+// | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
+// | GNU General Public License for more details. |
+// | |
+// | You should have received a copy of the GNU General Public License |
+// | along with this program; if not, write to the Free Software Foundation, |
+// | Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
+// | |
+// +---------------------------------------------------------------------------+
/**
- * geeklog plugin unpacker - Archive Libs Wrapper
+ * Geeklog plugin unpacker - Archive Libs Wrapper
*
* This class wraps calls to pecl Zip, pear Zip, pear Tar, using the best
* package available to unpack or list information about the archive.
*
- * @author Justin Carlson <justin DOT carlson AT gmail DOT com>
+ * @author Justin Carlson, justin DOT carlson AT gmail DOT com
*
*/
class unpacker {
-
+
// mime types ( these are not very reliable, varies browser to browser )
// for the best results, pass the real filename as well as the mime type
var $mime_def = array('application/zip' => 'zip',
@@ -57,7 +56,7 @@
'application/octet-stream' => 'tar',
'application/x-compress' => 'tar',
'application/x-compressed' => 'tar');
-
+
var $file = null; // archive name
var $filesize = null; // archive size (in bytes)
var $ext = null; // archive ext
@@ -70,7 +69,7 @@
var $type = null; // archive type
var $comp = null; // archive compression type (private)
-
+
/**
* Constructor
*
@@ -86,33 +85,33 @@
} else {
$this->d_sep = '/';
}
-
+
// if the file doesn't have it's path, assume local
if (! strstr($file, $this->d_sep)) {
$file = getcwd() . $this->d_sep . $file;
}
-
+
// make sure the file exists
if (file_exists($file)) {
-
+
// copy vars
$this->file = $file;
$this->filesize = filesize($file);
$this->ext = strtolower(substr($file, - 4));
-
+
// if the type is passed, store it
if ($mime_type != null) {
-
+
if (isset($this->mime_def[$mime_type])) {
$this->type = $this->mime_def[$mime_type];
} else {
return $this->setError('400', 'Invalid MIME Type');
}
-
+
}
-
+
if ($this->type == null || $this->type == 'other') {
-
+
// if a known mime type was not provided, expect real filename
// mime types are not reliable so this is the reccommended way
// for example: unpacker($_FILES['foo']['name'],$type);
@@ -126,21 +125,21 @@
} else {
$this->type = str_replace('.', '', $this->ext);
}
-
+
// see if we know of a mime type for this ext
if (in_array($this->type, $this->mime_def) === false) {
return $this->setError('400', 'Invalid File Extension');
}
}
-
+
// call the load wrapper, return result
return $this->load_file();
-
+
} else {
// file did not exist
return false;
}
-
+
}
/**
@@ -191,24 +190,23 @@
function load_zip() {
if (function_exists('zip_open')) {
-
+
// Use PECL ZIP
$this->archive = new ZipArchive();
$result = $this->archive->open($this->file);
if ($result === false) {
return $this->setError($result, 'ZipArchive Error');
}
-
+
} else {
-
+
// use Pear Archive_Zip
require_once 'Archive/Zip.php';
$this->archive = new Archive_Zip($this->file);
// unfortunately, we can't tell if it succeeded
-
}
-
+
// return resource handle or result
return true;
}
@@ -223,10 +221,10 @@
// use Pear Archive_Tar
require_once 'Archive/Tar.php';
$this->archive = new Archive_Tar($this->file, $this->comp);
-
+
// unfortunately, we can't tell if it succeeded
return ($this->archive);
-
+
}
/**
@@ -240,7 +238,7 @@
if (is_array($this->contents)) {
return $this->contents;
}
-
+
// not cached, load and cache the content list
$handler = 'list_' . $this->type;
if (method_exists($this, $handler)) {
@@ -249,7 +247,7 @@
} else {
return $this->setError('405', 'Unpacker called getlist ' . 'with unknown handler.');
}
-
+
}
/**
@@ -261,37 +259,37 @@
// using PECL::ZipArchive
if (function_exists('zip_open')) {
-
+
// catch empty archive
if ($this->archive->numFiles < 1) {
return $this->setError('411', 'Archive is empty.');
}
-
+
// reset cache
$this->contents = array();
for ($i = 0; $i < $this->archive->numFiles; $i ++) {
-
+
// Make ZipArchive's info look like Archive_Zip's
$zip_entry = $this->archive->statIndex($i);
$this->contents[$i]['filename'] = $zip_entry['name'];
$this->contents[$i]['size'] = $zip_entry['size'];
$this->contents[$i]['compressed'] = $zip_entry['comp_size'];
$this->contents[$i]['method'] = $zip_entry['comp_method'];
-
+
}
// return the contents list
return $this->contents;
-
+
// using PEAR::Archive_Zip
} else {
-
+
$this->contents = $this->archive->listContent();
if (is_array($this->contents)) {
return $this->contents;
} else {
return $this->setError('411', 'Archive is empty.');
}
-
+
}
}
@@ -323,12 +321,12 @@
if (is_writable($target_path) === false) {
return $this->setError('403', 'Permission denied writing to path.');
}
-
+
// make sure target ends with slash
if (substr($target_path, - 1) != $this->d_sep) {
$target_path .= $this->d_sep;
}
-
+
$handler = 'unpack_' . $this->type;
if (method_exists($this, $handler)) {
return $this->$handler($target_path, $item_array);
@@ -348,39 +346,39 @@
// using PECL::ZipArchive
if (function_exists('zip_open')) {
-
+
if ($this->archive) {
-
+
More information about the geeklog-cvs
mailing list