本文整理汇总了PHP中Admin::fetch_object方法的典型用法代码示例。如果您正苦于以下问题:PHP Admin::fetch_object方法的具体用法?PHP Admin::fetch_object怎么用?PHP Admin::fetch_object使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Admin
的用法示例。
在下文中一共展示了Admin::fetch_object方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: dirname
* Script to confirm / reject IP address request
***********************************************/
/* functions */
require dirname(__FILE__) . '/../../../functions/functions.php';
# initialize user object
$Database = new Database_PDO();
$User = new User($Database);
$Admin = new Admin($Database, false);
$Addresses = new Addresses($Database);
$Subnets = new Subnets($Database);
$Tools = new Tools($Database);
$Result = new Result();
# verify that user is logged in
$User->check_user_session();
# fetch request
$request = $Admin->fetch_object("requests", "id", $_POST['requestId']);
//fail
if ($request === false) {
$Result->show("danger", _("Request does not exist"), true, true);
} else {
$request = (array) $request;
}
# verify permissions
if ($Subnets->check_permission($User->user, $request['subnetId']) != 3) {
$Result->show("danger", _('You do not have permissions to process this request') . "!", true, true);
}
# set IP address
# if provided (requested from logged in user) check if already in use, if it is warn and set next free
# else get next free
if (strlen($request['ip_addr']) > 0) {
// check if it exists
示例2: dirname
*************************************************/
/* functions */
require dirname(__FILE__) . '/../../../functions/functions.php';
# initialize user object
$Database = new Database_PDO();
$User = new User($Database);
$Admin = new Admin($Database);
$Result = new Result();
# verify that user is logged in
$User->check_user_session();
# fetch group and set title
if ($_POST['action'] == "add") {
$title = _('Add new group');
} else {
//fetch all group details
$group = (array) $Admin->fetch_object("userGroups", "g_id", $_POST['id']);
//false die
$group !== false ?: $Result->show("danger", _("Invalid ID"), true, true);
$title = ucwords($_POST['action']) . ' ' . _('group') . ' ' . $group['g_name'];
}
?>
<!-- header -->
<div class="pHeader"><?php
print $title;
?>
</div>
<!-- content -->
<div class="pContent">
示例3: get_active_user_id
/**
* Gets id of active user
*
* @access private
* @return void
*/
private function get_active_user_id()
{
# cache
if ($this->user_id === null) {
# null
$user_id = null;
if (!isset($_SESSION['ipamusername'])) {
// when API calls subnet_create we get:
// Error: SQLSTATE[23000]: Integrity constraint violation: 1048 Column 'cuser' cannot be null
// so let's get a user_id
if (array_key_exists("HTTP_PHPIPAM_TOKEN", $_SERVER)) {
$admin = new Admin($this->Database, False);
$token = $admin->fetch_object("users", "token", $_SERVER['HTTP_PHPIPAM_TOKEN']);
if ($token === False) {
$this->user_id = null;
} else {
$user_id = $token;
}
} else {
$this->user_id = null;
}
} else {
try {
$user_id = $this->Database->getObjectQuery("select * from `users` where `username` = ? limit 1", array($_SESSION['ipamusername']));
} catch (Exception $e) {
$this->Result->show("danger", _("Database error: ") . $e->getMessage());
}
}
# save id
$this->user_id = $user_id->id;
# save user
$this->user = $user_id;
}
}
示例4: User
$Database = new Database_PDO();
$User = new User($Database);
$Admin = new Admin($Database);
$Tools = new Tools($Database);
$Result = new Result();
# verify that user is logged in
$User->check_user_session();
// checks
if (!is_numeric($_POST['newDomainId'])) {
$Result->show("danger", _("Invalid ID"), true);
}
if (!is_numeric($_POST['vlanId'])) {
$Result->show("danger", _("Invalid ID"), true);
}
// verify that new exists
$vlan_domain = $Admin->fetch_object("vlanDomains", "id", $_POST['newDomainId']);
if ($vlan_domain === false) {
$Result->show("danger", _("Invalid ID"), true);
}
//fetch vlan
$vlan = $Admin->fetch_object("vlans", "vlanId", $_POST['vlanId']);
if ($vlan === false) {
$Result->show("danger", _("Invalid ID"), true);
}
// check that it is not already set !
if ($User->settings->vlanDuplicate == 0) {
$check_vlan = $Admin->fetch_multiple_objects("vlans", "domainId", $vlan_domain->id, "vlanId");
if ($check_vlan !== false) {
foreach ($check_vlan as $v) {
if ($v->number == $vlan->number) {
$Result->show("danger", _("VLAN already exists"), true);
示例5: dirname
<?php
/* functions */
require dirname(__FILE__) . '/../../../functions/functions.php';
# initialize user object
$Database = new Database_PDO();
$User = new User($Database);
$Admin = new Admin($Database);
$Result = new Result();
# verify that user is logged in
$User->check_user_session();
# if edit check if protected?
if ($_POST['action'] != "add") {
$auth_method = $Admin->fetch_object("usersAuthMethod", "id", $_POST['id']);
if ($auth_method->protected == "Yes") {
$Result->show("danger", _("Method cannot be change as it is protected"), true, true);
}
}
# route to proper auth method editing
if (!file_exists(dirname(__FILE__) . "/edit-{$_POST['type']}.php")) {
$Result->show("danger", _("Invalid method type"), true, true);
} else {
include "edit-{$_POST['type']}.php";
}
示例6: dirname
*************************************/
/* functions */
require dirname(__FILE__) . '/../../../functions/functions.php';
# initialize user object
$Database = new Database_PDO();
$User = new User($Database);
$Admin = new Admin($Database);
$Result = new Result();
# verify that user is logged in
$User->check_user_session();
/* checks */
$error = array();
# for edit check old details
if ($_POST['action'] == "edit" || $_POST['action'] == "delete") {
# old
$agent_old = $Admin->fetch_object("scanAgents", "id", $_POST['id']);
// invalid id
if ($agent_old === false) {
$error[] = "Invalid agent Id";
}
// remove type and code if direct
if (@$agent_old->type == "direct") {
unset($_POST['type'], $_POST['code']);
}
}
# die if direct and delete
if (@$agent_old->type == "direct" && $_POST['action'] == "delete") {
$Result->show("danger", _("Cannot remove localhost scan agent"), true);
}
# checks for edit / add
if ($_POST['action'] != "delete") {
示例7: dirname
/**
* remove item from nat
************************************************/
/* functions */
require dirname(__FILE__) . '/../../../functions/functions.php';
# initialize user object
$Database = new Database_PDO();
$User = new User($Database);
$Admin = new Admin($Database);
$Tools = new Tools($Database);
$Result = new Result();
# verify that user is logged in
$User->check_user_session();
# get NAT object
$nat = $Admin->fetch_object("nat", "id", $_POST['id']);
$nat !== false ?: $Result->show("danger", _("Invalid ID"), true);
# static NAT checks
if ($nat->type == "static") {
// static NAT can only have IP address
if ($_POST['object_type'] != "ipaddresses") {
$Result->show("danger", _("Static NAT can only contain IP address"), true);
}
// decode
$nat_src = json_decode($nat->src, true);
$nat_dst = json_decode($nat->dst, true);
// validate all objects
if (sizeof(@$nat_src['ipaddresses']) > 0) {
foreach ($nat_src['ipaddresses'] as $ik => $iv) {
if ($Tools->fetch_object("ipaddresses", "id", $iv) === false) {
unset($nat_src['ipaddresses'][$ik]);
示例8: dirname
/**
* Mail settings
**************************/
/* functions */
require dirname(__FILE__) . '/../../../functions/functions.php';
require dirname(__FILE__) . '/../../../functions/classes/class.Mail.php';
# initialize user object
$Database = new Database_PDO();
$User = new User($Database);
$Admin = new Admin($Database);
$Result = new Result();
# verify that user is logged in
$User->check_user_session();
# fetch mailer settings
$mail_settings = $Admin->fetch_object("settingsMail", "id", 1);
# initialize mailer
$phpipam_mail = new phpipam_mail($User->settings, $mail_settings);
//override settings
$phpipam_mail->override_settings($_POST);
//create object
$phpipam_mail->initialize_mailer();
# set content
$content = $phpipam_mail->generate_message("phpIPAM test HTML message");
$content_plain = "phpIPAM test text message";
# try to send
try {
$phpipam_mail->Php_mailer->setFrom($_POST['mAdminMail'], $_POST['mAdminName']);
$phpipam_mail->Php_mailer->addAddress($User->settings->siteAdminMail, $User->settings->siteAdminName);
$phpipam_mail->Php_mailer->Subject = 'phpIPAM localhost mail test';
$phpipam_mail->Php_mailer->msgHTML($content);
示例9: array
# verify that user is logged in
$User->check_user_session();
# validate csrf cookie
$_POST['csrf_cookie'] == $_SESSION['csrf_cookie'] ?: $Result->show("danger", _("Invalid CSRF cookie"), true);
# remove users from this group if delete and remove group from sections
if ($_POST['action'] == "delete") {
$Admin->remove_group_from_users($_POST['g_id']);
$Admin->remove_group_from_sections($_POST['g_id']);
} else {
if (strlen($_POST['g_name']) < 2) {
$Result->show("danger", _('Name must be at least 2 characters long') . "!", true);
}
}
# unique name
if ($_POST['action'] == "add") {
if ($Admin->fetch_object("userGroups", "g_name", $_POST['g_name']) !== false) {
$Result->show("danger", _('Group already exists') . "!", true);
}
}
# create array of values for modification
$values = array("g_id" => @$_POST['g_id'], "g_name" => $_POST['g_name'], "g_desc" => @$_POST['g_desc']);
/* try to execute */
if (!$Admin->object_modify("userGroups", $_POST['action'], "g_id", $values)) {
$Result->show("danger", _("Group {$_POST['action']} error") . "!", false);
} else {
$Result->show("success", _("Group {$_POST['action']} success") . "!", false);
}
# from list of usernames provided from AD result if some user matches add him to group
if (strlen($_POST['gmembers']) > 0) {
// save id
$gid = $Admin->lastId;
示例10: dirname
/* functions */
require dirname(__FILE__) . '/../../../functions/functions.php';
# initialize user object
$Database = new Database_PDO();
$User = new User($Database);
$Admin = new Admin($Database);
$Tools = new Tools($Database);
$Sections = new Sections($Database);
$Result = new Result();
# verify that user is logged in
$User->check_user_session();
# create csrf token
$csrf = $User->csrf_cookie("create", "vrf");
# get VRF
if ($_POST['action'] != "add") {
$vrf = $Admin->fetch_object("vrf", "vrfId", $_POST['vrfId']);
$vrf !== false ?: $Result->show("danger", _("Invalid ID"), true, true);
$vrf = (array) $vrf;
}
# disable edit on delete
$readonly = $_POST['action'] == "delete" ? "readonly" : "";
# fetch custom fields
$custom = $Tools->fetch_custom_fields('vrf');
?>
<!-- header -->
<div class="pHeader"><?php
print ucwords(_("{$_POST['action']}"));
?>
<?php
示例11: foreach
if ($_POST['validity'] < date("Y-m-d H:i:s")) {
$Result->show("danger", _("Invalid date"), true);
}
if ($_POST['validity'] > date("Y-m-d H:i:s", strtotime("+ 7 days"))) {
$Result->show("danger", _("1 week is max validity time"), true);
}
# verify each recipient
if (strlen($_POST['email']) > 0) {
foreach (explode(",", $_POST['email']) as $rec) {
if (!filter_var(trim($rec), FILTER_VALIDATE_EMAIL)) {
$Result->show("danger", _("Invalid email address") . " - " . $rec, true);
}
}
}
# fetch object
$object = $Admin->fetch_object($_POST['type'], "id", $_POST['id']);
if ($_POST['type'] == "subnets") {
$tmp[] = "Share type: subnet";
$tmp[] = "\t" . $Subnets->transform_to_dotted($object->subnet) . "/{$object->mask}";
$tmp[] = "\t" . $object->description;
} else {
$tmp[] = "Share type: IP address";
$tmp[] = "\t" . $Subnets->transform_to_dotted($object->ip_addr);
$tmp[] = "\t" . $object->description;
}
# set new access
$new_access[$_POST['code']] = array("id" => $_POST['id'], "type" => $_POST['type'], "code" => $_POST['code'], "validity" => strtotime($_POST['validity']), "userId" => $User->user->id);
# create array of values for modification
$old_access = json_decode($User->settings->tempAccess, true);
if (!is_array($old_access)) {
$old_access = array();
示例12: ucwords
$Database = new Database_PDO();
$User = new User($Database);
$Admin = new Admin($Database);
$Tools = new Tools($Database);
$Result = new Result();
# verify that user is logged in
$User->check_user_session();
# create csrf token
$csrf = $User->csrf_cookie("create", "widget");
# strip tags - XSS
$_POST = $User->strip_input_tags($_POST);
# validate action
$Admin->validate_action($_POST['action'], true);
# fetch widget
if ($_POST['action'] != "add") {
$w = $Admin->fetch_object("widgets", "wid", $_POST['wid']);
$w !== false ?: $Result->show("danger", _("Invalid ID"), true, true);
$w = (array) $w;
}
?>
<!-- header -->
<div class="pHeader"><?php
print ucwords($_POST['action']) . " widget";
?>
</div>
<!-- content -->
<div class="pContent">
<form id="widgetEdit" name="widgetEdit">
示例13: dirname
require dirname(__FILE__) . '/../../../functions/functions.php';
# initialize user object
$Database = new Database_PDO();
$User = new User($Database);
$Admin = new Admin($Database);
$Tools = new Tools($Database);
$Result = new Result();
# verify that user is logged in
$User->check_user_session();
# strip input tags
$_POST = $Admin->strip_input_tags($_POST);
# validate csrf cookie
$User->csrf_cookie("validate", "location", $_POST['csrf_cookie']) === false ? $Result->show("danger", _("Invalid CSRF cookie"), true) : "";
# validations
if ($_POST['action'] == "delete" || $_POST['action'] == "edit") {
if ($Admin->fetch_object('locations', "id", $_POST['id']) === false) {
$Result->show("danger", _("Invalid Location object identifier"), false);
}
}
if ($_POST['action'] == "add" || $_POST['action'] == "edit") {
// name
if (strlen($_POST['name']) < 3) {
$Result->show("danger", _("Name must have at least 3 characters"), true);
}
// lat, long
if ($_POST['action'] !== "delete") {
// lat
if (strlen($_POST['lat']) > 0) {
if (!preg_match('/^(\\-?\\d+(\\.\\d+)?).\\s*(\\-?\\d+(\\.\\d+)?)$/', $_POST['lat'])) {
$Result->show("danger", _("Invalid Latitude"), true);
}
示例14: substr
# id must be numeric
if (!is_numeric($_POST['gid'])) {
$Result->show("danger", _("Invalid ID"), true);
}
# parse result
foreach ($_POST as $k => $p) {
if (substr($k, 0, 4) == "user") {
$users[substr($k, 4)] = substr($k, 4);
}
}
# remove each user from group
if (sizeof($users) > 0) {
foreach ($users as $key => $u) {
if (!$Admin->remove_group_from_user($_POST['gid'], $u)) {
# get user details
$user = $Admin->fetch_object("users", "id", $u);
$errors[] = $user->real_name;
}
}
} else {
$errors[] = _("Please select user(s) to remove from group!");
}
# print result
if (isset($errors)) {
print "<div class='alert alert alert-danger'>";
print _("Failed to remove users") . ":<hr>";
print "<ul>";
foreach ($errors as $e) {
print "<li>{$e}</li>";
}
print "</ul>";
示例15: dirname
* Print all available nameserver sets and configurations
************************************************/
/* functions */
require dirname(__FILE__) . '/../../../functions/functions.php';
# initialize user object
$Database = new Database_PDO();
$User = new User($Database);
$Admin = new Admin($Database);
$Tools = new Tools($Database);
$Sections = new Sections($Database);
$Result = new Result();
# verify that user is logged in
$User->check_user_session();
# get Nameserver sets
if ($_POST['action'] != "add") {
$nameservers = $Admin->fetch_object("nameservers", "id", $_POST['nameserverId']);
$nameservers !== false ?: $Result->show("danger", _("Invalid ID"), true, true);
$nameservers = (array) $nameservers;
}
# disable edit on delete
$readonly = $_POST['action'] == "delete" ? "readonly" : "";
?>
<!-- header -->
<div class="pHeader"><?php
print ucwords(_("{$_POST['action']}"));
?>
<?php
print _('Nameserver set');
?>