douyin8813 2015-08-30 06:35
浏览 53

joomla php变量在数值后面有一个随机的“。”字符

I have this website which is powered by Joomla!. The website have a custom component which I built to allow event registrations and the invoice number are coded to have auto increment capability.

An example of a invoice number would be like DOMAINNAME-00015-0000000055. Do note that "00015" is the event ID and "0000000055" is the increment. So after this invoice the next number would be DOMAINNAME-00015-0000000056 and so on.

So there is this event recently which is hosted and there are about 1500 registrations. However, I noticed that there are a few bookings which have their invoice number generated wrong. An example would be like DOMAINNAME-0015.-0000000057, so if you notice the event ID is "0015." instead of "00015". I checked the access log and noticed that when the event ID variable is passed from the view it is actually passing "15." instead of just "15".

The user will need to go to the event details page and click on this link to make a reservation of their booking. So I am suspecting that on the event details page the variable that contains the event ID that is added to the link is rendered as "15." instead of "15" in cases where the invoice number is generated wrongly.

But the question now is why? I have not seen cases where value are not consistent, there are about 6 cases out of the 1500 which have this issue. The event ID should be pulling from the database and it is a flat value of 15.

Any experienced guys know why is this happening?

[Edit]

Below is the code for the link where users will click to make their first initial reservation. The variable "cid" here is supposed to be "15" but from the access log of the web hosting server the users entered with a link which have the value of the variable "cid" set to "15." instead of "15" which results in the error of the invoice generation. The array "$post" is grabbed using the joomla! core function "JRequest::get();" which I think should not be the issue.

$apply_individual = 'index.php?option='.$post['option'].'&task=default&view=eventregistration&cid='.$post['cid'].'&type=individual';

This is the part where invoice number are generated.

function generateInvoiceID($event_id) {
    // Get a database object
    $db =& JFactory::getDBO();  
    $query = "SELECT * FROM #__db_name ORDER BY id";
    $db->setQuery($query);
    $results = $db->loadObjectList();

    $order_id = array();

    if(isset($results)) {
        foreach($results as $result) {
            if(!empty($result->invoice_id)) {
                $invoice_event_id = substr($result->invoice_id, 6, -11);
                $check_event_id = str_pad($event_id, 5, 0, STR_PAD_LEFT);
                $get_invoice_number = substr($result->invoice_id, -10);

                if($invoice_event_id == $check_event_id) {
                    //$order_id[] = $result->invoice_id;
                    $order_id[] = $get_invoice_number;
                }
            }
        }

        // get max id
        if(isset($order_id) && !empty($order_id)) {
            $max_id = max($order_id);
            //$max_id = substr($max_id, 12);
            $max_id++;
        } else {
            $max_id = 1;
        }

        $invoice_number = str_pad($max_id, 10, 0, STR_PAD_LEFT);
        $event_id = str_pad($event_id, 5, 0, STR_PAD_LEFT);
        $invoice_id = 'DOMAINNAME-'.$event_id.'-'.$invoice_number;
        $invoice_id = strtoupper($invoice_id);
    }

    return $invoice_id;
}

As you can see the event_id is converted to 5 digits using php function "str_pad". The increment number is working perfectly though. I also noticed that if I add a "." in the link which users will click I will generate a invoice number like "DOMAINNAME-0015.-0000000058". But I have no idea why a value for example "15." will be passed into the link in the first place. This issue does not affect all the invoice numbers but only a few like 5 out of 1500.

  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥15 网络设备配置与管理这个该怎么弄
    • ¥20 机器学习能否像多层线性模型一样处理嵌套数据
    • ¥20 西门子S7-Graph,S7-300,梯形图
    • ¥50 用易语言http 访问不了网页
    • ¥50 safari浏览器fetch提交数据后数据丢失问题
    • ¥15 matlab不知道怎么改,求解答!!
    • ¥15 永磁直线电机的电流环pi调不出来
    • ¥15 用stata实现聚类的代码
    • ¥15 请问paddlehub能支持移动端开发吗?在Android studio上该如何部署?
    • ¥20 docker里部署springboot项目,访问不到扬声器