put back the redirect function as it was in branch 1.6 (still not working perfectly with the auto_login)
git-svn-id: http://piwigo.org/svn/trunk@1567 68402e56-0260-453c-a942-63ccdbb3a9ee
This commit is contained in:
parent
2a8b727d4b
commit
dbadd4defb
4 changed files with 48 additions and 49 deletions
|
|
@ -582,14 +582,12 @@ function pwg_debug( $string )
|
|||
*/
|
||||
function redirect( $url , $msg = '', $refresh_time = 0)
|
||||
{
|
||||
global $lang_info, $lang;
|
||||
global $user, $template, $lang_info, $conf, $lang, $t2, $page, $debug;
|
||||
|
||||
if (!isset($lang_info)) {
|
||||
include_once(get_language_filepath('common.lang.php'));
|
||||
}
|
||||
|
||||
$template = new Template(PHPWG_ROOT_PATH.'template-common');
|
||||
$template->set_filenames( array( 'redirect' => 'redirect.tpl' ) );
|
||||
if (empty($msg))
|
||||
{
|
||||
$redirect_msg = l10n('redirect_msg');
|
||||
|
|
@ -600,24 +598,39 @@ function redirect( $url , $msg = '', $refresh_time = 0)
|
|||
}
|
||||
$redirect_msg = nl2br($redirect_msg);
|
||||
|
||||
$template->assign_vars(
|
||||
array(
|
||||
'CONTENT_ENCODING' => $lang_info['charset'],
|
||||
'LANG'=>$lang_info['code'],
|
||||
'DIR'=>$lang_info['direction'],
|
||||
)
|
||||
);
|
||||
$refresh = $refresh_time;
|
||||
$url_link = $url;
|
||||
$title = 'redirection';
|
||||
|
||||
$template->assign_vars(
|
||||
array(
|
||||
'U_REDIRECT_MSG' => $redirect_msg,
|
||||
'REFRESH_TIME' => $refresh_time,
|
||||
'U_REFRESH' => $url
|
||||
)
|
||||
);
|
||||
$template->assign_block_vars('refresh', array());
|
||||
unset($template);
|
||||
if ( isset($user['template']) )
|
||||
{
|
||||
$template = new Template(PHPWG_ROOT_PATH.'template/'.$user['template']);
|
||||
}
|
||||
else
|
||||
{
|
||||
list($tmpl, $thm) = explode('/', $conf['default_template']);
|
||||
global $themeconf;
|
||||
include(
|
||||
PHPWG_ROOT_PATH
|
||||
.'template/'.$tmpl
|
||||
.'/theme/'.$thm
|
||||
.'/themeconf.inc.php'
|
||||
);
|
||||
$template = new Template(PHPWG_ROOT_PATH.'template/'.$tmpl);
|
||||
$user['is_the_guest']=true;
|
||||
$user['id']=$conf['guest_id'];
|
||||
}
|
||||
|
||||
$template->set_filenames( array( 'redirect' => 'redirect.tpl' ) );
|
||||
|
||||
include( PHPWG_ROOT_PATH.'include/page_header.php' );
|
||||
|
||||
$template->set_filenames( array( 'redirect' => 'redirect.tpl' ) );
|
||||
$template->parse('redirect');
|
||||
$template->p();
|
||||
|
||||
include( PHPWG_ROOT_PATH.'include/page_tail.php' );
|
||||
|
||||
exit();
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -458,7 +458,7 @@ function create_user_infos($user_id)
|
|||
{
|
||||
$status = 'normal';
|
||||
}
|
||||
|
||||
|
||||
$insert =
|
||||
array(
|
||||
'user_id' => $user_id,
|
||||
|
|
@ -522,12 +522,13 @@ function get_language_filepath($filename)
|
|||
{
|
||||
global $user, $conf;
|
||||
|
||||
$directories =
|
||||
array(
|
||||
PHPWG_ROOT_PATH.'language/'.$user['language'],
|
||||
PHPWG_ROOT_PATH.'language/'.$conf['default_language'],
|
||||
PHPWG_ROOT_PATH.'language/'.PHPWG_DEFAULT_LANGUAGE
|
||||
);
|
||||
$directories = array();
|
||||
if ( isset($user['language']) )
|
||||
{
|
||||
$directories[] = PHPWG_ROOT_PATH.'language/'.$user['language'];
|
||||
}
|
||||
$directories[] = PHPWG_ROOT_PATH.'language/'.$conf['default_language'];
|
||||
$directories[] = PHPWG_ROOT_PATH.'language/'.PHPWG_DEFAULT_LANGUAGE;
|
||||
|
||||
foreach ($directories as $directory)
|
||||
{
|
||||
|
|
@ -556,13 +557,13 @@ function log_user($user_id, $remember_me)
|
|||
{
|
||||
// search for an existing auto_login_key
|
||||
$query = '
|
||||
SELECT auto_login_key
|
||||
SELECT auto_login_key
|
||||
FROM '.USERS_TABLE.'
|
||||
WHERE '.$conf['user_fields']['id'].' = '.$user_id.'
|
||||
;';
|
||||
|
||||
|
||||
$auto_login_key = current(mysql_fetch_assoc(pwg_query($query)));
|
||||
if (empty($auto_login_key))
|
||||
if (empty($auto_login_key))
|
||||
{
|
||||
$auto_login_key = base64_encode(md5(uniqid(rand(), true)));
|
||||
$query = '
|
||||
|
|
@ -574,7 +575,7 @@ UPDATE '.USERS_TABLE.'
|
|||
}
|
||||
$cookie = array('id' => $user_id, 'key' => $auto_login_key);
|
||||
setcookie($conf['remember_me_name'],
|
||||
serialize($cookie),
|
||||
serialize($cookie),
|
||||
time()+$conf['remember_me_length'],
|
||||
cookie_path()
|
||||
);
|
||||
|
|
@ -590,7 +591,7 @@ UPDATE '.USERS_TABLE.'
|
|||
* Performs auto-connexion when cookie remember_me exists
|
||||
* @return void
|
||||
*/
|
||||
function auto_login() {
|
||||
function auto_login() {
|
||||
global $conf;
|
||||
|
||||
// must remove slash added in include/common.inc.php
|
||||
|
|
@ -612,7 +613,7 @@ SELECT auto_login_key
|
|||
{
|
||||
setcookie($conf['remember_me_name'], '', 0, cookie_path());
|
||||
redirect(make_index_url());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
|
|
|
|||
|
|
@ -1,17 +0,0 @@
|
|||
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
|
||||
"http://www.w3.org/TR/html4/strict.dtd">
|
||||
<html lang="{LANG}" dir="{DIR}">
|
||||
<head>
|
||||
<title>{U_REDIRECT_MSG}</title>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset={CONTENT_ENCODING}">
|
||||
<!-- BEGIN refresh -->
|
||||
<meta http-equiv="refresh" content="{REFRESH_TIME};url={U_REFRESH}">
|
||||
<!-- END refresh -->
|
||||
</head>
|
||||
<body>
|
||||
<div id="the_page">
|
||||
<p>{U_REDIRECT_MSG}</p>
|
||||
<p><a href="{U_REFRESH}">{lang:click_to_redirect}</a></p>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
2
template/yoga/redirect.tpl
Normal file
2
template/yoga/redirect.tpl
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
<p>{U_REDIRECT_MSG}</p>
|
||||
<p><a href="{U_REFRESH}">{lang:click_to_redirect}</a></p>
|
||||
Loading…
Add table
Add a link
Reference in a new issue