本文整理汇总了PHP中Toolbox::seems_utf8方法的典型用法代码示例。如果您正苦于以下问题:PHP Toolbox::seems_utf8方法的具体用法?PHP Toolbox::seems_utf8怎么用?PHP Toolbox::seems_utf8使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Toolbox
的用法示例。
在下文中一共展示了Toolbox::seems_utf8方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: parseLine
/**
* CSV File parsing methods
*
* @param $fic
* @param $data
* @param $encoding (default 1)
**/
static function parseLine($fic, $data, $encoding = 1)
{
global $DB;
$csv = array();
$num = count($data);
for ($c = 0; $c < $num; $c++) {
//If field is not the last, or if field is the last of the line and is not empty
if ($c < $num - 1 || $c == $num - 1 && $data[$num - 1] != PluginDatainjectionCommonInjectionLib::EMPTY_VALUE) {
$tmp = trim($DB->escape($data[$c]));
switch ($encoding) {
//If file is ISO8859-1 : encode the datas in utf8
case PluginDatainjectionBackend::ENCODING_ISO8859_1:
if (!Toolbox::seems_utf8($tmp)) {
$csv[0][] = utf8_encode($tmp);
} else {
$csv[0][] = $tmp;
}
break;
case PluginDatainjectionBackend::ENCODING_UFT8:
$csv[0][] = $tmp;
break;
default:
//PluginDatainjectionBackend :: ENCODING_AUTO :
$csv[0][] = PluginDatainjectionBackend::toUTF8($tmp);
}
}
}
return $csv;
}
示例2: buildTicket
/** function buildTicket - Builds,and returns, the major structure of the ticket to be entered.
*
* @param $i mail ID
* @param $options array of possible options
*
* @return ticket fields array
*/
function buildTicket($i, $options = array())
{
global $CFG_GLPI;
$play_rules = isset($options['play_rules']) && $options['play_rules'];
$head = $this->getHeaders($i);
// Get Header Info Return Array Of Headers
// **Key Are (subject,to,toOth,toNameOth,from,fromName)
$tkt = array();
$tkt['_blacklisted'] = false;
// For RuleTickets
$tkt['_mailgate'] = $options['mailgates_id'];
// Use mail date if it's defined
if ($this->fields['use_mail_date']) {
$tkt['date'] = $head['date'];
}
// Detect if it is a mail reply
$glpi_message_match = "/GLPI-([0-9]+)\\.[0-9]+\\.[0-9]+@\\w*/";
// Check if email not send by GLPI : if yes -> blacklist
if (!isset($head['message_id']) || preg_match($glpi_message_match, $head['message_id'], $match)) {
$tkt['_blacklisted'] = true;
return $tkt;
}
// manage blacklist
$blacklisted_emails = Blacklist::getEmails();
// Add name of the mailcollector as blacklisted
$blacklisted_emails[] = $this->fields['name'];
if (Toolbox::inArrayCaseCompare($head['from'], $blacklisted_emails)) {
$tkt['_blacklisted'] = true;
return $tkt;
}
// max size = 0 : no import attachments
if ($this->fields['filesize_max'] > 0) {
if (is_writable(GLPI_TMP_DIR)) {
$tkt['_filename'] = $this->getAttached($i, GLPI_TMP_DIR . "/", $this->fields['filesize_max']);
$tkt['_tag'] = $this->tags;
} else {
//TRANS: %s is a directory
Toolbox::logInFile('mailgate', sprintf(__('%s is not writable'), GLPI_TMP_DIR . "/"));
}
}
// Who is the user ?
$tkt['_users_id_requester'] = User::getOrImportByEmail($head['from']);
$tkt["_users_id_requester_notif"]['use_notification'] = 1;
// Set alternative email if user not found / used if anonymous mail creation is enable
if (!$tkt['_users_id_requester']) {
$tkt["_users_id_requester_notif"]['alternative_email'] = $head['from'];
}
// Add to and cc as additional observer if user found
if (count($head['ccs'])) {
foreach ($head['ccs'] as $cc) {
if ($cc != $head['from'] && !Toolbox::inArrayCaseCompare($cc, $blacklisted_emails) && ($tmp = User::getOrImportByEmail($cc)) > 0) {
$tkt['_additional_observers'][] = array('users_id' => $tmp, 'use_notification' => 1);
}
}
}
if (count($head['tos'])) {
foreach ($head['tos'] as $to) {
if ($to != $head['from'] && !Toolbox::inArrayCaseCompare($to, $blacklisted_emails) && ($tmp = User::getOrImportByEmail($to)) > 0) {
$tkt['_additional_observers'][] = array('users_id' => $tmp, 'use_notification' => 1);
}
}
}
// Auto_import
$tkt['_auto_import'] = 1;
// For followup : do not check users_id = login user
$tkt['_do_not_check_users_id'] = 1;
$body = $this->getBody($i);
// Do it before using charset variable
$head['subject'] = $this->decodeMimeString($head['subject']);
$tkt['_head'] = $head;
if (!empty($this->charset) && !$this->body_converted) {
$body = Toolbox::encodeInUtf8($body, $this->charset);
$this->body_converted = true;
}
if (!Toolbox::seems_utf8($body)) {
$tkt['content'] = Toolbox::encodeInUtf8($body);
} else {
$tkt['content'] = $body;
}
// See In-Reply-To field
if (isset($head['in_reply_to'])) {
if (preg_match($glpi_message_match, $head['in_reply_to'], $match)) {
$tkt['tickets_id'] = intval($match[1]);
}
}
// See in References
if (!isset($tkt['tickets_id']) && isset($head['references'])) {
if (preg_match($glpi_message_match, $head['references'], $match)) {
$tkt['tickets_id'] = intval($match[1]);
}
}
// See in title
if (!isset($tkt['tickets_id']) && preg_match('/\\[.+#(\\d+)\\]/', $head['subject'], $match)) {
//.........这里部分代码省略.........
示例3: updateDevices
//.........这里部分代码省略.........
} else {
$tmp = array_search(stripslashes($prevalue . $processor["designation"]), $import_device);
list($type, $id) = explode(self::FIELD_SEPARATOR, $tmp);
$CompDevice->update(array('id' => $id, 'frequency' => $line["PROCESSORS"]));
unset($import_device[$tmp]);
}
}
}
}
break;
case "Item_DeviceNetworkCard":
//Carte reseau
if ($cfg_ocs["import_device_iface"] || $cfg_ocs["import_ip"]) {
PluginOcsinventoryngNetworkPort::importNetwork($PluginOcsinventoryngDBocs, $cfg_ocs, $ocsid, $computers_id, $dohistory);
}
break;
case "Item_DeviceGraphicCard":
$CompDevice = new $devicetype();
//carte graphique
if ($cfg_ocs["import_device_gfxcard"]) {
$do_clean = true;
$query2 = "SELECT DISTINCT(`NAME`) AS NAME,\n `MEMORY`\n FROM `videos`\n WHERE `HARDWARE_ID` = '{$ocsid}'\n AND `NAME` != ''\n ORDER BY `ID`";
$result2 = $PluginOcsinventoryngDBocs->query($query2);
if ($PluginOcsinventoryngDBocs->numrows($result2) > 0) {
while ($line2 = $PluginOcsinventoryngDBocs->fetch_array($result2)) {
$line2 = Toolbox::clean_cross_side_scripting_deep(Toolbox::addslashes_deep($line2));
$video["designation"] = $line2["NAME"];
if (!is_numeric($line2["MEMORY"])) {
$line2["MEMORY"] = 0;
}
if (!in_array(stripslashes($prevalue . $video["designation"]), $import_device)) {
$video["memory_default"] = $line2["MEMORY"];
$DeviceGraphicCard = new DeviceGraphicCard();
$video_id = $DeviceGraphicCard->import($video);
if ($video_id) {
$devID = $CompDevice->add(array('items_id' => $computers_id, 'itemtype' => 'Computer', 'devicegraphiccards_id' => $video_id, 'memory' => $line2["MEMORY"], 'is_dynamic' => 1, '_no_history' => !$dohistory));
}
} else {
$tmp = array_search(stripslashes($prevalue . $video["designation"]), $import_device);
list($type, $id) = explode(self::FIELD_SEPARATOR, $tmp);
$CompDevice->update(array('id' => $id, 'memory' => $line2["MEMORY"]));
unset($import_device[$tmp]);
}
}
}
}
break;
case "Item_DeviceSoundCard":
$CompDevice = new $devicetype();
//carte son
if ($cfg_ocs["import_device_sound"]) {
$do_clean = true;
$query2 = "SELECT DISTINCT(`NAME`) AS NAME,\n `DESCRIPTION`\n FROM `sounds`\n WHERE `HARDWARE_ID` = '{$ocsid}'\n AND `NAME` != ''\n ORDER BY `ID`";
$result2 = $PluginOcsinventoryngDBocs->query($query2);
if ($PluginOcsinventoryngDBocs->numrows($result2) > 0) {
while ($line2 = $PluginOcsinventoryngDBocs->fetch_array($result2)) {
$line2 = Toolbox::clean_cross_side_scripting_deep(Toolbox::addslashes_deep($line2));
if (!$cfg_ocs["ocs_db_utf8"] && !Toolbox::seems_utf8($line2["NAME"])) {
$line2["NAME"] = Toolbox::encodeInUtf8($line2["NAME"]);
}
$snd["designation"] = $line2["NAME"];
if (!in_array(stripslashes($prevalue . $snd["designation"]), $import_device)) {
if (!empty($line2["DESCRIPTION"])) {
$snd["comment"] = $line2["DESCRIPTION"];
}
$DeviceSoundCard = new DeviceSoundCard();
$snd_id = $DeviceSoundCard->import($snd);
if ($snd_id) {
$devID = $CompDevice->add(array('items_id' => $computers_id, 'itemtype' => 'Computer', 'devicesoundcards_id' => $snd_id, 'is_dynamic' => 1, '_no_history' => !$dohistory));
}
} else {
$id = array_search(stripslashes($prevalue . $snd["designation"]), $import_device);
unset($import_device[$id]);
}
}
}
}
break;
}
// Delete Unexisting Items not found in OCS
if ($do_clean && count($import_device)) {
foreach ($import_device as $key => $val) {
if (!(strpos($key, $devicetype . '$$') === false)) {
list($type, $id) = explode(self::FIELD_SEPARATOR, $key);
$CompDevice->delete(array('id' => $id, '_no_history' => !$dohistory, 1), true);
}
}
}
//TODO Import IP
if ($do_clean && count($import_ip) && $devicetype == "Item_DeviceNetworkCard") {
foreach ($import_ip as $key => $val) {
if ($key > 0) {
$netport = new NetworkPort();
$netport->delete(array('id' => $key));
}
}
}
//Alimentation
//Carte mere
}
示例4: get_update_content
function get_update_content($DB, $table, $from, $limit, $conv_utf8)
{
$content = "";
$DB->query("SET NAMES latin1");
$result = $DB->query("SELECT *\n FROM `{$table}`\n LIMIT {$from}, {$limit}");
if ($result) {
while ($row = $DB->fetch_assoc($result)) {
if (isset($row["id"])) {
$insert = "UPDATE `{$table}`\n SET ";
foreach ($row as $key => $val) {
$insert .= " `" . $key . "` = ";
if (!isset($val)) {
$insert .= "NULL,";
} else {
if ($val != "") {
if ($conv_utf8) {
// Gestion users AD qui sont deja en UTF8
if ($table != "glpi_users" || !Toolbox::seems_utf8($val)) {
$val = Toolbox::encodeInUtf8($val);
}
}
$insert .= "'" . addslashes($val) . "',";
} else {
$insert .= "'',";
}
}
}
$insert = preg_replace("/,\$/", "", $insert);
$insert .= " WHERE `id` = '" . $row["id"] . "' ";
$insert .= ";\n";
$content .= $insert;
}
}
}
return $content;
}
示例5: updateDevices
//.........这里部分代码省略.........
if ($line2['NAME']) {
$video["designation"] = $line2["NAME"];
$video["entities_id"] = $entities_id;
if (!is_numeric($line2["MEMORY"])) {
$line2["MEMORY"] = 0;
}
if (!in_array(stripslashes($prevalue . $video["designation"]), $import_device)) {
$video["memory_default"] = $line2["MEMORY"];
$DeviceGraphicCard = new DeviceGraphicCard();
$video_id = $DeviceGraphicCard->import($video);
if ($video_id) {
$devID = $CompDevice->add(array('items_id' => $computers_id, 'itemtype' => 'Computer', 'entities_id' => $entities_id, 'devicegraphiccards_id' => $video_id, 'memory' => $line2["MEMORY"], 'is_dynamic' => 1, '_no_history' => !$dohistory));
}
} else {
$tmp = array_search(stripslashes($prevalue . $video["designation"]), $import_device);
list($type, $id) = explode(self::FIELD_SEPARATOR, $tmp);
$CompDevice->update(array('id' => $id, 'memory' => $line2["MEMORY"]));
unset($import_device[$tmp]);
}
}
}
}
}
break;
case "Item_DeviceSoundCard":
$CompDevice = new $devicetype();
//carte son
$do_clean = true;
if ($ocsComputer) {
if (isset($ocsComputer['SOUNDS'])) {
foreach ($ocsComputer['SOUNDS'] as $line2) {
$line2 = Toolbox::clean_cross_side_scripting_deep(Toolbox::addslashes_deep($line2));
if ($line2['NAME']) {
if (!$cfg_ocs["ocs_db_utf8"] && !Toolbox::seems_utf8($line2["NAME"])) {
$line2["NAME"] = Toolbox::encodeInUtf8($line2["NAME"]);
}
$snd["entities_id"] = $entities_id;
$snd["designation"] = $line2["NAME"];
if (!in_array(stripslashes($prevalue . $snd["designation"]), $import_device)) {
if (!empty($line2["DESCRIPTION"])) {
$snd["comment"] = $line2["DESCRIPTION"];
}
$DeviceSoundCard = new DeviceSoundCard();
$snd_id = $DeviceSoundCard->import($snd);
if ($snd_id) {
$devID = $CompDevice->add(array('items_id' => $computers_id, 'itemtype' => 'Computer', 'entities_id' => $entities_id, 'devicesoundcards_id' => $snd_id, 'is_dynamic' => 1, '_no_history' => !$dohistory));
}
} else {
$id = array_search(stripslashes($prevalue . $snd["designation"]), $import_device);
unset($import_device[$id]);
}
}
}
}
}
break;
case "PluginOcsinventoryngItem_DeviceBiosdata":
$CompDevice = new $devicetype();
//Bios
$do_clean = true;
if ($ocsComputer) {
if (isset($ocsComputer['BIOS'])) {
$bios["designation"] = $ocsComputer['BIOS']["BVERSION"];
$bios["assettag"] = $ocsComputer['BIOS']["ASSETTAG"];
$bios["entities_id"] = $entities_id;
//$date = str_replace("/", "-", $ocsComputer['BIOS']["BDATE"]);
示例6: updateDevices
//.........这里部分代码省略.........
}
if ($line2["NAME"] != "Not Specified") {
$port["designation"] .= " " . $line2["NAME"];
} else {
if ($line2["CAPTION"] != "None") {
$port["designation"] .= " " . $line2["CAPTION"];
}
}
$port["entities_id"] = $entities_id;
if (!empty($port["designation"])) {
if (!in_array(stripslashes($prevalue . $port["designation"]), $import_device)) {
if (!empty($line2["DESCRIPTION"]) && $line2["DESCRIPTION"] != "None") {
$port["comment"] = $line2["DESCRIPTION"];
}
$DevicePci = new DevicePci();
$port_id = $DevicePci->import($port);
if ($port_id) {
$CompDevice->add(array('items_id' => $computers_id, 'itemtype' => 'Computer', 'entities_id' => $entities_id, 'devicepcis_id' => $port_id, 'is_dynamic' => 1), array(), $cfg_ocs['history_devices']);
}
} else {
$tmp = array_search(stripslashes($prevalue . $port["designation"]), $import_device);
unset($import_device[$tmp]);
}
}
}
}
//Slots
if (isset($ocsComputer['SLOTS'])) {
$CompDevice = new $devicetype();
$do_clean = true;
foreach ($ocsComputer['SLOTS'] as $line2) {
$line2 = Toolbox::clean_cross_side_scripting_deep(Toolbox::addslashes_deep($line2));
if ($line2['NAME']) {
if (!$cfg_ocs["ocs_db_utf8"] && !Toolbox::seems_utf8($line2["NAME"])) {
$line2["NAME"] = Toolbox::encodeInUtf8($line2["NAME"]);
}
$pci["entities_id"] = $entities_id;
$pci["designation"] = $line2["NAME"];
if (!in_array(stripslashes($prevalue . $pci["designation"]), $import_device)) {
if (!empty($line2["DESCRIPTION"])) {
$pci["comment"] = $line2["DESCRIPTION"];
}
$DevicePci = new DevicePci();
$pci_id = $DevicePci->import($pci);
if ($pci_id) {
$CompDevice->add(array('items_id' => $computers_id, 'itemtype' => 'Computer', 'entities_id' => $entities_id, 'devicepcis_id' => $pci_id, 'is_dynamic' => 1), array(), $cfg_ocs['history_devices']);
}
} else {
$id = array_search(stripslashes($prevalue . $pci["designation"]), $import_device);
unset($import_device[$id]);
}
}
}
}
break;
case "Item_DeviceProcessor":
$CompDevice = new $devicetype();
//Processeurs:
$do_clean = true;
foreach ($ocsComputer as $line2) {
$line2 = Toolbox::clean_cross_side_scripting_deep(Toolbox::addslashes_deep($line2));
$processor = array();
$processor["designation"] = $line2["TYPE"];
if (!is_numeric($line2["SPEED"])) {
$line2["SPEED"] = 0;
}