public function get_json()
 {
     if (Registry::getConfig('DEBUG')) {
         return array('message' => $this->message, 'exception_message' => $this->e_message, 'trace' => $this->trace);
     } else {
         return array('message' => $this->message);
     }
 }
 /**
  * Create a Data Map
  * 
  * @param string $connection [optional] database connection info
  * @param string $username   [optional] username to connect with
  * @param string $password   [optional] password to connect with
  */
 public function __construct($connection = null, $username = null, $password = null)
 {
     $this->registry = Registry::getInstance();
     // take conn and credentials from config, unless overriden in constructor
     if ($connection == null) {
         $connection = $this->registry->getConfig("DATABASE_CONNECTION", true);
     }
     if ($username == null) {
         $username = $this->registry->getConfig("DATABASE_USERNAME", true);
     }
     if ($password == null) {
         $password = $this->registry->getConfig("DATABASE_PASSWORD", true);
     }
     // assign it
     $this->connection = $connection;
     $this->username = $username;
     $this->password = $password;
 }
Beispiel #3
0
 /**
  * Returns escaped value of parameter stored in POST,GET.
  *
  * @param string $name         Name of parameter.
  * @param string $defaultValue Default value if no value provided.
  *
  * @return mixed
  */
 public function getRequestEscapedParameter($name, $defaultValue = null)
 {
     $value = $this->getRequestParameter($name, $defaultValue);
     // TODO: remove this after special chars concept implementation
     $isAdmin = Registry::getConfig()->isAdmin() && Registry::getSession()->getVariable("blIsAdmin");
     if ($value !== null && !$isAdmin) {
         $this->checkParamSpecialChars($value);
     }
     return $value;
 }
Beispiel #4
0
 public function index()
 {
     $config = Registry::getConfig();
     $pag['total'] = 0;
     $pag['limit'] = $_REQUEST['limit'] ? $_REQUEST['limit'] : $config->get("defaultLimit");
     $pag['limitStart'] = $_REQUEST['limitStart'];
     $this->setData("results", User::select($_REQUEST, $pag['limit'], $pag['limitStart'], $pag['total']));
     $this->setData("pag", $pag);
     $html = $this->view("views.list");
     $this->render($html);
 }
Beispiel #5
0
 /**
  * @return string
  */
 public static function generate()
 {
     $length = OptinCodeGenerator::DEFAULT_CODE_LENGTH;
     $config = Registry::getConfig();
     $optinConfig = $config->get('optin');
     if ($optinConfig) {
         $length = Registry::getConfig()->optin->code->length;
     }
     $randomCharacters = str_split(md5(mt_rand(0, 200000) . microtime(true)));
     $mergedCharacters = array_merge($randomCharacters, range('a', 'z'));
     shuffle($mergedCharacters);
     return substr(implode('', $mergedCharacters), 0, $length);
 }
Beispiel #6
0
 public function index()
 {
     //Remember filters
     if (!$_REQUEST['fresh']) {
         rememberFilter('search');
         rememberFilter('limit');
         rememberFilter('limitStart');
         rememberFilter('order');
         rememberFilter('orderDir');
     }
     $config = Registry::getConfig();
     $pag['total'] = 0;
     $pag['limit'] = $_REQUEST['limit'] ? $_REQUEST['limit'] : $config->get("defaultLimit");
     $pag['limitStart'] = $_REQUEST['limitStart'];
     $this->setData("results", Entrada::select($_REQUEST, $pag['limit'], $pag['limitStart'], $pag['total']));
     $this->setData("pag", $pag);
     $html = $this->view("views.list");
     $this->render($html);
     //Log
     Log::add(LOG_LISTAR_ENTRADA);
 }
 /**
  * Check whether or not an installation is required 
  * 
  * @return boolean
  */
 public static function required()
 {
     $query = new DBQuery("SHOW TABLES IN " . Registry::getConfig('DB_DATABASE'));
     $query->execute();
     $tables_in_db = array();
     while ($row = $query->rowNotAssoc()) {
         $tables_in_db[] = $row[0];
     }
     foreach (self::$required_tables as $table => $statement) {
         if (!in_array($table, $tables_in_db)) {
             return true;
         }
     }
     // Count number of users in database
     $query = new DBQuery("SELECT COUNT(*) AS `NumRows` FROM `users`");
     $query->execute();
     $row = $query->row();
     // If no users, offer installation
     if ($row['NumRows'] == 0) {
         return true;
     }
     return false;
 }
Beispiel #8
0
<?php

defined('_EXE') or die('Restricted access');
?>

<!-- Debugging Modals -->
<?php 
$config = Registry::getConfig();
if ($config->get("debug")) {
    ?>
    <?php 
    $debug = Registry::getDebug();
    ?>
    <!-- Current Queries Debug Modal -->
    <?php 
    $controller->setData("debug", $debug);
    ?>
    <?php 
    $controller->setData("debugModalId", "Current");
    ?>
    <?php 
    echo $controller->view("modules.debug.modalQueries");
    ?>
    <!-- Previous Queries Debug Modal -->
    <?php 
    if ($_SESSION['debug']['queries']) {
        ?>
        <?php 
        $controller->setData("debug", $_SESSION['debug']);
        ?>
        <?php 
Beispiel #9
0
 /**
  * Logout
  *
  * @return bool
  */
 public static function logout()
 {
     $config = Registry::getConfig();
     //Destroy Cookies
     unset($_COOKIE[$config->get("cookie")]);
     setcookie($config->get("cookie"), null, -1, "/");
     //Log
     Log::add(LOG_LOGOUT);
     return true;
 }
Beispiel #10
0
 public function __construct(Registry $registry)
 {
     $this->config = $registry->getConfig();
     $this->registry = $registry;
 }