/php/lib/Gloo/Config.php
PHP | 216 lines | 155 code | 48 blank | 13 comment | 14 complexity | d05073dc48702ad60d36910963f7d1ae MD5 | raw file
- <?php
- /*
- *
- * configuration items for gloo v2
- * PHP singleton implementation need not be thread safe!
- * I do not think there is even the concept of thread safe in PHP!
- *
- *
- *
- */
- class Gloo_Config {
- static private $instance = NULL;
- private $ini_array;
- private $isIndigloo ;
- static function getInstance() {
- if (self::$instance == NULL) {
- self::$instance = new Gloo_Config();
- }
- return self::$instance;
- }
- function __construct() {
- $iniFile = $_SERVER['GLOO_CONFIG_DIR'] . '/gloo_config.ini';
- file_exists($iniFile) || die("unable to open gloo_config.ini file ");
- // create config object
- $this->ini_array = parse_ini_file($iniFile);
- $host = $_SERVER["HTTP_HOST"];
- $host = strtolower($host);
- $pos = strpos($host,"indigloo.com");
- $this->isIndigloo = ($pos === false) ? false : true ;
- }
- function isRequired($name, $value) {
- if (empty($value)) {
- trigger_error("Default $name is empty in config", E_USER_ERROR);
- }
- return $value;
- }
- function __destruct() {
- }
- function mysql_host() {
- $host = ($this->isIndigloo)? $this->ini_array['mysql.indigloo.host'] : $this->ini_array['mysql.host'] ;
- return $host;
- }
- function mysql_db() {
- $db = ($this->isIndigloo)? $this->ini_array['mysql.indigloo.database'] : $this->ini_array['mysql.database'] ;
- return $db;
- }
- function mysql_user() {
- $user = ($this->isIndigloo)? $this->ini_array['mysql.indigloo.user'] : $this->ini_array['mysql.user'] ;
- return $user;
- }
- function mysql_password() {
- $password = ($this->isIndigloo)? $this->ini_array['mysql.indigloo.password'] : $this->ini_array['mysql.password'] ;
- return $password;
- }
-
- function is_debug() {
- $val = $this->ini_array['debug.mode'];
- if (intval($val) == 1) {
- return true;
- } else {
- return false;
- }
- }
- function log_level() {
- return $this->ini_array['log.level'];
- }
- function system_page_records() {
- return $this->ini_array['system.page.records'];
- }
- function max_file_size() {
- return $this->ini_array['max.file.size'];
- }
- function max_foto_size() {
- return $this->ini_array['max.foto.size'];
- }
- function thumbnail_width() {
- return $this->ini_array['thumbnail.width'];
- }
- function thumbnail_height() {
- return $this->ini_array['thumbnail.height'];
- }
- function aws_bucket() {
- return $this->ini_array['aws.bucket'];
- }
- function aws_access_key() {
- return $this->ini_array['aws.access.key'];
- }
- function aws_secret_key() {
- return $this->ini_array['aws.secret.key'];
- }
- function image_404_uri() {
- return $this->ini_array['image.404.uri'];
- }
- function thumbnail_404_uri() {
- return $this->ini_array['thumbnail.404.uri'];
- }
- function hasSmtpServer() {
- $val = $this->ini_array['smtp.provider'];
- // php === operator does a type check as well
- // php == will convert type before check and we do not want that
- if(empty($val) || ($val === 'Off') || ($val === 'off'))
- return false ;
- else
- return true ;
-
- }
-
- function smtp_host() {
- if($this->hasSmtpServer())
- return $this->ini_array['smtp.host'];
- else
- trigger_error('smtp.server config flag is set to Off',E_USER_ERROR);
- }
- function smtp_port() {
- return $this->ini_array['smtp.port'];
- }
- function smtp_user() {
- return $this->ini_array['smtp.user'];
- }
- function smtp_password() {
- $password = $this->ini_array['smtp.password'];
- $password = Gloo_Util::base64Decrypt($password);
- return $password;
- }
- function default_theme() {
- $theme = $this->isRequired('Theme', $this->ini_array['default.theme']);
- return $theme;
- }
- function log_location() {
- return $this->ini_array['log.location'];
- }
- //farm specific messages
- function getFarmName() {
- return $this->ini_array['farm.name'];
- }
- function getFarmDomain() {
- return $this->ini_array['farm.domain'];
- }
- function getFarmURI() {
- return $this->ini_array['farm.uri'];
- }
- function getFarmAdminEmail() {
- return $this->ini_array['farm.admin.email'];
- }
- function getFarmBuilderName() {
- return $this->ini_array['farm.builder.name'];
- }
- function getFarmLogoPath() {
- return $this->ini_array['farm.logo.path'];
- }
- function getFarmOrganizationId() {
- return $this->ini_array['farm.organization.id'];
- }
- function getFarmOrganizationDomain() {
- return $this->ini_array['farm.organization.domain'];
- }
- function getFarmNewSiteDomain() {
- return $this->ini_array['farm.new.site.domain'];
- }
-
- function isLocalStore() {
- $val = $this->ini_array['file.store.type'];
- if(empty($val) || ($val == 'local'))
- return true ;
- else
- return false ;
-
- }
-
- function getLocalStorePath() {
- return $this->ini_array['local.store.path'];
- }
-
- }
- ?>