当前位置: 首页>>代码示例>>PHP>>正文


PHP Toolbox::logInFile方法代码示例

本文整理汇总了PHP中Toolbox::logInFile方法的典型用法代码示例。如果您正苦于以下问题:PHP Toolbox::logInFile方法的具体用法?PHP Toolbox::logInFile怎么用?PHP Toolbox::logInFile使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Toolbox的用法示例。


在下文中一共展示了Toolbox::logInFile方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: logIfExtradebug

 /**
  * Log when extra-debug is activated
  */
 static function logIfExtradebug($file, $message)
 {
     if (!PluginFusioninventoryConfig::isExtradebugActive()) {
         return;
     }
     Toolbox::logInFile($file, $message);
 }
开发者ID:paisdelconocimiento,项目名称:glpi-smartcities,代码行数:10,代码来源:logger.class.php

示例2: sendProlog

 function sendProlog($input)
 {
     $input = gzcompress($input);
     $fp = fsockopen($this->server_ip, 80, $errno, $errstr, 30);
     if (!$fp) {
         echo "{$errstr} ({$errno})\n";
     } else {
         $out = "POST " . $this->server_urlpath . " HTTP/1.1\r\n";
         $out .= "Host: " . $this->server_ip . " \r\n";
         $out .= "Content-Length: " . strlen($input) . "\r\n";
         $out .= "Connection: close\r\n\r\n";
         fputs($fp, $out . $input);
         $zipped = "";
         while (!feof($fp)) {
             $line = fgets($fp, 4096);
             $zipped .= $line;
             if ($line == "\r\n") {
                 $zipped = "";
             }
         }
         fclose($fp);
         Toolbox::logInFile("RETSERV", $zipped . "\n");
         if (!gzuncompress($zipped)) {
             echo $zipped;
         }
         return gzuncompress($zipped);
     }
 }
开发者ID:korial29,项目名称:fusioninventory-for-glpi,代码行数:28,代码来源:emulatoragent.php

示例3: logIfExtradebug

 /**
  * Log when extra-debug is activated
  */
 static function logIfExtradebug($file, $message)
 {
     $config = new PluginFusioninventoryConfig();
     if ($config->getValue('extradebug')) {
         if (is_array($message)) {
             $message = print_r($message, TRUE);
         }
         Toolbox::logInFile($file, $message);
     }
 }
开发者ID:paisdelconocimiento,项目名称:glpi-smartcities,代码行数:13,代码来源:toolbox.class.php

示例4: post_addItem

 function post_addItem()
 {
     //only log in file, important events (connections and critical events; TODO : we need to add a general option to filter this in 9.1)
     if (isset($this->fields['level']) && $this->fields['level'] <= 3) {
         $message_type = "";
         if (isset($this->fields['type']) && $this->fields['type'] != 'system') {
             $message_type = "[" . $this->fields['type'] . " " . $this->fields['id'] . "] ";
         }
         $full_message = "[" . $this->fields['service'] . "] " . $message_type . $this->fields['level'] . ": " . Toolbox::stripslashes_deep($this->fields['message']) . "\n";
         Toolbox::logInFile("event", $full_message);
     }
 }
开发者ID:stweil,项目名称:glpi,代码行数:12,代码来源:event.class.php

示例5: includeLocales

/**
 * Include locales for a specific report
 *
 * @param $report_name  the name of the report to use
 * @param $plugin       plugins name (default 'reports')
 *
 * @return boolean, true if locale found
**/
function includeLocales($report_name, $plugin = 'reports')
{
    global $CFG_GLPI, $LANG;
    $prefix = GLPI_ROOT . "/plugins/{$plugin}/report/" . $report_name . "/" . $report_name;
    if (isset($_SESSION["glpilanguage"]) && file_exists($prefix . "." . $_SESSION["glpilanguage"] . ".php")) {
        include_once $prefix . "." . $_SESSION["glpilanguage"] . ".php";
    } else {
        if (file_exists($prefix . ".en_GB.php")) {
            include_once $prefix . ".en_GB.php";
        } else {
            // At least defined report name
            $name = $report_name . '_report_title';
            $LANG['plugin_' . $plugin][$report_name] = __($report_name . '_report_title', $plugin);
            // For dev
            if ($LANG['plugin_' . $plugin][$report_name] == $report_name . '_report_title') {
                Toolbox::logInFile('php-errors', "includeLocales({$name}, {$plugin}) => not found\n");
            }
            //    return false;
        }
    }
    return true;
}
开发者ID:paisdelconocimiento,项目名称:glpi-smartcities,代码行数:30,代码来源:function.php

示例6: str_replace

            $mmail->FromName = $row['email'];
        }
    }
    $body = str_replace("\\r", "", str_replace("\\n", "\n", $_POST['body']));
    if ($_POST['users_id_ticketmail']) {
        $address = PluginTicketmailProfile::getEmail($_POST['users_id_ticketmail']);
    } else {
        $address = $_POST["address"];
    }
    if (!NotificationMail::isUserAddressValid($address)) {
        Session::addMessageAfterRedirect(__("Invalid email address"), false, ERROR);
    }
    $mmail->AddAddress($address, $address);
    $mmail->Subject = $_POST["subject"];
    $mmail->Body = $body;
    $mmail->MessageID = "GLPI-ticketmail" . time() . "." . rand() . "@" . php_uname('n');
    if (!$mmail->Send()) {
        Session::addMessageAfterRedirect(__("Your email could not be processed.\nIf the problem persists, contact the administrator"), false, ERROR);
    } else {
        Toolbox::logInFile("mail", sprintf(__('%1$s: %2$s'), sprintf(__('An email was sent to %s'), $address), $_POST["subject"] . "\n"));
        $changes[0] = 0;
        $changes[1] = $address;
        $changes[2] = $_POST['subject'];
        Log::history($_POST['id'], 'Ticket', $changes, 'PluginTicketmailProfile', Log::HISTORY_PLUGIN + 1024);
        Session::addMessageAfterRedirect(sprintf(__('An email was sent to %s'), $address));
    }
    $mmail->ClearAddresses();
    Html::redirect($_SERVER['HTTP_REFERER']);
} else {
    Html::redirect("../index.php");
}
开发者ID:geldarr,项目名称:hack-space,代码行数:31,代码来源:ticketmail.form.php

示例7: execute

 /**
  * Standard method execution : checks if client can execute method + manage session
  *
  * @param $method string method name
  * @param $params array the method parameters
  * @param $protocol the communication protocol used
  *
  * @return array the method response
  **/
 function execute($method, $params, $protocol)
 {
     global $DB, $WEBSERVICES_METHOD, $TIMER_DEBUG;
     // Don't display error in result
     set_error_handler(array('Toolbox', 'userErrorHandlerNormal'));
     ini_set('display_errors', 'Off');
     $iptxt = isset($_SERVER["HTTP_X_FORWARDED_FOR"]) ? $_SERVER["HTTP_X_FORWARDED_FOR"] : $_SERVER["REMOTE_ADDR"];
     $ipnum = strstr($iptxt, ':') === false ? ip2long($iptxt) : '';
     if (isset($_SESSION["MESSAGE_AFTER_REDIRECT"])) {
         // Avoid to keep "info" message between call
         $_SESSION["MESSAGE_AFTER_REDIRECT"] = '';
     }
     $plug = new Plugin();
     if ($plug->isActivated('webservices')) {
         if (isset($params['session'])) {
             self::setSession($params['session']);
         }
         // Build query for security check
         $sql = "SELECT *\n                 FROM `glpi_plugin_webservices_clients`\n                 WHERE '" . addslashes($method) . "' REGEXP pattern\n                       AND `is_active` = '1' ";
         if ($ipnum) {
             $sql .= " AND (`ip_start` IS NULL\n                            OR (`ip_start` <= '{$ipnum}' AND `ip_end` >= '{$ipnum}'))";
         } else {
             $sql .= " AND `ipv6` = '" . addslashes($iptxt) . "'";
         }
         if (isset($params["username"])) {
             $username = addslashes($params["username"]);
             $password = md5(isset($params["password"]) ? $params["password"] : '');
             $sql .= " AND (`username` IS NULL\n                               OR (`username` = '{$username}' AND `password` = '{$password}'))";
             unset($params["username"]);
             unset($params["password"]);
         } else {
             $username = 'anonymous';
             $sql .= " AND `username` IS NULL ";
         }
         $deflate = $debug = $log = false;
         $entities = array();
         if (Session::getLoginUserID() && isset($_SESSION['glpiactiveentities'])) {
             $username = $_SESSION['glpiname'];
             // for log (no t for SQL request)
         }
         foreach ($DB->request($sql) as $data) {
             // Check matching rules
             // Store entities for not authenticated user
             if (!Session::getLoginUserID()) {
                 if ($data['is_recursive']) {
                     foreach (getSonsOf("glpi_entities", $data['entities_id']) as $entity) {
                         $entities[$entity] = $entity;
                     }
                 } else {
                     $entities[$data['entities_id']] = $data['entities_id'];
                 }
             }
             // Where to log
             if ($data["do_log"] == 2) {
                 // Log to file
                 $log = LOGFILENAME;
             } else {
                 if ($data["do_log"] == 1) {
                     // Log to History
                     $log = $data["id"];
                 }
             }
             $debug = $data['debug'];
             $deflate = $data['deflate'];
         }
         $callname = '';
         // Always log when connection denied
         if (!Session::getLoginUserID() && !count($entities)) {
             $resp = self::Error($protocol, 1, __('Access denied'));
             // log to file (not macthing config to use history)
             Toolbox::logInFile(LOGFILENAME, __('Access denied') . " ({$username}, {$iptxt}, {$method}, {$protocol})\n");
         } else {
             // Allowed
             if (!Session::getLoginUserID()) {
                 // TODO : probably more data should be initialized here
                 $_SESSION['glpiactiveentities'] = $entities;
             }
             // Log if configured
             if (is_numeric($log)) {
                 $changes[0] = 0;
                 $changes[1] = "";
                 $changes[2] = __('Connection') . " ({$username}, {$iptxt}, {$method}, {$protocol})";
                 Log::history($log, 'PluginWebservicesClient', $changes, 0, Log::HISTORY_LOG_SIMPLE_MESSAGE);
             } else {
                 if ($log && !$debug) {
                     Toolbox::logInFile($log, __('Connection') . " ({$username}, {$iptxt}, {$method})\n");
                 }
             }
             $defserver = ini_get('zlib.output_compression');
             if ($deflate && !$defserver) {
                 // Globally off, try to enable for this client
//.........这里部分代码省略.........
开发者ID:JULIO8,项目名称:respaldo_glpi,代码行数:101,代码来源:methodsession.class.php

示例8: addMessageAfterRedirect

 /**
  * Add a message to be displayed after redirect
  *
  * @param $msg             Message to add
  * @param $check_once      Check if the message is not already added (false by default)
  * @param $message_type    Message type (INFO, ERROR) (default INFO)
  * @param $reset           Clear previous added message (false by default)
  **/
 static function addMessageAfterRedirect($msg, $check_once = false, $message_type = INFO, $reset = false)
 {
     if (!empty($msg)) {
         if (self::isCron()) {
             // We are in cron mode
             // Do not display message in user interface, but record error
             if ($message_type == ERROR) {
                 Toolbox::logInFile('cron', $msg . "\n");
             }
         } else {
             if ($reset) {
                 $_SESSION["MESSAGE_AFTER_REDIRECT"] = '';
             }
             $toadd = "";
             if ($check_once) {
                 if (strstr($_SESSION["MESSAGE_AFTER_REDIRECT"], $msg) === false) {
                     $toadd = $msg . '<br>';
                 }
             } else {
                 $toadd = $msg . '<br>';
             }
             if (!empty($toadd)) {
                 switch ($message_type) {
                     case ERROR:
                     case WARNING:
                         $_SESSION["MESSAGE_AFTER_REDIRECT"] .= "<h3><span class='red'>{$toadd}</span></h3>";
                         break;
                     default:
                         // INFO
                         $_SESSION["MESSAGE_AFTER_REDIRECT"] .= "<h3>{$toadd}</h3>";
                 }
             }
         }
     }
 }
开发者ID:jose-martins,项目名称:glpi,代码行数:43,代码来源:session.class.php

示例9: 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)) {
//.........这里部分代码省略.........
开发者ID:remicollet,项目名称:glpi,代码行数:101,代码来源:mailcollector.class.php

示例10: sendNotification

 /**
  * @param $options   array
  **/
 function sendNotification($options = array())
 {
     $mmail = new self();
     $mmail->AddCustomHeader("Auto-Submitted: auto-generated");
     // For exchange
     $mmail->AddCustomHeader("X-Auto-Response-Suppress: OOF, DR, NDR, RN, NRN");
     $mmail->SetFrom($options['from'], $options['fromname']);
     if ($options['replyto']) {
         $mmail->AddReplyTo($options['replyto'], $options['replytoname']);
     }
     $mmail->Subject = $options['subject'];
     if (empty($options['content_html'])) {
         $mmail->isHTML(false);
         $mmail->Body = $options['content_text'];
     } else {
         $mmail->isHTML(true);
         $mmail->Body = $options['content_html'];
         $mmail->AltBody = $options['content_text'];
     }
     $mmail->AddAddress($options['to'], $options['toname']);
     if (!empty($options['messageid'])) {
         $mmail->MessageID = "<" . $options['messageid'] . ">";
     }
     $messageerror = __('Error in sending the email');
     if (!$mmail->Send()) {
         $senderror = true;
         Session::addMessageAfterRedirect($messageerror . "<br>" . $mmail->ErrorInfo, true);
     } else {
         //TRANS to be written in logs %1$s is the to email / %2$s is the subject of the mail
         Toolbox::logInFile("mail", sprintf(__('%1$s: %2$s'), sprintf(__('An email was sent to %s'), $options['to']), $options['subject'] . "\n"));
     }
     $mmail->ClearAddresses();
     return true;
 }
开发者ID:gaforeror,项目名称:glpi,代码行数:37,代码来源:notificationmail.class.php

示例11: generatePDF

 /**
  * Generate the PDF for some object
  *
  * @param $tab_id  Array   of ID of object to print
  * @param $tabs    Array   of name of tab to print
  * @param $page    Integer 1 for landscape, 0 for portrait
  * @param $render  Boolean send result if true,  return result if false
  *
  * @return pdf output if $render is false
  **/
 final function generatePDF($tab_id, $tabs, $page = 0, $render = true)
 {
     $this->pdf = new PluginPdfSimplePDF('a4', $page ? 'landscape' : 'portrait');
     foreach ($tab_id as $key => $id) {
         if ($this->addHeader($id)) {
             $this->pdf->newPage();
         } else {
             // Object not found or no right to read
             continue;
         }
         foreach ($tabs as $tab) {
             if (!$this->displayTabContentForPDF($this->pdf, $this->obj, $tab) && !$this->displayCommonTabForPDF($this->pdf, $this->obj, $tab)) {
                 $data = explode('$', $tab);
                 $itemtype = $data[0];
                 // Default set
                 $tabnum = isset($data[1]) ? $data[1] : 1;
                 if (!is_integer($itemtype) && $itemtype != 'empty') {
                     if ($itemtype == "Item_Devices") {
                         $PluginPdfComputer = new PluginPdfComputer();
                         if ($PluginPdfComputer->displayTabContentForPdf($this->pdf, $this->obj, $tabnum)) {
                             continue;
                         }
                     } else {
                         if (method_exists($itemtype, "displayTabContentForPdf") && ($obj = getItemForItemtype($itemtype))) {
                             if ($obj->displayTabContentForPdf($this->pdf, $this->obj, $tabnum)) {
                                 continue;
                             }
                         }
                     }
                 }
                 Toolbox::logInFile('php-errors', sprintf(__("PDF: don't know how to display %s tab") . '\\n', $tab));
             }
         }
     }
     if ($render) {
         $this->pdf->render();
     } else {
         return $this->pdf->output();
     }
 }
开发者ID:geldarr,项目名称:hack-space,代码行数:50,代码来源:common.class.php

示例12: getAgentsSubnet

 function getAgentsSubnet($nb_computers, $communication, $subnet = '', $ipstart = '', $ipend = '')
 {
     global $DB;
     $pfTaskjob = new PluginFusioninventoryTaskjob();
     $pfAgentmodule = new PluginFusioninventoryAgentmodule();
     // Number of computers min by agent
     $nb_computerByAgentMin = 20;
     $nb_agentsMax = ceil($nb_computers / $nb_computerByAgentMin);
     $a_agentList = array();
     if ($subnet != '') {
         $subnet = " AND `glpi_ipaddresses`.`name` LIKE '" . $subnet . "%' ";
     } else {
         if ($ipstart != '' and $ipend != '') {
             $subnet = " AND ( INET_ATON(`glpi_ipaddresses`.`name`) > INET_ATON('" . $ipstart . "')\n            AND  INET_ATON(`glpi_ipaddresses`.`name`) < INET_ATON('" . $ipend . "') ) ";
         }
     }
     $a_agents = $pfAgentmodule->getAgentsCanDo('NETWORKINVENTORY');
     $a_agentsid = array();
     foreach ($a_agents as $a_agent) {
         $a_agentsid[] = $a_agent['id'];
     }
     if (count($a_agentsid) == '0') {
         return $a_agentList;
     }
     $where = " AND `glpi_plugin_fusioninventory_agents`.`ID` IN (";
     $where .= implode(', ', $a_agentsid);
     $where .= ")\n         AND `glpi_ipaddresses`.`name` != '127.0.0.1' ";
     $query = "SELECT `glpi_plugin_fusioninventory_agents`.`id` as `a_id`,\n         `glpi_ipaddresses`.`name` as ip, token\n         FROM `glpi_plugin_fusioninventory_agents`\n         LEFT JOIN `glpi_networkports`\n            ON `glpi_networkports`.`items_id` = `glpi_plugin_fusioninventory_agents`.`computers_id`\n         LEFT JOIN `glpi_networknames`\n              ON `glpi_networknames`.`items_id`=`glpi_networkports`.`id`\n                 AND `glpi_networknames`.`itemtype`='NetworkPort'\n         LEFT JOIN `glpi_ipaddresses`\n              ON `glpi_ipaddresses`.`items_id`=`glpi_networknames`.`id`\n                 AND `glpi_ipaddresses`.`itemtype`='NetworkName'\n         LEFT JOIN `glpi_computers`\n            ON `glpi_computers`.`id` = `glpi_plugin_fusioninventory_agents`.`computers_id`\n         WHERE `glpi_networkports`.`itemtype`='Computer'\n            " . $subnet . "\n            " . $where . " ";
     Toolbox::logInFile('NET', $query);
     $result = $DB->query($query);
     if ($result) {
         while ($data = $DB->fetch_array($result)) {
             if ($communication == 'push') {
                 if ($pfTaskjob->isAgentAlive("1", $data['a_id'])) {
                     if (!in_array($a_agentList, $data['a_id'])) {
                         $a_agentList[] = $data['a_id'];
                         if (count($a_agentList) >= $nb_agentsMax) {
                             return $a_agentList;
                         }
                     }
                 }
             } else {
                 if ($communication == 'pull') {
                     if (!in_array($data['a_id'], $a_agentList)) {
                         $a_agentList[] = $data['a_id'];
                         if (count($a_agentList) > $nb_agentsMax) {
                             return $a_agentList;
                         }
                     }
                 }
             }
         }
     }
     return $a_agentList;
 }
开发者ID:korial29,项目名称:fusioninventory-for-glpi,代码行数:55,代码来源:networkinventory.class.php

示例13: logIfExtradebug

 /**
  * Log when extra-debug is activated
  */
 static function logIfExtradebug($file, $message)
 {
     if (self::isExtradebugActive()) {
         if (is_array($message)) {
             $message = print_r($message, TRUE);
         }
         Toolbox::logInFile($file, $message);
     }
 }
开发者ID:C-Duv,项目名称:fusioninventory-for-glpi,代码行数:12,代码来源:config.class.php

示例14: addMessageAfterRedirect

 /**
  * Add a message to be displayed after redirect
  *
  * @param $msg             Message to add
  * @param $check_once      Check if the message is not already added (false by default)
  * @param $message_type    Message type (INFO, WARNING, ERROR) (default INFO)
  * @param $reset           Clear previous added message (false by default)
  **/
 static function addMessageAfterRedirect($msg, $check_once = false, $message_type = INFO, $reset = false)
 {
     if (!empty($msg)) {
         if (self::isCron()) {
             // We are in cron mode
             // Do not display message in user interface, but record error
             if ($message_type == ERROR) {
                 Toolbox::logInFile('cron', $msg . "\n");
             }
         } else {
             if ($reset) {
                 $_SESSION["MESSAGE_AFTER_REDIRECT"] = [];
             }
             if (!isset($_SESSION["MESSAGE_AFTER_REDIRECT"][$message_type])) {
                 $_SESSION["MESSAGE_AFTER_REDIRECT"][$message_type] = array();
             }
             if (!$check_once || !isset($_SESSION["MESSAGE_AFTER_REDIRECT"][$message_type]) || in_array($msg, $_SESSION["MESSAGE_AFTER_REDIRECT"][$message_type]) === false) {
                 array_push($_SESSION["MESSAGE_AFTER_REDIRECT"][$message_type], $msg);
             }
         }
     }
 }
开发者ID:btry,项目名称:glpi,代码行数:30,代码来源:session.class.php

示例15: executeSync

 static function executeSync()
 {
     $REP_XML = GLPI_PLUGIN_DOC_DIR . '/sccm/xml/';
     $PluginSccmConfig = new PluginSccmConfig();
     $PluginSccmConfig->getFromDB(1);
     $PluginSccmSccm = new PluginSccmSccm();
     if ($PluginSccmConfig->getField('active_sync') == 1) {
         Toolbox::logInFile('sccm', "Inject start \n", true);
         $PluginSccmSccm->getDevices();
         Toolbox::logInFile('sccm', "getDevices OK \n", true);
         Toolbox::logInFile('sccm', "Generate XML start : " . count($PluginSccmSccm->devices) . " files\n", true);
         foreach ($PluginSccmSccm->devices as $device_values) {
             $PluginSccmSccmxml = new PluginSccmSccmxml($device_values);
             $PluginSccmSccmxml->setAccessLog();
             $PluginSccmSccmxml->setAccountInfos();
             $PluginSccmSccmxml->setHardware();
             $PluginSccmSccmxml->setOS();
             $PluginSccmSccmxml->setBios();
             $PluginSccmSccmxml->setProcessors();
             $PluginSccmSccmxml->setSoftwares();
             $PluginSccmSccmxml->setUsers();
             $PluginSccmSccmxml->setNetworks();
             $PluginSccmSccmxml->setDrives();
             $SXML = $PluginSccmSccmxml->sxml;
             $SXML->asXML($REP_XML . $PluginSccmSccmxml->device_id . ".ocs");
             $ch = curl_init();
             curl_setopt($ch, CURLOPT_URL, $PluginSccmConfig->getField('fusioninventory_url'));
             curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type: text/xml'));
             curl_setopt($ch, CURLOPT_HEADER, 0);
             curl_setopt($ch, CURLOPT_POST, 1);
             curl_setopt($ch, CURLOPT_POSTFIELDS, $SXML->asXML());
             curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 0);
             curl_setopt($ch, CURLOPT_REFERER, $PluginSccmConfig->getField('fusioninventory_url'));
             curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
             $ch_result = curl_exec($ch);
             curl_close($ch);
             Toolbox::logInFile('sccm', "Ajout OK - " . $PluginSccmSccmxml->device_id . " \n", true);
         }
     } else {
         echo __("Synchronization is disabled by configuration.", "sccm");
     }
 }
开发者ID:rjmontenegro,项目名称:sccm,代码行数:42,代码来源:sccm.class.php


注:本文中的Toolbox::logInFile方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。