| 1 | <?php |
|---|
| 2 | // +-----------------------------------------------------------------------+ |
|---|
| 3 | // | Piwigo - a PHP based picture gallery | |
|---|
| 4 | // +-----------------------------------------------------------------------+ |
|---|
| 5 | // | Copyright(C) 2008-2009 Piwigo Team http://piwigo.org | |
|---|
| 6 | // | Copyright(C) 2003-2008 PhpWebGallery Team http://phpwebgallery.net | |
|---|
| 7 | // | Copyright(C) 2002-2003 Pierrick LE GALL http://le-gall.net/pierrick | |
|---|
| 8 | // +-----------------------------------------------------------------------+ |
|---|
| 9 | // | This program is free software; you can redistribute it and/or modify | |
|---|
| 10 | // | it under the terms of the GNU General Public License as published by | |
|---|
| 11 | // | the Free Software Foundation | |
|---|
| 12 | // | | |
|---|
| 13 | // | This program is distributed in the hope that it will be useful, but | |
|---|
| 14 | // | WITHOUT ANY WARRANTY; without even the implied warranty of | |
|---|
| 15 | // | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
|---|
| 16 | // | General Public License for more details. | |
|---|
| 17 | // | | |
|---|
| 18 | // | You should have received a copy of the GNU General Public License | |
|---|
| 19 | // | along with this program; if not, write to the Free Software | |
|---|
| 20 | // | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, | |
|---|
| 21 | // | USA. | |
|---|
| 22 | // +-----------------------------------------------------------------------+ |
|---|
| 23 | |
|---|
| 24 | //----------------------------------------------------------- include |
|---|
| 25 | define('PHPWG_ROOT_PATH','./'); |
|---|
| 26 | |
|---|
| 27 | include(PHPWG_ROOT_PATH . 'admin/include/functions_install.inc.php'); |
|---|
| 28 | |
|---|
| 29 | @set_magic_quotes_runtime(0); // Disable magic_quotes_runtime |
|---|
| 30 | // |
|---|
| 31 | // addslashes to vars if magic_quotes_gpc is off this is a security |
|---|
| 32 | // precaution to prevent someone trying to break out of a SQL statement. |
|---|
| 33 | // |
|---|
| 34 | if( !@get_magic_quotes_gpc() ) |
|---|
| 35 | { |
|---|
| 36 | if( is_array($_POST) ) |
|---|
| 37 | { |
|---|
| 38 | while( list($k, $v) = each($_POST) ) |
|---|
| 39 | { |
|---|
| 40 | if( is_array($_POST[$k]) ) |
|---|
| 41 | { |
|---|
| 42 | while( list($k2, $v2) = each($_POST[$k]) ) |
|---|
| 43 | { |
|---|
| 44 | $_POST[$k][$k2] = addslashes($v2); |
|---|
| 45 | } |
|---|
| 46 | @reset($_POST[$k]); |
|---|
| 47 | } |
|---|
| 48 | else |
|---|
| 49 | { |
|---|
| 50 | $_POST[$k] = addslashes($v); |
|---|
| 51 | } |
|---|
| 52 | } |
|---|
| 53 | @reset($_POST); |
|---|
| 54 | } |
|---|
| 55 | |
|---|
| 56 | if( is_array($_GET) ) |
|---|
| 57 | { |
|---|
| 58 | while( list($k, $v) = each($_GET) ) |
|---|
| 59 | { |
|---|
| 60 | if( is_array($_GET[$k]) ) |
|---|
| 61 | { |
|---|
| 62 | while( list($k2, $v2) = each($_GET[$k]) ) |
|---|
| 63 | { |
|---|
| 64 | $_GET[$k][$k2] = addslashes($v2); |
|---|
| 65 | } |
|---|
| 66 | @reset($_GET[$k]); |
|---|
| 67 | } |
|---|
| 68 | else |
|---|
| 69 | { |
|---|
| 70 | $_GET[$k] = addslashes($v); |
|---|
| 71 | } |
|---|
| 72 | } |
|---|
| 73 | @reset($_GET); |
|---|
| 74 | } |
|---|
| 75 | |
|---|
| 76 | if( is_array($_COOKIE) ) |
|---|
| 77 | { |
|---|
| 78 | while( list($k, $v) = each($_COOKIE) ) |
|---|
| 79 | { |
|---|
| 80 | if( is_array($_COOKIE[$k]) ) |
|---|
| 81 | { |
|---|
| 82 | while( list($k2, $v2) = each($_COOKIE[$k]) ) |
|---|
| 83 | { |
|---|
| 84 | $_COOKIE[$k][$k2] = addslashes($v2); |
|---|
| 85 | } |
|---|
| 86 | @reset($_COOKIE[$k]); |
|---|
| 87 | } |
|---|
| 88 | else |
|---|
| 89 | { |
|---|
| 90 | $_COOKIE[$k] = addslashes($v); |
|---|
| 91 | } |
|---|
| 92 | } |
|---|
| 93 | @reset($_COOKIE); |
|---|
| 94 | } |
|---|
| 95 | } |
|---|
| 96 | |
|---|
| 97 | //----------------------------------------------------- variable initialization |
|---|
| 98 | |
|---|
| 99 | define('DEFAULT_PREFIX_TABLE', 'piwigo_'); |
|---|
| 100 | |
|---|
| 101 | // Obtain various vars |
|---|
| 102 | $dbhost = (!empty($_POST['dbhost'])) ? $_POST['dbhost'] : 'localhost'; |
|---|
| 103 | $dbuser = (!empty($_POST['dbuser'])) ? $_POST['dbuser'] : ''; |
|---|
| 104 | $dbpasswd = (!empty($_POST['dbpasswd'])) ? $_POST['dbpasswd'] : ''; |
|---|
| 105 | $dbname = (!empty($_POST['dbname'])) ? $_POST['dbname'] : ''; |
|---|
| 106 | $dblayer = (!empty($_POST['dblayer'])) ? $_POST['dblayer'] : 'mysql'; |
|---|
| 107 | |
|---|
| 108 | if (isset($_POST['install'])) |
|---|
| 109 | { |
|---|
| 110 | $table_prefix = $_POST['prefix']; |
|---|
| 111 | } |
|---|
| 112 | else |
|---|
| 113 | { |
|---|
| 114 | $table_prefix = DEFAULT_PREFIX_TABLE; |
|---|
| 115 | } |
|---|
| 116 | |
|---|
| 117 | $admin_name = (!empty($_POST['admin_name'])) ? $_POST['admin_name'] : ''; |
|---|
| 118 | $admin_pass1 = (!empty($_POST['admin_pass1'])) ? $_POST['admin_pass1'] : ''; |
|---|
| 119 | $admin_pass2 = (!empty($_POST['admin_pass2'])) ? $_POST['admin_pass2'] : ''; |
|---|
| 120 | $admin_mail = (!empty($_POST['admin_mail'])) ? $_POST['admin_mail'] : ''; |
|---|
| 121 | |
|---|
| 122 | $infos = array(); |
|---|
| 123 | $errors = array(); |
|---|
| 124 | |
|---|
| 125 | // database config file migration : mysql.inc.php et config_database.inc.php |
|---|
| 126 | $old_config_file = PHPWG_ROOT_PATH . 'include/mysql.inc.php'; |
|---|
| 127 | $config_file = PHPWG_ROOT_PATH . 'include/config_database.inc.php'; |
|---|
| 128 | if (!file_exists($config_file) && file_exists($old_config_file)) |
|---|
| 129 | { |
|---|
| 130 | $step = 3; |
|---|
| 131 | include $old_config_file; |
|---|
| 132 | $file_content = '<?php |
|---|
| 133 | $conf[\'dblayer\'] = \'mysql\'; |
|---|
| 134 | $conf[\'db_base\'] = \''.$cfgBase.'\'; |
|---|
| 135 | $conf[\'db_user\'] = \''.$cfgUser.'\'; |
|---|
| 136 | $conf[\'db_password\'] = \''.$cfgPassword.'\'; |
|---|
| 137 | $conf[\'db_host\'] = \''.$cfgHote.'\'; |
|---|
| 138 | |
|---|
| 139 | $prefixeTable = \''.$prefixeTable.'\'; |
|---|
| 140 | |
|---|
| 141 | define(\'PHPWG_INSTALLED\', true); |
|---|
| 142 | define(\'PWG_CHARSET\', \''.PWG_CHARSET.'\'); |
|---|
| 143 | define(\'DB_CHARSET\', \''.DB_CHARSET.'\'); |
|---|
| 144 | define(\'DB_COLLATE\', \''.DB_COLLATE.'\'); |
|---|
| 145 | |
|---|
| 146 | ?'.'>'; |
|---|
| 147 | } |
|---|
| 148 | // Open config.php ... if it exists |
|---|
| 149 | elseif (@file_exists($config_file)) |
|---|
| 150 | { |
|---|
| 151 | include($config_file); |
|---|
| 152 | // Is Piwigo already installed ? |
|---|
| 153 | if (defined("PHPWG_INSTALLED")) |
|---|
| 154 | { |
|---|
| 155 | die('Piwigo is already installed'); |
|---|
| 156 | } |
|---|
| 157 | } |
|---|
| 158 | |
|---|
| 159 | $prefixeTable = $table_prefix; |
|---|
| 160 | include(PHPWG_ROOT_PATH . 'include/config_default.inc.php'); |
|---|
| 161 | @include(PHPWG_ROOT_PATH. 'include/config_local.inc.php'); |
|---|
| 162 | include(PHPWG_ROOT_PATH .'include/dblayer/functions_'.$dblayer.'.inc.php'); |
|---|
| 163 | include(PHPWG_ROOT_PATH . 'include/constants.php'); |
|---|
| 164 | include(PHPWG_ROOT_PATH . 'include/functions.inc.php'); |
|---|
| 165 | include(PHPWG_ROOT_PATH . 'admin/include/functions.php'); |
|---|
| 166 | include(PHPWG_ROOT_PATH . 'admin/include/functions_upgrade.php'); |
|---|
| 167 | |
|---|
| 168 | if (isset($_GET['language'])) |
|---|
| 169 | { |
|---|
| 170 | $language = strip_tags($_GET['language']); |
|---|
| 171 | } |
|---|
| 172 | else |
|---|
| 173 | { |
|---|
| 174 | $language = 'en_UK'; |
|---|
| 175 | // Try to get browser language |
|---|
| 176 | foreach (get_languages('utf-8') as $language_code => $language_name) |
|---|
| 177 | { |
|---|
| 178 | if (substr($language_code,0,2) == @substr($_SERVER["HTTP_ACCEPT_LANGUAGE"],0,2)) |
|---|
| 179 | { |
|---|
| 180 | $language = $language_code; |
|---|
| 181 | break; |
|---|
| 182 | } |
|---|
| 183 | } |
|---|
| 184 | } |
|---|
| 185 | |
|---|
| 186 | if ('fr_FR' == $language) { |
|---|
| 187 | define('PHPWG_DOMAIN', 'fr.piwigo.org'); |
|---|
| 188 | } |
|---|
| 189 | else if ('de_DE' == $language) { |
|---|
| 190 | define('PHPWG_DOMAIN', 'de.piwigo.org'); |
|---|
| 191 | } |
|---|
| 192 | else if ('es_ES' == $language) { |
|---|
| 193 | define('PHPWG_DOMAIN', 'es.piwigo.org'); |
|---|
| 194 | } |
|---|
| 195 | else { |
|---|
| 196 | define('PHPWG_DOMAIN', 'piwigo.org'); |
|---|
| 197 | } |
|---|
| 198 | define('PHPWG_URL', 'http://'.PHPWG_DOMAIN); |
|---|
| 199 | |
|---|
| 200 | if (empty($step) || ($step != 3)) |
|---|
| 201 | { |
|---|
| 202 | load_language('common.lang', '', array('language' => $language, 'target_charset'=>'utf-8')); |
|---|
| 203 | load_language('admin.lang', '', array('language' => $language, 'target_charset'=>'utf-8')); |
|---|
| 204 | load_language('install.lang', '', array('language' => $language, 'target_charset'=>'utf-8')); |
|---|
| 205 | } |
|---|
| 206 | header('Content-Type: text/html; charset=UTF-8'); |
|---|
| 207 | //------------------------------------------------- check php version |
|---|
| 208 | if (version_compare(PHP_VERSION, REQUIRED_PHP_VERSION, '<')) |
|---|
| 209 | { |
|---|
| 210 | include(PHPWG_ROOT_PATH.'install/php5_apache_configuration.php'); |
|---|
| 211 | } |
|---|
| 212 | |
|---|
| 213 | //----------------------------------------------------- template initialization |
|---|
| 214 | include( PHPWG_ROOT_PATH .'include/template.class.php'); |
|---|
| 215 | $template = new Template(PHPWG_ROOT_PATH.'admin/template/goto', 'roma'); |
|---|
| 216 | $template->set_filenames( array('install' => 'install.tpl') ); |
|---|
| 217 | if (!isset($step)) |
|---|
| 218 | { |
|---|
| 219 | $step = 1; |
|---|
| 220 | } |
|---|
| 221 | //---------------------------------------------------------------- form analyze |
|---|
| 222 | if ( isset( $_POST['install'] )) |
|---|
| 223 | { |
|---|
| 224 | if (($pwg_db_link = pwg_db_connect($_POST['dbhost'], $_POST['dbuser'], |
|---|
| 225 | $_POST['dbpasswd'], $_POST['dbname']))!==false) |
|---|
| 226 | { |
|---|
| 227 | |
|---|
| 228 | array_push( $infos, l10n('step1_confirmation') ); |
|---|
| 229 | |
|---|
| 230 | $required_version = constant('REQUIRED_'.strtoupper($dblayer).'_VERSION'); |
|---|
| 231 | if ( version_compare(pwg_get_db_version(), $required_version, '>=') ) |
|---|
| 232 | { |
|---|
| 233 | $pwg_charset = 'utf-8'; |
|---|
| 234 | $pwg_db_charset = 'utf8'; |
|---|
| 235 | if ($dblayer=='mysql') |
|---|
| 236 | { |
|---|
| 237 | $install_charset_collate = "DEFAULT CHARACTER SET $pwg_db_charset"; |
|---|
| 238 | } |
|---|
| 239 | else |
|---|
| 240 | { |
|---|
| 241 | $install_charset_collate = ''; |
|---|
| 242 | } |
|---|
| 243 | } |
|---|
| 244 | else |
|---|
| 245 | { |
|---|
| 246 | $pwg_charset = 'iso-8859-1'; |
|---|
| 247 | $pwg_db_charset = 'latin1'; |
|---|
| 248 | $install_charset_collate = ''; |
|---|
| 249 | if ( !array_key_exists($language, get_languages($pwg_charset) ) ) |
|---|
| 250 | { |
|---|
| 251 | $language='en_UK'; |
|---|
| 252 | } |
|---|
| 253 | } |
|---|
| 254 | } |
|---|
| 255 | else |
|---|
| 256 | { |
|---|
| 257 | array_push( $errors, l10n('step1_err_server') ); |
|---|
| 258 | } |
|---|
| 259 | |
|---|
| 260 | $webmaster = trim(preg_replace( '/\s{2,}/', ' ', $admin_name )); |
|---|
| 261 | if ( empty($webmaster)) |
|---|
| 262 | array_push( $errors, l10n('step2_err_login1') ); |
|---|
| 263 | else if ( preg_match( '/[\'"]/', $webmaster ) ) |
|---|
| 264 | array_push( $errors, l10n('step2_err_login3') ); |
|---|
| 265 | if ( $admin_pass1 != $admin_pass2 || empty($admin_pass1) ) |
|---|
| 266 | array_push( $errors, l10n('step2_err_pass') ); |
|---|
| 267 | if ( empty($admin_mail)) |
|---|
| 268 | array_push( $errors, l10n('reg_err_mail_address') ); |
|---|
| 269 | else |
|---|
| 270 | { |
|---|
| 271 | $error_mail_address = validate_mail_address(null, $admin_mail); |
|---|
| 272 | if (!empty($error_mail_address)) |
|---|
| 273 | array_push( $errors, $error_mail_address ); |
|---|
| 274 | } |
|---|
| 275 | |
|---|
| 276 | if ( count( $errors ) == 0 ) |
|---|
| 277 | { |
|---|
| 278 | $step = 2; |
|---|
| 279 | $file_content = '<?php |
|---|
| 280 | $conf[\'dblayer\'] = \''.$dblayer.'\'; |
|---|
| 281 | $conf[\'db_base\'] = \''.$dbname.'\'; |
|---|
| 282 | $conf[\'db_user\'] = \''.$dbuser.'\'; |
|---|
| 283 | $conf[\'db_password\'] = \''.$dbpasswd.'\'; |
|---|
| 284 | $conf[\'db_host\'] = \''.$dbhost.'\'; |
|---|
| 285 | |
|---|
| 286 | $prefixeTable = \''.$table_prefix.'\'; |
|---|
| 287 | |
|---|
| 288 | define(\'PHPWG_INSTALLED\', true); |
|---|
| 289 | define(\'PWG_CHARSET\', \''.$pwg_charset.'\'); |
|---|
| 290 | define(\'DB_CHARSET\', \''.$pwg_db_charset.'\'); |
|---|
| 291 | define(\'DB_COLLATE\', \'\'); |
|---|
| 292 | |
|---|
| 293 | ?'.'>'; |
|---|
| 294 | |
|---|
| 295 | @umask(0111); |
|---|
| 296 | // writing the configuration file |
|---|
| 297 | if ( !($fp = @fopen( $config_file, 'w' ))) |
|---|
| 298 | { |
|---|
| 299 | $html_content = htmlentities( $file_content, ENT_QUOTES ); |
|---|
| 300 | $html_content = nl2br( $html_content ); |
|---|
| 301 | $error_copy = l10n('step1_err_copy'); |
|---|
| 302 | $error_copy .= '<br>--------------------------------------------------------------------<br>'; |
|---|
| 303 | $error_copy .= '<span class="sql_content">' . $html_content . '</span>'; |
|---|
| 304 | $error_copy .= '<br>--------------------------------------------------------------------<br>'; |
|---|
| 305 | } |
|---|
| 306 | @fputs($fp, $file_content, strlen($file_content)); |
|---|
| 307 | @fclose($fp); |
|---|
| 308 | |
|---|
| 309 | // Create empty local files to avoid log errors |
|---|
| 310 | create_empty_local_files(); |
|---|
| 311 | |
|---|
| 312 | // tables creation, based on piwigo_structure.sql |
|---|
| 313 | execute_sqlfile( |
|---|
| 314 | PHPWG_ROOT_PATH.'install/piwigo_structure-'.$dblayer.'.sql', |
|---|
| 315 | DEFAULT_PREFIX_TABLE, |
|---|
| 316 | $table_prefix |
|---|
| 317 | ); |
|---|
| 318 | // We fill the tables with basic informations |
|---|
| 319 | execute_sqlfile( |
|---|
| 320 | PHPWG_ROOT_PATH.'install/config.sql', |
|---|
| 321 | DEFAULT_PREFIX_TABLE, |
|---|
| 322 | $table_prefix |
|---|
| 323 | ); |
|---|
| 324 | |
|---|
| 325 | $query = ' |
|---|
| 326 | INSERT INTO piwigo_config (param,value,comment) |
|---|
| 327 | VALUES (\'secret_key\',\'md5('.pwg_db_cast_to_text(DB_RANDOM_FUNCTION.'()').')\', |
|---|
| 328 | \'a secret key specific to the gallery for internal use\');'; |
|---|
| 329 | pwg_query($query); |
|---|
| 330 | |
|---|
| 331 | // fill $conf global array |
|---|
| 332 | load_conf_from_db(); |
|---|
| 333 | |
|---|
| 334 | $insert = array( |
|---|
| 335 | 'id' => 1, |
|---|
| 336 | 'galleries_url' => PHPWG_ROOT_PATH.'galleries/', |
|---|
| 337 | ); |
|---|
| 338 | mass_inserts(SITES_TABLE, array_keys($insert), array($insert)); |
|---|
| 339 | |
|---|
| 340 | // webmaster admin user |
|---|
| 341 | $inserts = array( |
|---|
| 342 | array( |
|---|
| 343 | 'id' => 1, |
|---|
| 344 | 'username' => $admin_name, |
|---|
| 345 | 'password' => md5($admin_pass1), |
|---|
| 346 | 'mail_address' => $admin_mail, |
|---|
| 347 | ), |
|---|
| 348 | array( |
|---|
| 349 | 'id' => 2, |
|---|
| 350 | 'username' => 'guest', |
|---|
| 351 | ), |
|---|
| 352 | ); |
|---|
| 353 | mass_inserts(USERS_TABLE, array_keys($inserts[0]), $inserts); |
|---|
| 354 | |
|---|
| 355 | create_user_infos(array(1,2), array('language' => $language)); |
|---|
| 356 | |
|---|
| 357 | // Available upgrades must be ignored after a fresh installation. To |
|---|
| 358 | // make PWG avoid upgrading, we must tell it upgrades have already been |
|---|
| 359 | // made. |
|---|
| 360 | list($dbnow) = pwg_db_fetch_row(pwg_query('SELECT NOW();')); |
|---|
| 361 | define('CURRENT_DATE', $dbnow); |
|---|
| 362 | $datas = array(); |
|---|
| 363 | foreach (get_available_upgrade_ids() as $upgrade_id) |
|---|
| 364 | { |
|---|
| 365 | array_push( |
|---|
| 366 | $datas, |
|---|
| 367 | array( |
|---|
| 368 | 'id' => $upgrade_id, |
|---|
| 369 | 'applied' => CURRENT_DATE, |
|---|
| 370 | 'description' => 'upgrade included in installation', |
|---|
| 371 | ) |
|---|
| 372 | ); |
|---|
| 373 | } |
|---|
| 374 | mass_inserts( |
|---|
| 375 | UPGRADE_TABLE, |
|---|
| 376 | array_keys($datas[0]), |
|---|
| 377 | $datas |
|---|
| 378 | ); |
|---|
| 379 | } |
|---|
| 380 | } |
|---|
| 381 | |
|---|
| 382 | //------------------------------------------------------ start template output |
|---|
| 383 | if ($step == 3) |
|---|
| 384 | { |
|---|
| 385 | @umask(0111); |
|---|
| 386 | // writing the new configuration file |
|---|
| 387 | if ( !($fp = @fopen( $config_file, 'w' ))) |
|---|
| 388 | { |
|---|
| 389 | $html_content = htmlentities( $file_content, ENT_QUOTES ); |
|---|
| 390 | $html_content = nl2br( $html_content ); |
|---|
| 391 | $error_copy = l10n('Copy the text in pink between hyphens and paste it into the file "include/config_database.inc.php"(Warning : config_database.inc.php must only contain what is in pink, no line return or space character)'); |
|---|
| 392 | $error_copy .= '<br>--------------------------------------------------------------------<br>'; |
|---|
| 393 | $error_copy .= '<span class="sql_content">' . $html_content . '</span>'; |
|---|
| 394 | $error_copy .= '<br>--------------------------------------------------------------------<br>'; |
|---|
| 395 | } |
|---|
| 396 | else |
|---|
| 397 | { |
|---|
| 398 | @fputs($fp, $file_content, strlen($file_content)); |
|---|
| 399 | @fclose($fp); |
|---|
| 400 | |
|---|
| 401 | @unlink($old_config_file); |
|---|
| 402 | header("Location: index.php"); |
|---|
| 403 | exit(); |
|---|
| 404 | } |
|---|
| 405 | |
|---|
| 406 | $template->assign( |
|---|
| 407 | array( |
|---|
| 408 | 'T_CONTENT_ENCODING' => 'utf-8', |
|---|
| 409 | 'migration' => true |
|---|
| 410 | )); |
|---|
| 411 | } |
|---|
| 412 | else |
|---|
| 413 | { |
|---|
| 414 | $dbengines = available_engines(); |
|---|
| 415 | |
|---|
| 416 | foreach (get_languages('utf-8') as $language_code => $language_name) |
|---|
| 417 | { |
|---|
| 418 | if ($language == $language_code) |
|---|
| 419 | { |
|---|
| 420 | $template->assign('language_selection', $language_code); |
|---|
| 421 | } |
|---|
| 422 | $languages_options[$language_code] = $language_name; |
|---|
| 423 | } |
|---|
| 424 | $template->assign('language_options', $languages_options); |
|---|
| 425 | |
|---|
| 426 | $template->assign( |
|---|
| 427 | array( |
|---|
| 428 | 'T_CONTENT_ENCODING' => 'utf-8', |
|---|
| 429 | 'RELEASE' => PHPWG_VERSION, |
|---|
| 430 | 'F_ACTION' => 'install.php?language=' . $language, |
|---|
| 431 | 'F_DB_ENGINES' => $dbengines, |
|---|
| 432 | 'F_DB_LAYER' => $dblayer, |
|---|
| 433 | 'F_DB_HOST' => $dbhost, |
|---|
| 434 | 'F_DB_USER' => $dbuser, |
|---|
| 435 | 'F_DB_NAME' => $dbname, |
|---|
| 436 | 'F_DB_PREFIX' => $table_prefix, |
|---|
| 437 | 'F_ADMIN' => $admin_name, |
|---|
| 438 | 'F_ADMIN_EMAIL' => $admin_mail, |
|---|
| 439 | 'L_INSTALL_HELP' => sprintf(l10n('install_help'), PHPWG_URL.'/forum'), |
|---|
| 440 | )); |
|---|
| 441 | } |
|---|
| 442 | |
|---|
| 443 | //------------------------------------------------------ errors & infos display |
|---|
| 444 | if ($step == 1) |
|---|
| 445 | { |
|---|
| 446 | $template->assign('install', true); |
|---|
| 447 | } |
|---|
| 448 | elseif ($step == 3) |
|---|
| 449 | { |
|---|
| 450 | if (isset($error_copy)) |
|---|
| 451 | { |
|---|
| 452 | array_push($errors, $error_copy); |
|---|
| 453 | } |
|---|
| 454 | } |
|---|
| 455 | else |
|---|
| 456 | { |
|---|
| 457 | array_push($infos, l10n('install_end_message')); |
|---|
| 458 | |
|---|
| 459 | if (isset($error_copy)) |
|---|
| 460 | { |
|---|
| 461 | array_push($errors, $error_copy); |
|---|
| 462 | } |
|---|
| 463 | else |
|---|
| 464 | { |
|---|
| 465 | session_set_save_handler('pwg_session_open', |
|---|
| 466 | 'pwg_session_close', |
|---|
| 467 | 'pwg_session_read', |
|---|
| 468 | 'pwg_session_write', |
|---|
| 469 | 'pwg_session_destroy', |
|---|
| 470 | 'pwg_session_gc' |
|---|
| 471 | ); |
|---|
| 472 | if ( function_exists('ini_set') ) |
|---|
| 473 | { |
|---|
| 474 | ini_set('session.use_cookies', $conf['session_use_cookies']); |
|---|
| 475 | ini_set('session.use_only_cookies', $conf['session_use_only_cookies']); |
|---|
| 476 | ini_set('session.use_trans_sid', intval($conf['session_use_trans_sid'])); |
|---|
| 477 | ini_set('session.cookie_httponly', 1); |
|---|
| 478 | } |
|---|
| 479 | session_name($conf['session_name']); |
|---|
| 480 | session_set_cookie_params(0, cookie_path()); |
|---|
| 481 | $user = build_user(1, true); |
|---|
| 482 | log_user($user['id'], false); |
|---|
| 483 | } |
|---|
| 484 | |
|---|
| 485 | $template->assign( |
|---|
| 486 | 'SUBSCRIBE_BASE_URL', |
|---|
| 487 | get_newsletter_subscribe_base_url($language) |
|---|
| 488 | ); |
|---|
| 489 | } |
|---|
| 490 | if (count($errors) != 0) |
|---|
| 491 | { |
|---|
| 492 | $template->assign('errors', $errors); |
|---|
| 493 | } |
|---|
| 494 | |
|---|
| 495 | if (count($infos) != 0 ) |
|---|
| 496 | { |
|---|
| 497 | $template->assign('infos', $infos); |
|---|
| 498 | } |
|---|
| 499 | |
|---|
| 500 | //----------------------------------------------------------- html code display |
|---|
| 501 | $template->pparse('install'); |
|---|
| 502 | ?> |
|---|