Current oav website
This commit is contained in:
73
dotclear._no/admin/install/check.php
Normal file
73
dotclear._no/admin/install/check.php
Normal file
@ -0,0 +1,73 @@
|
||||
<?php
|
||||
/**
|
||||
* @package Dotclear
|
||||
* @subpackage Install
|
||||
*
|
||||
* @copyright Olivier Meunier & Association Dotclear
|
||||
* @copyright GPL-2.0-only
|
||||
*/
|
||||
|
||||
if (!defined('DC_RC_PATH')) {return;}
|
||||
|
||||
function dcSystemCheck($con, &$err)
|
||||
{
|
||||
$err = [];
|
||||
|
||||
if (version_compare(phpversion(), '5.6', '<')) {
|
||||
$err[] = sprintf(__('PHP version is %s (5.6 or earlier needed).'), phpversion());
|
||||
}
|
||||
|
||||
if (!function_exists('mb_detect_encoding')) {
|
||||
$err[] = __('Multibyte string module (mbstring) is not available.');
|
||||
}
|
||||
|
||||
if (!function_exists('iconv')) {
|
||||
$err[] = __('Iconv module is not available.');
|
||||
}
|
||||
|
||||
if (!function_exists('ob_start')) {
|
||||
$err[] = __('Output control functions are not available.');
|
||||
}
|
||||
|
||||
if (!function_exists('simplexml_load_string')) {
|
||||
$err[] = __('SimpleXML module is not available.');
|
||||
}
|
||||
|
||||
if (!function_exists('dom_import_simplexml')) {
|
||||
$err[] = __('DOM XML module is not available.');
|
||||
}
|
||||
|
||||
$pcre_str = base64_decode('w6nDqMOgw6o=');
|
||||
if (!@preg_match('/' . $pcre_str . '/u', $pcre_str)) {
|
||||
$err[] = __('PCRE engine does not support UTF-8 strings.');
|
||||
}
|
||||
|
||||
if (!function_exists("spl_classes")) {
|
||||
$err[] = __('SPL module is not available.');
|
||||
}
|
||||
|
||||
if ($con->syntax() == 'mysql') {
|
||||
if (version_compare($con->version(), '4.1', '<')) {
|
||||
$err[] = sprintf(__('MySQL version is %s (4.1 or earlier needed).'), $con->version());
|
||||
} else {
|
||||
$rs = $con->select('SHOW ENGINES');
|
||||
$innodb = false;
|
||||
while ($rs->fetch()) {
|
||||
if (strtolower($rs->f(0)) == 'innodb' && strtolower($rs->f(1)) != 'disabled' && strtolower($rs->f(1)) != 'no') {
|
||||
$innodb = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (!$innodb) {
|
||||
$err[] = __('MySQL InnoDB engine is not available.');
|
||||
}
|
||||
}
|
||||
} elseif ($con->driver() == 'pgsql') {
|
||||
if (version_compare($con->version(), '8.0', '<')) {
|
||||
$err[] = sprintf(__('PostgreSQL version is %s (8.0 or earlier needed).'), $con->version());
|
||||
}
|
||||
}
|
||||
|
||||
return count($err) == 0;
|
||||
}
|
||||
421
dotclear._no/admin/install/index.php
Normal file
421
dotclear._no/admin/install/index.php
Normal file
@ -0,0 +1,421 @@
|
||||
<?php
|
||||
/**
|
||||
* @package Dotclear
|
||||
* @subpackage Install
|
||||
*
|
||||
* @copyright Olivier Meunier & Association Dotclear
|
||||
* @copyright GPL-2.0-only
|
||||
*/
|
||||
|
||||
if (isset($_SERVER['DC_RC_PATH'])) {
|
||||
$rc_path = $_SERVER['DC_RC_PATH'];
|
||||
} elseif (isset($_SERVER['REDIRECT_DC_RC_PATH'])) {
|
||||
$rc_path = $_SERVER['REDIRECT_DC_RC_PATH'];
|
||||
} else {
|
||||
$rc_path = dirname(__FILE__) . '/../../inc/config.php';
|
||||
}
|
||||
|
||||
require dirname(__FILE__) . '/../../inc/prepend.php';
|
||||
require dirname(__FILE__) . '/check.php';
|
||||
|
||||
$can_install = true;
|
||||
$err = '';
|
||||
|
||||
# Loading locales for detected language
|
||||
$dlang = http::getAcceptLanguage();
|
||||
if ($dlang != 'en') {
|
||||
l10n::init($dlang);
|
||||
l10n::set(dirname(__FILE__) . '/../../locales/' . $dlang . '/date');
|
||||
l10n::set(dirname(__FILE__) . '/../../locales/' . $dlang . '/main');
|
||||
l10n::set(dirname(__FILE__) . '/../../locales/' . $dlang . '/plugins');
|
||||
}
|
||||
|
||||
if (!defined('DC_MASTER_KEY') || DC_MASTER_KEY == '') {
|
||||
$can_install = false;
|
||||
$err = '<p>' . __('Please set a master key (DC_MASTER_KEY) in configuration file.') . '</p>';
|
||||
}
|
||||
|
||||
# Check if dotclear is already installed
|
||||
$schema = dbSchema::init($core->con);
|
||||
if (in_array($core->prefix . 'post', $schema->getTables())) {
|
||||
$can_install = false;
|
||||
$err = '<p>' . __('Dotclear is already installed.') . '</p>';
|
||||
}
|
||||
|
||||
# Check system capabilites
|
||||
if (!dcSystemCheck($core->con, $_e)) {
|
||||
$can_install = false;
|
||||
$err = '<p>' . __('Dotclear cannot be installed.') . '</p><ul><li>' . implode('</li><li>', $_e) . '</li></ul>';
|
||||
}
|
||||
|
||||
# Get information and perform install
|
||||
$u_email = $u_firstname = $u_name = $u_login = $u_pwd = '';
|
||||
$mail_sent = false;
|
||||
if ($can_install && !empty($_POST)) {
|
||||
$u_email = !empty($_POST['u_email']) ? $_POST['u_email'] : null;
|
||||
$u_firstname = !empty($_POST['u_firstname']) ? $_POST['u_firstname'] : null;
|
||||
$u_name = !empty($_POST['u_name']) ? $_POST['u_name'] : null;
|
||||
$u_login = !empty($_POST['u_login']) ? $_POST['u_login'] : null;
|
||||
$u_pwd = !empty($_POST['u_pwd']) ? $_POST['u_pwd'] : null;
|
||||
$u_pwd2 = !empty($_POST['u_pwd2']) ? $_POST['u_pwd2'] : null;
|
||||
|
||||
try
|
||||
{
|
||||
# Check user information
|
||||
if (empty($u_login)) {
|
||||
throw new Exception(__('No user ID given'));
|
||||
}
|
||||
if (!preg_match('/^[A-Za-z0-9@._-]{2,}$/', $u_login)) {
|
||||
throw new Exception(__('User ID must contain at least 2 characters using letters, numbers or symbols.'));
|
||||
}
|
||||
if ($u_email && !text::isEmail($u_email)) {
|
||||
throw new Exception(__('Invalid email address'));
|
||||
}
|
||||
|
||||
if (empty($u_pwd)) {
|
||||
throw new Exception(__('No password given'));
|
||||
}
|
||||
if ($u_pwd != $u_pwd2) {
|
||||
throw new Exception(__("Passwords don't match"));
|
||||
}
|
||||
if (strlen($u_pwd) < 6) {
|
||||
throw new Exception(__('Password must contain at least 6 characters.'));
|
||||
}
|
||||
|
||||
# Try to guess timezone
|
||||
$default_tz = 'Europe/London';
|
||||
if (!empty($_POST['u_date']) && function_exists('timezone_open')) {
|
||||
if (preg_match('/\((.+)\)$/', $_POST['u_date'], $_tz)) {
|
||||
$_tz = $_tz[1];
|
||||
$_tz = @timezone_open($_tz);
|
||||
if ($_tz instanceof DateTimeZone) {
|
||||
$_tz = @timezone_name_get($_tz);
|
||||
|
||||
// check if timezone is valid
|
||||
// date_default_timezone_set throw E_NOTICE and/or E_WARNING if timezone is not valid and return false
|
||||
if (@date_default_timezone_set($_tz) !== false && $_tz) {
|
||||
$default_tz = $_tz;
|
||||
}
|
||||
}
|
||||
unset($_tz);
|
||||
}
|
||||
}
|
||||
|
||||
# Create schema
|
||||
$_s = new dbStruct($core->con, $core->prefix);
|
||||
require dirname(__FILE__) . '/../../inc/dbschema/db-schema.php';
|
||||
|
||||
$si = new dbStruct($core->con, $core->prefix);
|
||||
$changes = $si->synchronize($_s);
|
||||
|
||||
# Create user
|
||||
$cur = $core->con->openCursor($core->prefix . 'user');
|
||||
$cur->user_id = $u_login;
|
||||
$cur->user_super = 1;
|
||||
$cur->user_pwd = $core->auth->crypt($u_pwd);
|
||||
$cur->user_name = (string) $u_name;
|
||||
$cur->user_firstname = (string) $u_firstname;
|
||||
$cur->user_email = (string) $u_email;
|
||||
$cur->user_lang = $dlang;
|
||||
$cur->user_tz = $default_tz;
|
||||
$cur->user_creadt = date('Y-m-d H:i:s');
|
||||
$cur->user_upddt = date('Y-m-d H:i:s');
|
||||
$cur->user_options = serialize($core->userDefaults());
|
||||
$cur->insert();
|
||||
|
||||
$core->auth->checkUser($u_login);
|
||||
|
||||
$admin_url = preg_replace('%install/index.php$%', '', $_SERVER['REQUEST_URI']);
|
||||
$root_url = preg_replace('%/admin/install/index.php$%', '', $_SERVER['REQUEST_URI']);
|
||||
|
||||
# Create blog
|
||||
$cur = $core->con->openCursor($core->prefix . 'blog');
|
||||
$cur->blog_id = 'default';
|
||||
$cur->blog_url = http::getHost() . $root_url . '/index.php?';
|
||||
$cur->blog_name = __('My first blog');
|
||||
$core->addBlog($cur);
|
||||
$core->blogDefaults($cur->blog_id);
|
||||
|
||||
$blog_settings = new dcSettings($core, 'default');
|
||||
$blog_settings->addNamespace('system');
|
||||
$blog_settings->system->put('blog_timezone', $default_tz);
|
||||
$blog_settings->system->put('lang', $dlang);
|
||||
$blog_settings->system->put('public_url', $root_url . '/public');
|
||||
$blog_settings->system->put('themes_url', $root_url . '/themes');
|
||||
|
||||
# date and time formats
|
||||
$formatDate = __('%A, %B %e %Y');
|
||||
$date_formats = ['%Y-%m-%d', '%m/%d/%Y', '%d/%m/%Y', '%Y/%m/%d', '%d.%m.%Y', '%b %e %Y', '%e %b %Y', '%Y %b %e',
|
||||
'%a, %Y-%m-%d', '%a, %m/%d/%Y', '%a, %d/%m/%Y', '%a, %Y/%m/%d', '%B %e, %Y', '%e %B, %Y', '%Y, %B %e', '%e. %B %Y',
|
||||
'%A, %B %e, %Y', '%A, %e %B, %Y', '%A, %Y, %B %e', '%A, %Y, %B %e', '%A, %e. %B %Y'];
|
||||
$time_formats = ['%H:%M', '%I:%M', '%l:%M', '%Hh%M', '%Ih%M', '%lh%M'];
|
||||
if (strtoupper(substr(PHP_OS, 0, 3)) == 'WIN') {
|
||||
$formatDate = preg_replace('#(?<!%)((?:%%)*)%e#', '\1%#d', $formatDate);
|
||||
$date_formats = array_map(
|
||||
function ($f) {
|
||||
return str_replace('%e', '%#d', $f);
|
||||
},
|
||||
$date_formats);
|
||||
}
|
||||
$blog_settings->system->put('date_format', $formatDate);
|
||||
$blog_settings->system->put('date_formats', $date_formats, 'array', 'Date formats examples', true, true);
|
||||
$blog_settings->system->put('time_formats', $time_formats, 'array', 'Time formats examples', true, true);
|
||||
|
||||
# Add repository URL for themes and plugins
|
||||
$blog_settings->system->put('store_plugin_url', 'https://update.dotaddict.org/dc2/plugins.xml', 'string', 'Plugins XML feed location', true, true);
|
||||
$blog_settings->system->put('store_theme_url', 'https://update.dotaddict.org/dc2/themes.xml', 'string', 'Themes XML feed location', true, true);
|
||||
|
||||
# CSP directive (admin part)
|
||||
|
||||
/* SQlite Clearbricks driver does not allow using single quote at beginning or end of a field value
|
||||
so we have to use neutral values (localhost and 127.0.0.1) for some CSP directives
|
||||
*/
|
||||
$csp_prefix = $core->con->driver() == 'sqlite' ? 'localhost ' : ''; // Hack for SQlite Clearbricks driver
|
||||
$csp_suffix = $core->con->driver() == 'sqlite' ? ' 127.0.0.1' : ''; // Hack for SQlite Clearbricks driver
|
||||
|
||||
$blog_settings->system->put('csp_admin_on', true, 'boolean', 'Send CSP header (admin)', true, true);
|
||||
$blog_settings->system->put('csp_admin_report_only', false, 'boolean', 'CSP Report only violations (admin)', true, true);
|
||||
$blog_settings->system->put('csp_admin_default',
|
||||
$csp_prefix . "'self'" . $csp_suffix, 'string', 'CSP default-src directive', true, true);
|
||||
$blog_settings->system->put('csp_admin_script',
|
||||
$csp_prefix . "'self' 'unsafe-eval'" . $csp_suffix, 'string', 'CSP script-src directive', true, true);
|
||||
$blog_settings->system->put('csp_admin_style',
|
||||
$csp_prefix . "'self' 'unsafe-inline'" . $csp_suffix, 'string', 'CSP style-src directive', true, true);
|
||||
$blog_settings->system->put('csp_admin_img',
|
||||
$csp_prefix . "'self' data: https://media.dotaddict.org blob:", 'string', 'CSP img-src directive', true, true);
|
||||
|
||||
# Add Dotclear version
|
||||
$cur = $core->con->openCursor($core->prefix . 'version');
|
||||
$cur->module = 'core';
|
||||
$cur->version = (string) DC_VERSION;
|
||||
$cur->insert();
|
||||
|
||||
# Create first post
|
||||
$core->setBlog('default');
|
||||
|
||||
$cur = $core->con->openCursor($core->prefix . 'post');
|
||||
$cur->user_id = $u_login;
|
||||
$cur->post_format = 'xhtml';
|
||||
$cur->post_lang = $dlang;
|
||||
$cur->post_title = __('Welcome to Dotclear!');
|
||||
$cur->post_content = '<p>' . __('This is your first entry. When you\'re ready ' .
|
||||
'to blog, log in to edit or delete it.') . '</p>';
|
||||
$cur->post_content_xhtml = $cur->post_content;
|
||||
$cur->post_status = 1;
|
||||
$cur->post_open_comment = 1;
|
||||
$cur->post_open_tb = 0;
|
||||
$post_id = $core->blog->addPost($cur);
|
||||
|
||||
# Add a comment to it
|
||||
$cur = $core->con->openCursor($core->prefix . 'comment');
|
||||
$cur->post_id = $post_id;
|
||||
$cur->comment_tz = $default_tz;
|
||||
$cur->comment_author = __('Dotclear Team');
|
||||
$cur->comment_email = 'contact@dotclear.net';
|
||||
$cur->comment_site = 'https://dotclear.org/';
|
||||
$cur->comment_content = __("<p>This is a comment.</p>\n<p>To delete it, log in and " .
|
||||
"view your blog's comments. Then you might remove or edit it.</p>");
|
||||
$core->blog->addComment($cur);
|
||||
|
||||
# Plugins initialization
|
||||
define('DC_CONTEXT_ADMIN', true);
|
||||
$core->plugins->loadModules(DC_PLUGINS_ROOT);
|
||||
$plugins_install = $core->plugins->installModules();
|
||||
|
||||
# Add dashboard module options
|
||||
$core->auth->user_prefs->addWorkspace('dashboard');
|
||||
$core->auth->user_prefs->dashboard->put('doclinks', true, 'boolean', '', null, true);
|
||||
$core->auth->user_prefs->dashboard->put('dcnews', true, 'boolean', '', null, true);
|
||||
$core->auth->user_prefs->dashboard->put('quickentry', true, 'boolean', '', null, true);
|
||||
$core->auth->user_prefs->dashboard->put('nodcupdate', false, 'boolean', '', null, true);
|
||||
|
||||
# Add accessibility options
|
||||
$core->auth->user_prefs->addWorkspace('accessibility');
|
||||
$core->auth->user_prefs->accessibility->put('nodragdrop', false, 'boolean', '', null, true);
|
||||
|
||||
# Add user interface options
|
||||
$core->auth->user_prefs->addWorkspace('interface');
|
||||
$core->auth->user_prefs->interface->put('enhanceduploader', true, 'boolean', '', null, true);
|
||||
|
||||
# Add default favorites
|
||||
$core->favs = new dcFavorites($core);
|
||||
$init_favs = ['posts', 'new_post', 'newpage', 'comments', 'categories', 'media', 'blog_theme', 'widgets', 'simpleMenu', 'prefs', 'help'];
|
||||
$core->favs->setFavoriteIDs($init_favs, true);
|
||||
|
||||
$step = 1;
|
||||
} catch (Exception $e) {
|
||||
$err = $e->getMessage();
|
||||
}
|
||||
}
|
||||
|
||||
if (!isset($step)) {
|
||||
$step = 0;
|
||||
}
|
||||
header('Content-Type: text/html; charset=UTF-8');
|
||||
|
||||
// Prevents Clickjacking as far as possible
|
||||
header('X-Frame-Options: SAMEORIGIN'); // FF 3.6.9+ Chrome 4.1+ IE 8+ Safari 4+ Opera 10.5+
|
||||
|
||||
?>
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8" />
|
||||
<meta http-equiv="Content-Script-Type" content="text/javascript" />
|
||||
<meta http-equiv="Content-Style-Type" content="text/css" />
|
||||
<meta http-equiv="Content-Language" content="en" />
|
||||
<meta name="ROBOTS" content="NOARCHIVE,NOINDEX,NOFOLLOW" />
|
||||
<meta name="GOOGLEBOT" content="NOSNIPPET" />
|
||||
<title><?php echo __('Dotclear Install'); ?></title>
|
||||
|
||||
<link rel="stylesheet" href="../style/install.css" type="text/css" media="screen" />
|
||||
|
||||
<?php echo dcPage::jsLoad('../js/prepend.js'); ?>
|
||||
<?php echo dcPage::jsLoad('../js/jquery/jquery.js'); ?>
|
||||
<?php echo dcPage::jsLoad('../js/jquery/jquery.pwstrength.js'); ?>
|
||||
<?php echo dcPage::jsJson('install', [
|
||||
sprintf(__('Password strength: %s'), __('very weak')),
|
||||
sprintf(__('Password strength: %s'), __('weak')),
|
||||
sprintf(__('Password strength: %s'), __('mediocre')),
|
||||
sprintf(__('Password strength: %s'), __('strong')),
|
||||
sprintf(__('Password strength: %s'), __('very strong'))
|
||||
]);
|
||||
?>
|
||||
<?php echo dcPage::jsJson('install_show', __('show')); ?>
|
||||
<?php echo dcPage::jsLoad('../js/_install.js'); ?>
|
||||
</head>
|
||||
|
||||
<body id="dotclear-admin" class="install">
|
||||
<div id="content">
|
||||
<?php
|
||||
echo
|
||||
'<h1>' . __('Dotclear installation') . '</h1>' .
|
||||
'<div id="main">';
|
||||
|
||||
if (!is_writable(DC_TPL_CACHE)) {
|
||||
echo '<div class="error" role="alert"><p>' . sprintf(__('Cache directory %s is not writable.'), DC_TPL_CACHE) . '</p></div>';
|
||||
}
|
||||
|
||||
if ($can_install && !empty($err)) {
|
||||
echo '<div class="error" role="alert"><p><strong>' . __('Errors:') . '</strong></p>' . $err . '</div>';
|
||||
}
|
||||
|
||||
if (!empty($_GET['wiz'])) {
|
||||
echo '<p class="success" role="alert">' . __('Configuration file has been successfully created.') . '</p>';
|
||||
}
|
||||
|
||||
if ($can_install && $step == 0) {
|
||||
echo
|
||||
'<h2>' . __('User information') . '</h2>' .
|
||||
|
||||
'<p>' . __('Please provide the following information needed to create the first user.') . '</p>' .
|
||||
|
||||
'<form action="index.php" method="post">' .
|
||||
'<fieldset><legend>' . __('User information') . '</legend>' .
|
||||
'<p><label for="u_firstname">' . __('First Name:') . '</label> ' .
|
||||
form::field('u_firstname', 30, 255, [
|
||||
'default' => html::escapeHTML($u_firstname),
|
||||
'autocomplete' => 'given-name'
|
||||
]) .
|
||||
'</p>' .
|
||||
'<p><label for="u_name">' . __('Last Name:') . '</label> ' .
|
||||
form::field('u_name', 30, 255, [
|
||||
'default' => html::escapeHTML($u_name),
|
||||
'autocomplete' => 'family-name'
|
||||
]) .
|
||||
'</p>' .
|
||||
'<p><label for="u_email">' . __('Email:') . '</label> ' .
|
||||
form::email('u_email', [
|
||||
'size' => 30,
|
||||
'default' => html::escapeHTML($u_email),
|
||||
'autocomplete' => 'email'
|
||||
]) .
|
||||
'</p>' .
|
||||
'</fieldset>' .
|
||||
|
||||
'<fieldset><legend>' . __('Username and password') . '</legend>' .
|
||||
'<p><label for="u_login" class="required"><abbr title="' . __('Required field') . '">*</abbr> ' . __('Username:') . ' ' .
|
||||
form::field('u_login', 30, 32, [
|
||||
'default' => html::escapeHTML($u_login),
|
||||
'extra_html' => 'required placeholder="' . __('Username') . '"',
|
||||
'autocomplete' => 'username'
|
||||
]) .
|
||||
'</label></p>' .
|
||||
'<div class="pw-table">' .
|
||||
'<p class="pw-cell">' .
|
||||
'<label for="u_pwd" class="required"><abbr title="' . __('Required field') . '">*</abbr> ' . __('New password:') . '</label>' .
|
||||
form::password('u_pwd', 30, 255, [
|
||||
'extra_html' => 'data-indicator="pwindicator" required placeholder="' . __('Password') . '"',
|
||||
'autocomplete' => 'new-password'
|
||||
]) .
|
||||
'</p>' .
|
||||
'<div id="pwindicator">' .
|
||||
' <div class="bar"></div>' .
|
||||
' <p class="label no-margin"></p>' .
|
||||
'</div>' .
|
||||
'</div>' .
|
||||
'<p><label for="u_pwd2" class="required"><abbr title="' . __('Required field') . '">*</abbr> ' . __('Confirm password:') . ' ' .
|
||||
form::password('u_pwd2', 30, 255, [
|
||||
'extra_html' => 'required placeholder="' . __('Password') . '"',
|
||||
'autocomplete' => 'new-password'
|
||||
]) .
|
||||
'</label></p>' .
|
||||
'</fieldset>' .
|
||||
|
||||
'<p><input type="submit" value="' . __('Save') . '" /></p>' .
|
||||
'</form>';
|
||||
} elseif ($can_install && $step == 1) {
|
||||
# Plugins install messages
|
||||
$plugins_install_result = '';
|
||||
if (!empty($plugins_install['success'])) {
|
||||
$plugins_install_result .= '<div class="static-msg">' . __('Following plugins have been installed:') . '<ul>';
|
||||
foreach ($plugins_install['success'] as $k => $v) {
|
||||
$plugins_install_result .= '<li>' . $k . '</li>';
|
||||
}
|
||||
$plugins_install_result .= '</ul></div>';
|
||||
}
|
||||
if (!empty($plugins_install['failure'])) {
|
||||
$plugins_install_result .= '<div class="error">' . __('Following plugins have not been installed:') . '<ul>';
|
||||
foreach ($plugins_install['failure'] as $k => $v) {
|
||||
$plugins_install_result .= '<li>' . $k . ' (' . $v . ')</li>';
|
||||
}
|
||||
$plugins_install_result .= '</ul></div>';
|
||||
}
|
||||
|
||||
echo
|
||||
'<h2>' . __('All done!') . '</h2>' .
|
||||
|
||||
$plugins_install_result .
|
||||
|
||||
'<p class="success" role="alert">' . __('Dotclear has been successfully installed. Here is some useful information you should keep.') . '</p>' .
|
||||
|
||||
'<h3>' . __('Your account') . '</h3>' .
|
||||
'<ul>' .
|
||||
'<li>' . __('Username:') . ' <strong>' . html::escapeHTML($u_login) . '</strong></li>' .
|
||||
'<li>' . __('Password:') . ' <strong id="password">' . html::escapeHTML($u_pwd) . '</strong></li>' .
|
||||
'</ul>' .
|
||||
|
||||
'<h3>' . __('Your blog') . '</h3>' .
|
||||
'<ul>' .
|
||||
'<li>' . __('Blog address:') . ' <strong>' . html::escapeHTML(http::getHost() . $root_url) . '/index.php?</strong></li>' .
|
||||
'<li>' . __('Administration interface:') . ' <strong>' . html::escapeHTML(http::getHost() . $admin_url) . '</strong></li>' .
|
||||
'</ul>' .
|
||||
|
||||
'<form action="../auth.php" method="post">' .
|
||||
'<p><input type="submit" value="' . __('Manage your blog now') . '" />' .
|
||||
form::hidden(['user_id'], html::escapeHTML($u_login)) .
|
||||
form::hidden(['user_pwd'], html::escapeHTML($u_pwd)) .
|
||||
'</p>' .
|
||||
'</form>';
|
||||
} elseif (!$can_install) {
|
||||
echo '<h2>' . __('Installation can not be completed') . '</h2>' .
|
||||
'<div class="error" role="alert"><p><strong>' . __('Errors:') . '</strong></p>' . $err . '</div>' .
|
||||
'<p>' . __('For the said reasons, Dotclear can not be installed. ' .
|
||||
'Please refer to <a href="https://dotclear.org/documentation/2.0/admin/install">' .
|
||||
'the documentation</a> to learn how to correct the problem.') . '</p>';
|
||||
}
|
||||
?>
|
||||
</div>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
231
dotclear._no/admin/install/wizard.php
Normal file
231
dotclear._no/admin/install/wizard.php
Normal file
@ -0,0 +1,231 @@
|
||||
<?php
|
||||
/**
|
||||
* @package Dotclear
|
||||
* @subpackage Install
|
||||
*
|
||||
* @copyright Olivier Meunier & Association Dotclear
|
||||
* @copyright GPL-2.0-only
|
||||
*/
|
||||
|
||||
if (isset($_SERVER['DC_RC_PATH'])) {
|
||||
define('DC_RC_PATH', $_SERVER['DC_RC_PATH']);
|
||||
} elseif (isset($_SERVER['REDIRECT_DC_RC_PATH'])) {
|
||||
define('DC_RC_PATH', $_SERVER['REDIRECT_DC_RC_PATH']);
|
||||
} else {
|
||||
define('DC_RC_PATH', dirname(__FILE__) . '/../../inc/config.php');
|
||||
}
|
||||
|
||||
# ClearBricks and DotClear classes auto-loader
|
||||
if (@is_dir('/usr/lib/clearbricks')) {
|
||||
define('CLEARBRICKS_PATH', '/usr/lib/clearbricks');
|
||||
} elseif (is_dir(dirname(__FILE__) . '/../../inc/libs/clearbricks')) {
|
||||
define('CLEARBRICKS_PATH', dirname(__FILE__) . '/../../inc/libs/clearbricks');
|
||||
} elseif (isset($_SERVER['CLEARBRICKS_PATH']) && is_dir($_SERVER['CLEARBRICKS_PATH'])) {
|
||||
define('CLEARBRICKS_PATH', $_SERVER['CLEARBRICKS_PATH']);
|
||||
}
|
||||
|
||||
if (!defined('CLEARBRICKS_PATH') || !is_dir(CLEARBRICKS_PATH)) {
|
||||
exit('No clearbricks path defined');
|
||||
}
|
||||
|
||||
require CLEARBRICKS_PATH . '/_common.php';
|
||||
|
||||
# Loading locales for detected language
|
||||
$dlang = http::getAcceptLanguage();
|
||||
if ($dlang != 'en') {
|
||||
l10n::init($dlang);
|
||||
l10n::set(dirname(__FILE__) . '/../../locales/' . $dlang . '/main');
|
||||
}
|
||||
|
||||
if (is_file(DC_RC_PATH)) {
|
||||
http::redirect('index.php');
|
||||
}
|
||||
|
||||
if (!is_writable(dirname(DC_RC_PATH))) {
|
||||
$err = '<p>' . sprintf(__('Path <strong>%s</strong> is not writable.'), path::real(dirname(DC_RC_PATH))) . '</p>' .
|
||||
'<p>' . __('Dotclear installation wizard could not create configuration file for you. ' .
|
||||
'You must change folder right or create the <strong>config.php</strong> ' .
|
||||
'file manually, please refer to ' .
|
||||
'<a href="https://dotclear.org/documentation/2.0/admin/install">' .
|
||||
'the documentation</a> to learn how to do this.') . '</p>';
|
||||
}
|
||||
|
||||
$DBDRIVER = !empty($_POST['DBDRIVER']) ? $_POST['DBDRIVER'] : (function_exists('mysqli_connect') ? 'mysqli' : 'mysql');
|
||||
$DBHOST = !empty($_POST['DBHOST']) ? $_POST['DBHOST'] : '';
|
||||
$DBNAME = !empty($_POST['DBNAME']) ? $_POST['DBNAME'] : '';
|
||||
$DBUSER = !empty($_POST['DBUSER']) ? $_POST['DBUSER'] : '';
|
||||
$DBPASSWORD = !empty($_POST['DBPASSWORD']) ? $_POST['DBPASSWORD'] : '';
|
||||
$DBPREFIX = !empty($_POST['DBPREFIX']) ? $_POST['DBPREFIX'] : 'dc_';
|
||||
$ADMINMAILFROM = !empty($_POST['ADMINMAILFROM']) ? $_POST['ADMINMAILFROM'] : '';
|
||||
|
||||
if (!empty($_POST)) {
|
||||
try
|
||||
{
|
||||
if ($DBDRIVER == 'sqlite') {
|
||||
if (strpos($DBNAME, '/') === false) {
|
||||
$sqlite_db_directory = dirname(DC_RC_PATH) . '/../db/';
|
||||
files::makeDir($sqlite_db_directory, true);
|
||||
|
||||
# Can we write sqlite_db_directory ?
|
||||
if (!is_writable($sqlite_db_directory)) {
|
||||
throw new Exception(sprintf(__('Cannot write "%s" directory.'), path::real($sqlite_db_directory, false)));
|
||||
}
|
||||
$DBNAME = $sqlite_db_directory . $DBNAME;
|
||||
}
|
||||
}
|
||||
|
||||
# Tries to connect to database
|
||||
try {
|
||||
$con = dbLayer::init($DBDRIVER, $DBHOST, $DBNAME, $DBUSER, $DBPASSWORD);
|
||||
} catch (Exception $e) {
|
||||
throw new Exception('<p>' . __($e->getMessage()) . '</p>');
|
||||
}
|
||||
|
||||
# Checks system capabilites
|
||||
require dirname(__FILE__) . '/check.php';
|
||||
if (!dcSystemCheck($con, $_e)) {
|
||||
$can_install = false;
|
||||
throw new Exception('<p>' . __('Dotclear cannot be installed.') . '</p><ul><li>' . implode('</li><li>', $_e) . '</li></ul>');
|
||||
}
|
||||
|
||||
# Check if dotclear is already installed
|
||||
$schema = dbSchema::init($con);
|
||||
if (in_array($DBPREFIX . 'version', $schema->getTables())) {
|
||||
throw new Exception(__('Dotclear is already installed.'));
|
||||
}
|
||||
# Check master email
|
||||
if (!text::isEmail($ADMINMAILFROM)) {
|
||||
throw new Exception(__('Master email is not valid.'));
|
||||
}
|
||||
|
||||
# Does config.php.in exist?
|
||||
$config_in = dirname(__FILE__) . '/../../inc/config.php.in';
|
||||
if (!is_file($config_in)) {
|
||||
throw new Exception(sprintf(__('File %s does not exist.'), $config_in));
|
||||
}
|
||||
|
||||
# Can we write config.php
|
||||
if (!is_writable(dirname(DC_RC_PATH))) {
|
||||
throw new Exception(sprintf(__('Cannot write %s file.'), DC_RC_PATH));
|
||||
}
|
||||
|
||||
# Creates config.php file
|
||||
$full_conf = file_get_contents($config_in);
|
||||
|
||||
writeConfigValue('DC_DBDRIVER', $DBDRIVER, $full_conf);
|
||||
writeConfigValue('DC_DBHOST', $DBHOST, $full_conf);
|
||||
writeConfigValue('DC_DBUSER', $DBUSER, $full_conf);
|
||||
writeConfigValue('DC_DBPASSWORD', $DBPASSWORD, $full_conf);
|
||||
writeConfigValue('DC_DBNAME', $DBNAME, $full_conf);
|
||||
writeConfigValue('DC_DBPREFIX', $DBPREFIX, $full_conf);
|
||||
|
||||
$admin_url = preg_replace('%install/wizard.php$%', '', $_SERVER['REQUEST_URI']);
|
||||
writeConfigValue('DC_ADMIN_URL', http::getHost() . $admin_url, $full_conf);
|
||||
$admin_email = !empty($ADMINMAILFROM) ? $ADMINMAILFROM : 'dotclear@' . $_SERVER['HTTP_HOST'];
|
||||
writeConfigValue('DC_ADMIN_MAILFROM', $admin_email, $full_conf);
|
||||
writeConfigValue('DC_MASTER_KEY', md5(uniqid()), $full_conf);
|
||||
|
||||
$fp = @fopen(DC_RC_PATH, 'wb');
|
||||
if ($fp === false) {
|
||||
throw new Exception(sprintf(__('Cannot write %s file.'), DC_RC_PATH));
|
||||
}
|
||||
fwrite($fp, $full_conf);
|
||||
fclose($fp);
|
||||
chmod(DC_RC_PATH, 0666);
|
||||
|
||||
$con->close();
|
||||
http::redirect('index.php?wiz=1');
|
||||
} catch (Exception $e) {
|
||||
$err = $e->getMessage();
|
||||
}
|
||||
}
|
||||
|
||||
function writeConfigValue($name, $val, &$str)
|
||||
{
|
||||
$val = str_replace("'", "\'", $val);
|
||||
$str = preg_replace('/(\'' . $name . '\')(.*?)$/ms', '$1,\'' . $val . '\');', $str);
|
||||
}
|
||||
|
||||
header('Content-Type: text/html; charset=UTF-8');
|
||||
|
||||
// Prevents Clickjacking as far as possible
|
||||
header('X-Frame-Options: SAMEORIGIN'); // FF 3.6.9+ Chrome 4.1+ IE 8+ Safari 4+ Opera 10.5+
|
||||
|
||||
?>
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8" />
|
||||
<meta http-equiv="Content-Script-Type" content="text/javascript" />
|
||||
<meta http-equiv="Content-Style-Type" content="text/css" />
|
||||
<meta http-equiv="Content-Language" content="en" />
|
||||
<meta name="ROBOTS" content="NOARCHIVE,NOINDEX,NOFOLLOW" />
|
||||
<meta name="GOOGLEBOT" content="NOSNIPPET" />
|
||||
<title><?php echo __('Dotclear installation wizard'); ?></title>
|
||||
<link rel="stylesheet" href="../style/install.css" type="text/css" media="screen" />
|
||||
</head>
|
||||
|
||||
<body id="dotclear-admin" class="install">
|
||||
<div id="content">
|
||||
<?php
|
||||
echo
|
||||
'<h1>' . __('Dotclear installation wizard') . '</h1>' .
|
||||
'<div id="main">';
|
||||
|
||||
if (!empty($err)) {
|
||||
echo '<div class="error" role="alert"><p><strong>' . __('Errors:') . '</strong></p>' . $err . '</div>';
|
||||
} else {
|
||||
echo '<h2>' . __('Welcome') . '</h2>' .
|
||||
'<p>' . __('To complete your Dotclear installation and start writing on your blog, ' .
|
||||
'we just need to know how to access your database and who you are. ' .
|
||||
'Just fill this two steps wizard with this information and we will be done.') . '</p>' .
|
||||
'<p class="message"><strong>' . __('Attention:') . '</strong> ' .
|
||||
__('this wizard may not function on every host. If it does not work for you, ' .
|
||||
'please refer to <a href="https://dotclear.org/documentation/2.0/admin/install">' .
|
||||
'the documentation</a> to learn how to create the <strong>config.php</strong> ' .
|
||||
'file manually.') . '</p>';
|
||||
}
|
||||
|
||||
echo
|
||||
'<h2>' . __('System information') . '</h2>' .
|
||||
|
||||
'<p>' . __('Please provide the following information needed to create your configuration file.') . '</p>' .
|
||||
|
||||
'<form action="wizard.php" method="post">' .
|
||||
'<p><label class="required" for="DBDRIVER"><abbr title="' . __('Required field') . '">*</abbr> ' . __('Database type:') . '</label> ' .
|
||||
form::combo('DBDRIVER', [
|
||||
__('MySQL (deprecated)') => 'mysql',
|
||||
__('MySQLi') => 'mysqli',
|
||||
__('MySQLi (full UTF-8)') => 'mysqlimb4',
|
||||
__('PostgreSQL') => 'pgsql',
|
||||
__('SQLite') => 'sqlite'],
|
||||
['default' => $DBDRIVER, 'extra_html' => 'required placeholder="' . __('Driver') . '"']) . '</p>' .
|
||||
'<p><label for="DBHOST">' . __('Database Host Name:') . '</label> ' .
|
||||
form::field('DBHOST', 30, 255, html::escapeHTML($DBHOST)) . '</p>' .
|
||||
'<p><label for="DBNAME">' . __('Database Name:') . '</label> ' .
|
||||
form::field('DBNAME', 30, 255, html::escapeHTML($DBNAME)) . '</p>' .
|
||||
'<p><label for="DBUSER">' . __('Database User Name:') . '</label> ' .
|
||||
form::field('DBUSER', 30, 255, html::escapeHTML($DBUSER)) . '</p>' .
|
||||
'<p><label for="DBPASSWORD">' . __('Database Password:') . '</label> ' .
|
||||
form::password('DBPASSWORD', 30, 255) . '</p>' .
|
||||
'<p><label for="DBPREFIX" class="required"><abbr title="' . __('Required field') . '">*</abbr> ' . __('Database Tables Prefix:') . '</label> ' .
|
||||
form::field('DBPREFIX', 30, 255, [
|
||||
'default' => html::escapeHTML($DBPREFIX),
|
||||
'extra_html' => 'required placeholder="' . __('Prefix') . '"'
|
||||
]) .
|
||||
'</p>' .
|
||||
'<p><label for="ADMINMAILFROM">' . __('Master Email: (used as sender for password recovery)') . '</label> ' .
|
||||
form::email('ADMINMAILFROM', [
|
||||
'size' => 30,
|
||||
'default' => html::escapeHTML($ADMINMAILFROM),
|
||||
'autocomplete' => 'email'
|
||||
]) .
|
||||
'</p>' .
|
||||
|
||||
'<p><input type="submit" value="' . __('Continue') . '" /></p>' .
|
||||
'</form>';
|
||||
?>
|
||||
</div>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
Reference in New Issue
Block a user