Applied fixes from StyleCI
This commit is contained in:

committed by
StyleCI Bot

parent
b158c8e1ee
commit
a6a7c762dc
@@ -27,15 +27,16 @@ use PhpImap\Mailbox as ImapMailbox;
|
||||
*
|
||||
* @author Ladybird <info@ladybirdweb.com>
|
||||
*/
|
||||
class MailController extends Controller {
|
||||
|
||||
class MailController extends Controller
|
||||
{
|
||||
/**
|
||||
* constructor
|
||||
* Create a new controller instance.
|
||||
*
|
||||
* @param type TicketController $TicketController
|
||||
*/
|
||||
public function __construct(TicketWorkflowController $TicketWorkflowController) {
|
||||
public function __construct(TicketWorkflowController $TicketWorkflowController)
|
||||
{
|
||||
$this->middleware('board');
|
||||
$this->TicketWorkflowController = $TicketWorkflowController;
|
||||
}
|
||||
@@ -45,7 +46,8 @@ class MailController extends Controller {
|
||||
*
|
||||
* @return type
|
||||
*/
|
||||
public function readmails(Emails $emails, Email $settings_email, System $system, Ticket $ticket) {
|
||||
public function readmails(Emails $emails, Email $settings_email, System $system, Ticket $ticket)
|
||||
{
|
||||
// $path_url = $system->first()->url;
|
||||
if ($settings_email->first()->email_fetching == 1) {
|
||||
if ($settings_email->first()->all_emails == 1) {
|
||||
@@ -80,7 +82,7 @@ class MailController extends Controller {
|
||||
$protocol = $fetching_encryption2;
|
||||
} else {
|
||||
if ($e_mail->fetching_protocol) {
|
||||
$fetching_protocol = '/' . $e_mail->fetching_protocol;
|
||||
$fetching_protocol = '/'.$e_mail->fetching_protocol;
|
||||
} else {
|
||||
$fetching_protocol = '';
|
||||
}
|
||||
@@ -89,13 +91,13 @@ class MailController extends Controller {
|
||||
} else {
|
||||
$fetching_encryption = '';
|
||||
}
|
||||
$protocol = $fetching_protocol . $fetching_encryption;
|
||||
$protocol = $fetching_protocol.$fetching_encryption;
|
||||
}
|
||||
$imap_config = '{' . $host . ':' . $port . $protocol . '}INBOX';
|
||||
$imap_config = '{'.$host.':'.$port.$protocol.'}INBOX';
|
||||
$password = Crypt::decrypt($e_mail->password);
|
||||
$mailbox = new ImapMailbox($imap_config, $e_mail->email_address, $password, __DIR__);
|
||||
$mails = [];
|
||||
$mailsIds = $mailbox->searchMailBox('SINCE ' . date('d-M-Y', strtotime('-1 day')));
|
||||
$mailsIds = $mailbox->searchMailBox('SINCE '.date('d-M-Y', strtotime('-1 day')));
|
||||
if (!$mailsIds) {
|
||||
die('Mailbox is empty');
|
||||
}
|
||||
@@ -135,7 +137,7 @@ class MailController extends Controller {
|
||||
$date = $mail->date;
|
||||
$datetime = $overview[0]->date;
|
||||
$date_time = explode(' ', $datetime);
|
||||
$date = $date_time[1] . '-' . $date_time[2] . '-' . $date_time[3] . ' ' . $date_time[4];
|
||||
$date = $date_time[1].'-'.$date_time[2].'-'.$date_time[3].' '.$date_time[4];
|
||||
$date = date('Y-m-d H:i:s', strtotime($date));
|
||||
if (isset($mail->subject)) {
|
||||
$subject = $mail->subject;
|
||||
@@ -170,7 +172,7 @@ class MailController extends Controller {
|
||||
// var_dump($attachment->filePath);
|
||||
// dd($filepath);
|
||||
// $path = $dir_img_path[0]."/code/public/".$filepath[1];
|
||||
$path = public_path() . $filepath[1];
|
||||
$path = public_path().$filepath[1];
|
||||
// dd($path);
|
||||
$filesize = filesize($path);
|
||||
$file_data = file_get_contents($path);
|
||||
@@ -179,7 +181,7 @@ class MailController extends Controller {
|
||||
$string = str_replace('-', '', $attachment->name);
|
||||
$filename = explode('src', $attachment->filePath);
|
||||
$filename = str_replace('\\', '', $filename);
|
||||
$body = str_replace('cid:' . $imageid, $filepath[1], $body);
|
||||
$body = str_replace('cid:'.$imageid, $filepath[1], $body);
|
||||
$pos = strpos($body, $filepath[1]);
|
||||
if ($pos == false) {
|
||||
if ($settings_email->first()->attachment == 1) {
|
||||
@@ -224,7 +226,8 @@ class MailController extends Controller {
|
||||
*
|
||||
* @return type string
|
||||
*/
|
||||
public function separate_reply($body) {
|
||||
public function separate_reply($body)
|
||||
{
|
||||
$body2 = explode('---Reply above this line---', $body);
|
||||
$body3 = $body2[0];
|
||||
|
||||
@@ -238,7 +241,8 @@ class MailController extends Controller {
|
||||
*
|
||||
* @return type string
|
||||
*/
|
||||
public function decode_imap_text($str) {
|
||||
public function decode_imap_text($str)
|
||||
{
|
||||
$result = '';
|
||||
$decode_header = imap_mime_header_decode($str);
|
||||
foreach ($decode_header as $obj) {
|
||||
@@ -253,7 +257,8 @@ class MailController extends Controller {
|
||||
*
|
||||
* @return type
|
||||
*/
|
||||
public function fetch_attachments() {
|
||||
public function fetch_attachments()
|
||||
{
|
||||
$uploads = Upload::all();
|
||||
foreach ($uploads as $attachment) {
|
||||
$image = @imagecreatefromstring($attachment->file);
|
||||
@@ -261,8 +266,8 @@ class MailController extends Controller {
|
||||
imagejpeg($image, null, 80);
|
||||
$data = ob_get_contents();
|
||||
ob_end_clean();
|
||||
$var = '<a href="" target="_blank"><img src="data:image/jpg;base64,' . base64_encode($data) . '"/></a>';
|
||||
echo '<br/><span class="mailbox-attachment-icon has-img">' . $var . '</span>';
|
||||
$var = '<a href="" target="_blank"><img src="data:image/jpg;base64,'.base64_encode($data).'"/></a>';
|
||||
echo '<br/><span class="mailbox-attachment-icon has-img">'.$var.'</span>';
|
||||
}
|
||||
}
|
||||
|
||||
@@ -273,17 +278,19 @@ class MailController extends Controller {
|
||||
*
|
||||
* @return type file
|
||||
*/
|
||||
public function get_data($id) {
|
||||
public function get_data($id)
|
||||
{
|
||||
$attachments = App\Model\helpdesk\Ticket\Ticket_attachments::where('id', '=', $id)->get();
|
||||
foreach ($attachments as $attachment) {
|
||||
header('Content-type: application/' . $attachment->type . '');
|
||||
header('Content-Disposition: inline; filename=' . $attachment->name . '');
|
||||
header('Content-type: application/'.$attachment->type.'');
|
||||
header('Content-Disposition: inline; filename='.$attachment->name.'');
|
||||
header('Content-Transfer-Encoding: binary');
|
||||
echo $attachment->file;
|
||||
}
|
||||
}
|
||||
|
||||
public static function trimTableTag($html) {
|
||||
public static function trimTableTag($html)
|
||||
{
|
||||
if (strpos('<table>', $html) != false) {
|
||||
$first_pos = strpos($html, '<table');
|
||||
$fist_string = substr_replace($html, '', 0, $first_pos);
|
||||
@@ -292,23 +299,28 @@ class MailController extends Controller {
|
||||
$diff = $total - $last_pos;
|
||||
$str = substr_replace($fist_string, '', $last_pos, -1);
|
||||
$final_str = str_finish($str, '</table>');
|
||||
|
||||
return $final_str;
|
||||
}
|
||||
|
||||
return $html;
|
||||
}
|
||||
|
||||
public static function trim3D($html) {
|
||||
public static function trim3D($html)
|
||||
{
|
||||
$body = str_replace('=3D', '', $html);
|
||||
|
||||
return $body;
|
||||
}
|
||||
|
||||
public static function trimInjections($html, $tags = ['<script>', '</script>', '<style>', '</style>', '<?php', '?>']) {
|
||||
public static function trimInjections($html, $tags = ['<script>', '</script>', '<style>', '</style>', '<?php', '?>'])
|
||||
{
|
||||
$replace = [];
|
||||
foreach ($tags as $key => $tag) {
|
||||
$replace[$key] = htmlspecialchars($tag);
|
||||
}
|
||||
$body = str_replace($tags, $replace, $html);
|
||||
|
||||
return $body;
|
||||
}
|
||||
|
||||
}
|
||||
|
Reference in New Issue
Block a user