Projekt

Obecné

Profil

« Předchozí | Další » 

Revize 1771

Přidáno uživatelem Ondřej Fibich před téměř 12 roky(ů)

Vydani:

- freenetis 1.0.5

Opravy:

- fixes #409: Prevod letniho na zimni cas - DB problem s vytvorenim partitions
- fixes #410: PHP 5.3.9 - omezeni velikosti poli v post pozadavku

Zobrazit rozdíly:

freenetis/trunk/kohana/application/vendors/deb/freenetis/postinst
php_flag magic_quotes_runtime Off
php_flag file_uploads On
php_flag short_open_tag On
# large inputs (fixes #358)
# large inputs (fixes #358, #410)
php_value max_input_vars 100000
php_admin_value suhosin.post.max_vars 100000"
# make config for FN
freenetis/trunk/kohana/application/vendors/deb/freenetis/changelog
freenetis (1.0.4) stable; hight
* Fix release (#366, #367, #373, #374, #376, #377, #378, #380, #383, #384)
-- Ondrej Fibich <ondrej.fibich@gmail.com> Thu, 27 Sep 2012 21:24:48 +0200
freenetis (1.0.5) stable; hight
* Fix release (#254, #294, #396, #399, #402, #409, #410)
-- Ondrej Fibich <ondrej.fibich@gmail.com> Wed, 31 Oct 2012 00:35:25 +0100
freenetis/trunk/kohana/application/models/members_traffic.php
public function add_daily_partition()
{
$partition_name = date('Y_m_d', time());
$partition_date = date('Y-m-d', time() + 86400);
$partition_date = date('Y-m-d', strtotime('+1 day', time()));
$this->db->query("
ALTER TABLE members_traffics_daily
freenetis/trunk/kohana/application/models/log.php
<?php defined('SYSPATH') or die('No direct script access.');
/*
* This file is part of open source system FreenetIS
* and it is release under GPLv3 licence.
*
* More info about licence can be found:
* http://www.gnu.org/licenses/gpl-3.0.html
*
* More info about project can be found:
* http://www.freenetis.org/
*
*/
/**
* Model of logs.
* Table logs is handled as partitioned table, it needs at least MySQL ver. 5.1.
* Table partitions are created by scheduler.
* Logs are preserved for maximum of 30 days.
*
* @author Ondřej Fibich
* @package Model
*
* @property int $id
* @property int $user_id
* @property User_Model $user
* @property int $object_id
* @property string $table_name
* @property string $time
* @property string $values
*/
class Log_Model extends ORM
{
/** Logger action for adding record to the table */
const ACTION_ADD = 1;
/** Logger action for adding record to the table */
const ACTION_DELETE = 2;
/** Logger action for updating record to the table */
const ACTION_UPDATE = 3;
protected $belongs_to = array('user');
/**
* Contruct set logger
* @param int $id
*/
public function __construct($id = NULL)
{
parent::__construct($id);
// set action logger of
$this->set_logger(FALSE);
}
/**
* Creates table for logs
* @author Ondřej Fibich
*/
public static function create_table()
{
Database::instance()->query("
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);
");
}
/**
* Add new partition for logs
* @author Ondřej Fibich
* @see Scheduler_Controller::logs_partitions_daily()
*/
public function add_partition()
{
$partition_name = date('Y_m_d', time());
$partition_date = date('Y-m-d', time() + 86400);
$this->db->query("
ALTER TABLE logs
ADD PARTITION (
PARTITION p_$partition_name
VALUES LESS THAN (TO_DAYS('$partition_date')
) ENGINE = InnoDB)
");
}
/**
* Remove partitions for log which are more than 31 days old
*
* @author Ondřej Fibich
* @see Scheduler_Controller::logs_partitions_daily()
*/
public function remove_old_partitions()
{
// get all old partitions
$partitions = $this->db->query("
SELECT partition_name FROM
(
SELECT DISTINCT CONCAT('p_', DATE_FORMAT(time, '%Y_%m_%d')) AS partition_name
FROM logs l
WHERE DATE_SUB(NOW(), INTERVAL 31 DAY) > time
) p GROUP BY partition_name
");
foreach ($partitions as $partition)
{
$this->db->query("
ALTER TABLE logs
DROP PARTITION " . $partition->partition_name
);
}
}
/**
* Gets all users logs with limit
*
* @param int $offset
* @param int $limit
* @param int $user_id
* @return Mysql_Result
*/
public function get_all_users_logs($user_id, $offset, $limit)
{
return $this->db->query("
SELECT l.*
FROM logs l
WHERE user_id = ?
ORDER BY id DESC
LIMIT " .intval($offset). ", " .intval($limit). "
", $user_id);
}
/**
* Gets all objects logs with limit
*
* @param string $table_name
* @param int $object_id
* @param int $offset
* @param int $limit
* @return Mysql_Result
*/
public function get_all_object_logs($table_name, $object_id, $offset, $limit)
{
return $this->db->query("
SELECT l.*
FROM logs l
WHERE object_id = ? AND table_name = ?
ORDER BY id DESC
LIMIT " .intval($offset). ", " .intval($limit). "
", $object_id, $table_name);
}
/**
* Gets all logs with limit
*
* @param int $offset
* @param int $limit
* @param array $filter_sql Filter for where contition
* @return Mysql_Result
*/
public function get_all_logs($offset, $limit, $filter_sql = '')
{
// fill where contition
$where = !empty($filter_sql) ? 'WHERE ' . $filter_sql : '';
// query
return $this->db->query("
SELECT * FROM (
SELECT logs.*, u.name AS user_name, u.surname AS user_surname,
u.login AS user_login, m.name AS member_name
FROM logs
LEFT JOIN users u ON u.id = logs.user_id
LEFT JOIN members m ON m.id = u.member_id
) l $where
ORDER BY id DESC
LIMIT " .intval($offset). ", " .intval($limit). "
");
}
/**
* Gets number of logs
*
* @param array $filter_sql Filter for where contition
* @return int
*/
public function count_all_logs($filter_sql = array())
{
// fill where contition
$where = !empty($filter_sql) ? 'WHERE ' . $filter_sql : '';
return $this->db->query("
SELECT COUNT(*) AS count FROM (
SELECT logs.*, u.name AS user_name, u.surname AS user_surname,
u.login AS user_login, m.name AS member_name
FROM logs
LEFT JOIN users u ON u.id = logs.user_id
LEFT JOIN members m ON m.id = u.member_id
) l $where
")->current()->count;
}
/**
* Gets number of users logs
*
* @param int $user_id
* @return int
*/
public function count_all_users_logs($user_id)
{
return $this->db->query("
SELECT COUNT(*) AS count FROM logs WHERE user_id = ?
", $user_id)->current()->count;
}
/**
* Gets number of object logs
*
* @param string $table_name
* @param int $object_id
* @return int
*/
public function count_all_object_logs($table_name, $object_id)
{
return $this->db->query("
SELECT COUNT(*) AS count FROM logs WHERE table_name = ? AND object_id = ?
", $table_name, $object_id)->current()->count;
}
}
<?php defined('SYSPATH') or die('No direct script access.');
/*
* This file is part of open source system FreenetIS
* and it is release under GPLv3 licence.
*
* More info about licence can be found:
* http://www.gnu.org/licenses/gpl-3.0.html
*
* More info about project can be found:
* http://www.freenetis.org/
*
*/
/**
* Model of logs.
* Table logs is handled as partitioned table, it needs at least MySQL ver. 5.1.
* Table partitions are created by scheduler.
* Logs are preserved for maximum of 30 days.
*
* @author Ondřej Fibich
* @package Model
*
* @property int $id
* @property int $user_id
* @property User_Model $user
* @property int $object_id
* @property string $table_name
* @property string $time
* @property string $values
*/
class Log_Model extends ORM
{
/** Logger action for adding record to the table */
const ACTION_ADD = 1;
/** Logger action for adding record to the table */
const ACTION_DELETE = 2;
/** Logger action for updating record to the table */
const ACTION_UPDATE = 3;
protected $belongs_to = array('user');
/**
* Contruct set logger
* @param int $id
*/
public function __construct($id = NULL)
{
parent::__construct($id);
// set action logger of
$this->set_logger(FALSE);
}
/**
* Creates table for logs
* @author Ondřej Fibich
*/
public static function create_table()
{
Database::instance()->query("
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);
");
}
/**
* Add new partition for logs
* @author Ondřej Fibich
* @see Scheduler_Controller::logs_partitions_daily()
*/
public function add_partition()
{
$partition_name = date('Y_m_d', time());
$partition_date = date('Y-m-d', strtotime('+1 day', time()));
$this->db->query("
ALTER TABLE logs
ADD PARTITION (
PARTITION p_$partition_name
VALUES LESS THAN (TO_DAYS('$partition_date')
) ENGINE = InnoDB)
");
}
/**
* Remove partitions for log which are more than 31 days old
*
* @author Ondřej Fibich
* @see Scheduler_Controller::logs_partitions_daily()
*/
public function remove_old_partitions()
{
// get all old partitions
$partitions = $this->db->query("
SELECT partition_name FROM
(
SELECT DISTINCT CONCAT('p_', DATE_FORMAT(time, '%Y_%m_%d')) AS partition_name
FROM logs l
WHERE DATE_SUB(NOW(), INTERVAL 31 DAY) > time
) p GROUP BY partition_name
");
foreach ($partitions as $partition)
{
$this->db->query("
ALTER TABLE logs
DROP PARTITION " . $partition->partition_name
);
}
}
/**
* Gets all users logs with limit
*
* @param int $offset
* @param int $limit
* @param int $user_id
* @return Mysql_Result
*/
public function get_all_users_logs($user_id, $offset, $limit)
{
return $this->db->query("
SELECT l.*
FROM logs l
WHERE user_id = ?
ORDER BY id DESC
LIMIT " .intval($offset). ", " .intval($limit). "
", $user_id);
}
/**
* Gets all objects logs with limit
*
* @param string $table_name
* @param int $object_id
* @param int $offset
* @param int $limit
* @return Mysql_Result
*/
public function get_all_object_logs($table_name, $object_id, $offset, $limit)
{
return $this->db->query("
SELECT l.*
FROM logs l
WHERE object_id = ? AND table_name = ?
ORDER BY id DESC
LIMIT " .intval($offset). ", " .intval($limit). "
", $object_id, $table_name);
}
/**
* Gets all logs with limit
*
* @param int $offset
* @param int $limit
* @param array $filter_sql Filter for where contition
* @return Mysql_Result
*/
public function get_all_logs($offset, $limit, $filter_sql = '')
{
// fill where contition
$where = !empty($filter_sql) ? 'WHERE ' . $filter_sql : '';
// query
return $this->db->query("
SELECT * FROM (
SELECT logs.*, u.name AS user_name, u.surname AS user_surname,
u.login AS user_login, m.name AS member_name
FROM logs
LEFT JOIN users u ON u.id = logs.user_id
LEFT JOIN members m ON m.id = u.member_id
) l $where
ORDER BY id DESC
LIMIT " .intval($offset). ", " .intval($limit). "
");
}
/**
* Gets number of logs
*
* @param array $filter_sql Filter for where contition
* @return int
*/
public function count_all_logs($filter_sql = array())
{
// fill where contition
$where = !empty($filter_sql) ? 'WHERE ' . $filter_sql : '';
return $this->db->query("
SELECT COUNT(*) AS count FROM (
SELECT logs.*, u.name AS user_name, u.surname AS user_surname,
u.login AS user_login, m.name AS member_name
FROM logs
LEFT JOIN users u ON u.id = logs.user_id
LEFT JOIN members m ON m.id = u.member_id
) l $where
")->current()->count;
}
/**
* Gets number of users logs
*
* @param int $user_id
* @return int
*/
public function count_all_users_logs($user_id)
{
return $this->db->query("
SELECT COUNT(*) AS count FROM logs WHERE user_id = ?
", $user_id)->current()->count;
}
/**
* Gets number of object logs
*
* @param string $table_name
* @param int $object_id
* @return int
*/
public function count_all_object_logs($table_name, $object_id)
{
return $this->db->query("
SELECT COUNT(*) AS count FROM logs WHERE table_name = ? AND object_id = ?
", $table_name, $object_id)->current()->count;
}
}
freenetis/trunk/kohana/version.php
* The current version of FreenetIS.
* This value must be changed by developers in a new release of FreenetIS.
*/
define('FREENETIS_VERSION', '1.0.4');
define('FREENETIS_VERSION', '1.0.5');

Také k dispozici: Unified diff