759
759
throw new ADEIException(translate("Unlucky, the MD5 checksums of two groups (\"%s\" and \"%s\") are coinciding. This is not handled automaticaly yet. Please, add/alter md5 suffix to the newly added group.", $row[0], $postfix));
762
function CacheLogCreateTable() {
763
if (!@mysql_query("CREATE TABLE IF NOT EXISTS `cachelog`(
764
`id` INT NOT NULL AUTO_INCREMENT,
766
`postfix` VARCHAR(4096) NOT NULL,
773
throw new ADEIException(translate("Creation of system tables (cachelog) within CACHE database is failed") . " (" . mysql_error($this->dbh) . ")");
777
function CacheLogAdd($action, $postfix, $resolution) {
778
if (!$postfix) $postfix = $this->default_postfix;
779
$time = $this->SQLTime(time());
781
$query = "INSERT INTO `cachelog` VALUES(NULL, '{$time}', '" . mysql_real_escape_string($postfix) . "', $resolution, '$action', 0)";
782
if (!@mysql_query($query, $this->dbh)) {
783
switch (mysql_errno($this->dbh)) {
784
case CACHE::MYSQL_ER_NO_SUCH_TABLE:
785
$this->CacheLogCreateTable();
786
if (@mysql_query($query, $this->dbh))
789
throw new ADEIException(translate("Error logging info on %s:%s to CacheLog, error", $postfix, $resolution) . ": " . mysql_error($this->dbh));
795
function CacheLogGet($filters = false) {
800
if (isset($filters['archive'])) {
801
$archive = $filters['archive'];
802
unset($filters['archive']);
805
if (isset($filters['interval'])) {
806
$from = $this->SQLTime($filters['interval'][0]);
807
$to = $this->SQLTime($filters['interval'][1]);
808
$where .= " `time` BETWEEN $from AND $to";
809
unset($filters['interval']);
812
foreach ($filters as $flt => $val) {
813
if ($where) $where .= " AND ";
815
$where .= "`$flt` >= \"$val\"";
817
$where .= "`$flt` = \"$val\"";
821
$query = "SELECT * FROM `cachelog`";
822
if ($where) $query .= " WHERE $where";
823
$res = @mysql_query($query, $this->dbh);
825
switch (mysql_errno($this->dbh)) {
826
case CACHE::MYSQL_ER_NO_SUCH_TABLE:
829
throw new ADEIException(translate("Error querying CacheLog, error: %s, query: %s", mysql_error($this->dbh), $query));
834
while ($item = mysql_fetch_array($res, MYSQL_ASSOC)) {
835
$info = $this->ParsePostfix($item['postfix']);
836
foreach ($info as $key => $val) {
839
if ($archive !== false) {
840
if (preg_match("/_\d{4,8}$/", $item['db_name'])) {
841
if (!$archive) continue;
843
if ($archive) continue;
846
array_push($list, $item);
762
853
function GetPostfixType($db_group = false, $db_name = false, $db_server = false) {
763
854
if ((!$db_server)||(!$db_name)||(!$db_group)) {
764
855
if ($db_server === false) $db_server = $this->default_db_server;