2003-11-02 11:22:45 +01:00
< ? php
2004-02-07 20:36:44 +01:00
// +-----------------------------------------------------------------------+
2008-04-05 00:57:23 +02:00
// | Piwigo - a PHP based picture gallery |
// +-----------------------------------------------------------------------+
2010-03-19 23:37:10 +01:00
// | Copyright(C) 2008-2010 Piwigo Team http://piwigo.org |
2008-04-05 00:57:23 +02:00
// | Copyright(C) 2003-2008 PhpWebGallery Team http://phpwebgallery.net |
// | Copyright(C) 2002-2003 Pierrick LE GALL http://le-gall.net/pierrick |
// +-----------------------------------------------------------------------+
// | This program is free software; you can redistribute it and/or modify |
// | it under the terms of the GNU General Public License as published by |
// | the Free Software Foundation |
// | |
2004-02-07 20:36:44 +01:00
// | This program is distributed in the hope that it will be useful, but |
// | WITHOUT ANY WARRANTY; without even the implied warranty of |
// | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
// | General Public License for more details. |
// | |
// | You should have received a copy of the GNU General Public License |
// | along with this program; if not, write to the Free Software |
// | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, |
// | USA. |
// +-----------------------------------------------------------------------+
2003-11-02 11:22:45 +01:00
2004-02-20 20:07:43 +01:00
//----------------------------------------------------------- include
define ( 'PHPWG_ROOT_PATH' , './' );
2004-02-02 01:55:18 +01:00
2009-12-02 21:27:06 +01:00
include ( PHPWG_ROOT_PATH . 'admin/include/functions_install.inc.php' );
2004-03-05 00:55:40 +01:00
2009-08-17 18:21:09 +02:00
@ set_magic_quotes_runtime ( 0 ); // Disable magic_quotes_runtime
2004-02-20 20:07:43 +01:00
//
// addslashes to vars if magic_quotes_gpc is off this is a security
// precaution to prevent someone trying to break out of a SQL statement.
//
2009-10-09 16:41:30 +02:00
if ( !@ get_magic_quotes_gpc () )
2003-11-02 11:22:45 +01:00
{
2004-02-20 20:07:43 +01:00
if ( is_array ( $_POST ) )
2003-11-02 11:22:45 +01:00
{
2004-02-20 20:07:43 +01:00
while ( list ( $k , $v ) = each ( $_POST ) )
2003-11-02 11:22:45 +01:00
{
2004-02-20 20:07:43 +01:00
if ( is_array ( $_POST [ $k ]) )
2003-11-02 11:22:45 +01:00
{
2004-02-20 20:07:43 +01:00
while ( list ( $k2 , $v2 ) = each ( $_POST [ $k ]) )
{
$_POST [ $k ][ $k2 ] = addslashes ( $v2 );
}
@ reset ( $_POST [ $k ]);
2003-11-02 11:22:45 +01:00
}
else
{
2004-02-20 20:07:43 +01:00
$_POST [ $k ] = addslashes ( $v );
2003-11-02 11:22:45 +01:00
}
}
2004-02-20 20:07:43 +01:00
@ reset ( $_POST );
}
2007-02-25 12:42:25 +01:00
if ( is_array ( $_GET ) )
{
while ( list ( $k , $v ) = each ( $_GET ) )
{
if ( is_array ( $_GET [ $k ]) )
{
while ( list ( $k2 , $v2 ) = each ( $_GET [ $k ]) )
{
$_GET [ $k ][ $k2 ] = addslashes ( $v2 );
}
@ reset ( $_GET [ $k ]);
}
else
{
$_GET [ $k ] = addslashes ( $v );
}
}
@ reset ( $_GET );
}
2004-02-20 20:07:43 +01:00
if ( is_array ( $_COOKIE ) )
{
while ( list ( $k , $v ) = each ( $_COOKIE ) )
2003-11-02 11:22:45 +01:00
{
2004-02-20 20:07:43 +01:00
if ( is_array ( $_COOKIE [ $k ]) )
2003-11-02 11:22:45 +01:00
{
2004-02-20 20:07:43 +01:00
while ( list ( $k2 , $v2 ) = each ( $_COOKIE [ $k ]) )
{
$_COOKIE [ $k ][ $k2 ] = addslashes ( $v2 );
}
@ reset ( $_COOKIE [ $k ]);
2003-11-02 11:22:45 +01:00
}
else
{
2004-02-20 20:07:43 +01:00
$_COOKIE [ $k ] = addslashes ( $v );
2003-11-02 11:22:45 +01:00
}
}
2004-02-20 20:07:43 +01:00
@ reset ( $_COOKIE );
2003-11-02 11:22:45 +01:00
}
2004-02-20 20:07:43 +01:00
}
2003-11-02 11:22:45 +01:00
2004-02-20 20:07:43 +01:00
//----------------------------------------------------- variable initialization
2006-04-11 21:50:15 +02:00
2008-05-15 00:25:36 +02:00
define ( 'DEFAULT_PREFIX_TABLE' , 'piwigo_' );
2006-04-11 21:50:15 +02:00
2010-03-22 00:41:19 +01:00
// default database engine proposed if severals are available
// choices : sqlite, mysql, pgsql, pdo-sqlite
// see include/dblayer/dblayers.inc.php
define ( 'DEFAULT_DB_ENGINE' , 'mysql' );
// database engine default choice between sqlite (native or via pdo)
// if the twice are available.
define ( 'DEFAULT_DB_SQLITE' , 'native' );
2006-04-11 21:50:15 +02:00
if ( isset ( $_POST [ 'install' ]))
{
2010-03-21 18:20:56 +01:00
$prefixeTable = $_POST [ 'prefix' ];
2006-04-11 21:50:15 +02:00
}
else
{
2010-03-21 18:20:56 +01:00
$prefixeTable = DEFAULT_PREFIX_TABLE ;
2006-04-11 21:50:15 +02:00
}
2004-02-20 20:07:43 +01:00
2010-03-21 18:20:56 +01:00
include ( PHPWG_ROOT_PATH . 'include/config_default.inc.php' );
@ include ( PHPWG_ROOT_PATH . 'local/config/config.inc.php' );
2010-03-22 21:30:56 +01:00
// download database config file if exists
if ( ! empty ( $_GET [ 'dl' ]) && file_exists ( $conf [ 'local_data_dir' ] . '/pwg_' . $_GET [ 'dl' ]))
{
$filename = $conf [ 'local_data_dir' ] . '/pwg_' . $_GET [ 'dl' ];
header ( 'Cache-Control: no-cache, must-revalidate' );
header ( 'Pragma: no-cache' );
header ( 'Content-Disposition: attachment; filename="database.inc.php"' );
header ( 'Content-Transfer-Encoding: binary' );
header ( 'Content-Length: ' . filesize ( $filename ));
echo file_get_contents ( $filename );
unlink ( $filename );
exit ();
}
2010-03-21 18:20:56 +01:00
// Obtain various vars
$dbhost = ( ! empty ( $_POST [ 'dbhost' ])) ? $_POST [ 'dbhost' ] : 'localhost' ;
$dbuser = ( ! empty ( $_POST [ 'dbuser' ])) ? $_POST [ 'dbuser' ] : '' ;
$dbpasswd = ( ! empty ( $_POST [ 'dbpasswd' ])) ? $_POST [ 'dbpasswd' ] : '' ;
$dbname = ( ! empty ( $_POST [ 'dbname' ])) ? $_POST [ 'dbname' ] : '' ;
2010-03-22 00:41:19 +01:00
$dblayer = ( ! empty ( $_POST [ 'dblayer' ])) ? $_POST [ 'dblayer' ] : DEFAULT_DB_ENGINE ;
2010-03-21 18:20:56 +01:00
2004-02-20 20:07:43 +01:00
$admin_name = ( ! empty ( $_POST [ 'admin_name' ])) ? $_POST [ 'admin_name' ] : '' ;
$admin_pass1 = ( ! empty ( $_POST [ 'admin_pass1' ])) ? $_POST [ 'admin_pass1' ] : '' ;
$admin_pass2 = ( ! empty ( $_POST [ 'admin_pass2' ])) ? $_POST [ 'admin_pass2' ] : '' ;
$admin_mail = ( ! empty ( $_POST [ 'admin_mail' ])) ? $_POST [ 'admin_mail' ] : '' ;
$infos = array ();
$errors = array ();
2010-03-21 13:32:49 +01:00
// database config file migration : mysql.inc.php et database.inc.php
2009-12-04 19:59:05 +01:00
$old_config_file = PHPWG_ROOT_PATH . 'include/mysql.inc.php' ;
2010-03-21 13:32:49 +01:00
$config_file = PHPWG_ROOT_PATH . 'local/config/database.inc.php' ;
2009-12-04 19:59:05 +01:00
if ( ! file_exists ( $config_file ) && file_exists ( $old_config_file ))
{
$step = 3 ;
include $old_config_file ;
$file_content = ' < ? php
$conf [ \ ' dblayer\ ' ] = \ ' mysql\ ' ;
$conf [ \ 'db_base\'] = \'' . $cfgBase . ' \ ' ;
$conf [ \ 'db_user\'] = \'' . $cfgUser . ' \ ' ;
$conf [ \ 'db_password\'] = \'' . $cfgPassword . ' \ ' ;
$conf [ \ 'db_host\'] = \'' . $cfgHote . ' \ ' ;
$prefixeTable = \ '' . $prefixeTable . ' \ ' ;
define ( \ ' PHPWG_INSTALLED\ ' , true );
define ( \ 'PWG_CHARSET\', \'' . PWG_CHARSET . ' \ ' );
define ( \ 'DB_CHARSET\', \'' . DB_CHARSET . ' \ ' );
define ( \ 'DB_COLLATE\', \'' . DB_COLLATE . ' \ ' );
? '.' > ' ;
}
2004-02-20 20:07:43 +01:00
// Open config.php ... if it exists
2009-12-04 19:59:05 +01:00
elseif ( @ file_exists ( $config_file ))
2004-02-20 20:07:43 +01:00
{
2004-09-20 22:54:22 +02:00
include ( $config_file );
2008-05-15 00:25:36 +02:00
// Is Piwigo already installed ?
2004-09-20 22:54:22 +02:00
if ( defined ( " PHPWG_INSTALLED " ))
{
2008-05-15 00:25:36 +02:00
die ( 'Piwigo is already installed' );
2004-09-20 22:54:22 +02:00
}
2004-02-20 20:07:43 +01:00
}
2009-12-02 21:27:06 +01:00
include ( PHPWG_ROOT_PATH . 'include/dblayer/functions_' . $dblayer . '.inc.php' );
2004-02-20 20:07:43 +01:00
include ( PHPWG_ROOT_PATH . 'include/constants.php' );
include ( PHPWG_ROOT_PATH . 'include/functions.inc.php' );
2006-04-20 21:31:12 +02:00
include ( PHPWG_ROOT_PATH . 'admin/include/functions.php' );
2007-09-21 11:06:00 +02:00
include ( PHPWG_ROOT_PATH . 'admin/include/functions_upgrade.php' );
2004-09-20 22:54:22 +02:00
2008-03-03 20:42:16 +01:00
if ( isset ( $_GET [ 'language' ]))
2007-02-25 12:42:25 +01:00
{
2008-03-03 20:42:16 +01:00
$language = strip_tags ( $_GET [ 'language' ]);
2007-02-25 12:42:25 +01:00
}
2007-10-09 03:43:29 +02:00
else
2004-09-20 22:54:22 +02:00
{
2007-10-09 03:43:29 +02:00
$language = 'en_UK' ;
2008-03-03 20:42:16 +01:00
// Try to get browser language
foreach ( get_languages ( 'utf-8' ) as $language_code => $language_name )
{
if ( substr ( $language_code , 0 , 2 ) == @ substr ( $_SERVER [ " HTTP_ACCEPT_LANGUAGE " ], 0 , 2 ))
{
$language = $language_code ;
break ;
}
}
2004-09-20 22:54:22 +02:00
}
2009-03-14 00:43:50 +01:00
if ( 'fr_FR' == $language ) {
define ( 'PHPWG_DOMAIN' , 'fr.piwigo.org' );
}
2010-03-21 22:59:56 +01:00
else if ( 'it_IT' == $language ) {
define ( 'PHPWG_DOMAIN' , 'it.piwigo.org' );
}
2009-10-15 17:17:33 +02:00
else if ( 'de_DE' == $language ) {
define ( 'PHPWG_DOMAIN' , 'de.piwigo.org' );
}
else if ( 'es_ES' == $language ) {
define ( 'PHPWG_DOMAIN' , 'es.piwigo.org' );
}
2010-02-01 19:53:59 +01:00
else if ( 'pl_PL' == $language ) {
define ( 'PHPWG_DOMAIN' , 'pl.piwigo.org' );
}
else if ( 'zh_CN' == $language ) {
define ( 'PHPWG_DOMAIN' , 'cn.piwigo.org' );
}
2010-03-21 22:59:56 +01:00
else if ( 'hu_HU_CN' == $language ) {
define ( 'PHPWG_DOMAIN' , 'hu.piwigo.org' );
}
else if ( 'ru_RU_CN' == $language ) {
define ( 'PHPWG_DOMAIN' , 'ru.piwigo.org' );
}
2009-03-14 00:43:50 +01:00
else {
define ( 'PHPWG_DOMAIN' , 'piwigo.org' );
}
define ( 'PHPWG_URL' , 'http://' . PHPWG_DOMAIN );
2009-12-09 20:20:34 +01:00
if ( empty ( $step ) || ( $step != 3 ))
2009-12-04 19:59:05 +01:00
{
load_language ( 'common.lang' , '' , array ( 'language' => $language , 'target_charset' => 'utf-8' ));
load_language ( 'admin.lang' , '' , array ( 'language' => $language , 'target_charset' => 'utf-8' ));
load_language ( 'install.lang' , '' , array ( 'language' => $language , 'target_charset' => 'utf-8' ));
}
2009-12-10 00:34:57 +01:00
header ( 'Content-Type: text/html; charset=UTF-8' );
2009-03-16 17:57:10 +01:00
//------------------------------------------------- check php version
if ( version_compare ( PHP_VERSION , REQUIRED_PHP_VERSION , '<' ))
{
include ( PHPWG_ROOT_PATH . 'install/php5_apache_configuration.php' );
}
2004-02-20 20:07:43 +01:00
//----------------------------------------------------- template initialization
2009-03-16 17:57:10 +01:00
include ( PHPWG_ROOT_PATH . 'include/template.class.php' );
2010-03-13 01:00:52 +01:00
$template = new Template ( PHPWG_ROOT_PATH . 'admin/themes' , 'roma' );
2009-12-04 19:59:05 +01:00
$template -> set_filenames ( array ( 'install' => 'install.tpl' ) );
if ( ! isset ( $step ))
{
$step = 1 ;
}
2004-09-20 22:54:22 +02:00
//---------------------------------------------------------------- form analyze
2004-02-20 20:07:43 +01:00
if ( isset ( $_POST [ 'install' ] ))
{
2010-03-21 23:51:36 +01:00
try
2004-03-05 00:55:40 +01:00
{
2010-03-21 23:51:36 +01:00
$pwg_db_link = pwg_db_connect ( $_POST [ 'dbhost' ], $_POST [ 'dbuser' ],
$_POST [ 'dbpasswd' ], $_POST [ 'dbname' ]);
array_push ( $infos , l10n ( 'Parameters are correct' ) );
2009-12-09 20:20:34 +01:00
$required_version = constant ( 'REQUIRED_' . strtoupper ( $dblayer ) . '_VERSION' );
2009-12-02 21:27:06 +01:00
if ( version_compare ( pwg_get_db_version (), $required_version , '>=' ) )
2007-10-09 03:43:29 +02:00
{
2009-12-02 21:27:06 +01:00
$pwg_charset = 'utf-8' ;
$pwg_db_charset = 'utf8' ;
if ( $dblayer == 'mysql' )
{
2010-03-25 11:27:17 +01:00
$install_charset_collate = " DEFAULT CHARACTER SET $pwg_db_charset " ;
pwg_query ( 'SET NAMES "' . $pwg_db_charset . '"' );
2009-12-02 21:27:06 +01:00
}
else
{
2010-03-25 11:27:17 +01:00
$install_charset_collate = '' ;
2009-12-02 21:27:06 +01:00
}
2007-10-09 03:43:29 +02:00
}
else
{
2009-12-02 21:27:06 +01:00
$pwg_charset = 'iso-8859-1' ;
$pwg_db_charset = 'latin1' ;
2007-10-09 03:43:29 +02:00
$install_charset_collate = '' ;
if ( ! array_key_exists ( $language , get_languages ( $pwg_charset ) ) )
{
$language = 'en_UK' ;
}
}
2004-03-05 00:55:40 +01:00
}
2010-03-21 23:51:36 +01:00
catch ( Exception $e )
2004-03-05 00:55:40 +01:00
{
2010-03-21 23:51:36 +01:00
array_push ( $errors , l10n ( $e -> getMessage ()));
2004-03-05 00:55:40 +01:00
}
$webmaster = trim ( preg_replace ( '/\s{2,}/' , ' ' , $admin_name ));
if ( empty ( $webmaster ))
2010-03-02 15:54:22 +01:00
array_push ( $errors , l10n ( 'enter a login for webmaster' ) );
2004-03-05 00:55:40 +01:00
else if ( preg_match ( '/[\'"]/' , $webmaster ) )
2010-03-20 23:35:39 +01:00
array_push ( $errors , l10n ( 'webmaster login can\'t contain characters \' or "' ) );
2004-03-05 00:55:40 +01:00
if ( $admin_pass1 != $admin_pass2 || empty ( $admin_pass1 ) )
2010-03-02 15:54:22 +01:00
array_push ( $errors , l10n ( 'please enter your password again' ) );
2004-03-05 00:55:40 +01:00
if ( empty ( $admin_mail ))
2010-03-02 15:54:22 +01:00
array_push ( $errors , l10n ( 'mail address must be like xxx@yyy.eee (example : jack@altern.org)' ) );
2007-10-09 03:43:29 +02:00
else
2004-03-05 00:55:40 +01:00
{
2007-10-06 08:41:18 +02:00
$error_mail_address = validate_mail_address ( null , $admin_mail );
2004-03-05 00:55:40 +01:00
if ( ! empty ( $error_mail_address ))
array_push ( $errors , $error_mail_address );
}
2007-10-09 03:43:29 +02:00
2004-03-05 00:55:40 +01:00
if ( count ( $errors ) == 0 )
{
$step = 2 ;
2006-04-11 21:50:15 +02:00
$file_content = ' < ? php
2009-12-02 21:27:06 +01:00
$conf [ \ 'dblayer\'] = \'' . $dblayer . ' \ ' ;
2009-11-16 20:17:01 +01:00
$conf [ \ 'db_base\'] = \'' . $dbname . ' \ ' ;
$conf [ \ 'db_user\'] = \'' . $dbuser . ' \ ' ;
$conf [ \ 'db_password\'] = \'' . $dbpasswd . ' \ ' ;
$conf [ \ 'db_host\'] = \'' . $dbhost . ' \ ' ;
2006-04-11 21:50:15 +02:00
2010-03-21 18:20:56 +01:00
$prefixeTable = \ '' . $prefixeTable . ' \ ' ;
2006-04-11 21:50:15 +02:00
define ( \ ' PHPWG_INSTALLED\ ' , true );
2007-10-09 03:43:29 +02:00
define ( \ 'PWG_CHARSET\', \'' . $pwg_charset . ' \ ' );
define ( \ 'DB_CHARSET\', \'' . $pwg_db_charset . ' \ ' );
define ( \ ' DB_COLLATE\ ' , \ ' \ ' );
2006-04-11 21:50:15 +02:00
? '.' > ' ;
2007-10-09 03:43:29 +02:00
2004-03-05 00:55:40 +01:00
@ umask ( 0111 );
// writing the configuration file
if ( ! ( $fp = @ fopen ( $config_file , 'w' )))
2003-11-02 11:22:45 +01:00
{
2010-03-22 21:30:56 +01:00
$tmp_filename = md5 ( uniqid ( time ()));
$fh = @ fopen ( $conf [ 'local_data_dir' ] . '/pwg_' . $tmp_filename , 'w' );
@ fputs ( $fh , $file_content , strlen ( $file_content ));
@ fclose ( $fh );
$error_copy = l10n ( 'Creation of config file local/config/database.inc.php failed.' );
$error_copy .= sprintf ( '<br><a href="install.php?dl=%s">%s</a> %s' ,
$tmp_filename ,
l10n ( 'You can download the config file' ),
l10n ( 'and upload it to local/config directory of your installation.' )
);
$error_copy .= '<br><br>' ;
$error_copy .= l10n ( 'An alternate solution is to copy the text in the box above and paste it into the file "local/config/database.inc.php" (Warning : database.inc.php must only contain what is in the textarea, no line return or space character)' );
$error_copy .= '<br><br>' ;
$error_copy .= '<textarea rows="15" cols="70">' . $file_content . '</textarea>' ;
2004-03-05 00:55:40 +01:00
}
@ fputs ( $fp , $file_content , strlen ( $file_content ));
@ fclose ( $fp );
2007-10-09 03:43:29 +02:00
2008-05-15 00:25:36 +02:00
// tables creation, based on piwigo_structure.sql
2006-04-11 21:50:15 +02:00
execute_sqlfile (
2009-12-02 21:27:06 +01:00
PHPWG_ROOT_PATH . 'install/piwigo_structure-' . $dblayer . '.sql' ,
2006-04-11 21:50:15 +02:00
DEFAULT_PREFIX_TABLE ,
2010-03-21 18:20:56 +01:00
$prefixeTable
2006-04-11 21:50:15 +02:00
);
2004-03-05 00:55:40 +01:00
// We fill the tables with basic informations
2006-04-11 21:50:15 +02:00
execute_sqlfile (
PHPWG_ROOT_PATH . 'install/config.sql' ,
DEFAULT_PREFIX_TABLE ,
2010-03-21 18:20:56 +01:00
$prefixeTable
2006-04-11 21:50:15 +02:00
);
2003-11-02 11:22:45 +01:00
2009-12-02 21:27:06 +01:00
$query = '
2010-03-21 18:20:56 +01:00
INSERT INTO '.$prefixeTable.' config ( param , value , comment )
2009-12-02 21:27:06 +01:00
VALUES ( \ 'secret_key\',\'md5(' . pwg_db_cast_to_text ( DB_RANDOM_FUNCTION . '()' ) . ' ) \ ' ,
\ 'a secret key specific to the gallery for internal use\');' ;
pwg_query ( $query );
2010-03-25 11:27:17 +01:00
// fill languages table
$inserts = array ();
foreach ( get_languages ( 'utf-8' ) as $language_code => $language_name )
{
$inserts [] = array (
'id' => $language_code ,
'name' => $language_name ,
);
}
mass_inserts ( LANGUAGES_TABLE , array ( 'id' , 'name' ), $inserts );
2006-04-27 23:08:50 +02:00
// fill $conf global array
load_conf_from_db ();
2010-03-25 11:08:33 +01:00
// PWG_CHARSET is required for building the fs_themes array in the
// themes class
define ( 'PWG_CHARSET' , $pwg_charset );
activate_all_themes ();
2006-04-27 23:08:50 +02:00
$insert = array (
'id' => 1 ,
'galleries_url' => PHPWG_ROOT_PATH . 'galleries/' ,
);
mass_inserts ( SITES_TABLE , array_keys ( $insert ), array ( $insert ));
2007-10-09 03:43:29 +02:00
2004-03-05 00:55:40 +01:00
// webmaster admin user
2006-04-27 23:08:50 +02:00
$inserts = array (
array (
'id' => 1 ,
'username' => $admin_name ,
'password' => md5 ( $admin_pass1 ),
'mail_address' => $admin_mail ,
),
array (
'id' => 2 ,
'username' => 'guest' ,
),
);
mass_inserts ( USERS_TABLE , array_keys ( $inserts [ 0 ]), $inserts );
2005-07-16 16:29:35 +02:00
2007-03-29 00:30:04 +02:00
create_user_infos ( array ( 1 , 2 ), array ( 'language' => $language ));
2006-02-06 22:52:16 +01:00
// Available upgrades must be ignored after a fresh installation. To
// make PWG avoid upgrading, we must tell it upgrades have already been
// made.
2009-11-20 15:17:04 +01:00
list ( $dbnow ) = pwg_db_fetch_row ( pwg_query ( 'SELECT NOW();' ));
2006-04-20 21:31:12 +02:00
define ( 'CURRENT_DATE' , $dbnow );
$datas = array ();
2006-02-06 22:52:16 +01:00
foreach ( get_available_upgrade_ids () as $upgrade_id )
{
2006-04-20 21:31:12 +02:00
array_push (
$datas ,
array (
'id' => $upgrade_id ,
'applied' => CURRENT_DATE ,
'description' => 'upgrade included in installation' ,
)
);
2006-02-06 22:52:16 +01:00
}
2006-04-20 21:31:12 +02:00
mass_inserts (
UPGRADE_TABLE ,
array_keys ( $datas [ 0 ]),
$datas
);
2004-03-05 00:55:40 +01:00
}
2004-02-20 20:07:43 +01:00
}
2003-11-02 11:22:45 +01:00
2008-03-03 20:42:16 +01:00
//------------------------------------------------------ start template output
2009-12-04 19:59:05 +01:00
if ( $step == 3 )
{
@ umask ( 0111 );
// writing the new configuration file
if ( ! ( $fp = @ fopen ( $config_file , 'w' )))
{
$html_content = htmlentities ( $file_content , ENT_QUOTES );
$html_content = nl2br ( $html_content );
2010-03-21 13:32:49 +01:00
$error_copy = l10n ( 'Copy the text in pink between hyphens and paste it into the file "local/config/database.inc.php"(Warning : database.inc.php must only contain what is in pink, no line return or space character)' );
2009-12-04 19:59:05 +01:00
$error_copy .= '<br>--------------------------------------------------------------------<br>' ;
$error_copy .= '<span class="sql_content">' . $html_content . '</span>' ;
$error_copy .= '<br>--------------------------------------------------------------------<br>' ;
}
else
{
@ fputs ( $fp , $file_content , strlen ( $file_content ));
@ fclose ( $fp );
@ unlink ( $old_config_file );
header ( " Location: index.php " );
exit ();
}
2009-12-02 21:27:06 +01:00
2009-12-04 19:59:05 +01:00
$template -> assign (
array (
'T_CONTENT_ENCODING' => 'utf-8' ,
'migration' => true
));
}
else
2008-03-03 20:42:16 +01:00
{
2009-12-04 19:59:05 +01:00
$dbengines = available_engines ();
foreach ( get_languages ( 'utf-8' ) as $language_code => $language_name )
2008-03-03 20:42:16 +01:00
{
2009-12-04 19:59:05 +01:00
if ( $language == $language_code )
{
$template -> assign ( 'language_selection' , $language_code );
}
$languages_options [ $language_code ] = $language_name ;
2008-03-03 20:42:16 +01:00
}
2009-12-04 19:59:05 +01:00
$template -> assign ( 'language_options' , $languages_options );
$template -> assign (
array (
'T_CONTENT_ENCODING' => 'utf-8' ,
'RELEASE' => PHPWG_VERSION ,
'F_ACTION' => 'install.php?language=' . $language ,
'F_DB_ENGINES' => $dbengines ,
'F_DB_LAYER' => $dblayer ,
'F_DB_HOST' => $dbhost ,
'F_DB_USER' => $dbuser ,
'F_DB_NAME' => $dbname ,
2010-03-21 18:20:56 +01:00
'F_DB_PREFIX' => $prefixeTable ,
2009-12-04 19:59:05 +01:00
'F_ADMIN' => $admin_name ,
'F_ADMIN_EMAIL' => $admin_mail ,
2010-03-02 15:54:22 +01:00
'L_INSTALL_HELP' => sprintf ( l10n ( 'Need help ? Ask your question on <a href="%s">Piwigo message board</a>.' ), PHPWG_URL . '/forum' ),
2009-12-04 19:59:05 +01:00
));
2008-03-03 20:42:16 +01:00
}
2004-09-20 22:54:22 +02:00
//------------------------------------------------------ errors & infos display
2008-10-15 19:50:12 +02:00
if ( $step == 1 )
{
$template -> assign ( 'install' , true );
}
2009-12-04 19:59:05 +01:00
elseif ( $step == 3 )
{
if ( isset ( $error_copy ))
{
array_push ( $errors , $error_copy );
}
}
2008-10-15 19:50:12 +02:00
else
{
2010-03-02 15:54:22 +01:00
array_push ( $infos , l10n ( ' The configuration of Piwigo is finished , here is the next step < br >< br >
* go to the identification page and use the login / password given for webmaster < br >
* this login will enable you to access to the administration panel and to the instructions in order to place pictures in your directories ' ));
2008-10-15 19:50:12 +02:00
if ( isset ( $error_copy ))
{
array_push ( $errors , $error_copy );
}
2009-08-01 14:39:46 +02:00
else
{
session_set_save_handler ( 'pwg_session_open' ,
'pwg_session_close' ,
'pwg_session_read' ,
'pwg_session_write' ,
'pwg_session_destroy' ,
'pwg_session_gc'
);
if ( function_exists ( 'ini_set' ) )
{
ini_set ( 'session.use_cookies' , $conf [ 'session_use_cookies' ]);
ini_set ( 'session.use_only_cookies' , $conf [ 'session_use_only_cookies' ]);
ini_set ( 'session.use_trans_sid' , intval ( $conf [ 'session_use_trans_sid' ]));
ini_set ( 'session.cookie_httponly' , 1 );
}
session_name ( $conf [ 'session_name' ]);
session_set_cookie_params ( 0 , cookie_path ());
$user = build_user ( 1 , true );
log_user ( $user [ 'id' ], false );
}
2009-05-31 21:46:59 +02:00
$template -> assign (
'SUBSCRIBE_BASE_URL' ,
get_newsletter_subscribe_base_url ( $language )
);
2008-10-15 19:50:12 +02:00
}
2008-03-03 20:42:16 +01:00
if ( count ( $errors ) != 0 )
2004-02-20 20:07:43 +01:00
{
2008-03-03 20:42:16 +01:00
$template -> assign ( 'errors' , $errors );
2004-02-20 20:07:43 +01:00
}
2003-11-02 11:22:45 +01:00
2008-03-03 20:42:16 +01:00
if ( count ( $infos ) != 0 )
2004-02-20 20:07:43 +01:00
{
2008-03-03 20:42:16 +01:00
$template -> assign ( 'infos' , $infos );
2004-02-20 20:07:43 +01:00
}
2003-11-02 11:22:45 +01:00
//----------------------------------------------------------- html code display
2004-02-20 20:07:43 +01:00
$template -> pparse ( 'install' );
2009-03-16 17:57:10 +01:00
?>