plugins/SpecialUserPrefs.php
changeset 372 5bd429428101
parent 364 390eb356cd49
child 387 92664d2efab8
child 388 9829ca63b53a
equal deleted inserted replaced
371:dc6026376919 372:5bd429428101
   545                                WHERE user_id=$session->user_id;");
   545                                WHERE user_id=$session->user_id;");
   546         
   546         
   547         if ( !$q )
   547         if ( !$q )
   548           $db->_die();
   548           $db->_die();
   549         
   549         
       
   550         // verify language id
       
   551         $lang_id = strval(intval($_POST['lang_id']));
       
   552         $q = $db->sql_query('SELECT 1 FROM ' . table_prefix . 'language WHERE lang_id = ' . $lang_id . ';');
       
   553         if ( !$q )
       
   554           $db->_die();
       
   555         
       
   556         if ( $db->numrows() > 0 )
       
   557         {
       
   558           $db->free_result();
       
   559           
       
   560           // unload / reload $lang, this verifies that the selected language works
       
   561           unset($GLOBALS['lang']);
       
   562           unset($lang);
       
   563           $lang_id = intval($lang_id);
       
   564           $GLOBALS['lang'] = new Language($lang_id);
       
   565           global $lang;
       
   566           
       
   567           $q = $db->sql_query('UPDATE ' . table_prefix . 'users SET user_lang = ' . $lang_id . " WHERE user_id = {$session->user_id};");
       
   568           if ( !$q )
       
   569             $db->_die();
       
   570         }
       
   571         else
       
   572         {
       
   573           $db->free_result();
       
   574         }
       
   575         
   550         echo '<div class="info-box" style="margin: 0 0 10px 0;">' . $lang->get('usercp_publicinfo_msg_save_success') . '</div>';
   576         echo '<div class="info-box" style="margin: 0 0 10px 0;">' . $lang->get('usercp_publicinfo_msg_save_success') . '</div>';
   551       }
   577       }
       
   578       
       
   579       $lang_box = '<select name="lang_id">';
       
   580       $q = $db->sql_query('SELECT lang_id, lang_name_native FROM ' . table_prefix . "language;");
       
   581       if ( !$q )
       
   582         $db->_die();
       
   583       
       
   584       while ( $row = $db->fetchrow_num() )
       
   585       {
       
   586         list($lang_id, $lang_name) = $row;
       
   587         $lang_name = htmlspecialchars($lang_name);
       
   588         $selected = ( $lang->lang_id == $lang_id ) ? ' selected="selected"' : '';
       
   589         $lang_box .= "<option value=\"$lang_id\"$selected>$lang_name</option>";
       
   590       }
       
   591       
       
   592       $lang_box .= '</select>';
       
   593       
   552       echo '<form action="'.makeUrl($paths->fullpage).'" method="post">';
   594       echo '<form action="'.makeUrl($paths->fullpage).'" method="post">';
   553       ?>
   595       ?>
   554       <div class="tblholder">
   596       <div class="tblholder">
   555         <table border="0" cellspacing="1" cellpadding="4">
   597         <table border="0" cellspacing="1" cellpadding="4">
   556           <tr>
   598           <tr>
   560             <td colspan="2" class="row3"><?php echo $lang->get('usercp_publicinfo_note_optional'); ?></td>
   602             <td colspan="2" class="row3"><?php echo $lang->get('usercp_publicinfo_note_optional'); ?></td>
   561           </tr>
   603           </tr>
   562           <tr>
   604           <tr>
   563             <td class="row2" style="width: 50%;"><?php echo $lang->get('usercp_publicinfo_field_realname'); ?></td>
   605             <td class="row2" style="width: 50%;"><?php echo $lang->get('usercp_publicinfo_field_realname'); ?></td>
   564             <td class="row1" style="width: 50%;"><input type="text" name="real_name" value="<?php echo $session->real_name; ?>" size="30" /></td>
   606             <td class="row1" style="width: 50%;"><input type="text" name="real_name" value="<?php echo $session->real_name; ?>" size="30" /></td>
       
   607           </tr>
       
   608           <tr>
       
   609             <td class="row2"><?php echo $lang->get('usercp_publicinfo_field_language') . '<br /><small>' . $lang->get('usercp_publicinfo_field_language_hint') . '</small>'; ?></td>
       
   610             <td class="row1"><?php echo $lang_box; ?></td>
   565           </tr>
   611           </tr>
   566           <tr>
   612           <tr>
   567             <td class="row2"><?php echo $lang->get('usercp_publicinfo_field_changetheme_title'); ?></td>
   613             <td class="row2"><?php echo $lang->get('usercp_publicinfo_field_changetheme_title'); ?></td>
   568             <td class="row1"><?php echo $lang->get('usercp_publicinfo_field_changetheme_hint'); ?> <a href="<?php echo makeUrlNS('Special', 'ChangeStyle/' . $paths->page); ?>" onclick="ajaxChangeStyle(); return false;"><?php echo $lang->get('usercp_publicinfo_field_changetheme'); ?></a></td>
   614             <td class="row1"><?php echo $lang->get('usercp_publicinfo_field_changetheme_hint'); ?> <a href="<?php echo makeUrlNS('Special', 'ChangeStyle/' . $paths->page); ?>" onclick="ajaxChangeStyle(); return false;"><?php echo $lang->get('usercp_publicinfo_field_changetheme'); ?></a></td>
   569           </tr>
   615           </tr>