Revize 1345
Přidáno uživatelem Michal Kliment před více než 12 roky(ů)
freenetis/branches/testing/application/models/ulog2_ct.php | ||
---|---|---|
SET ip_address = ip2str(_orig_ip_saddr);
|
||
SET upload = _orig_raw_pktlen/1024;
|
||
SET download = _reply_raw_pktlen/1024;
|
||
SET local_upload = is_local * upload;
|
||
SET local_download = is_local * download;
|
||
|
||
SELECT IF(COUNT(*) > 0, 1, 0) INTO is_local
|
||
FROM local_subnets ls
|
||
WHERE INET_ATON(ip_address) & INET_ATON(netmask) = INET_ATON(network_address);
|
||
|
||
SET local_upload = is_local * upload;
|
||
SET local_download = is_local * download;
|
||
|
||
SELECT IFNULL(u.member_id, ip.member_id) INTO member_id
|
||
FROM
|
||
... | ... | |
WHERE ip_address = ip_address
|
||
) ip
|
||
LEFT JOIN devices d ON ip.device_id = d.id
|
||
LEFT JOIN users u ON d.user_id = u.id;
|
||
LEFT JOIN users u ON d.user_id = u.id
|
||
LIMIT 0,1;
|
||
|
||
INSERT INTO ip_addresses_traffics (ip_address, download, upload, local_download, local_upload, member_id)
|
||
VALUE(ip_address, download, upload, local_download, local_upload, member_id)
|
||
... | ... | |
ON DUPLICATE KEY
|
||
UPDATE download = download + download, upload = upload + upload, local_download = local_download + local_download, local_upload = local_upload + local_upload;
|
||
|
||
RETURN LAST_INSERT_ID();
|
||
RETURN 1;
|
||
END
|
||
");
|
||
$db->query("DROP FUNCTION IF EXISTS `insert_rand`");
|
Také k dispozici: Unified diff
Oprava spatne MySQL funkce pro zpracovani provozu.