Exemplo n.º 1
0
 public function __construct()
 {
     parent::__construct();
     $this->spam = antispam::getInstance();
     $this->security = security::getInstance();
     $this->filter = array('content' => array('filters' => array()), 'suscribe' => array('filters' => array(array('trueOrFalse'))));
     $this->validate = array('author' => array('required' => true, 'rules' => array(array('rule' => VALID_NOT_EMPTY, 'message' => 'Por favor introduce tu Nombre.'))), 'url' => array('rules' => array(array('rule' => VALID_URL, 'message' => 'No es una URL valida.'))), 'email' => array('required' => true, 'rules' => array(array('rule' => VALID_EMAIL, 'message' => 'El e-mail no es valido.'))), 'content' => array('required' => true, 'rules' => array(array('rule' => VALID_NOT_EMPTY, 'message' => 'Debes introducir un comentario.'), array('rule' => array('isSpam'), 'message' => 'No se aceptan comentarios en blanco o con spam.'))));
 }
Exemplo n.º 2
0
 protected function renderAdminMenu(array $prm = null)
 {
     $links = array();
     if (security::getInstance()->isLogged()) {
         $db = db::getInstance();
         $tables = $db->getTables();
         foreach ($tables as $t) {
             if (!strpos($t, '_') && !strpos($t, db::getCfg('i18n'))) {
                 $links[$t] = request::uriDef(array('module' => $t, 'action' => '', 'param' => ''));
             }
         }
     }
     $this->setViewVar('linksTable', $links);
 }
Exemplo n.º 3
0
<?php

echo '<h1>' . $error . '</h1>';
echo utils::htmlOut(session::getFlash('nyroError')) . '<br /><br />';
echo security::getInstance()->getLoginForm();
Exemplo n.º 4
0
	/**
	 * Every called action must pass by this function
	 *
	 * @param null|string $prm Actopn Parameters
	 * @throws nException if wrong parameter or other errors
	 */
	final public function exec(array $prm=array()) {
		$this->prmExec = array_merge(array(
			'module'=>$this->getName(),
			'action'=>'index',
			'param'=>'',
			'paramA'=>null,
			'prefix'=>null),
			$prm);

		$this->prmExec['prefix'] = null;

		if (array_key_exists(NYROENV, $this->cfg->basicPrefixExec) &&
				in_array($this->prmExec['action'], $this->cfg->getInArray('basicPrefixExec', NYROENV)))
			$this->prmExec['prefix'] = ucfirst(NYROENV);
		else if ($this->cfg->prefixExec && !in_array($this->prmExec['action'], $this->cfg->noPrefixExec))
			$this->prmExec['prefix'] = $this->cfg->prefixExec;

		$this->beforeExec($prm);

		if (!$this->cfg->render)
			security::getInstance()->check($this->prmExec);

		$fctName = ($this->cfg->render? 'render' : 'exec').$this->prmExec['prefix'].ucfirst($this->prmExec['action']);
		if (!method_exists($this, $fctName))
			response::getInstance()->error();

		$this->setViewAction($this->prmExec['action']);

		$param = is_array($this->prmExec['paramA'])? $this->prmExec['paramA'] : request::parseParam($this->prmExec['param']);

		$tags = $this->cfg->cacheTags;
		$search = array('/', '<', '>');
		$replace = array('', '', '');
		if (is_array($this->prmExec['paramA']))
			foreach($this->prmExec['paramA'] as $k=>$v) {
				if (is_object($v)) {
					if (is_callable(array($v, '__toString')))
						$tags[] = $k.'='.$v;
					else
						$tags[] = $k.'='.get_class($v);
				} elseif (!is_numeric($k))
					$tags[] = $k.'='.str_replace($search, $replace, $v);
				else
					$tags[] = str_replace($search, $replace, $v);
			}

		$paramTpl = array();
		foreach($param as $k=>$v) {
			if (is_object($v)) {
				if (is_callable(array($v, '__toString')))
					$paramTpl[] = $k.'='.$v;
				else
					$paramTpl[] = $k.'='.get_class($v);
			} else
				$paramTpl[] = $k.':'.$v;
		}

		$conf = array(
			'layout'=>$this->cfg->layout,
			'module'=>$this->getName(),
			'action'=>$this->cfg->viewAction,
			'param'=>implode(',', $paramTpl),
			'cache'=>array_merge(array(
				'enabled'=>$this->isCacheEnabled(),
				'serialize'=>false,
				'tags'=>$tags,
				'request'=>array('uri'=>false, 'meth'=>array())
			), $this->cfg->cache)
		);
		$this->tpl = factory::get('tpl', array_merge_recursive($conf, $this->cfg->tplPrm));
		$this->tpl->getCfg()->layout = $this->cfg->layout;
		$this->tpl->getCfg()->module = $this->getName();
		$this->tpl->getCfg()->action = $this->cfg->viewAction;
		$this->tpl->getCfg()->default = $this->cfg->viewAction;
		
		$this->prmExec['callbackPrm'] = array(
			'fctName'=>$fctName,
			'fctNameParam'=>$param,
			'prm'=>$prm
		);
		$this->middleExec($prm);
	}
Exemplo n.º 5
0
 protected function execAdminLogout(array $prm = array())
 {
     security::getInstance()->logout();
     response::getInstance()->redirect(request::uri('/'));
 }
Exemplo n.º 6
0
<?php

if (security::getInstance()->isLogged()) {
    ?>
	<ul id="menu">
	<?php 
    if (isset($links)) {
        foreach ($links as $l => $name) {
            if ($name == 'hr') {
                echo '<li class="hr"><span></span></li>';
            } else {
                echo '<li><a href="' . $l . '">' . $name . '</a></li>';
            }
        }
    }
    if (isset($linksTable)) {
        foreach ($linksTable as $name => $l) {
            echo '<li><a href="' . $l . '">' . $name . '</a></li>';
        }
        echo '<li class="hr"><span></span></li>';
    }
    ?>
		<li><a href="<?php 
    echo security::getInstance()->getPage('logout', true);
    ?>
">D&eacute;connexion</a></li>
	</ul>
<?php 
}