Changeset 383


Ignore:
Timestamp:
Mar 5, 2004, 12:56:02 AM (21 years ago)
Author:
z0rglub
Message:

use new format of config table

Location:
trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/admin/configuration.php

    r364 r383  
    4545                "ý" => "y", "ÿ" => "y");
    4646//------------------------------ verification and registration of modifications
    47 $conf_infos =
    48 array( 'prefix_thumbnail','webmaster','mail_webmaster','access',
    49        'session_id_size','session_time','session_keyword','max_user_listbox',
    50        'show_comments','nb_comment_page','upload_available',
    51        'upload_maxfilesize', 'upload_maxwidth','upload_maxheight',
    52        'upload_maxwidth_thumbnail','upload_maxheight_thumbnail','log',
    53        'comments_validation','comments_forall','authorize_cookies',
    54        'mail_notification' );
     47$conf_infos = array();
     48$query = 'SELECT param';
     49$query.= ' FROM '.CONFIG_TABLE;
     50$query.= ';';
     51$result = mysql_query( $query );
     52while ( $row = mysql_fetch_array( $result ) )
     53{
     54  array_push( $conf_infos, $row['param'] );
     55}
     56
    5557$default_user_infos =
    5658array( 'nb_image_line','nb_line_page','language','maxwidth',
     
    199201  if ( count( $error ) == 0 )
    200202  {
    201     mysql_query( 'DELETE FROM '.PREFIX_TABLE.'config;' );
    202     $query = 'INSERT INTO '.PREFIX_TABLE.'config';
    203     $query.= ' (';
    204     foreach ( $conf_infos as $i => $conf_info ) {
    205       if ( $i > 0 ) $query.= ',';
    206       $query.= $conf_info;
     203    foreach ( $conf_infos as $conf_info ) {
     204      if ( isset( $_POST[$conf_info] ) )
     205      {
     206        $query = 'UPDATE '.CONFIG_TABLE;
     207        $query.= ' SET value = ';
     208        if ( $_POST[$conf_info] == '' )
     209        {
     210          $query.= 'NULL';
     211        }
     212        else
     213        {
     214          $query.= "'".$_POST[$conf_info]."'";
     215        }
     216        $query.= " WHERE param = '".$conf_info."'";
     217        $query.= ';';
     218        mysql_query( $query );
     219      }
    207220    }
    208     $query.= ')';
    209     $query.= ' VALUES';
    210     $query.= ' (';
    211     foreach ( $conf_infos as $i => $conf_info ) {
    212       if ( $i > 0 ) $query.= ',';
    213       if ( $_POST[$conf_info] == '' ) $query.= 'NULL';
    214       else                            $query.= "'".$_POST[$conf_info]."'";
    215     }
    216     $query.= ')';
    217     $query.= ';';
    218     mysql_query( $query );
    219221
    220222    $query = 'UPDATE '.USERS_TABLE;
     
    249251{
    250252//--------------------------------------------------------- data initialization
    251   $query  = 'SELECT '.implode( ',', $conf_infos );
    252   $query .= ' FROM '.PREFIX_TABLE.'config;';
    253   $row = mysql_fetch_array( mysql_query( $query ) );
    254   foreach ( $conf_infos as $info ) {
    255     if ( isset( $row[$info] ) ) $$info = $row[$info];
    256     else                        $$info = '';
     253  $query = 'SELECT param,value';
     254  $query.= ' FROM '.CONFIG_TABLE;
     255  $query.= ';';
     256  $result = mysql_query( $query );
     257  while ( $row =mysql_fetch_array( $result ) )
     258  {
     259    if ( isset( $row['value'] ) )
     260    {
     261      $$row['param'] = $row['value'];
     262    }
     263    else
     264    {
     265      $$row['param'] = '';
     266    }
    257267  }
    258268
  • trunk/include/common.inc.php

    r375 r383  
    2525// | USA.                                                                  |
    2626// +-----------------------------------------------------------------------+
     27
    2728if( !defined("PHPWG_ROOT_PATH") )
    2829{
     
    167168// since basic forum information is not available
    168169//
    169 $sql = 'SELECT * FROM '.CONFIG_TABLE;
    170 if( !($result = mysql_query($sql)) )
     170$query = 'SELECT param,value';
     171$query.= ' FROM '.CONFIG_TABLE;
     172$query.= ';';
     173if( !( $result = mysql_query( $query ) ) )
    171174{
    172175  die("Could not query config information");
    173176}
    174177
    175 $row =mysql_fetch_array($result);
    176 // rertieving the configuration informations for site
    177 // $infos array is used to know the fields to retrieve in the table "config"
    178 // Each field becomes an information of the array $conf.
    179 // Example :
    180 //            prefix_thumbnail --> $conf['prefix_thumbnail']
    181 $infos = array( 'prefix_thumbnail', 'webmaster', 'mail_webmaster', 'access',
    182                 'session_id_size', 'session_keyword', 'session_time',
    183                 'max_user_listbox', 'show_comments', 'nb_comment_page',
    184                 'upload_available', 'upload_maxfilesize', 'upload_maxwidth',
    185                 'upload_maxheight', 'upload_maxwidth_thumbnail',
    186                 'upload_maxheight_thumbnail','log','comments_validation',
    187                 'comments_forall','authorize_cookies','mail_notification' );
    188 // affectation of each field of the table "config" to an information of the
    189 // array $conf.
    190 foreach ( $infos as $info ) {
    191   if ( isset( $row[$info] ) ) $conf[$info] = $row[$info];
    192   else                        $conf[$info] = '';
    193   // If the field is true or false, the variable is transformed into a boolean
    194   // value.
    195   if ( $conf[$info] == 'true' or $conf[$info] == 'false' )
    196   {
    197     $conf[$info] = get_boolean( $conf[$info] );
     178while ( $row =mysql_fetch_array( $result ) )
     179{
     180  if ( isset( $row['value'] ) )
     181  {
     182    $conf[$row['param']] = $row['value'];
     183  }
     184  else
     185  {
     186    $conf[$row['param']] = '';
     187  }
     188  // If the field is true or false, the variable is transformed into a
     189  // boolean value.
     190  if ( $conf[$row['param']] == 'true' or $conf[$row['param']] == 'false' )
     191  {
     192    $conf[$row['param']] = get_boolean( $conf[$row['param']] );
    198193  }
    199194}
Note: See TracChangeset for help on using the changeset viewer.