Weteran
Postów: 3264 Pomógł: 236
v7.02.06 Data rejestracji: 26.05.2007 12:25
|
Witam.
Modyfikacja przekierowuje po zalogowaniu do strony, którą się oglądało przed logowaniem. Umieściłem te dane w adresie i pobieram metodą GET. W załączniku gotowe pliki, a poniżej instrukcja modyfikacji.
Plik maincore.php
Linie 218-233, znajdź:
if (dbrows($result)) {
$data = dbarray($result);
$cookie_value = $data['user_id'].".".$user_pass;
if ($data['user_status'] == 0) {
$cookie_exp = isset($_POST['remember_me']) ? time() + 3600 * 24 * 30 : time() + 3600 * 3;
header("P3P: CP='NOI ADM DEV PSAi COM NAV OUR OTRo STP IND DEM'");
setcookie(COOKIE_PREFIX."user", $cookie_value, $cookie_exp, "/", "", "0");
redirect(BASEDIR."setuser.php?user=".$data['user_name'], true);
} elseif ($data['user_status'] == 1) {
redirect(BASEDIR."setuser.php?error=1", true);
} elseif ($data['user_status'] == 2) {
redirect(BASEDIR."setuser.php?error=2", true);
}
} else {
redirect(BASEDIR."setuser.php?error=3");
}
Kliknij i zaczekaj na załadowanie kodu ...
zamień na:
// modified by bartek124
$redirect_to = (isset($_POST['redirect']) ? "&redirect=".urlencode($_POST['redirect']) : "");
if (dbrows($result)) {
$data = dbarray($result);
$cookie_value = $data['user_id'].".".$user_pass;
if ($data['user_status'] == 0) {
$cookie_exp = isset($_POST['remember_me']) ? time() + 3600 * 24 * 30 : time() + 3600 * 3;
header("P3P: CP='NOI ADM DEV PSAi COM NAV OUR OTRo STP IND DEM'");
setcookie(COOKIE_PREFIX."user", $cookie_value, $cookie_exp, "/", "", "0");
redirect(BASEDIR."setuser.php?user=".$data['user_name'].$redirect_to, true);
} elseif ($data['user_status'] == 1) {
redirect(BASEDIR."setuser.php?error=1".$redirect_to, true);
} elseif ($data['user_status'] == 2) {
redirect(BASEDIR."setuser.php?error=2".$redirect_to, true);
}
} else {
redirect(BASEDIR."setuser.php?error=3".$redirect_to);
}
//
Kliknij i zaczekaj na załadowanie kodu ...
Plik setuser.php
Linia 25, znajdź:
echo "<meta http-equiv='refresh' content='2; url=".$settings['opening_page']."' />\n";
Kliknij i zaczekaj na załadowanie kodu ...
zamień na:
// modified by bartek124
if (isset($_GET['redirect'])) {
$redirect_to = urldecode(stripinput($_GET['redirect']));
} else {
$redirect_to = $settings['opening_page'];
}
echo "<meta http-equiv='refresh' content='2; url=".$redirect_to."' />\n";
//
Kliknij i zaczekaj na załadowanie kodu ...
Plik infusions/user_info_panel/user_info_panel.php
Linia 29, znajdź:
echo THEME_BULLET." <a href='".BASEDIR."setuser.php?logout=yes' class='side'>".$locale['global_124']."</a>\n";
Kliknij i zaczekaj na załadowanie kodu ...
zamień na:
// modified by bartek124
echo THEME_BULLET." <a href='".BASEDIR."setuser.php?logout=yes&redirect=".urlencode(START_PAGE)."' class='side'>".$locale['global_124']."</a>\n";
//
Kliknij i zaczekaj na załadowanie kodu ...
Linia 34, znajdź:
echo "<form name='loginform' method='post' action='".FUSION_SELF."'>\n";
Kliknij i zaczekaj na załadowanie kodu ...
pod dodaj:
// added by bartek124
echo "<input type='hidden' name='redirect' value='".START_PAGE."' />\n";
//
Kliknij i zaczekaj na załadowanie kodu ...
Plik locale/TWOJE_LOCALE/global.php
Linia ~147, znajdź:
<a href='index.php'>
Kliknij i zaczekaj na załadowanie kodu ...
zamień na:
<a href='".(isset($_GET['redirect']) ? stripinput(urldecode($_GET['redirect'])) : "index.php")."'>
Kliknij i zaczekaj na załadowanie kodu ...
Edytowane przez bartek124 dnia 03.01.2010 22:18:19
Nie pomagam na komunikatorach oraz PW!
|
Przedszkolak
Postów: 51 Pomógł: 4
v7.02.03 Data rejestracji: 14.06.2007 22:14
|
Mam rozwiązanie, jeśli ktoś będzie jeszcze chciał (pod PF v7.01):
maincore.php, dodać na końcu przed:
include INCLUDES."system_images.php";
to:
if (iMEMBER && (isset($_REQUEST['logout']) && $_REQUEST['logout'] == "yes")) {
if ($settings['login_method'] == "cookies") {
header("P3P: CP='NOI ADM DEV PSAi COM NAV OUR OTRo STP IND DEM'");
setcookie(COOKIE_PREFIX."user", "", time() - 7200, "/", "", "0");
setcookie(COOKIE_PREFIX."lastvisit", "", time() - 7200, "/", "", "0");
} elseif ($settings['login_method'] == "sessions") {
session_destroy();
$session_destroyed = true;
}
$result = dbquery("DELETE FROM ".DB_ONLINE." WHERE online_ip='".USER_IP."'");
$url = str_replace("&logout=yes", "", FUSION_REQUEST);
$url = str_replace("?logout=yes&", "?", $url);
$url = str_replace("?logout=yes", "", $url);
redirect($url);
} elseif (isset($_GET['login_member'])) {
if (($settings['login_method'] == "cookies" && isset($_COOKIE[COOKIE_PREFIX.'user'])) || ($settings['login_method'] == "sessions" && isset($_SESSION[COOKIE_PREFIX.'user_id']) && isset($_SESSION[COOKIE_PREFIX.'user_pass']))) {
if ($settings['login_method'] == "cookies") {
$cookie_vars = explode(".", $_COOKIE[COOKIE_PREFIX.'user']);
$user_pass = preg_check("/^[0-9a-z]{32}$/", $cookie_vars['1']) ? $cookie_vars['1'] : "";
} elseif ($settings['login_method'] == "sessions") {
$user_pass = preg_check("/^[0-9a-z]{32}$/", $_SESSION[COOKIE_PREFIX.'user_pass']) ? $_SESSION[COOKIE_PREFIX.'user_pass'] : "";
}
$url = str_replace("&login_member", "", FUSION_REQUEST);
$url = str_replace("?login_member&", "?", $url);
$url = str_replace("?login_member", "", $url);
redirect($url);
}
}
user_info_panel - link do wylogowania:
<a href='".(FUSION_QUERY != "" ? FUSION_REQUEST."&logout=yes" : FUSION_SELF."?logout=yes")."' class='side'>
oraz form logowania:
<form method='post' action='".(FUSION_QUERY != "" ? FUSION_REQUEST."&login_member" : FUSION_SELF."?login_member")."'>
Plik setuser:
<?php
/*-------------------------------------------------------+
| PHP-Fusion Content Management System
| Copyright (C) 2002 - 2010 Nick Jones
| http://www.php-fusion.co.uk/
+--------------------------------------------------------+
| Filename: setuser.php
| Author: Nick Jones (Digitanium) edit by szygmon
+--------------------------------------------------------+
| This program is released as free software under the
| Affero GPL license. You can redistribute it and/or
| modify it under the terms of this license which you
| can read by viewing the included agpl.txt or online
| at http://www.gnu.org/licenses/agpl.html. Removal of this
| copyright header is strictly prohibited without
| written permission from the original author(s).
+--------------------------------------------------------*/
require_once "maincore.php";
include THEME."theme.php";
$session_destroyed = false; $page_content = ""; $page_refresh = "2";
if (isset($_GET['error']) && $_GET['error'] == 1) {
$id = ((isset($_GET['id']) && isnum($_GET['error'])) ? $_GET['id'] : "0");
$data = dbarray(dbquery("SELECT suspend_reason FROM ".DB_SUSPENDS." WHERE suspended_user='".$id."' ORDER BY suspend_date DESC LIMIT 1"));
$page_content .= "<strong>".$locale['global_406']."<br /><br />\n";
$page_content .= $data['suspend_reason']."</strong><br /><br />\n";
$page_refresh = "15";
} elseif (isset($_GET['error']) && $_GET['error'] == 2) {
$page_content .= "<strong>".$locale['global_195']."</strong><br /><br />\n";
} elseif (isset($_GET['error']) && $_GET['error'] == 3) {
$id = ((isset($_GET['id']) && isnum($_GET['error'])) ? $_GET['id'] : "0");
$data = dbarray(dbquery("SELECT suspend_reason FROM ".DB_SUSPENDS." WHERE suspended_user='".$id."' ORDER BY suspend_date DESC LIMIT 1"));
$data2 = dbarray(dbquery("SELECT user_actiontime FROM ".DB_USERS." WHERE user_id='".$id."'"));
$page_content .= "<strong>".$locale['global_407'].showdate('shortdate', $data2['user_actiontime']).$locale['global_408']."<br /><br />\n";
$page_content .= $data['suspend_reason']."</strong><br /><br />\n";
$page_refresh = "15";
} elseif (isset($_GET['error']) && $_GET['error'] == 4) {
$page_content .= "<strong>".$locale['global_409']."<br /><br />\n";
$page_content .= $locale['global_410'].$data['suspend_reason']."</strong><br /><br />\n";
} elseif (isset($_GET['error']) && $_GET['error'] == 5) {
$page_content .= "<strong>".$locale['global_411']."</strong><br /><br />\n";
} elseif (isset($_GET['error']) && $_GET['error'] == 6) {
$page_content .= "<strong>".$locale['global_412']."</strong><br /><br />\n";
$page_refresh = "7";
} elseif (isset($_GET['error']) && $_GET['error'] == 8) {
$page_content .= "<strong>".$locale['global_196']."</strong><br /><br />\n";
}
echo "<!DOCTYPE html PUBLIC '-//W3C//DTD XHTML 1.0 Transitional//EN' 'http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd'>\n";
echo "<html>\n<head>\n";
echo "<title>".$settings['sitename']."</title>\n";
echo "<meta http-equiv='Content-Type' content='text/html; charset=".$locale['charset']."' />\n";
echo "<meta http-equiv='refresh' content='".$page_refresh."; url=".$settings['opening_page']."' />\n";
echo "<meta name='description' content='".$settings['description']."' />\n";
echo "<meta name='keywords' content='".$settings['keywords']."' />\n";
echo "<style type='text/css'>html, body { height:100%; }</style>\n";
echo "<link rel='stylesheet' href='".THEME."styles.css' type='text/css' />\n";
if (function_exists("get_head_tags")) { echo get_head_tags(); }
echo "</head>\n<body class='tbl2 setuser_body'>\n";
echo "<table style='width:100%;height:100%'>\n<tr>\n<td>\n";
echo "<table cellpadding='0' cellspacing='1' width='80%' class='tbl-border center'>\n<tr>\n";
echo "<td class='tbl1'>\n<div style='text-align:center'><!--setuser_pre_logo--><br />\n";
echo "<img src='".BASEDIR.$settings['sitebanner']."' alt='".$settings['sitename']."' /><br /><br />\n";
echo $page_content.$locale['global_197']."<br /><br />\n";
echo "</div>\n</td>\n</tr>\n</table>\n";
echo "</td>\n</tr>\n</table>\n";
echo "</body>\n</html>\n";
if (ob_get_length() !== FALSE){
ob_end_flush();
}
if ($settings['login_method'] == "sessions" && $session_destroyed == false) {
session_write_close();
}
mysql_close($db_connect);
?>
oraz includes/cookie_include:
<?php
/*-------------------------------------------------------+
| PHP-Fusion Content Management System
| Copyright (C) 2002 - 2010 Nick Jones
| http://www.php-fusion.co.uk/
+--------------------------------------------------------+
| Filename: cookie_include.php
| Author: Nick Jones (Digitanium) edit by szygmon
+--------------------------------------------------------+
| This program is released as free software under the
| Affero GPL license. You can redistribute it and/or
| modify it under the terms of this license which you
| can read by viewing the included agpl.txt or online
| at http://www.gnu.org/licenses/agpl.html. Removal of this
| copyright header is strictly prohibited without
| written permission from the original author(s).
+--------------------------------------------------------*/
if (!defined("IN_FUSION")) { die("Access Denied"); }
if (isset($_POST['login']) && isset($_POST['user_name']) && isset($_POST['user_pass'])) {
$user_name = preg_replace(array("/\=/","/\#/","/\sOR\s/"), "", stripinput($_POST['user_name']));
$user_pass = md5($_POST['user_pass']);
$result = dbquery("SELECT user_id, user_name, user_status, user_actiontime FROM ".DB_USERS." WHERE user_name='".$user_name."' AND user_password='".md5($user_pass)."' LIMIT 1");
if (dbrows($result)) {
$data = dbarray($result);
$cookie_value = $data['user_id'].".".$user_pass;
if ($data['user_status'] == 0 && $data['user_actiontime'] == 0) {
$cookie_exp = isset($_POST['remember_me']) ? time() + 3600 * 24 * 30 : time() + 3600 * 3;
header("P3P: CP='NOI ADM DEV PSAi COM NAV OUR OTRo STP IND DEM'");
setcookie(COOKIE_PREFIX."user", $cookie_value, $cookie_exp, "/", "", "0");
redirect(FUSION_REQUEST, true);
} elseif ($data['user_status'] == 1) {
redirect(BASEDIR."setuser.php?error=1&id=".$data['user_id'], true);
} elseif ($data['user_status'] == 2) {
redirect(BASEDIR."setuser.php?error=2", true);
} elseif ($data['user_status'] == 3) {
if ($data['user_actiontime'] < time()) {
require_once INCLUDES."suspend_include.php";
require_once INCLUDES."sendmail_include.php";
$_SESSION[COOKIE_PREFIX.'user_id'] = $data['user_id'];
$_SESSION[COOKIE_PREFIX.'user_pass'] = $user_pass;
$result = dbquery("UPDATE ".DB_USERS." SET user_status='0', user_actiontime='0' WHERE user_id='".$data['user_id']."'");
unsuspend_log($data['user_id'], 3, $locale['global_450'], true);
// Send mail
$subject = $locale['global_453'];
$message = str_replace("USER_NAME", $data['user_name'], $locale['global_452']);
sendemail($data['user_name'], $data['user_email'], $settings['siteusername'], $settings['siteemail'], $subject, $message);
// Send mail
redirect(FUSION_REQUEST, true);
} else {
redirect(BASEDIR."setuser.php?error=3&id=".$data['user_id'], true);
}
} elseif ($data['user_status'] == 4) {
redirect(BASEDIR."setuser.php?error=4&id=".$data['user_id'], true);
} elseif ($data['user_status'] == 5) {
redirect(BASEDIR."setuser.php?error=5", true);
} elseif ($data['user_status'] == 6) {
redirect(BASEDIR."setuser.php?error=6", true);
} elseif ($data['user_status'] == 7) {
require_once INCLUDES."sendmail_include.php";
$_SESSION[COOKIE_PREFIX.'user_id'] = $data['user_id'];
$_SESSION[COOKIE_PREFIX.'user_pass'] = $user_pass;
$result = dbquery("UPDATE ".DB_USERS." SET user_status='0', user_actiontime='0' WHERE user_id='".$data['user_id']."'");
// Send mail
$subject = $locale['global_454'];
$message = str_replace("USER_NAME", $data['user_name'], $locale['global_455']);
sendemail($data['user_name'], $data['user_email'], $settings['siteusername'], $settings['siteemail'], $subject, $message);
// Send mail
redirect(FUSION_REQUEST, true);
}
} else {
redirect(BASEDIR."setuser.php?error=8");
}
}
if (isset($_COOKIE[COOKIE_PREFIX.'user'])) {
$cookie_vars = explode(".", $_COOKIE[COOKIE_PREFIX.'user']);
$cookie_1 = isnum($cookie_vars['0']) ? $cookie_vars['0'] : "0";
$cookie_2 = (preg_check("/^[0-9a-z]{32}$/", $cookie_vars['1']) ? $cookie_vars['1'] : "");
$result = dbquery("SELECT * FROM ".DB_USERS." WHERE user_id='$cookie_1' AND user_password='".md5($cookie_2)."' LIMIT 1");
unset($cookie_vars,$cookie_1,$cookie_2);
if (dbrows($result)) {
$userdata = dbarray($result);
if ($userdata['user_status'] == 0) {
if ($userdata['user_theme'] != "Default" && file_exists(THEMES.$userdata['user_theme']."/theme.php") && ($settings['userthemes'] == 1 || $userdata['user_level'] >= 102)) {
if (!theme_exists($userdata['user_theme'])) {
echo "<strong>".$settings['sitename']." - ".$locale['global_300'].".</strong><br /><br />\n";
echo $locale['global_301'];
die();
}
} else {
if (!theme_exists($settings['theme'])) {
echo "<strong>".$settings['sitename']." - ".$locale['global_300'].".</strong><br /><br />\n";
echo $locale['global_301'];
die();
}
}
if ($userdata['user_offset'] <> 0) {
$settings['timeoffset'] = $settings['timeoffset'] + $userdata['user_offset'];
}
if (!isset($_COOKIE[COOKIE_PREFIX.'lastvisit']) || !isnum($_COOKIE[COOKIE_PREFIX.'lastvisit'])) {
$result = dbquery("UPDATE ".DB_USERS." SET user_threads='' WHERE user_id='".$userdata['user_id']."'");
setcookie(COOKIE_PREFIX."lastvisit", $userdata['user_lastvisit'], time() + 3600, "/", "", "0");
$lastvisited = $userdata['user_lastvisit'];
} else {
$lastvisited = $_COOKIE[COOKIE_PREFIX.'lastvisit'];
}
if ($userdata['user_level'] > 101) {
if (isset($_COOKIE[COOKIE_PREFIX.'admin']) && (!stristr(FUSION_REQUEST, str_replace("../", "", "/".ADMIN)) || USER_IP != $userdata['user_ip'])) {
setcookie(COOKIE_PREFIX."admin", "", time() - 7200, "/", "", "0");
}
}
} else {
header("P3P: CP='NOI ADM DEV PSAi COM NAV OUR OTRo STP IND DEM'");
setcookie(COOKIE_PREFIX."user", "", time() - 7200, "/", "", "0");
setcookie(COOKIE_PREFIX."lastvisit", "", time() - 7200, "/", "", "0");
redirect(BASEDIR."index.php", true);
}
} else {
header("P3P: CP='NOI ADM DEV PSAi COM NAV OUR OTRo STP IND DEM'");
setcookie(COOKIE_PREFIX."user", "", time() - 7200, "/", "", "0");
setcookie(COOKIE_PREFIX."lastvisit", "", time() - 7200, "/", "", "0");
redirect(BASEDIR."index.php", true);
}
} else {
if (!theme_exists($settings['theme'])) {
echo "<strong>".$settings['sitename']." - ".$locale['global_300'].".</strong><br /><br />\n";
echo $locale['global_301'];
die();
}
$userdata = "";
$userdata['user_level'] = 0;
$userdata['user_rights'] = "";
$userdata['user_groups'] = "";
// Edycja:
$userdata['user_id'] = "";
}
?>
Działa pod cookie, sesji nie robiłem. Po poprawnym zalogowaniu/wylogowaniu nie pokazuje się strona "czekaj na przekierowania" - od razu powraca do oglądanej strony. Tylko w razie zablokowania konta, błędu itp. pokazuje się info z powodem czy tam czymś... |