本文整理汇总了PHP中Toolbox::sanitize方法的典型用法代码示例。如果您正苦于以下问题:PHP Toolbox::sanitize方法的具体用法?PHP Toolbox::sanitize怎么用?PHP Toolbox::sanitize使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Toolbox
的用法示例。
在下文中一共展示了Toolbox::sanitize方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: updateItems
/**
* update an object to GLPI
*
* @param $itemtype string itemtype (class) of object
* @param $params array with theses options :
* - 'input' : Array of objects with fields of itemtype to be updated.
* Mandatory.
* You must provide in each object a key named 'id' to identify item to update.
*
* @return array of boolean
**/
protected function updateItems($itemtype, $params = array())
{
$this->initEndpoint();
$input = isset($params['input']) ? $params["input"] : null;
$item = new $itemtype();
$response = "";
if (is_object($input)) {
$input = array($input);
$isMultiple = false;
}
$isMultiple = true;
if (is_array($input)) {
$idCollection = array();
$failed = 0;
foreach ($input as $object) {
if (isset($object->id)) {
if (!$item->getFromDB($object->id)) {
$failed++;
$idCollection[] = array($object->id => false, 'message' => __("Item not found"));
continue;
}
//check rights
if (!$item->can($object->id, UPDATE)) {
$failed++;
$idCollection[] = array($object->id => false, 'message' => __("You don't have permission to perform this action."));
} else {
//update item
$object = Toolbox::sanitize((array) $object);
$update_return = $item->update($object);
if ($update_return === false) {
$failed++;
}
$idCollection[] = array($item->fields["id"] => $update_return, 'message' => $this->getGlpiLastMessage());
}
}
}
if ($isMultiple) {
if ($failed == count($input)) {
$this->returnError($idCollection, 400, "ERROR_GLPI_UPDATE", false);
} else {
if ($failed > 0) {
$this->returnError($idCollection, 207, "ERROR_GLPI_PARTIAL_UPDATE", false);
}
}
} else {
if ($failed > 0) {
$this->returnError($idCollection[0]['message'], 400, "ERROR_GLPI_UPDATE", false);
} else {
return $idCollection;
// Return collection, even if the request affects a single item
}
}
return $idCollection;
} else {
$this->messageBadArrayError();
}
}
示例2: array_map
}
// Security system
if (isset($_POST)) {
if (isset($_POST['_glpi_simple_form'])) {
$_POST = array_map('urldecode', $_POST);
}
$_POST = Toolbox::sanitize($_POST);
}
if (isset($_GET)) {
$_GET = Toolbox::sanitize($_GET);
}
if (isset($_REQUEST)) {
$_REQUEST = Toolbox::sanitize($_REQUEST);
}
if (isset($_FILES)) {
$_FILES = Toolbox::sanitize($_FILES);
}
// Mark if Header is loaded or not :
$HEADER_LOADED = false;
$FOOTER_LOADED = false;
if (isset($AJAX_INCLUDE)) {
$HEADER_LOADED = true;
}
/* On startup, register all plugins configured for use. */
if (!isset($AJAX_INCLUDE) && !isset($PLUGINS_INCLUDED)) {
// PLugin already included
$PLUGINS_INCLUDED = 1;
$LOADED_PLUGINS = array();
$plugin = new Plugin();
if (!isset($_SESSION["glpi_plugins"])) {
$plugin->init();