若用户被阻止php包含页面,是否包含其他?
有人能帮帮我吗,我正在尝试合并这段代码:若用户被阻止php包含页面,是否包含其他?,php,mysql,Php,Mysql,有人能帮帮我吗,我正在尝试合并这段代码: <?php $blocked_users = blocked_users(); while ($block = mysql_fetch_array($blocked_users)) { if ($block['blocked'] == '1') { include("includes/mod_profile/mod_blocked.php"); } } ?> <?php $page_title = "Profile"
<?php
$blocked_users = blocked_users();
while ($block = mysql_fetch_array($blocked_users)) {
if ($block['blocked'] == '1') {
include("includes/mod_profile/mod_blocked.php");
}
}
?>
<?php
$page_title = "Profile";
include('includes/headerframe.php');
// GET PROFILE ID FROM URL
if (isset ($_GET['id'])) {
$profile_id = $_GET['id'];
}
?>
<?php
$blocked_users = blocked_users();
while ($block = mysql_fetch_array($blocked_users)) {
if ($block['blocked'] == '1') {
include("includes/mod_profile/mod_blocked.php");
}
}
?>
<?php
$user_info_set = get_user_info();
if (!$user = mysql_fetch_array($user_info_set)) {
include ('includes/mod_profile/mod_noprofile.php');
}
else if (!isset($profile_id)) {
include("includes/mod_profile/mod_noprofile.php");
}
$profile_info_set = get_profile_info();
while ($profile = mysql_fetch_array($profile_info_set))
if (isset ($profile_id))
if ($user['account_status'] == "Active")
if ($user['account_type'] == "Escort") {
include("includes/mod_profile/mod_profile.php");
}
else if ($block['blocked'] == '1') {
include("includes/mod_profile/mod_noprofile.php");
}
$profile_info3_set = get_profile_info3();
while ($profile = mysql_fetch_array($profile_info3_set))
if (isset ($profile_id))
if ($user['account_status'] == "Active")
if ($user['account_type'] == "Client") {
include("includes/mod_profile/mod_account.php");
}
?>
我的数据库中有一个表,用于将用户块状态从0设置为1。如果某个用户阻止了某人,而该用户试图访问他们的个人资料,那么我会尝试这样做,以便该用户转到另一个显示为blocked的页面。我通过这里的两个选项来实现这一点
像这样添加break
或die()
<?php
$blocked_users = blocked_users();
while ($block = mysql_fetch_array($blocked_users)) {
if ($block['blocked'] == '1') {
include("includes/mod_profile/mod_blocked.php");
break;
}
}
?>
我不确定我是否完全理解你在做什么,但当我把你的问题答对后,你可以用以下方式来做:
$page_title = "Profile";
include('includes/headerframe.php');
// stores the correct include file...
$toInclude = false;
// GET PROFILE ID FROM URL
if (isset ($_GET['id'])) {
$profile_id = $_GET['id'];
}
// look up for blocked user..
$blocked_users = blocked_users();
while ($block = mysql_fetch_array($blocked_users)) {
if ($block['blocked'] == '1') {
// don't do the include inside the loop
// we simply set the $toInclude
$toInclude = "includes/mod_profile/mod_blocked.php";
break;
}
}
$user_info_set = get_user_info();
// in case no include is set, and there is no profile...
if ( !$toInclude && (!$user = mysql_fetch_array($user_info_set) ||
!isset($profile_id)) ) {
// we set the $toInclude now
$toInclude = 'includes/mod_profile/mod_noprofile.php';
}
if($toInclude) {
// either blocked or no-profile
include($toInclude);
} else {
// user is not blocked, and you have a profile
// proceed with your code for normal user handling here
}
<?php
$blocked_users = blocked_users();
while ($block = mysql_fetch_array($blocked_users)) {
if ($block['blocked'] == '1') {
include("includes/mod_profile/mod_blocked.php");
break;
}
}
?>
<?php
$page_title = "Profile";
include ('includes/headerframe.php');
// GET PROFILE ID FROM URL
if (isset($_GET['id'])) {
$profile_id = $_GET['id'];
die();
}
$blocked_users = blocked_users();
while ($block = mysql_fetch_array($blocked_users)) {
if ($block['blocked'] == '1') {
include ("includes/mod_profile/mod_blocked.php");
} else {
$user_info_set = get_user_info();
if (!$user = mysql_fetch_array($user_info_set)) {
include ('includes/mod_profile/mod_noprofile.php');
} else if (!isset($profile_id)) {
include ("includes/mod_profile/mod_noprofile.php");
}
$profile_info_set = get_profile_info();
while ($profile = mysql_fetch_array($profile_info_set))
if (isset($profile_id))
if ($user['account_status'] == "Active")
if ($user['account_type'] == "Escort") {
include ("includes/mod_profile/mod_profile.php");
} else if ($block['blocked'] == '1') {
include ("includes/mod_profile/mod_noprofile.php");
}
$profile_info3_set = get_profile_info3();
while ($profile = mysql_fetch_array($profile_info3_set))
if (isset($profile_id))
if ($user['account_status'] == "Active")
if ($user['account_type'] == "Client") {
include ("includes/mod_profile/mod_account.php");
}
}
}
?>
$page_title = "Profile";
include('includes/headerframe.php');
// stores the correct include file...
$toInclude = false;
// GET PROFILE ID FROM URL
if (isset ($_GET['id'])) {
$profile_id = $_GET['id'];
}
// look up for blocked user..
$blocked_users = blocked_users();
while ($block = mysql_fetch_array($blocked_users)) {
if ($block['blocked'] == '1') {
// don't do the include inside the loop
// we simply set the $toInclude
$toInclude = "includes/mod_profile/mod_blocked.php";
break;
}
}
$user_info_set = get_user_info();
// in case no include is set, and there is no profile...
if ( !$toInclude && (!$user = mysql_fetch_array($user_info_set) ||
!isset($profile_id)) ) {
// we set the $toInclude now
$toInclude = 'includes/mod_profile/mod_noprofile.php';
}
if($toInclude) {
// either blocked or no-profile
include($toInclude);
} else {
// user is not blocked, and you have a profile
// proceed with your code for normal user handling here
}