限制頁面存取的問題

edited 十月 2013 in PHP新手區
請問下面的程式碼是不是有錯誤?
想要做出登入後才能進入頁面,若不行,則到另一個頁面,而且"product_id"要一樣的功能,就是不能登入的頁面也要用"product_id"來做篩選.但測試時一直出現錯誤訊息

錯誤訊息:
Parse error: syntax error, unexpected T_ENCAPSED_AND_WHITESPACE, expecting T_STRING or T_VARIABLE or T_NUM_STRING in C:\AppServ\www\shopp_test\product.php on line 64(64就是藍色那行)


<?php
if (!isset($_SESSION)) {
session_start();
}
$MM_authorizedUsers = "0,1";
$MM_donotCheckaccess = "false";

// *** Restrict Access To Page: Grant or deny access to this page
function isAuthorized($strUsers, $strGroups, $UserName, $UserGroup) {
// For security, start by assuming the visitor is NOT authorized.
$isValid = False;

// When a visitor has logged into this site, the Session variable MM_Username set equal to their username.
// Therefore, we know that a user is NOT logged in if that Session variable is blank.
if (!empty($UserName)) {
// Besides being logged in, you may restrict access to only certain users based on an ID established when they login.
// Parse the strings into arrays.
$arrUsers = Explode(",", $strUsers);
$arrGroups = Explode(",", $strGroups);
if (in_array($UserName, $arrUsers)) {
$isValid = true;
}
// Or, you may restrict access to only certain users based on their username.
if (in_array($UserGroup, $arrGroups)) {
$isValid = true;
}
if (($strUsers == "") && false) {
$isValid = true;
}
}
return $isValid;
}

$MM_restrictGoTo = "productListNo.php?product_id=<?php echo $row_RecProduct; ?>";
if (!((isset($_SESSION)) && (isAuthorized("",$MM_authorizedUsers, $_SESSION, $_SESSION)))) {
$MM_qsChar = "?";
$MM_referrer = $_SERVER;
if (strpos($MM_restrictGoTo, "?")) $MM_qsChar = "&";
if (isset($QUERY_STRING) && strlen($QUERY_STRING) > 0)
$MM_referrer .= "?" . $QUERY_STRING;
$MM_restrictGoTo = $MM_restrictGoTo. $MM_qsChar . "accesscheck=" . urlencode($MM_referrer);
header("Location: ". $MM_restrictGoTo);
exit;
}
?>

原始討論: http://twpug.net/x/modules/newbb/viewtopic.php?topic_id=4363

評論

Sign In or Register to comment.