| 1 | <?php |
|---|
| 2 | // +-----------------------------------------------------------------------+ |
|---|
| 3 | // | Piwigo - a PHP based photo gallery | |
|---|
| 4 | // +-----------------------------------------------------------------------+ |
|---|
| 5 | // | Copyright(C) 2008-2011 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 | @set_magic_quotes_runtime(0); // Disable magic_quotes_runtime |
|---|
| 28 | // |
|---|
| 29 | // addslashes to vars if magic_quotes_gpc is off this is a security |
|---|
| 30 | // precaution to prevent someone trying to break out of a SQL statement. |
|---|
| 31 | // |
|---|
| 32 | if( !@get_magic_quotes_gpc() ) |
|---|
| 33 | { |
|---|
| 34 | if( is_array($_POST) ) |
|---|
| 35 | { |
|---|
| 36 | while( list($k, $v) = each($_POST) ) |
|---|
| 37 | { |
|---|
| 38 | if( is_array($_POST[$k]) ) |
|---|
| 39 | { |
|---|
| 40 | while( list($k2, $v2) = each($_POST[$k]) ) |
|---|
| 41 | { |
|---|
| 42 | $_POST[$k][$k2] = addslashes($v2); |
|---|
| 43 | } |
|---|
| 44 | @reset($_POST[$k]); |
|---|
| 45 | } |
|---|
| 46 | else |
|---|
| 47 | { |
|---|
| 48 | $_POST[$k] = addslashes($v); |
|---|
| 49 | } |
|---|
| 50 | } |
|---|
| 51 | @reset($_POST); |
|---|
| 52 | } |
|---|
| 53 | |
|---|
| 54 | if( is_array($_GET) ) |
|---|
| 55 | { |
|---|
| 56 | while( list($k, $v) = each($_GET) ) |
|---|
| 57 | { |
|---|
| 58 | if( is_array($_GET[$k]) ) |
|---|
| 59 | { |
|---|
| 60 | while( list($k2, $v2) = each($_GET[$k]) ) |
|---|
| 61 | { |
|---|
| 62 | $_GET[$k][$k2] = addslashes($v2); |
|---|
| 63 | } |
|---|
| 64 | @reset($_GET[$k]); |
|---|
| 65 | } |
|---|
| 66 | else |
|---|
| 67 | { |
|---|
| 68 | $_GET[$k] = addslashes($v); |
|---|
| 69 | } |
|---|
| 70 | } |
|---|
| 71 | @reset($_GET); |
|---|
| 72 | } |
|---|
| 73 | |
|---|
| 74 | if( is_array($_COOKIE) ) |
|---|
| 75 | { |
|---|
| 76 | while( list($k, $v) = each($_COOKIE) ) |
|---|
| 77 | { |
|---|
| 78 | if( is_array($_COOKIE[$k]) ) |
|---|
| 79 | { |
|---|
| 80 | while( list($k2, $v2) = each($_COOKIE[$k]) ) |
|---|
| 81 | { |
|---|
| 82 | $_COOKIE[$k][$k2] = addslashes($v2); |
|---|
| 83 | } |
|---|
| 84 | @reset($_COOKIE[$k]); |
|---|
| 85 | } |
|---|
| 86 | else |
|---|
| 87 | { |
|---|
| 88 | $_COOKIE[$k] = addslashes($v); |
|---|
| 89 | } |
|---|
| 90 | } |
|---|
| 91 | @reset($_COOKIE); |
|---|
| 92 | } |
|---|
| 93 | } |
|---|
| 94 | |
|---|
| 95 | //----------------------------------------------------- variable initialization |
|---|
| 96 | |
|---|
| 97 | define('DEFAULT_PREFIX_TABLE', 'piwigo_'); |
|---|
| 98 | |
|---|
| 99 | if (isset($_POST['install'])) |
|---|
| 100 | { |
|---|
| 101 | $prefixeTable = $_POST['prefix']; |
|---|
| 102 | } |
|---|
| 103 | else |
|---|
| 104 | { |
|---|
| 105 | $prefixeTable = DEFAULT_PREFIX_TABLE; |
|---|
| 106 | } |
|---|
| 107 | |
|---|
| 108 | include(PHPWG_ROOT_PATH . 'include/config_default.inc.php'); |
|---|
| 109 | @include(PHPWG_ROOT_PATH. 'local/config/config.inc.php'); |
|---|
| 110 | defined('PWG_LOCAL_DIR') or define('PWG_LOCAL_DIR', 'local/'); |
|---|
| 111 | |
|---|
| 112 | // download database config file if exists |
|---|
| 113 | if (!empty($_GET['dl']) && file_exists(PHPWG_ROOT_PATH.$conf['data_location'].'pwg_'.$_GET['dl'])) |
|---|
| 114 | { |
|---|
| 115 | $filename = PHPWG_ROOT_PATH.$conf['data_location'].'pwg_'.$_GET['dl']; |
|---|
| 116 | header('Cache-Control: no-cache, must-revalidate'); |
|---|
| 117 | header('Pragma: no-cache'); |
|---|
| 118 | header('Content-Disposition: attachment; filename="database.inc.php"'); |
|---|
| 119 | header('Content-Transfer-Encoding: binary'); |
|---|
| 120 | header('Content-Length: '.filesize($filename)); |
|---|
| 121 | echo file_get_contents($filename); |
|---|
| 122 | unlink($filename); |
|---|
| 123 | exit(); |
|---|
| 124 | } |
|---|
| 125 | |
|---|
| 126 | // Obtain various vars |
|---|
| 127 | $dbhost = (!empty($_POST['dbhost'])) ? $_POST['dbhost'] : 'localhost'; |
|---|
| 128 | $dbuser = (!empty($_POST['dbuser'])) ? $_POST['dbuser'] : ''; |
|---|
| 129 | $dbpasswd = (!empty($_POST['dbpasswd'])) ? $_POST['dbpasswd'] : ''; |
|---|
| 130 | $dbname = (!empty($_POST['dbname'])) ? $_POST['dbname'] : ''; |
|---|
| 131 | $dblayer = 'mysql'; |
|---|
| 132 | |
|---|
| 133 | $admin_name = (!empty($_POST['admin_name'])) ? $_POST['admin_name'] : ''; |
|---|
| 134 | $admin_pass1 = (!empty($_POST['admin_pass1'])) ? $_POST['admin_pass1'] : ''; |
|---|
| 135 | $admin_pass2 = (!empty($_POST['admin_pass2'])) ? $_POST['admin_pass2'] : ''; |
|---|
| 136 | $admin_mail = (!empty($_POST['admin_mail'])) ? $_POST['admin_mail'] : ''; |
|---|
| 137 | |
|---|
| 138 | $is_newsletter_subscribe = true; |
|---|
| 139 | if (isset($_POST['install'])) |
|---|
| 140 | { |
|---|
| 141 | $is_newsletter_subscribe = isset($_POST['newsletter_subscribe']); |
|---|
| 142 | } |
|---|
| 143 | |
|---|
| 144 | $infos = array(); |
|---|
| 145 | $errors = array(); |
|---|
| 146 | |
|---|
| 147 | $config_file = PHPWG_ROOT_PATH.PWG_LOCAL_DIR .'config/database.inc.php'; |
|---|
| 148 | if (@file_exists($config_file)) |
|---|
| 149 | { |
|---|
| 150 | include($config_file); |
|---|
| 151 | // Is Piwigo already installed ? |
|---|
| 152 | if (defined("PHPWG_INSTALLED")) |
|---|
| 153 | { |
|---|
| 154 | die('Piwigo is already installed'); |
|---|
| 155 | } |
|---|
| 156 | } |
|---|
| 157 | |
|---|
| 158 | include(PHPWG_ROOT_PATH . 'include/constants.php'); |
|---|
| 159 | include(PHPWG_ROOT_PATH . 'include/functions.inc.php'); |
|---|
| 160 | include(PHPWG_ROOT_PATH . 'admin/include/functions.php'); |
|---|
| 161 | |
|---|
| 162 | include(PHPWG_ROOT_PATH . 'admin/include/languages.class.php'); |
|---|
| 163 | $languages = new languages('utf-8'); |
|---|
| 164 | |
|---|
| 165 | if (isset($_GET['language'])) |
|---|
| 166 | { |
|---|
| 167 | $language = strip_tags($_GET['language']); |
|---|
| 168 | } |
|---|
| 169 | else |
|---|
| 170 | { |
|---|
| 171 | $language = 'en_UK'; |
|---|
| 172 | // Try to get browser language |
|---|
| 173 | foreach ($languages->fs_languages as $language_code => $fs_language) |
|---|
| 174 | { |
|---|
| 175 | if (substr($language_code,0,2) == @substr($_SERVER["HTTP_ACCEPT_LANGUAGE"],0,2)) |
|---|
| 176 | { |
|---|
| 177 | $language = $language_code; |
|---|
| 178 | break; |
|---|
| 179 | } |
|---|
| 180 | } |
|---|
| 181 | } |
|---|
| 182 | |
|---|
| 183 | if ('fr_FR' == $language) { |
|---|
| 184 | define('PHPWG_DOMAIN', 'fr.piwigo.org'); |
|---|
| 185 | } |
|---|
| 186 | else if ('it_IT' == $language) { |
|---|
| 187 | define('PHPWG_DOMAIN', 'it.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 if ('pl_PL' == $language) { |
|---|
| 196 | define('PHPWG_DOMAIN', 'pl.piwigo.org'); |
|---|
| 197 | } |
|---|
| 198 | else if ('zh_CN' == $language) { |
|---|
| 199 | define('PHPWG_DOMAIN', 'cn.piwigo.org'); |
|---|
| 200 | } |
|---|
| 201 | else if ('hu_HU' == $language) { |
|---|
| 202 | define('PHPWG_DOMAIN', 'hu.piwigo.org'); |
|---|
| 203 | } |
|---|
| 204 | else if ('ru_RU' == $language) { |
|---|
| 205 | define('PHPWG_DOMAIN', 'ru.piwigo.org'); |
|---|
| 206 | } |
|---|
| 207 | else if ('nl_NL' == $language) { |
|---|
| 208 | define('PHPWG_DOMAIN', 'nl.piwigo.org'); |
|---|
| 209 | } |
|---|
| 210 | else { |
|---|
| 211 | define('PHPWG_DOMAIN', 'piwigo.org'); |
|---|
| 212 | } |
|---|
| 213 | define('PHPWG_URL', 'http://'.PHPWG_DOMAIN); |
|---|
| 214 | |
|---|
| 215 | load_language('common.lang', '', array('language' => $language, 'target_charset'=>'utf-8')); |
|---|
| 216 | load_language('admin.lang', '', array('language' => $language, 'target_charset'=>'utf-8')); |
|---|
| 217 | load_language('install.lang', '', array('language' => $language, 'target_charset'=>'utf-8')); |
|---|
| 218 | |
|---|
| 219 | header('Content-Type: text/html; charset=UTF-8'); |
|---|
| 220 | //------------------------------------------------- check php version |
|---|
| 221 | if (version_compare(PHP_VERSION, REQUIRED_PHP_VERSION, '<')) |
|---|
| 222 | { |
|---|
| 223 | include(PHPWG_ROOT_PATH.'install/php5_apache_configuration.php'); |
|---|
| 224 | } |
|---|
| 225 | |
|---|
| 226 | //----------------------------------------------------- template initialization |
|---|
| 227 | include( PHPWG_ROOT_PATH .'include/template.class.php'); |
|---|
| 228 | $template = new Template(PHPWG_ROOT_PATH.'admin/themes', 'clear'); |
|---|
| 229 | $template->set_filenames( array('install' => 'install.tpl') ); |
|---|
| 230 | if (!isset($step)) |
|---|
| 231 | { |
|---|
| 232 | $step = 1; |
|---|
| 233 | } |
|---|
| 234 | //---------------------------------------------------------------- form analyze |
|---|
| 235 | include(PHPWG_ROOT_PATH .'include/dblayer/functions_'.$dblayer.'.inc.php'); |
|---|
| 236 | include(PHPWG_ROOT_PATH . 'admin/include/functions_install.inc.php'); |
|---|
| 237 | include(PHPWG_ROOT_PATH . 'admin/include/functions_upgrade.php'); |
|---|
| 238 | |
|---|
| 239 | if ( isset( $_POST['install'] )) |
|---|
| 240 | { |
|---|
| 241 | install_db_connect($infos, $errors); |
|---|
| 242 | pwg_db_check_charset(); |
|---|
| 243 | |
|---|
| 244 | $webmaster = trim(preg_replace( '/\s{2,}/', ' ', $admin_name )); |
|---|
| 245 | if ( empty($webmaster)) |
|---|
| 246 | array_push( $errors, l10n('enter a login for webmaster') ); |
|---|
| 247 | else if ( preg_match( '/[\'"]/', $webmaster ) ) |
|---|
| 248 | array_push( $errors, l10n('webmaster login can\'t contain characters \' or "') ); |
|---|
| 249 | if ( $admin_pass1 != $admin_pass2 || empty($admin_pass1) ) |
|---|
| 250 | array_push( $errors, l10n('please enter your password again') ); |
|---|
| 251 | if ( empty($admin_mail)) |
|---|
| 252 | array_push( $errors, l10n('mail address must be like xxx@yyy.eee (example : jack@altern.org)') ); |
|---|
| 253 | else |
|---|
| 254 | { |
|---|
| 255 | $error_mail_address = validate_mail_address(null, $admin_mail); |
|---|
| 256 | if (!empty($error_mail_address)) |
|---|
| 257 | array_push( $errors, $error_mail_address ); |
|---|
| 258 | } |
|---|
| 259 | |
|---|
| 260 | if ( count( $errors ) == 0 ) |
|---|
| 261 | { |
|---|
| 262 | $step = 2; |
|---|
| 263 | $file_content = '<?php |
|---|
| 264 | $conf[\'dblayer\'] = \''.$dblayer.'\'; |
|---|
| 265 | $conf[\'db_base\'] = \''.$dbname.'\'; |
|---|
| 266 | $conf[\'db_user\'] = \''.$dbuser.'\'; |
|---|
| 267 | $conf[\'db_password\'] = \''.$dbpasswd.'\'; |
|---|
| 268 | $conf[\'db_host\'] = \''.$dbhost.'\'; |
|---|
| 269 | |
|---|
| 270 | $prefixeTable = \''.$prefixeTable.'\'; |
|---|
| 271 | |
|---|
| 272 | define(\'PHPWG_INSTALLED\', true); |
|---|
| 273 | define(\'PWG_CHARSET\', \'utf-8\'); |
|---|
| 274 | define(\'DB_CHARSET\', \'utf8\'); |
|---|
| 275 | define(\'DB_COLLATE\', \'\'); |
|---|
| 276 | |
|---|
| 277 | ?'.'>'; |
|---|
| 278 | |
|---|
| 279 | @umask(0111); |
|---|
| 280 | // writing the configuration file |
|---|
| 281 | if ( !($fp = @fopen( $config_file, 'w' ))) |
|---|
| 282 | { |
|---|
| 283 | $tmp_filename = md5(uniqid(time())); |
|---|
| 284 | $fh = @fopen( PHPWG_ROOT_PATH.$conf['data_location'] . 'pwg_' . $tmp_filename, 'w' ); |
|---|
| 285 | @fputs($fh, $file_content, strlen($file_content)); |
|---|
| 286 | @fclose($fh); |
|---|
| 287 | |
|---|
| 288 | $template->assign( |
|---|
| 289 | array( |
|---|
| 290 | 'config_creation_failed' => true, |
|---|
| 291 | 'config_url' => 'install.php?dl='.$tmp_filename, |
|---|
| 292 | 'config_file_content' => $file_content, |
|---|
| 293 | ) |
|---|
| 294 | ); |
|---|
| 295 | } |
|---|
| 296 | @fputs($fp, $file_content, strlen($file_content)); |
|---|
| 297 | @fclose($fp); |
|---|
| 298 | |
|---|
| 299 | // tables creation, based on piwigo_structure.sql |
|---|
| 300 | execute_sqlfile( |
|---|
| 301 | PHPWG_ROOT_PATH.'install/piwigo_structure-'.$dblayer.'.sql', |
|---|
| 302 | DEFAULT_PREFIX_TABLE, |
|---|
| 303 | $prefixeTable, |
|---|
| 304 | $dblayer |
|---|
| 305 | ); |
|---|
| 306 | // We fill the tables with basic informations |
|---|
| 307 | execute_sqlfile( |
|---|
| 308 | PHPWG_ROOT_PATH.'install/config.sql', |
|---|
| 309 | DEFAULT_PREFIX_TABLE, |
|---|
| 310 | $prefixeTable, |
|---|
| 311 | $dblayer |
|---|
| 312 | ); |
|---|
| 313 | |
|---|
| 314 | $query = ' |
|---|
| 315 | INSERT INTO '.$prefixeTable.'config (param,value,comment) |
|---|
| 316 | VALUES (\'secret_key\',md5('.pwg_db_cast_to_text(DB_RANDOM_FUNCTION.'()').'), |
|---|
| 317 | \'a secret key specific to the gallery for internal use\');'; |
|---|
| 318 | pwg_query($query); |
|---|
| 319 | |
|---|
| 320 | conf_update_param('piwigo_db_version', get_branch_from_version(PHPWG_VERSION)); |
|---|
| 321 | conf_update_param('gallery_title', l10n('Just another Piwigo gallery')); |
|---|
| 322 | conf_update_param('page_banner', '<h1>%gallery_title%</h1>'."\n\n<p>".l10n('Welcome to my photo gallery').'</p>'); |
|---|
| 323 | |
|---|
| 324 | // fill languages table |
|---|
| 325 | foreach ($languages->fs_languages as $language_code => $fs_language) |
|---|
| 326 | { |
|---|
| 327 | $languages->perform_action('activate', $language_code); |
|---|
| 328 | } |
|---|
| 329 | |
|---|
| 330 | // fill $conf global array |
|---|
| 331 | load_conf_from_db(); |
|---|
| 332 | |
|---|
| 333 | // PWG_CHARSET is required for building the fs_themes array in the |
|---|
| 334 | // themes class |
|---|
| 335 | if (!defined('PWG_CHARSET')) |
|---|
| 336 | { |
|---|
| 337 | define('PWG_CHARSET', 'utf-8'); |
|---|
| 338 | } |
|---|
| 339 | activate_core_themes(); |
|---|
| 340 | |
|---|
| 341 | $insert = array( |
|---|
| 342 | 'id' => 1, |
|---|
| 343 | 'galleries_url' => PHPWG_ROOT_PATH.'galleries/', |
|---|
| 344 | ); |
|---|
| 345 | mass_inserts(SITES_TABLE, array_keys($insert), array($insert)); |
|---|
| 346 | |
|---|
| 347 | // webmaster admin user |
|---|
| 348 | $inserts = array( |
|---|
| 349 | array( |
|---|
| 350 | 'id' => 1, |
|---|
| 351 | 'username' => $admin_name, |
|---|
| 352 | 'password' => md5($admin_pass1), |
|---|
| 353 | 'mail_address' => $admin_mail, |
|---|
| 354 | ), |
|---|
| 355 | array( |
|---|
| 356 | 'id' => 2, |
|---|
| 357 | 'username' => 'guest', |
|---|
| 358 | ), |
|---|
| 359 | ); |
|---|
| 360 | mass_inserts(USERS_TABLE, array_keys($inserts[0]), $inserts); |
|---|
| 361 | |
|---|
| 362 | create_user_infos(array(1,2), array('language' => $language)); |
|---|
| 363 | |
|---|
| 364 | // Available upgrades must be ignored after a fresh installation. To |
|---|
| 365 | // make PWG avoid upgrading, we must tell it upgrades have already been |
|---|
| 366 | // made. |
|---|
| 367 | list($dbnow) = pwg_db_fetch_row(pwg_query('SELECT NOW();')); |
|---|
| 368 | define('CURRENT_DATE', $dbnow); |
|---|
| 369 | $datas = array(); |
|---|
| 370 | foreach (get_available_upgrade_ids() as $upgrade_id) |
|---|
| 371 | { |
|---|
| 372 | array_push( |
|---|
| 373 | $datas, |
|---|
| 374 | array( |
|---|
| 375 | 'id' => $upgrade_id, |
|---|
| 376 | 'applied' => CURRENT_DATE, |
|---|
| 377 | 'description' => 'upgrade included in installation', |
|---|
| 378 | ) |
|---|
| 379 | ); |
|---|
| 380 | } |
|---|
| 381 | mass_inserts( |
|---|
| 382 | UPGRADE_TABLE, |
|---|
| 383 | array_keys($datas[0]), |
|---|
| 384 | $datas |
|---|
| 385 | ); |
|---|
| 386 | |
|---|
| 387 | if ($is_newsletter_subscribe) |
|---|
| 388 | { |
|---|
| 389 | fetchRemote( |
|---|
| 390 | get_newsletter_subscribe_base_url($language).$admin_mail, |
|---|
| 391 | $result, |
|---|
| 392 | array(), |
|---|
| 393 | array('origin' => 'installation') |
|---|
| 394 | ); |
|---|
| 395 | } |
|---|
| 396 | } |
|---|
| 397 | } |
|---|
| 398 | |
|---|
| 399 | //------------------------------------------------------ start template output |
|---|
| 400 | foreach ($languages->fs_languages as $language_code => $fs_language) |
|---|
| 401 | { |
|---|
| 402 | if ($language == $language_code) |
|---|
| 403 | { |
|---|
| 404 | $template->assign('language_selection', $language_code); |
|---|
| 405 | } |
|---|
| 406 | $languages_options[$language_code] = $fs_language['name']; |
|---|
| 407 | } |
|---|
| 408 | $template->assign('language_options', $languages_options); |
|---|
| 409 | |
|---|
| 410 | $template->assign( |
|---|
| 411 | array( |
|---|
| 412 | 'T_CONTENT_ENCODING' => 'utf-8', |
|---|
| 413 | 'RELEASE' => PHPWG_VERSION, |
|---|
| 414 | 'F_ACTION' => 'install.php?language=' . $language, |
|---|
| 415 | 'F_DB_HOST' => $dbhost, |
|---|
| 416 | 'F_DB_USER' => $dbuser, |
|---|
| 417 | 'F_DB_NAME' => $dbname, |
|---|
| 418 | 'F_DB_PREFIX' => $prefixeTable, |
|---|
| 419 | 'F_ADMIN' => $admin_name, |
|---|
| 420 | 'F_ADMIN_EMAIL' => $admin_mail, |
|---|
| 421 | 'EMAIL' => '<span class="adminEmail">'.$admin_mail.'</span>', |
|---|
| 422 | 'F_NEWSLETTER_SUBSCRIBE' => $is_newsletter_subscribe, |
|---|
| 423 | 'L_INSTALL_HELP' => sprintf(l10n('Need help ? Ask your question on <a href="%s">Piwigo message board</a>.'), PHPWG_URL.'/forum'), |
|---|
| 424 | )); |
|---|
| 425 | |
|---|
| 426 | //------------------------------------------------------ errors & infos display |
|---|
| 427 | if ($step == 1) |
|---|
| 428 | { |
|---|
| 429 | $template->assign('install', true); |
|---|
| 430 | } |
|---|
| 431 | else |
|---|
| 432 | { |
|---|
| 433 | array_push( |
|---|
| 434 | $infos, |
|---|
| 435 | l10n('Congratulations, Piwigo installation is completed') |
|---|
| 436 | ); |
|---|
| 437 | |
|---|
| 438 | if (isset($error_copy)) |
|---|
| 439 | { |
|---|
| 440 | array_push($errors, $error_copy); |
|---|
| 441 | } |
|---|
| 442 | else |
|---|
| 443 | { |
|---|
| 444 | session_set_save_handler('pwg_session_open', |
|---|
| 445 | 'pwg_session_close', |
|---|
| 446 | 'pwg_session_read', |
|---|
| 447 | 'pwg_session_write', |
|---|
| 448 | 'pwg_session_destroy', |
|---|
| 449 | 'pwg_session_gc' |
|---|
| 450 | ); |
|---|
| 451 | if ( function_exists('ini_set') ) |
|---|
| 452 | { |
|---|
| 453 | ini_set('session.use_cookies', $conf['session_use_cookies']); |
|---|
| 454 | ini_set('session.use_only_cookies', $conf['session_use_only_cookies']); |
|---|
| 455 | ini_set('session.use_trans_sid', intval($conf['session_use_trans_sid'])); |
|---|
| 456 | ini_set('session.cookie_httponly', 1); |
|---|
| 457 | } |
|---|
| 458 | session_name($conf['session_name']); |
|---|
| 459 | session_set_cookie_params(0, cookie_path()); |
|---|
| 460 | $user = build_user(1, true); |
|---|
| 461 | log_user($user['id'], false); |
|---|
| 462 | |
|---|
| 463 | // email notification |
|---|
| 464 | include_once(PHPWG_ROOT_PATH.'include/functions_mail.inc.php'); |
|---|
| 465 | |
|---|
| 466 | $keyargs_content = array( |
|---|
| 467 | get_l10n_args('Hello %s,', $admin_name), |
|---|
| 468 | get_l10n_args('Welcome to your new installation of Piwigo!', ''), |
|---|
| 469 | get_l10n_args('', ''), |
|---|
| 470 | get_l10n_args('Here is your password: %s', $admin_pass1), |
|---|
| 471 | get_l10n_args('', ''), |
|---|
| 472 | get_l10n_args('Don\'t hesitate to consult our forums for any help: %s', PHPWG_URL), |
|---|
| 473 | ); |
|---|
| 474 | |
|---|
| 475 | pwg_mail( |
|---|
| 476 | $admin_mail, |
|---|
| 477 | array( |
|---|
| 478 | 'subject' => 'Just another Piwigo gallery', |
|---|
| 479 | 'content' => l10n_args($keyargs_content), |
|---|
| 480 | 'content_format' => 'text/plain', |
|---|
| 481 | ) |
|---|
| 482 | ); |
|---|
| 483 | } |
|---|
| 484 | } |
|---|
| 485 | if (count($errors) != 0) |
|---|
| 486 | { |
|---|
| 487 | $template->assign('errors', $errors); |
|---|
| 488 | } |
|---|
| 489 | |
|---|
| 490 | if (count($infos) != 0 ) |
|---|
| 491 | { |
|---|
| 492 | $template->assign('infos', $infos); |
|---|
| 493 | } |
|---|
| 494 | |
|---|
| 495 | //----------------------------------------------------------- html code display |
|---|
| 496 | $template->pparse('install'); |
|---|
| 497 | ?> |
|---|