[354] | 1 | <?php |
---|
| 2 | // +-----------------------------------------------------------------------+ |
---|
[593] | 3 | // | PhpWebGallery - a PHP based picture gallery | |
---|
| 4 | // | Copyright (C) 2002-2003 Pierrick LE GALL - pierrick@phpwebgallery.net | |
---|
[1075] | 5 | // | Copyright (C) 2003-2006 PhpWebGallery Team - http://phpwebgallery.net | |
---|
[354] | 6 | // +-----------------------------------------------------------------------+ |
---|
[593] | 7 | // | branch : BSF (Best So Far) |
---|
[354] | 8 | // | file : $RCSfile$ |
---|
| 9 | // | last update : $Date: 2006-03-22 01:01:47 +0000 (Wed, 22 Mar 2006) $ |
---|
| 10 | // | last modifier : $Author: rvelices $ |
---|
| 11 | // | revision : $Revision: 1092 $ |
---|
| 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 | // +-----------------------------------------------------------------------+ |
---|
[383] | 27 | |
---|
[650] | 28 | if (!defined('PHPWG_ROOT_PATH')) |
---|
[364] | 29 | { |
---|
[650] | 30 | die('Hacking attempt!'); |
---|
[364] | 31 | } |
---|
| 32 | // determine the initial instant to indicate the generation time of this page |
---|
[354] | 33 | $t1 = explode( ' ', microtime() ); |
---|
| 34 | $t2 = explode( '.', $t1[0] ); |
---|
| 35 | $t2 = $t1[1].'.'.$t2[1]; |
---|
| 36 | |
---|
| 37 | set_magic_quotes_runtime(0); // Disable magic_quotes_runtime |
---|
| 38 | |
---|
| 39 | // |
---|
[359] | 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. |
---|
[354] | 42 | // |
---|
| 43 | if( !get_magic_quotes_gpc() ) |
---|
| 44 | { |
---|
[359] | 45 | if( is_array( $_GET ) ) |
---|
[354] | 46 | { |
---|
[359] | 47 | while( list($k, $v) = each($_GET) ) |
---|
[354] | 48 | { |
---|
[359] | 49 | if( is_array($_GET[$k]) ) |
---|
| 50 | { |
---|
| 51 | while( list($k2, $v2) = each($_GET[$k]) ) |
---|
[354] | 52 | { |
---|
[359] | 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); |
---|
[354] | 63 | } |
---|
[1092] | 64 | |
---|
[359] | 65 | if( is_array($_POST) ) |
---|
[354] | 66 | { |
---|
[359] | 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 | } |
---|
[354] | 81 | } |
---|
[359] | 82 | @reset($_POST); |
---|
[354] | 83 | } |
---|
| 84 | |
---|
[359] | 85 | if( is_array($_COOKIE) ) |
---|
[354] | 86 | { |
---|
[359] | 87 | while( list($k, $v) = each($_COOKIE) ) |
---|
[354] | 88 | { |
---|
[359] | 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 | } |
---|
[354] | 101 | } |
---|
[359] | 102 | @reset($_COOKIE); |
---|
[354] | 103 | } |
---|
| 104 | } |
---|
| 105 | |
---|
| 106 | // |
---|
[359] | 107 | // Define some basic configuration arrays this also prevents malicious |
---|
| 108 | // rewriting of language and otherarray values via URI params |
---|
[354] | 109 | // |
---|
| 110 | $conf = array(); |
---|
| 111 | $page = array(); |
---|
| 112 | $user = array(); |
---|
| 113 | $lang = array(); |
---|
| 114 | |
---|
[364] | 115 | |
---|
[766] | 116 | @include(PHPWG_ROOT_PATH .'include/mysql.inc.php'); |
---|
[650] | 117 | if (!defined('PHPWG_INSTALLED')) |
---|
[354] | 118 | { |
---|
[650] | 119 | header('Location: install.php'); |
---|
[359] | 120 | exit; |
---|
[354] | 121 | } |
---|
| 122 | |
---|
[770] | 123 | include(PHPWG_ROOT_PATH . 'include/config_default.inc.php'); |
---|
| 124 | @include(PHPWG_ROOT_PATH. 'include/config_local.inc.php'); |
---|
[808] | 125 | include(PHPWG_ROOT_PATH . 'include/constants.php'); |
---|
[364] | 126 | include(PHPWG_ROOT_PATH . 'include/functions.inc.php'); |
---|
| 127 | include(PHPWG_ROOT_PATH . 'include/template.php'); |
---|
| 128 | |
---|
[354] | 129 | // Database connection |
---|
[681] | 130 | mysql_connect( $cfgHote, $cfgUser, $cfgPassword ) |
---|
[512] | 131 | or die ( "Could not connect to database server" ); |
---|
[681] | 132 | mysql_select_db( $cfgBase ) |
---|
[359] | 133 | or die ( "Could not connect to database" ); |
---|
[953] | 134 | |
---|
[1076] | 135 | if ($conf['check_upgrade_feed']) |
---|
| 136 | { |
---|
| 137 | // retrieve already applied upgrades |
---|
| 138 | $query = ' |
---|
| 139 | SELECT id |
---|
| 140 | FROM '.UPGRADE_TABLE.' |
---|
| 141 | ;'; |
---|
| 142 | $applied = array_from_query($query, 'id'); |
---|
| 143 | |
---|
| 144 | // retrieve existing upgrades |
---|
| 145 | $existing = get_available_upgrade_ids(); |
---|
| 146 | |
---|
| 147 | // which upgrades need to be applied? |
---|
| 148 | if (count(array_diff($existing, $applied)) > 0) |
---|
| 149 | { |
---|
| 150 | ob_start();// buffer output so that cookies work |
---|
| 151 | echo |
---|
| 152 | '<p>' |
---|
| 153 | .'Some database upgrades are missing, ' |
---|
| 154 | .'<a href="'.PHPWG_ROOT_PATH.'upgrade_feed.php">upgrade now</a>' |
---|
| 155 | .'</p>' |
---|
| 156 | ; |
---|
| 157 | } |
---|
| 158 | } |
---|
| 159 | |
---|
[354] | 160 | // |
---|
[394] | 161 | // Setup gallery wide options, if this fails then we output a CRITICAL_ERROR |
---|
| 162 | // since basic gallery information is not available |
---|
[354] | 163 | // |
---|
[541] | 164 | $query = ' |
---|
| 165 | SELECT param,value |
---|
| 166 | FROM '.CONFIG_TABLE.' |
---|
| 167 | ;'; |
---|
[650] | 168 | if (!($result = pwg_query($query))) |
---|
[354] | 169 | { |
---|
| 170 | die("Could not query config information"); |
---|
| 171 | } |
---|
| 172 | |
---|
[383] | 173 | while ( $row =mysql_fetch_array( $result ) ) |
---|
| 174 | { |
---|
| 175 | if ( isset( $row['value'] ) ) |
---|
[354] | 176 | { |
---|
[383] | 177 | $conf[$row['param']] = $row['value']; |
---|
[354] | 178 | } |
---|
[383] | 179 | else |
---|
| 180 | { |
---|
| 181 | $conf[$row['param']] = ''; |
---|
| 182 | } |
---|
| 183 | // If the field is true or false, the variable is transformed into a |
---|
| 184 | // boolean value. |
---|
| 185 | if ( $conf[$row['param']] == 'true' or $conf[$row['param']] == 'false' ) |
---|
| 186 | { |
---|
| 187 | $conf[$row['param']] = get_boolean( $conf[$row['param']] ); |
---|
| 188 | } |
---|
[354] | 189 | } |
---|
| 190 | |
---|
[650] | 191 | include(PHPWG_ROOT_PATH.'include/user.inc.php'); |
---|
[808] | 192 | |
---|
| 193 | // language files |
---|
[879] | 194 | include_once(get_language_filepath('common.lang.php')); |
---|
[808] | 195 | |
---|
| 196 | if (defined('IN_ADMIN') and IN_ADMIN) |
---|
| 197 | { |
---|
[879] | 198 | include_once(get_language_filepath('admin.lang.php')); |
---|
[808] | 199 | } |
---|
| 200 | |
---|
[1036] | 201 | if ($conf['gallery_locked']) |
---|
| 202 | { |
---|
[1052] | 203 | ob_start(); // make sure we can send cookies |
---|
[1036] | 204 | echo |
---|
| 205 | '<div style="text-align:center;">' |
---|
[1052] | 206 | .$lang['gallery_locked_message']; |
---|
| 207 | echo '<a href="'.PHPWG_ROOT_PATH.'identification.php">.</a>'; |
---|
| 208 | echo '</div>'; |
---|
[1036] | 209 | |
---|
[1052] | 210 | if ( basename($_SERVER["PHP_SELF"]) != 'identification.php' |
---|
[1070] | 211 | and !is_admin() ) |
---|
[1036] | 212 | { |
---|
| 213 | exit(); |
---|
| 214 | } |
---|
| 215 | } |
---|
| 216 | |
---|
[808] | 217 | // only now we can set the localized username of the guest user (and not in |
---|
| 218 | // include/user.inc.php) |
---|
| 219 | if ($user['is_the_guest']) |
---|
| 220 | { |
---|
| 221 | $user['username'] = $lang['guest']; |
---|
| 222 | } |
---|
| 223 | |
---|
[960] | 224 | // include template/theme configuration |
---|
| 225 | list($user['template'], $user['theme']) = explode('/', $user['template']); |
---|
| 226 | // TODO : replace initial $user['template'] by $user['layout'] |
---|
| 227 | |
---|
[1036] | 228 | include( |
---|
| 229 | PHPWG_ROOT_PATH |
---|
| 230 | .'template/'.$user['template'] |
---|
| 231 | .'/theme/'.$user['theme'] |
---|
| 232 | .'/themeconf.inc.php' |
---|
| 233 | ); |
---|
[960] | 234 | |
---|
[1085] | 235 | if (is_adviser()) |
---|
| 236 | { |
---|
| 237 | echo ' |
---|
| 238 | <div class="titrePage"> |
---|
| 239 | <h2> |
---|
| 240 | <div style="text-align:center;">'.$lang['adviser_mode_enabled'].' |
---|
| 241 | </div> |
---|
| 242 | </h2> |
---|
| 243 | </div> |
---|
| 244 | '; |
---|
| 245 | } |
---|
| 246 | |
---|
[808] | 247 | // template instance |
---|
| 248 | $template = new Template(PHPWG_ROOT_PATH.'template/'.$user['template']); |
---|
[362] | 249 | ?> |
---|