source: trunk/admin/configuration.php @ 493

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

"show metadata" feature added : you can ask to show metadata (EXIF and IPTC)
on picture.php page. Metadata read functions were moved from
admin/include/functions_metadata.php to include/functions_metadata.inc.php

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 15.4 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-25 21:09:09 +0000 (Wed, 25 Aug 2004) $
10// | last modifier : $Author: z0rglub $
11// | revision      : $Revision: 493 $
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$show_exif = ($conf['show_exif']=='true')?'SHOW_EXIF_YES':'SHOW_EXIF_NO';
214$show_iptc = ($conf['show_iptc']=='true')?'SHOW_IPTC_YES':'SHOW_IPTC_NO';
215
216//----------------------------------------------------- template initialization
217$template->set_filenames( array('config'=>'admin/configuration.tpl') );
218
219$template->assign_vars(array(
220  'ADMIN_NAME'=>$conf['webmaster'],
221  'ADMIN_MAIL'=>$conf['mail_webmaster'],
222  'THUMBNAIL_PREFIX'=>$conf['prefix_thumbnail'],
223  'NB_COMMENTS_PAGE'=>$conf['nb_comment_page'],
224  'LANG_SELECT'=>language_select($conf['default_lang'], 'default_lang'),
225  'NB_IMAGE_LINE'=>$conf['nb_image_line'],
226  'NB_ROW_PAGE'=>$conf['nb_line_page'],
227  'STYLE_SELECT'=>style_select($conf['default_style'], 'default_style'),
228  'RECENT_PERIOD'=>$conf['recent_period'],
229  'UPLOAD_MAXSIZE'=>$conf['upload_maxfilesize'],
230  'UPLOAD_MAXWIDTH'=>$conf['upload_maxwidth'],
231  'UPLOAD_MAXHEIGHT'=>$conf['upload_maxheight'],
232  'TN_UPLOAD_MAXWIDTH'=>$conf['upload_maxwidth_thumbnail'],
233  'TN_UPLOAD_MAXHEIGHT'=>$conf['upload_maxheight_thumbnail'],
234  'SESSION_LENGTH'=>$conf['session_time'],
235  'SESSION_ID_SIZE'=>$conf['session_id_size'],
236 
237  $access=>'checked="checked"',
238  $log=>'checked="checked"',
239  $mail_notif=>'checked="checked"',
240  $show_comments=>'checked="checked"',
241  $comments_all=>'checked="checked"',
242  $comments_validation=>'checked="checked"',
243  $expand=>'checked="checked"',
244  $nb_comments=>'checked="checked"',
245  $upload=>'checked="checked"',
246  $cookie=>'checked="checked"',
247  $use_exif=>'checked="checked"',
248  $use_iptc=>'checked="checked"',
249  $show_exif=>'checked="checked"',
250  $show_iptc=>'checked="checked"',
251 
252  'L_CONFIRM'=>$lang['conf_confirmation'],
253  'L_CONF_GENERAL'=>$lang['conf_general_title'],
254  'L_ADMIN_NAME'=>$lang['conf_general_webmaster'],
255  'L_ADMIN_NAME_INFO'=>$lang['conf_general_webmaster_info'],
256  'L_ADMIN_MAIL'=>$lang['conf_general_mail'],
257  'L_ADMIN_MAIL_INFO'=>$lang['conf_general_mail_info'],
258  'L_THUMBNAIL_PREFIX'=>$lang['conf_general_prefix'],
259  'L_THUMBNAIL_PREFIX_INFO'=>$lang['conf_general_prefix_info'],
260  'L_ACCESS'=>$lang['conf_general_access'],
261  'L_ACCESS_INFO'=>$lang['conf_general_access_info'],
262  'L_ACCESS_FREE'=>$lang['conf_general_access_1'],
263  'L_ACCESS_RESTRICTED'=>$lang['conf_general_access_2'],
264  'L_CONF_HISTORY'=>$lang['history'],
265  'L_CONF_HISTORY_INFO'=>$lang['conf_general_log_info'],
266  'L_MAIL_NOTIFICATION'=>$lang['conf_general_mail_notification'],
267  'L_MAIL_NOTIFICATION_INFO'=>$lang['conf_general_mail_notification_info'],
268  'L_CONF_COMMENTS'=>$lang['conf_comments_title'],
269  'L_SHOW_COMMENTS'=>$lang['conf_comments_show_comments'],
270  'L_SHOW_COMMENTS_INFO'=>$lang['conf_comments_show_comments_info'],
271  'L_COMMENTS_ALL'=>$lang['conf_comments_forall'],
272  'L_COMMENTS_ALL_INFO'=>$lang['conf_comments_forall_info'],
273  'L_NB_COMMENTS_PAGE'=>$lang['conf_comments_comments_number'],
274  'L_NB_COMMENTS_PAGE_INFO'=>$lang['conf_comments_comments_number_info'],
275  'L_VALIDATE_COMMENTS'=>$lang['conf_comments_validation'],
276  'L_VALIDATE_COMMENTS_INFO'=>$lang['conf_comments_validation_info'],
277  'L_ABILITIES_SETTINGS'=>$lang['conf_default_title'],
278  'L_LANG_SELECT'=>$lang['customize_language'],
279  'L_LANG_SELECT_INFO'=>$lang['conf_default_language_info'],
280  'L_NB_IMAGE_LINE'=>$lang['customize_nb_image_per_row'],
281  'L_NB_IMAGE_LINE_INFO'=>$lang['conf_default_nb_image_per_row_info'],
282  'L_NB_ROW_PAGE'=>$lang['customize_nb_row_per_page'],
283  'L_NB_ROW_PAGE_INFO'=>$lang['conf_default_nb_row_per_page_info'],
284  'L_STYLE_SELECT'=>$lang['customize_theme'],
285  'L_STYLE_SELECT_INFO'=>$lang['conf_default_theme_info'],
286  'L_RECENT_PERIOD'=>$lang['customize_recent_period'],
287  'L_RECENT_PERIOD_INFO'=>$lang['conf_default_recent_period_info'],
288  'L_EXPAND_TREE'=>$lang['customize_expand'],
289  'L_EXPAND_TREE_INFO'=>$lang['conf_default_expand_info'],
290  'L_NB_COMMENTS'=>$lang['customize_show_nb_comments'],
291  'L_NB_COMMENTS_INFO'=>$lang['conf_default_show_nb_comments_info'],
292  'L_AUTH_UPLOAD'=>$lang['conf_upload_available'],
293  'L_AUTH_UPLOAD_INFO'=>$lang['conf_upload_available_info'],
294  'L_CONF_UPLOAD'=>$lang['conf_upload_title'],
295  'L_UPLOAD_MAXSIZE'=>$lang['conf_upload_maxfilesize'],
296  'L_UPLOAD_MAXSIZE_INFO'=>$lang['conf_upload_maxfilesize_info'],
297  'L_UPLOAD_MAXWIDTH'=>$lang['conf_upload_maxwidth'],
298  'L_UPLOAD_MAXWIDTH_INFO'=>$lang['conf_upload_maxwidth_info'],
299  'L_UPLOAD_MAXHEIGHT'=>$lang['conf_upload_maxheight'],
300  'L_UPLOAD_MAXHEIGHT_INFO'=>$lang['conf_upload_maxheight_info'],
301  'L_TN_UPLOAD_MAXWIDTH'=>$lang['conf_upload_maxwidth_thumbnail'],
302  'L_TN_UPLOAD_MAXWIDTH_INFO'=>$lang['conf_upload_maxwidth_thumbnail_info'],
303  'L_TN_UPLOAD_MAXHEIGHT'=>$lang['conf_upload_maxheight_thumbnail'],
304  'L_TN_UPLOAD_MAXHEIGHT_INFO'=>$lang['conf_upload_maxheight_thumbnail'],
305  'L_CONF_SESSION'=>$lang['conf_session_title'],
306  'L_COOKIE'=>$lang['conf_session_cookie'],
307  'L_COOKIE_INFO'=>$lang['conf_session_cookie_info'],
308  'L_SESSION_LENGTH'=>$lang['conf_session_time'],
309  'L_SESSION_LENGTH_INFO'=>$lang['conf_session_time_info'],
310  'L_SESSION_ID_SIZE'=>$lang['conf_session_size'],
311  'L_SESSION_ID_SIZE_INFO'=>$lang['conf_session_size_info'],
312  'L_YES'=>$lang['yes'],
313  'L_NO'=>$lang['no'],
314  'L_SUBMIT'=>$lang['submit'],
315  'L_CONF_METADATA'=>$lang['conf_metadata_title'],
316  'L_USE_EXIF'=>$lang['conf_use_exif'],
317  'L_USE_EXIF_INFO'=>$lang['conf_use_exif_info'],
318  'L_USE_IPTC'=>$lang['conf_use_iptc'],
319  'L_USE_IPTC_INFO'=>$lang['conf_use_iptc_info'],
320  'L_SHOW_EXIF'=>$lang['conf_show_exif'],
321  'L_SHOW_EXIF_INFO'=>$lang['conf_show_exif_info'],
322  'L_SHOW_IPTC'=>$lang['conf_show_iptc'],
323  'L_SHOW_IPTC_INFO'=>$lang['conf_show_iptc_info'],
324 
325  'F_ACTION'=>add_session_id(PHPWG_ROOT_PATH.'admin.php?page=configuration')
326                         ));
327
328//-------------------------------------------------------------- errors display
329if ( sizeof( $error ) != 0 )
330{
331  $template->assign_block_vars('errors',array());
332  for ( $i = 0; $i < sizeof( $error ); $i++ )
333  {
334    $template->assign_block_vars('errors.error',array('ERROR'=>$error[$i]));
335  }
336}
337elseif ( isset( $_POST['submit'] ) )
338{
339  $template->assign_block_vars('confirmation' ,array());
340}
341//------------------------------------------------ remote sites administration
342$query = 'select id,galleries_url';
343$query.= ' from '.SITES_TABLE;
344$query.= " where galleries_url <> './galleries/';";
345$result = mysql_query( $query );
346if ( mysql_num_rows( $result ) > 0 )
347{
348  $vtp->addSession( $sub, 'remote_sites' );
349  $i = 0;
350  while ( $row = mysql_fetch_array( $result ) )
351  {
352    $vtp->addSession( $sub, 'site' );
353    $vtp->setVar( $sub, 'site.url', $row['galleries_url'] );
354    $vtp->setVar( $sub, 'site.id', $row['id'] );
355    if ( $i == 0 )
356    {
357      $vtp->addSession( $sub, 'rowspan' );
358      $vtp->setVar( $sub, 'rowspan.nb_sites', mysql_num_rows( $result ) );
359      $vtp->closeSession( $sub, 'rowspan' );
360    }
361    $vtp->closeSession( $sub, 'site' );
362    $i++;
363  }
364  $vtp->closeSession( $sub, 'remote_sites' );
365}
366//----------------------------------------------------------- sending html code
367$template->assign_var_from_handle('ADMIN_CONTENT', 'config');
368?>
Note: See TracBrowser for help on using the repository browser.