| // | branch : BSF (Best So Far) | // +-----------------------------------------------------------------------+ // | file : $RCSfile$ // | last update : $Date: 2004-03-04 23:55:40 +0000 (Thu, 04 Mar 2004) $ // | last modifier : $Author: z0rglub $ // | revision : $Revision: 382 $ // +-----------------------------------------------------------------------+ // | 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 | // | | // | 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. | // +-----------------------------------------------------------------------+ //----------------------------------------------------------- include define('PHPWG_ROOT_PATH','./'); // Guess an initial language ... function guess_lang() { global $_SERVER; $languages = array(); $i = 0; if ( $opendir = opendir ( PHPWG_ROOT_PATH.'language/' ) ) { while ( $file = readdir ( $opendir ) ) { if ( is_dir ( PHPWG_ROOT_PATH.'language/'.$file )&& !substr_count($file,'.')) { $languages[$i++] =$file; } } } if (isset($_SERVER['HTTP_ACCEPT_LANGUAGE'])) { $accept_lang_ary = explode(',', $_SERVER['HTTP_ACCEPT_LANGUAGE']); for ($i = 0; $i < sizeof($accept_lang_ary); $i++) { for ($j=0; $jset_filenames( array('install'=>'install.tpl') ); $step = 1; //----------------------------------------------------- form analyze if ( isset( $_POST['install'] )) { if ( @mysql_connect( $_POST['dbhost'], $_POST['dbuser'], $_POST['dbpasswd'] ) ) { if ( @mysql_select_db($_POST['dbname'] ) ) { array_push( $infos, $lang['step1_confirmation'] ); } else { array_push( $errors, $lang['step1_err_db'] ); } } else { array_push( $errors, $lang['step1_err_server'] ); } $webmaster = trim(preg_replace( '/\s{2,}/', ' ', $admin_name )); if ( empty($webmaster)) array_push( $errors, $lang['step2_err_login1'] ); else if ( preg_match( '/[\'"]/', $webmaster ) ) array_push( $errors, $lang['step2_err_login3'] ); if ( $admin_pass1 != $admin_pass2 || empty($admin_pass1) ) array_push( $errors, $lang['step2_err_pass'] ); if ( empty($admin_mail)) array_push( $errors, $lang['reg_err_mail_address'] ); else { $error_mail_address = validate_mail_address($admin_mail); if (!empty($error_mail_address)) array_push( $errors, $error_mail_address ); } if ( count( $errors ) == 0 ) { $step = 2; $file_content = ""; @umask(0111); // writing the configuration file if ( !($fp = @fopen( $config_file, 'w' ))) { $html_content = htmlentities( $file_content, ENT_QUOTES ); $html_content = nl2br( $html_content ); $template->assign_block_vars('error_copy', array('FILE_CONTENT'=>$html_content)); } @fputs($fp, $file_content, strlen($file_content)); @fclose($fp); // tables creation, based on phpwebgallery_structure.sql execute_sqlfile( './install/phpwebgallery_structure.sql' , 'phpwebgallery_' , $table_prefix ); // We fill the tables with basic informations execute_sqlfile( './install/config.sql' , 'phpwebgallery_' , $table_prefix ); $query = 'UPDATE '.CONFIG_TABLE; $query.= " SET value = '".$admin_name."'"; $query.= " WHERE param = 'webmaster'"; $query.= ';'; mysql_query( $query ); $query = 'UPDATE '.CONFIG_TABLE; $query.= " SET value = '".$admin_mail."'"; $query.= " WHERE param = 'mail_webmaster'"; $query.= ';'; mysql_query( $query ); $query = 'INSERT INTO '.SITES_TABLE; $query.= " (id,galleries_url) VALUES (1, './galleries/');"; mysql_query( $query ); // webmaster admin user $query = 'INSERT INTO '.USERS_TABLE; $query.= ' (id,username,password,status,language,mail_address) VALUES '; $query.= "(1,'".$admin_name."','".md5( $admin_pass1 )."'"; $query.= ",'admin','".$language."'"; $query.= ",'".$admin_mail."');"; mysql_query($query); // guest user $query = 'INSERT INTO '.USERS_TABLE; $query.= '(id,username,password,status,language) VALUES '; $query.= "(2,'guest','','guest','".$language."')"; $query.= ';'; mysql_query( $query ); } } $template->assign_vars(array( 'RELEASE'=>$release_version, 'L_BASE_TITLE'=>$lang['Initial_config'], 'L_LANG_TITLE'=>$lang['Default_lang'], 'L_DB_TITLE'=>$lang['step1_title'], 'L_DB_HOST'=>$lang['step1_host'], 'L_DB_HOST_INFO'=>$lang['step1_host_info'], 'L_DB_USER'=>$lang['step1_user'], 'L_DB_USER_INFO'=>$lang['step1_user_info'], 'L_DB_PASS'=>$lang['step1_pass'], 'L_DB_PASS_INFO'=>$lang['step1_pass_info'], 'L_DB_NAME'=>$lang['step1_database'], 'L_DB_NAME_INFO'=>$lang['step1_database_info'], 'L_DB_PREFIX'=>$lang['step1_prefix'], 'L_DB_PREFIX_INFO'=>$lang['step1_prefix_info'], 'L_ADMIN_TITLE'=>$lang['step2_title'], 'L_ADMIN'=>$lang['conf_general_webmaster'], 'L_ADMIN_INFO'=>$lang['conf_general_webmaster_info'], 'L_ADMIN_PASSWORD'=>$lang['step2_pwd'], 'L_ADMIN_PASSWORD_INFO'=>$lang['step2_pwd_info'], 'L_ADMIN_CONFIRM_PASSWORD'=>$lang['step2_pwd_conf'], 'L_ADMIN_CONFIRM_PASSWORD_INFO'=>$lang['step2_pwd_conf_info'], 'L_ADMIN_EMAIL'=>$lang['conf_general_mail'], 'L_ADMIN_EMAIL_INFO'=>$lang['conf_general_mail_info'], 'L_SUBMIT'=>$lang['Start_Install'], 'L_HELP'=>$lang['install_help'], 'L_ERR_COPY'=>$lang['step1_err_copy'], 'L_END_TITLE'=>$lang['install_end_title'], 'L_END_MESSAGE'=>$lang['install_end_message'], 'F_ACTION'=>add_session_id( 'install.php' ), 'F_DB_HOST'=>$dbhost, 'F_DB_USER'=>$dbuser, 'F_DB_NAME'=>$dbname, 'F_DB_PREFIX'=>$table_prefix, 'F_ADMIN'=>$admin_name, 'F_ADMIN_EMAIL'=>$admin_mail, 'F_LANG_SELECT'=>make_jumpbox($lang_options, $language, true), 'T_CONTENT_ENCODING' => $lang['charset'], 'T_STYLE' => './template/'.$install_style.'/'.$install_style.'-admin.css') ); //-------------------------------------------------------- errors & infos display if ( sizeof( $errors ) != 0 ) { $template->assign_block_vars('errors',array()); for ( $i = 0; $i < sizeof( $errors ); $i++ ) { $template->assign_block_vars('errors.error',array('ERROR'=>$errors[$i])); } } if ( sizeof( $infos ) != 0 ) { $template->assign_block_vars('infos',array()); for ( $i = 0; $i < sizeof( $infos ); $i++ ) { $template->assign_block_vars('infos.info',array('INFO'=>$infos[$i])); } } if ($step ==1) { $template->assign_block_vars('install',array()); } else { $template->assign_block_vars('install_end',array()); } //----------------------------------------------------------- html code display $template->pparse('install'); ?>