X-Git-Url: https://delta.frontaccounting.com/gitweb/?a=blobdiff_plain;f=includes%2Fpackages.inc;h=54d16abf5b4bf31cd15ff29f8b048a6acd0b9c94;hb=6bcd87642330092910f5d6977845a76ac59350ac;hp=2dc7bd3e46a87ac931ee5eede02ba604b7c45b58;hpb=8ffddf50ffbe93672c769e2cf0501d0f9125e2a0;p=fa-stable.git diff --git a/includes/packages.inc b/includes/packages.inc index 2dc7bd3e..54d16abf 100644 --- a/includes/packages.inc +++ b/includes/packages.inc @@ -19,7 +19,8 @@ define('PUBKEY_PATH', $path_to_root); // FrontAccounting package class // class package extends gzip_file { - function package($filename, $basedir=null) + + function __construct($filename, $basedir=null) { global $path_to_root; @@ -30,7 +31,7 @@ class package extends gzip_file { } else mkdir($basedir); } - $this->archive($filename); + parent::__construct($filename); $this->set_options(array('basedir'=> $basedir)); $this->options['type'] = "pkg"; } @@ -281,7 +282,7 @@ function get_pkg_or_list($type = null, $pkgname = null, $filter=array(), $outkey // and check remote signature with local copy of public key // $loclist = PKG_CACHE_PATH.'/Release.gz'; - $target_dir = $download==true ? "$path_to_root/tmp/" : $download; + $target_dir = $download==true ? VARLIB_PATH."/" : $download; if (isset($type) && !is_array($type)) { $type = array($type); @@ -299,6 +300,10 @@ function get_pkg_or_list($type = null, $pkgname = null, $filter=array(), $outkey $sig = url_get_contents($repo.'/Release.sig'); $data = file_get_contents($loclist); $cert = file_get_contents(PUBKEY_PATH.'/FA.pem'); + if (!function_exists('openssl_verify')) { + display_error(_("OpenSSL have to be available on your server to use extension repository system.")); + return null; + } if (openssl_verify($data, $sig, $cert) <= 0) { if ($refresh) { if (!@unlink($loclist)) @@ -617,7 +622,7 @@ function install_language($pkg_name) uninstall_package($old_pkg); } - $package = new package("$path_to_root/tmp/".$pkg['Filename'].'.pkg'); + $package = new package(VARLIB_PATH."/".$pkg['Filename'].'.pkg'); if ($package->install()) { $lang = array( 'name' => $pkg['Name'], @@ -631,7 +636,7 @@ function install_language($pkg_name) $lang['rtl'] = true; $installed_languages[$i] = $lang; write_lang($installed_languages); - unlink("$path_to_root/tmp/".$pkg['Filename'].'.pkg'); + unlink(VARLIB_PATH."/".$pkg['Filename'].'.pkg'); $Ajax->activate('lang_tbl'); } else { display_error(implode('
', $package->error)); @@ -652,7 +657,7 @@ function install_extension($pkg_name) $pkg = get_pkg_or_list(array('extension', 'theme', 'chart'), $pkg_name); if ($pkg) { - $package = new package("$path_to_root/tmp/".$pkg['Filename'].'.pkg'); + $package = new package(VARLIB_PATH."/".$pkg['Filename'].'.pkg'); $local_exts = get_company_extensions(); if ($package->install()) { $ext_id = array_search_key($pkg['Package'], $local_exts, 'package'); @@ -671,12 +676,6 @@ function install_extension($pkg_name) 'active' => @$pkg['DefaultStatus'] == 'active' ? true : false, 'path' => $pkg['InstallPath'], ); -// if (isset($pkg['MenuTabs'])) -// $ext['tabs'] = $pkg['MenuTabs']; -// if (isset($pkg['MenuEntries'])) -// $ext['entries'] = $pkg['MenuEntries']; -// if (isset($pkg['AccessExtensions'])) -// $ext['acc_file'] = $pkg['AccessExtensions']; if (isset($pkg['SqlScript'])) $ext['sql'] = $pkg['SqlScript']; @@ -691,7 +690,7 @@ function install_extension($pkg_name) activate_hooks($ext['package'], $comp); } - unlink("$path_to_root/tmp/".$pkg['Filename'].'.pkg'); + unlink(VARLIB_PATH."/".$pkg['Filename'].'.pkg'); $Ajax->activate('ext_tbl'); return $ret; } else { @@ -733,16 +732,15 @@ function get_package_info($pkg, $type=null, $filter=array(), $outkey=null, $down */ function check_src_ext_version($ext_v) { - global $src_version; - - $compat_levels = 2; // current policy is keeping compatibility on major version level. - $app = explode('.', strspn($src_version, "0123456789.")); - $pkg = explode('.', strspn($ext_v, "0123456789.")); - - for ($i=0; $i < min($compat_levels, count($app)); $i++) - if ($pkg[$i] < $app[$i]) - return false; - - return true; + global $src_version; + if ($ext_v != '-') { + $compat_levels = 2; // current policy is keeping compatibility on major version level. + $app = explode('.', substr($src_version, 0, strspn($src_version, "0123456789."))); + $pkg = explode('.', substr($ext_v, 0, strspn($ext_v, "0123456789."))); + + for ($i=0; $i < min($compat_levels, count($app)); $i++) + if ($pkg[$i] < $app[$i]) + return false; + } + return true; } -