From c565d4f8df4e4b142728170fc4adc93091d54d55 Mon Sep 17 00:00:00 2001 From: Abdulrahman Date: Thu, 31 Jan 2019 20:03:35 +0300 Subject: [PATCH] fixes update check performance ... --- admin/Masmak/admin_check_update.html | 25 ++++++- admin/Masmak/admin_footer.html | 18 ----- admin/Masmak/admin_start.html | 19 ++++- admin/index.php | 6 +- includes/adm/p_check_update.php | 103 +++++++++++++-------------- includes/adm/start.php | 4 +- 6 files changed, 99 insertions(+), 76 deletions(-) diff --git a/admin/Masmak/admin_check_update.html b/admin/Masmak/admin_check_update.html index 2d1d1cf..66580ed 100755 --- a/admin/Masmak/admin_check_update.html +++ b/admin/Masmak/admin_check_update.html @@ -7,7 +7,30 @@ -
alert-warningalert-info">{text}
+
+ +
+ diff --git a/admin/Masmak/admin_footer.html b/admin/Masmak/admin_footer.html index 677f942..f79a45c 100755 --- a/admin/Masmak/admin_footer.html +++ b/admin/Masmak/admin_footer.html @@ -24,25 +24,8 @@ - - - - diff --git a/admin/Masmak/admin_start.html b/admin/Masmak/admin_start.html index 806e994..b81a359 100755 --- a/admin/Masmak/admin_start.html +++ b/admin/Masmak/admin_start.html @@ -412,7 +412,24 @@

Kleeja proudly made in Buraydah City
❤ Trusted since 2007
{kleeja_version}
- + diff --git a/admin/index.php b/admin/index.php index 5895d12..b51a2bc 100755 --- a/admin/index.php +++ b/admin/index.php @@ -439,7 +439,11 @@ if(!ig('_ajax_')) else { $is_ajax = 'yes'; - echo_ajax(1, $tpl->display($stylee, $styleePath), $go_menu_html); + + echo_ajax(1, + empty($adminAjaxContent) ? $tpl->display($stylee, $styleePath) : $adminAjaxContent, + $go_menu_html + ); } //footer diff --git a/includes/adm/p_check_update.php b/includes/adm/p_check_update.php index de84d2c..e6f7e62 100755 --- a/includes/adm/p_check_update.php +++ b/includes/adm/p_check_update.php @@ -15,57 +15,68 @@ if (!defined('IN_ADMIN')) $stylee = "admin_check_update"; $current_smt = preg_replace('/[^a-z0-9_]/i', '', g('smt', 'str', 'general')); -$error = false; $update_link = $config['siteurl'] . 'install/update.php?lang=' . $config['language']; #to prevent getting the url data for all cats -if($current_smt == 'general'): +if($current_smt == 'check'): -//get data from kleeja database -$b_url = empty($_SERVER['SERVER_NAME']) ? $config['siteurl'] : $_SERVER['SERVER_NAME']; -$b_data = fetch_remote_file('https://raw.githubusercontent.com/awssat/kleeja/master/includes/version.php', false, 6); + //get data from kleeja github repo + if (! ($version_data = $cache->get('kleeja_repo_version'))) + { + $github_data = fetch_remote_file('https://raw.githubusercontent.com/awssat/kleeja/master/includes/version.php', false, 6); + if (! empty($github_data)) + { + preg_match_all('/define\(\'KLEEJA_VERSION\',\s{1,4}\'([^\']+)\'\);/', $github_data, $matches, PREG_SET_ORDER, 0); + $version_data = trim(htmlspecialchars($matches[0][1])); + $cache->save('kleeja_repo_version', $version_data, 3600 * 2); + } + } + $error = 0; -if ($b_data === false && !ig('show_msg')) -{ - $text = $lang['ERROR_CHECK_VER']; - $error = true; -} -else -{ - preg_match_all('/define\(\'KLEEJA_VERSION\',\s{1,4}\'([^\']+)\'\);/', $b_data, $matches, PREG_SET_ORDER, 0); - - if (empty($matches[0][1])) + if(empty($version_data)) { $text = $lang['ERROR_CHECK_VER']; - $error = true; + $error = 1; } -} - - -if(!$error) -{ - $version_data = trim(htmlspecialchars($matches[0][1])); - - if (version_compare(strtolower(KLEEJA_VERSION), strtolower($version_data), '<')) + else { - $text = sprintf($lang['UPDATE_NOW_S'] , KLEEJA_VERSION, strtolower($version_data)) . '

' . $lang['UPDATE_KLJ_NOW']; - $error = true; - } - else if (version_compare(strtolower(KLEEJA_VERSION), strtolower($version_data), '=')) - { - $text = $lang['U_LAST_VER_KLJ']; - } - else if (version_compare(strtolower(KLEEJA_VERSION), strtolower($version_data), '>')) - { - $text = $lang['U_USE_PRE_RE']; + if (version_compare(strtolower(KLEEJA_VERSION), strtolower($version_data), '<')) + { + $text = sprintf($lang['UPDATE_NOW_S'] , KLEEJA_VERSION, strtolower($version_data)) . '

' . $lang['UPDATE_KLJ_NOW']; + $error = 1; + } + else if (version_compare(strtolower(KLEEJA_VERSION), strtolower($version_data), '=')) + { + $text = $lang['U_LAST_VER_KLJ']; + } + else if (version_compare(strtolower(KLEEJA_VERSION), strtolower($version_data), '>')) + { + $text = $lang['U_USE_PRE_RE']; + } } - //lets recore it - $v = @unserialize($config['new_version']); + $data = array( + 'version_number' => $version_data, + 'last_check' => time() + ); - //To prevent expected error [ infinit loop ] + $data = serialize($data); + + update_config('new_version', $SQL->real_escape($data), false); + delete_cache('data_config'); + + $adminAjaxContent = $error . ':::' . $text; + +elseif($current_smt == 'general'): + +// if(!$error) +// { + + + + //To prevent expected error [ infinit loop ] if(ig('show_msg')) { $query_get = array( @@ -83,25 +94,11 @@ if(!$error) } } - $data = array( - 'version_number' => $version_data, - 'last_check' => time(), - 'msg_appeared' => ig('show_msg') ? true : false - ); - $data = serialize($data); +// } - update_config('new_version', $SQL->real_escape($data), false); - delete_cache('data_config'); -} +$showMessage = ig('show_msg'); -//then go back to start -if(ig('show_msg')) -{ - redirect(basename(ADMIN_PATH) . '?update_done=1'); - $SQL->close(); - exit; -} #end current_smt == general endif; diff --git a/includes/adm/start.php b/includes/adm/start.php index c00993d..fd29a80 100755 --- a/includes/adm/start.php +++ b/includes/adm/start.php @@ -172,11 +172,11 @@ if(!empty($d_groups) && is_array($d_groups)) } // -// if 3 days, lets check again ! +// if 10 days, lets check again ! // 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']) > 259200 && !$v['msg_appeared'] && $_SERVER['SERVER_NAME'] != 'localhost' && !ig('update_done'))) +if (empty($v['last_check']) || ((time() - $v['last_check']) > 3600 * 24 * 10 && $_SERVER['SERVER_NAME'] != 'localhost' && !ig('update_done'))) { redirect(basename(ADMIN_PATH) . '?cp=p_check_update&show_msg=1'); $SQL->close();