Exemple #1
0
    /**
     * Tears down the fixture, for example, closes a network connection.
     * This method is called after a test is executed.
     */
    public static function tearDownAfterClass()
    {
        $con = rolisz::get('dbCon');
        $con->Query('TRUNCATE `maintabel`;
TRUNCATE `many2main`;
TRUNCATE `many2many`;
TRUNCATE `tabellegatura`;');
    }
Exemple #2
0
$acl2->deleteACL('permission',13);*/
//$acl->init('',$db);
rolisz::plugin()->registerPlugin($acl2, 'afterMatch');
$_SERVER['REQUEST_URI'] = 'framework/test.php';
rolisz::set('THROTTLE', 1);
rolisz::route('/blog/:arg/ala/:ar2/asd', 'test2', 'GET', 'blog2');
rolisz::route('/blog/*', 'test1');
rolisz::route('/test', 'test1');
rolisz::route('/blog/:asd', 'test3');
rolisz::route('/test.php', 'test');
rolisz::route('/proiecs/aed[]te\\*', 'test2');
rolisz::route('/proiecs/:ala/bala/:korhaz/:edit/:buha', 'test', 'GET', 'testare');
rolisz::route('/proiecs/asfv', 'test2');
rolisz::route(' /infinity', 'test3|test', 'POST');
rolisz::route('/infinity/ourubors/ternary', 'test1');
$routes = rolisz::get('ROUTES');
//var_dump($routes);
rolisz::run();
function test($arg = 'def')
{
    echo 'works ';
    echo $arg;
}
function test1()
{
    echo 'test1';
}
function test2($arg1, $arg2 = 'def')
{
    echo 'test2 ';
    echo $arg1 . $arg2;
Exemple #3
0
 /**
  * 	Performs the replacing of the shorthand tags to full PHP tags in the $template file. Places the results in 
  * a temp folder, in a file called the md5 value of $template, to prevent collisions. 
  * 		@param string $template
  * 
  */
 private function compile($template)
 {
     $template_code = file_get_contents($template);
     $template_code = preg_replace('/{ignore}.+?{\\/ignore}/', '', $template_code);
     $template_code = preg_replace('/{noparse}(.+?){\\/noparse}/', '$1', $template_code);
     //@todo: fix this
     //Rules for substituting  ifs and elses
     $template_code = preg_replace('/{if="(.+?)"}/', '<?php if($1) { ?>', $template_code);
     $template_code = preg_replace('/{\\/if}/', '<?php } ?>', $template_code);
     $template_code = preg_replace('/{else}/', '<?php } else { ?>', $template_code);
     $template_code = preg_replace('/{elseif="(.+?)"}/', '<?php } elseif ($1) { ?>', $template_code);
     // Rules for substituting the two kinds of foreaches and the ed foreach
     $template_code = preg_replace('/{foreach (.+?) as (.+?) => (.+?) ?}/', '<?php if (is_array($$1))  foreach ($$1 as $$2=>$$3) { ?>', $template_code);
     $template_code = preg_replace('/{foreach (.+?) as (.+?) ?}/', '<?php if (is_array($$1))  foreach ($$1 as $$2) { ?>', $template_code);
     $template_code = preg_replace('/{\\/foreach}/', '<?php  } ?>', $template_code);
     // Each include directive found in the template is compiled and then replaced
     // with a static call to viewS
     preg_match_all('/{include="(.+?)"}/', $template_code, $matches);
     if (rolisz::check('TEMPLATE')) {
         $tplFolder = rolisz::get('TEMPLATE') . '/';
     }
     foreach ($matches[1] as $match) {
         $this->compile($tplFolder . $match);
     }
     $template_code = preg_replace('/{include="(.+?)"}/', '<?php $this->view(\'$1\'); ?>', $template_code);
     // Replace rule for variables. Allows for multiple functions to be called arround it , separated by |
     $template_code = preg_replace_callback('/{{ (.*?)(\\|(.+?))? }}/', function ($match) {
         $str = '<?php echo ';
         if (isset($match[3])) {
             $functions = explode('|', $match[3]);
             $nr = 0;
             $additionalArgs = array();
             foreach ($functions as $function) {
                 $nr++;
                 $matches;
                 if (preg_match('/\\((.+)\\)/', $function, $matches)) {
                     $function = preg_replace('/\\(.+\\)/', '', $function);
                     $additionalArgs[$nr] = $matches[1];
                 }
                 $str .= $function . '(';
             }
             if ($match[1] != '') {
                 $str .= '$' . $match[1];
             }
             if (!empty($additionalArgs)) {
                 foreach ($additionalArgs as $key => $value) {
                     $str = str_pad($str, strlen($str) + $nr - $key, ')');
                     if ($match[1] != '') {
                         $str .= ',';
                     }
                     $str .= $value . ')';
                 }
             } else {
                 $str = str_pad($str, strlen($str) + $nr, ')');
             }
             $str .= '; ?>';
         } else {
             $str .= '$' . $match[1] . '; ?>';
         }
         return $str;
     }, $template_code);
     if (!is_dir('temp')) {
         mkdir('temp');
     }
     $compile = 'temp/' . pathinfo($template, PATHINFO_FILENAME) . md5($template) . '.php';
     file_put_contents($compile, $template_code);
 }
Exemple #4
0
 /**
  *  Retrieves all requesters, resources, actions or permissions from the database or XML file. 
  * 		@param string $type
  * 		@return array
  */
 public function getACL($type)
 {
     if (is_null($this->prefix)) {
         return false;
     }
     if ($type == 'permission') {
         return rolisz::get('dbCon')->fetchAll("SELECT act.action, req.requester, res.resource, perm.id FROM {$this->prefix}_permissions AS perm \n\t\t\t\t\t\tLEFT JOIN {$this->prefix}_actions AS act ON perm.action=act.id \n\t\t\t\t\t\tLEFT JOIN {$this->prefix}_requesters AS req ON perm.requester=req.id \n\t\t\t\t\t\tLEFT JOIN {$this->prefix}_resources AS res ON perm.resource=res.id");
     }
     $acl = table::findS($this->prefix . "_{$type}s");
     if (!is_array($acl)) {
         $acl = array($acl);
     }
     foreach ($acl as &$element) {
         $element = $element->getData();
     }
     return $acl;
 }