fetch file

This commit is contained in:
Abdulrahman
2019-05-19 02:40:43 +03:00
parent fa882c423c
commit 3c0aaebce9
9 changed files with 357 additions and 254 deletions

View File

@@ -144,7 +144,7 @@ switch ($case):
{
$store_link = 'https://raw.githubusercontent.com/kleeja-official/store-catalog/master/catalog.json';
$store_catalog = fetch_remote_file($store_link);
$store_catalog = FetchFile::make($store_link)->get();
$store_catalog = json_decode($store_catalog, true);
if (json_last_error() == JSON_ERROR_NONE)
@@ -552,7 +552,7 @@ switch ($case):
// plugins avilable in kleeja store
$store_link = 'https://raw.githubusercontent.com/kleeja-official/store-catalog/master/catalog.json';
$catalog_plugins = fetch_remote_file($store_link);
$catalog_plugins = FetchFile::make($store_link)->get();
if ($catalog_plugins)
{
@@ -587,7 +587,10 @@ switch ($case):
) {
$plugin_name_link = $store_plugins[$plugin_name]['url'];
$plugin_archive = fetch_remote_file($plugin_name_link, PATH . 'cache/' . $plugin_name . '.zip', 60, false, 10, true);
$plugin_archive = FetchFile::make($plugin_name_link)
->setDestinationPath(PATH . 'cache/' . $plugin_name . '.zip')
->isBinaryFile(true)
->get();
if ($plugin_archive)
{

View File

@@ -117,7 +117,7 @@ case 'store':
{
$store_link = 'https://raw.githubusercontent.com/kleeja-official/store-catalog/master/catalog.json';
$store_catalog = fetch_remote_file($store_link);
$store_catalog = FetchFile::make($store_link)->get();
$store_catalog = json_decode($store_catalog, true);
if (json_last_error() == JSON_ERROR_NONE)
@@ -382,7 +382,7 @@ case 'download':
// plugins avilable in kleeja store
$store_link = 'https://raw.githubusercontent.com/kleeja-official/store-catalog/master/catalog.json';
$catalog_styles = fetch_remote_file($store_link);
$catalog_styles = FetchFile::make($store_link)->get();
if ($catalog_styles)
{
@@ -417,7 +417,10 @@ case 'download':
) {
$style_name_link = $store_styles[$style_name]['url'];
$style_archive = fetch_remote_file($style_name_link, PATH . 'cache/' . $style_name . '.zip', 60, false, 10, true);
$style_archive = FetchFile::make($style_name_link)
->setDestinationPath(PATH . 'cache/' . $style_name . '.zip')
->isBinaryFile(true)
->get();
if ($style_archive)
{

View File

@@ -54,7 +54,7 @@ if ($current_smt == 'check')
//get data from kleeja github repo
if (! ($version_data = $cache->get('kleeja_repo_version')))
{
$github_data = fetch_remote_file(KLEEJA_VERSION_CHECK_LINK, false, 100);
$github_data = FetchFile::make(KLEEJA_VERSION_CHECK_LINK)->setTimeOut(100)->get();
if (! empty($github_data))
{
@@ -151,7 +151,10 @@ elseif ($current_smt == 'update1')
else
{
// downloaded the last package to cache folder
fetch_remote_file(KLEEJA_LATEST_PACKAGE_LINK . $new_version, PATH . "cache/kleeja-{$new_version}.zip", 60, false, 10, true);
FetchFile::make(KLEEJA_LATEST_PACKAGE_LINK . $new_version)
->setDestinationPath(PATH . "cache/kleeja-{$new_version}.zip")
->isBinaryFile(true)
->get();
if (file_exists(PATH . "cache/kleeja-{$new_version}.zip"))
{

View File

@@ -177,7 +177,7 @@ if (! empty($d_groups) && is_array($d_groups))
// rev: let's say cache is not refreshed, so we will redirect alots of time,
// so update_done will be good solution
//
if (empty($v['last_check']) || ((time() - $v['last_check']) > 3600 * 24 * 10 && $_SERVER['SERVER_NAME'] != 'localhost' && ! ig('update_done')))
if ((empty($v['last_check']) || time() - $v['last_check'] > 3600 * 24 * 10) && ! ig('update_done'))
{
redirect(basename(ADMIN_PATH) . '?cp=p_check_update&show_msg=1');
$SQL->close();