Exemplo n.º 1
0
 public function sync($model)
 {
     $this->willRenderLayoutView = false;
     $this->willRenderActionView = false;
     $db = Framework\Registry::get("database");
     $db->sync(new $model());
 }
Exemplo n.º 2
0
 public static function total($user_id, $total)
 {
     $database = Framework\Registry::get("database");
     $totalPoints = $database->query()->from("points", array("SUM(unit)" => "points"))->where("user_id=?", $user_id)->all();
     $points = isset($totalPoints[0]["points"]) ? round($totalPoints[0]["points"]) : 0;
     return $points > $total ? $total : $points;
 }
Exemplo n.º 3
0
 function check_login()
 {
     $session = Framework\Registry::get('session');
     if ($session->get('user_id') != null) {
         return true;
     } else {
         return false;
     }
 }
Exemplo n.º 4
0
 function base_url($uri = '')
 {
     $config = Framework\Registry::get('config');
     $config = $config->parse('constant');
     $url = $config['constant']['base_url'];
     $url = rtrim($url, '/');
     $uri = trim($uri, '/');
     return $url . '/' . $uri;
 }
Exemplo n.º 5
0
 public function index()
 {
     $this->getLayoutView()->set("seo", Framework\Registry::get("seo"));
     $view = $this->getActionView();
     $limit = RequestMethods::get("limit", 10);
     $page = RequestMethods::get("page", 1);
     $items = Campaign::all(array("live = ?" => true), array("id", "live", "image", "title", "description"), "created", "desc", $limit, $page);
     $count = Campaign::count(array("live = ?" => true));
     $view->set("items", $items)->set("count", $count)->set("limit", $limit)->set("page", $page);
 }
Exemplo n.º 6
0
 function set_value($field = '', $default = '')
 {
     $input = Framework\Registry::get('input');
     if (!empty($input->post($field))) {
         $str = $input->post($field);
     } else {
         $str = $default;
     }
     $str = htmlspecialchars($str);
     return $str;
 }
Exemplo n.º 7
0
    }
    // 3. load and initialize the Configuration class
    $configuration = new Framework\Configuration(array("type" => "ini"));
    Framework\Registry::set("configuration", $configuration->initialize());
    // 4. load and initialize the Database class – does not connect
    $database = new Framework\Database();
    Framework\Registry::set("database", $database->initialize());
    // 5. load and initialize the Cache class – does not connect
    $cache = new Framework\Cache();
    Framework\Registry::set("cache", $cache->initialize());
    // 6. load and initialize the Session class
    $session = new Framework\Session();
    Framework\Registry::set("session", $session->initialize());
    // 7. load the Router class and provide the url + extension
    $router = new Framework\Router(array("url" => isset($_GET["url"]) ? $_GET["url"] : "home/index", "extension" => !empty($_GET["extension"]) ? $_GET["extension"] : "html"));
    Framework\Registry::set("router", $router);
    // include custom routes
    include "public/routes.php";
    // 8. dispatch the current request
    $router->dispatch();
    // 9. unset global variables
    unset($configuration);
    unset($database);
    unset($cache);
    unset($session);
    unset($router);
} catch (Exception $e) {
    // list exceptions
    $exceptions = array("500" => array("Framework\\Cache\\Exception", "Framework\\Cache\\Exception\\Argument", "Framework\\Cache\\Exception\\Implementation", "Framework\\Cache\\Exception\\Service", "Framework\\Configuration\\Exception", "Framework\\Configuration\\Exception\\Argument", "Framework\\Configuration\\Exception\\Implementation", "Framework\\Configuration\\Exception\\Syntax", "Framework\\Controller\\Exception", "Framework\\Controller\\Exception\\Argument", "Framework\\Controller\\Exception\\Implementation", "Framework\\Core\\Exception", "Framework\\Core\\Exception\\Argument", "Framework\\Core\\Exception\\Implementation", "Framework\\Core\\Exception\\Property", "Framework\\Core\\Exception\\ReadOnly", "Framework\\Core\\Exception\\WriteOnly", "Framework\\Database\\Exception", "Framework\\Database\\Exception\\Argument", "Framework\\Database\\Exception\\Implementation", "Framework\\Database\\Exception\\Service", "Framework\\Database\\Exception\\Sql", "Framework\\Model\\Exception", "Framework\\Model\\Exception\\Argument", "Framework\\Model\\Exception\\Connector", "Framework\\Model\\Exception\\Implementation", "Framework\\Model\\Exception\\Primary", "Framework\\Model\\Exception\\Type", "Framework\\Model\\Exception\\Validation", "Framework\\Request\\Exception", "Framework\\Request\\Exception\\Argument", "Framework\\Request\\Exception\\Implementation", "Framework\\Request\\Exception\\Response", "Framework\\Router\\Exception", "Framework\\Router\\Exception\\Argument", "Framework\\Router\\Exception\\Implementation", "Framework\\Session\\Exception", "Framework\\Session\\Exception\\Argument", "Framework\\Session\\Exception\\Implementation", "Framework\\Template\\Exception", "Framework\\Template\\Exception\\Argument", "Framework\\Template\\Exception\\Implementation", "Framework\\Template\\Exception\\Parser", "Framework\\View\\Exception", "Framework\\View\\Exception\\Argument", "Framework\\View\\Exception\\Data", "Framework\\View\\Exception\\Implementation", "Framework\\View\\Exception\\Renderer", "Framework\\View\\Exception\\Syntax"), "404" => array("Framework\\Router\\Exception\\Action", "Framework\\Router\\Exception\\Controller"));
    $exception = get_class($e);
    // attempt to find the approapriate template, and render
Exemplo n.º 8
0
    unset($cache);
    unset($session);
    unset($router);
    unset($httpRequest);
} catch (Exception $e) {
    // list exceptions
    $exceptions = array("500" => array("Framework\\Cache\\Exception", "Framework\\Cache\\Exception\\Argument", "Framework\\Cache\\Exception\\Implementation", "Framework\\Cache\\Exception\\Service", "Framework\\Configuration\\Exception", "Framework\\Configuration\\Exception\\Argument", "Framework\\Configuration\\Exception\\Implementation", "Framework\\Configuration\\Exception\\Syntax", "Framework\\Controller\\Exception", "Framework\\Controller\\Exception\\Argument", "Framework\\Controller\\Exception\\Implementation", "Framework\\Core\\Exception", "Framework\\Core\\Exception\\Argument", "Framework\\Core\\Exception\\Implementation", "Framework\\Core\\Exception\\Property", "Framework\\Core\\Exception\\ReadOnly", "Framework\\Core\\Exception\\WriteOnly", "Framework\\Database\\Exception", "Framework\\Database\\Exception\\Argument", "Framework\\Database\\Exception\\Implementation", "Framework\\Database\\Exception\\Service", "Framework\\Database\\Exception\\Sql", "Framework\\Model\\Exception", "Framework\\Model\\Exception\\Argument", "Framework\\Model\\Exception\\Connector", "Framework\\Model\\Exception\\Implementation", "Framework\\Model\\Exception\\Primary", "Framework\\Model\\Exception\\Type", "Framework\\Model\\Exception\\Validation", "Framework\\Request\\Exception", "Framework\\Request\\Exception\\Argument", "Framework\\Request\\Exception\\Implementation", "Framework\\Request\\Exception\\Response", "Framework\\Router\\Exception", "Framework\\Router\\Exception\\Argument", "Framework\\Router\\Exception\\Implementation", "Framework\\Session\\Exception", "Framework\\Session\\Exception\\Argument", "Framework\\Session\\Exception\\Implementation", "Framework\\Template\\Exception", "Framework\\Template\\Exception\\Argument", "Framework\\Template\\Exception\\Implementation", "Framework\\Template\\Exception\\Parser", "Framework\\View\\Exception", "Framework\\View\\Exception\\Argument", "Framework\\View\\Exception\\Data", "Framework\\View\\Exception\\Implementation", "Framework\\View\\Exception\\Renderer", "Framework\\View\\Exception\\Syntax"), "404" => array("Framework\\Router\\Exception\\Action", "Framework\\Router\\Exception\\Controller"));
    $exception = get_class($e);
    // attempt to find the approapriate template, and render
    foreach ($exceptions as $template => $classes) {
        foreach ($classes as $class) {
            if ($class == $exception) {
                if ($template == '404') {
                    Framework\Registry::get('httpRequest')->setResponseCode(\Framework\HttpRequest::HTTP_RESPONSE_NOT_FOUND)->createRequestHeader();
                } else {
                    Framework\Registry::get('httpRequest')->setResponseCode(\Framework\HttpRequest::HTTP_RESPONSE_INTERNAL_SERVER_ERROR)->createRequestHeader();
                }
                if (isset($logger_error)) {
                    $logger_error->log("[Exception] Code:" . $e->getCode() . ' Message:' . $e->getMessage());
                }
                include APP_PATH . "/application/views/errors/{$template}.php";
                exit;
            }
        }
    }
    // render fallback template
    if (isset($logger_error)) {
        $logger_error->log("[Exception] Code:" . $e->getCode() . ' Message' . $e->getMessage());
    }
    echo "An error occurred." . $e->getMessage();
    include APP_PATH . "/application/views/errors/error.php";
Exemplo n.º 9
0
 public function index()
 {
     $this->getLayoutView()->set("seo", Framework\Registry::get("seo"));
 }
Exemplo n.º 10
0
<?php

$apiContext = new \PayPal\Rest\ApiContext(new \PayPal\Auth\OAuthTokenCredential('<ClientID>', '<ClientSecret>'));
Framework\Registry::set("PayPalApiContext", $apiContext);
Exemplo n.º 11
0
<?php

// initialize Googl
include "googl.php";
$googl = new googl();
Framework\Registry::set("googl", $googl);
Exemplo n.º 12
0
        $doc = new GoogleDOM($this->param("q"), $this->getUrl(), $this->getPage(), $this->param(self::PARAM_NBRESULTS));
        libxml_use_internal_errors(TRUE);
        $doc->loadHTML($r);
        libxml_use_internal_errors(FALSE);
        libxml_clear_errors();
        if ($doc->isCaptcha()) {
            throw new \GoogleUrl\Exception\CaptachaException();
        }
        return $doc;
    }
    /**
     * get the generated url
     * @return string the generated url
     */
    public function getUrl()
    {
        return $this->__toString();
    }
    /**
     * Same as gerUrl
     * @return string the generated url
     */
    public function __toString()
    {
        $url = "https://www.google." . $this->tld . "/search?" . http_build_query($this->googleParams);
        return $url;
    }
}
$googleUrl = new GoogleUrl();
Framework\Registry::set("googleScrape", $googleUrl);
unset($googleUrl);
Exemplo n.º 13
0
 public function sync($model)
 {
     $this->noview();
     $db = Framework\Registry::get('database');
     $db->sync(new $model());
 }
Exemplo n.º 14
0
        $headers = '';
        foreach ($_SERVER as $name => $value) {
            if (substr($name, 0, 5) == 'HTTP_') {
                $headers[str_replace(' ', '-', ucwords(strtolower(str_replace('_', ' ', substr($name, 5)))))] = $value;
            }
        }
        return $headers;
    }
}
// 2. load the Core class that includes an autoloader
require_once APP_PATH . "/framework/core.php";
Framework\Core::initialize();
// plugins
$path = APP_PATH . "/application/plugins";
$iterator = new DirectoryIterator($path);
// 3. load and initialize the Configuration class
$configuration = new Framework\Configuration(array("type" => "ini"));
Framework\Registry::set("configuration", $configuration->initialize());
// 4. load and initialize the Database class – does not connect
$database = new Framework\Database();
Framework\Registry::set("database", $database->initialize());
// 5. load and initialize the Cache class – does not connect
$cache = new Framework\Cache();
Framework\Registry::set("cache", $cache->initialize());
// 6. load and initialize the Session class
$session = new Framework\Session();
Framework\Registry::set("session", $session->initialize());
unset($configuration);
unset($database);
unset($cache);
unset($session);
Exemplo n.º 15
0
<?php

$client_id = '<Client Id>';
$client_secret = '<Client Secret>';
$redirect_uri = 'http://trafficmonitor.ca/webmaster/authenticate';
$client = new Google_Client();
$client->setClientId($client_id);
$client->setClientSecret($client_secret);
$client->setRedirectUri($redirect_uri);
$client->setScopes('https://www.googleapis.com/auth/webmasters');
Framework\Registry::set("gClient", $client);
Exemplo n.º 16
0
$config = new Framework\Config(array('type' => 'ini'));
Framework\Registry::set('config', $config->initialize());
unset($config);
// load functions
$functions = new Framework\Functions();
Framework\Registry::set('functions', $functions->initialize());
unset($functions);
// load session
$session = new Framework\Session();
Framework\Registry::set('session', $session);
unset($session);
// load cookie
$cookie = new Framework\Cookie();
Framework\Registry::set('cookie', $cookie);
unset($cookie);
$input = new Framework\Input();
Framework\Registry::set('input', $input);
unset($input);
$validator = new Framework\Validator();
Framework\Registry::set('validator', $validator);
unset($validator);
// load database
$database = new Framework\Database();
Framework\Registry::set('database', $database->initialize());
unset($database);
// load router
$router = new Framework\Router();
Framework\Registry::set('router', $router);
unset($router);
Framework\Registry::get('router')->dispatch();
Exemplo n.º 17
0
<?php

// initialize seo
include "seo.php";
$seo = new SEO(array("title" => "A Smarter Performance Marketing Network", "photo" => CDN . "img/logo.png"));
Framework\Registry::set("seo", $seo);
Exemplo n.º 18
0
<?php

$database = new Framework\Database(array("type" => "mysql", "options" => array("host" => "localhost", "username" => "prophpmvc", "password" => "prophpmvc", "schema" => "prophpmvc")));
$database = $database->initialize();
$database = $database->connect();
Framework\Registry::set("database", $database);
class Example extends Framework\Model
{
    /**
     * @readwrite
     * @column
     * @type autonumber
     * @primary
     */
    protected $_id;
    /**
     * @readwrite
     * @column
     * @type text
     * @length 32
     */
    protected $_name;
    /**
     * @readwrite
     * @column
     * @type datetime
     */
    protected $_created;
}
Framework\Test::add(function () use($database) {
    $example = new Example();