Post by harap » Sat Feb 18, 2017 12:23 pm

hello Sirs,

I'm using OC v2.2. have an issue. Customer successfully paid by Paypal Express then got stuck on a page that shown warning messages (see attached). Until refresh the page then return back to my store site. Actually the order and payment transaction are correctly completed.

How to avoid this warning page?

Please help. Thanks in advance!

Attachments

error_PP_express.png

error_PP_express.png (75.77 KiB) Viewed 1890 times

Last edited by harap on Sun Feb 19, 2017 4:46 am, edited 2 times in total.

Active Member

Posts

Joined
Wed Sep 16, 2015 12:34 am
Location - United States

Post by rgbworld » Sun Feb 19, 2017 1:53 am

I would look at the file mentioned in the warnings (vq2-system_library_mail.php). What code is at line 113?

I would compare the file: system/library/mail.php with the file vq2-system_library_mail.php and note the differences. It appears you have a vqmod that is modifying "mail.php". The warning states that there is an "illegal string offset" of "file" or "filename". A string offset should be a number, not a word. That's why it is an "illegal" offset.

I would be looking for calls to php methods such as 'substr'. These methods require an 'offset' into the string, and "file" or "filename" are not valid offsets.

Finally, once resolved, I would disable displaying of error messages if this is a live site. That alone might prevent the "warnings", but first try to resolve the "illegal offset" issue.

RGB World - FREE and Commercial Extensions
For custom work or support, please use our Contact Form or visit our Support Forum.

Favorite Quote: There are 10 types of people in the world. Those who understand binary and those who don't. 8)


User avatar
New member

Posts

Joined
Wed Aug 08, 2012 6:11 am

Post by harap » Sun Feb 19, 2017 4:25 am

Thanks for helping.

The code for line #113 is:
$mail->AddAttachment($attachment['file'],$attachment['filename']);
Last edited by harap on Mon Feb 20, 2017 12:40 am, edited 1 time in total.

Active Member

Posts

Joined
Wed Sep 16, 2015 12:34 am
Location - United States

Post by rgbworld » Sun Feb 19, 2017 5:12 am

Unfortunately, I am running OpenCart 2.3.0.2, so I am unable to review with more detail. As mentioned in my initial reply, you are going to have to compare the original file with the vqcache file and determine why the variable (most likely passed to substr) contains text rather than an offset (number).

Also, as best as I can tell, you have a vqmod that is modifying mail.php. I suggest you locate the .xml file that is modifying /system/library/mail.php and contact the developer of that mod.

Appologies for not being able to resolve the issue.

RGB World - FREE and Commercial Extensions
For custom work or support, please use our Contact Form or visit our Support Forum.

Favorite Quote: There are 10 types of people in the world. Those who understand binary and those who don't. 8)


User avatar
New member

Posts

Joined
Wed Aug 08, 2012 6:11 am

Post by harap » Sun Feb 19, 2017 8:08 am

Sorry, Just counted the line#113 is:
$mail->AddAttachment($attachment['file'],$attachment['filename']);

Active Member

Posts

Joined
Wed Sep 16, 2015 12:34 am
Location - United States

Post by harap » Mon Feb 20, 2017 1:29 am

Compared mail.php with vq2-system_library_mail.php, they are different on heading and ending code.

mail.php
-----------------------------
<?php
class Mail {
protected $to;
(all same)
ending with }
-------------------------------


vq2-system_library_mail.php
----------------------------------
<?php
include_once(\VQMod::modCheck(DIR_SYSTEM."library/phpmailer/PHPMailerAutoload.php"));
final class Mail {
protected $to;
protected $from;
protected $sender;
protected $reply_to; /* add */
protected $subject;
protected $text;
protected $html;
protected $attachments = array();
public $protocol = 'mail';
public $smtp_hostname;
public $smtp_username;
public $smtp_password;
public $smtp_port = 25;
public $smtp_timeout = 5;
public $verp = FALSE;
public $parameter = '';

public function __construct($config = array()) {
foreach ($config as $key => $value) {
$this->$key = $value;
}
}

public function setTo($to) {
$this->to = $to;
}

public function setFrom($from) {
$this->from = $from;
}

public function setSender($sender) {
$this->sender = $sender;
}

public function setReplyTo($reply_to) {
$this->reply_to = $reply_to;
}

public function setSubject($subject) {
$this->subject = $subject;
}

public function setText($text) {
$text = nl2br($text);
$this->text = $text;
}

public function setHtml($html) {
$this->html = $html;
}

public function addAttachment($filename) {
$this->attachments[] = $filename;
}

public function send() {
if (!$this->to) {
throw new \Exception('Error: E-Mail to required!');
}

if (!$this->from) {
throw new \Exception('Error: E-Mail from required!');
}

if (!$this->sender) {
throw new \Exception('Error: E-Mail sender required!');
}

if (!$this->subject) {
throw new \Exception('Error: E-Mail subject required!');
}

if ((!$this->text) && (!$this->html)) {
throw new \Exception('Error: E-Mail message required!');
}

if (is_array($this->to)) {
$to = implode(',', $this->to);
} else {
$to = $this->to;
}

if ($this->protocol == 'smtp'&&$this->smtp_hostname&&$this->smtp_username) {
if (!$this->html) {
$message =$this->text;
} else {
$message = $this->html;
}

$mail = new PHPMailer();
$mail->IsSMTP();

$mail->CharSet = "utf-8";
$mail->Host = $this->smtp_hostname;
$mail->Port = $this->smtp_port;
$mail->SMTPAuth = true;
$mail->Username = $this->smtp_username;
$mail->Password = $this->smtp_password;

$mail->setFrom($this->from,$this->sender);
$mail->AddReplyTo($this->from,$this->sender);
$mail->Sender = $this->smtp_username;
$mail->From = $this->from;
$mail->FromName = $this->sender;
$mail->Subject = $this->subject;
$mail->MsgHTML($message);

foreach ($this->attachments as $attachment) {
$mail->AddAttachment($attachment['file'],$attachment['filename']);
}

$to = explode(',',$to);
foreach($to as $t){
$mail->AddAddress($t);
}


$mail->Send();
}else{

$boundary = '----=_NextPart_' . md5(time());

$header = 'MIME-Version: 1.0' . PHP_EOL;

if ($this->protocol != 'mail') {
$header .= 'To: <' . $to . '>' . PHP_EOL;
$header .= 'Subject: =?UTF-8?B?' . base64_encode($this->subject) . '?=' . PHP_EOL;
}

$header .= 'Date: ' . date('D, d M Y H:i:s O') . PHP_EOL;
$header .= 'From: =?UTF-8?B?' . base64_encode($this->sender) . '?= <' . $this->from . '>' . PHP_EOL;

if (!$this->reply_to) {
$header .= 'Reply-To: =?UTF-8?B?' . base64_encode($this->sender) . '?= <' . $this->from . '>' . PHP_EOL;
} else {
$header .= 'Reply-To: =?UTF-8?B?' . base64_encode($this->reply_to) . '?= <' . $this->reply_to . '>' . PHP_EOL;
}

$header .= 'Return-Path: ' . $this->from . PHP_EOL;
$header .= 'X-Mailer: PHP/' . phpversion() . PHP_EOL;
$header .= 'Content-Type: multipart/related; boundary="' . $boundary . '"' . PHP_EOL . PHP_EOL;

if (!$this->html) {
$message = '--' . $boundary . PHP_EOL;
$message .= 'Content-Type: text/plain; charset="utf-8"' . PHP_EOL;
$message .= 'Content-Transfer-Encoding: 8bit' . PHP_EOL . PHP_EOL;
$message .= $this->text . PHP_EOL;
} else {
$message = '--' . $boundary . PHP_EOL;
$message .= 'Content-Type: multipart/alternative; boundary="' . $boundary . '_alt"' . PHP_EOL . PHP_EOL;
$message .= '--' . $boundary . '_alt' . PHP_EOL;
$message .= 'Content-Type: text/plain; charset="utf-8"' . PHP_EOL;
$message .= 'Content-Transfer-Encoding: 8bit' . PHP_EOL . PHP_EOL;

if ($this->text) {
$message .= $this->text . PHP_EOL;
} else {
$message .= 'This is a HTML email and your email client software does not support HTML email!' . PHP_EOL;
}

$message .= '--' . $boundary . '_alt' . PHP_EOL;
$message .= 'Content-Type: text/html; charset="utf-8"' . PHP_EOL;
$message .= 'Content-Transfer-Encoding: 8bit' . PHP_EOL . PHP_EOL;
$message .= $this->html . PHP_EOL;
$message .= '--' . $boundary . '_alt--' . PHP_EOL;
}

foreach ($this->attachments as $attachment) {
if (file_exists($attachment)) {
$handle = fopen($attachment, 'r');

$content = fread($handle, filesize($attachment));

fclose($handle);

$message .= '--' . $boundary . PHP_EOL;
$message .= 'Content-Type: application/octet-stream; name="' . basename($attachment) . '"' . PHP_EOL;
$message .= 'Content-Transfer-Encoding: base64' . PHP_EOL;
$message .= 'Content-Disposition: attachment; filename="' . basename($attachment) . '"' . PHP_EOL;
$message .= 'Content-ID: <' . basename(urlencode($attachment)) . '>' . PHP_EOL;
$message .= 'X-Attachment-Id: ' . basename(urlencode($attachment)) . PHP_EOL . PHP_EOL;
$message .= chunk_split(base64_encode($content));
}
}

$message .= '--' . $boundary . '--' . PHP_EOL;

ini_set('sendmail_from', $this->from);

if ($this->parameter) {
mail($to, '=?UTF-8?B?' . base64_encode($this->subject) . '?=', $message, $header, $this->parameter);
} else {
mail($to, '=?UTF-8?B?' . base64_encode($this->subject) . '?=', $message, $header);
}

}
}
}

/*

class Mail {
protected $to;
(all same)

ending with */
----------------------------------------------------

Active Member

Posts

Joined
Wed Sep 16, 2015 12:34 am
Location - United States

Post by rgbworld » Mon Feb 20, 2017 2:09 am

Here's a stab in the dark...

This method seems to be adding $filename to a 1-dimensional array:

Code: Select all

public function addAttachment($filename) {
$this->attachments[] = $filename;
}
So, possibly changing:

Code: Select all

foreach ($this->attachments as $attachment) {
$mail->AddAttachment($attachment['file'],$attachment['filename']);
}
to:

Code: Select all

foreach ($this->attachments as $attachment) {
$mail->AddAttachment($attachment);
}
Again, I am only guessing. :)

RGB World - FREE and Commercial Extensions
For custom work or support, please use our Contact Form or visit our Support Forum.

Favorite Quote: There are 10 types of people in the world. Those who understand binary and those who don't. 8)


User avatar
New member

Posts

Joined
Wed Aug 08, 2012 6:11 am

Post by harap » Mon Feb 20, 2017 4:08 am

Hello rgbworld,

You are the best. It works like a charm. No more Warning page appeared, and smoothly directed to my site after paying by Paypal express.

Thank you again Sir. :)

Active Member

Posts

Joined
Wed Sep 16, 2015 12:34 am
Location - United States
Who is online

Users browsing this forum: No registered users and 30 guests