Пример #1
0
 /** db profiling **/
 public function doProfile()
 {
     $this->db = xn("db");
     import("lib.mongo.RQuery");
     import("lib.page.RPageStyle1");
     $query = new RQuery($this->_mongo, $this->db, "system.profile");
     $page = new RPageStyle1();
     $page->setTotal($query->count());
     $page->setSize(10);
     $page->setAutoQuery();
     $this->page = $page;
     $this->rows = $query->offset($page->offset())->limit($page->size())->desc("ts")->findAll();
     foreach ($this->rows as $index => $row) {
         $this->rows[$index]["text"] = $this->_highlight($row, "json");
     }
     $this->display();
 }
Пример #2
0
    if ($configInput['type'] == 'api') {
        $context->isAPI = true;
    }
    $doActions[] = $context;
}
//
// ---------
//
// create a RQuery if a filter was provided
//
/**
 * @var RQuery $objectFilterRQuery
 */
$objectFilterRQuery = null;
if ($rulesFilter !== null) {
    $objectFilterRQuery = new RQuery('rule');
    $res = $objectFilterRQuery->parseFromString($rulesFilter, $errorMessage);
    if ($res === false) {
        fwrite(STDERR, "\n\n**ERROR** Rule filter parser: " . $errorMessage . "\n\n");
        exit(1);
    }
    print " - Rule filter after sanitization: ";
    $objectFilterRQuery->display();
    print "\n";
}
// --------------------
//
// load the config
//
print " - Loading configuration through PAN-Configurator library... ";
$pan->load_from_domxml($xmlDoc);
Пример #3
0
    /** clear rows in collection **/
    public function doClearRows()
    {
        $this->db = x("db");
        $this->collection = xn("collection");
        import("lib.mongo.RQuery");
        $query = new RQuery($this->_mongo, $this->db, $this->collection);
        $query->delete();
        echo '<script language="javascript">
window.parent.frames["left"].location.reload();
</script>';
        $this->redirect("collection.index", array("db" => $this->db, "collection" => $this->collection), true);
    }
Пример #4
0
    $configType = 'panos';
}
unset($xpathResult);
if ($configType == 'panos') {
    $pan = new PANConf();
} else {
    $pan = new PanoramaConf();
}
print " - Detected platform type is '{$configType}'\n";
if ($configInput['type'] == 'api') {
    $pan->connector = $configInput['connector'];
}
$errorMessage = '';
$filterQuery = null;
if (isset(PH::$args['filter'])) {
    $filterQuery = new RQuery('rule');
    if (!$filterQuery->parseFromString(PH::$args['filter'], $errorMessage)) {
        derr($errorMessage);
    }
    print " - rule filter after sanitizing : ";
    $filterQuery->display();
}
//
// load the config
//
print " - loading config... ";
$pan->load_from_domxml($xmlDoc);
print "OK!\n";
// </editor-fold>
//
// Location provided in CLI ?
Пример #5
0
    if ($configInput['type'] == 'api') {
        $context->isAPI = true;
    }
    $doActions[] = $context;
}
//
// ---------
//
// create a RQuery if a filter was provided
//
/**
 * @var RQuery $objectFilterRQuery
 */
$objectFilterRQuery = null;
if ($objectsFilter !== null) {
    $objectFilterRQuery = new RQuery('service');
    $res = $objectFilterRQuery->parseFromString($objectsFilter, $errorMessage);
    if ($res === false) {
        fwrite(STDERR, "\n\n**ERROR** Rule filter parser: " . $errorMessage . "\n\n");
        exit(1);
    }
    print " - filter after sanitization : " . $objectFilterRQuery->sanitizedString() . "\n";
}
// --------------------
//
// load the config
//
$pan->load_from_domxml($xmlDoc);
print "\n*** config loaded ***\n";
// --------------------
//
Пример #6
0
<?php

require '../src/autoload.php';
$rQueryConf = new RQueryConfiguratorDatabase('mysql', 'localhost', 'root', '', 'rquery');
$rQuery = new RQuery($rQueryConf, new RQueryDriverPdo());
$rQuery->dropTable("test");
$rQuery->dropTable(["test", "toto"]);
$rQuery->useSqlFile('test_file.sql');
$rQuery->dropTable("test");
$rQuery->dropTable(["test", "toto"]);
$rQuery->exec("CREATE TABLE `test` (\n  `id` INT UNSIGNED NOT NULL AUTO_INCREMENT,\n  `name` VARCHAR(255) NOT NULL,\n  PRIMARY KEY (`id`) );");
$rQuery->optimize("test");
$rQuery->optimize(["test", "toto"]);
$id = $rQuery->insert("INSERT INTO test (`name`) VALUES (:name)", array('name' => 'A'));
var_dump("Insert Into test last id: " . $id);
$idB = $rQuery->insert("INSERT INTO test (`name`) VALUES (:name)", array('name' => 'B'));
var_dump("Insert Into test last id: " . $idB);
$id = $rQuery->insert("INSERT INTO test (`name`) VALUES (:name)", array('name' => 'C'));
var_dump("Insert Into test last id: " . $id);
$id = $rQuery->insert("INSERT INTO test (`name`) VALUES (:name)", array('name' => 'chickenskill'));
var_dump("Insert Into test last id: " . $id);
$rowsAffected = $rQuery->update("UPDATE test SET name = :name WHERE id = :id", array('id' => $idB, 'name' => 'google'));
var_dump("Row affected: " . $rowsAffected);
$rowsAffected = $rQuery->delete("DELETE FROM test WHERE name = :name1 OR name = :name2", array('name1' => 'A', 'name2' => 'C'));
var_dump("Row affected: " . $rowsAffected);
$cursor = $rQuery->select("SELECT * FROM test");
while ($row = $rQuery->read($cursor)) {
    var_dump($row);
}
$pdo = $rQuery->getDriver();
var_dump($pdo);
Пример #7
0
 /**
  * @param string $text
  * @param string $errorMessage
  * @return bool|int FALSE if an error occured (see $errorMessage content)
  */
 public function parseFromString($text, &$errorMessage)
 {
     $supportedFilters =& self::$defaultFilters[$this->objectType];
     $len = strlen($text);
     $start = 0;
     $previousClose = 0;
     $end = $len - 1;
     $findOpen = strpos($text, '(', $start);
     $findClose = strpos($text, ')', $start);
     //print $this->padded."Parsing \"$text\"\n";
     while ($findOpen !== FALSE && $findClose > $findOpen) {
         $newQuery = new RQuery($this->objectType, $this->level + 1);
         $this->subQueries[] = $newQuery;
         $res = $newQuery->parseFromString(substr($text, $findOpen + 1), $errorMessage, $supportedFilters);
         if ($res === false) {
             return false;
         }
         if ($findOpen != 0 && $text[$findOpen - 1] == '!') {
             $newQuery->inverted = true;
         }
         if (count($this->subQueries) > 1) {
             if ($newQuery->inverted) {
                 $operator = substr($text, $previousClose + 1, $findOpen - $previousClose - 2);
             } else {
                 $operator = substr($text, $previousClose + 1, $findOpen - $previousClose - 1);
             }
             $operator = self::extractOperatorFromString($operator, $errorMessage);
             if ($operator === false) {
                 return false;
             }
             $this->subQueriesOperators[] = $operator;
             ////print $this->padded."raw operator found: '$operator'\n";
         }
         $previousClose = $findOpen + $res;
         //print $this->padded.'remains to be parsed after subQ extracted: '.substr($text,$previousClose+1)."\n";
         $start = $findOpen + $res + 1;
         $findOpen = strpos($text, '(', $start);
         $findClose = strpos($text, ')', $start);
     }
     if ($this->level != 0) {
         $findClose = strpos($text, ')', $previousClose + 1);
         if ($findClose === false) {
             $errorMessage = 'cannot find closing )';
             //print $this->padded."test\n";
             return false;
         } elseif (count($this->subQueries) == 0) {
             $this->text = substr($text, 0, $findClose);
             if (!$this->extractWordsFromText($this->text, $supportedFilters, $errorMessage)) {
                 return false;
             }
             return $findClose + 1;
         }
         return $findClose + 1;
     }
     // here we are at top level
     if (count($this->subQueries) == 0) {
         //print $this->padded."No subquery found, this is an expression: $text\n";
         $this->text = $text;
         if (!$this->extractWordsFromText($this->text, $supportedFilters, $errorMessage)) {
             return false;
         }
     } else {
         //print $this->padded . "Sub-queries found\n";
         //$this->text = $text;
     }
     return 1;
 }
Пример #8
0
 /**
  * Returns an Array with all Rules inside this store
  * @param null|string $withFilter
  * @return SecurityRule[]|NatRule[]
  */
 public function &rules($withFilter = null)
 {
     $query = null;
     if ($withFilter !== null && $withFilter != '') {
         $errMesg = '';
         $query = new RQuery('rule');
         if ($query->parseFromString($withFilter, $errMsg) === false) {
             derr("error while parsing query: {$errMesg}");
         }
         $res = array();
         foreach ($this->rules as $rule) {
             if ($query->matchSingleObject($rule)) {
                 $res[] = $rule;
             }
         }
         if ($this->isPreOrPost) {
             foreach ($this->postRules as $rule) {
                 if ($query->matchSingleObject($rule)) {
                     $res[] = $rule;
                 }
             }
         }
         return $res;
     }
     if (!$this->isPreOrPost) {
         $res = $this->rules;
         return $res;
     }
     $res = array_merge($this->rules, $this->postRules);
     return $res;
 }