source: tags/build-A01/include/common.inc.php @ 16897

Last change on this file since 16897 was 1699, checked in by rub, 17 years ago

Feature Issue ID 0000496: Integrate MOD add_index on PWG with plugin.lang.php

Add some plugin triggers:

o for help
o for language
o for site manager
o for advanced features

Allow to launch directly plugin page (without section key)

Add add_index plugin, available on site manager and advanced features

Configuration page and best help must be coming soon.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 7.1 KB
Line 
1<?php
2// +-----------------------------------------------------------------------+
3// | PhpWebGallery - a PHP based picture gallery                           |
4// | Copyright (C) 2002-2003 Pierrick LE GALL - pierrick@phpwebgallery.net |
5// | Copyright (C) 2003-2006 PhpWebGallery Team - http://phpwebgallery.net |
6// +-----------------------------------------------------------------------+
7// | branch        : BSF (Best So Far)
8// | file          : $Id: common.inc.php 1699 2007-01-08 00:16:10Z rub $
9// | last update   : $Date: 2007-01-08 00:16:10 +0000 (Mon, 08 Jan 2007) $
10// | last modifier : $Author: rub $
11// | revision      : $Revision: 1699 $
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// determine the initial instant to indicate the generation time of this page
33$t1 = explode( ' ', microtime() );
34$t2 = explode( '.', $t1[0] );
35$t2 = $t1[1].'.'.$t2[1];
36
37set_magic_quotes_runtime(0); // Disable magic_quotes_runtime
38
39//
40// addslashes to vars if magic_quotes_gpc is off this is a security
41// precaution to prevent someone trying to break out of a SQL statement.
42//
43if( !get_magic_quotes_gpc() )
44{
45  if( is_array( $_GET ) )
46  {
47    while( list($k, $v) = each($_GET) )
48    {
49      if( is_array($_GET[$k]) )
50      {
51        while( list($k2, $v2) = each($_GET[$k]) )
52        {
53          $_GET[$k][$k2] = addslashes($v2);
54        }
55        @reset($_GET[$k]);
56      }
57      else
58      {
59        $_GET[$k] = addslashes($v);
60      }
61    }
62    @reset($_GET);
63  }
64
65  if( is_array($_POST) )
66  {
67    while( list($k, $v) = each($_POST) )
68    {
69      if( is_array($_POST[$k]) )
70      {
71        while( list($k2, $v2) = each($_POST[$k]) )
72        {
73          $_POST[$k][$k2] = addslashes($v2);
74        }
75        @reset($_POST[$k]);
76      }
77      else
78      {
79        $_POST[$k] = addslashes($v);
80      }
81    }
82    @reset($_POST);
83  }
84
85  if( is_array($_COOKIE) )
86  {
87    while( list($k, $v) = each($_COOKIE) )
88    {
89      if( is_array($_COOKIE[$k]) )
90      {
91        while( list($k2, $v2) = each($_COOKIE[$k]) )
92        {
93          $_COOKIE[$k][$k2] = addslashes($v2);
94        }
95        @reset($_COOKIE[$k]);
96      }
97      else
98      {
99        $_COOKIE[$k] = addslashes($v);
100      }
101    }
102    @reset($_COOKIE);
103  }
104}
105
106//
107// Define some basic configuration arrays this also prevents malicious
108// rewriting of language and otherarray values via URI params
109//
110$conf = array();
111$page = array();
112$user = array();
113$lang = array();
114$header_msgs = array();
115$header_notes = array();
116
117@include(PHPWG_ROOT_PATH .'include/mysql.inc.php');
118if (!defined('PHPWG_INSTALLED'))
119{
120  header('Location: install.php');
121  exit;
122}
123
124include(PHPWG_ROOT_PATH . 'include/config_default.inc.php');
125@include(PHPWG_ROOT_PATH. 'include/config_local.inc.php');
126include(PHPWG_ROOT_PATH . 'include/constants.php');
127include(PHPWG_ROOT_PATH . 'include/functions.inc.php');
128include(PHPWG_ROOT_PATH . 'include/template.php');
129
130// Database connection
131mysql_connect( $cfgHote, $cfgUser, $cfgPassword )
132or die ( "Could not connect to database server" );
133mysql_select_db( $cfgBase )
134or die ( "Could not connect to database" );
135
136//
137// Setup gallery wide options, if this fails then we output a CRITICAL_ERROR
138// since basic gallery information is not available
139//
140load_conf_from_db();
141load_plugins();
142
143include(PHPWG_ROOT_PATH.'include/user.inc.php');
144
145
146// language files
147include_once(get_language_filepath('common.lang.php'));
148if (defined('IN_ADMIN') and IN_ADMIN)
149{
150  include_once(get_language_filepath('admin.lang.php'));
151}
152trigger_action('loading_lang');
153@include_once(get_language_filepath('local.lang.php'));
154
155// only now we can set the localized username of the guest user (and not in
156// include/user.inc.php)
157if ($user['is_the_guest'])
158{
159  $user['username'] = $lang['guest'];
160}
161
162// template instance
163$template = new Template(PHPWG_ROOT_PATH.'template/'.$user['template'], $user['theme'] );
164
165if ($conf['gallery_locked'])
166{
167  $header_msgs[] = $lang['gallery_locked_message'];
168
169  if ( script_basename() != 'identification' and !is_admin() )
170  {
171    //next line required if PATH_INFO (no ? in url) but won't work for scripts outside PWG
172    $page['root_path'] = cookie_path();
173    echo $lang['gallery_locked_message']
174      .'<a href="'.get_root_url().'identification.php">.</a>';
175    exit();
176  }
177}
178
179if ($user['is_the_guest'] and !$conf['guest_access']
180    and !in_array( script_basename(),
181                      // Array of basename without file extention
182                      array('identification',
183                            'password',
184                            'register'
185                        )
186                  )
187    )
188{
189  //next line required if PATH_INFO (no ? in url) but won't work for scripts outside PWG
190  $page['root_path'] = cookie_path();
191  redirect (get_root_url().'identification.php');
192}
193
194if ($conf['check_upgrade_feed']
195    and defined('PHPWG_IN_UPGRADE')
196    and PHPWG_IN_UPGRADE)
197{
198
199  // retrieve already applied upgrades
200  $query = '
201SELECT id
202  FROM '.UPGRADE_TABLE.'
203;';
204  $applied = array_from_query($query, 'id');
205
206  // retrieve existing upgrades
207  $existing = get_available_upgrade_ids();
208
209  // which upgrades need to be applied?
210  if (count(array_diff($existing, $applied)) > 0)
211  {
212    //next line required if PATH_INFO (no ? in url) but won't work for scripts outside PWG
213    $page['root_path'] = cookie_path();
214    $header_msgs[] = 'Some database upgrades are missing, '
215      .'<a href="'.get_root_url().'upgrade_feed.php">upgrade now</a>';
216  }
217}
218
219if (is_adviser())
220{
221  $header_msgs[] = $lang['adviser_mode_enabled'];
222}
223
224if (count($header_msgs) > 0)
225{
226  $template->assign_block_vars('header_msgs',array());
227  foreach ($header_msgs as $header_msg)
228  {
229    $template->assign_block_vars('header_msgs.header_msg',
230                                 array('HEADER_MSG'=>$header_msg));
231  }
232}
233
234if (!defined('IN_ADMIN') or !IN_ADMIN)
235{
236  include(PHPWG_ROOT_PATH.'include/functions_filter.inc.php');
237  include(PHPWG_ROOT_PATH.'include/filter.inc.php');
238}
239
240if (isset($conf['header_notes']))
241{
242  $header_notes = array_merge($header_notes, $conf['header_notes']);
243}
244
245// default event handlers
246add_event_handler('render_comment_content', 'parse_comment_content');
247trigger_action('init');
248?>
Note: See TracBrowser for help on using the repository browser.