Ejemplo n.º 1
0
<?php

// Copyright (c) 2010 Guanoo, Inc.
//
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public License
// as published by the Free Software Foundation; either version 3
// of the License, or (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Lesser General Public License for more details.
load_interface('SQL_connector');
/**
 * Connect to a SQLite2 database via the older SQLite PHP extension.
 *
 * @author Kevin Hutchinson <*****@*****.**>
 */
class Data_SQLite2 extends YAWF implements SQL_connector
{
    const SQLITE_FILE_PERMISSIONS = 0666;
    // everyone can read and write
    private $sqlite_db;
    /**
     * Create a new Data_SQLite2 object
     *
     * @param Array $options not used by SQLite (optional)
     */
    public function __construct($options = array())
    {
Ejemplo n.º 2
0
<?php

// Copyright (c) 2010 Guanoo, Inc.
//
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public License
// as published by the Free Software Foundation; either version 3
// of the License, or (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Lesser General Public License for more details.
load_interface('Mailer');
/**
 * The Request class provides Controller and Service objects with
 * access to form and query parameters, cookies, the web session
 * and the web server environment. It also makes the app language
 * available, and the requested content type and HTTP method.
 *
 * @author Kevin Hutchinson <*****@*****.**>
 */
class Request extends YAWF implements Mailer
{
    /**
     * A mapping of request content types to file types
     */
    private static $request_types = array('text/xml' => Symbol::XML, 'text/html' => Symbol::HTML, 'text/plain' => Symbol::TXT, 'text/yaml' => Symbol::YAML, 'text/json' => Symbol::JSON, 'text/jsonp' => Symbol::JSON, 'text/javascript' => Symbol::JSON, 'text/serialized' => Symbol::SERIALIZED, 'application/json' => Symbol::JSON, 'application/jsonp' => Symbol::JSON, 'application/javascript' => Symbol::JSON, 'application/serialized' => Symbol::SERIALIZED, 'application/x-javascript' => Symbol::JSON, 'application/xml' => Symbol::XML, 'application/yaml' => Symbol::YAML);
    protected $app;
    // either the "App" or the "App_test" object
    protected $params;
Ejemplo n.º 3
0
<?php

// Copyright (c) 2010 Guanoo, Inc.
//
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public License
// as published by the Free Software Foundation; either version 3
// of the License, or (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Lesser General Public License for more details.
load_interface('Modelled');
/**
 * The Simple_model class provides a foundation class from which
 * to build your own model classes using alternative data stores.
 *
 * @author Kevin Hutchinson <*****@*****.**>
 */
class Simple_model extends YAWF implements Modelled
{
    /**
     * The $data Array holds data fields and values for the simple model object
     */
    protected $data;
    /**
     * The $changed Array holds data fields whose values have been changed
     */
    protected $changed;
    /**
Ejemplo n.º 4
0
<?php

/* A class handling forms */
namespace controllers;

load_interface('form');
class form implements \iform
{
    protected $elements = array();
    // the vars inside the global variable
    protected $errors = array();
    // all the errors
    protected $type;
    // the type of form get/post
    protected $upload_handler = NULL;
    // if something is expected to be uploaded, this object will take care of it
    protected $constructor = array('init' => NULL, 'valid' => NULL, 'error' => NULL);
    protected $escapes = true;
    // protection against XSS
    const POST = 'POST';
    const GET = 'GET';
    const VALID = 'valid';
    const INIT = 'init';
    const ERROR = 'error';
    public function __construct($type = \controllers\form::POST)
    {
        $this->type = $type;
    }
    public function toggle_security($t = false)
    {
        $this->escapes = false;
Ejemplo n.º 5
0
<?php

/* A pattern is something that'll be compared to the url, and if matching will return files needed to be loaded */
namespace routing;

load_interface('pattern');
class pattern implements \ipattern
{
    protected $regex = array();
    // the regulars expression that'll be used
    protected $permission;
    // options concerning the regular expressions comparaison
    protected $get_options = array();
    // options for the gets
    protected $override_default_files = false;
    // decides whether the default files have to be loaded
    public $handler;
    // the handler for constructors
    public function __construct()
    {
        $this->handler = new \handling\constructors\handler();
    }
    public function set_override($v = true)
    {
        $this->override_default_files = $v;
    }
    public function add_permission($p)
    {
        $this->permissions[] = $p;
    }
    public static function option($permission = false, $pattern = false)
Ejemplo n.º 6
0
<?php

/* A module is a piece of the application */
namespace modules;

load_interface('model');
load_interface('view');
class module
{
    public $view;
    // the view
    public $model;
    // the model
    protected $model_result = array();
    // the result of the model
    protected $actions = array('model' => 'exec', 'view' => 'exec');
    // the method if the view and model are objects
    protected $name;
    // the directory name
    protected $path;
    // the path to the module's dir
    public function __construct($name, $path)
    {
        $this->name = $name;
        $this->path = $path;
    }
    public function set_couple($model, $view, $actions = array())
    {
        $this->model = $model;
        $this->view = $view;
        $this->actions = $actions;
Ejemplo n.º 7
0
<?php

/* A route is something that loads a module according to parameters */
namespace routing\routes;

load_interface('route');
class route implements \iroute
{
    protected $name;
    // the module's name, the directory in which its files are in
    protected $path;
    // the path to the module's name
    protected $patterns = array();
    // the patterns
    protected $first_pattern = false;
    // the first pattern, if one
    public $handler;
    // the handler for the constructor
    public function __construct($name, $path)
    {
        $this->name = $name;
        $this->path = $path;
        $this->create_object();
        $this->handler = new \handling\constructors\handler();
        $this->handler->default->set_name($name);
    }
    public function set_first_pattern($f)
    {
        $this->first_pattern = $f;
    }
    public function add_pattern($pattern)
Ejemplo n.º 8
0
<?php

/* Everything you need is here */
include_once 'config.php';
include_once 'helpers/loaders.php';
load_helper('dirs');
load_interface('cachable');
$journal = new \handling\log\journal(LOG_DIRECTORY, LOG);
//set_error_handler(function($error,$message,$file,$line,$context){
//  \handling\log\journal::write_error_message($error,$message,$file,$line,$context);}); // using this function to write errors