Severity: 8192
Message: Function create_function() is deprecated
Filename: geshi/geshi.php
Line Number: 4698
Backtrace:
File: /home/httpd/vhosts/scratchbook.ch/geopaste.scratchbook.ch/application/libraries/geshi/geshi.php
Line: 4698
Function: _error_handler
File: /home/httpd/vhosts/scratchbook.ch/geopaste.scratchbook.ch/application/libraries/geshi/geshi.php
Line: 4621
Function: _optimize_regexp_list_tokens_to_string
File: /home/httpd/vhosts/scratchbook.ch/geopaste.scratchbook.ch/application/libraries/geshi/geshi.php
Line: 1655
Function: optimize_regexp_list
File: /home/httpd/vhosts/scratchbook.ch/geopaste.scratchbook.ch/application/libraries/geshi/geshi.php
Line: 2029
Function: optimize_keyword_group
File: /home/httpd/vhosts/scratchbook.ch/geopaste.scratchbook.ch/application/libraries/geshi/geshi.php
Line: 2168
Function: build_parse_cache
File: /home/httpd/vhosts/scratchbook.ch/geopaste.scratchbook.ch/application/libraries/Process.php
Line: 45
Function: parse_code
File: /home/httpd/vhosts/scratchbook.ch/geopaste.scratchbook.ch/application/models/Pastes.php
Line: 517
Function: syntax
File: /home/httpd/vhosts/scratchbook.ch/geopaste.scratchbook.ch/application/controllers/Main.php
Line: 693
Function: getPaste
File: /home/httpd/vhosts/scratchbook.ch/geopaste.scratchbook.ch/index.php
Line: 315
Function: require_once
<?php /** * Class and Function List: * Function list: * - __construct() * - run() * - _get_email() * - _update_handler() * - _resolve_ticket() * - _update_duedate() * - _update_priority() * - _create_ticket() * - _delete_email() * - _alert() * - __destruct() * - __construct() * - _get_subject() * - _get_description() * - _get_customer() * - _get_jira_id() * - _get_updates() * - _get_priority() * - _get_urgency() * - logfile() * - decode_subject() * - string_in_values() * Classes list: * - Mail2itop * - Ticket */ include ('../config-itop.php'); require_once ('itopsoaptypes.class.inc.php'); require_once ('simple_html_dom.php'); // $m = new Mail2itop($MySettings['db_host'], $MySettings['db_user'], $MySettings['db_pwd'], $MySettings['db_name']); $m->run(); class Mail2itop { var $mailbox; function __construct($db_host, $db_user, $db_pwd, $db_name) { } function run() { $this->_get_email(); } // private function _get_email() { if ($imap_header) { $t = new Ticket($imap_header, $imap_body); if ($t->subject != '') { logfile('got mail with subject: ' . $t->subject); if (string_in_values($t->subject, 'created:,moved:,updated:')) { if (string_in_values($t->subject, 'created:,moved:')) { $this->_create_ticket($t); } else if (string_in_values($t->subject, 'updated:')) { $this->_update_handler($t); } } } //delete email $this->_delete_email(); //get next email $this->_get_email(); } } // private function _update_handler($t) { foreach ($t->updates as $update) { if (string_in_values($update[0], 'status') && string_in_values($update[2], 'resolved')) { logfile('resolving ticket'); $this->_resolve_ticket($t); } else if (string_in_values($update[0], 'due date')) { logfile('updating due date'); $this->_update_duedate($t, $update[2]); } else if (string_in_values($update[0], 'priority')) { logfile('updating priority'); $this->_update_priority($t, $update[2]); } else if (string_in_values($update[0], 'status') && string_in_values($update[2], 'reopened')) { logfile('reopen ticket'); $this->_create_ticket($t); } } } // private function _resolve_ticket($t) { $ticked_id = $r['id']; logfile('set status to resolved: ' . $t->jira_id); } // private function _update_duedate($t, $duedate) { $ticked_id = $r['id']; mysql_query("UPDATE ticket_response SET ttr_escalation_deadline = '" . $duedate . "' WHERE id = '" . $ticked_id . "';"); logfile('set TTR to ' . $duedate . ': ' . $t->jira_id); } // private function _update_priority($t, $priority) { if (string_in_values($priority, 'critical,blocker')) { $this->_alert($t, 'priority_change', 'alert-ops-email'); $this->_alert($t, 'priority_change', 'alert-ops-sms'); $this->_alert($t, 'priority_change', 'alert-ops-pager'); } } // private function _create_ticket($t) { //send alert $this->_alert($t, 'new_ticket', 'alert-ops-email'); $this->_alert($t, 'new_ticket', 'alert-ops-sms'); if (string_in_values($t->priority, 'blocker')) { $this->_alert($t, 'new_ticket', 'alert-ops-pager'); } //soap $sWsdlUri = $sItopRoot . '/webservices/itop.wsdl.php'; //$sWsdlUri .= '?service_category='; $aSOAPMapping = SOAPMapping::GetMapping(); 'trace' => 1, 'classmap' => $aSOAPMapping, )); //begin try { $oRes = $oSoapClient->CreateIncidentTicket('importer', /* login */ 'cRDCcsAXSi3cU', /* password */ $t->subject, /* title */ $t->description, /* description */ null, /* caller */ new SOAPSearchCondition('name', $t->customer) )) , /* customer */ new SOAPSearchCondition('name', 'Jira-Import') )) , /* service */ new SOAPSearchCondition('name', 'Jira-Import') )) , /* service subcategory */ '', /* product */ new SOAPSearchCondition('name', 'Operation') )) , /* workgroup */ '', /* affected CIs */ '2', /* impact; a service, for the correct mapping :) */ $t->urgency /* urgency */); echo "<p>CreateIncidentTicket() returned:\n"; echo "<pre>\n"; echo "</pre>\n"; echo "</p>\n"; } catch(SoapFault $e) { echo "<h1>SoapFault Exception: {$e->getMessage() }</h1>\n"; echo "<h2>Request</h2>\n"; echo "<pre>\n"; echo "</pre>"; echo "<h2>Response</h2>"; echo $oSoapClient->__getLastResponse() . "\n"; logfile('ERROR'); logfile('SoapFault Exception: ' . $e->getMessage()); logfile('Request: ' . $oSoapClient->__getLastRequest()); logfile('Response: ' . $oSoapClient->__getLastResponse()); //send email mail('e@mail.com', 'iTop Import Error', 'SoapFault Exception: ' . $e->getMessage() . ' Request: ' . $oSoapClient->__getLastRequest() . ' Response: ' . $oSoapClient->__getLastResponse()); } logfile("\n"); return true; } // private function _delete_email() { } // private function _alert($t, $what, $who = 'alert-ops-sms') { { //only handle OPS mails return true; } //variables $priority = $t->priority; //what switch ($what) { case 'new_ticket': $text = '(' . $priority . ') ' . $subject . ' - http://jira.yoursite.com/browse/' . $t->jira_id; $subject = $text; $body = $text; break; case 'priority_change': $text = 'Priority changed: (' . $priority . ') ' . $subject . ' - http://jira.yoursite.com/browse/' . $t->jira_id; $subject = $text; $body = $text; break; } //who $who_mails = $r['description']; //send } function __destruct() { } } class Ticket { var $imap_body; var $imap_header; var $subject; var $description; var $customer; var $jira_id; var $updates; var $priority; var $urgency; function __construct($imap_header, $imap_body) { //fill all attributes... $this->subject = $this->_get_subject(); $this->description = $this->_get_description(); $this->customer = $this->_get_customer(); $this->jira_id = $this->_get_jira_id(); $this->updates = $this->_get_updates(); $this->priority = $this->_get_priority(); $this->urgency = $this->_get_urgency(); } // private function _get_subject() { $subject = ''; $subject = decode_subject($this->imap_header->subject); return $subject; } // private function _get_description() { { } if ($description == '') { $description = 'Keine Beschreibung vorhanden'; } //char limiter (iTop allows only 65535 chars) return $description; } // private function _get_customer() { $customer_code = ''; { $customer_code = $this->subject; $customer_code = $customer_code[0]; } $customer = $r['name']; return $customer; } // private function _get_jira_id() { $jira_id = $this->subject; $jira_id = $jira_id[1]; $jira_id = $jira_id[0]; return $jira_id; } // private function _get_updates() { { return false; } //parse imap body $v = $v[1]; $v = $v[0]; //cleanup //parse html $html = str_get_html($v); $tr = $html->find('tr'); { $element = $tr[$i]; $line = str_get_html($element->innertext); $line = $line->find('td'); foreach ($line as $parsed_line) { $e = $parsed_line->innertext; $update_element[] = $e; } $updates[] = $update_element; } return $updates; } // private function _get_priority() { $priority = $priority[1]; $priority = $priority[0]; return $priority; } // private function _get_urgency() { $priority = $this->priority; //get urgency $urgency = 3; //$priority = low: trivial,medium,major if (string_in_values($priority, 'critical')) { $urgency = 2; } else if (string_in_values($priority, 'blocker')) { $urgency = 1; } return $urgency; } } //utils function logfile($string) { } function decode_subject($text) { $r = ''; foreach ($s as $e) { $r.= $e->text; } return $r; } function string_in_values($string, $values) { $r = false; { { $r = true; } } return $r; }