Merge branch 'next-version' into master

This commit is contained in:
Hani Rouatbi
2022-08-27 20:14:12 +01:00
committed by GitHub
2 changed files with 32 additions and 22 deletions

View File

@@ -32,7 +32,7 @@ class cache
{
if (defined('DEV_STAGE'))
{
return [];
return false;
}
$name = preg_replace('![^a-z0-9_]!', '_', $name);
@@ -40,22 +40,15 @@ class cache
if (file_exists(PATH . 'cache/' . $name . '.php'))
{
include PATH . 'cache/' . $name . '.php';
return empty($data) ? [] : $data;
}
else
{
return [];
return empty($data) ? false : $data;
}
return false;
}
public function exists($name)
public function exists($name): bool
{
$name = preg_replace('![^a-z0-9_]!', '_', $name);
if (file_exists(PATH . 'cache/' . $name . '.php'))
{
return true;
}
return file_exists(PATH . 'cache/' . $name . '.php');
}
public function save($name, $data, $time = 86400)
@@ -64,17 +57,20 @@ class cache
$data_for_save = '<?' . 'php' . "\n";
$data_for_save .= '//Cache file, generated for Kleeja at ' . gmdate('d-m-Y h:i A') . "\n\n";
$data_for_save .= '//No direct opening' . "\n";
$data_for_save .= '(!defined("IN_COMMON") ? exit("hacking attemp!") : null);' . "\n\n";
$data_for_save .= '(!defined("IN_COMMON") ? exit("hacking attempt!") : null);' . "\n\n";
$data_for_save .= '//return false after x time' . "\n";
$data_for_save .= 'if(time() > ' . (time() + $time) . ') return false;' . "\n\n";
$data_for_save .= '$data = ' . var_export($data, true) . ";\n\n//end of cache";
if ($fd = @fopen(PATH . 'cache/' . $name . '.php', 'w'))
{
@flock($fd, LOCK_EX); // exlusive look
@fwrite($fd, $data_for_save);
@flock($fd, LOCK_UN);
@fclose($fd);
try {
$fd = fopen(PATH . 'cache/' . $name . '.php', 'w');
flock($fd, LOCK_EX); // exclusive look
fwrite($fd, $data_for_save);
flock($fd, LOCK_UN);
fclose($fd);
return true;
} catch (Exception $e) {
return false;
}
}
@@ -113,7 +109,7 @@ if (! ($config = $cache->get('data_config')))
is_array($plugin_run_result = Plugins::getInstance()->run('qr_select_config_cache', get_defined_vars())) ? extract($plugin_run_result) : null; //run hook
$result = $SQL->build($query);
$config = [];
while ($row=$SQL->fetch_array($result))
{
$config[$row['name']] = $row['value'];
@@ -130,6 +126,8 @@ if (! ($config = $cache->get('data_config')))
if (! ($olang = $cache->get('data_lang' . $config['language'])))
{
$olang = [];
$query = [
'SELECT' => 'l.word, l.trans',
'FROM' => "{$dbprefix}lang l",

View File

@@ -86,7 +86,7 @@ function kleeja_show_error($error_number, $error_string = '', $error_file = '',
echo '.error {color: #333;background:#ffebe8;float:left;width:73%;text-align:left;margin-top:10px;border: 1px solid #dd3c10; padding: 10px;font-family:tahoma,arial;font-size: 12px;}' . "\n";
echo "</style>\n</head>\n<body>\n\t" . '<div class="error">' . "\n\n\t\t<h2>Kleeja error : </h2><br />" . "\n";
echo "\n\t\t<strong> [ " . $error_number . ':' . basename($error_file) . ':' . $error_line . ' ] </strong><br /><br />' . "\n\t\t" . $error_string . "\n\t";
echo "\n\t\t" . '<br /><br /><small>Visit <a href="http://kleeja.net/" title="kleeja">Kleeja</a> Website for more details.</small>' . "\n\t";
echo "\n\t\t" . '<br /><br /><small>Visit <a href="https://kleeja.net/" title="kleeja">Kleeja</a> Website for more details.</small>' . "\n\t";
echo "</div>\n</body>\n</html>";
global $SQL;
@@ -147,9 +147,21 @@ if (! is_bot() && PHP_SESSION_ACTIVE !== session_status() && ! headers_sent())
//no enough data
if ((empty($dbname) || empty($dbuser)) && ($dbtype !== 'sqlite'))
{
header('Location: ./install/index.php');
$install_file_url = (defined('IN_ADMIN') ? '.' : '') . './install/index.php';
if (file_exists(PATH . '/install/index.php')) {
header("Location: {$install_file_url}");
exit;
}
kleeja_show_error(
'',
"There is no (install) folder, and the config file is not correct",
'includes/common.php',
__LINE__
);
exit;
}
// solutions for hosts running under suexec, add define('HAS_SUEXEC', true) to config.php.