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') 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/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 -- 3 files changed, 2 insertions(+), 10 deletions(-) (limited to 'lib/plugins/plugin/classes') 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 ''; -- cgit v1.2.3 From f2cb3ec76dec3fe2b40f25765ef842223c7132fe Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Elan=20Ruusam=C3=A4e?= 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. --- lib/plugins/plugin/classes/ap_download.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'lib/plugins/plugin/classes') 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. --- lib/plugins/plugin/classes/ap_download.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'lib/plugins/plugin/classes') 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