is_connected()) { exit('Can not connect to database, please make sure the data in `config.php` is correct!'); } if (defined('SQL_LAYER') && SQL_LAYER == 'mysqli') { if (! empty($SQL->version()) && version_compare($SQL->version(), MIN_MYSQL_VERSION, '<')) { exit('The required MySQL version is `' . MIN_MYSQL_VERSION . '` and yours is `' . $SQL->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, $dbprefix); include_once PATH . 'includes/usr.php'; include_once PATH . 'includes/functions_alternative.php'; $usrcp = new usrcp; $password = ! empty($cli_options['password']) ? $cli_options['password'] : mt_rand(); $user_salt = substr(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 = ! 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'; 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 : '
'); $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 : '
'); $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 : '
'); $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 : '
'); $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 : '
'); $err++; } $it++; } } if ($err > 0) { echo CLI ? PHP_EOL : '
'; echo 'We encountered a problem during installation, see the error log:'; echo CLI ? PHP_EOL : '
'; echo CLI ? '' : ''; } else { echo CLI ? '' : ''; echo 'Kleeja has been installed successfully, enjoy ...'; echo CLI ? PHP_EOL : '

'; echo 'Username: admin' . (CLI ? PHP_EOL : '
'); echo 'Password: ' . $password; }