diff options
author | z0rglub <z0rglub@piwigo.org> | 2004-09-20 20:54:22 +0000 |
---|---|---|
committer | z0rglub <z0rglub@piwigo.org> | 2004-09-20 20:54:22 +0000 |
commit | 86770499b50257360799b748aa164d7751009e36 (patch) | |
tree | 7b36060fe18e397b12360496aca8e74e7bb8c503 | |
parent | 9d0ffba6377a0a011d773ad03cff08d9c5cc0268 (diff) |
- commenting unused function guess_lang
- code refactoring (commenting, code conventions)
- reorganize variable init in install.php avoiding "undefined constant" in
languages files
- PhpWebGallery site and forum URL are not variables anymore, only text in
language file
git-svn-id: http://piwigo.org/svn/trunk@529 68402e56-0260-453c-a942-63ccdbb3a9ee
-rw-r--r-- | install.php | 239 | ||||
-rw-r--r-- | language/en_UK.iso-8859-1/admin.lang.php | 2 | ||||
-rw-r--r-- | language/en_UK.iso-8859-1/common.lang.php | 4 |
3 files changed, 132 insertions, 113 deletions
diff --git a/install.php b/install.php index 55f8f3fec..bff9ddce8 100644 --- a/install.php +++ b/install.php @@ -32,56 +32,75 @@ define('PHPWG_ROOT_PATH','./'); function guess_lang() { return 'en_UK.iso-8859-1'; - 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; $j<sizeof($languages); $j++) - { - if (preg_match('#' . substr($languages[$j],0,2) . '#i', substr(trim($accept_lang_ary[$i]),0,2))) - { - if (file_exists(PHPWG_ROOT_PATH . 'language/' . $languages[$j].'/install.lang.php')) - { - return $languages[$j]; - } - } - } - } - } - return 'en_EN'; +// $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; $j<sizeof($languages); $j++) +// { +// if (preg_match('#' . substr($languages[$j],0,2) . '#i', substr(trim($accept_lang_ary[$i]),0,2))) +// { +// if (file_exists(PHPWG_ROOT_PATH . 'language/' . $languages[$j].'/install.lang.php')) +// { +// return $languages[$j]; +// } +// } +// } +// } +// } +// return 'en_EN'; } -function execute_sqlfile( $filepath, $replaced, $replacing ) +/** + * loads an sql file and executes all queries + * + * Before executing a query, $replaced is... replaced by $replacing. This is + * useful when the SQL file contains generic words. Drop table queries are + * not executed. + * + * @param string filepath + * @param string replaced + * @param string replacing + * @return void + */ +function execute_sqlfile($filepath, $replaced, $replacing) { - $sql_lines = file( $filepath ); + $sql_lines = file($filepath); $query = ''; - foreach ( $sql_lines as $sql_line ) { - $sql_line = trim( $sql_line ); - if ( preg_match( '/(^--|^$)/', $sql_line ) ) continue; + foreach ($sql_lines as $sql_line) + { + $sql_line = trim($sql_line); + if (preg_match('/(^--|^$)/', $sql_line)) + { + continue; + } $query.= ' '.$sql_line; // if we reached the end of query, we execute it and reinitialize the // variable "query" - if ( preg_match( '/;$/', $sql_line ) ) + if (preg_match('/;$/', $sql_line)) { - $query = trim( $query ); - $query = str_replace( $replaced, $replacing, $query ); + $query = trim($query); + $query = str_replace($replaced, $replacing, $query); // we don't execute "DROP TABLE" queries - if ( !preg_match( '/^DROP TABLE/i', $query ) ) mysql_query( $query ); + if (!preg_match('/^DROP TABLE/i', $query)) + { + mysql_query($query); + } $query = ''; } } @@ -137,24 +156,6 @@ if( !get_magic_quotes_gpc() ) //----------------------------------------------------- variable initialization $install_style = 'default'; -$release_version = '1.4'; -if ( isset( $_POST['language'] )) -{ - $language = strip_tags($_POST['language']); -} -else -{ - $language = guess_lang(); -} - -if ( !file_exists(@realpath(PHPWG_ROOT_PATH . 'language/' . $language . '/install.lang.php')) ) -{ - $language = 'en_UK.iso-8859-1'; -} - -include( './language/'.$language.'/common.lang.php' ); -include( './language/'.$language.'/admin.lang.php' ); -include( './language/'.$language.'/install.lang.php' ); // Obtain various vars $dbhost = (!empty($_POST['dbhost'])) ? $_POST['dbhost'] : 'localhost'; @@ -162,7 +163,7 @@ $dbuser = (!empty($_POST['dbuser'])) ? $_POST['dbuser'] : ''; $dbpasswd = (!empty($_POST['dbpasswd'])) ? $_POST['dbpasswd'] : ''; $dbname = (!empty($_POST['dbname'])) ? $_POST['dbname'] : ''; -$table_prefix = (!empty($_POST['prefix'])) ? $_POST['prefix'] : 'phpwg_'; +$table_prefix = (!empty($_POST['prefix'])) ? $_POST['prefix'] : 'phpwebgallery_'; $admin_name = (!empty($_POST['admin_name'])) ? $_POST['admin_name'] : ''; $admin_pass1 = (!empty($_POST['admin_pass1'])) ? $_POST['admin_pass1'] : ''; @@ -176,23 +177,40 @@ $errors = array(); $config_file = PHPWG_ROOT_PATH.'include/mysql.inc.php'; if (@file_exists($config_file)) { - include($config_file); -} - -// Is phpBB already installed? Yes? Redirect to the index -if (defined("PHPWG_INSTALLED")) -{ - die( 'PhpWebGallery is already installed' ); + include($config_file); + // Is PhpWebGallery already installed ? + if (defined("PHPWG_INSTALLED")) + { + die('PhpWebGallery is already installed'); + } } include(PHPWG_ROOT_PATH . 'include/constants.php'); include(PHPWG_ROOT_PATH . 'include/functions.inc.php'); include(PHPWG_ROOT_PATH . 'include/template.php'); + +if ( isset( $_POST['language'] )) +{ + $language = strip_tags($_POST['language']); +} +else +{ + $language = guess_lang(); +} + +if ( !file_exists(@realpath(PHPWG_ROOT_PATH . 'language/' . $language . '/install.lang.php')) ) +{ + $language = 'en_UK.iso-8859-1'; +} + +include( './language/'.$language.'/common.lang.php' ); +include( './language/'.$language.'/admin.lang.php' ); +include( './language/'.$language.'/install.lang.php' ); //----------------------------------------------------- template initialization $template=setup_style($install_style); $template->set_filenames( array('install'=>'install.tpl') ); $step = 1; -//----------------------------------------------------- form analyze +//---------------------------------------------------------------- form analyze if ( isset( $_POST['install'] )) { if ( @mysql_connect( $_POST['dbhost'], @@ -297,50 +315,51 @@ if ( isset( $_POST['install'] )) } } -$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['install_webmaster'], - 'L_ADMIN_INFO'=>$lang['install_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_webmaster'], - 'L_ADMIN_EMAIL_INFO'=>$lang['conf_general_mail_webmaster_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'], +$template->assign_vars( + array( + 'RELEASE'=>PHPWG_VERSION, - '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'=>language_select($language), - - 'T_CONTENT_ENCODING' => $lang_info['charset'] - )); - -//-------------------------------------------------------- errors & infos display + '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['install_webmaster'], + 'L_ADMIN_INFO'=>$lang['install_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_mail_webmaster'], + 'L_ADMIN_EMAIL_INFO'=>$lang['conf_mail_webmaster_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'=>language_select($language), + + 'T_CONTENT_ENCODING' => $lang_info['charset'] + )); + +//------------------------------------------------------ errors & infos display if ( sizeof( $errors ) != 0 ) { $template->assign_block_vars('errors',array()); diff --git a/language/en_UK.iso-8859-1/admin.lang.php b/language/en_UK.iso-8859-1/admin.lang.php index 3468be092..ae074b692 100644 --- a/language/en_UK.iso-8859-1/admin.lang.php +++ b/language/en_UK.iso-8859-1/admin.lang.php @@ -243,7 +243,7 @@ $lang['help_access_title'] = 'Access authorization'; $lang['help_access'][0] = 'PhpWebGallery is able to forbid access to categories. Categories can be "public" or "private". In order to forbid access to a category :'; $lang['help_access'][1] = '1. Modify category informations (from the "categories" section in tha admin panel) and make it "private".'; $lang['help_access'][2] = '2. On the page of permissions (for a group or a user) the private category will be shown and you\'ll be able to authorize access or not.'; -$lang['help_infos'][2] = 'If you have any question, do not hesitate to take a look at the forum or ask a question there. The <a href="'.PHPWG_FORUM_URL.'" style="text-decoration:underline">forum</a> (message board) is available on the presentation site of PhpWebGallery.'; +$lang['help_infos'][2] = 'If you have any question, do not hesitate to take a look at the forum or ask a question there. The <a href="http://forum.phpwebgallery.net" style="text-decoration:underline">forum</a> (message board) is available on the presentation site of PhpWebGallery.'; // Image informations $lang['infoimage_general'] = 'General options for the category'; diff --git a/language/en_UK.iso-8859-1/common.lang.php b/language/en_UK.iso-8859-1/common.lang.php index 24e636d4f..a9632b586 100644 --- a/language/en_UK.iso-8859-1/common.lang.php +++ b/language/en_UK.iso-8859-1/common.lang.php @@ -180,9 +180,9 @@ $lang['about_page_title'] = 'About PhpWebGallery'; $lang['about_title'] = 'About...'; $lang['about_message'] = '<div style="text-align:center;font-weigh:bold;">Information about PhpWebGallery</div> <ul> - <li>This website uses the version '.PHPWG_VERSION.' of "<a href="'.PHPWG_URL.'" style="text-decoration:underline">PhpWebGallery</a>. PhpWebGallery is a web application giving you the possibility to create an online images gallery easily.</li> + <li>This website uses the version '.PHPWG_VERSION.' of "<a href="htt://www.phpwebgallery.net" style="text-decoration:underline">PhpWebGallery</a>. PhpWebGallery is a web application giving you the possibility to create an online images gallery easily.</li> <li>Technicaly, PhpWebGallery is fully developped with PHP (the elePHPant) with a MySQL database (the SQuirreL).</li> - <li>If you have any suggestions or comments, please visit <a href="'.PHPWG_URL.'" style="text-decoration:underline">PhpWebGallery</a> official site, and its dedicated <a href="'.PHPWG_FORUM_URL.'" style="text-decoration:underline">forum</a>.</li> + <li>If you have any suggestions or comments, please visit <a href="http://www.phpwebgallery.net" style="text-decoration:underline">PhpWebGallery</a> official site, and its dedicated <a href="http://forum.phpwebgallery.net" style="text-decoration:underline">forum</a>.</li> </ul>'; $lang['about_return'] = 'Back'; $lang['ident_page_title'] = 'Identification'; |