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