Fix our updater and use GitHub releases (#991)

* Updater works until the unzip process

* Use modern zip library

* Re-enable the json cache

* Simplifying

* Fix merge conflict

Co-authored-by: Yağızhan <yagizhan49@protonmail.com>
This commit is contained in:
Benjamin AerniandYağızhan authored and GitHub committed 2021-08-24 05:49:16 -07:00
1 parent c898832713
commit 8f842fb400
6 files changed
+245 -5723

No files matched your search

+6 -2
View File
@@ -55,9 +55,13 @@ class Box_Tools
}
}
public function file_get_contents($filename, $use_include_path = false, $context = null, $offset = -1)
public function file_get_contents($filename, $use_include_path = false, $context = null, $offset = -1, $useoffset = true)
{
return file_get_contents($filename, $use_include_path, $context, $offset);
if($useoffset){
return file_get_contents($filename, $use_include_path, $context, $offset);
} else {
return file_get_contents($filename, $use_include_path, $context);
}
}
public function get_url($url, $timeout = 10)
+7 -17
View File
@@ -32,15 +32,8 @@ class Box_Update
{
return $this->di;
}
private $_url = 'https://api.github.com/repos/boxbilling/boxbilling/releases/latest';
private $_url = 'http://api.boxbilling.com/compare-version.php';
public function __construct()
{
if(defined('BB_VERSION_URL') && BB_VERSION_URL) {
$this->_url = BB_VERSION_URL;
}
}
/**
* Returns latest information
@@ -57,10 +50,10 @@ class Box_Update
public function getLatestVersion()
{
$response = $this->_getLatestVersionInfo();
if(!is_object($response)) {
if(!isset($response['tag_name'])){
return Box_Version::VERSION;
}
return $response->version;
return $response['tag_name'];
}
/**
@@ -70,10 +63,7 @@ class Box_Update
public function getLatestVersionDownloadLink()
{
$response = $this->_getLatestVersionInfo();
if(isset($response->update)) {
return $response->update;
}
return $response->link;
return $response['assets'][0]['browser_download_url'];
}
/**
@@ -105,11 +95,11 @@ class Box_Update
public function getJson()
{
$url = $this->_url . '?current=' . Box_Version::VERSION;
$url = $this->_url;
$curl = new Box_Curl($url);
$curl->request();
$response = $curl->getBody();
return json_decode($response);
return json_decode($response, true);
}
/**
@@ -128,7 +118,7 @@ class Box_Update
$latest_version_archive = BB_PATH_CACHE.DIRECTORY_SEPARATOR.$latest_version.'.zip';
// download latest archive from link
$content = $this->di['tools']->file_get_contents($this->getLatestVersionDownloadLink());
$content = $this->di['tools']->file_get_contents($this->getLatestVersionDownloadLink(), false, null, null, false);
$f = fopen($latest_version_archive,'wb');
fwrite($f,$content,strlen($content));
fclose($f);
+1 -3
View File
@@ -30,8 +30,6 @@ final class Box_Version
*/
public static function compareVersion($version)
{
$version = strtolower($version);
$version = preg_replace('/(\d)pr(\d?)/', '$1a$2', $version);
return version_compare($version, strtolower(self::VERSION));
return version_compare(strtolower($version), strtolower(self::VERSION));
}
}
+10 -5699
View File
File diff suppressed because it is too large. Load diff
+2 -1
View File
@@ -28,7 +28,8 @@
"guzzlehttp/guzzle": "*",
"laminas/laminas-httphandlerrunner": "^2.0.1",
"docnet/tfpdf": "^2.2",
"infinityfree/mofh-client": "^0.7.0"
"infinityfree/mofh-client": "^0.7.0",
"nelexa/zip": "^4.0.0"
},
"suggest": {
"ext-gettext": "*"
+219 -1
View File
@@ -4,7 +4,7 @@
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
"This file is @generated automatically"
],
"content-hash": "c7d0339db92fc6588a4c86b4e7542676",
"content-hash": "14c60af4031e822101c9a0923cea92d9",
"packages": [
{
"name": "composer/ca-bundle",
@@ -764,6 +764,79 @@
],
"time": "2019-09-10T13:16:29+00:00"
},
{
"name": "nelexa/zip",
"version": "4.0.0",
"source": {
"type": "git",
"url": "https://github.com/Ne-Lexa/php-zip.git",
"reference": "668afcf81ac4f05fbc428fd137507a13eb49fa9e"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/Ne-Lexa/php-zip/zipball/668afcf81ac4f05fbc428fd137507a13eb49fa9e",
"reference": "668afcf81ac4f05fbc428fd137507a13eb49fa9e",
"shasum": ""
},
"require": {
"ext-zlib": "*",
"php": "^7.4 || ^8.0",
"psr/http-message": "^1.0",
"symfony/finder": "^3.0 || ^4.0 || ^5.0"
},
"require-dev": {
"ext-bz2": "*",
"ext-dom": "*",
"ext-fileinfo": "*",
"ext-iconv": "*",
"ext-openssl": "*",
"ext-xml": "*",
"friendsofphp/php-cs-fixer": "^2.18",
"guzzlehttp/psr7": "^1.6",
"phpunit/phpunit": "^9",
"symfony/http-foundation": "^5.2",
"symfony/var-dumper": "^5.0",
"vimeo/psalm": "^4.6"
},
"suggest": {
"ext-bz2": "Needed to support BZIP2 compression",
"ext-fileinfo": "Needed to get mime-type file",
"ext-iconv": "Needed to support convert zip entry name to requested character encoding",
"ext-openssl": "Needed to support encrypt zip entries or use ext-mcrypt"
},
"type": "library",
"autoload": {
"psr-4": {
"PhpZip\\": "src/"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Ne-Lexa",
"email": "alexey@nelexa.ru",
"role": "Developer"
}
],
"description": "PhpZip is a php-library for extended work with ZIP-archives. Open, create, update, delete, extract and get info tool. Supports appending to existing ZIP files, WinZip AES encryption, Traditional PKWARE Encryption, BZIP2 compression, external file attributes and ZIP64 extensions. Alternative ZipArchive. It does not require php-zip extension.",
"homepage": "https://github.com/Ne-Lexa/php-zip",
"keywords": [
"archive",
"extract",
"unzip",
"winzip",
"zip",
"ziparchive"
],
"support": {
"issues": "https://github.com/Ne-Lexa/php-zip/issues",
"source": "https://github.com/Ne-Lexa/php-zip/tree/4.0.0"
},
"time": "2021-02-24T12:51:19+00:00"
},
{
"name": "phpmailer/phpmailer",
"version": "v6.5.1",
@@ -1265,6 +1338,68 @@
},
"time": "2021-08-19T14:15:27+00:00"
},
{
"name": "symfony/finder",
"version": "v5.3.4",
"source": {
"type": "git",
"url": "https://github.com/symfony/finder.git",
"reference": "17f50e06018baec41551a71a15731287dbaab186"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/symfony/finder/zipball/17f50e06018baec41551a71a15731287dbaab186",
"reference": "17f50e06018baec41551a71a15731287dbaab186",
"shasum": ""
},
"require": {
"php": ">=7.2.5",
"symfony/polyfill-php80": "^1.16"
},
"type": "library",
"autoload": {
"psr-4": {
"Symfony\\Component\\Finder\\": ""
},
"exclude-from-classmap": [
"/Tests/"
]
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Fabien Potencier",
"email": "fabien@symfony.com"
},
{
"name": "Symfony Community",
"homepage": "https://symfony.com/contributors"
}
],
"description": "Finds files and directories via an intuitive fluent interface",
"homepage": "https://symfony.com",
"support": {
"source": "https://github.com/symfony/finder/tree/v5.3.4"
},
"funding": [
{
"url": "https://symfony.com/sponsor",
"type": "custom"
},
{
"url": "https://github.com/fabpot",
"type": "github"
},
{
"url": "https://tidelift.com/funding/github/packagist/symfony/symfony",
"type": "tidelift"
}
],
"time": "2021-07-23T15:54:19+00:00"
},
{
"name": "symfony/polyfill-ctype",
"version": "v1.23.0",
@@ -1424,6 +1559,89 @@
],
"time": "2021-05-27T12:26:48+00:00"
},
{
"name": "symfony/polyfill-php80",
"version": "v1.23.1",
"source": {
"type": "git",
"url": "https://github.com/symfony/polyfill-php80.git",
"reference": "1100343ed1a92e3a38f9ae122fc0eb21602547be"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/symfony/polyfill-php80/zipball/1100343ed1a92e3a38f9ae122fc0eb21602547be",
"reference": "1100343ed1a92e3a38f9ae122fc0eb21602547be",
"shasum": ""
},
"require": {
"php": ">=7.1"
},
"type": "library",
"extra": {
"branch-alias": {
"dev-main": "1.23-dev"
},
"thanks": {
"name": "symfony/polyfill",
"url": "https://github.com/symfony/polyfill"
}
},
"autoload": {
"psr-4": {
"Symfony\\Polyfill\\Php80\\": ""
},
"files": [
"bootstrap.php"
],
"classmap": [
"Resources/stubs"
]
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Ion Bazan",
"email": "ion.bazan@gmail.com"
},
{
"name": "Nicolas Grekas",
"email": "p@tchwork.com"
},
{
"name": "Symfony Community",
"homepage": "https://symfony.com/contributors"
}
],
"description": "Symfony polyfill backporting some PHP 8.0+ features to lower PHP versions",
"homepage": "https://symfony.com",
"keywords": [
"compatibility",
"polyfill",
"portable",
"shim"
],
"support": {
"source": "https://github.com/symfony/polyfill-php80/tree/v1.23.1"
},
"funding": [
{
"url": "https://symfony.com/sponsor",
"type": "custom"
},
{
"url": "https://github.com/fabpot",
"type": "github"
},
{
"url": "https://tidelift.com/funding/github/packagist/symfony/symfony",
"type": "tidelift"
}
],
"time": "2021-07-28T13:41:28+00:00"
},
{
"name": "twig/extensions",
"version": "v1.5.4",