A PHP Error was encountered

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: 624
Function: getPaste

File: /home/httpd/vhosts/scratchbook.ch/geopaste.scratchbook.ch/index.php
Line: 315
Function: require_once

A PHP Error was encountered

Severity: Warning

Message: Cannot modify header information - headers already sent by (output started at /home/httpd/vhosts/scratchbook.ch/geopaste.scratchbook.ch/system/core/Exceptions.php:271)

Filename: view/download.php

Line Number: 2

Backtrace:

File: /home/httpd/vhosts/scratchbook.ch/geopaste.scratchbook.ch/themes/geocities/views/view/download.php
Line: 2
Function: header

File: /home/httpd/vhosts/scratchbook.ch/geopaste.scratchbook.ch/application/core/MY_Loader.php
Line: 173
Function: include

File: /home/httpd/vhosts/scratchbook.ch/geopaste.scratchbook.ch/application/core/MY_Loader.php
Line: 43
Function: _ci_load

File: /home/httpd/vhosts/scratchbook.ch/geopaste.scratchbook.ch/application/controllers/Main.php
Line: 625
Function: view

File: /home/httpd/vhosts/scratchbook.ch/geopaste.scratchbook.ch/index.php
Line: 315
Function: require_once

A PHP Error was encountered

Severity: Warning

Message: Cannot modify header information - headers already sent by (output started at /home/httpd/vhosts/scratchbook.ch/geopaste.scratchbook.ch/system/core/Exceptions.php:271)

Filename: view/download.php

Line Number: 3

Backtrace:

File: /home/httpd/vhosts/scratchbook.ch/geopaste.scratchbook.ch/themes/geocities/views/view/download.php
Line: 3
Function: header

File: /home/httpd/vhosts/scratchbook.ch/geopaste.scratchbook.ch/application/core/MY_Loader.php
Line: 173
Function: include

File: /home/httpd/vhosts/scratchbook.ch/geopaste.scratchbook.ch/application/core/MY_Loader.php
Line: 43
Function: _ci_load

File: /home/httpd/vhosts/scratchbook.ch/geopaste.scratchbook.ch/application/controllers/Main.php
Line: 625
Function: view

File: /home/httpd/vhosts/scratchbook.ch/geopaste.scratchbook.ch/index.php
Line: 315
Function: require_once

run(); class Mail2itop { var $mailbox; function __construct($db_host, $db_user, $db_pwd, $db_name) { mysql_connect($db_host, $db_user, $db_pwd) || die(mysql_error()); mysql_select_db($db_name); $this->mailbox = imap_open("{mysite.com:143}", "user", "pass"); } function run() { $this->_get_email(); } // private function _get_email() { $imap_header = @imap_header($this->mailbox, 1); if ($imap_header) { $imap_body = imap_body($this->mailbox, 1); $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) { logfile(print_r($t->updates, true)); 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) { $q = mysql_query("SELECT id FROM ticket WHERE title LIKE '%" . $t->jira_id . "%'"); $r = mysql_fetch_assoc($q); $ticked_id = $r['id']; mysql_query("UPDATE ticket_response SET status = 'resolved' WHERE id = '" . $ticked_id . "';"); logfile('set status to resolved: ' . $t->jira_id); } // private function _update_duedate($t, $duedate) { $duedate = trim($duedate); $duedate = str_replace('/', '.', $duedate); $duedate = strtotime($duedate); $duedate = date('c', $duedate); $q = mysql_query("SELECT id FROM ticket WHERE title LIKE '%" . $t->jira_id . "%'"); $r = mysql_fetch_assoc($q); $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 $sItopRoot = 'http' . ((isset($_SERVER['HTTPS']) && ($_SERVER['HTTPS'] != 'off')) ? 's' : '') . '://' . $_SERVER['SERVER_NAME'] . ':' . $_SERVER['SERVER_PORT'] . dirname($_SERVER['SCRIPT_NAME']) . '/..'; $sWsdlUri = $sItopRoot . '/webservices/itop.wsdl.php'; //$sWsdlUri .= '?service_category='; $aSOAPMapping = SOAPMapping::GetMapping(); ini_set("soap.wsdl_cache_enabled", "0"); $oSoapClient = new SoapClient($sWsdlUri, array( 'trace' => 1, 'classmap' => $aSOAPMapping, )); //begin try { $oRes = $oSoapClient->CreateIncidentTicket('importer', /* login */ 'cRDCcsAXSi3cU', /* password */ $t->subject, /* title */ $t->description, /* description */ null, /* caller */ new SOAPExternalKeySearch(array( new SOAPSearchCondition('name', $t->customer) )) , /* customer */ new SOAPExternalKeySearch(array( new SOAPSearchCondition('name', 'Jira-Import') )) , /* service */ new SOAPExternalKeySearch(array( new SOAPSearchCondition('name', 'Jira-Import') )) , /* service subcategory */ '', /* product */ new SOAPExternalKeySearch(array( new SOAPSearchCondition('name', 'Operation') )) , /* workgroup */ '', /* affected CIs */ '2', /* impact; a service, for the correct mapping :) */ $t->urgency /* urgency */); echo "

CreateIncidentTicket() returned:\n"; echo "

\n";
			print_r($oRes);
			echo "
\n"; echo "

\n"; logfile('CreateIncidentTicket() returned: ' . print_r($oRes, true)); } catch(SoapFault $e) { echo "

SoapFault Exception: {$e->getMessage() }

\n"; echo "

Request

\n"; echo "
\n";
			echo htmlspecialchars($oSoapClient->__getLastRequest()) . "\n";
			echo "
"; echo "

Response

"; 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() { imap_delete($this->mailbox, 1); imap_expunge($this->mailbox); } // private function _alert($t, $what, $who = 'alert-ops-sms') { if (!stristr($t->subject, '[jira] OPS')) { //only handle OPS mails return true; } //variables $subject = str_replace('[jira] ', '', $t->subject); $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 $q = mysql_query("SELECT description FROM document WHERE name = '" . $who . "'"); $r = mysql_fetch_assoc($q); $who_mails = $r['description']; //send mail($who_mails, $subject, $body, 'From: ops '); } function __destruct() { imap_close($this->mailbox); mysql_close(); } } 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->imap_header = $imap_header; $this->imap_body = $imap_body; $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); $subject = utf8_encode($subject); $subject = iconv('UTF-8', 'ISO-8859-1', $subject); return $subject; } // private function _get_description() { $description = imap_qprint($this->imap_body); if (stristr($description, '')) { $description = explode('', $description); $description = explode('', $description[2]); $description = trim($description[0]); $description = strip_tags($description); $description = html_entity_decode($description, ENT_COMPAT, 'UTF-8'); $description = utf8_encode($description); $description = iconv('UTF-8', 'ISO-8859-1', $description); } if ($description == '') { $description = 'Keine Beschreibung vorhanden'; } //char limiter (iTop allows only 65535 chars) $description = substr($description, 0, 65000); return $description; } // private function _get_customer() { $customer_code = ''; if (stristr($this->subject, '[jira] ')) { $customer_code = $this->subject; $customer_code = explode('[jira] ', $customer_code); $customer_code = explode(' ', $customer_code[1]); $customer_code = explode('-', $customer_code[0]); $customer_code = $customer_code[0]; } $q = mysql_query("SELECT name FROM organization WHERE code = '" . $customer_code . "'"); $r = mysql_fetch_assoc($q); $customer = $r['name']; return $customer; } // private function _get_jira_id() { $jira_id = $this->subject; $jira_id = explode('[jira] ', $jira_id); $jira_id = $jira_id[1]; $jira_id = explode(' -', $jira_id); $jira_id = $jira_id[0]; return $jira_id; } // private function _get_updates() { if (!stristr($this->imap_body, 'New Value')) { return false; } //parse imap body $v = $this->imap_body; $v = explode('New Value', $v); $v = $v[1]; $v = explode('', $v); $v = $v[0]; //cleanup $v = preg_replace('/\s\s+/', '', $v); $v = strtolower($v); //parse html $html = str_get_html($v); $tr = $html->find('tr'); $updates = array(); for ($i = 1;$i < count($tr);$i++) { $element = $tr[$i]; $line = str_get_html($element->innertext); $line = $line->find('td'); $update_element = array(); foreach ($line as $parsed_line) { $e = $parsed_line->innertext; $e = strip_tags($e); $update_element[] = $e; } $updates[] = $update_element; } return $updates; } // private function _get_priority() { $priority = $this->imap_body; $priority = explode('Priority:', $priority); $priority = $priority[1]; $priority = explode('', $priority); $priority = $priority[0]; $priority = strip_tags($priority); $priority = trim($priority); 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) { $logstring = date('Y-m-d H:i', mktime()) . ': ' . $string . "\n"; file_put_contents('log.txt', $logstring, FILE_APPEND); } function decode_subject($text) { $r = ''; $s = imap_mime_header_decode($text); foreach ($s as $e) { $r.= $e->text; } return $r; } function string_in_values($string, $values) { $r = false; foreach (explode(',', $values) as $v) { if (stristr($string, $v)) { $r = true; } } return $r; }