public function execute()
 {
     $session = \Libs\Session::current();
     // Include debug info:
     $session->actors()->{'info'} = 'Actors\\Info';
     parent::execute();
 }
 public function execute()
 {
     $session = \Libs\Session::current();
     $session->headers()->{'content-type'} = 'application/xml';
     $session->actors()->{'create'} = 'Actors\\Create';
     parent::execute();
 }
 public function checkLoginCaptcha($params)
 {
     //Si esta autenticado redireccionar a la vista Principal del sitio y el captcha coincide con el generado
     if (Session::getValue('captcha') == $params['captcha']) {
         if (AuthenticationUtils::login($params['username'], $params['password'])) {
             header('Location: ' . URL_BASE . "/index.php/Index/index");
         }
         header('Location: ' . URL_BASE . "/index.php/Authentication/showLoginWithCaptcha");
     }
     header('Location: ' . URL_BASE . "/index.php/Authentication/showLoginWithCaptcha");
 }
    public function execute(\Libs\DOM\Element $element)
    {
        parent::execute($element);
        $session = \Libs\Session::current();
        $db = $session->app()->database();
        $id = trim(isset($session->parameters()->{'data'}) ? $session->parameters()->{'data'} : '');
        // Ignore null values:
        if ($id == '') {
            exit;
        }
        // Lookup the URL of the id:
        $query = '
				SELECT url
				FROM urls
				WHERE id = "%s"
				LIMIT 1
			';
        $data = $db->query($query, $id);
        // Redirect home if the URL doesn't exist:
        if ($data === false) {
            header('Location: ' . SERVER_URL);
            exit;
        }
        // Increment the number of hits for this id:
        $query = '
				UPDATE urls
				SET hits = 1 + (
						SELECT hits
						FROM urls
						WHERE id = "%1$s"
					)
				WHERE id = "%1$s"
			';
        $db->exec($query, $id);
        // Record this hit:
        $address = isset($_SERVER['REMOTE_ADDR']) ? $_SERVER['REMOTE_ADDR'] : '';
        $referrer = isset($_SERVER['HTTP_REFERER']) ? $_SERVER['HTTP_REFERER'] : '';
        $agent = isset($_SERVER['HTTP_USER_AGENT']) ? $_SERVER['HTTP_USER_AGENT'] : '';
        $query = '
				INSERT INTO hits (
					id, address, timestamp, referrer, agent
				)
				VALUES (
					"%s", "%s", "%s", "%s", "%s"
				)
			';
        $db->exec($query, $id, $address, gmdate('U'), $referrer, $agent);
        // Make sure the URL begins with a protocol:
        if (!preg_match('%^(https?|ftp)://%', $data->url)) {
            $data->url = 'http://' . $data->url;
        }
        // Redirect to the URL:
        header('Location: ' . $data->url);
    }
 public function execute(\Libs\DOM\Element $element)
 {
     parent::execute($element);
     $session = \Apps\Debug\App::$session;
     $document = \Libs\Session::view()->document();
     $input = $document->createElement('input', $session->view()->document()->saveXML());
     $output = $document->createElement('output', $session->view()->output());
     $element->appendChild($input);
     $element->appendChild($output);
     //echo '<pre>', htmlentities($element->saveXML()); exit;
 }
Exemple #6
0
 public function save()
 {
     $petOwner = new PetOwner();
     $petOwner->setUsername(Session::get('username'));
     $petOwner->setEmail(Session::get('email'));
     $petOwner->setPassword(Session::get('password'));
     $petFactory = new PetFactory(Session::get('planet'), $_POST['kind']);
     $pet = $petFactory->createPet();
     // Usar transação
     DAO::on('PetOwner')->save($petOwner);
     // DAO::on('Pet')->insert($pet);
     header('Location: ' . URL . 'login/run');
 }
 public function generateCaptcha($w = 350, $h = 60)
 {
     unlink(getcwd() . "/public/uploads/captcha.png");
     Session::setValue('captcha', self::texto());
     $captcha = \imagecreatetruecolor($w, $h);
     $colorFondo = \imagecolorallocate($captcha, 0, 0, 255);
     $colorTexto = \imagecolorallocate($captcha, 255, 255, 0);
     $colorLinea = \imagecolorallocate($captcha, 255, 105, 180);
     \imageline($captcha, 120, 39, 250, 39, $colorLinea);
     \imageline($captcha, 120, 45, 250, 45, $colorLinea);
     \imageline($captcha, 120, 50, 250, 50, $colorLinea);
     \imagestring($captcha, 5, 150, 35, Session::getValue('captcha'), $colorTexto);
     imagepng($captcha, getcwd() . "/public/uploads/captcha.png");
     imagedestroy($captcha);
 }
 public function __set($name, $value)
 {
     if (!$value instanceof \Libs\Actor) {
         // Relative to current App:
         if (strpos($value, '\\') !== 0) {
             $app = \Libs\Session::current()->app();
             $dir = $app->dir();
             $namespace = $app->namespace();
             $file = sprintf('%s/%s.php', $dir, strtr($value, '\\_', '/.'));
             $class = sprintf('\\%s\\%s', $namespace, $value);
             require_once $file;
             $value = $class::instance();
         }
     }
     $this->values[$name] = $value;
     $this->iterator = new \ArrayIterator($this->values);
 }
Exemple #9
0
 function run()
 {
     $sth = $this->db->prepare("SELECT userid, role FROM user WHERE \n\t\t\tusername = :username AND password = :password");
     $sth->execute(array(':username' => $_POST['username'], ':password' => \Libs\Hash::create('sha256', $_POST['password'], HASH_PASSWORD_KEY)));
     $data = $sth->fetch();
     $count = $sth->rowCount();
     if ($count > 0) {
         // login
         \Libs\Session::init();
         \Libs\Session::set('role', $data['role']);
         \Libs\Session::set('loggedIn', true);
         \Libs\Session::set('userid', $data['userid']);
         header('location: ../dashboard');
     } else {
         header('location: ../login');
     }
 }
 public function execute()
 {
     $session = \Libs\Session::current();
     // Create sub session to render the request:
     $simulate = \Libs\Session::open();
     // Copy Apps:
     foreach ($session->apps() as $key => $app) {
         if ($app instanceof \Apps\Debug\App) {
             continue;
         }
         $simulate->registerApp($app);
         unset($session->apps()->{$key});
     }
     foreach ($session->instances() as $key => $value) {
         if ($value instanceof \Apps\Debug\App) {
             continue;
         }
         if ($value instanceof \Apps\Debug\Views\Main) {
             continue;
         }
         $simulate->instances()->{$key} = $value;
         unset($session->instances()->{$key});
     }
     // Copy parameters:
     foreach ($session->parameters() as $key => $value) {
         if ($key == 'debug') {
             continue;
         }
         $simulate->parameters()->{$key} = $value;
     }
     // Execute session:
     $simulate->execute();
     $simulate->render();
     self::$session = $simulate;
     \Libs\Session::close($simulate);
     // Continue with main session:
     parent::execute();
 }
    public function execute(\Libs\DOM\Element $element)
    {
        parent::execute($element);
        $session = \Libs\Session::current();
        $document = $session->view()->document();
        $db = $session->app()->database();
        $url = trim(isset($session->parameters()->{'data'}) ? $session->parameters()->{'data'} : '');
        // Ignore null values:
        if ($url == '') {
            exit;
        }
        // Make sure the URL begins with a protocol:
        if (!preg_match('%^(https?|ftp)://%', $url)) {
            $url = 'http://' . $url;
        }
        // Lookup the id of an existing URL:
        $query = '
				SELECT id
				FROM urls
				WHERE url = "%s"
				LIMIT 1
			';
        $data = $db->query($query, $url);
        // No id found, create a new one:
        if ($data === false) {
            $generate = function () {
                return base_convert(rand(46656, 1679615), 10, 36);
            };
            // Get current timestamp in GMT:
            $timestamp = gmdate('U');
            // Create a random 4 character string:
            $id = $generate();
            $query = '
					SELECT COUNT(*) == 0 as `count`
					FROM urls
					WHERE id = "%s"
					LIMIT 1
				';
            // Make sure the ID is not in use:
            while (true) {
                $taken = $db->query($query, $id);
                if ($taken->count) {
                    break;
                }
                $id = $generate();
            }
            // Write new URL to database:
            $query = '
					INSERT INTO urls (
						id, url, timestamp, hits
					)
					VALUES (
						"%s", "%s", "%s", 0
					)
				';
            $db->exec($query, $id, $url, $timestamp);
        } else {
            $id = $data->id;
        }
        $element->setAttribute('id', $id);
    }
 public static function logout()
 {
     $con = DBConexion::getInstance();
     $query = vsprintf("DELETE FROM sesion WHERE session_id='%s' AND session_data = '%s';", array(self::getCookie('session_id'), self::getCookie('token')));
     $res = $con->executeUpdate(array($query));
     //Cerrando conexion con BD
     $con->destroy();
     //Destruyendo los valores guardados en la cookie.
     self::deleteCookie('session_id');
     self::deleteCookie('token');
     unset($_COOKIE);
     $_COOKIE = array();
     //Destruyendo la sesion de las cookies del navegador y la sesion como tal
     Session::destroy();
     self::$arrUsuario = array();
 }
Exemple #13
0
 public function play(\Libs\Toy $toy)
 {
     // Test
     echo 'Playing with... ' . get_class($toy);
     $this->stress -= 5;
     Session::set('pet', $this);
     header('Location: ' . URL . 'pet/index');
     exit;
     $placid = $kind->playWithToy($toy);
     // new Ball
     $this->setStress($placid);
 }
 public function execute()
 {
     $session = \Libs\Session::current();
     $session->actors()->{'create'} = 'Actors\\Redirect';
     parent::execute();
 }
Exemple #15
0
 public function run()
 {
     $pet = DAO::on('Pet')->findById(1);
     Session::set('pet', $pet);
     header('Location: ' . URL . 'pet/index');
 }
Exemple #16
0
 public function logout()
 {
     Session::destroy();
     header('Location: ' . URL . 'index');
 }
Exemple #17
0
if (\Libs\Session::get('loggedIn') == true) {
    ?>
		<a href="<?php 
    echo URL;
    ?>
dashboard">Dashboard</a>	
		<a href="<?php 
    echo URL;
    ?>
note">Notes</a>	
		<a href="<?php 
    echo URL;
    ?>
image">Image</a>	
		<?php 
    if (\Libs\Session::get('role') == 'owner') {
        ?>
			<a href="<?php 
        echo URL;
        ?>
user">Users</a>	
		<?php 
    }
    ?>
		<a href="<?php 
    echo URL;
    ?>
dashboard/logout">Logout</a>	
	<?php 
} else {
    ?>
Exemple #18
0
 function logout()
 {
     \Libs\Session::destroy();
     header('location: ' . URL . 'login');
     exit;
 }