/.config
[return to app]1
<?php
2 date_default_timezone_set('EST'); //set to the timezone of your application
3 session_start(); //if no use for sessions, comment this line out
4 /**
5 * Framework configuration - this object contains your application-specific settings
6 */
7 class config extends configDefaults {
8 /**
9 * The SITE_NAME and SITE_DOMAIN constants are used in the default templates; you must set this if you will
use the
10 * default framework functionality such as the "default" layout or the preset email-elements.
11 * You can always access these from anywhere in your application via:
12 * get::$config->SITE_NAME
13 * get::$config->SITE_DOMAIN
14 */
15 const SITE_NAME = 'YourSite';
16 const SITE_DOMAIN = 'YourSite.com';
17
18 /**
19 * Database name - create new constants for additional connections (commented out example for DB_SLAVE_NAME
follows)
20 * Defining DB-name constants is a good practice but not required if you hard-code them in dbConnect() below
21 */
22 const DB_NAME = 'vork';
23 //const DB_SLAVE_NAME = 'slave4readonly';
24
25 /**
26 * Most RDBMS users will only need to adjust the connection string in the first $db object. The syntax of this
must
27 * always match the syntax of the constructor or connect method of your relational-database PHP extension.
28 *
29 * For the MySQLi extension all arguments are optional and formatted as:
30 * self::$db = new $db($host, $username, $passwd, $dbname, $port, $socket);
31 *
32 * Note: in most setups $host is either "localhost" or set to an IP address
33 * for Amazon RDS it would be something like: myinstance.crwjauxgijdf.us-east-1.rds.amazonaws.com
34 *
35 * For the syntax of other extensions refer to: http://www.php.net/manual/en/refs.database.vendors.php
36 *
37 * @param string $modelObject One of the values in self::$modelObjects determining which DB connection to
establish
38 */
39 public function dbConnect($modelObject) {
40 $db = (!DEBUG_MODE ? 'db' : 'dbDebug');
41 switch ($modelObject) { //a case must exist for each value in self::$modelObjects (additional cases are
benign)
42 case 'db': // relation-database credentials (MySQL, Postgres, MS SQL Server, Oracle, etc.)
43 self::$$modelObject = new $db('HOSTNAME', 'USERNAME', 'PASSWORD', self::DB_NAME);
44 break;
45 case 'mongo':
46 if (!class_exists('vorkMongo')) {
47 require self::basepath() . 'sql' . self::DS . 'mongodb';
48 }
49 $m = new vorkMongo();
50 self::$$modelObject = $m->selectDB(self::DB_NAME);
51 //Upsert arg is array in newer MongoDB (leave as-is), Boolean in older- remove comments around
(Boolean)
52 $this->mongoUpsert = /* (Boolean) */ array('upsert' => true);
53 break;
54 case 'couchdb':
55 if (!class_exists('vorkMongo')) {
56 require self::basepath() . 'sql' . self::DS . 'couchdb';
57 }
58 self::$$modelObject = new vorkCouchdb();
59 self::$$modelObject->DB_NAME = self::DB_NAME;
60 //optional properties:
61 //self::$$modelObject->host = 'HOSTNAME'; self::$$modelObject->port = 'PORT';
62 //self::$$modelObject->user = 'USERNAME'; self::$$modelObject->pass = 'PASS';
63 break;
64 case 'membase':
65 self::$$modelObject = (class_exists('memcache') ? new Memcache : new blackhole);
66 self::$$modelObject->addServer('localhost', 11211); // signature: addServer('HOSTNAME', 'PORT')
67 break;
68 case 'cache': //Memcache is used below, but can be swapped with any object-oriented caching mechanism
69 get::$cache = (class_exists('memcache') ? new Memcache : new blackhole);
70 get::$cache->addServer('localhost', 11211); // signature: addServer('HOSTNAME', 'PORT')
71 break;
72 case 'dbro':
73 //if an additional connection is needed, adjust credentials below and follow the instructions in
the
74 //comment for $modelObjects just after this class.
75 self::$$modelObject = new $db('HOSTNAME', 'USERNAME', 'PASSWORD', self::DB_SLAVE_NAME);
76 break;
77 default:
78 return false;
79 break;
80 }
81 }
82
83 /**
84 * Instructions for using multiple database connections and/or NoSQL like MongoDB or Couchbase (CouchDB or
Membase)
85 *
86 * If you are only using one database connection and it is an RDBMS (any database except non-relational like
Mongo)
87 * then you can skip this step.
88 *
89 * For typical installations you can just uncomment one of the examples that follow this comment.
90 * Caution: do NOT uncomment more than one of the following examples; it will trigger a PHP fatal error if you
do!
91 *
92 * Full details:
93 * Each database connection (both RDBMS & NoSQL) needs to be defined in the $modelObjects array and have a
static
94 * propery existing by the same name. "db" exists by default so to add a second read-only connection you set
95 * $modelObjects to array('db', 'dbro') and create a new $dbro static property (commented-out examples
follow).
96 *
97 * Use the same process for adding a MongoDB or a Couchbase-DB connection in conjuction with an RDBMS
(substituting
98 * "dbro" in the last example with "mongo", "couchdb" or "membase").
99 *
100 * To use MongoDB or a Couchbase-DB as the sole database just overwrite $modelObjects with array('mongo') -
this is
101 * instead of keeping the default 'db' connection within the array. You will also want to comment out the
verylast
102 * line in this file which is RDBMS-specific: require '.config-rdbms';
103 *
104 * Important: each connection defined here must establish the connection within the dbConnect() method above,
an
105 * example for both mongo and dbro exists, for other connections just provide a unique name and access from
within
106 * your models by name: $this->mydbname->query(...);
107 */
108 //Adds MongoDB support in conjunction with a relational database
109 //public static $modelObjects = array('db', 'mongo'); public static $mongo;
110
111 //Uses MongoDB as the exclusive datasource
112 //public static $modelObjects = array('mongo'); public static $mongo;
113
114 //Adds CouchDB in conjunction with a relational database
115 //public static $modelObjects = array('db', 'couchdb'); public static $couchdb;
116
117 //Uses CouchDB as the exclusive datasource
118 //public static $modelObjects = array('couchdb'); public static $couchdb;
119
120 //Adds Membase in conjunction with a relational database
121 //public static $modelObjects = array('db', 'membase'); public static $membase;
122
123 //Uses Membase as the exclusive datasource
124 //public static $modelObjects = array('membase'); public static $membase;
125
126 //Adds an additional realtional-database connection called "dbro"
127 //public static $modelObjects = array('db', 'dbro'); public static $dbro;
128
129 /**
130 * If true all self::$modelObjects database connections are made upon loading the first model
131 * If false your connections are lazy-loaded when needed but each of your models must extend the model
abstract
132 * eg.: class wikiModel extends model {...}
133 */
134 const MODEL_AUTOCONNECT = true;
135
136 /**
137 * Enables the caching functions by initializing get::$cache with a cache object
138 */
139 const CACHE_CONNECT = false;
140
141 /**
142 * Enables special AJAX handling - eg.: AJAX requests will skip the layout file and just return the view
contents
143 *
144 * Can be set globally here and then overridden form within any controller-action or component
145 *
146 * Valid values:
147 * (Boolean) true or false will enable or disable AJAX in all controllers
148 * array('controlerName1' => true,
149 * 'controlerName2' => 'actionName',
150 * 'controlerName3' => array('action1', 'action2'))
151 *
152 * @var mixed Boolean or an array with controller-name keys & val either true, an action name or an array of
actions
153 */
154 public $ajaxEnabled = true;
155
156 /**
157 * Execute a file that is global to the application before the page loads
158 * File must be in the root of the mvc directory
159 */
160 const APP_CONSTRUCT = null;
161
162 /**
163 * Execute a file that is global to the application after the page loads
164 * File must be in the root of the mvc directory
165 */
166 const APP_DESTRUCT = null;
167
168 /**
169 * Enter your ShareThis publisher code to enable the shareThis tools helper
170 */
171 //const SHARE_THIS = 'd123456789-1234-1234-1234-a1e123456f';
172
173
174 /**
175 * Enter your AddThis publisher code to enable the addThis tools helper
176 */
177 //const ADD_THIS = 'xa-1234567890123e';
178
179 /**
180 * Enter your Google AdSense client ID to enable use of the adSense tools helper
181 */
182 //const GOOGLE_AD_CLIENT = '';
183
184 /**
185 * Enter your Google Checkout credentials to enable use of the helper
186 */
187 /*
188 public $GOOGLE_CHECKOUT = array('useSandbox' => false,
189 'live' => array('id' => 'YOURID', 'key' => 'YOURKEY'),
190 'sandbox' => array('id' => 'YOURID', 'key' => 'YOURKEY'));
191 */
192
193 /**
194 * Enter your AuthorizeNet credentials to enable use of the chargeAuthNet method of the cc component
195 */
196 /*
197 const AUTHNET_LOGIN = '';
198 const AUTHNET_PASSWORD = '';
199 */
200
201 /**
202 * Meetup API key - enables usage of the Meetup tools-helper
203 */
204 //const MEETUP_API_KEY = '47e794a9c4766374c761a57833a77';
205
206 /**
207 * Enter your UPS account credentials and XML Access Key (refer to ups.com for signup) to enable use of
208 * the UPS functions in the shipping component
209 *
210 * @var array
211 */
212 //public $UPS = array('xmlAccessKey' => 'YOURKEY000000000', 'userid' => 'YOURID', 'password' => 'YOURPASS');
213
214 /**
215 * Enter your Amazon Web Services credentials to enable use of the amazon component
216 */
217 /*
218 public $AMAZON = array('id' => '0000-0000-1234', 'accessKey' => 'AAAABBBBX12345CCDDDD',
219 'secretKey' => 'aA01234560bB01234560cC01234560dD');
220 */
221
222 /**
223 * Enter your PayPal email to enable use of the PayPal component
224 */
225 //const PAYPAL_EMAIL = 'you@yourdomain.com';
226
227 /**
228 * Convenience function to determine if a user is a "superuser" (someone who gets complete access to
229 * all information) and by default only used in the errorhandler view (to determine verbosity) but typical
applications
230 * find many uses for this
231 *
232 * Note, if your application uses this method to grant access to private resources then you are
highly-recommended
233 * to use a stronger authentication method than just checking the IP address (IPs can easily be spoofed.)
234 *
235 * @return boolean
236 */
237 public function isSuperuser() {
238 return (isset($_SERVER['REMOTE_ADDR']) && $_SERVER['REMOTE_ADDR'] == '127.0.0.1'); // <--change this
before use
239 }
240
241 /**
242 * Set any application-specific constants or properties after this comment.
243 * examples:
244 * const MY_CONSTANT = 'Hello, Shalom and Bonjour';
245 * public $myProperty = array(1, 2, 3);
246 *
247 * Access them from any MVC element via:
248 * get::$config->MY_CONSTANT
249 * get::$config->myProperty
250 */
251 //const EXAMPLE_CONSTANT = 'your data...';
252 }
253
254 /**
255 * If you are using a relational-database other than MySQL or Amazon RDS (eg. SQLite, Oracle, etc.) then you need
to
256 * set your RDBMS-type in the .config-rdbms file. If you are NOT using a relational-database then comment out the
257 * next line. Note: MongoDB and other NoSQL databases are NOT relational and do not require the .config-rdbms
file
258 */
259 require '.config-rdbms';