source: trunk/admin/configuration.php @ 1250

Last change on this file since 1250 was 1250, checked in by nikrou, 18 years ago

bug fixed: popuhelp (slash)
svn merge -r1248:1249 from branch-1_6 into trunk

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 9.5 KB
RevLine 
[362]1<?php
2// +-----------------------------------------------------------------------+
[593]3// | PhpWebGallery - a PHP based picture gallery                           |
4// | Copyright (C) 2002-2003 Pierrick LE GALL - pierrick@phpwebgallery.net |
[1044]5// | Copyright (C) 2003-2006 PhpWebGallery Team - http://phpwebgallery.net |
[362]6// +-----------------------------------------------------------------------+
[593]7// | branch        : BSF (Best So Far)
[362]8// | file          : $RCSfile$
9// | last update   : $Date: 2006-04-21 21:16:37 +0000 (Fri, 21 Apr 2006) $
10// | last modifier : $Author: nikrou $
11// | revision      : $Revision: 1250 $
12// +-----------------------------------------------------------------------+
13// | This program is free software; you can redistribute it and/or modify  |
14// | it under the terms of the GNU General Public License as published by  |
15// | the Free Software Foundation                                          |
16// |                                                                       |
17// | This program is distributed in the hope that it will be useful, but   |
18// | WITHOUT ANY WARRANTY; without even the implied warranty of            |
19// | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU      |
20// | General Public License for more details.                              |
21// |                                                                       |
22// | You should have received a copy of the GNU General Public License     |
23// | along with this program; if not, write to the Free Software           |
24// | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, |
25// | USA.                                                                  |
26// +-----------------------------------------------------------------------+
[2]27
[527]28if( !defined("PHPWG_ROOT_PATH") )
[393]29{
[1072]30  die ("Hacking attempt!");
[393]31}
[527]32
[1072]33include_once(PHPWG_ROOT_PATH.'admin/include/functions.php');
34
35// +-----------------------------------------------------------------------+
36// | Check Access and exit when user status is not ok                      |
37// +-----------------------------------------------------------------------+
38check_status(ACCESS_ADMINISTRATOR);
39
[512]40//-------------------------------------------------------- sections definitions
41if (!isset($_GET['section']))
42{
43  $page['section'] = 'general';
44}
45else
46{
47  $page['section'] = $_GET['section'];
48}
49//------------------------------------------------------ $conf reinitialization
[587]50$result = pwg_query('SELECT param,value FROM '.CONFIG_TABLE);
[512]51while ($row = mysql_fetch_array($result))
52{
53  $conf[$row['param']] = $row['value'];
[516]54  // if the parameter is present in $_POST array (if a form is submited), we
55  // override it with the submited value
[700]56  if (isset($_POST[$row['param']]))
[512]57  {
58    $conf[$row['param']] = $_POST[$row['param']];
[1071]59    if ( 'page_banner'==$row['param'] )
60    { // should we do it for all ?
61      $conf[$row['param']] = stripslashes( $conf[$row['param']] );
62    }
[512]63  }
[1071]64}
[2]65//------------------------------ verification and registration of modifications
[512]66if (isset($_POST['submit']))
[2]67{
[21]68  $int_pattern = '/^\d+$/';
[512]69  switch ($page['section'])
[2]70  {
[512]71    case 'general' :
[130]72    {
[1044]73      if ( !url_is_remote($_POST['gallery_url']) )
74      {
75        array_push($page['errors'], $lang['conf_gallery_url_error']);
76      }
[512]77      break;
[130]78    }
[512]79    case 'comments' :
80    {
81      // the number of comments per page must be an integer between 5 and 50
82      // included
83      if (!preg_match($int_pattern, $_POST['nb_comment_page'])
84           or $_POST['nb_comment_page'] < 5
85           or $_POST['nb_comment_page'] > 50)
86      {
[792]87        array_push($page['errors'], $lang['conf_nb_comment_page_error']);
[512]88      }
89      break;
90    }
91    case 'default' :
92    {
93      // periods must be integer values, they represents number of days
94      if (!preg_match($int_pattern, $_POST['recent_period'])
95          or $_POST['recent_period'] <= 0)
96      {
[792]97        array_push($page['errors'], $lang['periods_error']);
[512]98      }
[869]99      // maxwidth
100      if (isset($_POST['default_maxwidth'])
101          and !empty($_POST['default_maxwidth'])
102          and (!preg_match($int_pattern, $_POST['default_maxwidth'])
103               or $_POST['default_maxwidth'] < 50))
104      {
105        array_push($page['errors'], $lang['maxwidth_error']);
106      }
107      // maxheight
108      if (isset($_POST['default_maxheight'])
109          and !empty($_POST['default_maxheight'])
110          and (!preg_match($int_pattern, $_POST['default_maxheight'])
111               or $_POST['default_maxheight'] < 50))
112      {
113        array_push($page['errors'], $lang['maxheight_error']);
114      }
[512]115      break;
116    }
[2]117  }
[1071]118
[528]119  // updating configuration if no error found
[792]120  if (count($page['errors']) == 0)
[345]121  {
[869]122//    echo '<pre>'; print_r($_POST); echo '</pre>';
[587]123    $result = pwg_query('SELECT * FROM '.CONFIG_TABLE);
[512]124    while ($row = mysql_fetch_array($result))
125    {
126      if (isset($_POST[$row['param']]))
127      {
[882]128        $value = $_POST[$row['param']];
[1071]129
130        if ('gallery_title' == $row['param'])
[882]131        {
132          if (!$conf['allow_html_descriptions'])
133          {
134            $value = strip_tags($value);
135          }
136        }
[1071]137
[528]138        $query = '
139UPDATE '.CONFIG_TABLE.'
[882]140  SET value = \''. str_replace("\'", "''", $value).'\'
[528]141  WHERE param = \''.$row['param'].'\'
142;';
[587]143        pwg_query($query);
[512]144      }
145    }
[792]146    array_push($page['infos'], $lang['conf_confirmation']);
[345]147  }
[512]148}
[527]149
[512]150//----------------------------------------------------- template initialization
[527]151$template->set_filenames( array('config'=>'admin/configuration.tpl') );
[512]152
[528]153$action = PHPWG_ROOT_PATH.'admin.php?page=configuration';
154$action.= '&amp;section='.$page['section'];
[21]155
[528]156$template->assign_vars(
157  array(
158    'L_YES'=>$lang['yes'],
159    'L_NO'=>$lang['no'],
160    'L_SUBMIT'=>$lang['submit'],
161    'L_RESET'=>$lang['reset'],
[858]162
[1250]163    'U_HELP' => PHPWG_ROOT_PATH.'popuphelp.php?page=configuration',
[1071]164
[1004]165    'F_ACTION'=>$action
[528]166    ));
167
[527]168switch ($page['section'])
[528]169{
170  case 'general' :
[2]171  {
[1044]172    $html_check='checked="checked"';
[1071]173
[528]174    $history_yes = ($conf['log']=='true')?'checked="checked"':'';
175    $history_no  = ($conf['log']=='false')?'checked="checked"':'';
[653]176    $lock_yes = ($conf['gallery_locked']=='true')?'checked="checked"':'';
177    $lock_no = ($conf['gallery_locked']=='false')?'checked="checked"':'';
[1071]178
[528]179    $template->assign_block_vars(
180      'general',
181      array(
182        'HISTORY_YES'=>$history_yes,
183        'HISTORY_NO'=>$history_no,
[653]184        'GALLERY_LOCKED_YES'=>$lock_yes,
185        'GALLERY_LOCKED_NO'=>$lock_no,
[1044]186        ($conf['rate']=='true'?'RATE_YES':'RATE_NO')=>$html_check,
187        ($conf['rate_anonymous']=='true'
188             ? 'RATE_ANONYMOUS_YES' : 'RATE_ANONYMOUS_NO')=>$html_check,
[882]189        'CONF_GALLERY_TITLE' => $conf['gallery_title'],
[1071]190        'CONF_PAGE_BANNER' => $conf['page_banner'],
[1044]191        'CONF_GALLERY_URL' => $conf['gallery_url'],
[528]192        ));
193    break;
194  }
195  case 'comments' :
196  {
197    $all_yes = ($conf['comments_forall']=='true')?'checked="checked"':'';
198    $all_no  = ($conf['comments_forall']=='false')?'checked="checked"':'';
199    $validate_yes = ($conf['comments_validation']=='true')?'checked="checked"':'';
200    $validate_no = ($conf['comments_validation']=='false')?'checked="checked"':'';
[1071]201
[528]202    $template->assign_block_vars(
203      'comments',
204      array(
205        'NB_COMMENTS_PAGE'=>$conf['nb_comment_page'],
206        'COMMENTS_ALL_YES'=>$all_yes,
207        'COMMENTS_ALL_NO'=>$all_no,
208        'VALIDATE_YES'=>$validate_yes,
209        'VALIDATE_NO'=>$validate_no
210        ));
211    break;
212  }
213  case 'default' :
214  {
215    $show_yes = ($conf['show_nb_comments']=='true')?'checked="checked"':'';
216    $show_no = ($conf['show_nb_comments']=='false')?'checked="checked"':'';
217    $expand_yes = ($conf['auto_expand']=='true')?'checked="checked"':'';
218    $expand_no  = ($conf['auto_expand']=='false')?'checked="checked"':'';
[1071]219
[528]220    $template->assign_block_vars(
221      'default',
222      array(
223        'NB_IMAGE_LINE'=>$conf['nb_image_line'],
224        'NB_ROW_PAGE'=>$conf['nb_line_page'],
225        'CONF_RECENT'=>$conf['recent_period'],
226        'NB_COMMENTS_PAGE'=>$conf['nb_comment_page'],
[869]227        'MAXWIDTH'=>$conf['default_maxwidth'],
228        'MAXHEIGHT'=>$conf['default_maxheight'],
[528]229        'EXPAND_YES'=>$expand_yes,
230        'EXPAND_NO'=>$expand_no,
231        'SHOW_COMMENTS_YES'=>$show_yes,
232        'SHOW_COMMENTS_NO'=>$show_no
233        ));
[1071]234
[858]235    $blockname = 'default.language_option';
[1071]236
[858]237    foreach (get_languages() as $language_code => $language_name)
238    {
239      if (isset($_POST['submit']))
240      {
241        $selected =
242          $_POST['default_language'] == $language_code
243            ? 'selected="selected"' : '';
244      }
245      else if ($conf['default_language'] == $language_code)
246      {
247        $selected = 'selected="selected"';
248      }
249      else
250      {
251        $selected = '';
252      }
[1071]253
[858]254      $template->assign_block_vars(
255        $blockname,
256        array(
257          'VALUE'=> $language_code,
258          'CONTENT' => $language_name,
259          'SELECTED' => $selected
260          ));
261    }
[541]262
[858]263    $blockname = 'default.template_option';
264
[1048]265    foreach (get_pwg_themes() as $pwg_template)
[858]266    {
267      if (isset($_POST['submit']))
268      {
269        $selected =
270          $_POST['default_template'] == $pwg_template
271            ? 'selected="selected"' : '';
272      }
273      else if ($conf['default_template'] == $pwg_template)
274      {
275        $selected = 'selected="selected"';
276      }
277      else
278      {
279        $selected = '';
280      }
[1071]281
[858]282      $template->assign_block_vars(
283        $blockname,
284        array(
285          'VALUE'=> $pwg_template,
286          'CONTENT' => $pwg_template,
287          'SELECTED' => $selected
288          )
289        );
290    }
291
[1071]292
[528]293    break;
294  }
295}
[2]296//----------------------------------------------------------- sending html code
[393]297$template->assign_var_from_handle('ADMIN_CONTENT', 'config');
[362]298?>
Note: See TracBrowser for help on using the repository browser.