Changeset 529


Ignore:
Timestamp:
Sep 20, 2004, 10:54:22 PM (20 years ago)
Author:
z0rglub
Message:
  • 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
Location:
trunk
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/install.php

    r519 r529  
    3333{
    3434  return 'en_UK.iso-8859-1';
    35   global $_SERVER;
    36   $languages = array();
    37   $i = 0;
    38   if ( $opendir = opendir ( PHPWG_ROOT_PATH.'language/' ) )
    39   {
    40     while ( $file = readdir ( $opendir ) )
    41     {
    42       if ( is_dir ( PHPWG_ROOT_PATH.'language/'.$file )&& !substr_count($file,'.'))
    43       {
    44         $languages[$i++] =$file;
    45       }
    46     }
    47   }
    48 
    49   if (isset($_SERVER['HTTP_ACCEPT_LANGUAGE']))
    50   {
    51         $accept_lang_ary = explode(',', $_SERVER['HTTP_ACCEPT_LANGUAGE']);
    52         for ($i = 0; $i < sizeof($accept_lang_ary); $i++)
    53         {
    54           for ($j=0; $j<sizeof($languages); $j++)
    55           {
    56                 if (preg_match('#' . substr($languages[$j],0,2) . '#i', substr(trim($accept_lang_ary[$i]),0,2)))
    57                 {
    58                   if (file_exists(PHPWG_ROOT_PATH . 'language/' . $languages[$j].'/install.lang.php'))
    59                   {
    60                         return $languages[$j];
    61                   }
    62                 }
    63           }
    64         }
    65   }
    66   return 'en_EN';
    67 }
    68 
    69 function execute_sqlfile( $filepath, $replaced, $replacing )
    70 {
    71   $sql_lines = file( $filepath );
     35
     36//   $languages = array();
     37//   $i = 0;
     38//   if ($opendir = opendir(PHPWG_ROOT_PATH.'language/'))
     39//   {
     40//     while ( $file = readdir ( $opendir ) )
     41//     {
     42//       if ( is_dir ( PHPWG_ROOT_PATH.'language/'.$file )&& !substr_count($file,'.'))
     43//       {
     44//         $languages[$i++] =$file;
     45//       }
     46//     }
     47//   }
     48
     49//   if (isset($_SERVER['HTTP_ACCEPT_LANGUAGE']))
     50//   {
     51//     $accept_lang_ary = explode(',', $_SERVER['HTTP_ACCEPT_LANGUAGE']);
     52//     for ($i = 0; $i < sizeof($accept_lang_ary); $i++)
     53//     {
     54//       for ($j=0; $j<sizeof($languages); $j++)
     55//       {
     56//         if (preg_match('#' . substr($languages[$j],0,2) . '#i', substr(trim($accept_lang_ary[$i]),0,2)))
     57//         {
     58//           if (file_exists(PHPWG_ROOT_PATH . 'language/' . $languages[$j].'/install.lang.php'))
     59//                {
     60//                     return $languages[$j];
     61//                }
     62//         }
     63//       }
     64//     }
     65//   }
     66//   return 'en_EN';
     67}
     68
     69/**
     70 * loads an sql file and executes all queries
     71 *
     72 * Before executing a query, $replaced is... replaced by $replacing. This is
     73 * useful when the SQL file contains generic words. Drop table queries are
     74 * not executed.
     75 *
     76 * @param string filepath
     77 * @param string replaced
     78 * @param string replacing
     79 * @return void
     80 */
     81function execute_sqlfile($filepath, $replaced, $replacing)
     82{
     83  $sql_lines = file($filepath);
    7284  $query = '';
    73   foreach ( $sql_lines as $sql_line ) {
    74     $sql_line = trim( $sql_line );
    75     if ( preg_match( '/(^--|^$)/', $sql_line ) ) continue;
     85  foreach ($sql_lines as $sql_line)
     86  {
     87    $sql_line = trim($sql_line);
     88    if (preg_match('/(^--|^$)/', $sql_line))
     89    {
     90      continue;
     91    }
    7692    $query.= ' '.$sql_line;
    7793    // if we reached the end of query, we execute it and reinitialize the
    7894    // variable "query"
    79     if ( preg_match( '/;$/', $sql_line ) )
    80     {
    81       $query = trim( $query );
    82       $query = str_replace( $replaced, $replacing, $query );
     95    if (preg_match('/;$/', $sql_line))
     96    {
     97      $query = trim($query);
     98      $query = str_replace($replaced, $replacing, $query);
    8399      // we don't execute "DROP TABLE" queries
    84       if ( !preg_match( '/^DROP TABLE/i', $query ) ) mysql_query( $query );
     100      if (!preg_match('/^DROP TABLE/i', $query))
     101      {
     102        mysql_query($query);
     103      }
    85104      $query = '';
    86105    }
     
    138157//----------------------------------------------------- variable initialization
    139158$install_style = 'default';
    140 $release_version = '1.4';
    141 if ( isset( $_POST['language'] ))
    142 {
    143   $language = strip_tags($_POST['language']);
    144 }
    145 else
    146 {
    147   $language = guess_lang();
    148 }
    149 
    150 if ( !file_exists(@realpath(PHPWG_ROOT_PATH . 'language/' . $language . '/install.lang.php')) )
    151 {
    152   $language = 'en_UK.iso-8859-1';
    153 }
    154 
    155 include( './language/'.$language.'/common.lang.php' );
    156 include( './language/'.$language.'/admin.lang.php' );
    157 include( './language/'.$language.'/install.lang.php' );
    158159
    159160// Obtain various vars
     
    163164$dbname = (!empty($_POST['dbname'])) ? $_POST['dbname'] : '';
    164165
    165 $table_prefix = (!empty($_POST['prefix'])) ? $_POST['prefix'] : 'phpwg_';
     166$table_prefix = (!empty($_POST['prefix'])) ? $_POST['prefix'] : 'phpwebgallery_';
    166167
    167168$admin_name = (!empty($_POST['admin_name'])) ? $_POST['admin_name'] : '';
     
    177178if (@file_exists($config_file))
    178179{
    179         include($config_file);
    180 }
    181 
    182 // Is phpBB already installed? Yes? Redirect to the index
    183 if (defined("PHPWG_INSTALLED"))
    184 {
    185   die( 'PhpWebGallery is already installed' );
     180  include($config_file);
     181  // Is PhpWebGallery already installed ?
     182  if (defined("PHPWG_INSTALLED"))
     183  {
     184    die('PhpWebGallery is already installed');
     185  }
    186186}
    187187
     
    189189include(PHPWG_ROOT_PATH . 'include/functions.inc.php');
    190190include(PHPWG_ROOT_PATH . 'include/template.php');
     191
     192if ( isset( $_POST['language'] ))
     193{
     194  $language = strip_tags($_POST['language']);
     195}
     196else
     197{
     198  $language = guess_lang();
     199}
     200
     201if ( !file_exists(@realpath(PHPWG_ROOT_PATH . 'language/' . $language . '/install.lang.php')) )
     202{
     203  $language = 'en_UK.iso-8859-1';
     204}
     205
     206include( './language/'.$language.'/common.lang.php' );
     207include( './language/'.$language.'/admin.lang.php' );
     208include( './language/'.$language.'/install.lang.php' );
    191209//----------------------------------------------------- template initialization
    192210$template=setup_style($install_style);
    193211$template->set_filenames( array('install'=>'install.tpl') );
    194212$step = 1;
    195 //----------------------------------------------------- form analyze
     213//---------------------------------------------------------------- form analyze
    196214if ( isset( $_POST['install'] ))
    197215{
     
    298316}
    299317
    300 $template->assign_vars(array(
    301   'RELEASE'=>$release_version,
     318$template->assign_vars(
     319  array(
     320    'RELEASE'=>PHPWG_VERSION,
    302321 
    303   'L_BASE_TITLE'=>$lang['Initial_config'],
    304   'L_LANG_TITLE'=>$lang['Default_lang'],
    305   'L_DB_TITLE'=>$lang['step1_title'],
    306   'L_DB_HOST'=>$lang['step1_host'],
    307   'L_DB_HOST_INFO'=>$lang['step1_host_info'],
    308   'L_DB_USER'=>$lang['step1_user'],
    309   'L_DB_USER_INFO'=>$lang['step1_user_info'],
    310   'L_DB_PASS'=>$lang['step1_pass'],
    311   'L_DB_PASS_INFO'=>$lang['step1_pass_info'],
    312   'L_DB_NAME'=>$lang['step1_database'],
    313   'L_DB_NAME_INFO'=>$lang['step1_database_info'],
    314   'L_DB_PREFIX'=>$lang['step1_prefix'],
    315   'L_DB_PREFIX_INFO'=>$lang['step1_prefix_info'],
    316   'L_ADMIN_TITLE'=>$lang['step2_title'],
    317   'L_ADMIN'=>$lang['install_webmaster'],
    318   'L_ADMIN_INFO'=>$lang['install_webmaster_info'],
    319   'L_ADMIN_PASSWORD'=>$lang['step2_pwd'],
    320   'L_ADMIN_PASSWORD_INFO'=>$lang['step2_pwd_info'],
    321   'L_ADMIN_CONFIRM_PASSWORD'=>$lang['step2_pwd_conf'],
    322   'L_ADMIN_CONFIRM_PASSWORD_INFO'=>$lang['step2_pwd_conf_info'],
    323   'L_ADMIN_EMAIL'=>$lang['conf_general_mail_webmaster'],
    324   'L_ADMIN_EMAIL_INFO'=>$lang['conf_general_mail_webmaster_info'],
    325   'L_SUBMIT'=>$lang['Start_Install'],
    326   'L_HELP'=>$lang['install_help'],
    327   'L_ERR_COPY'=>$lang['step1_err_copy'],
    328   'L_END_TITLE'=>$lang['install_end_title'],
    329   'L_END_MESSAGE'=>$lang['install_end_message'],
    330  
    331   'F_ACTION'=>add_session_id( 'install.php' ),
    332   'F_DB_HOST'=>$dbhost,
    333   'F_DB_USER'=>$dbuser,
    334   'F_DB_NAME'=>$dbname,
    335   'F_DB_PREFIX'=>$table_prefix,
    336   'F_ADMIN'=>$admin_name,
    337   'F_ADMIN_EMAIL'=>$admin_mail,
    338   'F_LANG_SELECT'=>language_select($language),
    339  
    340   'T_CONTENT_ENCODING' => $lang_info['charset']
    341         ));
    342        
    343 //-------------------------------------------------------- errors & infos display
     322    'L_BASE_TITLE'=>$lang['Initial_config'],
     323    'L_LANG_TITLE'=>$lang['Default_lang'],
     324    'L_DB_TITLE'=>$lang['step1_title'],
     325    'L_DB_HOST'=>$lang['step1_host'],
     326    'L_DB_HOST_INFO'=>$lang['step1_host_info'],
     327    'L_DB_USER'=>$lang['step1_user'],
     328    'L_DB_USER_INFO'=>$lang['step1_user_info'],
     329    'L_DB_PASS'=>$lang['step1_pass'],
     330    'L_DB_PASS_INFO'=>$lang['step1_pass_info'],
     331    'L_DB_NAME'=>$lang['step1_database'],
     332    'L_DB_NAME_INFO'=>$lang['step1_database_info'],
     333    'L_DB_PREFIX'=>$lang['step1_prefix'],
     334    'L_DB_PREFIX_INFO'=>$lang['step1_prefix_info'],
     335    'L_ADMIN_TITLE'=>$lang['step2_title'],
     336    'L_ADMIN'=>$lang['install_webmaster'],
     337    'L_ADMIN_INFO'=>$lang['install_webmaster_info'],
     338    'L_ADMIN_PASSWORD'=>$lang['step2_pwd'],
     339    'L_ADMIN_PASSWORD_INFO'=>$lang['step2_pwd_info'],
     340    'L_ADMIN_CONFIRM_PASSWORD'=>$lang['step2_pwd_conf'],
     341    'L_ADMIN_CONFIRM_PASSWORD_INFO'=>$lang['step2_pwd_conf_info'],
     342    'L_ADMIN_EMAIL'=>$lang['conf_mail_webmaster'],
     343    'L_ADMIN_EMAIL_INFO'=>$lang['conf_mail_webmaster_info'],
     344    'L_SUBMIT'=>$lang['Start_Install'],
     345    'L_HELP'=>$lang['install_help'],
     346    'L_ERR_COPY'=>$lang['step1_err_copy'],
     347    'L_END_TITLE'=>$lang['install_end_title'],
     348    'L_END_MESSAGE'=>$lang['install_end_message'],
     349   
     350    'F_ACTION'=>add_session_id( 'install.php' ),
     351    'F_DB_HOST'=>$dbhost,
     352    'F_DB_USER'=>$dbuser,
     353    'F_DB_NAME'=>$dbname,
     354    'F_DB_PREFIX'=>$table_prefix,
     355    'F_ADMIN'=>$admin_name,
     356    'F_ADMIN_EMAIL'=>$admin_mail,
     357    'F_LANG_SELECT'=>language_select($language),
     358   
     359    'T_CONTENT_ENCODING' => $lang_info['charset']
     360    ));
     361
     362//------------------------------------------------------ errors & infos display
    344363if ( sizeof( $errors ) != 0 )
    345364{
  • trunk/language/en_UK.iso-8859-1/admin.lang.php

    r527 r529  
    244244$lang['help_access'][1] = '1. Modify category informations (from the "categories" section in tha admin panel) and make it "private".';
    245245$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.';
    246 $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.';
     246$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.';
    247247
    248248// Image informations
  • trunk/language/en_UK.iso-8859-1/common.lang.php

    r527 r529  
    181181$lang['about_message'] = '<div style="text-align:center;font-weigh:bold;">Information about PhpWebGallery</div>
    182182<ul>
    183   <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>
     183  <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>
    184184  <li>Technicaly, PhpWebGallery is fully developped with PHP (the elePHPant) with a MySQL database (the SQuirreL).</li>
    185   <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>
     185  <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>
    186186</ul>';
    187187$lang['about_return'] = 'Back';
Note: See TracChangeset for help on using the changeset viewer.