2018-01-09 02:09:07 +03:00
|
|
|
<?php
|
|
|
|
|
/**
|
|
|
|
|
*
|
|
|
|
|
* @package adm
|
|
|
|
|
* @copyright (c) 2007 Kleeja.com
|
|
|
|
|
* @license ./docs/license.txt
|
|
|
|
|
*
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
// not for directly open
|
2019-05-03 23:52:08 +03:00
|
|
|
if (! defined('IN_ADMIN'))
|
2018-01-09 02:09:07 +03:00
|
|
|
{
|
2019-05-03 23:52:08 +03:00
|
|
|
exit();
|
2018-01-09 02:09:07 +03:00
|
|
|
}
|
|
|
|
|
|
2019-05-03 23:52:08 +03:00
|
|
|
$stylee = 'admin_check_update';
|
2018-01-09 02:09:07 +03:00
|
|
|
$current_smt = preg_replace('/[^a-z0-9_]/i', '', g('smt', 'str', 'general'));
|
|
|
|
|
$update_link = $config['siteurl'] . 'install/update.php?lang=' . $config['language'];
|
|
|
|
|
|
2019-05-03 23:52:08 +03:00
|
|
|
//to prevent getting the url data for all cats
|
|
|
|
|
if ($current_smt == 'check'):
|
|
|
|
|
|
|
|
|
|
//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 (empty($version_data))
|
|
|
|
|
{
|
|
|
|
|
$text = $lang['ERROR_CHECK_VER'];
|
|
|
|
|
$error = 1;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
if (version_compare(strtolower(KLEEJA_VERSION), strtolower($version_data), '<'))
|
|
|
|
|
{
|
|
|
|
|
$text = sprintf($lang['UPDATE_NOW_S'], KLEEJA_VERSION, strtolower($version_data)) . '<br /><br />' . $lang['UPDATE_KLJ_NOW'];
|
|
|
|
|
$error = 1;
|
|
|
|
|
}
|
|
|
|
|
elseif (version_compare(strtolower(KLEEJA_VERSION), strtolower($version_data), '='))
|
|
|
|
|
{
|
|
|
|
|
$text = $lang['U_LAST_VER_KLJ'];
|
|
|
|
|
}
|
|
|
|
|
elseif (version_compare(strtolower(KLEEJA_VERSION), strtolower($version_data), '>'))
|
|
|
|
|
{
|
|
|
|
|
$text = $lang['U_USE_PRE_RE'];
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
$text = $lang['ERROR_CHECK_VER'] . ' [code: ' . htmlspecialchars($version_data) . ']';
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$data = [
|
|
|
|
|
'version_number' => $version_data,
|
|
|
|
|
'last_check' => time()
|
|
|
|
|
];
|
2018-01-09 16:21:15 +03:00
|
|
|
|
2019-01-31 20:03:35 +03:00
|
|
|
$data = serialize($data);
|
2018-01-09 02:09:07 +03:00
|
|
|
|
2019-01-31 20:03:35 +03:00
|
|
|
update_config('new_version', $SQL->real_escape($data), false);
|
|
|
|
|
delete_cache('data_config');
|
2018-01-09 02:09:07 +03:00
|
|
|
|
2019-05-03 23:52:08 +03:00
|
|
|
$adminAjaxContent = $error . ':::' . $text;
|
2018-01-09 02:09:07 +03:00
|
|
|
|
2019-05-03 23:52:08 +03:00
|
|
|
elseif ($current_smt == 'general'):
|
2019-01-31 20:03:35 +03:00
|
|
|
|
|
|
|
|
// if(!$error)
|
|
|
|
|
// {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2019-05-03 23:52:08 +03:00
|
|
|
//To prevent expected error [ infinit loop ]
|
|
|
|
|
if (ig('show_msg'))
|
|
|
|
|
{
|
|
|
|
|
$query_get = [
|
|
|
|
|
'SELECT' => '*',
|
|
|
|
|
'FROM' => "{$dbprefix}config",
|
|
|
|
|
'WHERE' => "name = 'new_version'"
|
|
|
|
|
];
|
2018-01-09 02:09:07 +03:00
|
|
|
|
2019-05-03 23:52:08 +03:00
|
|
|
$result_get = $SQL->build($query_get);
|
2018-01-09 02:09:07 +03:00
|
|
|
|
2019-05-03 23:52:08 +03:00
|
|
|
if (! $SQL->num_rows($result_get))
|
|
|
|
|
{
|
|
|
|
|
//add new config value
|
|
|
|
|
add_config('new_version', '');
|
|
|
|
|
}
|
|
|
|
|
}
|
2018-01-09 02:09:07 +03:00
|
|
|
|
|
|
|
|
|
2019-01-31 20:03:35 +03:00
|
|
|
// }
|
2018-01-09 02:09:07 +03:00
|
|
|
|
2019-01-31 20:03:35 +03:00
|
|
|
$showMessage = ig('show_msg');
|
2018-01-09 02:09:07 +03:00
|
|
|
|
|
|
|
|
|
2019-05-03 23:52:08 +03:00
|
|
|
//end current_smt == general
|
2018-01-09 02:09:07 +03:00
|
|
|
endif;
|
|
|
|
|
|
|
|
|
|
//secondary menu
|
2019-05-03 23:52:08 +03:00
|
|
|
$go_menu = [
|
|
|
|
|
'general' => ['name'=>$lang['R_CHECK_UPDATE'], 'link'=> basename(ADMIN_PATH) . '?cp=p_check_update&smt=general', 'goto'=>'general', 'current'=> $current_smt == 'general'],
|
|
|
|
|
'howto' => ['name'=>$lang['HOW_UPDATE_KLEEJA'], 'link'=> basename(ADMIN_PATH) . '?cp=p_check_update&smt=howto', 'goto'=>'howto', 'current'=> $current_smt == 'howto'],
|
|
|
|
|
'site' => ['name'=>'Kleeja.com', 'link'=> 'http://www.kleeja.com', 'goto'=>'site', 'current'=> $current_smt == 'site'],
|
|
|
|
|
];
|