/.config
[return to app]1
<?php
date_default_timezone_set('EST'); //set to the timezone of your application
session_start(); //if no use for sessions, comment this line out
/**
* Framework configuration - this object contains your application-specific settings
*/
class config extends configDefaults {
/**
* The SITE_NAME and SITE_DOMAIN constants are used in the default templates; you must set this if you will
use the
* default framework functionality such as the "default" layout or the preset email-elements.
* You can always access these from anywhere in your application via:
* get::$config->SITE_NAME
* get::$config->SITE_DOMAIN
*/
const SITE_NAME = 'YourSite';
const SITE_DOMAIN = 'YourSite.com';
/**
* Database name - create new constants for additional connections (commented out example for DB_SLAVE_NAME
follows)
* Defining DB-name constants is a good practice but not required if you hard-code them in dbConnect() below
*/
const DB_NAME = 'vork';
//const DB_SLAVE_NAME = 'slave4readonly';
/**
* Most RDBMS users will only need to adjust the connection string in the first $db object. The syntax of this
must
* always match the syntax of the constructor or connect method of your relational-database PHP extension.
*
* For the MySQLi extension all arguments are optional and formatted as:
* self::$db = new $db($host, $username, $passwd, $dbname, $port, $socket);
*
* Note: in most setups $host is either "localhost" or set to an IP address
* for Amazon RDS it would be something like: myinstance.crwjauxgijdf.us-east-1.rds.amazonaws.com
*
* For the syntax of other extensions refer to: http://www.php.net/manual/en/refs.database.vendors.php
*
* @param string $modelObject One of the values in self::$modelObjects determining which DB connection to
establish
*/
public function dbConnect($modelObject) {
$db = (!DEBUG_MODE ? 'db' : 'dbDebug');
switch ($modelObject) { //a case must exist for each value in self::$modelObjects (additional cases are
benign)
case 'db': // relation-database credentials (MySQL, Postgres, MS SQL Server, Oracle, etc.)
self::$$modelObject = new $db('HOSTNAME', 'USERNAME', 'PASSWORD', self::DB_NAME);
break;
case 'mongo':
if (!class_exists('vorkMongo')) {
require self::basepath() . 'sql' . self::DS . 'mongodb';
}
$m = new vorkMongo();
self::$$modelObject = $m->selectDB(self::DB_NAME);
//Upsert arg is array in newer MongoDB (leave as-is), Boolean in older- remove comments around
(Boolean)
$this->mongoUpsert = /* (Boolean) */ array('upsert' => true);
break;
case 'couchdb':
if (!class_exists('vorkMongo')) {
require self::basepath() . 'sql' . self::DS . 'couchdb';
}
self::$$modelObject = new vorkCouchdb();
self::$$modelObject->DB_NAME = self::DB_NAME;
//optional properties:
//self::$$modelObject->host = 'HOSTNAME'; self::$$modelObject->port = 'PORT';
//self::$$modelObject->user = 'USERNAME'; self::$$modelObject->pass = 'PASS';
break;
case 'membase':
self::$$modelObject = (class_exists('memcache') ? new Memcache : new blackhole);
self::$$modelObject->addServer('localhost', 11211); // signature: addServer('HOSTNAME', 'PORT')
break;
case 'cache': //Memcache is used below, but can be swapped with any object-oriented caching mechanism
get::$cache = (class_exists('memcache') ? new Memcache : new blackhole);
get::$cache->addServer('localhost', 11211); // signature: addServer('HOSTNAME', 'PORT')
break;
case 'dbro':
//if an additional connection is needed, adjust credentials below and follow the instructions in
the
//comment for $modelObjects just after this class.
self::$$modelObject = new $db('HOSTNAME', 'USERNAME', 'PASSWORD', self::DB_SLAVE_NAME);
break;
default:
return false;
break;
}
}
/**
* Instructions for using multiple database connections and/or NoSQL like MongoDB or Couchbase (CouchDB or
Membase)
*
* If you are only using one database connection and it is an RDBMS (any database except non-relational like
Mongo)
* then you can skip this step.
*
* For typical installations you can just uncomment one of the examples that follow this comment.
* Caution: do NOT uncomment more than one of the following examples; it will trigger a PHP fatal error if you
do!
*
* Full details:
* Each database connection (both RDBMS & NoSQL) needs to be defined in the $modelObjects array and have a
static
* propery existing by the same name. "db" exists by default so to add a second read-only connection you set
* $modelObjects to array('db', 'dbro') and create a new $dbro static property (commented-out examples
follow).
*
* Use the same process for adding a MongoDB or a Couchbase-DB connection in conjuction with an RDBMS
(substituting
* "dbro" in the last example with "mongo", "couchdb" or "membase").
*
* To use MongoDB or a Couchbase-DB as the sole database just overwrite $modelObjects with array('mongo') -
this is
* instead of keeping the default 'db' connection within the array. You will also want to comment out the
verylast
* line in this file which is RDBMS-specific: require '.config-rdbms';
*
* Important: each connection defined here must establish the connection within the dbConnect() method above,
an
* example for both mongo and dbro exists, for other connections just provide a unique name and access from
within
* your models by name: $this->mydbname->query(...);
*/
//Adds MongoDB support in conjunction with a relational database
//public static $modelObjects = array('db', 'mongo'); public static $mongo;
//Uses MongoDB as the exclusive datasource
//public static $modelObjects = array('mongo'); public static $mongo;
//Adds CouchDB in conjunction with a relational database
//public static $modelObjects = array('db', 'couchdb'); public static $couchdb;
//Uses CouchDB as the exclusive datasource
//public static $modelObjects = array('couchdb'); public static $couchdb;
//Adds Membase in conjunction with a relational database
//public static $modelObjects = array('db', 'membase'); public static $membase;
//Uses Membase as the exclusive datasource
//public static $modelObjects = array('membase'); public static $membase;
//Adds an additional realtional-database connection called "dbro"
//public static $modelObjects = array('db', 'dbro'); public static $dbro;
/**
* If true all self::$modelObjects database connections are made upon loading the first model
* If false your connections are lazy-loaded when needed but each of your models must extend the model
abstract
* eg.: class wikiModel extends model {...}
*/
const MODEL_AUTOCONNECT = true;
/**
* Enables the caching functions by initializing get::$cache with a cache object
*/
const CACHE_CONNECT = false;
/**
* Enables special AJAX handling - eg.: AJAX requests will skip the layout file and just return the view
contents
*
* Can be set globally here and then overridden form within any controller-action or component
*
* Valid values:
* (Boolean) true or false will enable or disable AJAX in all controllers
* array('controlerName1' => true,
* 'controlerName2' => 'actionName',
* 'controlerName3' => array('action1', 'action2'))
*
* @var mixed Boolean or an array with controller-name keys & val either true, an action name or an array of
actions
*/
public $ajaxEnabled = true;
/**
* Execute a file that is global to the application before the page loads
* File must be in the root of the mvc directory
*/
const APP_CONSTRUCT = null;
/**
* Execute a file that is global to the application after the page loads
* File must be in the root of the mvc directory
*/
const APP_DESTRUCT = null;
/**
* Enter your ShareThis publisher code to enable the shareThis tools helper
*/
//const SHARE_THIS = 'd123456789-1234-1234-1234-a1e123456f';
/**
* Enter your AddThis publisher code to enable the addThis tools helper
*/
//const ADD_THIS = 'xa-1234567890123e';
/**
* Enter your Google AdSense client ID to enable use of the adSense tools helper
*/
//const GOOGLE_AD_CLIENT = '';
/**
* Enter your Google Checkout credentials to enable use of the helper
*/
/*
public $GOOGLE_CHECKOUT = array('useSandbox' => false,
'live' => array('id' => 'YOURID', 'key' => 'YOURKEY'),
'sandbox' => array('id' => 'YOURID', 'key' => 'YOURKEY'));
*/
/**
* Enter your AuthorizeNet credentials to enable use of the chargeAuthNet method of the cc component
*/
/*
const AUTHNET_LOGIN = '';
const AUTHNET_PASSWORD = '';
*/
/**
* Meetup API key - enables usage of the Meetup tools-helper
*/
//const MEETUP_API_KEY = '47e794a9c4766374c761a57833a77';
/**
* Enter your UPS account credentials and XML Access Key (refer to ups.com for signup) to enable use of
* the UPS functions in the shipping component
*
* @var array
*/
//public $UPS = array('xmlAccessKey' => 'YOURKEY000000000', 'userid' => 'YOURID', 'password' => 'YOURPASS');
/**
* Enter your Amazon Web Services credentials to enable use of the amazon component
*/
/*
public $AMAZON = array('id' => '0000-0000-1234', 'accessKey' => 'AAAABBBBX12345CCDDDD',
'secretKey' => 'aA01234560bB01234560cC01234560dD');
*/
/**
* Enter your PayPal email to enable use of the PayPal component
*/
//const PAYPAL_EMAIL = 'you@yourdomain.com';
/**
* Convenience function to determine if a user is a "superuser" (someone who gets complete access to
* all information) and by default only used in the errorhandler view (to determine verbosity) but typical
applications
* find many uses for this
*
* Note, if your application uses this method to grant access to private resources then you are
highly-recommended
* to use a stronger authentication method than just checking the IP address (IPs can easily be spoofed.)
*
* @return boolean
*/
public function isSuperuser() {
return (isset($_SERVER['REMOTE_ADDR']) && $_SERVER['REMOTE_ADDR'] == '127.0.0.1'); // <--change this
before use
}
/**
* Set any application-specific constants or properties after this comment.
* examples:
* const MY_CONSTANT = 'Hello, Shalom and Bonjour';
* public $myProperty = array(1, 2, 3);
*
* Access them from any MVC element via:
* get::$config->MY_CONSTANT
* get::$config->myProperty
*/
//const EXAMPLE_CONSTANT = 'your data...';
}
/**
* If you are using a relational-database other than MySQL or Amazon RDS (eg. SQLite, Oracle, etc.) then you need
to
* set your RDBMS-type in the .config-rdbms file. If you are NOT using a relational-database then comment out the
* next line. Note: MongoDB and other NoSQL databases are NOT relational and do not require the .config-rdbms
file
*/
require '.config-rdbms';

