diff options
author | rvelices <rv-github@modusoptimus.com> | 2006-10-20 02:17:53 +0000 |
---|---|---|
committer | rvelices <rv-github@modusoptimus.com> | 2006-10-20 02:17:53 +0000 |
commit | eaacbc7b2d224524eac6def04e9b721949afd4b8 (patch) | |
tree | 76fd94a28037ffc5ff5bafa037e411c0306ea4f0 /include/common.inc.php | |
parent | dbadd4defb870c09664ea4178951d72f5d2ada3b (diff) |
- put back config['session_length'] disappeared in r1493 but has always been
used in the code (generates mysql errors on session garbage collector)
- fix auto_login (die mysql when session timed out, but user has remember)
- when a user reconnects from identification.php, the remember cookie was not
deleted
- fix all redirect warnings/errors (many changes - mainly in common.inc.php
and user.inc.php)
- reduced $conf['remember_me_length'] to 60 days, because now at each auto
login the 60 days countdown restarts
git-svn-id: http://piwigo.org/svn/trunk@1568 68402e56-0260-453c-a942-63ccdbb3a9ee
Diffstat (limited to '')
-rw-r--r-- | include/common.inc.php | 107 |
1 files changed, 50 insertions, 57 deletions
diff --git a/include/common.inc.php b/include/common.inc.php index d7b557679..d0376afe8 100644 --- a/include/common.inc.php +++ b/include/common.inc.php @@ -132,28 +132,6 @@ or die ( "Could not connect to database server" ); mysql_select_db( $cfgBase ) or die ( "Could not connect to database" ); -if ($conf['check_upgrade_feed'] - and defined('PHPWG_IN_UPGRADE') - and PHPWG_IN_UPGRADE) -{ - // retrieve already applied upgrades - $query = ' -SELECT id - FROM '.UPGRADE_TABLE.' -;'; - $applied = array_from_query($query, 'id'); - - // retrieve existing upgrades - $existing = get_available_upgrade_ids(); - - // which upgrades need to be applied? - if (count(array_diff($existing, $applied)) > 0) - { - $header_msgs[] = 'Some database upgrades are missing, ' - .'<a href="'.PHPWG_ROOT_PATH.'upgrade_feed.php">upgrade now</a>'; - } -} - // // Setup gallery wide options, if this fails then we output a CRITICAL_ERROR // since basic gallery information is not available @@ -162,67 +140,82 @@ load_conf_from_db(); include(PHPWG_ROOT_PATH.'include/user.inc.php'); + // language files include_once(get_language_filepath('common.lang.php')); - if (defined('IN_ADMIN') and IN_ADMIN) { include_once(get_language_filepath('admin.lang.php')); } +// only now we can set the localized username of the guest user (and not in +// include/user.inc.php) +if ($user['is_the_guest']) +{ + $user['username'] = $lang['guest']; +} + +// template instance +$template = new Template(PHPWG_ROOT_PATH.'template/'.$user['template'], $user['theme'] ); + if ($conf['gallery_locked']) { - $header_msgs[] = $lang['gallery_locked_message'] - . '<a href="'.PHPWG_ROOT_PATH.'identification.php">.</a>'; + $header_msgs[] = $lang['gallery_locked_message']; - if ( basename($_SERVER["PHP_SELF"]) != 'identification.php' + if ( basename($_SERVER["SCRIPT_FILENAME"]) != 'identification.php' and !is_admin() ) { - echo( $lang['gallery_locked_message'] ); + //next line required if PATH_INFO (no ? in url) but won't work for scripts outside PWG + $page['root_path'] = cookie_path(); + echo $lang['gallery_locked_message'] + .'<a href="'.get_root_url().'identification.php">.</a>'; exit(); } } -// only now we can set the localized username of the guest user (and not in -// include/user.inc.php) -if ($user['is_the_guest']) +if ($user['is_the_guest'] and !$conf['guest_access'] + and !in_array( basename($_SERVER['SCRIPT_FILENAME']), + array('identification.php', + 'password.php', + 'register.php' + ) + ) + ) { - $user['username'] = $lang['guest']; + //next line required if PATH_INFO (no ? in url) but won't work for scripts outside PWG + $page['root_path'] = cookie_path(); + redirect (get_root_url().'identification.php'); } -// include template/theme configuration -if (defined('IN_ADMIN') and IN_ADMIN) -{ - list($user['template'], $user['theme']) = - explode - ( - '/', - isset($conf['default_admin_layout']) ? $conf['default_admin_layout'] - : $user['template'] - ); -// TODO : replace $conf['admin_layout'] by $user['admin_layout'] -} -else +if ($conf['check_upgrade_feed'] + and defined('PHPWG_IN_UPGRADE') + and PHPWG_IN_UPGRADE) { - list($user['template'], $user['theme']) = explode('/', $user['template']); -} -// TODO : replace initial $user['template'] by $user['layout'] + // retrieve already applied upgrades + $query = ' +SELECT id + FROM '.UPGRADE_TABLE.' +;'; + $applied = array_from_query($query, 'id'); -include( - PHPWG_ROOT_PATH - .'template/'.$user['template'] - .'/theme/'.$user['theme'] - .'/themeconf.inc.php' - ); + // retrieve existing upgrades + $existing = get_available_upgrade_ids(); + + // which upgrades need to be applied? + if (count(array_diff($existing, $applied)) > 0) + { + //next line required if PATH_INFO (no ? in url) but won't work for scripts outside PWG + $page['root_path'] = cookie_path(); + $header_msgs[] = 'Some database upgrades are missing, ' + .'<a href="'.get_root_url().'upgrade_feed.php">upgrade now</a>'; + } +} if (is_adviser()) { $header_msgs[] = $lang['adviser_mode_enabled']; } -// template instance -$template = new Template(PHPWG_ROOT_PATH.'template/'.$user['template']); - if (count($header_msgs) > 0) { $template->assign_block_vars('header_msgs',array()); @@ -232,4 +225,4 @@ if (count($header_msgs) > 0) array('HEADER_MSG'=>$header_msg)); } } -?> +?>
\ No newline at end of file |