Esempio n. 1
0
 private function CreateReader(SOURCERequest $req, $info_reader = true)
 {
     if ($this->cache_reader) {
         /* Conversion is not needed, used only for local stuff */
         $rdr = $req->CreateCacheReader();
         if (!$this->reader_access_by_cache_readers) {
             $rdr->DisableReaderAccess();
         }
         return $rdr;
     } else {
         return $req->CreateReader();
     }
 }
Esempio n. 2
0
    static function Parse($srctree, $optimize = false, $flags = 0)
    {
        global $ADEI;
        global $ADEI_SRCTREE_EXTRA;
        $elements = explode(",", preg_replace_callback("/(\\([^)]+,[^)]+\\))/", create_function('$matches', '
		return preg_replace("/,/", ";", $matches[0]);
	    '), $srctree));
        $curid = false;
        $res = array();
        $idnum = array();
        $extras = array();
        if (!$elements || !$elements[0]) {
            $elements = array();
        }
        if ($flags & SOURCETree::EXPAND_SERVERS) {
            $remove_dublicates = false;
            $new_elements = array();
            foreach ($elements as $element) {
                if (preg_match("/^(.*)\\(([^)]+)\\)\$/", $element, $m)) {
                    array_push($new_elements, $element);
                } else {
                    $parts = explode("__", $element, 4);
                    if (sizeof($parts) == 1) {
                        $req = new SERVERRequest($props = array("db_server" => $parts[0]));
                        $list = $req->GetDatabaseList();
                        foreach ($list as $id => $info) {
                            array_push($new_elements, $parts[0] . "__" . $id);
                        }
                        $remove_dublicates = true;
                    } else {
                        if (sizeof($parts) > 2 && $parts[0] == "virtual") {
                            $extra = $parts[1];
                            if (!$extras[$extra]) {
                                ADEI::RequireClass("srctree/{$ADEI_SRCTREE_EXTRA[$extra]['class']}");
                                $extras[$extra] = new $ADEI_SRCTREE_EXTRA[$extra]['class']($req, $ADEI_SRCTREE_EXTRA[$extra]['options']);
                            }
                            $parts = explode("__", $element, 3);
                            $list = $extras[$extra]->Parse($parts[2]);
                            foreach ($list as $item) {
                                array_push($new_elements, $item);
                            }
                            $remove_dublicates = true;
                        } else {
                            array_push($new_elements, $element);
                        }
                    }
                }
            }
            $elements = array();
            foreach ($new_elements as $element) {
                if (preg_match("/^(.*)\\(([^)]+)\\)\$/", $element, $m)) {
                    array_push($elements, $element);
                } else {
                    $parts = explode("__", $element, 4);
                    if (sizeof($parts) == 2) {
                        $req = new SOURCERequest($props = array("db_server" => $parts[0], "db_name" => $parts[1]));
                        $list = $req->GetGroupList();
                        foreach ($list as $gid => $info) {
                            array_push($elements, $parts[0] . "__" . $parts[1] . "__" . $gid);
                        }
                        $remove_dublicates = true;
                    } else {
                        array_push($elements, $element);
                    }
                }
            }
            if ($remove_dublicates) {
                if ($optimize) {
                    $elements = array_unique($elements);
                } else {
                    $new_elements = array_unique($elements);
                    ksort($new_elements);
                    $elements = array_values($new_elements);
                }
            }
        }
        foreach ($elements as $element) {
            if (preg_match("/^(.*)\\(([^)]+)\\)\$/", $element, $m)) {
                $id = $m[1];
                $parts = explode("__", $m[1], 3);
                if (sizeof($parts) < 3) {
                    throw new ADEIException(translate("Unsupported element (%s) in the source tree", $m[1]));
                }
                $items = explode(";", $m[2]);
            } else {
                $parts = explode("__", $element, 4);
                if (sizeof($parts) == 1 && ($flags & SOURCETree::IGNORE_UIDS) == 0) {
                    $item_props = $ADEI->ResolveUID($parts[0]);
                    // Controls are not supported at the moment
                    if ($item_props) {
                        $parts = explode("__", SOURCETree::PropsToItem($item_props));
                    } else {
                        if (($flags & SOURCETree::IGNORE_BADITEMS) == 0) {
                            throw new ADEIException(translate("UID (%s) is not available", $parts[0]));
                        } else {
                            continue;
                        }
                    }
                }
                if (sizeof($parts) < 3) {
                    if (($flags & SOURCETree::IGNORE_BADITEMS) == 0) {
                        throw new ADEIException(translate("Unsupported element (%s) of source tree", $element));
                    } else {
                        continue;
                    }
                }
                $id = $parts[0] . "__" . $parts[1] . "__" . $parts[2];
                if (sizeof($parts) == 4) {
                    $items = array($parts[3]);
                } else {
                    $items = false;
                }
            }
            if ($optimize) {
                $realid = $id;
            } else {
                if (strcmp($id, $curid)) {
                    if ($idnum[$id]) {
                        $realid = $id . "__" . ++$idnum[$id];
                    } else {
                        $realid = $id;
                        $idnum[$id] = 1;
                    }
                    $curid = $id;
                }
            }
            if (!isset($res[$realid])) {
                $res[$realid] = array('props' => array('db_server' => $parts[0], 'db_name' => $parts[1], 'db_group' => $parts[2]), 'items' => array());
            }
            if ($items === false) {
                $res[$realid]['items'] = false;
                unset($res[$realid]['props']['db_mask']);
            } else {
                if (is_array($res[$realid]['items'])) {
                    $res[$realid]['items'] = array_merge($res[$realid]['items'], $items);
                    $res[$realid]['props']['db_mask'] = implode(",", $res[$realid]['items']);
                }
            }
        }
        return $res;
    }
Esempio n. 3
0
 function __construct(&$props = NULL)
 {
     parent::__construct($props);
 }
Esempio n. 4
0
<?php

require "../../adei.php";
header("Content-type: text/xml");
header("Cache-Control: no-cache, must-revalidate");
header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");
$_GET['db_server'] = "toska";
$_GET['db_name'] = "womisaDB_repl";
try {
    $req = new SOURCERequest($_GET);
    $reader = $req->CreateReader();
    $list = $reader->GetGroupList();
    unset($reader);
    if (!count($list)) {
        $error = translate("No LogGroups is found");
    }
} catch (ADEIException $ex) {
    $error = xml_escape($ex->getMessage());
}
echo "<?xml version=\"1.0\"?>\n";
if ($error) {
    echo "<result><Error>{$error}</Error></result>";
} else {
    echo "<result>";
    foreach ($list as $value => $db) {
        echo "<Value name=\"" . xml_escape($db['name']) . "\" value=\"" . $value . "\"/>";
    }
    echo "</result>";
}
Esempio n. 5
0
        if ($timezone) {
            date_default_timezone_set($adei_timezone);
        }
        if (!$from) {
            $from = $to = $time;
        } else {
            if ($time > $to) {
                $to = $time;
            } elseif ($time < $from) {
                $from = $time;
            }
        }
    }
    rewind($f);
}
$req = new SOURCERequest($config);
$reader = $req->CreateReader(REQUEST::READER_FORBID_CACHEREADER);
$ginfo = $reader->GetGroupList(REQUEST::NEED_INFO | REQUEST::NEED_ITEMINFO);
foreach (array_keys($ginfo) as $gid) {
    $size = sizeof($ginfo[$gid]['items']);
    $groups[$gid] = array("items" => false, "size" => $size);
    for ($i = 0; $i < $size; $i++) {
        $groups[$gid][$i] = -1;
    }
}
$namestr = fgets($f);
$names = split(',', preg_replace('/(^\\s+|\\s+$)/', "", $namestr));
unset($names[0]);
foreach ($names as $pos => $name) {
    $sn = strstr($name, "\\");
    if ($sn) {