Skip to content

Commit

Permalink
Removed checking for updates.
Browse files Browse the repository at this point in the history
  • Loading branch information
parpalak committed Mar 7, 2024
1 parent c61283a commit 3bec6f9
Show file tree
Hide file tree
Showing 12 changed files with 12 additions and 113 deletions.
7 changes: 7 additions & 0 deletions _admin/db_update.php
Original file line number Diff line number Diff line change
Expand Up @@ -193,6 +193,13 @@
}
}

if (S2_DB_REVISION < 17) {
$s2_db->buildAndQuery([
'DELETE' => 'config',
'WHERE' => 'name = \'S2_ADMIN_UPDATES\'',
]);
}

$query = array(
'UPDATE' => 'config',
'SET' => 'value = \''.S2_DB_LAST_REVISION.'\'',
Expand Down
13 changes: 0 additions & 13 deletions _admin/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -288,19 +288,6 @@ function s2_jsvarencode ($var)

($hook = s2_hook('ai_js_end')) ? eval($hook) : null;

if ($s2_user['edit_users'] && S2_ADMIN_UPDATES)
{

?>
GETAsyncRequest(sUrl + 'action=check_updates', function (http, data)
{
if (data.is_update)
PopupMessages.show(data.message);
});
<?php

}

?>
</script>
</body>
Expand Down
6 changes: 1 addition & 5 deletions _admin/install.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
use Symfony\Component\ErrorHandler\ErrorRenderer\HtmlErrorRenderer;

define('S2_VERSION', '2.0dev');
define('S2_DB_REVISION', 16);
define('S2_DB_REVISION', 17);
define('MIN_PHP_VERSION', '8.2.0');

define('S2_ROOT', '../');
Expand Down Expand Up @@ -981,9 +981,6 @@ function get_preferred_lang ($languages)
$s2_db->buildAndQuery($query);
$admin_uid = $s2_db->insertId();

// Enable/disable automatic check for updates depending on PHP environment (require cURL, fsockopen or allow_url_fopen)
$check_for_updates = (function_exists('curl_init') || function_exists('fsockopen') || in_array(strtolower(@ini_get('allow_url_fopen')), array('on', 'true', '1'))) ? 1 : 0;

// Insert config data
$config = array(
'S2_SITE_NAME' => "'".$lang_install['Site name']."'",
Expand All @@ -1003,7 +1000,6 @@ function get_preferred_lang ($languages)
'S2_ADMIN_COLOR' => "'#eeeeee'",
'S2_ADMIN_NEW_POS' => "'0'",
'S2_ADMIN_CUT' => "'0'",
'S2_ADMIN_UPDATES' => "'".$check_for_updates."'",
'S2_LOGIN_TIMEOUT' => "'60'",
'S2_DB_REVISION' => "'".S2_DB_REVISION."'",
);
Expand Down
1 change: 0 additions & 1 deletion _admin/lang/en/admin.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
'No permission' => 'You do not have enough permissions to perform this action.',
'Other sessions' => 'You have logged in from different browsers. Here are your sessions: <br />%s',
'Close other sessions' => 'Close all sessions except the current one',
'New version message' => '<strong>S2 %s</strong> has been released. Get the new version <a target="_blank" href="http://s2cms.ru/download">on the S2 site &uarr;</a>.',

// Login form
'Password' => 'Password',
Expand Down
6 changes: 2 additions & 4 deletions _admin/lang/en/admin_opt.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
'S2_ADMIN_COLOR' => 'Background color of the control panel (examples: %s).',
'S2_ADMIN_NEW_POS' => 'The created pages are placed before existing ones in the tree structure.',
'S2_ADMIN_CUT' => 'Use page texts above the “&lt;cut&gt;” tag as excerpts.',
'S2_ADMIN_UPDATES' => 'Show notifications when logging in the control panel if a new S2 version is released.',
'S2_LOGIN_TIMEOUT' => 'Idle timeout (minutes). Users have to re-enter their login and password when this timeout expires.'

);
Expand All @@ -39,7 +38,6 @@
'S2_ADMIN_COLOR' => 'Background color',
'S2_ADMIN_NEW_POS' => 'New pages on top',
'S2_ADMIN_CUT' => '“Cut” istead of excerpts',
'S2_ADMIN_UPDATES' => 'Check for updates',
'S2_LOGIN_TIMEOUT' => 'Timeout'

);
Expand All @@ -52,5 +50,5 @@
'Invalid webmaster email' => 'You have entered an invalid webmaster e-mail. The previous one is used.',
'Invalid style' => 'You have chosen the incorrect style.',
'Invalid lang pack' => 'The language pack “%s” contains errors.',
);

);
1 change: 0 additions & 1 deletion _admin/lang/ru/admin.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
'No permission' => 'У вас недостаточно прав для совершения этого действия.',
'Other sessions' => 'Вы зашли в панель управления с нескольких браузеров. Вот ваши сеансы: <br />%s',
'Close other sessions' => 'Закрыть все сеансы кроме текущего',
'New version message' => 'Вышла новая версия <strong>S2 %s</strong>. Ее можно <a target="_blank" href="http://s2cms.ru/download">скачать на сайте движка &uarr;</a>.',

// Login form
'Password' => 'Пароль',
Expand Down
4 changes: 1 addition & 3 deletions _admin/lang/ru/admin_opt.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
'S2_ADMIN_COLOR' => 'Цвет фона в панели управления (примеры: %s).',
'S2_ADMIN_NEW_POS' => 'При создании новые страницы помещаются в древовидной структуре перед имеющимися, а не после них.',
'S2_ADMIN_CUT' => 'Использовать текст страницы до тега «&lt;cut&gt;» как выдержку.',
'S2_ADMIN_UPDATES' => 'Уведомлять о выходе новых версий S2 при входе в панель управления.',
'S2_LOGIN_TIMEOUT' => 'Время простоя (в минутах), по истечении которого придется вводить логин и пароль заново.'

);
Expand All @@ -39,7 +38,6 @@
'S2_ADMIN_COLOR' => 'Цвет фона',
'S2_ADMIN_NEW_POS' => 'Новые страницы сверху',
'S2_ADMIN_CUT' => '«Кат» вместо выдержки',
'S2_ADMIN_UPDATES' => 'Проверка обновлений',
'S2_LOGIN_TIMEOUT' => 'Таймаут'

);
Expand All @@ -53,4 +51,4 @@
'Invalid style' => 'Был указан неверный стиль оформления.',
'Invalid lang pack' => 'Языковой пакет «%s» содержит ошибки.',

);
);
3 changes: 0 additions & 3 deletions _admin/options.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@
'S2_ADMIN_COLOR' => 'string',
'S2_ADMIN_NEW_POS' => 'int',
'S2_ADMIN_CUT' => 'boolean',
'S2_ADMIN_UPDATES' => 'boolean',
'S2_LOGIN_TIMEOUT' => 'int',
);

Expand Down Expand Up @@ -182,8 +181,6 @@ function s2_get_options ()
'S2_ADMIN_CUT' => s2_get_checkbox('S2_ADMIN_CUT', $options['S2_ADMIN_CUT'], $lang_const_names['S2_ADMIN_CUT'], $lang_const_explain['S2_ADMIN_CUT']),
'S2_LOGIN_TIMEOUT' => s2_get_input('S2_LOGIN_TIMEOUT', $options['S2_LOGIN_TIMEOUT'], $lang_const_names['S2_LOGIN_TIMEOUT'], $lang_const_explain['S2_LOGIN_TIMEOUT']),
);
if (function_exists('curl_init') || function_exists('fsockopen') || in_array(strtolower(@ini_get('allow_url_fopen')), array('on', 'true', '1')))
$fieldset['S2_ADMIN_UPDATES'] = s2_get_checkbox('S2_ADMIN_UPDATES', $options['S2_ADMIN_UPDATES'], $lang_const_names['S2_ADMIN_UPDATES'], $lang_const_explain['S2_ADMIN_UPDATES']);
($hook = s2_hook('fn_get_options_pre_admin_fs_merge')) ? eval($hook) : null;
$output .= '<fieldset><legend>'.$lang_admin['Admin panel'].'</legend>'.implode('', $fieldset).'</fieldset>';

Expand Down
19 changes: 0 additions & 19 deletions _admin/site_ajax.php
Original file line number Diff line number Diff line change
Expand Up @@ -82,25 +82,6 @@
s2_close_other_sessions($session_id);
}

elseif ($action == 'check_updates')
{
$is_permission = $s2_user['edit_users'];
($hook = s2_hook('rq_action_check_updates_start')) ? eval($hook) : null;
s2_test_user_rights($is_permission);

@$updates = include S2_CACHE_DIR.'cache_updates.php';
if (empty($updates) || $updates['cached'] + 7200 < time())
$updates = S2Cache::generate_updates();

if ($updates['fail'] === false && version_compare($updates['version'], S2_VERSION, '>'))
$return = array('is_update' => 1, 'message' => sprintf($lang_admin['New version message'], $updates['version']));
else
$return = array('is_update' => 0);

header('Content-Type: application/json; charset=utf-8');
echo s2_json_encode($return);
}

//=======================[Managing items]=======================================

// Drag & Drop
Expand Down
61 changes: 0 additions & 61 deletions _include/S2Cache.php
Original file line number Diff line number Diff line change
Expand Up @@ -127,65 +127,4 @@ public static function generate_hooks(): array

return $map;
}

/**
* Generate the updates cache PHP script
* @return array|mixed
*/
public static function generate_updates()
{
/** @var DbLayer $s2_db */
$s2_db = \Container::get(DbLayer::class);

$return = ($hook = s2_hook('fn_generate_updates_cache_start')) ? eval($hook) : null;
if ($return !== null) {
return $return;
}
/*
// Get a list of installed hotfix extensions
$query = array(
'SELECT' => 'e.id',
'FROM' => 'extensions AS e',
'WHERE' => 'e.id LIKE \'hotfix_%\''
);
($hook = s2_hook('fn_generate_updates_cache_qr_get_hotfixes')) ? eval($hook) : null;
$result = $s2_db->query_build($query);
$hotfixes = array();
while ($hotfix = $s2_db->fetchAssoc($result))
$hotfixes[] = urlencode($hotfix['id']);
$result = s2_get_remote_file('http://s2cms.ru/update/?type=xml&version='.urlencode(S2_VERSION).'&hotfixes='.implode(',', $hotfixes), 8);
*/
// Contact the S2 updates service
$result = s2_get_remote_file('http://s2cms.ru/update/index.php?version=' . urlencode(S2_VERSION), 8);

// Make sure we got everything we need
if ($result !== null && strpos($result['content'], '</s2_updates>') !== false) {
if (!defined('S2_XML_FUNCTIONS_LOADED'))
require S2_ROOT . '_include/xml.php';

$update_info = s2_xml_to_array(trim($result['content']));

$output['version'] = $update_info['s2_updates']['lastversion'];
$output['cached'] = time();
$output['fail'] = false;
} else {
$output = array('cached' => time(), 'fail' => true);
}

($hook = s2_hook('fn_generate_updates_cache_write')) ? eval($hook) : null;

if (!defined('S2_DISABLE_CACHE')) {
// Output update status as PHP code
try {
s2_overwrite_file_skip_locked(S2_CACHE_DIR . 'cache_updates.php', '<?php' . "\n\n" . 'return ' . var_export($output, true) . ';' . "\n");
} catch (\RuntimeException $e) {
error('Unable to write updates cache file to cache directory. Please make sure PHP has write access to the directory \'' . S2_CACHE_DIR . '\'.', __FILE__, __LINE__);
}
}

return $output;
}
}
2 changes: 1 addition & 1 deletion _include/common.php
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ function collectParameters(): array
include S2_CACHE_DIR . 'cache_config.php';
}

define('S2_DB_LAST_REVISION', 16);
define('S2_DB_LAST_REVISION', 17);
if (S2_DB_REVISION < S2_DB_LAST_REVISION) {
include S2_ROOT . '_admin/db_update.php';
}
2 changes: 0 additions & 2 deletions _tests/acceptance/InstallCest.php
Original file line number Diff line number Diff line change
Expand Up @@ -529,7 +529,6 @@ private function testAdminCommentManagement(AcceptanceTester $I): void
'S2_PREMODERATION' => '1',
'S2_ADMIN_COLOR' => '#e7e4f4',
'S2_LOGIN_TIMEOUT' => '120000',
'S2_ADMIN_UPDATES' => '0',
]
];

Expand Down Expand Up @@ -606,7 +605,6 @@ private function testAdminCommentManagement(AcceptanceTester $I): void
'S2_PREMODERATION' => '1',
'S2_ADMIN_COLOR' => '#e7e4f4',
'S2_LOGIN_TIMEOUT' => '120000',
'S2_ADMIN_UPDATES' => '0',
]
];

Expand Down

0 comments on commit 3bec6f9

Please sign in to comment.