Example #1
0
 public function testGetEnvironmentWithValidPath()
 {
     $path = $this->getMockPath();
     $mockEnvironment = "development";
     file_put_contents($path . "/.env", "ENVIRONMENT={$mockEnvironment}");
     $environment = $this->config->getEnvironment($path);
     $this->assertEquals($mockEnvironment, $environment);
 }
 /**
  * Create a new Controller instance.
  */
 public function __construct()
 {
     // Setup the used Template to default, if it is not already defined.
     if (!isset($this->template)) {
         $this->template = Config::get('app.template');
     }
 }
Example #3
0
 public function __construct($lang, $defaultLang)
 {
     if (empty($lang)) {
         $lang = CookieStorage::get('locale', Config::getDefaultLang());
     }
     $this->lang = $lang;
     $this->defaultLang = $defaultLang;
 }
 private function __construct()
 {
     $this->errorLevel = Config::getErrorLoggingLevel();
     $this->errorRender = Config::isErrorRender();
     $this->errorFileLogging = Config::isErrorFileLogging();
     set_error_handler(array($this, 'handleError'));
     register_shutdown_function(array($this, 'handleFatalError'));
 }
Example #5
0
 /**
  * Initializes, only the 1st instance, the static $customFields for this entity.
  * 
  * @return void
  */
 public function __construct()
 {
     if (!empty(self::$customFieldsConfig)) {
         return;
     }
     $config = Config::get('custom_fields');
     self::$customFieldsConfig = $config[self::CUSTOM_FIELDS_CONFIG_KEY];
 }
 /**
  * Create a new URL Generator instance.
  *
  * @param  \Routing\RouteCollection  $routes
  * @param  \Symfony\Component\HttpFoundation\Request   $request
  * @return void
  */
 public function __construct(RouteCollection $routes, Request $request)
 {
     $this->routes = $routes;
     $this->setRequest($request);
     // Wheter or not are used the Unnamed Parameters.
     if ('unnamed' == Config::get('routing.parameters', 'named')) {
         $this->legacyRouting = true;
     }
 }
Example #7
0
 private static function connect()
 {
     self::$instance = new self();
     $config = Config::getInstance();
     self::$instance = new \Mongo("mongodb://" . $config['db_host'] . ":" . $config['db_port'] . "/" . $config['db_database']);
     if (!self::$instance) {
         throw new \RuntimeException("Ошибка подключения к базе данных: ");
     }
 }
 /**
  * Static method get
  *
  * @param  array $group
  * @return Helpers\Database
  */
 public static function get($name = null)
 {
     $name = $name ?: Config::get('database.default');
     // Check if the instance is the same.
     if (isset(self::$instances[$name])) {
         return self::$instances[$name];
     }
     // Set the Database into $instances to avoid any potential duplication.
     return self::$instances[$name] = new static($name);
 }
Example #9
0
 public static function connect()
 {
     self::$instance = new self();
     $config = Config::getInstance();
     self::$instance->connection = mysqli_connect($config->get('host'), $config->get('username'), $config->get('password'), $config->get('database'));
     if (!self::$instance->connection) {
         throw new \RuntimeException("Ошибка подключения к базе данных: " . mysqli_error(self::$instance->connection));
     }
     return self::$instance;
 }
 public static function process($fetch = false)
 {
     $config = Config::get('profiler');
     if ($config['useForensics'] != true) {
         return null;
     }
     // The QuickProfiller was enabled into Configuration.
     $profiler = new static();
     return $profiler->display($fetch);
 }
 /**
  * Change the Framework Language.
  */
 public function change($language)
 {
     $languages = Config::get('languages');
     // Only set language if it's in the Languages array
     if (preg_match('/[a-z]/', $language) && in_array($language, array_keys($languages))) {
         Session::set('language', $language);
         // Store the current Language in a Cookie lasting five years.
         Cookie::queue(PREFIX . 'language', $language, Cookie::FIVEYEARS);
     }
     return Redirect::back();
 }
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $error = false;
     $path = Config::get('cache.path', 'app/Storage/Cache');
     if (!is_dir($path)) {
         $output->writeln("<error>Cache directory does not exist. path: {$path}</>");
         $error = true;
     }
     self::cleanCache($path);
     $output->writeln("<info>Cache directory has been cleaned. path: {$path}</>");
 }
Example #13
0
 /**
  * create connection
  */
 public function __construct()
 {
     if (is_null(self::$_connection)) {
         try {
             $dbConfig = Config::getConfig()['database'];
             self::$_connection = new ExtendedPdo("mysql:host={$dbConfig['host']};dbname={$dbConfig['database']};port={$dbConfig['port']}", $dbConfig['user'], $dbConfig['pass']);
             self::$_connection->connect();
         } catch (\Exception $e) {
             Log::addError($e->getMessage(), 'db connection');
         }
     }
 }
Example #14
0
 /**
  * Constructor.
  *
  * @param string $db
  * @param string $table
  */
 public function __construct($db, $table = '')
 {
     $this->boolDebug = Config::getGeneralSettings('on_error_print_queries');
     $this->dbConfig = Config::getDbSettings();
     $this->connection = null;
     $this->isConnected = false;
     $this->table = $table;
     $this->dbDriver = $this->dbConfig[$db]['db_driver'];
     $this->bindParamsMap = array();
     $this->paramsMapCounter = 0;
     $this->db = $db;
 }
 /**
  * Register the Assets Dispatcher.
  */
 public function registerAssetsDispatcher()
 {
     // NOTE: When this method is executed, the Config Store is not yet available.
     $driver = Config::get('routing.assets.driver', 'default');
     if ($driver == 'custom') {
         $className = Config::get('routing.assets.dispatcher');
     } else {
         $className = 'Routing\\Assets\\' . ucfirst($driver) . 'Dispatcher';
     }
     // Bind the calculated class name to the Assets Dispatcher Interface.
     $this->app->bind('Routing\\Assets\\DispatcherInterface', $className);
 }
Example #16
0
 /**
  * getRedis [reids实例]
  * @author wangzhiqiang
  * @param int $id
  * @return mixed
  */
 public function getRedis($id = 0)
 {
     if (empty($this->redis[$id]) || !$this->redis[$id]->info()) {
         $this->redis[$id] = new \Redis();
         $config = Config::get_redis_config();
         $res = $this->redis[$id]->connect($config['host'], $config['port']);
         $this->redis[$id]->auth($config['password']);
         $this->redis[$id]->select($id);
         if (!$res) {
         }
     }
     return $this->redis[$id];
 }
Example #17
0
 /**
  * Task of this constructor is to check, whether all necessary properties are set in data storage,
  * (if not - set them). Properties should be specific for this current user
  * (initially they default to those of default user)
  */
 public function __construct($pwd)
 {
     parent::__construct();
     if (is_string($pwd) && !empty($pwd)) {
         $this->userPwd = $pwd;
     }
     /// Now we should check, if userdata already exists in Redis. If not - write it there
     $redisDataProvider = new RedisDataProvider($this);
     $existsMapper = new RedisExistsMapper($this->userPwd . '_' . 'init');
     $val = $redisDataProvider->exists($existsMapper);
     if (1 !== intval($val)) {
         /// write client data
     }
 }
Example #18
0
 public function __construct()
 {
     try {
         $nameDB = Config::getInstance()->get('name');
         $hostDB = Config::getInstance()->get('host');
         $user = Config::getInstance()->get('user');
         $pass = Config::getInstance()->get('pass');
         $argument = sprintf("mysql:dbname=%s;host=%s;", $nameDB, $hostDB);
         $this->conn = new \PDO($argument, $user, $pass);
     } catch (PDOException $e) {
         print "¡Error!: " . $e->getMessage() . "<br/>";
         die;
     }
 }
 public function index($token)
 {
     if ($this->token != $token) {
         return Response::make('', 403);
         // Error 403 (Access denied)
     }
     // Get the execution date and time as translated string.
     $format = __d('system', '%d %b %Y, %R');
     $date = Carbon::now()->formatLocalized($format);
     // Execute the CRON tasks.
     $result = $this->executeCron();
     // Create the page information.
     $title = __d('system', '{0} - Cron executed on {1}', Config::get('app.name'), $date);
     return $this->getView()->with('title', $title)->with('content', $result);
 }
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $error = false;
     $path = Config::get('session.files', 'app/Storage/Sessions');
     if ($input->getArgument('lifeTime')) {
         $lifeTime = $input->getArgument('lifeTime');
     } else {
         $lifeTime = Config::get('session.lifetime', 180);
     }
     if (!is_dir($path)) {
         $output->writeln("<error>Session directory does not exist. path: {$path}</>");
         $error = true;
     }
     self::clearSessions($path, $lifeTime);
     $output->writeln("<info>The sessions have been cleared. Lifetime: {$lifeTime}, path: {$path}</>");
 }
Example #21
0
 public function add_forecast()
 {
     $api = new \models\ApiModel();
     $towns = $api->getCities();
     $config = \config\Config::getInstance();
     $db = new \Mongo("mongodb://" . $config['db_host'] . ":" . $config['db_port'] . "/" . $config['db_database']);
     $collection = $db->selectCollection('ngs', 'forecasts');
     foreach ($towns as $town) {
         $decoded = $api->getForecast($town['name']);
         foreach ($decoded['forecasts'] as $forecasts) {
             foreach ($forecasts['hours'] as $hours) {
                 if ($hours['hour'] == '12') {
                     $mas = array('temperature' => $hours['temperature']['avg'], 'pressure' => $hours['pressure']['avg'], 'humidity' => $hours['humidity']['avg'], 'wind' => array('speed' => $hours['wind']['speed']['avg'], 'direction' => $hours['wind']['direction']['title']), 'cloud' => $hours['cloud']['title'], 'precipitation' => $hours['precipitation']['title']);
                 }
             }
             $document = array('date' => new \MongoDate(strtotime($forecasts['date'])), 'city' => $town['name'], 'forecast' => $mas);
             $collection->update(array('city' => $document['city'], 'date' => $document['date']), array('$set' => $document), array('upsert' => true));
         }
     }
 }
 public static function getReport()
 {
     $options = Config::get('profiler');
     // Calculate the variables.
     $execTime = microtime(true) - HttpRequest::server('REQUEST_TIME_FLOAT');
     $elapsedTime = sprintf("%01.4f", $execTime);
     $memoryUsage = Number::humanSize(memory_get_usage());
     if ($options['withDatabase'] == true) {
         $connection = DB::connection();
         $queries = $connection->getQueryLog();
         $totalQueries = count($queries);
         $queriesStr = $totalQueries == 1 ? __d('nova', 'query') : __d('nova', 'queries');
     } else {
         $totalQueries = 0;
         $queriesStr = __d('nova', 'queries');
     }
     $estimatedUsers = sprintf("%0d", intval(25 / $execTime));
     //
     $retval = __d('nova', 'Elapsed Time: <b>{0}</b> sec | Memory Usage: <b>{1}</b> | SQL: <b>{2}</b> {3} | UMAX: <b>{4}</b>', $elapsedTime, $memoryUsage, $totalQueries, $queriesStr, $estimatedUsers);
     return $retval;
 }
Example #23
0
 public function menu()
 {
     $path = $this->get_file_and_path();
     $menu = Config::menus();
     $menu_one = [];
     $menu_two = [];
     foreach ($menu as $key => $value) {
         $first_page = $value[1];
         if (!PATHINFO) {
             $one = ['index.php?__my=' . $key . '/' . $first_page, $value[0], $key];
         } else {
             $one = ['/' . $key . '/' . $first_page, $value[0], $key];
         }
         $menu_one[] = $one;
         if ($path['clss'] == $key) {
             foreach ($value[2] as $k => $v) {
                 if (!PATHINFO) {
                     $two = ['index.php?__my=' . $key . '/' . $k, $v, $k];
                 } else {
                     $two = ['/' . $key . '/' . $k, $v, $k];
                 }
                 $menu_two[] = $two;
             }
         }
     }
     if (PATHINFO) {
         $url = '/';
     } else {
         $url = 'index.php?__my=';
     }
     $this->assign('_url', $url);
     $this->assign('_menu_one', $menu_one);
     $this->assign('_menu_two', $menu_two);
     $this->assign('_file', $path['file']);
     $this->assign('_clss', $path['clss']);
     //print_r($menu_two);exit();
 }
Example #24
0
 public function system_path($path)
 {
     return Config::getBasePath() . self::SYSTEM_RESOURCE_PATH . '/' . $this->trimSlashes($path);
 }
 public function __construct()
 {
     if (empty(self::$mysql)) {
         self::$mysql = new MY_mysql(Config::get_mysql_config());
     }
 }
 public static function systemRedirect($url = "")
 {
     header("Location: " . Config::getBasePath() . Settings::SYSTEM_REQUEST_PREFIX . '/' . trim($url, "/"));
     exit;
 }
<?php

/**
 * Database configuration
 *
 * @author David Carr - dave@daveismyname.com
 * @author Virgil-Adrian Teaca - virgil@giulianaeassociati.com
 * @version 3.0
 */
use Config\Config;
/**
 * Setup the Database configuration.
 */
Config::set('database', array('fetch' => PDO::FETCH_CLASS, 'default' => 'mysql', 'connections' => array('sqlite' => array('driver' => 'sqlite', 'database' => APPDIR . 'Storage' . DS . 'database.sqlite', 'prefix' => ''), 'mysql' => array('driver' => 'mysql', 'hostname' => 'localhost', 'database' => 'nova', 'username' => 'nova', 'password' => 'password', 'prefix' => PREFIX, 'charset' => 'utf8', 'collation' => 'utf8_general_ci'), 'pgsql' => array('driver' => 'pgsql', 'host' => 'localhost', 'database' => 'nova', 'username' => 'nova', 'password' => 'password', 'charset' => 'utf8', 'prefix' => PREFIX, 'schema' => 'public'))));
<?php

/**
 * All known Languages
 *
 * @author David Carr - dave@daveismyname.com
 * @author Virgil-Adrian Teaca - virgil@giulianaeassociati.com
 * @version 3.0
 */
use Config\Config;
Config::set('languages', array('cs' => array('info' => 'Czech', 'name' => 'čeština', 'locale' => 'cs_CZ', 'dir' => 'ltr'), 'da' => array('info' => 'Danish', 'name' => 'Dansk', 'locale' => 'da_DK', 'dir' => 'ltr'), 'de' => array('info' => 'German', 'name' => 'Deutsch', 'locale' => 'de_DE', 'dir' => 'ltr'), 'en' => array('info' => 'English', 'name' => 'English', 'locale' => 'en_US', 'dir' => 'ltr'), 'es' => array('info' => 'Spanish', 'name' => 'Español', 'locale' => 'es_ES', 'dir' => 'ltr'), 'fa' => array('info' => 'Persian', 'name' => 'پارسی', 'locale' => 'fa_IR', 'dir' => 'rtl'), 'fr' => array('info' => 'French', 'name' => 'Français', 'locale' => 'fr_FR', 'dir' => 'ltr'), 'it' => array('info' => 'Italian', 'name' => 'italiano', 'locale' => 'it_IT', 'dir' => 'ltr'), 'ja' => array('info' => 'Japanesse', 'name' => '日本語', 'locale' => 'ja_JA', 'dir' => 'ltr'), 'nl' => array('info' => 'Dutch', 'name' => 'Nederlands', 'locale' => 'nl_NL', 'dir' => 'ltr'), 'pl' => array('info' => 'Polish', 'name' => 'polski', 'locale' => 'pl_PL', 'dir' => 'ltr'), 'ro' => array('info' => 'Romanian', 'name' => 'Română', 'locale' => 'ro_RO', 'dir' => 'ltr'), 'ru' => array('info' => 'Russian', 'name' => 'ру́сский', 'locale' => 'ru_RU', 'dir' => 'ltr')));
<?php

/**
 * Active Modules
 *
 * @author David Carr - dave@daveismyname.com
 * @author Virgil-Adrian Teaca - virgil@giulianaeassociati.com
 * @version 3.0
 */
use Config\Config;
Config::set('modules', array('path' => APPDIR . 'Modules', 'namespace' => 'App\\Modules\\', 'modules' => array('demos' => array('namespace' => 'Demos', 'enabled' => true, 'order' => 10001), 'files' => array('namespace' => 'Files', 'enabled' => true, 'order' => 9001), 'system' => array('namespace' => 'System', 'enabled' => true, 'order' => 8001), 'users' => array('namespace' => 'Users', 'enabled' => true, 'order' => 9001))));
<?php

/**
 * Config - the Global Configuration loaded BEFORE the Nova Application starts.
 *
 * @author Virgil-Adrian Teaca - virgil@giulianaeassociati.com
 * @version 3.0
 */
use Config\Config;
/**
 * PREFER to be used in Database calls or storing Session data, default is 'nova_'
 */
define('PREFIX', 'nova_');
/**
 * Setup the Config API Mode.
 * For using the 'database' mode, you need to have a database, with a table generated by 'scripts/nova_options'
 */
define('CONFIG_STORE', 'files');
// Supported: "files", "database"
/**
 * Routing configuration
 */
Config::set('routing', array('assets' => array('driver' => 'default', 'dispatcher' => 'Shared\\Routing\\Assets\\CustomDispatcher', 'cacheTime' => 10800, 'paths' => array('almasaeed2010/adminlte' => array('bootstrap', 'dist', 'plugins'), 'twbs/bootstrap' => 'dist'))));