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
<?php

include '../rolisz.php';
rolisz::connect('MySQLi', 'localhost', 'root', '', 'rolisz');
include '../db.php';
table::set('posts');
table::addRelationM2MS('posts', 'post_category', 'id', 'pid', 'category', 'id', 'cid');
table::addRelationM2MS('posts', 'post_tags', 'id', 'pid', 'tags', 'id', 'tid');
table::addRelationS('posts', 'users', 'author', 'id');
table::addRelationS('posts', 'comments', 'pid');
//var_dump(table::findS('posts'));
$posts = new table('posts');
// $posts->addRelationM2M('post_category','id','pid','category','id','cid');
// $posts->addRelation('users','author','id');
// $posts->addRelation('comments','pid');
$posts->title = 'Test Post';
$posts->body = 'Lorem Ipsum Doloret coloret';
$posts->author = 1;
//$posts->save();
$posts1 = new table('posts', 1);
$test = $posts1->find('category');
$comment = new table('comments', 1);
$comment->posts(array('id' => 1));
$comment->save();
$author = new table('users', 1);
$posts2 = new table('posts', 2);
$posts2->tags(array('tag' => 'google'));
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
<?php

include '../rolisz.php';
rolisz::connect('MySQLi', 'localhost', 'root', '', 'wordpress');
include '../db.php';
$posts = new table('wpb_posts', '59');
$posts->addRelationM2M('wpb_term_relationships', 'id', 'object_id', 'wpb_terms', 'term_id', 'term_taxonomy_id');
$posts->addRelation('wpb_users', 'post_author', 'ID');
$posts->addRelation('wpb_comments', 'comment_post_ID');
$term_rel = new table('wpb_terms');
$term_rel->addRelation('wpb_term_taxonomy', 'term_id');
//$posts->save();
$test = $posts->find('wpb_posts', array('wpb_terms' => array('wpb_term_taxonomy' => array('taxonomy' => 'category'), 'name' => 'Customization')));
var_dump($test);
echo 'yooooo';
$test = $posts->find('wpb_terms');
var_dump($test);
Exemple #5
0
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;
}
function test3($arg1)
Exemple #6
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;
 }
Exemple #7
0
 /**
  *	Sets up autoload, initializes some constants and starts session. 
  *		@public
  **/
 public static function start()
 {
     //	Use the rolisz autoload function
     spl_autoload_register(array('rolisz', 'autoload'));
     //dunno
     $root = rolisz::fixSlashes(realpath('.')) . '/';
     //Set a few site dependent framework variables
     self::$global = array('BASE' => preg_replace('/(.*)\\/.+/', '$1', $_SERVER['SCRIPT_NAME']), 'ENCODING' => 'UTF-8', 'ERROR' => NULL, 'QUIET' => FALSE, 'RELEASE' => FALSE, 'ROOT' => $root, 'SITEMAP' => array(), 'TIME' => time(), 'THROTTLE' => 0, 'VERSION' => self::AppName . ' ' . self::Version, 'AJAX' => isset($_SERVER['HTTP_X_REQUESTED_WITH']) && $_SERVER['HTTP_X_REQUESTED_WITH'] == 'XMLHttpRequest');
     self::$executionPoints = array('beforeMatch' => array(), 'afterMatch' => array(), 'hydrateTable' => array(), 'saveTable' => array(), 'deleteTable' => array(), 'compileTemplate' => array());
     session_start();
 }
Exemple #8
0
 /** 
  * 	Process routes based on the incoming URI. If no match is found, a 404 error is trigerred. beforeMatch and afterMatch plugins
  * 	are called here. Throttles outputting the script until rolisz::get('THROTTLE') time has passed.
  **/
 public static function run()
 {
     $routes = array_keys(self::$global['ROUTES'][$_SERVER['REQUEST_METHOD']]);
     if (self::$global['AJAX']) {
         $routes = array_merge($routes, array_keys(self::$global['ROUTES']['A' . $_SERVER['REQUEST_METHOD']]));
     }
     // Process routes
     if (!isset($routes)) {
         trigger_error('No routes set!');
         return;
     }
     $found = FALSE;
     $time = time();
     self::$global['ROUTE'] = explode('/', trim(substr($_SERVER['REQUEST_URI'], strlen(self::$global['BASE'])), ' /'));
     self::$global['ARGS'] = array();
     $valid_routes = array();
     rolisz::runPlugins('beforeMatch', self::$global['ROUTE']);
     // Search recursively the depth to which an identical route is defined
     foreach ($routes as $route) {
         if (self::matches($route)) {
             $valid_routes[] = $route;
         }
     }
     rsort($valid_routes);
     self::$global['ARGS'] = array_unique(self::$global['ARGS']);
     if (!empty($valid_routes)) {
         $found = TRUE;
     }
     if (!$found) {
         rolisz::http404();
     } else {
         if (!isset(self::$global['ARGS'][$valid_routes[0]])) {
             self::$global['ARGS'][$valid_routes[0]] = array();
         }
         self::$global['currentRoute'] = self::$global['ROUTES'][$_SERVER['REQUEST_METHOD']][$valid_routes[0]];
         rolisz::runPlugins('afterMatch', self::$global['currentRoute']);
         rolisz::call(self::$global['currentRoute'], self::$global['ARGS'][$valid_routes[0]]);
         // Delay output for throttling
         $elapsed = time() - $time;
         if (self::$global['THROTTLE'] / 1000.0 > $elapsed) {
             usleep(1000000.0 * (self::$global['THROTTLE'] / 1000.0 - $elapsed));
         }
     }
     return;
 }
Exemple #9
0
<?php

include '../rolisz.php';
$form1 = new form(array('id' => 'test1'));
$form1->input('text', array('name' => 'user', 'pattern' => '.{6,}'))->input('password', array('name' => 'pass', 'pattern' => '[0-9]{3,5}'))->input('textarea', array('name' => 'textareaname', 'value' => 'value'))->input('select', array('name' => 'selectname', 'options' => array('o' => 'opt', 'n' => 'noopt')));
$form2 = new form(array('id' => 'test2', 'action' => 'testare'));
$form2->input('text', array('name' => 'user'))->input('password', array('name' => 'pass'))->input('radio', array('name' => 'radio'))->textarea(array('name' => 'textareaname', 'value' => 'value'))->input('select', array('name' => 'selectname', 'options' => array('o' => 'opt', 'n' => 'noopt')));
//var_dump($form1->getString());
//var_dump($form2->getString());
//$form1->show();
//$form2->show();
//$form1->validate();
$posts = rolisz::connect('MySQLi', 'localhost', 'root', '', 'rolisz');
$posts = rolisz::table('posts', 1);
$form3 = new form(array('id' => 'test3'), $posts);
$form3->input('text', array('name' => 'author', 'pattern' => function ($arg) {
    if ($arg == 'rolisz') {
        return true;
    }
    return false;
}));
$form3->removeInput('title');
var_dump($form3->getString());
$form3->show();
if (isset($_GET['send'])) {
    $form3->validate();
}