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 SQL Server下载
    • ¥15 python如何将动态的多个子列表,拼接后进行集合的交集
    • ¥20 vitis-ai量化基于pytorch框架下的yolov5模型
    • ¥15 如何实现H5在QQ平台上的二次分享卡片效果?
    • ¥15 python爬取bilibili校园招聘网站
    • ¥30 求解达问题(有红包)
    • ¥15 请解包一个pak文件
    • ¥15 不同系统编译兼容问题
    • ¥100 三相直流充电模块对数字电源芯片在物理上它必须具备哪些功能和性能?
    • ¥30 数字电源对DSP芯片的具体要求