| [ Index ] |
|
Code source de Dotclear 2.0-beta6 |
1 <?php 2 # ***** BEGIN LICENSE BLOCK ***** 3 # This file is part of DotClear. 4 # Copyright (c) 2005 Olivier Meunier and contributors. All rights 5 # reserved. 6 # 7 # DotClear is free software; you can redistribute it and/or modify 8 # it under the terms of the GNU General Public License as published by 9 # the Free Software Foundation; either version 2 of the License, or 10 # (at your option) any later version. 11 # 12 # DotClear is distributed in the hope that it will be useful, 13 # but WITHOUT ANY WARRANTY; without even the implied warranty of 14 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 # GNU General Public License for more details. 16 # 17 # You should have received a copy of the GNU General Public License 18 # along with DotClear; if not, write to the Free Software 19 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 20 # 21 # ***** END LICENSE BLOCK ***** 22 23 if (isset($_SERVER['DC_RC_PATH'])) { 24 $rc_path = $_SERVER['DC_RC_PATH']; 25 } elseif (isset($_SERVER['REDIRECT_DC_RC_PATH'])) { 26 $rc_path = $_SERVER['REDIRECT_DC_RC_PATH']; 27 } else { 28 $rc_path = dirname(__FILE__).'/../../inc/config.php'; 29 } 30 31 if (!is_file($rc_path)) { 32 printf('Configuration file does not exist. Please create one 33 first. You may use the <a href="%s">wizard</a>.','wizard.php'); 34 exit; 35 } 36 37 require dirname(__FILE__).'/../../inc/prepend.php'; 38 require dirname(__FILE__).'/check.php'; 39 40 $can_install = true; 41 $err = ''; 42 43 # Loading locales for detected language 44 $dlang = http::getAcceptLanguage(); 45 if ($dlang) { 46 l10n::init(); 47 l10n::set(dirname(__FILE__).'/../../locales/'.$dlang.'/main'); 48 } 49 50 if (!defined('DC_MASTER_KEY') || DC_MASTER_KEY == '') { 51 $can_install = false; 52 $err = '<p>'.__('Please set a master key (DC_MASTER_KEY) in configuration file.').'</p>'; 53 } 54 55 # Check if dotclear is already installed 56 if (in_array($core->prefix.'version',$core->con->getTables())) { 57 $can_install = false; 58 $err = '<p>'.__('DotClear is already installed.').'</p>'; 59 } 60 61 # Check system capabilites 62 if (!dcSystemCheck($core->con,$_e)) { 63 $can_install = false; 64 $err = '<p>'.__('DotClear cannot be installed.').'</p><ul><li>'.implode('</li><li>',$_e).'</li></ul>'; 65 } 66 67 # Get information and perform install 68 $u_email = $u_firstname = $u_name= ''; 69 $mail_sent = false; 70 if ($can_install && !empty($_POST)) 71 { 72 $u_email = !empty($_POST['u_email']) ? $_POST['u_email'] : null; 73 $u_firstname = !empty($_POST['u_firstname']) ? $_POST['u_firstname'] : null; 74 $u_name = !empty($_POST['u_name']) ? $_POST['u_name'] : null; 75 76 try 77 { 78 if (empty($u_email)) { 79 throw new Exception(__('No email')); 80 } 81 if (!text::isEmail($u_email)) { 82 throw new Exception(__('Invalid email address')); 83 } 84 85 $db_file = dirname(__FILE__).'/../../inc/dbschema/create-'.DC_DBDRIVER.'.xml'; 86 87 if (!is_file($db_file)) { 88 throw new Exception(__('Database loading file not found.')); 89 } 90 91 $xml = file_get_contents($db_file); 92 93 $xmlsql = new xmlsql($core->con,$xml); 94 $xmlsql->replace('{{PREFIX}}',$core->prefix); 95 96 97 $xmlsql->execute(); 98 99 $user_pwd = crypt::createPassword(); 100 101 $cur = $core->con->openCursor($core->prefix.'user'); 102 $cur->user_id = 'admin'; 103 $cur->user_super = 1; 104 $cur->user_pwd = crypt::hmac(DC_MASTER_KEY,$user_pwd); 105 $cur->user_name = (string) $u_name; 106 $cur->user_firstname = (string) $u_firstname; 107 $cur->user_email = (string) $u_email; 108 $cur->user_lang = $dlang; 109 $cur->user_creadt = array('NOW()'); 110 $cur->user_upddt = array('NOW()'); 111 $cur->user_options = serialize($core->userDefaults()); 112 $cur->insert(); 113 114 $core->auth->checkUser('admin'); 115 116 $admin_url = preg_replace('%install/index.php$%','',$_SERVER['REQUEST_URI']); 117 $root_url = preg_replace('%/admin/install/index.php$%','',$_SERVER['REQUEST_URI']); 118 119 $cur = $core->con->openCursor($core->prefix.'blog'); 120 $cur->blog_id = 'default'; 121 $cur->blog_url = http::getHost().$root_url.'/index.php?'; 122 $cur->blog_name = __('My first blog'); 123 $core->addBlog($cur); 124 $core->blogDefaults($cur->blog_id); 125 126 $blog_settings = new dcSettings($core,'default'); 127 $blog_settings->setNameSpace('system'); 128 $blog_settings->put('lang',$dlang); 129 $blog_settings->put('public_url',$root_url.'/public'); 130 $blog_settings->put('themes_url',$root_url.'/themes'); 131 132 $cur = $core->con->openCursor($core->prefix.'version'); 133 $cur->module = 'core'; 134 $cur->version = (string) DC_VERSION; 135 $cur->insert(); 136 137 $subject = mb_encode_mimeheader('DotClear '.__('successfully installed'),'UTF-8','B'); 138 139 $message = 140 __('Your new DotClear blog has been successfully set up at:')."\n\n". 141 http::getHost().$admin_url."\n\n". 142 143 __('You can log in to the administrator account with the following information:')."\n\n". 144 145 __('Username:')." admin\n". 146 __('Password:').' '.$user_pwd."\n\n". 147 148 __('We hope you enjoy your new weblog. Thanks!')."\n\n". 149 150 "--\n". 151 "The DotClear Team\n". 152 "http://www.dotclear.net/"; 153 154 $headers[] = 'From: dotclear@'.$_SERVER['HTTP_HOST']; 155 $headers[] = 'Content-Type: text/plain; charset=UTF-8;'; 156 157 try { 158 mail::sendMail($u_email,$subject,$message,$headers); 159 $mail_sent = true; 160 } catch (Exception $e) { } 161 162 $step = 1; 163 } 164 catch (Exception $e) 165 { 166 $err = $e->getMessage(); 167 } 168 } 169 170 if (!isset($step)) { 171 $step = 0; 172 } 173 header('Content-Type: text/html; charset=UTF-8'); 174 ?> 175 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> 176 <html xmlns="http://www.w3.org/1999/xhtml" 177 xml:lang="en" lang="en"> 178 <head> 179 <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> 180 <meta http-equiv="Content-Script-Type" content="text/javascript" /> 181 <meta http-equiv="Content-Style-Type" content="text/css" /> 182 <meta http-equiv="Content-Language" content="en" /> 183 <meta name="MSSmartTagsPreventParsing" content="TRUE" /> 184 <meta name="ROBOTS" content="NOARCHIVE,NOINDEX,NOFOLLOW" /> 185 <meta name="GOOGLEBOT" content="NOSNIPPET" /> 186 <title>DotClear Install</title> 187 188 <style type="text/css"> 189 @import url(../style/default.css); 190 </style> 191 </head> 192 193 <body id="dotclear-admin" class="install"> 194 <div id="content"> 195 <?php 196 echo 197 '<h1>'.__('Dotclear installation').'</h1>'; 198 199 if (!is_writable(DC_TPL_CACHE)) { 200 echo '<div class="error"><p>'.sprintf(__('Cache directory %s is not writable.'),DC_TPL_CACHE).'</p></div>'; 201 } 202 203 if (!empty($err)) { 204 echo '<div class="error"><p><strong>'.__('Errors:').'</strong></p>'.$err.'</div>'; 205 } 206 207 if (!empty($_GET['wiz'])) { 208 echo '<p class="message">'.__('Confirugration file has been successfully created.').'</p>'; 209 } 210 211 if ($can_install && $step == 0) 212 { 213 echo 214 '<h2>'.__('User information').'</h2>'. 215 216 '<p>'.__('Please provide the following information needed to create the first user.').'</p>'. 217 218 '<form action="index.php" method="post">'. 219 '<p><label class="required" title="'.__('Required field').'">'.__('Email:').' '. 220 form::field('u_email',20,255,html::escapeHTML($u_email)).'</label></p>'. 221 '<p><label>'.__('Firstname:').' '. 222 form::field('u_firstname',20,255,html::escapeHTML($u_firstname)).'</label></p>'. 223 '<p><label>'.__('Name:').' '. 224 form::field('u_name',20,255,html::escapeHTML($u_name)).'</label></p>'. 225 '<p><input type="submit" value="'.__('save').'" /></p>'. 226 '</form>'; 227 } 228 elseif ($can_install && $step == 1) 229 { 230 echo 231 '<h2>'.__('All done!').'</h2>'. 232 233 '<p>'.sprintf(__('Now you can <a href="%s">log in</a> with the following information:'), 234 '../auth.php').'</p>'. 235 '<ul>'. 236 '<li>'.__('Login:').' <strong>admin</strong></li>'. 237 '<li>'.__('Password:').' <strong>'.$user_pwd.'</strong></li>'. 238 '</ul>'; 239 240 if ($mail_sent) { 241 echo 242 '<p>'.sprintf(__('A password reminder was sent to %s. You\'ll be able to change it once you\'re logged in.'), 243 $u_email).'</p>'; 244 } 245 } 246 ?> 247 </div> 248 </body> 249 </html>
titre
Description
Corps
titre
Description
Corps
titre
Description
Corps
titre
Corps
| Généré le : Fri Feb 23 22:16:06 2007 | par Balluche grâce à PHPXref 0.7 |