/** * Loads the configuration settings for a SimpleDB connection. * * @param array $config The configuration settings, * which can take the following options: * `region` - The region. * `version` - The version of the API. * `access_key` - The access key id. * `primary_key` - The primary key (used * to identify records). * `secret_key` - The secret access key. * `signature_method` - The signature method. * `signature_version` - The AWS signature * version (currently 2). * `scheme` - The protocol (http or * https) to use when * making REST requests. * `classes` - Dependency classes. * @access public * @return void */ public function __construct(array $config = array()) { $defaults = array('region' => 'sdb.amazonaws.com', 'version' => '2009-04-15', 'access_key' => '', 'primary_key' => 'id', 'secret_key' => '', 'signature_method' => 'HmacSHA256', 'signature_version' => 2, 'scheme' => 'http', 'classes' => array('rest' => 'nx\\lib\\Rest')); parent::__construct($config + $defaults); }
public function __construct(array $config = array()) { $defaults = array('host' => '', 'username' => '', 'password' => '', 'port' => 25, 'auth' => true); parent::__construct($config + $defaults); }
/** * Initializes the controller with sanitized http request data, * generates a token to be used to ensure that the next request is valid, * and loads a user object if a valid session is found. * * @access protected * @return void */ protected function _init() { parent::_init(); $session = $this->_config['classes']['session']; $this->_session = new $session(); $this->_http_get = $this->sanitize($this->_config['http_get']); $this->_http_post = $this->sanitize($this->_config['http_post']); if (!$this->_is_valid_request($this->_http_get) || !$this->_is_valid_request($this->_http_post)) { $this->handle_CSRF(); $this->_token = null; } if (is_null($this->_token)) { $this->_token = Auth::create_token(); } if ($this->_session->is_logged_in()) { $user = $this->_config['classes']['user']; $this->_user = new $user(array('id' => $this->_session->get_user_id())); $this->_template = $this->_user->get_template(); } }
/** * Loads the configuration settings for Memcached. * * @param array $config The configuration settings, which * can take two options: * `host` - The hostname of * the memcached server. * `persistent_id` - A unique ID used * to allow persistence * between requests. * (By default, instances are * destroyed at the end of the request.) * @access public * @return void */ public function __construct(array $config = array()) { $defaults = array('host' => 'localhost', 'persistent_id' => ''); parent::__construct($config + $defaults); }
/** * Loads the configuration settings for a MySQL connection. * * @param array $config The configuration settings, * which can take four options: * `database` - The name of the database. * `host` - The database host. * `username` - The database username. * `password` - The database password. * (By default, instances are * destroyed at the end of the request.) * @access public * @return void */ public function __construct(array $config = array()) { $defaults = array('database' => 'journal', 'host' => 'localhost', 'username' => 'root', 'password' => 'admin'); parent::__construct($config + $defaults); }
/** * Initializes an object. Object properties are populated * automatically - first by checking the cache, and then, if that * fails, by retrieving the values from the database. * * @see /nx/core/Model->__construct() * @access protected * @return void */ protected function _init() { parent::_init(); $this->_db = Connections::get_db($this->_config['db']); $this->_cache = Connections::get_cache($this->_config['cache']); if (isset($this->_config['where'])) { $field = '`' . $this->_meta['key'] . '`'; $table = $this->classname(); $this->_db->find($field, $table, $this->_config['where'], 'LIMIT 1'); $result = $this->_db->fetch('assoc'); if ($result) { $this->_config['id'] = $result[$this->_meta['key']]; } } if (is_numeric($this->_config['id'])) { if (!$this->pull_from_cache($this, $this->_config['id'])) { $where = array($this->_meta['key'] => $this->_config['id']); $this->_db->find('*', $this->classname(), $where); $this->_db->fetch('into', $this); $this->cache(); } } }