Exemple #1
0
 public function RewriteRuleDirective(\HTRouter\Request $request, $line)
 {
     $args = explode(" ", $line, 3);
     if (count($args) <= 2) {
         // Add optional flags
         $args[] = "";
     }
     $rule = new Rule($args[0], $args[1], $args[2]);
     foreach ($this->getConfig()->get("TempRewriteConditions", array()) as $condition) {
         $rule->addCondition($condition);
     }
     $this->getConfig()->append("RewriteRule", $rule);
     // Clear the current rewrite conditions
     $this->getConfig()->clear("TempRewriteConditions");
 }
Exemple #2
0
 function testDoesMatchingWithConditionsFunction()
 {
     // Rule does not match, since port != 1337
     $rule = new Rule(".+", "test.php", "");
     $rule->addCondition(new Condition('%{SERVER_ADMIN}', '=info@example.org', ''));
     $rule->addCondition(new Condition('%{SERVER_PORT}', '=1337', ''));
     $result = $rule->rewrite($this->_request);
     $this->assertEquals(0, $result->rc);
     $this->assertEquals("/test.php", $this->_request->getFilename());
     // Rule matches, since info@example.org is correct, and we need OR
     $rule = new Rule(".+", "test.php", "");
     $rule->addCondition(new Condition('%{SERVER_ADMIN}', '=info@example.org', '[OR]'));
     $rule->addCondition(new Condition('%{SERVER_PORT}', '=1337', ''));
     $result = $rule->rewrite($this->_request);
     //$this->assertTrue($rule->matches());
     // Rule matches, since both conditions are true
     $rule = new Rule(".+", "test.php", "");
     $rule->addCondition(new Condition('%{SERVER_ADMIN}', '=info@example.org', ''));
     $rule->addCondition(new Condition('%{SERVER_PORT}', '=80', ''));
     $result = $rule->rewrite($this->_request);
     //$this->assertTrue($rule->matches());
 }
Exemple #3
0
 function testSubstitution_013()
 {
     $this->_request->setUri("blaat");
     $_SERVER['SCRIPT_FILENAME'] = "foo.php";
     $this->assertEquals("blaat foo.php true off", Rule::expandSubstitutions("%{REQUEST_URI} %{REQUEST_FILENAME} %{IS_SUBREQ} %{HTTPS}", $this->_request));
 }