This commit is contained in:
Abdulrahman
2019-05-08 02:07:47 +03:00
parent d2dc847f90
commit 0b238a3258
6 changed files with 299 additions and 97 deletions

View File

@@ -0,0 +1,28 @@
<?php
/**
* @ignore an alias class for plugins class, during installation or updating.
*/
class Plugins
{
private static $instance;
/**
* @return Plugins
*/
public static function getInstance()
{
if (is_null(self::$instance)) {
self::$instance = new self();
}
return self::$instance;
}
/**
* @return array
*/
public function run($name)
{
return [];
}
}

View File

@@ -26,13 +26,13 @@ if (ig('change_lang'))
}
// Including current language
$lang = require $_path . 'lang/' . getlang() . '/common.php';
$lang = array_merge($lang, require $_path . 'lang/' . getlang() . '/install.php');
$lang = require PATH . 'lang/' . getlang() . '/common.php';
$lang = array_merge($lang, require PATH . 'lang/' . getlang() . '/install.php');
$IN_DEV = false;
// Exceptions for development
if (file_exists($_path . '.svn/entries') || file_exists('dev.txt'))
if (file_exists(PATH . '.svn/entries') || file_exists('dev.txt'))
{
define('DEV_STAGE', true);
$IN_DEV = true;
@@ -46,13 +46,11 @@ if (file_exists($_path . '.svn/entries') || file_exists('dev.txt'))
*/
function getlang ($link = false)
{
global $_path;
if (ig('lang'))
{
$lang = preg_replace('/[^a-z0-9]/i', '', g('lang', 'str', 'en'));
$ln = file_exists($_path . 'lang/' . $lang . '/install.php') ? $lang : 'en';
$ln = file_exists(PATH . 'lang/' . $lang . '/install.php') ? $lang : 'en';
}
else
{
@@ -64,11 +62,9 @@ function getlang ($link = false)
function getjquerylink()
{
global $_path;
if (file_exists($_path . 'admin/Masmak/js/jquery.min.js'))
if (file_exists(PATH . 'admin/Masmak/js/jquery.min.js'))
{
return $_path . 'admin/Masmak/js/jquery.min.js';
return PATH . 'admin/Masmak/js/jquery.min.js';
}
else
{
@@ -81,7 +77,7 @@ function getjquerylink()
*/
function gettpl($tplname)
{
global $lang, $_path;
global $lang;
$tpl = preg_replace('/{{([^}]+)}}/', '<?php \\1 ?>', file_get_contents('style/' . $tplname));
ob_start();
@@ -95,34 +91,21 @@ function gettpl($tplname)
/**
* Export config
*/
function do_config_export($srv, $usr, $pass, $nm, $prf, $fpath = '')
function do_config_export($srv, $usr, $pass, $nm, $prf)
{
global $_path;
if (! in_array($type, ['mysql', 'mysqli']))
{
$type = 'mysql';
}
$data = '<?php' . "\n\n" . '//fill these variables with your data' . "\n";
//$data .= '$db_type = \'' . $type . "'; //mysqli or mysql \n";
$data .= '$dbserver = \'' . str_replace("'", "\'", $srv) . "'; //database server \n";
$data .= '$dbuser = \'' . str_replace("'", "\'", $usr) . "' ; // database user \n";
$data .= '$dbpass = \'' . str_replace("'", "\'", $pass) . "'; // database password \n";
$data .= '$dbname = \'' . str_replace("'", "\'", $nm) . "'; // database name \n";
$data .= '$dbprefix = \'' . str_replace("'", "\'", $prf) . "'; // if you use prefix for tables , fill it \n";
//$data .= '$adminpath = \'admin.php\';// if you renamed your acp file , please fill the new name here \n';
//$data .= "\n\n\n";
//$data .= "//for integration with script must change user systen from admin cp \n";
//$data .= '$script_path = \'' . str_replace("'", "\'", $fpath) . "'; // path of script (./forums) \n";
//$data .= "\n\n";
//$data .= '?'.'>';
$written = false;
if (is_writable($_path))
if (is_writable(PATH))
{
$fh = @fopen($_path . 'config.php', 'wb');
$fh = @fopen(PATH . 'config.php', 'wb');
if ($fh)
{

View File

@@ -23,6 +23,7 @@ if (file_exists($_path . 'config.php'))
{
include_once $_path . 'config.php';
}
include_once 'includes/plugins.php';
include_once $_path . 'includes/functions_display.php';
include_once $_path . 'includes/functions_alternative.php';
include_once $_path . 'includes/functions.php';
@@ -32,36 +33,6 @@ include_once $_path . 'includes/mysqli.php';
include_once 'includes/functions_install.php';
/**
* @ignore an alias class for plugins class
*/
class Plugins
{
private static $instance;
/**
* @return Plugins
*/
public static function getInstance()
{
if (is_null(self::$instance))
{
self::$instance = new self();
}
return self::$instance;
}
/**
* @return array
*/
public function run($name)
{
return [];
}
}
if (! ig('step'))
{
@@ -71,7 +42,6 @@ if (! ig('step'))
exit;
}
//
// Kleeja must be safe ..
//
@@ -81,7 +51,7 @@ if (! empty($dbuser) && ! empty($dbname) && ! (ig('step') && in_array(g('step'),
if (! empty($d))
{
header('Location: index.php');
header('Location: ./index.php');
exit;
}
@@ -243,8 +213,8 @@ case 'data' :
//connect .. for check
$SQL = new KleejaDatabase($dbserver, $dbuser, $dbpass, $dbname);
include_once '../includes/usr.php';
include_once '../includes/functions_alternative.php';
include_once $_path . 'includes/usr.php';
include_once $_path . 'includes/functions_alternative.php';
$usrcp = new usrcp;
$user_salt = substr(kleeja_base64_encode(pack('H*', sha1(mt_rand()))), 0, 7);

225
install/quick.php Normal file
View File

@@ -0,0 +1,225 @@
<?php
/**
*
* @package install
* @copyright (c) 2007 Kleeja.com
* @license ./docs/license.txt
*
*/
// Report all errors, except notices
@error_reporting(E_ALL ^ E_NOTICE);
/**
* include important files
*/
define('IN_COMMON', true);
$_path = '../';
define('PATH', __DIR__ . '/../');
define('CLI', PHP_SAPI === 'cli');
include_once 'includes/plugins.php';
include_once PATH . 'includes/functions_display.php';
include_once PATH . 'includes/functions_alternative.php';
include_once PATH . 'includes/functions.php';
include_once PATH . 'includes/mysqli.php';
include_once 'includes/functions_install.php';
if (file_exists(PATH . 'config.php'))
{
include_once PATH . 'config.php';
}
else
{
do_config_export(
'localhost',
'root',
'',
'kleeja',
'klj_'
);
exit('`config.php` was missing! so we created one for you, now go fill it with database information.');
}
$SQL = new KleejaDatabase($dbserver, $dbuser, $dbpass, $dbname);
if (! $SQL->is_connected())
{
exit('Can not connect to database, please make sure the data in `config.php` is correct!');
}
if (! empty($SQL->mysql_version()) && version_compare($SQL->mysql_version(), MIN_MYSQL_VERSION, '<'))
{
exit('The required MySQL version is `' . MIN_MYSQL_VERSION . '` and yours is `' . $SQL->mysql_version() . '`!');
}
foreach (['cache', 'uploads', 'uploads/thumbs'] as $folder)
{
if (! is_writable(PATH . $folder))
{
@chmod(PATH . $folder, 0755);
if (! is_writable(PATH . $folder))
{
exit('The folder `' . $folder . '` has to be writable!');
}
}
}
//install
$SQL = new KleejaDatabase($dbserver, $dbuser, $dbpass, $dbname);
include_once PATH . 'includes/usr.php';
include_once PATH . 'includes/functions_alternative.php';
$usrcp = new usrcp;
$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';
// Queries
include 'includes/install_sqls.php';
include 'includes/default_values.php';
$SQL->query($install_sqls['ALTER_DATABASE_UTF']);
$err = 0;
$errors = '';
foreach ($install_sqls as $name => $sql_content)
{
if ($name == 'DROP_TABLES' || $name == 'ALTER_DATABASE_UTF')
{
continue;
}
if (! $SQL->query($sql_content))
{
$errors .= implode(':', $SQL->get_error()) . '' . "\n___\n";
echo $lang['INST_SQL_ERR'] . ' : ' . $name . '[basic]' . (CLI ? PHP_EOL : '<br>');
$err++;
}
}
if ($err == 0)
{
//add configs
foreach ($config_values as $cn)
{
if (empty($cn[6]))
{
$cn[6] = 0;
}
$sql = "INSERT INTO `{$dbprefix}config` (`name`, `value`, `option`, `display_order`, `type`, `plg_id`, `dynamic`) VALUES ('$cn[0]', '$cn[1]', '$cn[2]', '$cn[3]', '$cn[4]', '$cn[5]', '$cn[6]');";
if (! $SQL->query($sql))
{
$errors .= implode(':', $SQL->get_error()) . '' . "\n___\n";
echo $lang['INST_SQL_ERR'] . ' : [configs_values] ' . $cn . (CLI ? PHP_EOL : '<br>');
$err++;
}
}
//add groups configs
foreach ($config_values as $cn)
{
if ($cn[4] != 'groups' or ! $cn[4])
{
continue;
}
$itxt = '';
foreach ([1, 2, 3] as $im)
{
$itxt .= ($itxt == '' ? '' : ',') . "($im, '$cn[0]', '$cn[1]')";
}
$sql = "INSERT INTO `{$dbprefix}groups_data` (`group_id`, `name`, `value`) VALUES " . $itxt . ';';
if (! $SQL->query($sql))
{
$errors .= implode(':', $SQL->get_error()) . '' . "\n___\n";
echo $lang['INST_SQL_ERR'] . ' : [groups_configs_values] ' . $cn . (CLI ? PHP_EOL : '<br>');
$err++;
}
}
//add exts
foreach ($ext_values as $gid => $exts)
{
$itxt = '';
foreach ($exts as $t => $v)
{
$itxt .= ($itxt == '' ? '' : ',') . "('$t', $gid, $v)";
}
$sql = "INSERT INTO `{$dbprefix}groups_exts` (`ext`, `group_id`, `size`) VALUES " . $itxt . ';';
if (! $SQL->query($sql))
{
$errors .= implode(':', $SQL->get_error()) . '' . "\n___\n";
echo $lang['INST_SQL_ERR'] . ' : [ext_values] ' . $gid . (CLI ? PHP_EOL : '<br>');
$err++;
}
}
//add acls
foreach ($acls_values as $cn => $ct)
{
$it = 1;
$itxt = '';
foreach ($ct as $ctk)
{
$itxt .= ($itxt == '' ? '' : ',') . "('$cn', '$it', '$ctk')";
$it++;
}
$sql = "INSERT INTO `{$dbprefix}groups_acl` (`acl_name`, `group_id`, `acl_can`) VALUES " . $itxt . ';';
if (! $SQL->query($sql))
{
$errors .= implode(':', $SQL->get_error()) . '' . "\n___\n";
echo $lang['INST_SQL_ERR'] . ' : [acl_values] ' . $cn . (CLI ? PHP_EOL : '<br>');
$err++;
}
$it++;
}
}
if ($err > 0)
{
echo CLI ? PHP_EOL : '<br><span style="color:red">';
echo 'We encountered a problem during installation, see the error log:';
echo CLI ? PHP_EOL : '</span><br>';
echo CLI ? '' : '<textarea rows="10" style="width:100%">';
echo $errors;
echo CLI ? '' : '</textarea>';
}
else
{
echo CLI ? '' : '<span style="color:green">';
echo 'Kleeja has been installed successfully, enjoy ...';
echo CLI ? PHP_EOL : '</span><br><br>';
echo 'Username: admin' . (CLI ? PHP_EOL : '<br>');
echo 'Password: ' . $password;
}