Example #1
0
 /**
  * Check if an item exists by key.
  *
  * @param string $key
  *
  * @return bool
  */
 public function has($key)
 {
     if (array_key_exists($key, $this->settings)) {
         return true;
     }
     return $this->fallback instanceof Config ? $this->fallback->has($key) : false;
 }
 /**
  * Create Kafka producer.
  *
  * @param array $params
  */
 public function __construct(array $params)
 {
     parent::__construct($params);
     $this->config = new HashConfig($params);
     if (!$this->config->has('KafkaEventHost')) {
         throw new InvalidArgumentException("KafkaEventHost must be configured");
     }
 }
Example #3
0
 /**
  * Gateway constructor.
  * @param null $config
  * @param null $port
  */
 public function __construct($config = null, $port = null)
 {
     $this->config = app('config');
     $this->request = app('request');
     if ($this->config->has('gateway.timezone')) {
         date_default_timezone_set($this->config->get('gateway.timezone'));
     }
     if (!is_null($port)) {
         $this->make($port);
     }
 }
 /**
  * Register the service provider.
  *
  * @return void
  */
 public function register()
 {
     $this->package('opensolutions/doctrine2bridge', 'doctrine2bridge');
     $this->app['config']->package('opensolutions/doctrine2bridge', __DIR__ . '/../config');
     $this->app->singleton('d2cachebridge', function ($app) {
         $cacheClass = "\\Doctrine\\Common\\Cache\\" . \Config::get('doctrine2bridge::cache.type');
         if (!class_exists($cacheClass)) {
             throw new Exception\ImplementationNotFound($cacheClass);
         }
         $cache = new $cacheClass();
         if (\Config::has('doctrine2bridge::cache.namespace')) {
             $cache->setNamespace(\Config::get('doctrine2bridge::cache.namespace'));
         }
         switch (\Config::get('doctrine2bridge::cache.type')) {
             case 'MemcacheCache':
                 $memcache = new \Memcache();
                 if (!\Config::has('doctrine2bridge::cache.memcache.servers') || !count(\Config::get('doctrine2bridge::cache.memcache.servers'))) {
                     throw new Exception\Configuration('No servers defined for Doctrine2Bridge\\Doctrine2CacheBridgeServiceProvider - Memcache');
                 }
                 foreach (\Config::get('doctrine2bridge::cache.memcache.servers') as $server) {
                     $memcache->addServer($server['host'], isset($server['port']) ? $server['port'] : 11211, isset($server['persistent']) ? $server['persistent'] : false, isset($server['weight']) ? $server['weight'] : 1, isset($server['timeout']) ? $server['timeout'] : 1, isset($server['retry_int']) ? $server['retry_int'] : 15);
                     $cache->setMemcache($memcache);
                 }
                 break;
         }
         return $cache;
     });
     // Shortcut so developers don't need to add an Alias in app/config/app.php
     \App::booting(function () {
         $loader = \Illuminate\Foundation\AliasLoader::getInstance();
         $loader->alias('D2Cache', 'Doctrine2Bridge\\Support\\Facades\\Doctrine2Cache');
     });
 }
 /**
  * Initializes a cURL session with common options
  * @param  String $url
  * @param  int $timeout
  * @return resource
  */
 private static function curl_init($url)
 {
     $ch = curl_init($url);
     if (Config::has('solder.md5_connect_timeout')) {
         $timeout = Config::get('solder.md5_connect_timeout');
         if (is_int($timeout)) {
             curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, $timeout);
         }
     } else {
         curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 5);
     }
     if (Config::has('solder.md5_file_timeout')) {
         $timeout = Config::get('solder.md5_file_timeout');
         if (is_int($timeout)) {
             curl_setopt($ch, CURLOPT_TIMEOUT, $timeout);
         }
     } else {
         curl_setopt($ch, CURLOPT_TIMEOUT, 15);
     }
     curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
     curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
     curl_setopt($ch, CURLOPT_USERAGENT, 'TechnicSolder/0.7 (https://github.com/TechnicPack/TechnicSolder)');
     curl_setopt($ch, CURLOPT_MAXREDIRS, 5);
     curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);
     curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
     return $ch;
 }
 /**
  * Bootstrap any application services.
  *
  * @return void
  */
 public function boot()
 {
     /**
      * Build data for the sidebar block.
      */
     view()->composer('laraboard::*', function ($view) {
         $view->with('messaging', \Config::has('messenger'));
     });
     view()->composer('laraboard::category.show', function ($view) {
         $data = $view->getData();
         $view->with('crumbs', [['name' => $data['category']->name, 'url' => route('category.show', [$data['category']->slug])]]);
     });
     view()->composer('laraboard::board.show', function ($view) {
         $data = $view->getData();
         $view->with('crumbs', [['name' => $data['board']->category->name, 'url' => route('category.show', $data['board']->category->slug)], ['name' => $data['board']->name, 'url' => route('board.show', [$data['board']->category->slug, $data['board']->slug])]]);
     });
     view()->composer('laraboard::thread.show', function ($view) {
         $data = $view->getData();
         $view->with('crumbs', [['name' => $data['thread']->board->category->name, 'url' => route('category.show', $data['thread']->board->category->slug)], ['name' => $data['thread']->board->name, 'url' => route('board.show', [$data['thread']->board->category->slug, $data['thread']->board->slug])], ['name' => $data['thread']->name, 'url' => route('thread.show', [$data['thread']->board->category->slug, $data['thread']->board->slug, $data['thread']->slug, $data['thread']->name_slug])]]);
     });
     view()->composer('laraboard::post.edit', function ($view) {
         $data = $view->getData();
         $thread = $data['post']->thread;
         $view->with('crumbs', [['name' => $thread->board->category->name, 'url' => route('category.show', $thread->board->category->slug)], ['name' => $thread->board->name, 'url' => route('board.show', [$thread->board->category->slug, $thread->board->slug])], ['name' => $thread->name, 'url' => route('thread.show', [$thread->board->category->slug, $thread->board->slug, $thread->slug, $thread->name_slug])]]);
     });
 }
 /**
  * Validate parameters and options with syncle command.
  *
  * @param array $options A merged options and parameters arrays.
  * @return string Error message.
  */
 public function validate($options)
 {
     if (!empty($options['by']) and !\Config::has('syncle::DeployMethod.' . $options['by'])) {
         return \Lang::get('syncle::SyncleCommand.MethodNotFound');
     }
     return '';
 }
Example #8
0
 /**
  * Attempt to log a user into the application.
  *
  * @param  array  $arguments
  * @return void
  */
 public function attempt($arguments = array())
 {
     $username = Config::get('auth.username');
     if (!Config::has('auth.username')) {
         throw new Exception('The username in application/config/auth.php must be defined.');
     }
     $model = Config::get('auth.model');
     // Add the username to the query
     $query = array('$or' => array(array(Config::get('auth.username') => $arguments[Config::get('auth.username')])));
     // If we've specified an 'username_alt' field in the config, add that to the $OR
     if (Config::has('auth.username_alt')) {
         $query['$or'][] = array(Config::get('auth.username_alt') => $arguments[Config::get('auth.username')]);
     }
     $user = Epic_Mongo::db('user')->findOne($query);
     // This driver uses a basic username and password authentication scheme
     // so if the credentials match what is in the database we will just
     // log the user into the application and remember them if asked.
     $password = $arguments[Config::get('auth.password')];
     // if ( ! is_null($user) and Hash::check($password, $user->password))
     if (!is_null($user) and Hash::check($password, $user->password)) {
         return $this->login($user->_id, array_get($arguments, 'remember'));
     } else {
         if (!is_null($user) and md5($password) == $user->password) {
             return $this->login($user->_id, array_get($arguments, 'remember'));
         }
     }
     return false;
 }
Example #9
0
 public static function run()
 {
     // Jump ship if no key has been specified
     if (!Config::has('locate::options.maxmind_key')) {
         return false;
     }
     $options = array('l' => Config::get('locate::options.maxmind_key'), 'i' => Locate::ip());
     $response = @file_get_contents('http://geoip.maxmind.com/b?' . http_build_query($options));
     if ($response !== false) {
         $response = explode(',', $response);
         // Verify fields
         if (isset($response[5]) && $response[5] == 'IP_NOT_FOUND') {
             return false;
         }
         $required_fields = array(1, 2, 3, 4);
         foreach ($required_fields as $field) {
             if (!isset($response[$field]) || empty($response[$field])) {
                 return false;
             }
         }
         $states = Config::get('locate::abbrevs.states');
         return array('city' => $response[2], 'state' => isset($states[$response[1]]) ? $states[$response[1]] : null, 'state_code' => $response[1], 'country' => $response[0], 'country_code' => $response[0], 'zipcode' => null, 'lat' => $response[3], 'lng' => $response[4]);
     }
     return false;
 }
 public function __construct()
 {
     // Initialize Dropbox Application configuration
     if (Config::has('queue.postfix')) {
         $this->file_queue_id .= '.' . Config::get('queue.postfix');
         $this->listing_queue_id .= '.' . Config::get('queue.postfix');
     }
 }
 /**
  * Get ElasticSearch Client
  *
  * @return \Elasticsearch\Client
  */
 public function getElasticSearchClient()
 {
     $config = array();
     if (\Config::has('elasticquent.config')) {
         $config = \Config::get('elasticquent.config');
     }
     return \Elasticsearch\ClientBuilder::fromConfig($config, true);
 }
 /**
  * Get ElasticSearch Client
  *
  * @return \Elasticsearch\Client
  */
 public function getElasticSearchClient()
 {
     $config = array();
     if (\Config::has('elasticquent.config')) {
         $config = \Config::get('elasticquent.config');
     }
     return new \Elasticsearch\Client($config);
 }
 public function __construct(ThrottleCacheMgrInterface $cache_mgr)
 {
     if (!\Config::has('throttle.keys')) {
         throw new \RuntimeException('Missing throttle keys config');
     }
     $this->throttle_keys = \Config::get('throttle.keys');
     $this->cache_mgr = $cache_mgr;
 }
 public function __construct()
 {
     $this->contextIO = new ContextIO(Config::get('contextIO.key'), Config::get('contextIO.secret'));
     $this->accountIDs = [];
     if (Config::has('queue.postfix')) {
         $this->sync_queue_id .= '.' . Config::get('queue.postfix');
         $this->file_queue_id .= '.' . Config::get('queue.postfix');
     }
 }
Example #15
0
 /**
  *
  * @param string $config_id A valid configuration id to autolist configuration
  * @param function $query_modifier An optional function to modify the model query just before result retrieval
  * @throws Exception
  */
 function __construct($config_id, $query_modifier = NULL)
 {
     $this->config_id = $config_id;
     if (!Config::has($config_id) || !Config::has("{$config_id}.model")) {
         throw new Exception('Model must be defined in autolist config');
     }
     $this->config = Config::get($config_id);
     $this->set_query_modifier($query_modifier);
 }
 public function __construct()
 {
     // Initialize Dropbox Application configuration
     $this->appInfo = Dropbox\AppInfo::loadFromJson(['key' => Config::get('dropbox.key'), 'secret' => Config::get('dropbox.secret')]);
     if (Config::has('queue.postfix')) {
         $this->sync_queue_id .= '.' . Config::get('queue.postfix');
         $this->file_queue_id .= '.' . Config::get('queue.postfix');
     }
 }
 /**
  * Store a newly created setting in storage.
  *
  * @return Response
  */
 public function store()
 {
     $validator = Validator::make($data = Input::all(), Setting::$rules);
     // echo "<pre>"; print_r( $data ); echo "</pre>"; exit;
     foreach ($data['settings'] as $config => $value) {
         $settings = Setting::where('setting_name', $config)->where('setting_type', 'settings')->where('user_id', Confide::user()->id)->orderBy('id', 'DESC')->get();
         if (Config::has('settings.' . $config)) {
             if (empty($value)) {
                 foreach ($settings as $setting) {
                     $setting->delete();
                 }
             } else {
                 $setting = $settings->first();
                 $setting = !$setting ? new Setting() : $setting;
             }
             $setting->setting_type = 'settings';
             $setting->setting_name = $config;
             if (!empty($value) and $setting->setting_value != $value) {
                 $setting->setting_value = $value;
                 $setting->user_id = Confide::user()->id;
                 $setting->save();
             }
         }
     }
     if (isset($data['mail'])) {
         $data['mail']['pretend'] = @$data['mail']['pretend'] == 'on' ? true : false;
         foreach ($data['mail'] as $config => $value) {
             if (Config::has('mail.' . $config)) {
                 $setting = Setting::where('setting_name', $config)->where('setting_type', 'mail')->where('user_id', Confide::user()->id)->orderBy('id', 'DESC')->first();
                 if (!$setting) {
                     $setting = new Setting();
                     $setting->setting_type = 'mail';
                     $setting->setting_name = $config;
                 }
                 if (is_array($value)) {
                     $value = json_encode($value);
                 }
                 // echo "<pre>"; print_r( $value ); echo "</pre>"; exit;
                 if ($value != $setting->setting_value) {
                     $setting->setting_value = (string) $value;
                     $setting->user_id = Confide::user()->id;
                     $setting->save();
                 }
             }
             // echo "<pre>"; print_r( $setting ); echo "</pre>";
         }
         // echo "<pre>"; print_r( $data ); echo "</pre>";exit;
     }
     $alert[] = ['class' => 'alert-success', 'message' => '<strong><i class="fa fa-check"></i></strong> Configurações salvas!'];
     Session::flash('alerts', $alert);
     if (Request::header('referer')) {
         return Redirect::back();
     } else {
         return Redirect::route('settings.index');
     }
 }
Example #18
0
 public function testParse()
 {
     Config::parse('<?xml version="1.0"?><document><xmlstring>1</xmlstring></document>', 'xml');
     $this->assertEquals(1, Config::get('xmlstring'));
     Config::reset();
     Config::parse('tests/framework/application/test.xml');
     $this->assertTrue(Config::has('xmlfile.istrue'));
     $this->assertEquals(1, Config::get('xmlfile.istrue'));
     Config::reset();
 }
Example #19
0
 public function testParse()
 {
     Config::parse('{"jsonstring":1}', 'json');
     $this->assertEquals(1, Config::get('jsonstring'));
     Config::reset();
     Config::parse(__DIR__ . '/fixtures/config.json');
     $this->assertTrue(Config::has('jsonstring'));
     $this->assertEquals(1, Config::get('jsonstring'));
     Config::reset();
 }
Example #20
0
 public function testParse()
 {
     Config::parse('inistring=1', 'ini');
     $this->assertEquals(1, Config::get('inistring'));
     Config::reset();
     Config::parse(__DIR__ . '/fixtures/config.ini');
     $this->assertTrue(Config::has('inifile'));
     $this->assertEquals(1, Config::get('inifile'));
     Config::reset();
 }
 protected function getConfig($index, $index_type)
 {
     $config_var = 'index.index_' . $index . '_type_' . $index_type;
     if (!\Config::has($config_var)) {
         throw new \InvalidArgumentException('Index / Index type config file cannot be found');
     }
     $this->config = \Config::get($config_var);
     $this->index = $this->config['setup']['index'];
     $this->index_type = $this->config['setup']['type'];
 }
 protected function getConfig($index_model)
 {
     $config_var = 'laravel-elasticsearch-repository::index.index_models.' . $index_model;
     if (!\Config::has($config_var)) {
         throw new \InvalidArgumentException('Index model cannot be found in config');
     }
     $this->config = \Config::get($config_var);
     $this->index = $this->config['setup']['index'];
     $this->index_type = $this->config['setup']['type'];
 }
Example #23
0
 public function testParse()
 {
     Config::parse('<?xml version="1.0"?><document><xmlstring>1</xmlstring></document>', 'xml');
     $this->assertEquals(1, Config::get('xmlstring'));
     Config::reset();
     Config::parse(__DIR__ . '/fixtures/config.xml');
     $this->assertTrue(Config::has('xmlfile.istrue'));
     $this->assertEquals(1, Config::get('xmlfile.istrue'));
     Config::reset();
 }
Example #24
0
 public function testParse()
 {
     Config::parse('inistring=1', 'ini');
     $this->assertEquals(1, Config::get('inistring'));
     Config::reset();
     Config::parse('tests/framework/application/test.ini');
     $this->assertTrue(Config::has('inifile'));
     $this->assertEquals(1, Config::get('inifile'));
     Config::reset();
 }
 public function getMinecraft()
 {
     if (Config::has('solder.minecraft_api')) {
         $url = Config::get('solder.minecraft_api');
     } else {
         $url = self::MINECRAFT_API;
     }
     $response = UrlUtils::get_url_contents($url);
     return json_decode($response);
 }
 public static function authenticate()
 {
     if (!Config::falsey(Config::get('auth:require'))) {
         $userServerSource = Config::has('auth:userServerSource') ? Config::get('auth:userServerSource') : false;
         $user = $userServerSource && array_key_exists($userServerSource, $_SERVER) ? $_SERVER[$userServerSource] : (array_key_exists('PHP_AUTH_USER', $_SERVER) ? $_SERVER['PHP_AUTH_USER'] : '');
         return self::isAllowed($user);
     } else {
         return true;
     }
 }
Example #27
0
 /**
  * @return string
  */
 private function getDirectivesString()
 {
     $cmd = '';
     if ($this->config->has('disable_functions')) {
         $cmd .= ' -d disable_functions=' . implode(',', $this->config->read('disable_functions'));
     }
     foreach ($this->config->read('directives') as $name => $value) {
         $cmd .= ' -d ' . $name . '=' . $value;
     }
     return $cmd;
 }
 /**
  * Get Index Name
  *
  * @return string
  */
 public function getIndexName()
 {
     // The first thing we check is if there
     // is an elasticquery config file and if there is a
     // default index.
     if (\Config::has('elasticquent.default_index')) {
         return \Config::get('elasticquent.default_index');
     }
     // Otherwise we will just go with 'default'
     return 'default';
 }
 /**
  * 设置默认disk名字
  * @param $diskName config/filesystems.php disks数组内的key
  * @return $this
  * @throws \Exception
  */
 public function withDisk($diskName = null)
 {
     if ($diskName == null) {
         $this->diskName = \Config::get('upload.base_storage_disk');
     } elseif (\Config::has('filesystems.disks.' . $diskName)) {
         $this->diskName = $diskName;
     } else {
         throw new BadDiskException("Bad disk name: " . $diskName);
     }
     return $this;
 }
Example #30
0
 public function __construct()
 {
     // Get the DB Name from the Configuration File
     $this->_db = Config::get('epicmongo.dbname');
     // Get the TypesMap from the Configuration File
     $this->_typeMap = Config::get('epicmongo.typemap');
     // Check if we're using Epic_Mongo_Auth_Laravel, if we are, add it to the typeMap
     if (Config::has('auth.model') && Config::get('auth.driver') === 'epic_mongo') {
         $this->_typeMap += array('user' => Config::get('auth.model'));
     }
     // Run parent construct
     parent::__construct();
 }