本文整理汇总了PHP中Toolbox::clean_cross_side_scripting_deep方法的典型用法代码示例。如果您正苦于以下问题:PHP Toolbox::clean_cross_side_scripting_deep方法的具体用法?PHP Toolbox::clean_cross_side_scripting_deep怎么用?PHP Toolbox::clean_cross_side_scripting_deep使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Toolbox
的用法示例。
在下文中一共展示了Toolbox::clean_cross_side_scripting_deep方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: methodsetTicketSolution
/**
* Solution of a ticket for an authenticated user
*
* @param $params array of options (ticket, id2name)
* @param $protocol the communication protocol used
*
* @return array of hashtable as glpi.getTicket
**/
static function methodsetTicketSolution($params, $protocol)
{
global $DB, $CFG_GLPI;
if (isset($params['help'])) {
return array('ticket' => 'integer,mandatory', 'id2name' => 'bool,optional', 'type' => 'integer,optional', 'solution' => 'text,mandatory', 'help' => 'bool,optional');
}
if (!Session::getLoginUserID()) {
return self::Error($protocol, WEBSERVICES_ERROR_NOTAUTHENTICATED);
}
$ticket = new Ticket();
if (!isset($params['ticket'])) {
return self::Error($protocol, WEBSERVICES_ERROR_MISSINGPARAMETER, '', 'ticket');
}
if (!isset($params['solution'])) {
return self::Error($protocol, WEBSERVICES_ERROR_MISSINGPARAMETER, '', 'solution');
}
if (isset($params['type']) && !is_numeric($params['type'])) {
return self::Error($protocol, WEBSERVICES_ERROR_BADPARAMETER, '', 'type=' . $params['type']);
}
if (!$ticket->can($params['ticket'], 'r')) {
return self::Error($protocol, WEBSERVICES_ERROR_NOTFOUND, '', 'ticket');
}
if (!$ticket->getFromDB($params['ticket'])) {
return self::Error($protocol, WEBSERVICES_ERROR_NOTFOUND, '', 'solution');
}
$input = array('id' => $ticket->getField('id'), 'solution' => addslashes(Toolbox::clean_cross_side_scripting_deep($params['solution'])), 'status' => Ticket::SOLVED);
if (isset($params['type'])) {
$input['solutiontypes_id'] = $params['type'];
}
if (!$ticket->canSolve($params['ticket'], 'w')) {
return self::Error($protocol, WEBSERVICES_ERROR_NOTALLOWED);
}
if ($ticket->update($input)) {
unset($params['solution'], $params['type']);
return self::methodGetTicket($params, $protocol);
}
return self::Error($protocol, WEBSERVICES_ERROR_FAILED, '', self::getDisplayError());
}
示例2: header
-------------------------------------------------------------------------
LICENSE
This file is part of GLPI.
GLPI is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
GLPI 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 General Public License for more details.
You should have received a copy of the GNU General Public License
along with GLPI. If not, see <http://www.gnu.org/licenses/>.
--------------------------------------------------------------------------
*/
/** @file
* @brief
*/
$AJAX_INCLUDE = 1;
include '../inc/includes.php';
header("Content-Type: text/html; charset=UTF-8");
Html::header_nocache();
Session::checkLoginUser();
if (isset($_POST['name'])) {
echo "<input type='text' " . (isset($_POST["size"]) ? " size='" . $_POST["size"] . "' " : "") . " " . (isset($_POST["maxlength"]) ? "maxlength='" . $_POST["maxlength"] . "' " : "") . " name='" . $_POST['name'] . "' value=\"" . Html::cleanInputText(Toolbox::clean_cross_side_scripting_deep(rawurldecode(stripslashes($_POST["data"])))) . "\">";
}
示例3: get_entries_clean
/**
* Get ldap query results and clean them at the same time
*
* @param link the directory connection
* @param result the query results
*
* @return an array which contains ldap query results
**/
static function get_entries_clean($link, $result)
{
return Toolbox::clean_cross_side_scripting_deep(ldap_get_entries($link, $result));
}
示例4: selectGroupOnAdd
static function selectGroupOnAdd($item)
{
global $CFG_GLPI, $DB;
if (isset($item->input['_auto_import']) || isset($item->input['bypassgrouponadd'])) {
return;
}
$peGroup_group = new self();
if ($_SESSION['glpiactiveprofile']['interface'] == 'central') {
$peConfig = new PluginEscalationConfig();
if ($peConfig->getValue('workflow', $item->fields['entities_id']) == '1') {
if (isset($_POST['_groups_id_assign']) && $_POST['_groups_id_assign'] > 0) {
if (isset($_SESSION['plugin_escalation_files'])) {
$_FILES = $_SESSION['plugin_escalation_files'];
}
return;
} else {
$group = new Group();
Html::header(__('Administration'), '', "maintain", "ticket");
if (isset($_POST['dropdown__groups_id_requester']) && $_POST['dropdown__groups_id_requester'] > 0) {
$_SESSION['plugin_escalation_groups_id_requester'] = $_POST['dropdown__groups_id_requester'];
}
if (isset($_FILES)) {
foreach ($_FILES['filename']['tmp_name'] as $numfile => $datafile) {
if ($datafile != '') {
$split = explode("/", $datafile);
Document::renameForce($datafile, GLPI_DOC_DIR . "/_tmp/" . end($split));
$_FILES['filename']['tmp_name'][$numfile] = GLPI_DOC_DIR . "/_tmp/" . end($split);
}
}
$_SESSION['plugin_escalation_files'] = $_FILES;
}
echo '<form action="' . $CFG_GLPI['root_doc'] . '/front/ticket.form.php"
enctype="multipart/form-data" name="form_ticket" method="post">';
echo "<table class='tab_cadre_fixe'>";
echo "<tr class='tab_bg_1'>";
echo "<th colspan='2'>Sélection du groupe de techniciens</th>";
echo "</tr>";
echo "<tr class='tab_bg_1'>";
echo "<td>";
echo __('Group in charge of the ticket') . " :";
echo "</td>";
echo "<td>";
$a_groups = array();
foreach ($_SESSION['glpigroups'] as $groups_id) {
$group->getFromDB($groups_id);
$a_groups[$groups_id] = $group->getName();
$queryg = "SELECT * FROM `" . $peGroup_group->getTable() . "`\n WHERE `groups_id_source` = '" . $groups_id . "' ";
$resultg = $DB->query($queryg);
while ($datag = $DB->fetch_array($resultg)) {
$group->getFromDB($datag['groups_id_destination']);
$a_groups[$groups_id . "_" . $datag['groups_id_destination']] = " > " . $group->getName();
}
}
$rand = Dropdown::showFromArray("_groups_id_assign_escalation", $a_groups);
$params = array('groups_id' => '__VALUE__', 'entity' => $_POST['entities_id'], 'rand' => $rand);
Ajax::updateItemOnSelectEvent("dropdown__groups_id_assign" . $rand, "show_assignuser{$rand}", $CFG_GLPI["root_doc"] . "/plugins/escalation/ajax/dropdownUserassign.php", $params);
echo "</tr>";
echo "<tr class='tab_bg_1'>";
echo "<td colspan='2'>";
foreach ($_POST as $key => $value) {
if (is_array($value)) {
foreach ($value as $keyy => $valuee) {
echo '<input type="hidden" name="' . $key . '[' . $keyy . ']" value="' . $valuee . '" />';
}
} else {
if ($key == 'content') {
$value = Html::cleanPostForTextArea(Toolbox::clean_cross_side_scripting_deep($value));
echo '<textarea name="' . $key . '" style="display:none;">' . $value . '</textarea>';
} else {
if ($key == 'dropdown__groups_id_requester') {
echo '<input type="hidden" name="_groups_id_requester" value="' . $value . '" />';
} else {
$value = Html::cleanInputText(Toolbox::clean_cross_side_scripting_deep(stripslashes($value)));
echo '<input type="hidden" name="' . $key . '" value="' . $value . '" />';
}
}
}
}
if (!isset($_POST['_users_id_assign']) or $_POST['_users_id_assign'] == '0') {
echo "<span id='show_assignuser{$rand}'></span>";
}
echo "</td>";
echo "</tr>";
echo "<tr class='tab_bg_1'>";
echo "<td colspan='2' align='center'>";
echo "<input type='submit' name='add' value=\"" . __('Add') . "\" class='submit'>";
echo "</td>";
echo "</tr>";
echo "</table>";
Html::closeForm();
Html::footer();
exit;
}
}
}
}
示例5: importNetwork
/**
* @param $cfg_ocs
* @param $ocsComputer
* @param $computers_id
* @param $entities_id
*/
static function importNetwork($cfg_ocs, $ocsComputer, $computers_id, $entities_id)
{
global $DB;
// Group by DESCRIPTION, MACADDR, TYPE, TYPEMIB, SPEED, VIRTUALDEV
// to get an array in IPADDRESS
$ocsNetworks = array();
foreach ($ocsComputer as $ocsNetwork) {
$key = $ocsNetwork['DESCRIPTION'] . $ocsNetwork['MACADDR'] . $ocsNetwork['TYPE'] . $ocsNetwork['TYPEMIB'] . $ocsNetwork['SPEED'] . $ocsNetwork['VIRTUALDEV'];
if (!isset($ocsNetworks[$key])) {
$ocsNetworks[$key] = $ocsNetwork;
$ocsNetworks[$key]['IPADDRESS'] = array($ocsNetwork['IPADDRESS']);
} else {
$ocsNetworks[$key]['IPADDRESS'][] = $ocsNetwork['IPADDRESS'];
}
}
$network_ports = array();
$network_ifaces = array();
foreach ($ocsNetworks as $line) {
$line = Toolbox::clean_cross_side_scripting_deep(Toolbox::addslashes_deep($line));
$mac = $line['MACADDR'];
if (!isset($network_ports[$mac])) {
$network_ports[$mac] = array('virtual' => array());
}
$name = PluginOcsinventoryngOcsServer::encodeOcsDataInUtf8($cfg_ocs["ocs_db_utf8"], $line['DESCRIPTION']);
if (!empty($line['IPADDRESS'])) {
$ip = $line['IPADDRESS'];
} else {
$ip = false;
}
$networkport_type = new PluginOcsinventoryngNetworkPortType();
$networkport_type->getFromTypeAndTypeMIB($line);
$speed = NetworkPortEthernet::transformPortSpeed($line['SPEED'], false);
if (!empty($speed)) {
$networkport_type->fields['speed'] = $speed;
}
$values = array('name' => $name, 'type' => array_push($network_ifaces, $networkport_type) - 1, 'ip' => $ip, 'result' => $line);
// Virtual dev can be :
// 1°) specifically defined from OCS
// 2°) if there is already one main device
// 3°) if the networkport is issued by VMWare
if (isset($line['VIRTUALDEV']) && $line['VIRTUALDEV'] == '1' || isset($network_ports[$mac]['main']) || preg_match('/^vm(k|nic)([0-9]+)$/', $name)) {
$network_ports[$mac]['virtual'][] = $values;
} else {
$network_ports[$mac]['main'] = $values;
}
}
$already_known_ports = array();
$already_known_ifaces = array();
foreach ($network_ports as $mac => $ports) {
if (isset($ports['main'])) {
$main = $ports['main'];
$type = $network_ifaces[$main['type']];
// First search for the Network Card
$item_device = new Item_DeviceNetworkCard();
$item_device->getFromDBByQuery("INNER JOIN `glpi_devicenetworkcards`\n ON (`glpi_devicenetworkcards`.`designation`='" . $main['name'] . "')\n WHERE `glpi_items_devicenetworkcards`.`itemtype`='Computer'\n AND `glpi_items_devicenetworkcards`.`items_id`='{$computers_id}'\n AND `glpi_items_devicenetworkcards`.`mac`='{$mac}'\n AND `glpi_items_devicenetworkcards`.`devicenetworkcards_id`=\n `glpi_devicenetworkcards`.`id`");
// If not found, then, create it
if ($item_device->isNewItem()) {
$deviceNetworkCard = new DeviceNetworkCard();
$device_input = array('designation' => $main['name'], 'bandwidth' => $type->fields['speed'], 'entities_id' => $entities_id);
$net_id = $deviceNetworkCard->import($device_input);
if ($net_id) {
$item_device->add(array('items_id' => $computers_id, 'itemtype' => 'Computer', 'entities_id' => $entities_id, 'devicenetworkcards_id' => $net_id, 'mac' => $mac, '_no_history' => !$cfg_ocs['history_network'], 'is_dynamic' => 1, 'is_deleted' => 0));
}
}
if (!$item_device->isNewItem()) {
$already_known_ifaces[] = $item_device->getID();
}
if ($type->fields['instantiation_type'] == __CLASS__) {
$result = $main['result'];
$inst_input = array('TYPE' => $result['TYPE'], 'TYPEMIB' => $result['TYPEMIB'], 'speed' => $result['SPEED']);
} else {
$inst_input = $type->fields;
foreach (array('id', 'name', 'OCS_TYPE', 'OCS_TYPEMIB', 'instantiation_type', 'comment') as $field) {
unset($inst_input[$field]);
}
}
$inst_input['items_devicenetworkcards_id'] = $item_device->getID();
$networkports_id = self::updateNetworkPort($mac, $main['name'], $computers_id, $type->fields['instantiation_type'], $inst_input, $main['ip'], false, $cfg_ocs['history_network'], $already_known_ports);
if ($networkports_id < 0) {
continue;
}
$already_known_ports[] = $networkports_id;
} else {
$networkports_id = 0;
}
foreach ($ports['virtual'] as $port) {
$inst_input = array('networkports_id_alias' => $networkports_id);
$id = self::updateNetworkPort($mac, $port['name'], $computers_id, 'NetworkPortAlias', $inst_input, $port['ip'], true, $cfg_ocs['history_network'], $already_known_ports);
if ($id > 0) {
$already_known_ports[] = $id;
}
}
}
$query = "SELECT `id`\n FROM `glpi_networkports`\n WHERE `itemtype` = 'Computer'\n AND `items_id` = '{$computers_id}'\n AND `is_dynamic` = '1'";
//.........这里部分代码省略.........
示例6: count
$nb = count($data);
$data = Toolbox::clean_cross_side_scripting_deep(Toolbox::addslashes_deep($data));
$hardware[$data["ID"]] = $data["DEVICEID"];
echo "{$i}/{$nb}\r";
}
}
echo " {$nb} computers in OCS\n";
}
echo "+ Search links with no computer in OCS\n";
$query = "SELECT `id`, `ocsid`, `ocs_deviceid`\n FROM `glpi_plugin_ocsinventoryng_ocslinks`\n WHERE `plugin_ocsinventoryng_ocsservers_id` = '{$ocsservers_id}'";
$result = $DB->query($query);
$nb = $DB->numrows($result);
if ($nb > 0) {
for ($i = 1; $data = $DB->fetch_array($result); $i++) {
$nbchk++;
$data = Toolbox::clean_cross_side_scripting_deep(Toolbox::addslashes_deep($data));
if (isset($hardware[$data["ocsid"]])) {
echo "{$i}/{$nb}\r";
} else {
printf("%12d : %s\n", $data['id'], $data['ocs_deviceid']);
if (isset($_GET['clean'])) {
$query_del = "DELETE\n FROM `glpi_plugin_ocsinventoryng_ocslinks`\n WHERE `id` = '" . $data["id"] . "'";
if ($DB->query($query_del)) {
$nbdel++;
}
} else {
$nbtodo++;
}
}
}
echo " {$nb} links checked\n";
示例7: getDatasForObject
//.........这里部分代码省略.........
foreach ($item->getGroups(CommonITILActor::OBSERVER) as $tmp) {
$gid = $tmp['groups_id'];
$groups[$gid] = Dropdown::getDropdownName('glpi_groups', $gid);
}
$datas["##{$objettype}.observergroups##"] = implode(', ', $groups);
}
$datas["##{$objettype}.observerusers##"] = '';
if ($item->countUsers(CommonITILActor::OBSERVER)) {
$users = array();
foreach ($item->getUsers(CommonITILActor::OBSERVER) as $tmp) {
$uid = $tmp['users_id'];
$user_tmp = new User();
if ($uid && $user_tmp->getFromDB($uid)) {
$users[] = $user_tmp->getName();
} else {
$users[] = $tmp['alternative_email'];
}
}
$datas["##{$objettype}.observerusers##"] = implode(', ', $users);
}
$datas["##{$objettype}.assigntogroups##"] = '';
if ($item->countGroups(CommonITILActor::ASSIGN)) {
$groups = array();
foreach ($item->getGroups(CommonITILActor::ASSIGN) as $tmp) {
$gid = $tmp['groups_id'];
$groups[$gid] = Dropdown::getDropdownName('glpi_groups', $gid);
}
$datas["##{$objettype}.assigntogroups##"] = implode(', ', $groups);
}
$datas["##{$objettype}.solution.type##"] = '';
if ($item->getField('solutiontypes_id')) {
$datas["##{$objettype}.solution.type##"] = Dropdown::getDropdownName('glpi_solutiontypes', $item->getField('solutiontypes_id'));
}
$datas["##{$objettype}.solution.description##"] = Toolbox::unclean_cross_side_scripting_deep($item->getField('solution'));
// Complex mode
if (!$simple) {
$datas['log'] = array();
// Use list_limit_max or load the full history ?
foreach (Log::getHistoryData($item, 0, $CFG_GLPI['list_limit_max']) as $data) {
$tmp = array();
$tmp["##{$objettype}.log.date##"] = $data['date_mod'];
$tmp["##{$objettype}.log.user##"] = $data['user_name'];
$tmp["##{$objettype}.log.field##"] = $data['field'];
$tmp["##{$objettype}.log.content##"] = $data['change'];
$datas['log'][] = $tmp;
}
$datas["##{$objettype}.numberoflogs##"] = count($datas['log']);
// Get unresolved items
$restrict = "`" . $item->getTable() . "`.`status`\n NOT IN ('" . implode("', '", array_merge($item->getSolvedStatusArray(), $item->getClosedStatusArray())) . "'\n )";
if ($item->maybeDeleted()) {
$restrict .= " AND `" . $item->getTable() . "`.`is_deleted` = '0' ";
}
$datas["##{$objettype}.numberofunresolved##"] = countElementsInTableForEntity($item->getTable(), $this->getEntity(), $restrict);
// Document
$query = "SELECT `glpi_documents`.*\n FROM `glpi_documents`\n LEFT JOIN `glpi_documents_items`\n ON (`glpi_documents`.`id` = `glpi_documents_items`.`documents_id`)\n WHERE `glpi_documents_items`.`itemtype` = '" . $item->getType() . "'\n AND `glpi_documents_items`.`items_id` = '" . $item->getField('id') . "'";
$datas["documents"] = array();
$addtodownloadurl = '';
if ($item->getType() == 'Ticket') {
$addtodownloadurl = "%2526tickets_id=" . $item->fields['id'];
}
if ($result = $DB->query($query)) {
while ($data = $DB->fetch_assoc($result)) {
$tmp = array();
$tmp['##document.id##'] = $data['id'];
$tmp['##document.name##'] = $data['name'];
$tmp['##document.weblink##'] = $data['link'];
示例8: showForItem
/**
* Show OcsLink of an item
*
* @param $item CommonDBTM object
* @param $withtemplate integer withtemplate param (default '')
*
* @return nothing
**/
static function showForItem(CommonDBTM $item, $withtemplate = '')
{
global $DB, $CFG_GLPI;
$target = Toolbox::getItemTypeFormURL(__CLASS__);
if (in_array($item->getType(), array('Computer'))) {
$items_id = $item->getField('id');
if (!empty($items_id) && $item->fields["is_dynamic"] && Session::haveRight("plugin_ocsinventoryng_view", READ)) {
$query = "SELECT *\n FROM `glpi_plugin_ocsinventoryng_ocslinks`\n WHERE `computers_id` = '{$items_id}' " . getEntitiesRestrictRequest("AND", "glpi_plugin_ocsinventoryng_ocslinks");
$result = $DB->query($query);
if ($DB->numrows($result) > 0) {
$data = $DB->fetch_assoc($result);
$data = Toolbox::clean_cross_side_scripting_deep(Toolbox::addslashes_deep($data));
if (count($data)) {
$ocs_config = PluginOcsinventoryngOcsServer::getConfig(PluginOcsinventoryngOcsServer::getByMachineID($items_id));
echo "<div class='center'>";
echo "<form method='post' action=\"{$target}\">";
echo "<input type='hidden' name='id' value='{$items_id}'>";
echo "<table class='tab_cadre_fixe'>";
echo "<tr><th colspan = '4'>OCS Inventory NG</th>";
echo "<tr class='tab_bg_1'>";
$colspan = 4;
if (Session::haveRight("plugin_ocsinventoryng_view", READ) && Session::haveRight("plugin_ocsinventoryng_sync", UPDATE)) {
$colspan = 2;
echo "<td class='center'>" . __('Automatic update OCSNG', 'ocsinventoryng') . "</td>";
echo "<td class='left'>";
Dropdown::showYesNo("use_auto_update", $data["use_auto_update"]);
echo "</td>";
}
echo "<td class='center' colspan='" . $colspan . "'>";
printf(__('%1$s: %2$s'), __('OCSNG TAG', 'ocsinventoryng'), $data['tag']);
echo "</td></tr>";
if (Session::haveRight("plugin_ocsinventoryng_sync", UPDATE)) {
echo "<tr class='tab_bg_1'>";
$colspan = 4;
echo "<td class='center' colspan='2'>";
echo "<input type='hidden' name='resynch_id' value='" . $data["id"] . "'>";
echo "<input class=submit type='submit' name='force_ocs_resynch' value=\"" . _sx('button', 'Force synchronization', 'ocsinventoryng') . "\">";
echo "</td>";
//echo "<tr class='tab_bg_1'>";
echo "<td class='center' colspan='2'>";
echo "<input type='hidden' name='link_id' value='" . $data["id"] . "'>";
echo "<input class=submit type='submit' name='update' value=\"" . _sx('button', 'Save') . "\">";
echo "</td></tr>";
}
echo "</table>\n";
Html::closeForm();
echo "</div>";
}
}
}
}
}
示例9: updateModel
function updateModel($xml, $message, $result)
{
global $DB;
$pfMapping = new PluginFusioninventoryMapping();
if ($message == '1') {
$_SESSION["MESSAGE_AFTER_REDIRECT"] = __('Model already exists', 'fusioninventory');
}
// Update model oids
// Get list of oids in DB
$a_oidsDB = array();
$models_data = $DB->fetch_assoc($result);
$pfModelMib = new PluginFusioninventorySnmpmodelMib();
$pfModel = new PluginFusioninventorySnmpmodel();
$pfModel->getFromDB($models_data['id']);
$input = array();
$input['id'] = $pfModel->fields['id'];
$input['comment'] = Toolbox::clean_cross_side_scripting_deep(Toolbox::addslashes_deep((string) $xml->comments));
$pfModel->update($input);
$a_devices = array();
if (isset($xml->devices)) {
foreach ($xml->devices->sysdescr as $child) {
$a_devices[] = (string) $child;
}
}
$pfSnmpmodeldevice = new PluginFusioninventorySnmpmodeldevice();
$pfSnmpmodeldevice->updateDevicesForModel($pfModel->fields['id'], $a_devices);
$a_oids = $pfModelMib->find("`plugin_fusioninventory_snmpmodels_id`='" . $models_data['id'] . "'");
foreach ($a_oids as $data) {
$oid = Dropdown::getDropdownName("glpi_plugin_fusioninventory_snmpmodelmiboids", $data['plugin_fusioninventory_snmpmodelmiboids_id']);
$oid_name = '';
if ($data['plugin_fusioninventory_mappings_id'] != 0) {
$pfMapping->getFromDB($data['plugin_fusioninventory_mappings_id']);
$oid_name = $pfMapping->fields["name"];
}
$a_oidsDB[$oid . "-" . $oid_name] = $data['id'];
}
$mapping_type = '';
foreach ($xml->oidlist->oidobject as $child) {
$input = array();
if (isset($a_oidsDB[$child->oid . "-" . $child->mapping_name])) {
// Update oid
$pfModelMib->getFromDB($a_oidsDB[$child->oid . "-" . $child->mapping_name]);
$input = $pfModelMib->fields;
}
$input["plugin_fusioninventory_snmpmodels_id"] = $models_data['id'];
$input['plugin_fusioninventory_snmpmodelmibobjects_id'] = 0;
if (isset($child->object)) {
$input['plugin_fusioninventory_snmpmodelmibobjects_id'] = Dropdown::importExternal("PluginFusioninventorySnmpmodelMibObject", $child->object);
}
$input['plugin_fusioninventory_snmpmodelmiboids_id'] = Dropdown::importExternal("PluginFusioninventorySnmpmodelMibOid", $child->oid);
$input['oid_port_counter'] = 0;
if (isset($child->portcounter)) {
$input['oid_port_counter'] = $child->portcounter;
}
$input['oid_port_dyn'] = 0;
if (isset($child->dynamicport)) {
$input['oid_port_dyn'] = $child->dynamicport;
}
$input["vlan"] = 0;
if (isset($child->vlan)) {
$input["vlan"] = $child->vlan;
}
$input["is_active"] = 0;
if (isset($child->activation)) {
$input["is_active"] = $child->activation;
}
if (isset($mapping_type)) {
unset($mapping_type);
}
if (isset($child->mapping_type)) {
$mapping_type = '';
if (is_numeric($child->mapping_type)) {
switch ($child->mapping_type) {
case '1':
$mapping_type = "Computer";
break;
case '2':
$mapping_type = "NetworkEquipment";
break;
case '3':
$mapping_type = "Printer";
break;
}
} else {
$mapping_type = $child->mapping_type;
}
}
$input["plugin_fusioninventory_mappings_id"] = 0;
if (isset($child->mapping_name)) {
if ($child->mapping_name != '') {
$a_mappings = $pfMapping->get($mapping_type, $child->mapping_name);
$input["plugin_fusioninventory_mappings_id"] = $a_mappings['id'];
}
}
$input["plugin_fusioninventory_mappings_id"] = 0;
if (isset($child->mapping_name)) {
if ($child->mapping_name != '') {
$a_mappings = $pfMapping->get($mapping_type, $child->mapping_name);
$input["plugin_fusioninventory_mappings_id"] = $a_mappings['id'];
}
//.........这里部分代码省略.........
示例10: cleanValue
function cleanValue($value)
{
$value = Html::clean($value);
$value = Toolbox::clean_cross_side_scripting_deep($value);
$value = Toolbox::addslashes_deep($value);
return $value;
}
示例11: importPeripheral
/**
*
* Import peripherals from OCS
* @since 1.0
* @param $cfg_ocs OCSNG mode configuration
* @param $computers_id computer's id in GLPI
* @param $ocsid computer's id in OCS
* @param $ocsservers_id OCS server id
* @param $entity the entity in which the peripheral will be created
* @param $dohistory record in history link between peripheral and computer
*/
static function importPeripheral($cfg_ocs, $computers_id, $ocsservers_id, $ocsComputer, $entity, $dohistory)
{
global $DB;
$already_processed = array();
$p = new Peripheral();
$conn = new Computer_Item();
if (isset($ocsComputer["INPUTS"])) {
if (count($ocsComputer["INPUTS"]) > 0) {
foreach ($ocsComputer["INPUTS"] as $peripheral) {
if ($peripheral["CAPTION"] !== '') {
$peripherals[] = $peripheral;
}
}
if (count($peripherals) > 0) {
foreach ($peripherals as $peripheral) {
$peripheral = Toolbox::clean_cross_side_scripting_deep(Toolbox::addslashes_deep($peripheral));
$periph = array();
$periph["name"] = self::encodeOcsDataInUtf8($cfg_ocs["ocs_db_utf8"], $peripheral["CAPTION"]);
//Look for a monitor with the same name (and serial if possible) already connected
//to this computer
$query = "SELECT `p`.`id`, `gci`.`is_deleted`\n FROM `glpi_printers` as `p`, `glpi_computers_items` as `gci`\n WHERE `p`.`id` = `gci`.`items_id`\n AND `gci`.`is_dynamic`='1'\n AND `computers_id`='{$computers_id}'\n AND `itemtype`='Peripheral'\n AND `p`.`name`='" . $periph["name"] . "'";
$results = $DB->query($query);
$id = false;
$lock = false;
if ($DB->numrows($results) > 0) {
$id = $DB->result($results, 0, 'id');
$lock = $DB->result($results, 0, 'is_deleted');
}
if (!$id) {
// Clean peripheral object
$p->reset();
if ($peripheral["MANUFACTURER"] != "NULL") {
$periph["brand"] = self::encodeOcsDataInUtf8($cfg_ocs["ocs_db_utf8"], $peripheral["MANUFACTURER"]);
}
if ($peripheral["INTERFACE"] != "NULL") {
$periph["comment"] = self::encodeOcsDataInUtf8($cfg_ocs["ocs_db_utf8"], $peripheral["INTERFACE"]);
}
$periph["peripheraltypes_id"] = Dropdown::importExternal('PeripheralType', $peripheral["TYPE"]);
$id_periph = 0;
if ($cfg_ocs["import_periph"] == 1) {
//Config says : manage peripherals as global
//check if peripherals already exists in GLPI
$periph["is_global"] = 1;
$query = "SELECT `id`\n FROM `glpi_peripherals`\n WHERE `name` = '" . $periph["name"] . "'\n AND `is_global` = '1'\n AND `entities_id` = '{$entity}'";
$result_search = $DB->query($query);
if ($DB->numrows($result_search) > 0) {
//Periph is already in GLPI
//Do not import anything just get periph ID for link
$id_periph = $DB->result($result_search, 0, "id");
} else {
$input = $periph;
if ($cfg_ocs["states_id_default"] > 0) {
$input["states_id"] = $cfg_ocs["states_id_default"];
}
$input["entities_id"] = $entity;
$id_periph = $p->add($input);
}
} else {
if ($cfg_ocs["import_periph"] == 2) {
//Config says : manage peripherals as single units
//Import all peripherals as non global.
$input = $periph;
$input["is_global"] = 0;
if ($cfg_ocs["states_id_default"] > 0) {
$input["states_id"] = $cfg_ocs["states_id_default"];
}
$input["entities_id"] = $entity;
$id_periph = $p->add($input);
}
}
if ($id_periph) {
$already_processed[] = $id_periph;
$conn = new Computer_Item();
if ($connID = $conn->add(array('computers_id' => $computers_id, 'itemtype' => 'Peripheral', 'items_id' => $id_periph, '_no_history' => !$dohistory, 'is_dynamic' => 1))) {
//Update column "is_deleted" set value to 0 and set status to default
$input = array();
$input["id"] = $id_periph;
$input["is_deleted"] = 0;
$input["entities_id"] = $entity;
if ($cfg_ocs["states_id_default"] > 0) {
$input["states_id"] = $cfg_ocs["states_id_default"];
}
$p->update($input);
}
}
} else {
$already_processed[] = $id;
}
}
//.........这里部分代码省略.........
示例12: protectData
static function protectData($data)
{
if (Toolbox::get_magic_quotes_gpc()) {
$data = Toolbox::stripslashes_deep($data);
}
$data = Toolbox::addslashes_deep($data);
$data = Toolbox::clean_cross_side_scripting_deep($data);
return $data;
}
示例13: displayField
function displayField($name, $fieldname, $valuedisplay, $value = '', $checked = '')
{
if ($value == '') {
$value = $valuedisplay;
}
$type = 'checkbox';
$inputname = 'checked[]';
if (strstr($fieldname, 'requester') || strstr($fieldname, 'assign')) {
$type = 'radio';
$inputname = $fieldname;
$fieldname = $value;
}
echo "<tr class='tab_bg_3'>";
echo "<td>";
echo "<input type='" . $type . "' name='" . $inputname . "' value='" . $fieldname . "' " . $checked . " />";
echo "</td>";
echo "<td>";
echo $name;
echo "</td>";
echo "<td>";
echo $valuedisplay;
if ($type == 'checkbox') {
$value = Html::cleanInputText(Toolbox::clean_cross_side_scripting_deep(stripslashes($value)));
echo '<input type="hidden" name="' . $fieldname . '" value="' . $value . '" />';
}
echo "</td>";
echo "</tr>";
}
示例14: setRichTextContent
/**
* Convert simple text content to rich text content, init html editor
*
* @since version 0.85
*
* @param $name name of textarea
* @param $content content to convert in html
* @param $rand
*
* @return $content
**/
function setRichTextContent($name, $content, $rand)
{
// Init html editor
Html::initEditorSystem($name, $rand);
// If no html
if ($content == strip_tags($content)) {
$content = $this->convertTagToImage($content);
}
// If content does not contain <br> or <p> html tag, use nl2br
$content = Html::entity_decode_deep($content);
if (!preg_match("/<br\\s?\\/?>/", $content) && !preg_match("/<p>/", $content)) {
$content = nl2br($content);
}
return Toolbox::clean_cross_side_scripting_deep($content);
}
示例15: header
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
GLPI 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 General Public License for more details.
You should have received a copy of the GNU General Public License
along with GLPI. If not, see <http://www.gnu.org/licenses/>.
--------------------------------------------------------------------------
*/
/** @file
* @brief
*/
include '../../../inc/includes.php';
header("Content-Type: text/html; charset=UTF-8");
Html::header_nocache();
Session::checkLoginUser();
if (isset($_POST['name'])) {
$step = 1;
if (!isset($_REQUEST['force_integer'])) {
$step = PLUGIN_ORDER_NUMBER_STEP;
}
$class = "";
if (isset($_REQUEST['class'])) {
$class = "class='" . $_REQUEST['class'] . "'";
}
$data = Html::cleanInputText(Toolbox::clean_cross_side_scripting_deep(rawurldecode(stripslashes($_POST["data"]))));
echo "<input type='number' step='{$step}' name='" . $_POST['name'] . "' value='{$data}' {$class}>";
}