Skip to content
Snippets Groups Projects
Commit c8a59047 authored by Jared Hancock's avatar Jared Hancock
Browse files

Merge remote branch 'upstream-1.7/develop' into develop

Roll a few commits made post 1.7.3

Conflicts:
	include/class.thread.php
parents 68ba2c64 d6970162
No related branches found
No related tags found
No related merge requests found
...@@ -220,9 +220,28 @@ class MailFetcher { ...@@ -220,9 +220,28 @@ class MailFetcher {
return imap_utf7_encode($mailbox); return imap_utf7_encode($mailbox);
} }
//Generic decoder - resulting text is utf8 encoded -> mirrors imap_utf8 /**
* Mime header value decoder. Usually unicode characters are encoded
* according to RFC-2047. This function will decode RFC-2047 encoded
* header values as well as detect headers which are not encoded.
*
* Caveats:
* If headers contain non-ascii characters the result of this function
* is completely undefined. If osTicket is corrupting your email
* headers, your mail software is not encoding the header text
* correctly.
*
* Returns:
* Header value, transocded to UTF-8
*/
function mime_decode($text, $encoding='utf-8') { function mime_decode($text, $encoding='utf-8') {
// Handle poorly or completely un-encoded header values (
if (function_exists('mb_detect_encoding'))
if (($src_enc = mb_detect_encoding($text))
&& (strcasecmp($src_enc, 'ASCII') !== 0))
return Format::encode($text, $src_enc, $encoding);
// Handle ASCII text and RFC-2047 encoding
$str = ''; $str = '';
$parts = imap_mime_header_decode($text); $parts = imap_mime_header_decode($text);
foreach ($parts as $part) foreach ($parts as $part)
...@@ -298,7 +317,11 @@ class MailFetcher { ...@@ -298,7 +317,11 @@ class MailFetcher {
$struct=@imap_fetchstructure($this->mbox, $mid); $struct=@imap_fetchstructure($this->mbox, $mid);
//Match the mime type. //Match the mime type.
if($struct && !$struct->ifdparameters && strcasecmp($mimeType, $this->getMimeType($struct))==0) { if($struct
&& strcasecmp($mimeType, $this->getMimeType($struct))==0
&& (!$struct->ifdparameters
|| !$this->findFilename($struct->dparameters))) {
$partNumber=$partNumber?$partNumber:1; $partNumber=$partNumber?$partNumber:1;
if(($text=imap_fetchbody($this->mbox, $mid, $partNumber))) { if(($text=imap_fetchbody($this->mbox, $mid, $partNumber))) {
if($struct->encoding==3 or $struct->encoding==4) //base64 and qp decode. if($struct->encoding==3 or $struct->encoding==4) //base64 and qp decode.
......
#!/usr/bin/php -q
<?php
#
# Configuration: Enter the url and key. That is it.
# url => URL to api/task/cron e.g # http://yourdomain.com/support/api/tickets.json
# key => API's Key (see admin panel on how to generate a key)
#
$config = array(
'url'=>'http://domain.com/api/tickets.json',
'key'=>'<api key>'
);
# Fill in the data for the new ticket, this will likely come from $_POST.
$data = array(
'name' => 'John Doe',
'email' => 'mailbox@host.com',
'subject' => 'Test API message',
'message' => 'This is a test of the osTicket API',
'ip' => $_SERVER['REMOTE_ADDR'],
'attachments' => array(),
);
/*
* Add in attachments here if necessary
$data['attachments'][] =
array('filename.pdf' =>
'data:image/png;base64,' .
base64_encode(file_get_contents('/path/to/filename.pdf')));
*/
#pre-checks
function_exists('curl_version') or die('CURL support required');
function_exists('json_encode') or die('JSON support required');
#set timeout
set_time_limit(30);
#curl post
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $config['url']);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($data));
curl_setopt($ch, CURLOPT_USERAGENT, 'osTicket API Client v1.7');
curl_setopt($ch, CURLOPT_HEADER, FALSE);
curl_setopt($ch, CURLOPT_HTTPHEADER, array( 'Expect:', 'X-API-Key: '.$config['key']));
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, FALSE);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);
$result=curl_exec($ch);
$code = curl_getinfo($ch, CURLINFO_HTTP_CODE);
curl_close($ch);
if ($code != 201)
die('Unable to create ticket: '.$result);
$ticket_id = (int) $result;
# Continue onward here if necessary. $ticket_id has the ID number of the
# newly-created ticket
?>
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment