moved to update page and make it better

This commit is contained in:
Abdulrahman
2019-05-12 03:08:45 +03:00
parent cc8a85b32c
commit b70e76664c
10 changed files with 407 additions and 387 deletions

View File

@@ -1,52 +1,126 @@
<IF NAME="current_smt == general">
<!-- Breadcrumbs -->
<ol class="breadcrumb">
<li class="breadcrumb-item"><a href="./">{lang.R_CPINDEX}</a></li>
<li class="breadcrumb-item active">{lang.R_CHECK_UPDATE}</li>
</ol>
<div id="updateInfo" class="alert">
<img src="{STYLE_PATH_ADMIN}images/ajax-loader-small.gif" />
<div class="alert d-flex justify-content-between align-middle" id="updateInfo">
<div>
<img src="{STYLE_PATH_ADMIN}images/ajax-loader-small.gif" /> {lang.LOADING}
</div>
<button id="updateButton" type="button" class="btn btn-outline-dark btn-sm d-none" onclick="updateNow(1)">{lang.UPDATE_KLJ_NOW}</button>
</div>
<ul class="list-group mt-5 d-none" id="updateProcess">
<li class="list-group-item disabled" id="update1">
<div class="d-flex justify-content-between">
<div>
<h4 class="d-inline px-2">1</h4> Downloading latest Kleeja package...
</div>
<span class="update-status badge badge-primary badge-light p-2"></span>
</div>
<div class="update-message d-none alert alert-danger mt-3 mb-0"></div>
</li>
<li class="list-group-item disabled" id="update2">
<div class="d-flex justify-content-between">
<div>
<h4 class="d-inline px-2">2</h4> Create a backup container and extract the new package ...
</div>
<span class="update-status badge badge-primary badge-light p-2"></span>
</div>
<div class="update-message d-none alert alert-danger mt-3 mb-0"></div>
</li>
<li class="list-group-item disabled" id="update3">
<div class="d-flex justify-content-between">
<div>
<h4 class="d-inline px-2">3</h4> Updating to new version (files & database upgrade) ...
</div>
<span class="update-status badge badge-primary badge-light p-2"></span>
</div>
<div class="update-message d-none alert alert-danger mt-3 mb-0"></div>
</li>
</ul>
<script>
setTimeout(function(){
$.ajax({
url: './?cp=p_check_update&smt=check&_ajax_=1',
dataType: 'json'})
.done(function (data) {
if(data.content){
var info = data.content.split(":::");
$('#updateInfo').html(info[1]).addClass(info[0] == 1 ? 'alert-warning' : 'alert-info');
} else {
this.fail();
}
<IF NAME="showMessage"> location.href = './?update_done=1'; </IF>
})
.fail(function() {
$('#updateInfo').html('{lang.ERROR_CHECK_VER}').addClass('alert-warning');
<IF NAME="showMessage"> location.href = './?update_done=1'; </IF>
});
}, 300);
function loadWhenJQueryIsReady() {
setTimeout(function() {
if (typeof jQuery == 'undefined' && typeof window.jQuery == 'undefined') {
loadWhenJQueryIsReady();
} else {
checkVersion();
}
}, 500);
}
loadWhenJQueryIsReady();
function checkVersion() {
$.ajax({
url: './?cp=p_check_update&smt=check&_ajax_=1',
dataType: 'json'})
.done(function (data) {
if(data.content) {
var info = data.content.split(":::");
$('#updateInfo').addClass(info[0] != 0 ? 'alert-warning' : 'alert-info');
$('#updateInfo div').html(info[1]);
<UNLESS NAME="showMessage">
if(info[0] == 2) {
$('#updateButton').removeClass('d-none');
}
</UNLESS>
} else {
this.fail();
}
<IF NAME="showMessage"> location.href = './?update_done=1'; </IF>
})
.fail(function() {
$('#updateInfo').html('{lang.ERROR_CHECK_VER}').addClass('alert-warning');
<IF NAME="showMessage"> location.href = './?update_done=1'; </IF>
});
}
function updateNow(step) {
if(step == 1) {
$('#updateButton').addClass('d-none');
$('#updateProcess').removeClass('d-none');
}
$('#update'+step+' .update-status').html('<img src="{STYLE_PATH_ADMIN}images/ajax-loader-small.gif">');
$('#update'+step+'').removeClass('disabled');
$.ajax({
url: './?cp=p_check_update&smt=update'+step+'&_ajax_=1',
dataType: 'json'})
.done(function (data) {
if(data.content) {
var info = data.content.split(":::");
if(info[1].length > 0) {
$('#update'+step+' .update-message').removeClass('d-none').addClass('d-block').text(info[1]);
if(info[0] == 1) {
$('#update'+step+' .update-message').removeClass('alter-danger').addClass('alert-success');
}
}
$('#update'+step+' .update-status').html(info[0] == 1 ? '<i class="fa fa-check text-success"></i>' : '<i class="fa fa-warning text-danger"></i>');
if(info[0] == 1 && step < 3) {
setTimeout(function() {
updateNow(step+1);
}, 500);
}
} else {
this.fail();
}
})
.fail(function(data) {
$('#update'+step+' .update-status').text('error!');
$('#update'+step+' .update-message').removeClass('d-none').addClass('d-block').html(
(data.content ? data.content : (data.responseJSON ? data.responseJSON.content : '{lang.ERROR_TRY_AGAIN}'))
);
});
}
</script>
<ELSEIF NAME="current_smt == howto">
<!-- Breadcrumbs -->
<ol class="breadcrumb">
<li class="breadcrumb-item"><a href="./">{lang.R_CPINDEX}</a></li>
<li class="breadcrumb-item active">{lang.HOW_UPDATE_KLEEJA}</li>
</ol>
<ul class="update_list">
<li>{lang.HOW_UPDATE_KLEEJA_STEP1}</li>
<li>{lang.HOW_UPDATE_KLEEJA_STEP2}</li>
<li>{lang.HOW_UPDATE_KLEEJA_STEP3}
<input class="form-control" type="text" value="{update_link}" readonly>
</li>
</ul>
</IF>

View File

@@ -657,7 +657,7 @@ switch ($case):
if (is_dir($plugin_folder_name))
{
delete_plugin_folder($plugin_folder_name);
kleeja_unlink($plugin_folder_name);
}
redirect($plugin_download_link . $update_plugin . '&amp;update' );
@@ -672,7 +672,7 @@ switch ($case):
if (is_dir($plugin_folder_name))
{
delete_plugin_folder($plugin_folder_name);
kleeja_unlink($plugin_folder_name);
}
kleeja_admin_info(

View File

@@ -13,17 +13,36 @@ if (! defined('IN_ADMIN'))
exit();
}
set_time_limit(0);
$current_version = '3.0';
$new_version = unserialize($config['new_version']);
$new_version = empty($new_version['version_number'])
? KLEEJA_VERSION
: $new_version['version_number'];
$backup_archive_path = PATH . 'cache/backup.zip';
define('KLEEJA_VERSION_CHECK_LINK', 'https://api.github.com/repos/kleeja-official/kleeja/releases/latest');
define('KLEEJA_LATEST_PACKAGE_LINK', 'https://github.com/kleeja-official/kleeja/archive/');
$stylee = 'admin_check_update';
$current_smt = preg_replace('/[^a-z0-9_]/i', '', g('smt', 'str', 'general'));
$current_smt = preg_replace('/[^a-z0-9_]/i', '', g('smt', 'str', 'general'));
$update_link = $config['siteurl'] . 'install/update.php?lang=' . $config['language'];
//to prevent getting the url data for all cats
if ($current_smt == 'check'):
//only founders can do the upgrade process ...
if(in_array($current_smt, ['update1', 'update2', 'update3']) && intval($userinfo['founder']) !== 1)
{
header('HTTP/1.0 401 Unauthorized');
kleeja_admin_err($lang['HV_NOT_PRVLG_ACCESS']);
}
//check latest version
if ($current_smt == 'check')
{
//get data from kleeja github repo
if (! ($version_data = $cache->get('kleeja_repo_version')))
{
$github_data = fetch_remote_file('https://api.github.com/repos/kleeja-official/kleeja/releases/latest', false, 60);
$github_data = fetch_remote_file(KLEEJA_VERSION_CHECK_LINK, false, 100);
if (! empty($github_data))
{
@@ -47,16 +66,16 @@ if ($current_smt == 'check'):
}
else
{
if (version_compare(strtolower(KLEEJA_VERSION), strtolower($version_data), '<'))
if (version_compare(strtolower($current_version), strtolower($version_data), '<'))
{
$text = sprintf($lang['UPDATE_NOW_S'], KLEEJA_VERSION, strtolower($version_data)) . '<br /><br />' . $lang['UPDATE_KLJ_NOW'];
$error = 1;
$text = sprintf($lang['UPDATE_NOW_S'], $current_version, strtolower($version_data));
$error = 2;
}
elseif (version_compare(strtolower(KLEEJA_VERSION), strtolower($version_data), '='))
elseif (version_compare(strtolower($current_version), strtolower($version_data), '='))
{
$text = $lang['U_LAST_VER_KLJ'];
}
elseif (version_compare(strtolower(KLEEJA_VERSION), strtolower($version_data), '>'))
elseif (version_compare(strtolower($current_version), strtolower($version_data), '>'))
{
$text = $lang['U_USE_PRE_RE'];
}
@@ -77,14 +96,10 @@ if ($current_smt == 'check'):
delete_cache('data_config');
$adminAjaxContent = $error . ':::' . $text;
elseif ($current_smt == 'general'):
// if(!$error)
// {
}
// home of update page
elseif ($current_smt == 'general')
{
//To prevent expected error [ infinit loop ]
if (ig('show_msg'))
{
@@ -103,18 +118,199 @@ elseif ($current_smt == 'general'):
}
}
$showMessage = ig('show_msg');
}
//1. download latest kleeja version
elseif ($current_smt == 'update1')
{
if (! class_exists('ZipArchive'))
{
$adminAjaxContent = '930:::' . $lang['NO_ZIP_ARCHIVE'];
}
elseif (! version_compare(strtolower($current_version), strtolower($new_version), '<'))
{
$adminAjaxContent = '940:::there is no update for your version!';
}
else
{
// downloaded the last package to cache folder
fetch_remote_file(KLEEJA_LATEST_PACKAGE_LINK . $new_version . '.zip', PATH . "cache/kleeja-{$new_version}.zip", 60, false, 10, true);
if(file_exists(PATH . "cache/kleeja-{$new_version}.zip"))
{
$adminAjaxContent = '1:::';
file_put_contents(PATH . 'cache/step1.done', time());
}
else
{
$adminAjaxContent = '2:::We have encountered a problem while downloading the package ... ';
}
}
}
//2. extract new kleeja package, create backup zip file
elseif ($current_smt == 'update2')
{
if(! file_exists(PATH . 'cache/step1.done'))
{
header('HTTP/1.0 401 Unauthorized');
kleeja_admin_err($lang['HV_NOT_PRVLG_ACCESS']);
}
// }
kleeja_unlink(PATH . 'cache/step1.done');
$showMessage = ig('show_msg');
// let's extract the zip to cache
$zip = new ZipArchive;
if ($zip->open(PATH . "cache/kleeja-{$new_version}.zip") == true)
{
$zip->extractTo(PATH . 'cache/');
$zip->close();
}
//end current_smt == general
endif;
// let's check if there any update files in install folder
$update_file = PATH . "cache/kleeja-{$new_version}/install/includes/update_files/{$old_version}_to_{$new_version}.php";
//secondary menu
$go_menu = [
'general' => ['name'=>$lang['R_CHECK_UPDATE'], 'link'=> basename(ADMIN_PATH) . '?cp=p_check_update&amp;smt=general', 'goto'=>'general', 'current'=> $current_smt == 'general'],
'howto' => ['name'=>$lang['HOW_UPDATE_KLEEJA'], 'link'=> basename(ADMIN_PATH) . '?cp=p_check_update&amp;smt=howto', 'goto'=>'howto', 'current'=> $current_smt == 'howto'],
'site' => ['name'=>'Kleeja.com', 'link'=> 'http://www.kleeja.com', 'goto'=>'site', 'current'=> $current_smt == 'site'],
];
if (file_exists($update_file))
{
// move the update file from install folder to cache folder to include it later and delete install folder
// becuse if install folder is exists , it can make some problems if dev mode is not active
rename($update_file, PATH . "cache/update_{$old_version}_to_{$new_version}.php");
}
// skip some folders
foreach (['cache', 'plugins', 'uploads', 'styles', 'install'] as $folder_name)
{
kleeja_unlink(PATH . "cache/kleeja-{$new_version}/{$folder_name}");
}
if (file_exists($backup_archive_path))
{
kleeja_unlink($backup_archive_path);
}
file_put_contents(PATH . 'cache/step2.done', time());
$adminAjaxContent = '1:::';
}
//3. update, or rollback on failure
elseif ($current_smt == 'update3')
{
if(! file_exists(PATH . 'cache/step2.done'))
{
header('HTTP/1.0 401 Unauthorized');
kleeja_admin_err($lang['HV_NOT_PRVLG_ACCESS']);
}
kleeja_unlink(PATH . 'cache/step2.done');
$backup = new ZipArchive;
if($backup->open($backup_archive_path, ZipArchive::CREATE) !== true)
{
}
// delete plugin folder function with some changes :)
$it = new RecursiveDirectoryIterator(PATH . "cache/kleeja-{$new_version}/", RecursiveDirectoryIterator::SKIP_DOTS);
$files = new RecursiveIteratorIterator($it, RecursiveIteratorIterator::CHILD_FIRST);
$update_failed = false;
$failed_files = $new_folders = [];
//maintenance mode on
update_config('siteclose', 1);
foreach ($files as $file)
{
if ($file->isFile())
{
$file_path = str_replace("cache/kleeja-{$new_version}/", '', $file->getPathname());
$file_dir = str_replace("cache/kleeja-{$new_version}/", '', $file->getPath());
// same, no need to replace
if (file_exists($file_path) && md5_file($file_path) == md5_file($file->getPathname()))
{
continue;
}
//no folder?
if (! file_exists($file_dir))
{
mkdir($file_dir, K_DIR_CHMOD, true);
array_push($new_folders, $file_dir);
}
if (! is_writable($file_path))
{
chmod($file_path, K_FILE_CHMOD);
}
//back up current file
$backup->addFromString(
$file_path,
file_get_contents($file_path)
);
//copy file
if (file_put_contents(
$file_path,
file_get_contents($file->getPathname())
) === false)
{
$update_failed = true;
array_push($failed_files, $file_path);
break;
}
}
elseif ($file->isDir())
{
// here is folder , when we finish update , we will delete all folders and files
if (! file_exists($file_path))
{
mkdir($file_path, K_DIR_CHMOD, true);
array_push($new_folders, $file_path);
}
continue;
}
}
$backup->close();
if ($update_failed)
{
//rollback to backup
$zip = new ZipArchive;
$zip->open($backup_archive_path);
$zip->extractTo(PATH);
$zip->close();
foreach ($new_folders as $folder)
{
kleeja_unlink($folder);
}
//maintenance mode off
update_config('siteclose', 0);
$adminAjaxContent = '1002:::updating process has failed...' .
(defined('DEV_STAGE') ? '[failed files: ' . implode(', ', $failed_files) . ']' : '');
}
else
{
// we will include what we want to do in this file , and kleeja will done
if (file_exists($db_update_file = PATH . "cache/update_{$old_version}_to_{$new_version}.php"))
{
require_once $db_update_file;
}
//maintenance mode off
update_config('siteclose', 0);
// after a success update, delete files and folders in cache
kleeja_unlink(PATH . "cache/kleeja-{$new_version}");
delete_cache('', true);
$adminAjaxContent = "1:::Kleeja has been updated to {$new_version} successfully...";
}
}
//endif

View File

@@ -1,248 +0,0 @@
<?php
/**
*
* @package adm
* @copyright (c) 2007 Kleeja.com
* @license ./docs/license.txt
*
*/
// not for directly open
if (! defined('IN_ADMIN'))
{
exit();
}
/**
* TODO:
* - ajax
* - first get new kleeja version. (one request)
* - show [update] button.
* - update (one request).
* - after-update (one request)
*/
set_time_limit(0);
$old_version = KLEEJA_VERSION;
$new_version = unserialize($config['new_version']);
$new_version = empty($new_version['version_number'])
? KLEEJA_VERSION
: $new_version['version_number'];
// solutions for hosts running under suexec, add define('HAS_SUEXEC', true) to config.php.
define('K_FILE_CHMOD', defined('HAS_SUEXEC') ? (0644 & ~ umask()) : 0644);
define('K_DIR_CHMOD', defined('HAS_SUEXEC') ? (0755 & ~ umask()) : 0755);
// he can reinstall kleeja if he want by $_GET['install_again'] => for developers only
if (! ig('install_again'))
{
// not reinstall , he want to update , => check if kleeja need or not
if (! version_compare(strtolower($old_version), strtolower($new_version), '<'))
{
// kleeja doesn't need to update
kleeja_admin_info('there is no update for your version!', ADMIN_PATH);
exit;
}
}
else
{
// kleeja is up to date, unless your are a developer trying to make a point...
if (! defined('DEV_STAGE'))
{
kleeja_admin_info('Kleeja is up to date!');
exit;
}
}
/**
* we will download the last version from github and extract it in cache folder
* then scan the new version files , and put it to the PATH
* we don't need to create the folders again in PATH
* and if we have to update the DB or removing some old files ,
* we can check if there any update file of this version from the new install folder
* EX : if file exists PATH . 'install/update/$old_version_$new_version.php': require_once the file
*/
$kj_new_pack_link = 'https://github.com/kleeja-official/kleeja/archive/';
if (! class_exists('ZipArchive'))
{
//$error = $lang['NO_ZIP_ARCHIVE'];
$down_new_pack = false;
}
else
{
// downloaded the last version to cache folder
$down_new_pack = fetch_remote_file($kj_new_pack_link . $new_version . '.zip', PATH . 'cache/kleeja.zip', 60, false, 10, true);
}
if ($down_new_pack)
{
// let's extract the zip to cache
$zip = new ZipArchive;
if ($zip->open(PATH . 'cache/kleeja.zip') == true)
{
$zip->extractTo(PATH . 'cache/');
$zip->close();
}
// some folder don't need it
$no_need = [
'cache', // delete_cache() function
'plugins', // kleeja now support plugins update
'uploads',
'styles', // kleeja will support style_update soon
'install' // befor removing install folder , we will take what we want from it
];
// let's check if there any update files in install folder
$update_file = PATH . "cache/kleeja-{$new_version}/install/includes/update_files/{$old_version}_to_{$new_version}.php";
if (file_exists($update_file))
{
// move the update file from install folder to cache folder to include it later and delete install folder
// becuse if install folder is exists , it can make some problems if dev mode is not active
rename($update_file, PATH . "cache/update_{$old_version}_to_{$new_version}.php");
}
foreach ($no_need as $folderName)
{
kleeja_unlink(PATH . "cache/kleeja-{$new_version}/{$folderName}");
}
# backup as zip file and import the local files in it to rollback later on failure
$backup_version = PATH . 'cache/backup.zip';
if (file_exists($backup_version))
{
kleeja_unlink($backup_version);
}
$backup = new ZipArchive;
$backup->open($backup_version, ZipArchive::CREATE);
// delete plugin folder function with some changes :)
$it = new RecursiveDirectoryIterator(PATH . "cache/kleeja-{$new_version}/", RecursiveDirectoryIterator::SKIP_DOTS);
$files = new RecursiveIteratorIterator($it, RecursiveIteratorIterator::CHILD_FIRST);
$update_failed = false;
$failed_files = [];
$new_folders = [];
//maintenance mode on
update_config('siteclose', 1);
foreach ($files as $file)
{
if ($file->isFile())
{
$file_path = str_replace("cache/kleeja-{$new_version}/", '', $file->getPathname());
$file_dir = str_replace("cache/kleeja-{$new_version}/", '', $file->getPath());
// same, no need to replace
if (file_exists($file_path) && md5_file($file_path) == md5_file($file->getPathname()))
{
continue;
}
//no folder?
if(! file_exists($file_dir))
{
mkdir($file_dir, K_DIR_CHMOD, true);
array_push($new_folders, $file_dir);
}
if (! is_writable($file_path))
{
chmod($file_path, K_FILE_CHMOD);
}
//back up current file
$backup->addFromString(
$file_path,
file_get_contents($file_path)
);
//copy file
if (file_put_contents(
$file_path,
file_get_contents($file->getPathname())
) === false)
{
$update_failed = true;
array_push($failed_files, $file_path);
break;
}
}
elseif ($file->isDir())
{
// here is folder , when we finish update , we will delete all folders and files
if (! file_exists($file_path))
{
mkdir($file_path, K_DIR_CHMOD, true);
array_push($new_folders, $file_path);
}
continue;
}
else
{
// not file or folder ?
}
}
$backup->close();
if ($update_failed)
{
//rollback to backup
$zip = new ZipArchive;
$zip->open($backup_version);
$zip->extractTo(PATH);
$zip->close();
foreach($new_folders as $folder)
{
kleeja_unlink($folder);
}
//maintenance mode off
update_config('siteclose', 0);
kleeja_admin_err(
'updating process has failed...' .
(defined('DEV_STAGE') ? '[failed files: ' . implode(', ', $failed_files) . ']' : '')
);
}
else
{
// we will include what we want to do in this file , and kleeja will done
if (file_exists($updateFiles = PATH . "cache/update_{$old_version}_to_{$new_version}.php"))
{
require_once $updateFiles;
}
//maintenance mode off
update_config('siteclose', 0);
// after a success update, delete files and folders in cache
kleeja_unlink(PATH . "cache/kleeja-{$new_version}");
delete_cache('', true);
kleeja_info(
"Kleeja has been updated to {$new_version} successfully...",
'',
true,
'?cp=p_check_update'
);
}
}

View File

@@ -57,11 +57,15 @@ require_once PATH . KLEEJA_CONFIG_FILE;
define('ADM_FILES_PATH', PATH . 'includes/adm');
//Report all errors, except notices
error_reporting( defined('DEV_STAGE') ? E_ALL : E_ALL ^ E_NOTICE);
error_reporting(defined('DEV_STAGE') ? E_ALL : E_ALL ^ E_NOTICE);
/**
* functions for start
* @param mixed $error_number
* @param mixed $error_string
* @param mixed $error_file
* @param mixed $error_line
*/
function kleeja_show_error($error_number, $error_string = '', $error_file = '', $error_line = '')
{
@@ -129,9 +133,9 @@ if (empty($dbname) || empty($dbuser))
exit;
}
//include files .. & classes ..
$root_path = PATH;
// $db_type = isset($db_type) ? $db_type : 'mysqli';
// solutions for hosts running under suexec, add define('HAS_SUEXEC', true) to config.php.
define('K_FILE_CHMOD', defined('HAS_SUEXEC') ? (0644 & ~umask()) : 0644);
define('K_DIR_CHMOD', defined('HAS_SUEXEC') ? (0755 & ~umask()) : 0755);
include PATH . 'includes/functions_alternative.php';
include PATH . 'includes/version.php';
@@ -163,7 +167,7 @@ unset($dbpass);
$tpl = new kleeja_style;
$tpl = new kleeja_style;
$usrcp = new usrcp;
//then get caches
@@ -310,10 +314,10 @@ if (
file_exists(PATH . 'install') &&
! defined('IN_ADMIN') &&
! defined('IN_LOGIN') &&
! defined('DEV_STAGE') &&
! defined('DEV_STAGE') &&
! (defined('IN_GO') && in_array(g('go'), ['queue'])) &&
! (defined('IN_UCP') && in_array(g('go'), ['captcha', 'login']))
) {
) {
//Different message for admins! delete install folder
kleeja_info((user_can('enter_acp') ? $lang['DELETE_INSTALL_FOLDER'] : $lang['WE_UPDATING_KLEEJA_NOW']), $lang['SITE_CLOSED']);
}
@@ -323,16 +327,16 @@ if (
$login_page = '';
if (
$config['siteclose'] == '1' &&
! user_can('enter_acp') &&
! defined('IN_LOGIN') &&
! defined('IN_ADMIN') &&
$config['siteclose'] == '1' &&
! user_can('enter_acp') &&
! defined('IN_LOGIN') &&
! defined('IN_ADMIN') &&
! (defined('IN_GO') && in_array(g('go'), ['queue'])) &&
! (defined('IN_UCP') && in_array(g('go'), ['captcha', 'login', 'register', 'logout']))
) {
//if download, images ?
if (
( defined('IN_DOWNLOAD') && (ig('img') || ig('thmb') || ig('thmbf') || ig('imgf')) )
(defined('IN_DOWNLOAD') && (ig('img') || ig('thmb') || ig('thmbf') || ig('imgf')))
|| g('go', 'str', '') == 'queue'
) {
@$SQL->close();
@@ -352,7 +356,8 @@ if (
//exceed total size
if (($stat_sizes >= ($config['total_size'] *(1048576))) && ! defined('IN_LOGIN') && ! defined('IN_ADMIN'))
{// convert megabytes to bytes
{
// convert megabytes to bytes
// Send a 503 HTTP response code to prevent search bots from indexing the maintenace message
header('HTTP/1.1 503 Service Temporarily Unavailable');
kleeja_info($lang['SIZES_EXCCEDED'], $lang['STOP_FOR_SIZE']);

View File

@@ -22,7 +22,7 @@ if (! defined('IN_COMMON'))
*/
function kleeja_detecting_bots()
{
global $SQL, $usrcp, $dbprefix, $config, $klj_session;
global $SQL, $dbprefix, $config;
// get information ..
$agent = $SQL->escape($_SERVER['HTTP_USER_AGENT']);
@@ -1502,11 +1502,11 @@ function kleeja_log($text)
return;
}
$log_file = PATH . 'cache/kleeja_log.log';
$l_c = @file_get_contents($log_file);
$fp = @fopen($log_file, 'w');
@fwrite($fp, $text . ' [time : ' . date('H:i a, d-m-Y') . "] \r\n" . $l_c);
@fclose($fp);
file_put_contents(
PATH . 'cache/kleeja_log.log',
date_format(date_create(), 'Y-m-d h:i:s.ua') . ' | INFO | ' . $text . PHP_EOL,
FILE_APPEND | LOCK_EX
);
}

View File

@@ -11,7 +11,7 @@
define('MIN_PHP_VERSION', '7.0');
define('MIN_MYSQL_VERSION', '4.2.2');
//version of latest changes at db
define ('LAST_DB_VERSION', '9');
define('LAST_DB_VERSION', '9');
//set no errors
define('MYSQL_NO_ERRORS', true);
@@ -74,6 +74,7 @@ function getjquerylink()
/**
* Parsing installing templates
* @param mixed $tplname
*/
function gettpl($tplname)
{
@@ -90,6 +91,11 @@ function gettpl($tplname)
/**
* Export config
* @param mixed $srv
* @param mixed $usr
* @param mixed $pass
* @param mixed $nm
* @param mixed $prf
*/
function do_config_export($srv, $usr, $pass, $nm, $prf)
{
@@ -100,32 +106,22 @@ function do_config_export($srv, $usr, $pass, $nm, $prf)
$data .= '$dbname = \'' . str_replace("'", "\'", $nm) . "'; // database name \n";
$data .= '$dbprefix = \'' . str_replace("'", "\'", $prf) . "'; // if you use prefix for tables , fill it \n";
$written = false;
if (is_writable(PATH))
if (file_put_contents(PATH . 'config.php', $data, LOCK_EX) !== false)
{
$fh = @fopen(PATH . 'config.php', 'wb');
if ($fh)
{
fwrite($fh, $data);
fclose($fh);
$written = true;
}
return true;
}
if (! $written)
if (defined('CLI') && CLI)
{
header('Content-Type: text/x-delimtext; name="config.php"');
header('Content-disposition: attachment; filename=config.php');
echo $data;
exit;
return true;
}
return true;
//
header('Content-Type: text/x-delimtext; name="config.php"');
header('Content-disposition: attachment; filename=config.php');
echo $data;
exit;
}
@@ -140,6 +136,7 @@ function get_microtime()
/**
* Get config value from database directly, if not return false.
* @param mixed $name
*/
function inst_get_config($name)
{

View File

@@ -30,6 +30,15 @@ include_once PATH . 'includes/mysqli.php';
include_once 'includes/functions_install.php';
//cli options
$cli_options = [];
if (CLI)
{
$cli_options = getopt('', ['password::', 'link::']);
}
if (file_exists(PATH . 'config.php'))
{
include_once PATH . 'config.php';
@@ -80,15 +89,17 @@ include_once PATH . 'includes/usr.php';
include_once PATH . 'includes/functions_alternative.php';
$usrcp = new usrcp;
$password = mt_rand();
$password = ! empty($cli_options['password']) ? $cli_options['password'] : mt_rand();
$user_salt = substr(kleeja_base64_encode(pack('H*', sha1(mt_rand()))), 0, 7);
$user_pass = $usrcp->kleeja_hash_password($password . $user_salt);
$user_name = $clean_name = 'admin';
$user_mail = $config_sitemail = 'admin@example.com';
$config_urls_type = 'id';
$config_sitename = 'Yet Another Kleeja';
$config_siteurl = 'http://' . $_SERVER['HTTP_HOST'] . str_replace('install', '', dirname($_SERVER['PHP_SELF']));
$config_time_zone = '3';
$config_siteurl = ! empty($cli_options['link'])
? $cli_options['link']
: 'http://' . $_SERVER['HTTP_HOST'] . str_replace('install', '', dirname($_SERVER['PHP_SELF']));
$config_time_zone = 'Asia/Buraydah';
// Queries
include 'includes/install_sqls.php';

View File

@@ -123,9 +123,9 @@ return [
'PLUGIN_EXISTS_BEFORE' => 'الاضافة هذه موجودة سابقاً بنفس الاصدار أو أعلى ولاتحتاج تحديث !',
'R_CHECK_UPDATE' => 'فحص عن تحديثات',
'ERROR_CHECK_VER' => 'خطأ: لا يمكن جلب معلومات عن آخر نسخة في هذه اللحظة، حاول مجدداً لاحقا!.',
'UPDATE_KLJ_NOW' => 'يجب أن تقوم بتحديث نسختك إلى آخر نسخة الآن، قم بالذهاب لموقع كليجا لمعلومات أكثر .',
'UPDATE_KLJ_NOW' => 'تحديث الآن!',
'U_LAST_VER_KLJ' => 'أنت تستخدم آخر نسخة من كليجا. شكراً لمتابعة نسختك بإستمرار.',
'U_USE_PRE_RE' => 'أنت تستخدم نسخة تطويرية لم تصدر حتى الآن , اضغط <a href="mailto:info@kleeja.com">هنا</a> لإخبارنا بأي أخطاء برمجية وثغرات قد تقابلك.',
'U_USE_PRE_RE' => 'أنت تستخدم نسخة تطويرية لم تصدر حتى الآن , اضغط <a href="https://github.com/kleeja-official/kleeja/issues">هنا</a> لإخبارنا بأي أخطاء برمجية وثغرات قد تقابلك.',
'STYLE_IS_DEFAULT' => 'استايل افتراضي',
'MAKE_AS_DEFAULT' => 'تعيينه افتراضي',
'STYLE_NOW_IS_DEFAULT' => 'تم تعيين الاستايل "%s" ستايل افتراضي',
@@ -171,18 +171,10 @@ return [
'ADD_HEADER_EXTRA' => 'هيدر إضافي',
'ADD_FOOTER_EXTRA' => 'فوتر إضافي',
'ADMIN_USING_IE6' => 'أنت تستخدم متصفح "انترنت اكسبلور قديم" هذا رغم انك صاحب موقع وتعرف اكثر ممايعرفه المستخدمون العاديون ! قم بترقية متصفحك او استخدم فيرفوكس الآن.',
'T_CLEANING_FILES_NOW' => 'جاري تنفيذ عملية حذف الملفات الخاملة حالياً على دفعات تفادياً للضغط ,وقت العملية يعتمد على عدد الملفات وحجمها ...',
'HOW_UPDATE_KLEEJA' => 'كيف تقوم بتحديث كليجا ؟',
'HOW_UPDATE_KLEEJA_STEP1' => 'توجه الى موقع سكربت كليجا الرسمي <a target="_blank" href="http://www.kleeja.com/">Kleeja.com</a> ثم توجه إلى صفحة التحميل وقم بتنزيل آخر تسخة صدرت من الاسكربت في حال توفر سكربت الترقية قم بتحميله',
'HOW_UPDATE_KLEEJA_STEP2' => ' بعد ذلك قم بفك الضغط عن الملف الذي قمت بتحميله ثم رفعه الى موقعك لاستبدال الملفات القدييمة بالجديدة <b> عدا ملف config.php</b>.',
'HOW_UPDATE_KLEEJA_STEP3' => 'بعد اتمام الخطوة السابقة بنجاح , قم بطلب العنوان التالي للتحديث قاعدة بيانـات الاسكربت:',
'DEPEND_ON_NO_STYLE_ERR' => 'هذا الستايل يعتمد على ستايل "%s" غير الموجود لديك ضمن الستايلات !.',
'PLUGINS_REQ_NO_STYLE_ERR' => 'هذا الستايل يتطلب ان تكون الإضافة/الاضافات [ %s ] مثبتة لديك , ثبتها وحاول من جديد !.',
'KLJ_VER_NO_STYLE_ERR' => 'هذا الستايل يتطلب على الاقل اصدار %s من كليجا .',
'T_CLEANING_FILES_NOW' => 'جاري تنفيذ عملية حذف الملفات الخاملة حالياً على دفعات تفادياً للضغط ,وقت العملية يعتمد على عدد الملفات وحجمها ...',
'DEPEND_ON_NO_STYLE_ERR' => 'هذا الستايل يعتمد على ستايل "%s" غير الموجود لديك ضمن الستايلات !.',
'PLUGINS_REQ_NO_STYLE_ERR' => 'هذا الستايل يتطلب ان تكون الإضافة/الاضافات [ %s ] مثبتة لديك , ثبتها وحاول من جديد !.',
'KLJ_VER_NO_STYLE_ERR' => 'هذا الستايل يتطلب على الاقل اصدار %s من كليجا .',
'STYLE_DEPEND_ON' => 'يعتمد على ستايل',
'MESSAGE_NONE' => 'حتى الآن لا يوجد أي رسائل ..',
'KLEEJA_TEAM' => 'فريق تطوير كليجا',
@@ -198,10 +190,8 @@ return [
'ADM_UNWANTED_FILES' => 'يبدوا انك قمت بالترقية من نسخة سابقة وبسبب اختلاف اسماء بعض الملفات ستلاحظ وجود ازرار متكررة بلوحة التحكم . <br /> لحل المشكلة قم بإزالة كافة الملفات في المسار "includes/adm" واعادة رفعها من جديد. ايضا قم بحذف ملف admin.php من المجلد الرئيسي اذا وجد.',
'HTML_URLS_ENABLED_NO_HTCC' => 'لقد قمت بتفعيل روابط الهتمل ولكنك نسيت أن تقوم بإعادة تسمية الملف htaccess.txt في مجلد كليجا الرئيسي ليصبح ".htaccess". اذا لم تفهم شيئاً من هذا الكلام قم بالسؤال في الدعم الفني لكليجا او قم بتعطيل روابط الهتمل .',
'PLUGIN_CONFIRM_ADD' => 'انتبه, الاضافات هي تعديلات برمجية على السكربت و قد تكون ضارة أحياناً , لذا ان كنت غير متأكد من مصدر الإضافة ولم تقم بتحميلها من موقع كليجا فالافضل ان تراجع نفسك الآن . ',
'LOADING' => 'جاري التنفيذ',
'PLUGIN_CONFIRM_ADD' => 'انتبه, الاضافات هي تعديلات برمجية على السكربت و قد تكون ضارة أحياناً , لذا ان كنت غير متأكد من مصدر الإضافة ولم تقم بتحميلها من موقع كليجا فالافضل ان تراجع نفسك الآن . ',
'LOADING' => 'جاري التنفيذ',
'WELCOME' => 'مرحباً',
'ENABLE_CAPTCHA' => 'تفعيل كود الامان بكليجا',
'NO_THUMB_FOLDER' => 'يبدو ان المصغرات مُفعلة لديك ولكن في نفس الوقت مجلد %s غير متوفر مما يمنع عملية انشاء المصغرات, قم بإنشاء المجلد.',

View File

@@ -125,9 +125,9 @@ return [
'PLUGIN_EXISTS_BEFORE' => 'This plugin exists before with same version or above, so no need to update it!.',
'R_CHECK_UPDATE' => 'Check for updates',
'ERROR_CHECK_VER' => 'Error: cannot get any update information at this moment , try again later !',
'UPDATE_KLJ_NOW' => 'You Have to update your version now!. visit Kleeja.com for more information',
'UPDATE_KLJ_NOW' => 'update now!',
'U_LAST_VER_KLJ' => 'You are using the latest version of Kleeja...',
'U_USE_PRE_RE' => 'You are using a Pre-release version, Click <a href="mailto:info@kleeja.com">here</a> to report any bugs or exploits.',
'U_USE_PRE_RE' => 'You are using a Pre-release version, Click <a href="https://github.com/kleeja-official/kleeja/issues">here</a> to report any bugs or exploits.',
'STYLE_IS_DEFAULT' => 'Default style',
'MAKE_AS_DEFAULT' => 'Set as default',
@@ -174,12 +174,7 @@ return [
'ADD_HEADER_EXTRA' => 'Extra Header',
'ADD_FOOTER_EXTRA' => 'Extra footer',
'ADMIN_USING_IE6' => 'You are using an outdated IE browser, Please update your browser or use FireFox now!',
'T_CLEANING_FILES_NOW' => 'Deleting Un-downloaded files, The process could take a while depending on the size and number of the files.',
'HOW_UPDATE_KLEEJA' => 'How to update Kleeja?',
'HOW_UPDATE_KLEEJA_STEP1' => 'Visit the official website <a target="_blank" href="http://www.kleeja.com/">Kleeja.com</a> then go to the Download page and download the latest version of the script, or download an upgrade copy if available.',
'HOW_UPDATE_KLEEJA_STEP2' => 'Unzip the file and upload it to your website to replace the old files with the new ones <b>Except config.php and uploads folder</b>.',
'HOW_UPDATE_KLEEJA_STEP3' => 'When done, go to the following URL to update the database.',
'DEPEND_ON_NO_STYLE_ERR' => 'This style is based on the "%s" style which you dont seem to have',
'PLUGINS_REQ_NO_STYLE_ERR' => 'This style requires the [ s% ] plugin(s), install it/them and try again.',
'KLJ_VER_NO_STYLE_ERR' => 'This style requires Kleeja version %s or above',