source: trunk/admin/configuration.php @ 486

Last change on this file since 486 was 486, checked in by z0rglub, 20 years ago
  • add files metadata support : use info for database fields
  • distinction between directories synchronization and metadata synchronization
  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 15.0 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-08-21 12:52:43 +0000 (Sat, 21 Aug 2004) $
10// | last modifier : $Author: z0rglub $
11// | revision      : $Revision: 486 $
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      if (isset($_POST[$config_name]))
176      {
177        $conf[$config_name] = $_POST[$config_name];
178      }
179      else
180      {
181        $conf[$config_name] = $row['value'];
182      }
183
184      if (isset($_POST[$config_name]))
185      {
186        $query = '
187UPDATE '.CONFIG_TABLE.'
188  SET value = \''. str_replace("\'", "''", $conf[$config_name]).'\'
189  WHERE param = \''.$config_name.'\'
190;';
191        mysql_query($query);
192      }
193    }
194  }
195}
196
197// echo '<pre>';
198// print_r($conf);
199// echo '</pre>';
200
201$access = ($conf['access']=='free')?'ACCESS_FREE':'ACCESS_RESTRICTED'; 
202$log = ($conf['log']=='true')?'HISTORY_YES':'HISTORY_NO'; 
203$mail_notif = ($conf['mail_notification']=='true')?'MAIL_NOTIFICATION_YES':'MAIL_NOTIFICATION_NO'; 
204$show_comments = ($conf['show_comments']=='true')?'SHOW_COMMENTS_YES':'SHOW_COMMENTS_NO';
205$comments_all = ($conf['comments_forall']=='true')?'COMMENTS_ALL_YES':'COMMENTS_ALL_NO';
206$comments_validation = ($conf['comments_validation']=='true')?'VALIDATE_COMMENTS_YES':'VALIDATE_COMMENTS_NO';
207$expand = ($conf['auto_expand']=='true')?'EXPAND_TREE_YES':'EXPAND_TREE_NO';
208$nb_comments = ($conf['show_nb_comments']=='true')?'NB_COMMENTS_YES':'NB_COMMENTS_NO';
209$upload = ($conf['upload_available']=='true')?'UPLOAD_YES':'UPLOAD_NO';
210$cookie = ($conf['authorize_cookies']=='true')?'COOKIE_YES':'COOKIE_NO';
211$use_exif = ($conf['use_exif']=='true')?'USE_EXIF_YES':'USE_EXIF_NO';
212$use_iptc = ($conf['use_iptc']=='true')?'USE_IPTC_YES':'USE_IPTC_NO';
213
214//----------------------------------------------------- template initialization
215$template->set_filenames( array('config'=>'admin/configuration.tpl') );
216
217$template->assign_vars(array(
218  'ADMIN_NAME'=>$conf['webmaster'],
219  'ADMIN_MAIL'=>$conf['mail_webmaster'],
220  'THUMBNAIL_PREFIX'=>$conf['prefix_thumbnail'],
221  'NB_COMMENTS_PAGE'=>$conf['nb_comment_page'],
222  'LANG_SELECT'=>language_select($conf['default_lang'], 'default_lang'),
223  'NB_IMAGE_LINE'=>$conf['nb_image_line'],
224  'NB_ROW_PAGE'=>$conf['nb_line_page'],
225  'STYLE_SELECT'=>style_select($conf['default_style'], 'default_style'),
226  'RECENT_PERIOD'=>$conf['recent_period'],
227  'UPLOAD_MAXSIZE'=>$conf['upload_maxfilesize'],
228  'UPLOAD_MAXWIDTH'=>$conf['upload_maxwidth'],
229  'UPLOAD_MAXHEIGHT'=>$conf['upload_maxheight'],
230  'TN_UPLOAD_MAXWIDTH'=>$conf['upload_maxwidth_thumbnail'],
231  'TN_UPLOAD_MAXHEIGHT'=>$conf['upload_maxheight_thumbnail'],
232  'SESSION_LENGTH'=>$conf['session_time'],
233  'SESSION_ID_SIZE'=>$conf['session_id_size'],
234 
235  $access=>'checked="checked"',
236  $log=>'checked="checked"',
237  $mail_notif=>'checked="checked"',
238  $show_comments=>'checked="checked"',
239  $comments_all=>'checked="checked"',
240  $comments_validation=>'checked="checked"',
241  $expand=>'checked="checked"',
242  $nb_comments=>'checked="checked"',
243  $upload=>'checked="checked"',
244  $cookie=>'checked="checked"',
245  $use_exif=>'checked="checked"',
246  $use_iptc=>'checked="checked"',
247 
248  'L_CONFIRM'=>$lang['conf_confirmation'],
249  'L_CONF_GENERAL'=>$lang['conf_general_title'],
250  'L_ADMIN_NAME'=>$lang['conf_general_webmaster'],
251  'L_ADMIN_NAME_INFO'=>$lang['conf_general_webmaster_info'],
252  'L_ADMIN_MAIL'=>$lang['conf_general_mail'],
253  'L_ADMIN_MAIL_INFO'=>$lang['conf_general_mail_info'],
254  'L_THUMBNAIL_PREFIX'=>$lang['conf_general_prefix'],
255  'L_THUMBNAIL_PREFIX_INFO'=>$lang['conf_general_prefix_info'],
256  'L_ACCESS'=>$lang['conf_general_access'],
257  'L_ACCESS_INFO'=>$lang['conf_general_access_info'],
258  'L_ACCESS_FREE'=>$lang['conf_general_access_1'],
259  'L_ACCESS_RESTRICTED'=>$lang['conf_general_access_2'],
260  'L_CONF_HISTORY'=>$lang['history'],
261  'L_CONF_HISTORY_INFO'=>$lang['conf_general_log_info'],
262  'L_MAIL_NOTIFICATION'=>$lang['conf_general_mail_notification'],
263  'L_MAIL_NOTIFICATION_INFO'=>$lang['conf_general_mail_notification_info'],
264  'L_CONF_COMMENTS'=>$lang['conf_comments_title'],
265  'L_SHOW_COMMENTS'=>$lang['conf_comments_show_comments'],
266  'L_SHOW_COMMENTS_INFO'=>$lang['conf_comments_show_comments_info'],
267  'L_COMMENTS_ALL'=>$lang['conf_comments_forall'],
268  'L_COMMENTS_ALL_INFO'=>$lang['conf_comments_forall_info'],
269  'L_NB_COMMENTS_PAGE'=>$lang['conf_comments_comments_number'],
270  'L_NB_COMMENTS_PAGE_INFO'=>$lang['conf_comments_comments_number_info'],
271  'L_VALIDATE_COMMENTS'=>$lang['conf_comments_validation'],
272  'L_VALIDATE_COMMENTS_INFO'=>$lang['conf_comments_validation_info'],
273  'L_ABILITIES_SETTINGS'=>$lang['conf_default_title'],
274  'L_LANG_SELECT'=>$lang['customize_language'],
275  'L_LANG_SELECT_INFO'=>$lang['conf_default_language_info'],
276  'L_NB_IMAGE_LINE'=>$lang['customize_nb_image_per_row'],
277  'L_NB_IMAGE_LINE_INFO'=>$lang['conf_default_nb_image_per_row_info'],
278  'L_NB_ROW_PAGE'=>$lang['customize_nb_row_per_page'],
279  'L_NB_ROW_PAGE_INFO'=>$lang['conf_default_nb_row_per_page_info'],
280  'L_STYLE_SELECT'=>$lang['customize_theme'],
281  'L_STYLE_SELECT_INFO'=>$lang['conf_default_theme_info'],
282  'L_RECENT_PERIOD'=>$lang['customize_recent_period'],
283  'L_RECENT_PERIOD_INFO'=>$lang['conf_default_recent_period_info'],
284  'L_EXPAND_TREE'=>$lang['customize_expand'],
285  'L_EXPAND_TREE_INFO'=>$lang['conf_default_expand_info'],
286  'L_NB_COMMENTS'=>$lang['customize_show_nb_comments'],
287  'L_NB_COMMENTS_INFO'=>$lang['conf_default_show_nb_comments_info'],
288  'L_AUTH_UPLOAD'=>$lang['conf_upload_available'],
289  'L_AUTH_UPLOAD_INFO'=>$lang['conf_upload_available_info'],
290  'L_CONF_UPLOAD'=>$lang['conf_upload_title'],
291  'L_UPLOAD_MAXSIZE'=>$lang['conf_upload_maxfilesize'],
292  'L_UPLOAD_MAXSIZE_INFO'=>$lang['conf_upload_maxfilesize_info'],
293  'L_UPLOAD_MAXWIDTH'=>$lang['conf_upload_maxwidth'],
294  'L_UPLOAD_MAXWIDTH_INFO'=>$lang['conf_upload_maxwidth_info'],
295  'L_UPLOAD_MAXHEIGHT'=>$lang['conf_upload_maxheight'],
296  'L_UPLOAD_MAXHEIGHT_INFO'=>$lang['conf_upload_maxheight_info'],
297  'L_TN_UPLOAD_MAXWIDTH'=>$lang['conf_upload_maxwidth_thumbnail'],
298  'L_TN_UPLOAD_MAXWIDTH_INFO'=>$lang['conf_upload_maxwidth_thumbnail_info'],
299  'L_TN_UPLOAD_MAXHEIGHT'=>$lang['conf_upload_maxheight_thumbnail'],
300  'L_TN_UPLOAD_MAXHEIGHT_INFO'=>$lang['conf_upload_maxheight_thumbnail'],
301  'L_CONF_SESSION'=>$lang['conf_session_title'],
302  'L_COOKIE'=>$lang['conf_session_cookie'],
303  'L_COOKIE_INFO'=>$lang['conf_session_cookie_info'],
304  'L_SESSION_LENGTH'=>$lang['conf_session_time'],
305  'L_SESSION_LENGTH_INFO'=>$lang['conf_session_time_info'],
306  'L_SESSION_ID_SIZE'=>$lang['conf_session_size'],
307  'L_SESSION_ID_SIZE_INFO'=>$lang['conf_session_size_info'],
308  'L_YES'=>$lang['yes'],
309  'L_NO'=>$lang['no'],
310  'L_SUBMIT'=>$lang['submit'],
311  'L_CONF_METADATA'=>$lang['conf_metadata_title'],
312  'L_USE_EXIF'=>$lang['conf_use_exif'],
313  'L_USE_EXIF_INFO'=>$lang['conf_use_exif_info'],
314  'L_USE_IPTC'=>$lang['conf_use_iptc'],
315  'L_USE_IPTC_INFO'=>$lang['conf_use_iptc_info'],
316 
317  'F_ACTION'=>add_session_id(PHPWG_ROOT_PATH.'admin.php?page=configuration')
318                         ));
319
320//-------------------------------------------------------------- errors display
321if ( sizeof( $error ) != 0 )
322{
323  $template->assign_block_vars('errors',array());
324  for ( $i = 0; $i < sizeof( $error ); $i++ )
325  {
326    $template->assign_block_vars('errors.error',array('ERROR'=>$error[$i]));
327  }
328}
329elseif ( isset( $_POST['submit'] ) )
330{
331  $template->assign_block_vars('confirmation' ,array());
332}
333//------------------------------------------------ remote sites administration
334$query = 'select id,galleries_url';
335$query.= ' from '.SITES_TABLE;
336$query.= " where galleries_url <> './galleries/';";
337$result = mysql_query( $query );
338if ( mysql_num_rows( $result ) > 0 )
339{
340  $vtp->addSession( $sub, 'remote_sites' );
341  $i = 0;
342  while ( $row = mysql_fetch_array( $result ) )
343  {
344    $vtp->addSession( $sub, 'site' );
345    $vtp->setVar( $sub, 'site.url', $row['galleries_url'] );
346    $vtp->setVar( $sub, 'site.id', $row['id'] );
347    if ( $i == 0 )
348    {
349      $vtp->addSession( $sub, 'rowspan' );
350      $vtp->setVar( $sub, 'rowspan.nb_sites', mysql_num_rows( $result ) );
351      $vtp->closeSession( $sub, 'rowspan' );
352    }
353    $vtp->closeSession( $sub, 'site' );
354    $i++;
355  }
356  $vtp->closeSession( $sub, 'remote_sites' );
357}
358//----------------------------------------------------------- sending html code
359$template->assign_var_from_handle('ADMIN_CONTENT', 'config');
360?>
Note: See TracBrowser for help on using the repository browser.