source: trunk/admin/configuration.php @ 452

Last change on this file since 452 was 452, checked in by z0rglub, 20 years ago

replacement of short_period and long_period by recent_period

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 14.5 KB
Line 
1<?php
2// +-----------------------------------------------------------------------+
3// |                           configuration.php                           |
4// +-----------------------------------------------------------------------+
5// | application   : PhpWebGallery <http://phpwebgallery.net>              |
6// | branch        : BSF (Best So Far)                                     |
7// +-----------------------------------------------------------------------+
8// | file          : $RCSfile$
9// | last update   : $Date: 2004-07-09 21:00:00 +0000 (Fri, 09 Jul 2004) $
10// | last modifier : $Author: z0rglub $
11// | revision      : $Revision: 452 $
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// +-----------------------------------------------------------------------+
27
28if( !defined("PHPWG_ROOT_PATH") )
29{
30        die ("Hacking attempt!");
31}
32
33include_once( PHPWG_ROOT_PATH.'admin/include/isadmin.inc.php' );
34       
35$Caracs = array("¥" => "Y", "µ" => "u", "À" => "A", "Á" => "A", 
36                "Â" => "A", "Ã" => "A", "Ä" => "A", "Å" => "A", 
37                "Æ" => "A", "Ç" => "C", "È" => "E", "É" => "E", 
38                "Ê" => "E", "Ë" => "E", "Ì" => "I", "Í" => "I", 
39                "Î" => "I", "Ï" => "I", "Ð" => "D", "Ñ" => "N", 
40                "Ò" => "O", "Ó" => "O", "Ô" => "O", "Õ" => "O", 
41                "Ö" => "O", "Ø" => "O", "Ù" => "U", "Ú" => "U", 
42                "Û" => "U", "Ü" => "U", "Ý" => "Y", "ß" => "s", 
43                "à" => "a", "á" => "a", "â" => "a", "ã" => "a", 
44                "ä" => "a", "å" => "a", "æ" => "a", "ç" => "c", 
45                "è" => "e", "é" => "e", "ê" => "e", "ë" => "e", 
46                "ì" => "i", "í" => "i", "î" => "i", "ï" => "i", 
47                "ð" => "o", "ñ" => "n", "ò" => "o", "ó" => "o", 
48                "ô" => "o", "õ" => "o", "ö" => "o", "ø" => "o", 
49                "ù" => "u", "ú" => "u", "û" => "u", "ü" => "u", 
50                "ý" => "y", "ÿ" => "y");
51//------------------------------ verification and registration of modifications
52$error = array();
53if ( isset( $_POST['submit'] ) )
54{
55  $int_pattern = '/^\d+$/';
56  // deletion of site as asked
57  $site_deleted = false;
58  $query = 'SELECT id';
59  $query.= ' FROM '.SITES_TABLE;
60  $query.= " WHERE galleries_url <> './galleries/';";
61  $result = mysql_query( $query );
62  while ( $row = mysql_fetch_array( $result ) )
63  {
64    $site = 'delete_site_'.$row['id'];
65    if ( $_POST[$site] == 1 )
66    {
67      delete_site( $row['id'] );
68      $site_deleted = true;
69    }
70  }
71  // if any picture of this site were linked to another categories, we have
72  // to update the informations of those categories. To make it simple, we
73  // just update all the categories
74  if ( $site_deleted )
75  {
76    update_category( 'all' );
77    synchronize_all_users();
78  }
79  // thumbnail prefix must not contain accentuated characters
80  $old_prefix = $_POST['prefix_thumbnail'];
81  $prefix = strtr( $_POST['prefix_thumbnail'], $Caracs );
82  if ( $old_prefix != $prefix )
83  {
84    array_push( $error, $lang['conf_err_prefixe'] );
85  }
86  // mail must be formatted as follows : name@server.com
87  $pattern = '/^[\w-]+(\.[\w-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)+$/';
88  if ( !preg_match( $pattern, $_POST['mail_webmaster'] ) )
89  {
90    array_push( $error, $lang['conf_err_mail'] );
91  }
92  // periods must be integer values, they represents number of days
93  if (!preg_match($int_pattern, $_POST['recent_period'])
94      or $_POST['recent_period'] <= 0)
95  {
96    array_push( $error, $lang['err_periods'] );
97  }
98  // session_id size must be an integer between 4 and 50
99  if ( !preg_match( $int_pattern, $_POST['session_id_size'] )
100       or $_POST['session_id_size'] < 4
101       or $_POST['session_id_size'] > 50 )
102  {
103    array_push( $error, $lang['conf_err_sid_size'] );
104  }
105  // session_time must be an integer between 5 and 60, in minutes
106  if ( !preg_match( $int_pattern, $_POST['session_time'] )
107       or $_POST['session_time'] < 5
108       or $_POST['session_time'] > 60 )
109  {
110    array_push( $error, $lang['conf_err_sid_time'] );
111  }
112  // the number of comments per page must be an integer between 5 and 50
113  // included
114  if ( !preg_match( $int_pattern, $_POST['nb_comment_page'] )
115       or $_POST['nb_comment_page'] < 5
116       or $_POST['nb_comment_page'] > 50 )
117  {
118    array_push( $error, $lang['conf_err_comment_number'] );
119  }
120  // the maximum upload filesize must be an integer between 10 and 1000
121  if ( !preg_match( $int_pattern, $_POST['upload_maxfilesize'] )
122       or $_POST['upload_maxfilesize'] < 10
123       or $_POST['upload_maxfilesize'] > 1000 )
124  {
125    array_push( $error, $lang['conf_err_upload_maxfilesize'] );
126  }
127  // the maximum width of uploaded pictures must be an integer superior to
128  // 10
129  if ( !preg_match( $int_pattern, $_POST['upload_maxwidth'] )
130       or $_POST['upload_maxwidth'] < 10 )
131  {
132    array_push( $error, $lang['conf_err_upload_maxwidth'] );
133  }
134  // the maximum height  of uploaded pictures must be an integer superior to
135  // 10
136  if ( !preg_match( $int_pattern, $_POST['upload_maxheight'] )
137       or $_POST['upload_maxheight'] < 10 )
138  {
139    array_push( $error, $lang['conf_err_upload_maxheight'] );
140  }
141  // the maximum width of uploaded thumbnails must be an integer superior to
142  // 10
143  if ( !preg_match( $int_pattern, $_POST['upload_maxwidth_thumbnail'] )
144       or $_POST['upload_maxwidth_thumbnail'] < 10 )
145  {
146    array_push( $error, $lang['conf_err_upload_maxwidth_thumbnail'] );
147  }
148  // the maximum width of uploaded thumbnails must be an integer superior to
149  // 10
150  if ( !preg_match( $int_pattern, $_POST['upload_maxheight_thumbnail'] )
151       or $_POST['upload_maxheight_thumbnail'] < 10 )
152  {
153    array_push( $error, $lang['conf_err_upload_maxheight_thumbnail'] );
154  }
155
156/*  if ( $_POST['maxwidth'] != ''
157       and ( !preg_match( $int_pattern, $_POST['maxwidth'] )
158             or $_POST['maxwidth'] < 50 ) )
159  {
160    array_push( $error, $lang['err_maxwidth'] );
161  }
162  if ( $_POST['maxheight']
163       and ( !preg_match( $int_pattern, $_POST['maxheight'] )
164             or $_POST['maxheight'] < 50 ) )
165  {
166    array_push( $error, $lang['err_maxheight'] );
167  }*/
168  // updating configuraiton if no error found
169  if ( count( $error ) == 0 )
170  {
171    $result = mysql_query( "SELECT * FROM ".CONFIG_TABLE );
172    while ( $row = mysql_fetch_array( $result ) )
173        {
174          $config_name = $row['param'];
175          $conf[$config_name] = ( isset($_POST[$config_name]) ) ? $_POST[$config_name] : $row['value'];
176      if ( isset( $_POST[$config_name] ) )
177      {
178        $query = 'UPDATE '.CONFIG_TABLE;
179        $query.= " SET value = '". str_replace("\'", "''", $conf[$config_name]) ;
180        $query.= "' WHERE param = '$config_name'";
181        mysql_query( $query );
182      }
183    }
184  }
185}
186
187$access = ($conf['access']=='free')?'ACCESS_FREE':'ACCESS_RESTRICTED'; 
188$log = ($conf['log']=='true')?'HISTORY_YES':'HISTORY_NO'; 
189$mail_notif = ($conf['mail_notification']=='true')?'MAIL_NOTIFICATION_YES':'MAIL_NOTIFICATION_NO'; 
190$show_comments = ($conf['show_comments']=='true')?'SHOW_COMMENTS_YES':'SHOW_COMMENTS_NO';
191$comments_all = ($conf['comments_forall']=='true')?'COMMENTS_ALL_YES':'COMMENTS_ALL_NO';
192$comments_validation = ($conf['comments_validation']=='true')?'VALIDATE_COMMENTS_YES':'VALIDATE_COMMENTS_NO';
193$expand = ($conf['auto_expand']=='true')?'EXPAND_TREE_YES':'EXPAND_TREE_NO';
194$nb_comments = ($conf['show_nb_comments']=='true')?'NB_COMMENTS_YES':'NB_COMMENTS_NO';
195$upload = ($conf['upload_available']=='true')?'UPLOAD_YES':'UPLOAD_NO';
196$cookie = ($conf['authorize_cookies']=='true')?'COOKIE_YES':'COOKIE_NO';
197
198//----------------------------------------------------- template initialization
199$template->set_filenames( array('config'=>'admin/configuration.tpl') );
200
201$template->assign_vars(array(
202  'ADMIN_NAME'=>$conf['webmaster'],
203  'ADMIN_MAIL'=>$conf['mail_webmaster'],
204  'THUMBNAIL_PREFIX'=>$conf['prefix_thumbnail'],
205  'NB_COMMENTS_PAGE'=>$conf['nb_comment_page'],
206  'LANG_SELECT'=>language_select($conf['default_lang'], 'default_lang'),
207  'NB_IMAGE_LINE'=>$conf['nb_image_line'],
208  'NB_ROW_PAGE'=>$conf['nb_line_page'],
209  'STYLE_SELECT'=>style_select($conf['default_style'], 'default_style'),
210  'RECENT_PERIOD'=>$conf['recent_period'],
211  'UPLOAD_MAXSIZE'=>$conf['upload_maxfilesize'],
212  'UPLOAD_MAXWIDTH'=>$conf['upload_maxwidth'],
213  'UPLOAD_MAXHEIGHT'=>$conf['upload_maxheight'],
214  'TN_UPLOAD_MAXWIDTH'=>$conf['upload_maxwidth_thumbnail'],
215  'TN_UPLOAD_MAXHEIGHT'=>$conf['upload_maxheight_thumbnail'],
216  'SESSION_LENGTH'=>$conf['session_time'],
217  'SESSION_ID_SIZE'=>$conf['session_id_size'],
218 
219  $access=>'checked="checked"',
220  $log=>'checked="checked"',
221  $mail_notif=>'checked="checked"',
222  $show_comments=>'checked="checked"',
223  $comments_all=>'checked="checked"',
224  $comments_validation=>'checked="checked"',
225  $expand=>'checked="checked"',
226  $nb_comments=>'checked="checked"',
227  $upload=>'checked="checked"',
228  $cookie=>'checked="checked"',
229 
230  'L_CONFIRM'=>$lang['conf_confirmation'],
231  'L_CONF_GENERAL'=>$lang['conf_general_title'],
232  'L_ADMIN_NAME'=>$lang['conf_general_webmaster'],
233  'L_ADMIN_NAME_INFO'=>$lang['conf_general_webmaster_info'],
234  'L_ADMIN_MAIL'=>$lang['conf_general_mail'],
235  'L_ADMIN_MAIL_INFO'=>$lang['conf_general_mail_info'],
236  'L_THUMBNAIL_PREFIX'=>$lang['conf_general_prefix'],
237  'L_THUMBNAIL_PREFIX_INFO'=>$lang['conf_general_prefix_info'],
238  'L_ACCESS'=>$lang['conf_general_access'],
239  'L_ACCESS_INFO'=>$lang['conf_general_access_info'],
240  'L_ACCESS_FREE'=>$lang['conf_general_access_1'],
241  'L_ACCESS_RESTRICTED'=>$lang['conf_general_access_2'],
242  'L_CONF_HISTORY'=>$lang['history'],
243  'L_CONF_HISTORY_INFO'=>$lang['conf_general_log_info'],
244  'L_MAIL_NOTIFICATION'=>$lang['conf_general_mail_notification'],
245  'L_MAIL_NOTIFICATION_INFO'=>$lang['conf_general_mail_notification_info'],
246  'L_CONF_COMMENTS'=>$lang['conf_comments_title'],
247  'L_SHOW_COMMENTS'=>$lang['conf_comments_show_comments'],
248  'L_SHOW_COMMENTS_INFO'=>$lang['conf_comments_show_comments_info'],
249  'L_COMMENTS_ALL'=>$lang['conf_comments_forall'],
250  'L_COMMENTS_ALL_INFO'=>$lang['conf_comments_forall_info'],
251  'L_NB_COMMENTS_PAGE'=>$lang['conf_comments_comments_number'],
252  'L_NB_COMMENTS_PAGE_INFO'=>$lang['conf_comments_comments_number_info'],
253  'L_VALIDATE_COMMENTS'=>$lang['conf_comments_validation'],
254  'L_VALIDATE_COMMENTS_INFO'=>$lang['conf_comments_validation_info'],
255  'L_ABILITIES_SETTINGS'=>$lang['conf_default_title'],
256  'L_LANG_SELECT'=>$lang['customize_language'],
257  'L_LANG_SELECT_INFO'=>$lang['conf_default_language_info'],
258  'L_NB_IMAGE_LINE'=>$lang['customize_nb_image_per_row'],
259  'L_NB_IMAGE_LINE_INFO'=>$lang['conf_default_nb_image_per_row_info'],
260  'L_NB_ROW_PAGE'=>$lang['customize_nb_row_per_page'],
261  'L_NB_ROW_PAGE_INFO'=>$lang['conf_default_nb_row_per_page_info'],
262  'L_STYLE_SELECT'=>$lang['customize_theme'],
263  'L_STYLE_SELECT_INFO'=>$lang['conf_default_theme_info'],
264  'L_RECENT_PERIOD'=>$lang['customize_recent_period'],
265  'L_RECENT_PERIOD_INFO'=>$lang['conf_default_recent_period_info'],
266  'L_EXPAND_TREE'=>$lang['customize_expand'],
267  'L_EXPAND_TREE_INFO'=>$lang['conf_default_expand_info'],
268  'L_NB_COMMENTS'=>$lang['customize_show_nb_comments'],
269  'L_NB_COMMENTS_INFO'=>$lang['conf_default_show_nb_comments_info'],
270  'L_AUTH_UPLOAD'=>$lang['conf_upload_available'],
271  'L_AUTH_UPLOAD_INFO'=>$lang['conf_upload_available_info'],
272  'L_CONF_UPLOAD'=>$lang['conf_upload_title'],
273  'L_UPLOAD_MAXSIZE'=>$lang['conf_upload_maxfilesize'],
274  'L_UPLOAD_MAXSIZE_INFO'=>$lang['conf_upload_maxfilesize_info'],
275  'L_UPLOAD_MAXWIDTH'=>$lang['conf_upload_maxwidth'],
276  'L_UPLOAD_MAXWIDTH_INFO'=>$lang['conf_upload_maxwidth_info'],
277  'L_UPLOAD_MAXHEIGHT'=>$lang['conf_upload_maxheight'],
278  'L_UPLOAD_MAXHEIGHT_INFO'=>$lang['conf_upload_maxheight_info'],
279  'L_TN_UPLOAD_MAXWIDTH'=>$lang['conf_upload_maxwidth_thumbnail'],
280  'L_TN_UPLOAD_MAXWIDTH_INFO'=>$lang['conf_upload_maxwidth_thumbnail_info'],
281  'L_TN_UPLOAD_MAXHEIGHT'=>$lang['conf_upload_maxheight_thumbnail'],
282  'L_TN_UPLOAD_MAXHEIGHT_INFO'=>$lang['conf_upload_maxheight_thumbnail'],
283  'L_CONF_SESSION'=>$lang['conf_session_title'],
284  'L_COOKIE'=>$lang['conf_session_cookie'],
285  'L_COOKIE_INFO'=>$lang['conf_session_cookie_info'],
286  'L_SESSION_LENGTH'=>$lang['conf_session_time'],
287  'L_SESSION_LENGTH_INFO'=>$lang['conf_session_time_info'],
288  'L_SESSION_ID_SIZE'=>$lang['conf_session_size'],
289  'L_SESSION_ID_SIZE_INFO'=>$lang['conf_session_size_info'],
290  'L_YES'=>$lang['yes'],
291  'L_NO'=>$lang['no'],
292  'L_SUBMIT'=>$lang['submit'],
293 
294  'F_ACTION'=>add_session_id(PHPWG_ROOT_PATH.'admin.php?page=configuration')
295  ));
296
297//-------------------------------------------------------------- errors display
298if ( sizeof( $error ) != 0 )
299{
300  $template->assign_block_vars('errors',array());
301  for ( $i = 0; $i < sizeof( $error ); $i++ )
302  {
303    $template->assign_block_vars('errors.error',array('ERROR'=>$error[$i]));
304  }
305}
306elseif ( isset( $_POST['submit'] ) )
307{
308  $template->assign_block_vars('confirmation' ,array());
309}
310//------------------------------------------------ remote sites administration
311$query = 'select id,galleries_url';
312$query.= ' from '.SITES_TABLE;
313$query.= " where galleries_url <> './galleries/';";
314$result = mysql_query( $query );
315if ( mysql_num_rows( $result ) > 0 )
316{
317  $vtp->addSession( $sub, 'remote_sites' );
318  $i = 0;
319  while ( $row = mysql_fetch_array( $result ) )
320  {
321    $vtp->addSession( $sub, 'site' );
322    $vtp->setVar( $sub, 'site.url', $row['galleries_url'] );
323    $vtp->setVar( $sub, 'site.id', $row['id'] );
324    if ( $i == 0 )
325    {
326      $vtp->addSession( $sub, 'rowspan' );
327      $vtp->setVar( $sub, 'rowspan.nb_sites', mysql_num_rows( $result ) );
328      $vtp->closeSession( $sub, 'rowspan' );
329    }
330    $vtp->closeSession( $sub, 'site' );
331    $i++;
332  }
333  $vtp->closeSession( $sub, 'remote_sites' );
334}
335//----------------------------------------------------------- sending html code
336$template->assign_var_from_handle('ADMIN_CONTENT', 'config');
337?>
Note: See TracBrowser for help on using the repository browser.