由于时间问题导致自动导入的ShipStation问题?

时间:2013-10-08 00:44:57

标签: php date opencart

我是整个电子商务领域的新手,但我试图让它在OpenCart与ShipStation合作完成装运订单并处理它们的付款。但是我在ShipStation扩展模块的error_log中收到此错误。

更新: 应该发生的事情是当我在应用程序ShipStation上点击并从商店点击更新时,它会向此export.php脚本发送请求(这就是向我发送错误)。

2013-10-07 20:25:03 - PHP Notice:  Undefined offset: 1 in /home/begumbou/public_html/shipstation/controller/export.php on line 15
2013-10-07 20:25:03 - PHP Notice:  Undefined offset: 1 in /home/begumbou/public_html/shipstation/controller/export.php on line 15
2013-10-07 20:25:03 - PHP Notice:  Undefined offset: 2 in /home/begumbou/public_html/shipstation/controller/export.php on line 15
2013-10-07 20:25:03 - PHP Notice:  A non well formed numeric value encountered in /home/begumbou/public_html/shipstation/controller/export.php on line 15
2013-10-07 20:25:03 - PHP Notice:  A non well formed numeric value encountered in /home/begumbou/public_html/shipstation/controller/export.php on line 15
2013-10-07 20:25:03 - PHP Notice:  Undefined offset: 1 in /home/begumbou/public_html/shipstation/controller/export.php on line 22
2013-10-07 20:25:03 - PHP Notice:  Undefined offset: 1 in /home/begumbou/public_html/shipstation/controller/export.php on line 22
2013-10-07 20:25:03 - PHP Notice:  Undefined offset: 2 in /home/begumbou/public_html/shipstation/controller/export.php on line 22
2013-10-07 20:25:03 - PHP Notice:  A non well formed numeric value encountered in /home/begumbou/public_html/shipstation/controller/export.php on line 22
2013-10-07 20:25:03 - PHP Notice:  A non well formed numeric value encountered in /home/begumbou/public_html/shipstation/controller/export.php on line 22
2013-10-07 22:25:08 - PHP Notice:  Undefined offset: 1 in /home/begumbou/public_html/shipstation/controller/export.php on line 15
2013-10-07 22:25:08 - PHP Notice:  Undefined offset: 1 in /home/begumbou/public_html/shipstation/controller/export.php on line 15
2013-10-07 22:25:08 - PHP Notice:  Undefined offset: 2 in /home/begumbou/public_html/shipstation/controller/export.php on line 15
2013-10-07 22:25:08 - PHP Notice:  A non well formed numeric value encountered in /home/begumbou/public_html/shipstation/controller/export.php on line 15
2013-10-07 22:25:08 - PHP Notice:  A non well formed numeric value encountered in /home/begumbou/public_html/shipstation/controller/export.php on line 15
2013-10-07 22:25:08 - PHP Notice:  Undefined offset: 1 in /home/begumbou/public_html/shipstation/controller/export.php on line 22
2013-10-07 22:25:08 - PHP Notice:  Undefined offset: 1 in /home/begumbou/public_html/shipstation/controller/export.php on line 22
2013-10-07 22:25:08 - PHP Notice:  Undefined offset: 2 in /home/begumbou/public_html/shipstation/controller/export.php on line 22
2013-10-07 22:25:08 - PHP Notice:  A non well formed numeric value encountered in /home/begumbou/public_html/shipstation/controller/export.php on line 22
2013-10-07 22:25:08 - PHP Notice:  A non well formed numeric value encountered in /home/begumbou/public_html/shipstation/controller/export.php on line 22
2013-10-08 0:21:11 - PHP Notice:  Undefined offset: 1 in /home/begumbou/public_html/shipstation/controller/export.php on line 15
2013-10-08 0:21:11 - PHP Notice:  Undefined offset: 1 in /home/begumbou/public_html/shipstation/controller/export.php on line 15
2013-10-08 0:21:11 - PHP Notice:  Undefined offset: 2 in /home/begumbou/public_html/shipstation/controller/export.php on line 15
2013-10-08 0:21:11 - PHP Notice:  A non well formed numeric value encountered in /home/begumbou/public_html/shipstation/controller/export.php on line 15
2013-10-08 0:21:11 - PHP Notice:  A non well formed numeric value encountered in /home/begumbou/public_html/shipstation/controller/export.php on line 15
2013-10-08 0:21:11 - PHP Notice:  Undefined offset: 1 in /home/begumbou/public_html/shipstation/controller/export.php on line 22
2013-10-08 0:21:11 - PHP Notice:  Undefined offset: 1 in /home/begumbou/public_html/shipstation/controller/export.php on line 22
2013-10-08 0:21:11 - PHP Notice:  Undefined offset: 2 in /home/begumbou/public_html/shipstation/controller/export.php on line 22
2013-10-08 0:21:11 - PHP Notice:  A non well formed numeric value encountered in /home/begumbou/public_html/shipstation/controller/export.php on line 22
2013-10-08 0:21:11 - PHP Notice:  A non well formed numeric value encountered in /home/begumbou/public_html/shipstation/controller/export.php on line 22

第15行陈述

$data['startdate'] = date('Y-m-d H:i:s', mktime($starttime[0], $starttime[1], 0, $startdate[0], $startdate[1], $startdate[2]));

和第22行说明

$data['enddate'] = date('Y-m-d H:i:s', mktime($endtime[0], $endtime[1], 0, $enddate[0], $enddate[1], $enddate[2]));

将所有代码放在一起

    if (isset($this->request->get['start_date'])) {
        $start_date_time = explode(' ', $this->request->get['start_date']);
        $startdate = explode('/', $start_date_time[0]);
        $starttime = explode(':', $start_date_time[1]);
        $data['startdate'] = date('Y-m-d H:i:s', mktime($starttime[0], $starttime[1], 0, $startdate[0], $startdate[1], $startdate[2]));
    }

    if (isset($this->request->get['end_date'])) {
        $end_date_time = explode(' ', $this->request->get['end_date']);
        $enddate = explode('/', $end_date_time[0]);
        $endtime = explode(':', $end_date_time[1]);
        $data['enddate'] = date('Y-m-d H:i:s', mktime($endtime[0], $endtime[1], 0, $enddate[0], $enddate[1], $enddate[2]));

更新ERROR_LOG

[08-Oct-2013 17:33:39 UTC] Array
(
    [0] => 01%3a08
)

[08-Oct-2013 17:33:39 UTC] Array
(
    [0] => 17%3a33
)

这是在raw_error_logs上,它匹配上面给出的数组。

162.209.46.39 - - [08/Oct/2013:13:33:39 -0400] "GET /shipstation/index.php?action=export&start_date=10%2f08%2f2013+01%3a08&end_date=10%2f08%2f2013+17%3a33&page=1&SS-UserName=R4ND0ML3TT3RSANDNUB3RS1T00K0UT&SS-Password=R4ND0ML3TT3RSANDNUB3RS1T00K0UT HTTP/1.1" 302 448 "-" "ShipStation"

1 个答案:

答案 0 :(得分:1)

通过GET链接,您已发出GET /shipstation/index.php?action=export&start_date=10%2f08%2f2013+01%3a08&...,通知不应发生。

start_dateend_date的格式与您预期的格式不同时,会发出通知。

替换您的代码:

if (isset($this->request->get['start_date'])) { ... }
if (isset($this->request->get['end_date'])) { ... }

使用:

foreach (array('start_date', 'end_date') as $field) {
    if (!isset($this->request->get[$field])) continue;
    $date = $this->request->get[$field];
    try {
        $dt = new DateTime($date);
        $data[str_replace('_', '', $field)] = $dt->format('Y-m-d H:i:s');
    } catch (Exception $e) {
        exit("ERROR: Field '{$field}' has invalid datetime format = '{$date}' ({$e->getMessage()})");
    }
}

并查看是否发生错误。