本文整理汇总了PHP中Admin::object_modify方法的典型用法代码示例。如果您正苦于以下问题:PHP Admin::object_modify方法的具体用法?PHP Admin::object_modify怎么用?PHP Admin::object_modify使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Admin
的用法示例。
在下文中一共展示了Admin::object_modify方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: _
<!-- content -->
<div class="pContent">
<?php
# remove item from nat
$s = json_decode($nat->src, true);
$d = json_decode($nat->dst, true);
if (is_array($s[$_POST['type']])) {
$s[$_POST['type']] = array_diff($s[$_POST['type']], array($_POST['item_id']));
}
if (is_array($d[$_POST['type']])) {
$d[$_POST['type']] = array_diff($d[$_POST['type']], array($_POST['item_id']));
}
# save back and update
$src_new = json_encode(array_filter($s));
$dst_new = json_encode(array_filter($d));
if ($Admin->object_modify("nat", "edit", "id", array("id" => $_POST['id'], "src" => $src_new, "dst" => $dst_new)) !== false) {
$Result->show("success", "Object removed", false);
}
?>
</div>
<!-- footer -->
<div class="pFooter">
<div class="btn-group">
<button class="btn btn-sm btn-default hidePopup2"><?php
print _('Close');
?>
</button>
</div>
</div>
示例2: foreach
if (!$Subnets->modify_subnet($_POST['action'], $values)) {
$Result->show("danger", _('Error editing subnet'), true);
} else {
# if add save id !
if ($_POST['action'] == "add") {
$new_subnet_id = $Subnets->lastInsertId;
}
# update also all slave subnets if section changes!
if (isset($values['sectionId']) && $_POST['action'] == "edit" || $_POST['action'] == "delete") {
$Subnets->reset_subnet_slaves_recursive();
$Subnets->fetch_subnet_slaves_recursive($_POST['subnetId']);
$Subnets->remove_subnet_slaves_master($_POST['subnetId']);
if (sizeof($Subnets->slaves) > 0) {
foreach ($Subnets->slaves as $slaveId) {
if ($_POST['action'] == "edit") {
$Admin->object_modify("subnets", "edit", "id", array("id" => $slaveId, "sectionId" => $_POST['sectionIdNew']));
} else {
$Admin->object_modify("subnets", "delete", "id", array("id" => $slaveId));
}
}
}
}
# edit success
if ($_POST['action'] == "delete") {
$Result->show("success", _('Subnet, IP addresses and all belonging subnets deleted successfully') . '!', false);
} elseif ($_POST['action'] == "add") {
$Result->show("success", _("Subnet {$_POST['action']} successfull") . '!<div class="hidden subnet_id_new">' . $new_subnet_id . '</div><div class="hidden section_id_new">' . $values['sectionId'] . '</div>', false);
} else {
$Result->show("success", _("Subnet {$_POST['action']} successfull") . '!', false);
}
}
示例3: foreach
$Result->show("danger", _("Invalid ID"), true);
}
// Hostname must be present
if (@$_POST['name'] == "") {
$Result->show("danger", _('Name is mandatory') . '!', true);
}
// set sections
if (@$_POST['id'] != 1) {
foreach ($_POST as $key => $line) {
if (strlen(strstr($key, "section-")) > 0) {
$key2 = str_replace("section-", "", $key);
$temp[] = $key2;
unset($_POST[$key]);
}
}
# glue sections together
$_POST['permissions'] = sizeof($temp) > 0 ? implode(";", $temp) : null;
} else {
$_POST['permissions'] = "";
}
# set update values
$values = array("id" => @$_POST['id'], "name" => @$_POST['name'], "description" => @$_POST['description'], "permissions" => @$_POST['permissions']);
# update domain
if (!$Admin->object_modify("vlanDomains", $_POST['action'], "id", $values)) {
} else {
$Result->show("success", _("Domain {$_POST['action']} successfull") . '!', false);
}
# if delete move all vlans to default domain!
if ($_POST['action'] == "delete") {
$Admin->update_object_references("vlans", "domainId", $_POST['id'], 1);
}
示例4: subnet_split
/**
* This function splits subnet into smaller subnets
*
* @access private
* @param mixed $subnet_old
* @param mixed $number
* @param mixed $prefix
* @param string $group (default: "yes")
* @param string $strict (default: "yes")
* @return void
*/
public function subnet_split($subnet_old, $number, $prefix, $group = "yes", $strict = "yes")
{
# we first need to check if it is ok to split subnet and get parameters
$check = $this->verify_subnet_split($subnet_old, $number, $group, $strict);
# ok, extract parameters from result array - 0 is $newsubnets and 1 is $addresses
$newsubnets = $check[0];
$addresses = $check[1];
# admin object
$Admin = new Admin($this->Database, false);
# create new subnets and change subnetId for recalculated hosts
$m = 0;
foreach ($newsubnets as $subnet) {
//set new subnet insert values
$values = array("description" => strlen($prefix) > 0 ? $prefix . ($m + 1) : "split_subnet_" . ($m + 1), "subnet" => $subnet['subnet'], "mask" => $subnet['mask'], "sectionId" => $subnet['sectionId'], "masterSubnetId" => $subnet['masterSubnetId'], "vlanId" => @$subnet['vlanId'], "vrfId" => @$subnet['vrfId'], "allowRequests" => @$subnet['allowRequests'], "showName" => @$subnet['showName'], "permissions" => $subnet['permissions']);
//create new subnets
$this->modify_subnet("add", $values);
//get all address ids
unset($ids);
foreach ($addresses as $ip) {
if ($ip->subnetId == $m) {
$ids[] = $ip->id;
}
}
//replace all subnetIds in IP addresses to new subnet
if (isset($ids)) {
if (!$Admin->object_modify("ipaddresses", "edit-multiple", $ids, array("subnetId" => $this->lastInsertId))) {
$Result->show("danger", _("Failed to move IP address"), true);
}
}
# next
$m++;
}
# do we need to remove old subnet?
if ($group != "yes") {
if (!$Admin->object_modify("subnets", "delete", "id", array("id" => $subnet_old->id))) {
$Result->show("danger", _("Failed to remove old subnet"), true);
}
}
# result
return true;
}
示例5: Subnets
$Subnets = new Subnets($Database);
$DNS = new DNS($Database);
$Result = new Result();
# insert to database
$discovered = 0;
//for mailing
foreach ($scan_subnets as $s) {
if (sizeof(@$s->discovered) > 0) {
foreach ($s->discovered as $ip) {
// try to resolve hostname
$tmp = new stdClass();
$tmp->ip_addr = $ip;
$hostname = $DNS->resolve_address($tmp, true);
//set update query
$values = array("subnetId" => $s->id, "ip_addr" => $Subnets->transform_address($ip, "decimal"), "dns_name" => $hostname['name'], "description" => "-- autodiscovered --", "note" => "This host was autodiscovered on " . date("Y-m-d H:i:s"), "lastSeen" => date("Y-m-d H:i:s"));
$Admin->object_modify("ipaddresses", "add", "id", $values);
//set discovered
$discovered++;
}
}
}
# send mail
if ($discovered > 0 && $send_mail) {
# check for recipients
foreach ($Admin->fetch_multiple_objects("users", "role", "Administrator") as $admin) {
if ($admin->mailNotify == "Yes") {
$recepients[] = array("name" => $admin->real_name, "email" => $admin->email);
}
}
# none?
if (!isset($recepients)) {
示例6: implode
$query[] = 'order by `ip_addr` ASC;';
//join
$query = implode("\n", $query);
}
# fetch records
$ipaddresses = $Database->getObjectsQuery($query);
# try to update dns records
foreach ($ipaddresses as $ip) {
# fetch subnet
$subnet = $Subnets->fetch_subnet("id", $ip->subnetId);
$nsid = $subnet === false ? false : $subnet->nameserverId;
# try to resolve
$hostname = $DNS->resolve_address($ip->ip_addr, null, true, $nsid);
# update if change
if ($hostname['name'] != $Subnets->transform_to_dotted($ip->ip_addr)) {
# values
$values = array("dns_name" => $hostname['name'], "id" => $ip->id);
# execute
if (!$Admin->object_modify("ipaddresses", "edit", "id", $values)) {
$Result->show_cli("Failed to update address " . $Subnets->transform_to_dotted($ip->ip_addr));
}
# set text
$res[] = 'updated ip address ' . $Subnets->transform_to_dotted($ip->ip_addr) . ' with hostname ' . $hostname['name'];
}
}
# if verbose print result so it can be emailed via cron!
if ($resolve_config['verbose'] == 1) {
foreach ($res as $line) {
print $line . "\n";
}
}
示例7: 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();
# ID must be numeric */
if ($_POST['action'] != "add") {
if (!is_numeric($_POST['wid'])) {
$Result->show("danger", _("Invalid ID"), true);
}
}
# Title and path must be present!
if ($_POST['action'] != "delete") {
if (strlen($_POST['wtitle']) == 0 || strlen($_POST['wfile']) == 0) {
$Result->show("danger", _("Filename and title are mandatory") . "!", true);
}
}
# Remove .php form wfile if it is present
$_POST['wfile'] = str_replace(".php", "", trim(@$_POST['wfile']));
# set update values
$values = array("wid" => @$_POST['wid'], "wtitle" => $_POST['wtitle'], "wdescription" => @$_POST['wdescription'], "wfile" => $_POST['wfile'], "wadminonly" => $_POST['wadminonly'], "wactive" => $_POST['wactive'], "whref" => $_POST['whref'], "wsize" => $_POST['wsize']);
# update
if (!$Admin->object_modify("widgets", $_POST['action'], "wid", $values)) {
$Result->show("danger", _("Widget {$_POST['action']} error") . "!", true);
} else {
$Result->show("success", _("Widget {$_POST['action']} success") . "!", true);
}
示例8: foreach
}
# fetch custom fields
$custom = $Tools->fetch_custom_fields('locations');
if (sizeof($custom) > 0) {
foreach ($custom as $myField) {
//booleans can be only 0 and 1!
if ($myField['type'] == "tinyint(1)") {
if ($_POST[$myField['name']] > 1) {
$_POST[$myField['name']] = 0;
}
}
//not null!
if ($myField['Null'] == "NO" && strlen($_POST[$myField['name']]) == 0) {
$Result->show("danger", $myField['name'] . '" can not be empty!', true);
}
# save to update array
$update[$myField['name']] = $_POST[$myField['name']];
}
}
// set values
$values = array("id" => @$_POST['id'], "name" => $_POST['name'], "address" => $_POST['address'], "lat" => $_POST['lat'], "long" => $_POST['long'], "description" => $_POST['description']);
# custom fields
if (isset($update)) {
$values = array_merge($values, $update);
}
# execute update
if (!$Admin->object_modify("locations", $_POST['action'], "id", $values)) {
$Result->show("danger", _("Location {$_POST['action']} failed"), false);
} else {
$Result->show("success", _("Location {$_POST['action']} successful"), false);
}
示例9: foreach
//booleans can be only 0 and 1!
if ($myField['type'] == "tinyint(1)") {
if ($_POST[$myField['name']] > 1) {
$_POST[$myField['name']] = 0;
}
}
//not null!
if ($myField['Null'] == "NO" && strlen($_POST[$myField['name']]) == 0) {
$Result->show("danger", $myField['name'] . '" can not be empty!', true);
}
# save to update array
$values[$myField['name']] = $_POST[$myField['name']];
}
}
# execute
if (!$Admin->object_modify("subnets", $_POST['action'], "id", $values)) {
$Result->show("danger", _('Error editing subnet'), true);
} else {
# update also all slave subnets!
if (isset($values['sectionId']) && $_POST['action'] != "add") {
$Subnets->reset_subnet_slaves_recursive();
$Subnets->fetch_subnet_slaves_recursive($_POST['subnetId']);
$Subnets->remove_subnet_slaves_master($_POST['subnetId']);
if (sizeof($Subnets->slaves) > 0) {
foreach ($Subnets->slaves as $slaveId) {
$Admin->object_modify("subnets", "edit", "id", array("id" => $slaveId, "sectionId" => $_POST['sectionIdNew']));
}
}
}
# edit success
if ($_POST['action'] == "delete") {
示例10: dirname
/* functions */
require dirname(__FILE__) . '/../../functions/functions.php';
/* @mail functions ------------------- */
require dirname(__FILE__) . '/../../functions/classes/class.Mail.php';
# initialize user object
$Database = new Database_PDO();
$Subnets = new Subnets($Database);
$Tools = new Tools($Database);
$Admin = new Admin($Database, false);
$Result = new Result();
# fetch settings, user is not authenticated !
$settings = $Tools->fetch_settings();
# requests must be enabled!
if ($settings['enableIPrequests'] == 1) {
# verify email
if (!$Result->validate_email($_POST['requester'])) {
$Result->show("danger", _('Please provide valid email address') . '! (' . _('requester') . ': ' . $_POST['requester'] . ')', true);
}
# formulate insert values
$values = array("subnetId" => $_POST['subnetId'], "ip_addr" => @$_POST['ip_addr'], "description" => @$_POST['description'], "dns_name" => @$_POST['dns_name'], "owner" => $_POST['owner'], "requester" => $_POST['requester'], "comment" => @$_POST['comment'], "processed" => 0);
if (!$Admin->object_modify("requests", "add", "id", $values)) {
$Result->show("danger", _('Error submitting new IP address request'), true);
} else {
$Result->show("success", _('Request submitted successfully'));
# send mail
//if(!sendIPReqEmail($_POST)) { $Result->show("danger", _('Sending mail for new IP request failed'), true); }
//else { $Result->show("success", _('Sending mail for IP request succeeded'), true); }
}
} else {
$Result->show("danger", _('IP requests disabled'), true);
}
示例11: array
// save
$password = array_pop(readline_list_history());
}
}
// validate password
if (strlen($password) < 8) {
$Result->show_cli("Password must be at least 8 characters long", true);
}
// hash passowrd
$password_crypted = $User->crypt_user_pass($password);
// save type
$crypt_type = $User->return_crypt_type();
// set update array
$values = array("id" => 1, "password" => $password_crypted);
// update password
if (!$Admin->object_modify("users", "edit", "id", $values)) {
$Result->show_cli("Failed to update Admin password", false);
} else {
$Result->show_cli("Admin password updated", false);
}
// debug ?
if ($debugging || $fail) {
$Result->show_cli("---------");
$Result->show_cli("Crypt type: " . $crypt_type);
$Result->show_cli("Password: " . $password_crypted);
$Result->show_cli("---------");
}
// fail
if ($fail) {
die;
}
示例12: unset
$_POST['csrf_cookie'] == $_SESSION['csrf_cookie'] ?: $Result->show("danger", _("Invalid CSRF cookie"), true);
# get action
$action = $_POST['action'];
//for adding remove id
if ($action == "add") {
unset($_POST['id']);
} else {
//check id
if (!is_numeric($_POST['id'])) {
$Result->show("danger", _("Invalid ID"), true);
}
}
# set update query
$values = array("id" => @$_POST['id'], "type" => $_POST['type'], "description" => @$_POST['description']);
# add params
unset($_POST['id'], $_POST['type'], $_POST['description'], $_POST['action']);
$values["params"] = json_encode($_POST);
# add - set protected
if ($action == "add") {
$values['protected'] = "No";
}
# update
if (!$Admin->object_modify("usersAuthMethod", $action, "id", $values)) {
$Result->show("danger", _("Failed to edit authentication method"), false);
} else {
$Result->show("success", _("Authentication method updated"), false);
}
# if delete also reset all users that have thos auth method
if ($action == "delete") {
$Database->runQuery("update `users` set `authMethod`=1 where `authMethod`= ?;", array($values['id']));
}
示例13: strlen
if (strpos($key, $f['name']) !== false) {
$res[substr($key, strlen($f['name']))][$f['name']] = $line;
}
}
}
}
# insert entries
if (sizeof($res) > 0) {
$errors = 0;
foreach ($res as $r) {
# set insert values
$values = array("rd" => $r['rd'], "name" => $r['name'], "description" => $r['description']);
# custom fields
if (isset($required_fields)) {
foreach ($required_fields as $k => $f) {
$values[$f['name']] = $r[$f['name']];
}
}
# insert vrfs
if (!$Admin->object_modify("vrf", "add", "vrfId", $values)) {
$Result->show("danger", _("Failed to import entry") . " " . $r['number'] . " " . $r['name'], false);
$errors++;
}
}
# success if no errors
if ($errors == 0) {
$Result->show("success", _("Scan results added to database") . "!", true);
}
} else {
$Result->show("danger", _("No entries available"), true);
}
示例14: foreach
<?php
$msg = "";
$rows = "";
# Update Subnet master
foreach ($rlist as $sect_id => $sect_check) {
# Skip empty sections
if (!$edata[$sect_id]) {
continue;
}
# Grab a subnet and find its closest master
foreach ($edata[$sect_id] as &$c_subnet) {
if ($c_subnet['action'] == "edit") {
# We only need id and new master
$values = array("id" => $c_subnet['id'], "masterSubnetId" => $c_subnet['new_masterSubnetId']);
# update
$c_subnet['result'] = $Admin->object_modify("subnets", $c_subnet['action'], "id", $values);
if ($c_subnet['result']) {
$trc = $colors[$c_subnet['action']];
$msg = "Master " . $c_subnet['action'] . " successful.";
} else {
$trc = "danger";
$msg = "Master " . $c_subnet['action'] . " failed.";
}
$rows .= "<tr class='" . $trc . "'><td><i class='fa " . $icons[$c_subnet['action']] . "' rel='tooltip' data-placement='bottom' title='" . _($msg) . "'></i></td>";
$rows .= "<td>" . $sect_names[$sect_id] . "</td><td>" . $c_subnet['ip'] . "/" . $c_subnet['mask'] . "</td>";
$rows .= "<td>" . $c_subnet['description'] . "</td><td>" . $vrf_name[$c_subnet['vrfId']] . "</td><td>";
$rows .= $c_subnet['new_master'] . "</td><td>" . _($msg) . "</td></tr>\n";
}
}
}
print "<table class='table table-condensed table-hover' id='resultstable'><tbody>";
示例15: foreach
$Result->show("danger", _("Name is mandatory"), true);
}
if ($_POST['namesrv1'] == "") {
$Result->show("danger", _("Primary nameserver is mandatory"), true);
}
// set sections
if (@$_POST['nameserverId'] != 1) {
foreach ($_POST as $key => $line) {
if (strlen(strstr($key, "section-")) > 0) {
$key2 = str_replace("section-", "", $key);
$temp[] = $key2;
unset($_POST[$key]);
}
}
# glue sections together
$_POST['permissions'] = sizeof($temp) > 0 ? implode(";", $temp) : null;
} else {
$_POST['permissions'] = "";
}
# set update array
$values = array("id" => @$_POST['nameserverId'], "name" => $_POST['name'], "namesrv1" => $_POST['namesrv1'], "namesrv2" => $_POST['namesrv2'], "namesrv3" => $_POST['namesrv3'], "description" => $_POST['description'], "permissions" => $_POST['permissions']);
# update
if (!$Admin->object_modify("nameservers", $_POST['action'], "nameserverid", $values)) {
$Result->show("danger", _("Failed to {$_POST['action']} nameserver set") . '!', true);
} else {
$Result->show("success", _("Nameserver set {$_POST['action']} successfull") . '!', false);
}
# remove all references if delete
if ($_POST['action'] == "delete") {
$Admin->remove_object_references("nameservers", "id", $_POST['nameserverId']);
}