Ejemplo n.º 1
0
         $error = translate("Version information is not available");
     }
     break;
 case "cache":
     try {
         $req = new GROUPRequest();
         $fix_time = $req->GetTimeFormat();
         $multi_mode = false;
     } catch (ADEIException $ae) {
         if ($_GET['db_server'] || $_GET['db_name'] || $_GET['db_group']) {
             throw $ae;
         }
         $multi_mode = true;
     }
     try {
         $cache = new CACHEDB();
         $flags = REQUEST::NEED_ITEMINFO | REQUEST::NEED_INFO | CACHE::TABLE_INFO;
         if ($multi_mode) {
             $info = $cache->GetCacheList($flags);
         } else {
             $info = array();
             $postfix = $cache->GetCachePostfix($req->props['db_group'], $req->props['db_name'], $req->props['db_server']);
             $info[0] = $cache->GetExtendedCacheInfo($postfix, $flags);
         }
     } catch (ADEIException $ex) {
         $ex->logInfo(NULL, $req);
         $error = xml_escape($ex->getInfo());
     }
     break;
 case "log":
     try {
Ejemplo n.º 2
0
 function CreateMask(array &$minfo = NULL, $flags = 0)
 {
     if (!$this->reader) {
         return parent::CreateMask($minfo, $flags);
     }
     if (!$minfo) {
         if ($this->req instanceof DATARequest) {
             $minfo = $this->req->GetMaskInfo($flags);
         }
     }
     $mask = $this->reader->CreateMask($this->group, $minfo, $flags);
     if (!$mask->ids) {
         $mask->ids = $this->GetCacheIDs();
     }
     return $mask;
 }
Ejemplo n.º 3
0
//    $props["filename"] =  preg_replace("/[^\w\d]/", "_", $grname) . "__" . round($from) . "_" . round($to) . "." . $ext;
    
    $query = $req->GetQueryString($props);
    
    echo "<a href=\"services/getdata.php?$query\">" . $title . "</a>";
}

try {
    $req = new SOURCERequest();
} catch (ADEIException $e) {
    $req = new REQUEST();
    $nodata = 1;
}
*/
$flags = REQUEST::NEED_ITEMINFO | REQUEST::NEED_INFO | CACHE::TABLE_INFO | CACHE::NEED_REQUESTS | CACHE::FIND_BROKEN;
$cache = new CACHEDB();
$list = $cache->GetCacheList($flags);
usort($list, create_function('$a,$b', 'return strcasecmp(
    $a["db_server"] . "__" . $a["db_name"] . "__" . $a["db_group"],
    $b["db_server"] . "__" . $b["db_name"] . "__" . $b["db_group"]
);'));
?>
<br/><form id="postfix_form" action="index.php?page=do.php" method="post">
    <input type="hidden" name="action" id="action_input"/>
    <input type="submit" value="<?echo translate("Drop Selected");?> " onClick="javascript:doDrop()"/>
    <input type="submit" value="<?echo translate("Resize Selected");?> " onClick="javascript:doRewidth()"/>
<?

function sumarize_info(&$sum, &$info) {
    if (is_numeric($info['first'])) {
        if (($sum['first'] === false)||($sum['first'] > $info['first'])) {
Ejemplo n.º 4
0
<?php

//   $res = exec('ps xa | grep "downloads_check.php" | grep -v grep | wc -l');
//   if ($res > 1) exit;
if (preg_match("/(.*)downloads_check.php\$/", $_SERVER['SCRIPT_FILENAME'], $m)) {
    @chdir($m[1]);
}
require "../adei.php";
$lock = new LOCK("downloads_check");
$lock->Lock(LOCK::BLOCK);
global $ADEI;
global $ADEI_ROOTDIR;
$ADEI->RequireClass("download");
$cache = new CACHEDB();
$dm = new DOWNLOADMANAGER();
$res = $cache->GetDownloads("", "ASC");
while ($row = mysql_fetch_array($res)) {
    $download = $row['dl_id'];
    $status = $row['status'];
    $name = $dm->Getfilename($download);
    $file = $ADEI_ROOTDIR . "tmp/downloads/" . $name;
    if (file_exists($file)) {
        $fsize = filesize($file);
        $lastmodified = time() - filemtime($file);
    } else {
        $fsize = 0;
        $lastmodified = 0;
    }
    if ($fsize > 1 && $lastmodified > 1 && $status != 'Ready') {
        // We should check if it's really complete (I think - not), and remove failed downloads
        // We also should check that it is not in progress (old mtime?)
Ejemplo n.º 5
0
 function GetSQL(CACHEDB &$cache, $table = false, $limit = 0, $use_subseconds = false, $sequence = false, $sampling = 0)
 {
     global $MYSQL_FORCE_INDEXES;
     $res = array();
     if (!$limit) {
         $limit = $this->GetItemLimit();
     }
     if ($limit) {
         $res['limit'] = " LIMIT " . abs($limit);
     } else {
         $res['limit'] = "";
     }
     if ($sequence === false) {
         $sequence = $this->sequence;
     }
     $from = $this->GetWindowStart();
     $ifrom = floor($from);
     if ($sequence == INTERVAL::SEQUENCE_UNSORTED) {
         $res['sort'] = "";
     } elseif ($limit < 0 || $sequence == INTERVAL::SEQUENCE_BACKWARD) {
         $res['sort'] = "ORDER BY `id` DESC";
     } else {
         $res['sort'] = "ORDER BY `id` ASC";
     }
     if ($use_subseconds) {
         $res['list'] = "EXTENDED_UNIX_TIMESTAMP(time) AS timestamp, `ns`";
     } else {
         $res['list'] = "EXTENDED_UNIX_TIMESTAMP(time) AS timestamp";
     }
     if ($this->IsEmpty()) {
         $res['cond'] = "WHERE (`id` = NULL)";
         return $res;
     }
     if ($this->window_size > 0) {
         $to = $this->GetWindowEnd();
         $ito = floor($to);
         if ($use_subseconds) {
             if ($from == $ifrom) {
                 $nfrom = 0;
             } else {
                 $nfrom = round(1000000000 * ("0" . strstr($from, ".")));
             }
             if ($to == $ito) {
                 $nto = 0;
             } else {
                 $nto = round(1000000000 * ("0" . strstr($to, ".")));
             }
         } else {
             $nfrom = 0;
             $nto = 0;
         }
         $res['cond'] = "WHERE ((`id` >= ADEI_TIMESTAMP({$ifrom}, {$nfrom})) AND (`id` < ADEI_TIMESTAMP({$ito}, {$nto})))";
     } else {
         if ($this->sequence == INTERVAL::SEQUENCE_BACKWARD) {
             $sign = '<';
         } else {
             $sign = '>';
         }
         $sqlfrom = $cache->SQLTime($ifrom);
         if ($use_subseconds && $ifrom != $from) {
             $nfrom = round(1000000000 * ("0" . strstr($from, ".")));
         } else {
             $nfrom = 0;
         }
         $res['cond'] = "WHERE `id` {$sign} ADEI_TIMESTAMP({$ifrom}, {$nfrom})";
     }
     if ($sampling) {
         if (!$table) {
             throw new ADEIException(translate("Ineternal Error: The table name should be passed to query generator if resampling is needed"));
         }
         $sampling *= 1000000000;
         /*
         	The first command is terribly slow, and the second should be avoided
         	because we want floating timestamp start.
         
                 $groupping = "FLOOR((`id` - ADEI_TIMESTAMP($ifrom, $nfrom)) / $sampling)";
                 $groupping = "FLOOR((`id` - 1000000000*$from) / $sampling)";
         */
         $groupping = "FLOOR(`id` / {$sampling})";
         if ($MYSQL_FORCE_INDEXES) {
             $idx_fix = "FORCE INDEX (id)";
         } else {
             $idx_fix = "";
         }
         $res['join'] = ", (SELECT MAX(`id`) AS tmptbl_id FROM `{$table}` {$idx_fix} {$res['cond']} GROUP BY {$groupping}) AS tmptbl";
         $res['cond'] = "WHERE tmptbl.tmptbl_id = `id`";
     }
     $res['index'] = "id";
     /*    
         if ($use_subseconds) {
             $res['list'] = "EXTENDED_UNIX_TIMESTAMP(time) AS timestamp, `ns`";
     	if (($sequence == INTERVAL::SEQUENCE_UNSORTED))
     	    $res['sort'] = "";
     	elseif (($limit < 0)||($sequence == INTERVAL::SEQUENCE_BACKWARD))
     	    $res['sort'] = "ORDER BY `time` DESC, `ns` DESC";
     	else
     	    $res['sort'] = "ORDER BY `time` ASC, `ns` ASC";
         } else {
             $res['list'] = "EXTENDED_UNIX_TIMESTAMP(time) AS timestamp";
     	if (($sequence == INTERVAL::SEQUENCE_UNSORTED))
     	    $res['sort'] = "";
     	elseif (($limit < 0)||($sequence == INTERVAL::SEQUENCE_BACKWARD))
     	    $res['sort'] = "ORDER BY `time` DESC";
     	else 
     	    $res['sort'] = "ORDER BY `time` ASC";
         }
         if ($this->window_size > 0) {
     	$to = dsMathPreciseAdd($this->window_start, $this->window_size);
     	$ito = floor($to);
     	if (($use_subseconds)&&(($ifrom != $from)||($ito != $to))) {
     	    if ($ifrom == $ito) {
     		$sqlfrom = $cache->SQLTime($ifrom);
     		if ($from == $ifrom) $nfrom = 0;
     		else $nfrom = round(1000000000*("0" . strstr($from, ".")));
     		if ($to == $ito) $nto = 0;
     		else $nto = round(1000000000*("0" . strstr($to, ".")));
     	        $res['cond'] = "WHERE ((`time` = $sqlfrom) AND (`ns` >= $nfrom) AND (`ns` < $nto))";
     	    } else {
     		$cond = "";
     	        if ($ifrom != $from) {
     		    $nfrom = round(1000000000*("0" . strstr($from, ".")));
     		    $sqlfrom = $cache->SQLTime($ifrom);
     		    $cond = "((`time` = $sqlfrom) AND (`ns` >= $nfrom))";
     		    $ifrom++;
     		}
     		if ($ifrom != $ito) {
     		    if ($cond) $cond .= " OR ";
     		    $sqlfrom = $cache->SQLTime($ifrom);
     	    	    $sqlto = $cache->SQLTime($ito);
         		    $cond .= "((`time` >= $sqlfrom) AND (`time` < $sqlto))";
     		} else $sqlto = false;
     		if ($ito != $to) {
     		    if ($cond) $cond .= " OR ";
     		    if (!$sqlto) $sqlto = $cache->SQLTime($ito);
     		
     		    $nto = round(1000000000*("0" . strstr($to, ".")));
     		    $cond .= "((`time` = $sqlto) AND (`ns` < $nto))";
     		}
     	
     		$res['cond'] = "WHERE ($cond)";
     	    }
     	} else {
     	    $sqlfrom = $cache->SQLTime($ifrom);
     	    $sqlto = $cache->SQLTime($ito);
         	    $res['cond'] = "WHERE ((`time` >= $sqlfrom) AND (`time` < $sqlto))";
     	}
         } else {
     	if ($this->sequence == INTERVAL::SEQUENCE_BACKWARD) $sign = '<';
     	else $sign = '>';
     	$sqlfrom = $cache->SQLTime($ifrom);
     	if (($use_subseconds)&&($ifrom != $from)) {
     	    $nfrom = round(1000000000*("0" . strstr($from, ".")));
     	    $res['cond'] = "WHERE (((`time` = $sqlfrom) AND (`ns` $sign $nfrom)) OR (`time` $sign $sqlfrom))";
     	} else {
     	    $res['cond'] = "WHERE `time` $sign $sqlfrom";
     	}
         }
         if ($sampling) {
     	if (!$table)
     	    throw new ADEIException(translate("Ineternal Error: The table name should be passed to query generator if resampling is needed"));
     	if ($use_subseconds) {
     	    $sampling*=1000000000;
     	    $rfrom = ($from - $ifrom)*1000000000;	    
     	    $groupping = "FLOOR(((EXTENDED_UNIX_TIMESTAMP(`time`) - $ifrom) * 1000000000 + (`ns` - $rfrom))/$sampling)";
     	    $res['join'] = ", (SELECT MIN(time) AS tmptbl_time, MIN($groupping) AS tmptbl_idx FROM $table {$res['cond']} GROUP BY $groupping) AS tmptbl";
     	    $res['cond'] = "WHERE tmptbl.tmptbl_time = `time` AND tmptbl.tmptbl_idx = $groupping";
     	} else {
     	    $groupping = "FLOOR((EXTENDED_UNIX_TIMESTAMP(`time`) - " . ($ifrom) . " )/$sampling)";
     	    $res['join'] = ", (SELECT MIN(`time`) AS tmptbl_time FROM $table {$res['cond']} GROUP BY $groupping) AS tmptbl";
     	    $res['cond'] = "WHERE tmptbl.tmptbl_time = `time`";
     	}
         }
     */
     #    echo print_r($res, true) . "\n";
     #    exit;
     return $res;
 }
Ejemplo n.º 6
0
<?php

require "../adei.php";
$c = new CACHEDB();
$c->CreateStoredProcedures();
$list = $c->GetCacheList(REQUEST::NEED_ITEMINFO);
foreach ($list as &$info) {
    $table = "cache0{$info['postfix']}";
    $subseconds = $info['info']['ns'];
    echo $table . " - ";
    try {
        $query = "ALTER TABLE `{$table}` ADD `id` BIGINT NOT NULL FIRST";
        $c->Query($query);
        if ($subseconds) {
            $query = "UPDATE `{$table}` SET id = UNIX_TIMESTAMP(`time`)*1000000000+`ns`";
        } else {
            $query = "UPDATE `{$table}` SET id = UNIX_TIMESTAMP(`time`)*1000000000";
        }
        $c->Query($query);
        $query = "ALTER TABLE `{$table}` ADD UNIQUE KEY (id)";
        $c->Query($query);
        #	if ($subseconds) {
        #	    $query = "CREATE TRIGGER cache0_id BEFORE INSERT ON `$table` FOR EACH ROW SET NEW.id = UNIX_TIMESTAMP(NEW.time)*1000000000+NEW.ns";
        #	} else {
        #	    $query = "CREATE TRIGGER cache0_id BEFORE INSERT ON `$table` FOR EACH ROW SET NEW.id = UNIX_TIMESTAMP(NEW.time)*1000000000";
        #	}
        #	$c->Query($query);
        $done = true;
    } catch (ADEIException $ae) {
        $done = false;
        $error = $ae->getMessage();
Ejemplo n.º 7
0
 function GetGroupList($flags = 0)
 {
     if ($flags & REQUEST::LIST_ALL) {
         return REQUEST::GetGroupList($flags);
     }
     $list = array();
     if (isset($this->props['db_group'])) {
         if ($rdr) {
             $reader =& $rdr;
         } else {
             $reader = $this->CreateReader();
         }
         $grp = $reader->CreateGroup($req = array('db_group' => $this->props['db_group']));
         $list = $reader->GetGroupInfo($grp, $flags);
     } else {
         if ($rdr) {
             $reader =& $rdr;
         } else {
             $reader = $this->CreateReader();
         }
         $list = $reader->GetGroupList($flags);
     }
     if ($flags & REQUEST::SKIP_UNCACHED && !$this->srv['virtual']) {
         $cache = new CACHEDB();
         $cached_groups = $cache->ListCachedGroups($this->props['db_name'], $this->props['db_server']);
         #	print_r($list);
         #	print_r($cached_groups);
         foreach (array_keys($list) as $key) {
             if (!in_array($list[$key]['gid'], $cached_groups)) {
                 unset($list[$key]);
             }
         }
     }
     if ($list) {
         foreach ($list as &$gr) {
             $gr['db_group'] = $gr['gid'];
             $gr['db_group_name'] = $gr['name'];
         }
     }
     return $list;
 }
Ejemplo n.º 8
0
<?php

require "../adei.php";
$c = new CACHEDB();
$c->CreateStoredProcedures();
Ejemplo n.º 9
0
    }
    
    if (!$postfix) {
	?><span class="error"><?echo translate("Error: The list of items is not supplied");?></span><?
	exit;
    }
    
    if (!is_array($postfix)) $postfix = array($postfix);

    if (!$confirm) PlaceJS();
    
    switch ($action) {
	case "drop":
	    if ($confirm) {
		try {
		    $cache = new CACHEDB();
		    foreach ($postfix as $p) {
			$cache->Drop($p);
		    }
		    echo translate("Done. All CACHES are droped.");
		} catch (ADEIException $ae) {
		    ?><span class="error"><?echo translate("Error: %s", $ae->getInfo());?></span><?
		}
	    } else RequestConfirmation(
		translate("Do you really want to drop following tables: "),
		$postfix);
	    break;
	case "rewidth":
	    if ($confirm) {
		try {
		    $name = GetAdminFile("resize-");