Projekt

Obecné

Profil

« Předchozí | Další » 

Revize 882

Přidáno uživatelem Michal Kliment před více než 13 roky(ů)

Oprava callback funkce pro vypis poradoveho cisla. Pridany SQL procedury pro logovani na strane centralniho routeru.

Zobrazit rozdíly:

freenetis/branches/ulogd/application/helpers/callback.php
*/
class callback_Core
{
private static $order_number;
/**
* Callback for balance field in accounts.
* @author Jiri Svitak
......
break;
}
echo self::$order_number.'.';
echo $order_number.'.';
}
/**
freenetis/branches/ulogd/application/upgrade_sql/upgrade_sql.php
// array of sql queries that upgrade database
$upgrade_sql[get_SVN_rev()] = array(
// drop old log table
"DROP TABLE `logs`;",
"DELIMITER $$
// create new table which have got partitions and NO indexes
"CREATE TABLE IF NOT EXISTS `logs` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`table_name` varchar(255) COLLATE utf8_czech_ci NOT NULL,
`values` text COLLATE utf8_czech_ci,
`time` datetime NOT NULL,
`action` tinyint(2) NOT NULL DEFAULT '1',
`object_id` int(11) NOT NULL,
`user_id` int(11) NOT NULL,
KEY `id` (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_czech_ci
PARTITION BY RANGE (TO_DAYS(`time`))
(PARTITION p_first VALUES LESS THAN (TO_DAYS('1970-01-01')) ENGINE = InnoDB);"
CREATE FUNCTION `INSERT_CT`(
`_orig_ip_saddr` int unsigned,
`_orig_ip_daddr` int unsigned,
`_orig_ip_protocol` tinyint(3) unsigned,
`_orig_l4_sport` int(5),
`_orig_l4_dport` int(5),
`_orig_raw_pktlen` bigint,
`_orig_raw_pktcount` bigint,
`_reply_ip_daddr` int unsigned,
`_reply_l4_dport` int(5),
`_reply_raw_pktlen` bigint,
`_reply_raw_pktcount` bigint,
`_icmp_code` tinyint(3),
`_icmp_type` tinyint(3),
`_flow_start_sec` int(10),
`_flow_end_sec` int(10)
) RETURNS bigint(20) unsigned
READS SQL DATA
BEGIN
INSERT INTO ulog2_ct
(orig_ip_saddr, orig_ip_daddr, orig_ip_protocol,
orig_l4_sport, orig_l4_dport, orig_raw_pktlen, orig_raw_pktcount,
reply_ip_daddr,
reply_l4_dport, reply_raw_pktlen, reply_raw_pktcount,
icmp_code, icmp_type,
flow_start_sec,
flow_end_sec
)
VALUES (_orig_ip_saddr, _orig_ip_daddr, _orig_ip_protocol,
_orig_l4_sport, _orig_l4_dport, _orig_raw_pktlen, _orig_raw_pktcount,
_reply_ip_daddr,
_reply_l4_dport, _reply_raw_pktlen, _reply_raw_pktcount,
_icmp_code, _icmp_type,
_flow_start_sec,
_flow_end_sec
);
RETURN LAST_INSERT_ID();
END$$
CREATE FUNCTION `insert_rand`() RETURNS bigint(20) unsigned
READS SQL DATA
BEGIN
SET @tnow=now();
INSERT INTO ulog2_ct
(orig_ip_daddr,
orig_l4_dport,
reply_l4_dport,
flow_start_sec,
flow_end_sec
)
VALUES (
rand()*4294967295,
rand()*80,
rand()*65535,
unix_timestamp(@tnow - interval (rand()*60) second),
unix_timestamp(@tnow)
);
RETURN LAST_INSERT_ID();
END$$
CREATE FUNCTION `ip2str`(ip INT UNSIGNED) RETURNS varchar(15) CHARSET latin1
DETERMINISTIC
RETURN concat(ip & 255, ".", ip>>8 & 255, ".", ip>>16 & 255, ".", ip>>24)$$
CREATE FUNCTION `swap_endian`(ip INT UNSIGNED) RETURNS int(10) unsigned
DETERMINISTIC
RETURN ((ip & 255)<<24 | (ip & 65280)<<8 | (ip>>8 & 65280) | ip>>24)$$
DELIMITER ;"
);
?>
freenetis/branches/ulogd/application/upgrade_sql/upgrade_sql_875.php
<?php
// array of sql queries that upgrade database
$upgrade_sql[875] = array(
// drop old log table
"DROP TABLE `logs`;",
// create new table which have got partitions and NO indexes
"CREATE TABLE IF NOT EXISTS `logs` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`table_name` varchar(255) COLLATE utf8_czech_ci NOT NULL,
`values` text COLLATE utf8_czech_ci,
`time` datetime NOT NULL,
`action` tinyint(2) NOT NULL DEFAULT '1',
`object_id` int(11) NOT NULL,
`user_id` int(11) NOT NULL,
KEY `id` (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_czech_ci
PARTITION BY RANGE (TO_DAYS(`time`))
(PARTITION p_first VALUES LESS THAN (TO_DAYS('1970-01-01')) ENGINE = InnoDB);"
);
?>

Také k dispozici: Unified diff