php CheckLoginOrDie类(方法)实例源码

下面列出了php CheckLoginOrDie 类(方法)源码代码实例,从而了解它的用法。

作者:mahyuddi    项目:emulab-stabl   
#
# This file is distributed in the hope that it will be useful, but WITHOUT
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
# FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Affero General Public
# License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this file.  If not, see <http://www.gnu.org/licenses/>.
#
# }}}
#
include "defs.php3";
#
# Only admin users ...
#
$this_user = CheckLoginOrDie();
$uid = $this_user->uid();
$isadmin = ISADMIN();
if (!$isadmin) {
    USERERROR("You do not have permission to change login names!", 1);
}
#
# Verify page/form arguments.
#
$reqargs = RequiredPageArguments("target_user", PAGEARG_USER);
$optargs = OptionalPageArguments("submit", PAGEARG_STRING, "new_uid", PAGEARG_STRING);
$target_uid = $target_user->uid();
$target_idx = $target_user->uid_idx();
if ($target_user->status() != TBDB_USERSTATUS_UNAPPROVED) {
    USERERROR("The user {$target_uid} must be " . "unapproved (but verified) to change!", 1);
}

作者:mahyuddi    项目:emulab-stabl   
# }}}
#
include "defs.php3";
#
# This page is a generic toggle page, like adminmode.php3, but more
# generalized. There are a set of things you can toggle, and each of
# those items has a permission check and a set (pair) of valid values.
#
# Usage: toggle.php?type=swappable&value=1&pid=foo&eid=bar
# (type & value are required, others are optional and vary by type)
#
# No PAGEHEADER since we spit out a Location header later. See below.
#
# Only known and logged in users can do this.
#
$this_user = CheckLoginOrDie(CHECKLOGIN_USERSTATUS | CHECKLOGIN_WEBONLY);
$uid = $this_user->uid();
$isadmin = ISADMIN();
# List of valid toggles
$toggles = array("adminon", "webfreeze", "cvsweb", "lockdown", "stud", "cvsrepo_public", "workbench", "hiderun", "widearearoot", "imageglobal", "skipvlans", "adminflag", "imagedoesxen");
# list of valid values for each toggle
$values = array("adminon" => array(0, 1), "webfreeze" => array(0, 1), "cvsweb" => array(0, 1), "stud" => array(0, 1), "lockdown" => array(0, 1), "skipvlans" => array(0, 1), "cvsrepo_public" => array(0, 1), "workbench" => array(0, 1), "widearearoot" => array(0, 1), "imageglobal" => array(0, 1), "imagedoesxen" => array(0, 1), "adminflag" => array(0, 1), "hiderun" => array(0, 1));
# list of valid extra variables for the each toggle, and mandatory flag.
$optargs = array("adminon" => array(), "webfreeze" => array("user" => 1), "cvsweb" => array("user" => 1), "stud" => array("user" => 1), "lockdown" => array("pid" => 1, "eid" => 1), "skipvlans" => array("pid" => 1, "eid" => 1), "cvsrepo_public" => array("pid" => 1), "workbench" => array("pid" => 1), "widearearoot" => array("user" => 1), "imageglobal" => array("imageid" => 1), "imagedoesxen" => array("imageid" => 1), "adminflag" => array("user" => 1), "hiderun" => array("instance" => 1, "runidx" => 1));
# Mandatory page arguments.
$reqargs = RequiredPageArguments("type", PAGEARG_STRING, "value", PAGEARG_STRING);
# Where we zap to.
$zapurl = null;
if (!in_array($type, $toggles)) {
    PAGEARGERROR("There is no toggle for {$type}!");
}


问题


面经


文章

微信
公众号

扫码关注公众号