Exemple #1
0
 static function checkLoggedIn($html, $login)
 {
     $matches = array('@log\\s?(out|off)@i', '@sign\\s?(out|off)@i', '@Last Month|Last Week@i', '@[^a-z]My [a-z]@i', '@[ >]Scoop Interactive[< ]@i');
     foreach ($matches as $match) {
         if (preg_match($match, $html)) {
             return true;
         }
     }
     Debug::out('||ERROR||: Could not login');
     Debug::out($login);
     return false;
 }
Exemple #2
0
 function resolveRoutes()
 {
     $this->unparsedTokens = array_merge([''], $this->tokens);
     $this->globals['route'] = $this;
     $i = 0;
     while ($this->unparsedTokens && !$this->stopRouting) {
         $i++;
         if ($i > $this->max_loops) {
             Debug::out('_routing rules are looping');
             Debug::out($this);
             Debug::toss('Route appears to be looping infinitely');
         }
         $this->currentToken = array_shift($this->unparsedTokens);
         if ($this->currentToken) {
             $this->parsedTokens[] = $this->currentToken;
         }
         $path = $this->options['folder'] . implode('/', $this->parsedTokens);
         if (!isset($this->ruleSets[$path])) {
             $this->ruleSets[$path] = (array) Files::inc($path . '/_routing.php', $this->globals, ['extract' => ['rules']])['rules'];
         }
         if (!$this->ruleSets[$path] || $this->stopRouting) {
             continue;
         }
         //note, on match, matehRules resets unparsedTokens (having the effect of loopiing matchRules over again)
         $this->matchRules($path, $this->ruleSets[$path]);
     }
     $this->parsedTokens = [];
 }
Exemple #3
0
<?php

$base = realpath(__DIR__ . '/../');
# Assumes composer used
require $base . '/vendor/autoload.php';
use Grithin\Route;
$route = new Route(['folder' => $base . '/control/']);
/**
Based on the controls and the routes, will handle the following paths:

-	/
-	/bill/123
-	/staticMethod
-	/instanceMethod
-	/globalFunction
-	/index
-	/test/normal
*/
try {
    $route->handle();
} catch (RouteException $e) {
    \Grithin\Debug::out('Route exception encountered');
    \Grithin\Debug::out($route);
    throw $e;
}
Exemple #4
0
<?php

\Grithin\Debug::out(['Tokens:', $route->tokens]);
\Grithin\Debug::quit('Loaded Control: ' . __FILE__);
Exemple #5
0
 function instancely($route)
 {
     \Grithin\Debug::out([$route->regexMatch, $route->tokens]);
     \Grithin\Debug::quit('Route Rule Function Called');
 }
Exemple #6
0
	'clicks' : 2
]
*/
Debug::out($conform->standardise_errors());
/*
0 : [
		'fields' : [
			0 : 'hits'
		]
		'message' : 'v.int'
		'rule' : [
			'flags' : []
			'params' : []
			'fn_path' : 'v.int'
		]
		'type' : 'v.int'
		'params' : []
	]
]
*/
# Clearing previous errors and output
$conform->clear();
# rules which always pass
$rules = ['hits' => 'f.int', 'clicks' => ''];
Debug::out($conform->fields_rules($rules));
/*
[
	'hits' : 0
	'clicks' : 2
]
*/