[問題]登入後才能觀看該網頁

phpBB Installation & Usage Support
phpBB 2 安裝於各類型作業平台之問題討論;外掛問題,請到相關版面依發問格式發表!
(發表文章請按照公告格式發表,違者砍文)

版主: 版主管理群

版面規則
本區是討論關於 phpBB 2.0.X 架設安裝上的問題,只要有安裝任何外掛,請到外掛討論相關版面按照公告格式發表。
(發表文章請按照公告格式發表,違者砍文)
主題已鎖定
死狐狸
星球公民
星球公民
文章: 144
註冊時間: 2004-05-12 17:34
來自: 江狐....
聯繫:

[問題]登入後才能觀看該網頁

文章 死狐狸 »

請問如在在將首頁上的A連結必須要先登入後才能看到內容~~(就算是直接打網址也是要先登入),剛剛搜尋了一下好像沒什麼答案,所以參考了一下個人資料的連結,依我的猜想,應該是紅色的這段吧(現在正開始起步學PHP~)

代碼: 選擇全部

<?php
/***************************************************************************
 *                                profile.php
 *                            -------------------
 *   begin                : Saturday, Feb 13, 2001
 *   copyright            : (C) 2001 The phpBB Group
 *   email                : support@phpbb.com
 *
 *   $Id: profile.php,v 1.193.2.3 2003/03/02 23:16:17 acydburn Exp $
 *
 *
 ***************************************************************************/

/***************************************************************************
 *
 *   This program is free software; you can redistribute it and/or modify
 *   it under the terms of the GNU General Public License as published by
 *   the Free Software Foundation; either version 2 of the License, or
 *   (at your option) any later version.
 *
 ***************************************************************************/

define('IN_PHPBB', true);
if ( (isset($HTTP_GET_VARS['mode']) && ($HTTP_GET_VARS['mode'] == 'viewprofile')) || (isset($HTTP_POST_VARS['mode']) && ($HTTP_POST_VARS['mode'] == 'viewprofile')) )
{
	define('IN_CASHMOD', true);
	define('CM_VIEWPROFILE',true);
}
$phpbb_root_path = './';
include($phpbb_root_path . 'extension.inc');
include($phpbb_root_path . 'common.'.$phpEx);

//
// Start session management
//
$userdata = session_pagestart($user_ip, PAGE_PROFILE);
init_userprefs($userdata);
//
// End session management
//

// session id check
if (!empty($HTTP_POST_VARS['sid']) || !empty($HTTP_GET_VARS['sid']))
{
	$sid = (!empty($HTTP_POST_VARS['sid'])) ? $HTTP_POST_VARS['sid'] : $HTTP_GET_VARS['sid'];
}
else
{
	$sid = '';
}

//
// Set default email variables
//
$script_name = preg_replace('/^\/?(.*?)\/?$/', '\1', trim($board_config['script_path']));
$script_name = ( $script_name != '' ) ? $script_name . '/profile.'.$phpEx : 'profile.'.$phpEx;
$server_name = trim($board_config['server_name']);
$server_protocol = ( $board_config['cookie_secure'] ) ? 'https://' : 'http://';
$server_port = ( $board_config['server_port'] <> 80 ) ? ':' . trim($board_config['server_port']) . '/' : '/';

$server_url = $server_protocol . $server_name . $server_port . $script_name;

// -----------------------
// Page specific functions
//
function gen_rand_string($hash)
{
	$chars = array( 'a', 'A', 'b', 'B', 'c', 'C', 'd', 'D', 'e', 'E', 'f', 'F', 'g', 'G', 'h', 'H', 'i', 'I', 'j', 'J',  'k', 'K', 'l', 'L', 'm', 'M', 'n', 'N', 'o', 'O', 'p', 'P', 'q', 'Q', 'r', 'R', 's', 'S', 't', 'T',  'u', 'U', 'v', 'V', 'w', 'W', 'x', 'X', 'y', 'Y', 'z', 'Z', '1', '2', '3', '4', '5', '6', '7', '8', '9', '0');
	
	$max_chars = count($chars) - 1;
	srand( (double) microtime()*1000000);
	
	$rand_str = '';
	for($i = 0; $i < 8; $i++)
	{
		$rand_str = ( $i == 0 ) ? $chars[rand(0, $max_chars)] : $rand_str . $chars[rand(0, $max_chars)];
	}

	return ( $hash ) ? md5($rand_str) : $rand_str;
}
//
// End page specific functions
// ---------------------------

//
// Start of program proper
//
[color=red]if ( isset($HTTP_GET_VARS['mode']) || isset($HTTP_POST_VARS['mode']) )
{
	$mode = ( isset($HTTP_GET_VARS['mode']) ) ? $HTTP_GET_VARS['mode'] : $HTTP_POST_VARS['mode'];

	if ( $mode == 'viewprofile' )
	{
		     if ( !$userdata['session_logged_in'] && $mode == 'viewprofile' ) 
      { 
         redirect(append_sid("login.$phpEx?redirect=profile.$phpEx&mode=viewprofile", true)); 
      } [/color]
		include($phpbb_root_path . 'includes/usercp_viewprofile.'.$phpEx);
		exit;
	}
	else if ( $mode == 'editprofile' || $mode == 'register' )
	{
		if ( !$userdata['session_logged_in'] && $mode == 'editprofile' )
		{
			redirect(append_sid("login.$phpEx?redirect=profile.$phpEx&mode=editprofile", true));
		}

		include($phpbb_root_path . 'includes/usercp_register.'.$phpEx);
		exit;
	}
	else if ( $mode == 'sendpassword' )
	{
		include($phpbb_root_path . 'includes/usercp_sendpasswd.'.$phpEx);
		exit;
	}
	else if ( $mode == 'activate' )
	{
		include($phpbb_root_path . 'includes/usercp_activate.'.$phpEx);
		exit;
	}
	else if ( $mode == 'email' )
	{
		include($phpbb_root_path . 'includes/usercp_email.'.$phpEx);
		exit;
	}
}

redirect(append_sid("index.$phpEx", true));

?>
希望大大能指導小第一下 :-D
感激不盡!!
●架設主機作業系統:Xp Pro
●快速架站程式:Appserv2.4.4a
●我的網站 : 1. http://foxbbs.24cc.com 2.建造中\r
●免費空間連結: http://members.lycos.co.uk/
●您的 phpBB2 版本:1. 2.08 2. 2.0.17
------------------------------------------------------
您在使用電腦上有任何問題嗎?歡迎來江狐論壇跟大家一起解決喔!!

P.S 直接叫我"死狐狸"沒關係啦!! :mrgreen:
死狐狸
星球公民
星球公民
文章: 144
註冊時間: 2004-05-12 17:34
來自: 江狐....
聯繫:

文章 死狐狸 »

補充一下~上面說的A網頁就是此頁,請問要如何修改呢??

[php]<?php
<?php
/***************************************************************************
* usercp_show_agreement.php
* -------------------
* begin : Saturday, Feb 13, 2001
* copyright : (C) 2001 The phpBB Group
* email : support@phpbb.com
*
* $Id: usercp_register.php,v 1.20 2002/04/03 23:24:59 psotfx Exp $
*
*
***************************************************************************/

/***************************************************************************
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
*
***************************************************************************/
define('IN_PHPBB', true);
$phpbb_root_path = './';
include($phpbb_root_path . 'extension.inc');
include($phpbb_root_path . 'common.'.$phpEx);

//
// Start session management
//
$userdata = session_pagestart($user_ip, PAGE_INDEX);
init_userprefs($userdata);
//
// End session management
//'

global $template, $lang, $phpbb_root_path, $phpEx;

include($phpbb_root_path . 'virinfocenter.'.$phpEx);

$template->set_filenames(array(
'body' => 'virinfocenter_demo.tpl')
);

$template->assign_vars(array(
'SITE_ABOUT_TITLE' => '江狐病毒資訊中心')
);

$error = FALSE;
$page_title = "江狐病毒資訊中心";

include($phpbb_root_path . 'includes/page_header.'.$phpEx);

$template->pparse('body');

include($phpbb_root_path . 'includes/page_tail.'.$phpEx);



?>
?>[/php]
●架設主機作業系統:Xp Pro
●快速架站程式:Appserv2.4.4a
●我的網站 : 1. http://foxbbs.24cc.com 2.建造中\r
●免費空間連結: http://members.lycos.co.uk/
●您的 phpBB2 版本:1. 2.08 2. 2.0.17
------------------------------------------------------
您在使用電腦上有任何問題嗎?歡迎來江狐論壇跟大家一起解決喔!!

P.S 直接叫我"死狐狸"沒關係啦!! :mrgreen:
死狐狸
星球公民
星球公民
文章: 144
註冊時間: 2004-05-12 17:34
來自: 江狐....
聯繫:

文章 死狐狸 »

剛剛在上面那個檔案中加入這段截自profile.php的語法(其中紅色的部份不知要如何更改),不過卻發生錯誤,希望大大們能只到小弟正確滴方法

代碼: 選擇全部

//
// Start of program proper
//
if ( isset($HTTP_GET_VARS['mode']) || isset($HTTP_POST_VARS['[color=red]mode[/color]']) )
{
	$mode = ( isset($HTTP_GET_VARS['[color=red]mode[/color]']) ) ? $HTTP_GET_VARS['[color=red]mode[/color]'] : $HTTP_POST_VARS['[color=red]mode[/color]'];

	if ( $mode == '[color=red]viewprofile[/color]' )
	{
		     if ( !$userdata['session_logged_in'] && $mode == '[color=red]viewprofile[/color]' ) 
      { 
         redirect(append_sid("login.$phpEx?redirect=[color=red]profile.$phpEx&mode=viewprofile[/color]", true)); 
      } 
●架設主機作業系統:Xp Pro
●快速架站程式:Appserv2.4.4a
●我的網站 : 1. http://foxbbs.24cc.com 2.建造中\r
●免費空間連結: http://members.lycos.co.uk/
●您的 phpBB2 版本:1. 2.08 2. 2.0.17
------------------------------------------------------
您在使用電腦上有任何問題嗎?歡迎來江狐論壇跟大家一起解決喔!!

P.S 直接叫我"死狐狸"沒關係啦!! :mrgreen:
死狐狸
星球公民
星球公民
文章: 144
註冊時間: 2004-05-12 17:34
來自: 江狐....
聯繫:

文章 死狐狸 »

剛剛參考這篇,終於茲幾幫自己解決問題囉!!
●架設主機作業系統:Xp Pro
●快速架站程式:Appserv2.4.4a
●我的網站 : 1. http://foxbbs.24cc.com 2.建造中\r
●免費空間連結: http://members.lycos.co.uk/
●您的 phpBB2 版本:1. 2.08 2. 2.0.17
------------------------------------------------------
您在使用電腦上有任何問題嗎?歡迎來江狐論壇跟大家一起解決喔!!

P.S 直接叫我"死狐狸"沒關係啦!! :mrgreen:
神川小羽
調皮の小羽
調皮の小羽
文章: 1461
註冊時間: 2004-05-01 05:55
來自: 謎樣之筱語
聯繫:

文章 神川小羽 »

我是這樣子寫耶...
[php]
if ($userdata['user_id']==ANONYMOUS)
{
header("Location:login.".$phpEx);
}
[/php]
-.-
主題已鎖定

回到「phpBB 2 安裝與使用」