Loading...
 
Skip to main content

Development


tiki-webmail.php line 420

posts: 21 ☆ ☆ ☆ United States

When visiting the webmail mailbox, I get two errors — the second of which is cascaded by the first:

Image
Copy to clipboard
Notice: Undefined index: Date in .../tiki-webmail.php on line 420 Notice: strtotime(): Called with empty time parameter in .../tiki-webmail.php on line 420

The refenced code is:

Image
Copy to clipboard
[LINE 420] $aux["timestamp"] = strtotime($aux['Date']);

I used the PHP function print_r() to inspect what the $aux array contains. The culprit turned out to be the absence of a 'Date' record. Instead, the message header as parsed from qmail apparently replaces that with a 'Received' array.

Image
Copy to clipboard
Array ( [Return-Path] => <ac...@ho...> [Delivered-To] => ac...@ho... [Received] => Array ( [0] => (qmail # invoked by uid #); 2 Jan 2006 23:56:00 -0000

My fix (yes, it works) is to check for the known header variants in order to extract the date value, as such:

Image
Copy to clipboard
if (array_key_exists('Date',$aux)) { $aux["timestamp"] = strtotime($aux['Date']); } elseif (array_key_exists('Received',$aux)) { list ($sz_to_dev_nul, $sz_to_Date) = explode(';',$aux['Received'][0],2); $aux["timestamp"] = strtotime($sz_to_Date); } else { $aux["timestamp"] = ''; }
posts: 21 ☆ ☆ ☆ United States

> When visiting the webmail mailbox, I get two errors — the second of which is cascaded by the first:

> Image
Copy to clipboard
> Notice: Undefined index: > Date in .../tiki-webmail.php on line 420 > Notice: strtotime(): > Called with empty time parameter in > .../tiki-webmail.php on line 420 >

> The refenced code is:

> Image
Copy to clipboard
> [LINE 420] $aux["timestamp"] = strtotime($aux['Date']); >

> I used the PHP function print_r() to inspect what the $aux array contains. The culprit turned out to be the absence of a 'Date' record. Instead, the message header as parsed from qmail apparently replaces that with a 'Received' array.

> Image
Copy to clipboard
> Array > ( > [Return-Path] => <ac...@ho...> > [Delivered-To] => ac...@ho... > [Received] => Array > ( > [0] => (qmail # invoked by uid #); 2 Jan 2006 23:56:00 -0000 >

> My fix (yes, it works) is to check for the known header variants in order to extract the date value, as such:

> Image
Copy to clipboard
> if (array_key_exists('Date',$aux)) > { $aux["timestamp"] = strtotime($aux['Date']); > } elseif (array_key_exists('Received',$aux)) > { list ($sz_to_dev_nul, $sz_to_Date) = explode(';',$aux['Received'][0],2); > $aux["timestamp"] = strtotime($sz_to_Date); > } else > { $aux["timestamp"] = ''; > } >


The Tiki webmail reply feature reports a similar complaint:

Image
Copy to clipboard
Notice: Undefined index: delivery-date in .../tiki-webmail.php on line 252 Notice: strtotime(): Called with empty time parameter in .../tiki-webmail.php on line 252

The refenced code is:

Image
Copy to clipboard
[LINE 251] } [LINE 252] $output['header']['timestamp'] = strtotime($output['header']['delivery-date']);

I again used the PHP function print_r(), this time to inspect what the output header array contains. The culprit turned out to be the absence of a 'delivery-date' record. Instead, the message header as parsed from qmail apparently replaces that with a 'received' array.

Image
Copy to clipboard
Array ( [header] => Array ( [return-path] => <ac...@ho...> [delivered-to] => ac...@ho... [received] => Array ( [0] => (qmail # invoked by uid #); 2 Jan 2006 23:56:00 -0000 [...] => [n] => from node.sourcehost.tld (HELO www.host.tld) (#.#.#.#) by smtp.host.tld with SMTP; 2 Jan 2006 23:59:00 -0000 )

My fix (yes, it works) is similar, but extracts the last 'received' line (n) into the date value, as such:

Image
Copy to clipboard
if (array_key_exists('delivery-date',$output['header'])) { $output['header']['timestamp'] = strtotime($output['header']['delivery-date']); } elseif (array_key_exists('received',$output['header'])) { $i_output_header_received = sizeof($output['header']['received']) - 1; list ($sz_to_dev_nul, $sz_to_delivery_date) = explode(';',$output['header']['received'][$i_output_header_received],2); $output['header']['timestamp'] = strtotime($sz_to_delivery_date); } else { $output['header']['timestamp'] = ''; }