From fba11f64c26a8dde5f64c57233b0da84fae35959 Mon Sep 17 00:00:00 2001 From: Andreas Gohr Date: Sat, 3 Nov 2012 18:42:57 +0100 Subject: removed old TarLib and changed plugin manager to use new one --- lib/plugins/plugin/classes/ap_download.class.php | 25 ++++++++++-------------- 1 file changed, 10 insertions(+), 15 deletions(-) (limited to 'lib/plugins/plugin/classes/ap_download.class.php') diff --git a/lib/plugins/plugin/classes/ap_download.class.php b/lib/plugins/plugin/classes/ap_download.class.php index d1b518d9d..0eb567c80 100644 --- a/lib/plugins/plugin/classes/ap_download.class.php +++ b/lib/plugins/plugin/classes/ap_download.class.php @@ -200,31 +200,26 @@ class ap_download extends ap_manage { if (in_array($ext, array('tar','bz','gz'))) { switch($ext){ case 'bz': - $compress_type = TarLib::COMPRESS_BZIP; + $compress_type = Tar::COMPRESS_BZIP; break; case 'gz': - $compress_type = TarLib::COMPRESS_GZIP; + $compress_type = Tar::COMPRESS_GZIP; break; default: - $compress_type = TarLib::COMPRESS_NONE; + $compress_type = Tar::COMPRESS_NONE; } - $tar = new TarLib($file, $compress_type); - if($tar->_initerror < 0){ + $tar = new Tar(); + try { + $tar->open($file, $compress_type); + $tar->extract($target); + return true; + }catch(Exception $e){ if($conf['allowdebug']){ - msg('TarLib Error: '.$tar->TarErrorStr($tar->_initerror),-1); + msg('Tar Error: '.$e->getMessage().' ['.$e->getFile().':'.$e->getLine().']',-1); } return false; } - $ok = $tar->Extract(TarLib::FULL_ARCHIVE, $target, '', 0777); - - if($ok<1){ - if($conf['allowdebug']){ - msg('TarLib Error: '.$tar->TarErrorStr($ok),-1); - } - return false; - } - return true; } else if ($ext == 'zip') { $zip = new ZipLib(); -- cgit v1.2.3 From 38479cbba628ee76a92ff5f3c974cfa8e6ce9e61 Mon Sep 17 00:00:00 2001 From: Dominik Eckelmann Date: Thu, 29 Nov 2012 16:06:43 +0100 Subject: some coding style improvements - removed some dead/unused code - fixed phpdoc - added typing on methods --- lib/plugins/acl/admin.php | 7 ------- lib/plugins/config/settings/config.class.php | 7 +++---- lib/plugins/info/syntax.php | 20 +++----------------- lib/plugins/plugin/admin.php | 22 ++++------------------ lib/plugins/plugin/classes/ap_download.class.php | 4 +--- lib/plugins/plugin/classes/ap_manage.class.php | 6 +----- lib/plugins/plugin/classes/ap_update.class.php | 2 -- lib/plugins/popularity/action.php | 6 +++++- lib/plugins/popularity/admin.php | 8 ++++++-- lib/plugins/popularity/helper.php | 10 ++++++---- lib/plugins/revert/admin.php | 2 -- lib/plugins/syntax.php | 14 +++++++------- lib/plugins/usermanager/admin.php | 5 +---- 13 files changed, 37 insertions(+), 76 deletions(-) (limited to 'lib/plugins/plugin/classes/ap_download.class.php') diff --git a/lib/plugins/acl/admin.php b/lib/plugins/acl/admin.php index 1197892f2..0d9cd742a 100644 --- a/lib/plugins/acl/admin.php +++ b/lib/plugins/acl/admin.php @@ -173,8 +173,6 @@ class admin_plugin_acl extends DokuWiki_Admin_Plugin { * @author Andreas Gohr */ function html() { - global $ID; - echo '
'.NL; echo '

'.$this->getLang('admin_acl').'

'.NL; echo '
'.NL; @@ -208,7 +206,6 @@ class admin_plugin_acl extends DokuWiki_Admin_Plugin { * @author Andreas Gohr */ function _get_opts($addopts=null){ - global $ID; $opts = array( 'do'=>'admin', 'page'=>'acl', @@ -230,7 +227,6 @@ class admin_plugin_acl extends DokuWiki_Admin_Plugin { global $ID; global $lang; - $dir = $conf['datadir']; $ns = $this->ns; if(empty($ns)){ $ns = dirname(str_replace(':','/',$ID)); @@ -326,7 +322,6 @@ class admin_plugin_acl extends DokuWiki_Admin_Plugin { * @author Andreas Gohr */ function _html_detail(){ - global $conf; global $ID; echo '
'.NL; @@ -493,7 +488,6 @@ class admin_plugin_acl extends DokuWiki_Admin_Plugin { * @author Andreas Gohr */ function _html_list_acl($item){ - global $ID; $ret = ''; // what to display if($item['label']){ @@ -764,7 +758,6 @@ class admin_plugin_acl extends DokuWiki_Admin_Plugin { * @author Andreas Gohr */ function _html_select(){ - global $conf; $inlist = false; if($this->who && diff --git a/lib/plugins/config/settings/config.class.php b/lib/plugins/config/settings/config.class.php index 8c48018d7..a30a0605b 100644 --- a/lib/plugins/config/settings/config.class.php +++ b/lib/plugins/config/settings/config.class.php @@ -369,7 +369,7 @@ if (!class_exists('setting')) { * update setting with user provided value $input * if value fails error check, save it * - * @return true if changed, false otherwise (incl. on error) + * @return boolean true if changed, false otherwise (incl. on error) */ function update($input) { if (is_null($input)) return false; @@ -426,7 +426,6 @@ if (!class_exists('setting')) { if ($fmt=='php') { // translation string needs to be improved FIXME - $tr = array("\n"=>'\n', "\r"=>'\r', "\t"=>'\t', "\\" => '\\\\', "'" => '\\\''); $tr = array("\\" => '\\\\', "'" => '\\\''); $out = '$'.$var."['".$this->_out_key()."'] = '".strtr($this->_local, $tr)."';\n"; @@ -538,7 +537,7 @@ if (!class_exists('setting_email')) { * update setting with user provided value $input * if value fails error check, save it * - * @return true if changed, false otherwise (incl. on error) + * @return boolean true if changed, false otherwise (incl. on error) */ function update($input) { if (is_null($input)) return false; @@ -574,7 +573,7 @@ if (!class_exists('setting_richemail')) { * update setting with user provided value $input * if value fails error check, save it * - * @return true if changed, false otherwise (incl. on error) + * @return boolean true if changed, false otherwise (incl. on error) */ function update($input) { if (is_null($input)) return false; diff --git a/lib/plugins/info/syntax.php b/lib/plugins/info/syntax.php index 9aedbf0aa..d813aa23a 100644 --- a/lib/plugins/info/syntax.php +++ b/lib/plugins/info/syntax.php @@ -15,20 +15,6 @@ if(!defined('DOKU_INC')) die(); */ class syntax_plugin_info extends DokuWiki_Syntax_Plugin { - /** - * return some info - */ - function getInfo(){ - return array( - 'author' => 'Andreas Gohr', - 'email' => 'andi@splitbrain.org', - 'date' => '2008-09-12', - 'name' => 'Info Plugin', - 'desc' => 'Displays information about various DokuWiki internals', - 'url' => 'http://dokuwiki.org/plugin:info', - ); - } - /** * What kind of syntax are we? */ @@ -114,7 +100,7 @@ class syntax_plugin_info extends DokuWiki_Syntax_Plugin { * * uses some of the original renderer methods */ - function _plugins_xhtml($type, &$renderer){ + function _plugins_xhtml($type, Doku_Renderer &$renderer){ global $lang; $renderer->doc .= '
    '; @@ -152,7 +138,7 @@ class syntax_plugin_info extends DokuWiki_Syntax_Plugin { * * uses some of the original renderer methods */ - function _helpermethods_xhtml(&$renderer){ + function _helpermethods_xhtml(Doku_Renderer &$renderer){ global $lang; $plugins = plugin_list('helper'); @@ -237,7 +223,7 @@ class syntax_plugin_info extends DokuWiki_Syntax_Plugin { /** * Adds a TOC item */ - function _addToTOC($text, $level, &$renderer){ + function _addToTOC($text, $level, Doku_Renderer_xhtml &$renderer){ global $conf; if (($level >= $conf['toptoclevel']) && ($level <= $conf['maxtoclevel'])){ diff --git a/lib/plugins/plugin/admin.php b/lib/plugins/plugin/admin.php index b2108f185..8b1ee3c7d 100644 --- a/lib/plugins/plugin/admin.php +++ b/lib/plugins/plugin/admin.php @@ -33,6 +33,10 @@ class admin_plugin_plugin extends DokuWiki_Admin_Plugin { var $disabled = 0; var $plugin = ''; var $cmd = ''; + + /** + * @var ap_manage + */ var $handler = NULL; var $functions = array('delete','update',/*'settings',*/'info'); // require a plugin name @@ -43,27 +47,9 @@ class admin_plugin_plugin extends DokuWiki_Admin_Plugin { var $error = ''; function admin_plugin_plugin() { - global $conf; $this->disabled = plugin_isdisabled('plugin'); } - /** - * return some info - */ - function getInfo(){ - $disabled = ($this->disabled) ? '(disabled)' : ''; - - return array( - 'author' => 'Christopher Smith', - 'email' => 'chris@jalakai.co.uk', - 'date' => '2009-11-11', - 'name' => 'Plugin Manager', - 'desc' => "Manage Plugins, including automated plugin installer $disabled", - 'url' => 'http://www.dokuwiki.org/plugin:plugin', - ); - } - - /** * return sort order for position in admin menu */ diff --git a/lib/plugins/plugin/classes/ap_download.class.php b/lib/plugins/plugin/classes/ap_download.class.php index 0eb567c80..3cc455867 100644 --- a/lib/plugins/plugin/classes/ap_download.class.php +++ b/lib/plugins/plugin/classes/ap_download.class.php @@ -7,7 +7,6 @@ class ap_download extends ap_manage { * Initiate the plugin download */ function process() { - global $lang; global $INPUT; $plugin_url = $INPUT->str('url'); @@ -45,7 +44,6 @@ class ap_download extends ap_manage { * Process the downloaded file */ function download($url, $overwrite=false) { - global $lang; // check the url $matches = array(); if (!preg_match("/[^\/]*$/", $url, $matches) || !$matches[0]) { @@ -241,7 +239,7 @@ class ap_download extends ap_manage { * if neither bz, gz or zip are recognized, tar is assumed. * * @author Andreas Gohr - * @returns false if the file can't be read, otherwise an "extension" + * @returns boolean|string false if the file can't be read, otherwise an "extension" */ function guess_archive($file){ $fh = fopen($file,'rb'); diff --git a/lib/plugins/plugin/classes/ap_manage.class.php b/lib/plugins/plugin/classes/ap_manage.class.php index 28579cbe9..3ec740dae 100644 --- a/lib/plugins/plugin/classes/ap_manage.class.php +++ b/lib/plugins/plugin/classes/ap_manage.class.php @@ -69,7 +69,6 @@ class ap_manage { } function html_pluginlist() { - global $ID; global $plugin_protected; foreach ($this->manager->plugin_list as $plugin) { @@ -195,11 +194,8 @@ class ap_manage { closedir($dh); return @rmdir($path); - } else { - return @unlink($path); } - - return false; + return @unlink($path); } diff --git a/lib/plugins/plugin/classes/ap_update.class.php b/lib/plugins/plugin/classes/ap_update.class.php index c43429a1b..5d7f6cb08 100644 --- a/lib/plugins/plugin/classes/ap_update.class.php +++ b/lib/plugins/plugin/classes/ap_update.class.php @@ -5,8 +5,6 @@ class ap_update extends ap_download { var $overwrite = true; function process() { - global $lang; - $plugin_url = $this->plugin_readlog($this->plugin, 'url'); $this->download($plugin_url, $this->overwrite); return ''; diff --git a/lib/plugins/popularity/action.php b/lib/plugins/popularity/action.php index 1c7a2f65d..f0cbb771b 100644 --- a/lib/plugins/popularity/action.php +++ b/lib/plugins/popularity/action.php @@ -9,6 +9,10 @@ require_once(DOKU_PLUGIN.'action.php'); require_once(DOKU_PLUGIN.'popularity/admin.php'); class action_plugin_popularity extends Dokuwiki_Action_Plugin { + + /** + * @var helper_plugin_popularity + */ var $helper; function action_plugin_popularity(){ @@ -22,7 +26,7 @@ class action_plugin_popularity extends Dokuwiki_Action_Plugin { $controller->register_hook('INDEXER_TASKS_RUN', 'AFTER', $this, '_autosubmit', array()); } - function _autosubmit(&$event, $param){ + function _autosubmit(Doku_Event &$event, $param){ //Do we have to send the data now if ( !$this->helper->isAutosubmitEnabled() || $this->_isTooEarlyToSubmit() ){ return; diff --git a/lib/plugins/popularity/admin.php b/lib/plugins/popularity/admin.php index 474a09ef9..deb8048f4 100644 --- a/lib/plugins/popularity/admin.php +++ b/lib/plugins/popularity/admin.php @@ -14,6 +14,10 @@ if(!defined('DOKU_INC')) die(); */ class admin_plugin_popularity extends DokuWiki_Admin_Plugin { var $version; + + /** + * @var helper_plugin_popularity + */ var $helper; var $sentStatus = null; @@ -118,9 +122,9 @@ class admin_plugin_popularity extends DokuWiki_Admin_Plugin { /** * Build the form which presents the data to be sent - * @param string $submit How is the data supposed to be sent? (may be: 'browser' or 'server') + * @param string $submissionMode How is the data supposed to be sent? (may be: 'browser' or 'server') * @param string $data The popularity data, if it has already been computed. NULL otherwise. - * @return The form, as an html string + * @return string The form, as an html string */ function buildForm($submissionMode, $data = null){ $url = ($submissionMode === 'browser' ? $this->helper->submitUrl : script()); diff --git a/lib/plugins/popularity/helper.php b/lib/plugins/popularity/helper.php index 34521021d..5bbeddba0 100644 --- a/lib/plugins/popularity/helper.php +++ b/lib/plugins/popularity/helper.php @@ -29,6 +29,8 @@ class helper_plugin_popularity extends Dokuwiki_Plugin { */ var $popularityLastSubmitFile; + var $version; + function helper_plugin_popularity(){ global $conf; @@ -69,7 +71,7 @@ class helper_plugin_popularity extends Dokuwiki_Plugin { /** * Check if autosubmit is enabled - * @return TRUE if we should send data once a month, FALSE otherwise + * @return boolean TRUE if we should send data once a month, FALSE otherwise */ function isAutoSubmitEnabled(){ return @file_exists($this->autosubmitFile); @@ -78,7 +80,7 @@ class helper_plugin_popularity extends Dokuwiki_Plugin { /** * Send the data, to the submit url * @param string $data The popularity data - * @return An empty string if everything worked fine, a string describing the error otherwise + * @return string An empty string if everything worked fine, a string describing the error otherwise */ function sendData($data){ $error = ''; @@ -102,7 +104,7 @@ class helper_plugin_popularity extends Dokuwiki_Plugin { /** * Gather all information - * @return The popularity data as a string + * @return string The popularity data as a string */ function gatherAsString(){ $data = $this->_gather(); @@ -119,7 +121,7 @@ class helper_plugin_popularity extends Dokuwiki_Plugin { /** * Gather all information - * @return The popularity data as an array + * @return array The popularity data as an array */ function _gather(){ global $conf; diff --git a/lib/plugins/revert/admin.php b/lib/plugins/revert/admin.php index 958cf5acf..fcdaa230d 100644 --- a/lib/plugins/revert/admin.php +++ b/lib/plugins/revert/admin.php @@ -73,8 +73,6 @@ class admin_plugin_revert extends DokuWiki_Admin_Plugin { * Start the reversion process */ function _revert($revert,$filter){ - global $conf; - echo '

    '; echo '

    '.$this->getLang('revstart').'

    '; diff --git a/lib/plugins/syntax.php b/lib/plugins/syntax.php index 8b94493e4..552cc747a 100644 --- a/lib/plugins/syntax.php +++ b/lib/plugins/syntax.php @@ -84,13 +84,13 @@ class DokuWiki_Syntax_Plugin extends Doku_Parser_Mode { * * Usually you should only need the $match param. * - * @param $match string The text matched by the patterns - * @param $state int The lexer state for the match - * @param $pos int The character position of the matched text - * @param $handler Doku_Handler Reference to the Doku_Handler object - * @return array Return an array with all data you want to use in render + * @param string $match The text matched by the patterns + * @param int $state The lexer state for the match + * @param int $pos The character position of the matched text + * @param Doku_Handler $handler Reference to the Doku_Handler object + * @return array Return an array with all data you want to use in render */ - function handle($match, $state, $pos, &$handler){ + function handle($match, $state, $pos, Doku_Handler &$handler){ trigger_error('handle() not implemented in '.get_class($this), E_USER_WARNING); } @@ -117,7 +117,7 @@ class DokuWiki_Syntax_Plugin extends Doku_Parser_Mode { * @param $data array data created by handler() * @return boolean rendered correctly? */ - function render($format, &$renderer, $data) { + function render($format, Doku_Renderer &$renderer, $data) { trigger_error('render() not implemented in '.get_class($this), E_USER_WARNING); } diff --git a/lib/plugins/usermanager/admin.php b/lib/plugins/usermanager/admin.php index 30b65debb..cf8963e64 100644 --- a/lib/plugins/usermanager/admin.php +++ b/lib/plugins/usermanager/admin.php @@ -73,8 +73,6 @@ class admin_plugin_usermanager extends DokuWiki_Admin_Plugin { * handle user request */ function handle() { - global $ID; - if (is_null($this->_auth)) return false; // extract the command and any specific parameters @@ -308,7 +306,6 @@ class admin_plugin_usermanager extends DokuWiki_Admin_Plugin { function _htmlInputField($id, $name, $label, $value, $cando, $indent=0) { $class = $cando ? '' : ' class="disabled"'; - $disabled = $cando ? '' : ' disabled="disabled"'; echo str_pad('',$indent); if($name == 'userpass'){ @@ -549,7 +546,7 @@ class admin_plugin_usermanager extends DokuWiki_Admin_Plugin { /** * retrieve & clean user data from the form * - * @return array(user, password, full name, email, array(groups)) + * @return array (user, password, full name, email, array(groups)) */ function _retrieveUser($clean=true) { global $auth; -- cgit v1.2.3 From f2cb3ec76dec3fe2b40f25765ef842223c7132fe Mon Sep 17 00:00:00 2001 From: Elan Ruusamäe Date: Wed, 23 Jan 2013 13:55:25 +0200 Subject: handle bzip1 as well in fact .tbz is tar.bz (bzip1) and .tbz2 is what tar.bz2 is used commonly. --- _test/tests/inc/tar.test.php | 18 +++++++++++------- inc/Tar.class.php | 4 ++-- lib/plugins/plugin/classes/ap_download.class.php | 2 +- 3 files changed, 14 insertions(+), 10 deletions(-) (limited to 'lib/plugins/plugin/classes/ap_download.class.php') diff --git a/_test/tests/inc/tar.test.php b/_test/tests/inc/tar.test.php index e8805a75d..f27b9506b 100644 --- a/_test/tests/inc/tar.test.php +++ b/_test/tests/inc/tar.test.php @@ -73,7 +73,7 @@ class Tar_TestCase extends DokuWikiTest { public function test_tarcontent() { $dir = dirname(__FILE__).'/tar'; - foreach(array('tar', 'tgz', 'tbz') as $ext) { + foreach(array('tar', 'tgz', 'tbz', 'tbz2') as $ext) { $tar = new Tar(); $file = "$dir/test.$ext"; @@ -96,7 +96,7 @@ class Tar_TestCase extends DokuWikiTest { $dir = dirname(__FILE__).'/tar'; $out = sys_get_temp_dir().'/dwtartest'.md5(time()); - foreach(array('tar', 'tgz', 'tbz') as $ext) { + foreach(array('tar', 'tgz', 'tbz', 'tbz2') as $ext) { $tar = new Tar(); $file = "$dir/test.$ext"; @@ -122,7 +122,7 @@ class Tar_TestCase extends DokuWikiTest { $dir = dirname(__FILE__).'/tar'; $out = sys_get_temp_dir().'/dwtartest'.md5(time()); - foreach(array('tar', 'tgz', 'tbz') as $ext) { + foreach(array('tar', 'tgz', 'tbz', 'tbz2') as $ext) { $tar = new Tar(); $file = "$dir/test.$ext"; @@ -148,7 +148,7 @@ class Tar_TestCase extends DokuWikiTest { $dir = dirname(__FILE__).'/tar'; $out = sys_get_temp_dir().'/dwtartest'.md5(time()); - foreach(array('tar', 'tgz', 'tbz') as $ext) { + foreach(array('tar', 'tgz', 'tbz', 'tbz2') as $ext) { $tar = new Tar(); $file = "$dir/test.$ext"; @@ -174,7 +174,7 @@ class Tar_TestCase extends DokuWikiTest { $dir = dirname(__FILE__).'/tar'; $out = sys_get_temp_dir().'/dwtartest'.md5(time()); - foreach(array('tar', 'tgz', 'tbz') as $ext) { + foreach(array('tar', 'tgz', 'tbz', 'tbz2') as $ext) { $tar = new Tar(); $file = "$dir/test.$ext"; @@ -199,7 +199,7 @@ class Tar_TestCase extends DokuWikiTest { $dir = dirname(__FILE__).'/tar'; $out = sys_get_temp_dir().'/dwtartest'.md5(time()); - foreach(array('tar', 'tgz', 'tbz') as $ext) { + foreach(array('tar', 'tgz', 'tbz', 'tbz2') as $ext) { $tar = new Tar(); $file = "$dir/test.$ext"; @@ -229,6 +229,10 @@ class Tar_TestCase extends DokuWikiTest { $this->assertEquals(Tar::COMPRESS_GZIP, $tar->filetype('foo.tar.gz')); $this->assertEquals(Tar::COMPRESS_BZIP, $tar->filetype('foo.tbz')); $this->assertEquals(Tar::COMPRESS_BZIP, $tar->filetype('foo.tBZ')); + $this->assertEquals(Tar::COMPRESS_BZIP, $tar->filetype('foo.tbz2')); + $this->assertEquals(Tar::COMPRESS_BZIP, $tar->filetype('foo.tBZ2')); + $this->assertEquals(Tar::COMPRESS_BZIP, $tar->filetype('foo.tar.bz')); + $this->assertEquals(Tar::COMPRESS_BZIP, $tar->filetype('foo.tar.BZ')); $this->assertEquals(Tar::COMPRESS_BZIP, $tar->filetype('foo.tar.BZ2')); $this->assertEquals(Tar::COMPRESS_BZIP, $tar->filetype('foo.tar.bz2')); } @@ -316,4 +320,4 @@ class Tar_TestCase extends DokuWikiTest { TestUtils::rdelete($out); } -} \ No newline at end of file +} diff --git a/inc/Tar.class.php b/inc/Tar.class.php index 59e14c705..86fe65abb 100644 --- a/inc/Tar.class.php +++ b/inc/Tar.class.php @@ -618,7 +618,7 @@ class Tar { $file = strtolower($file); if(substr($file, -3) == '.gz' || substr($file, -4) == '.tgz') { $comptype = Tar::COMPRESS_GZIP; - } elseif(substr($file, -4) == '.bz2' || substr($file, -4) == '.tbz') { + } elseif(substr($file, -4) == '.bz2' || substr($file, -3) == '.bz' || substr($file, -4) == '.tbz' || substr($file, -5) == ".tbz2") { $comptype = Tar::COMPRESS_BZIP; } else { $comptype = Tar::COMPRESS_NONE; @@ -631,4 +631,4 @@ class TarIOException extends Exception { } class TarIllegalCompressionException extends Exception { -} \ No newline at end of file +} diff --git a/lib/plugins/plugin/classes/ap_download.class.php b/lib/plugins/plugin/classes/ap_download.class.php index 3cc455867..e13d1b8f2 100644 --- a/lib/plugins/plugin/classes/ap_download.class.php +++ b/lib/plugins/plugin/classes/ap_download.class.php @@ -195,7 +195,7 @@ class ap_download extends ap_manage { if (substr($target, -1) == "/") $target = substr($target, 0, -1); $ext = $this->guess_archive($file); - if (in_array($ext, array('tar','bz','gz'))) { + if (in_array($ext, array('tar','bz','bz2','gz'))) { switch($ext){ case 'bz': $compress_type = Tar::COMPRESS_BZIP; -- cgit v1.2.3 From 7afccd0aab62eed3797273e5241b7729bab1fb3f Mon Sep 17 00:00:00 2001 From: Andreas Gohr Date: Wed, 23 Jan 2013 16:16:18 +0100 Subject: Revert "handle bzip1 as well" This reverts commit f2cb3ec76dec3fe2b40f25765ef842223c7132fe. Turns out I was too fast merging this. I can't get PHP's bzip handler to handle a bzip1 compressed file. --- _test/tests/inc/tar.test.php | 18 +++++++----------- inc/Tar.class.php | 2 +- lib/plugins/plugin/classes/ap_download.class.php | 2 +- 3 files changed, 9 insertions(+), 13 deletions(-) (limited to 'lib/plugins/plugin/classes/ap_download.class.php') diff --git a/_test/tests/inc/tar.test.php b/_test/tests/inc/tar.test.php index f27b9506b..e8805a75d 100644 --- a/_test/tests/inc/tar.test.php +++ b/_test/tests/inc/tar.test.php @@ -73,7 +73,7 @@ class Tar_TestCase extends DokuWikiTest { public function test_tarcontent() { $dir = dirname(__FILE__).'/tar'; - foreach(array('tar', 'tgz', 'tbz', 'tbz2') as $ext) { + foreach(array('tar', 'tgz', 'tbz') as $ext) { $tar = new Tar(); $file = "$dir/test.$ext"; @@ -96,7 +96,7 @@ class Tar_TestCase extends DokuWikiTest { $dir = dirname(__FILE__).'/tar'; $out = sys_get_temp_dir().'/dwtartest'.md5(time()); - foreach(array('tar', 'tgz', 'tbz', 'tbz2') as $ext) { + foreach(array('tar', 'tgz', 'tbz') as $ext) { $tar = new Tar(); $file = "$dir/test.$ext"; @@ -122,7 +122,7 @@ class Tar_TestCase extends DokuWikiTest { $dir = dirname(__FILE__).'/tar'; $out = sys_get_temp_dir().'/dwtartest'.md5(time()); - foreach(array('tar', 'tgz', 'tbz', 'tbz2') as $ext) { + foreach(array('tar', 'tgz', 'tbz') as $ext) { $tar = new Tar(); $file = "$dir/test.$ext"; @@ -148,7 +148,7 @@ class Tar_TestCase extends DokuWikiTest { $dir = dirname(__FILE__).'/tar'; $out = sys_get_temp_dir().'/dwtartest'.md5(time()); - foreach(array('tar', 'tgz', 'tbz', 'tbz2') as $ext) { + foreach(array('tar', 'tgz', 'tbz') as $ext) { $tar = new Tar(); $file = "$dir/test.$ext"; @@ -174,7 +174,7 @@ class Tar_TestCase extends DokuWikiTest { $dir = dirname(__FILE__).'/tar'; $out = sys_get_temp_dir().'/dwtartest'.md5(time()); - foreach(array('tar', 'tgz', 'tbz', 'tbz2') as $ext) { + foreach(array('tar', 'tgz', 'tbz') as $ext) { $tar = new Tar(); $file = "$dir/test.$ext"; @@ -199,7 +199,7 @@ class Tar_TestCase extends DokuWikiTest { $dir = dirname(__FILE__).'/tar'; $out = sys_get_temp_dir().'/dwtartest'.md5(time()); - foreach(array('tar', 'tgz', 'tbz', 'tbz2') as $ext) { + foreach(array('tar', 'tgz', 'tbz') as $ext) { $tar = new Tar(); $file = "$dir/test.$ext"; @@ -229,10 +229,6 @@ class Tar_TestCase extends DokuWikiTest { $this->assertEquals(Tar::COMPRESS_GZIP, $tar->filetype('foo.tar.gz')); $this->assertEquals(Tar::COMPRESS_BZIP, $tar->filetype('foo.tbz')); $this->assertEquals(Tar::COMPRESS_BZIP, $tar->filetype('foo.tBZ')); - $this->assertEquals(Tar::COMPRESS_BZIP, $tar->filetype('foo.tbz2')); - $this->assertEquals(Tar::COMPRESS_BZIP, $tar->filetype('foo.tBZ2')); - $this->assertEquals(Tar::COMPRESS_BZIP, $tar->filetype('foo.tar.bz')); - $this->assertEquals(Tar::COMPRESS_BZIP, $tar->filetype('foo.tar.BZ')); $this->assertEquals(Tar::COMPRESS_BZIP, $tar->filetype('foo.tar.BZ2')); $this->assertEquals(Tar::COMPRESS_BZIP, $tar->filetype('foo.tar.bz2')); } @@ -320,4 +316,4 @@ class Tar_TestCase extends DokuWikiTest { TestUtils::rdelete($out); } -} +} \ No newline at end of file diff --git a/inc/Tar.class.php b/inc/Tar.class.php index 20d892e68..20f397395 100644 --- a/inc/Tar.class.php +++ b/inc/Tar.class.php @@ -618,7 +618,7 @@ class Tar { $file = strtolower($file); if(substr($file, -3) == '.gz' || substr($file, -4) == '.tgz') { $comptype = Tar::COMPRESS_GZIP; - } elseif(substr($file, -4) == '.bz2' || substr($file, -3) == '.bz' || substr($file, -4) == '.tbz' || substr($file, -5) == ".tbz2") { + } elseif(substr($file, -4) == '.bz2' || substr($file, -4) == '.tbz') { $comptype = Tar::COMPRESS_BZIP; } else { $comptype = Tar::COMPRESS_NONE; diff --git a/lib/plugins/plugin/classes/ap_download.class.php b/lib/plugins/plugin/classes/ap_download.class.php index e13d1b8f2..3cc455867 100644 --- a/lib/plugins/plugin/classes/ap_download.class.php +++ b/lib/plugins/plugin/classes/ap_download.class.php @@ -195,7 +195,7 @@ class ap_download extends ap_manage { if (substr($target, -1) == "/") $target = substr($target, 0, -1); $ext = $this->guess_archive($file); - if (in_array($ext, array('tar','bz','bz2','gz'))) { + if (in_array($ext, array('tar','bz','gz'))) { switch($ext){ case 'bz': $compress_type = Tar::COMPRESS_BZIP; -- cgit v1.2.3