Ejemplo n.º 1
0
 /**
  * set config keys and isntance wide settings
  *
  * @param key string Our instance key
  *
  * @return void
  */
 private function __construct($key)
 {
     //our instance and distingushing key
     $this->key = $key;
     //if our key is the default
     if ($this->key == 'default') {
         //generate our cache key from the full url
         $this->key = md5(Uri::full());
     }
     //get our cache settings
     $this->config = Config::settings('cache');
     //get our cache config from both system and app settings
     $this->duration = $this->config['duration'];
     //if we are in debug mode, force the duration to 0 (as in off)
     $this->duration = IS_DEBUG === true ? $this->duration : 0;
     //create our cache path
     $this->dir = PUBLIC_PATH . rtrim($this->config['dir'], '/') . '/';
     //set our language code
     $this->lang_code = defined('LANG_CODE') ? '-' . LANG_CODE : '';
     //create our filename default and append a language code to the filename if it exists
     $this->file = $this->checkDir() . $this->key . $this->lang_code . '.' . ltrim($this->config['file_ext'], '.');
     //has our file type been passed into the init: self::init('css')->concat($array);
     if (isset($this->config[$this->key])) {
         //check the cache dir is in place and add our file name
         $this->file = $this->checkDir() . $this->config[$this->key];
     }
     //for debugging
     $this->timestamp = Timer::mtime();
 }
Ejemplo n.º 2
0
 /**
  * Decode a string from the values that have been generated
  *
  * @param text string The string that has been encoded
  * 
  * @return string
  */
 public static function decrypt($text)
 {
     $config = Config::settings('encrypt');
     $base64key = $config['key'];
     $base64ivector = $config['iv'];
     return bzdecompress(trim(mcrypt_decrypt(MCRYPT_RIJNDAEL_256, base64_decode($base64key), base64_decode($text), MCRYPT_MODE_CBC, base64_decode($base64ivector))));
 }
Ejemplo n.º 3
0
 /**
  * create our instance and setup class wide variables 
  *
  * @return void
  */
 function __construct()
 {
     //get our debug callback and store it incase of debugging
     $this->debug_backtrace = Debug::backtrace();
     //keep just the second element sa that tells us where the calling class is
     $this->debug_backtrace = $this->debug_backtrace[1];
     //get our config
     $config = Config::settings('email');
     $this->header = $config['header'];
     $this->footer = $config['footer'];
     //init our email instance
     $this->email = new PHPMailer(true);
     //check if we want to use smtp and set all our required values from the config
     if ($config['smtp'] === true) {
         // telling the class to use SMTP
         $this->email->IsSMTP();
         // set the host address
         $this->email->Host = $config['smtp-host'];
         // enable SMTP authentication
         $this->email->SMTPAuth = true;
         // SMTP connection will not close after each email sent
         $this->email->SMTPKeepAlive = true;
         // set the SMTP port for the GMAIL server
         $this->email->Port = $config['smtp-port'];
         // SMTP account username
         $this->email->Username = $config['smtp-username'];
         // SMTP account password
         $this->email->Password = $config['smtp-password'];
     }
     //add the default from address
     $this->addFrom($config['from-address'], $config['fromt-name']);
 }
Ejemplo n.º 4
0
 public function __construct($path = null)
 {
     if ($path) {
         include $path;
         self::$settings = $set;
     }
 }
Ejemplo n.º 5
0
 /**
  * prevent direct instantition
  *
  * @param lang string Our current language code
  *
  * @return void
  */
 private function __construct($lang)
 {
     $this->config = Config::settings('language');
     //maintain our language code
     $this->lang = $lang;
     //load our translations file
     $this->load();
 }
Ejemplo n.º 6
0
 public static function init()
 {
     if (!isset(self::$bInit)) {
         $data = parse_ini_file(BASE_DIR . '/admin/configuration.ini', true);
         self::$database = (object) $data['database'];
         self::$settings = (object) $data['settings'];
         self::$bInit = 'y';
     }
 }
Ejemplo n.º 7
0
 /**
  * prevent normal instantiation 
  *
  * @param key string The key that is used to seperate our instances
  *
  * @return void
  */
 private function __construct($key)
 {
     //if our key is the default
     if ($this->key == 'default') {
         //generate our meta key from the full url - and make sure its just alphanumeric
         $this->key = md5(Uri::full());
     }
     $this->config = Config::settings('meta');
 }
Ejemplo n.º 8
0
 public static function Save($new_settings, $overwrite = false)
 {
     self::$settings = $overwrite ? $new_settings : array_merge(self::$settings, $new_settings);
     self::$settings['random_value'] = sha1(uniqid(rand(), true));
     $elements = array();
     foreach (self::$settings as $setting => $value) {
         $elements[] = "'{$setting}' => '" . addslashes($value) . "'";
     }
     $config = preg_replace('~//<' . self::TAG_NAME . '>.*?//</' . self::TAG_NAME . '>~msi', "//<" . self::TAG_NAME . ">\n              " . join(",\n              ", $elements) . "\n//</" . self::TAG_NAME . ">", str_replace(array("\r\n", "\r"), "\n", file_get_contents(BASE_DIR . '/classes/Config.php')));
     file_put_contents(BASE_DIR . '/classes/Config.php', $config);
 }
Ejemplo n.º 9
0
 /**
  * refuse normal instantiation
  *
  * @param connection_name 	string 	Inorder to maintain different connections and instances
  *
  * @return void
  */
 private function __construct($connection_name)
 {
     //get the ftp config
     $config = Config::settings('ftp');
     //if we have a set of connection details for the required connection
     if (isset($config[$connection_name]) and is_array($config[$connection_name])) {
         //loop through our config and assign to instance variables
         foreach ($config[$connection_name] as $k => $v) {
             $this->{$k} = $v;
         }
     }
 }
Ejemplo n.º 10
0
	public function main ($query, $count = 0, $limit = 0) {

		$perpage = empty($count) ? Config::settings('per_page') : $count;
		$page = isset($query['page']) && $query['page'] > 0 ? $query['page'] : 1;
		$start = ($page - 1) * $perpage;
		
		$params = array('deleted');
		$condition = "area != ? group by place, item_id order by max(date) desc limit $start, $perpage";

		$items = Database::set_counter()->
			get_table('comment', array('place', 'item_id'), $condition, $params);

		$condition = "";
		foreach ($items as $item) {
			$condition .= " or (place = ? and item_id = ?)";
			$params[] = $item['place'];
			$params[] = $item['item_id'];
		}
		$condition = "area != ? and (".substr($condition,4).") order by date";
		
		$comments = Database::get_full_vector('comment', $condition, $params);
	
		foreach ($items as $item) {
			$item_comments = array();
			
			foreach ($comments as $id => $comment) {
				if (
					$comment['item_id'] == $item['item_id'] && 
					$comment['place'] == $item['place']
				) {
					$item_comments[$id] = new Item_Comment(
						$comment, 
						Globals::user_settings('display')
					);
				}
			}
			
			$this->items[] = new Item_Comment_Block(array(
				'limit' =>  empty($limit) ? 
								Globals::user_settings('last_comments') : 
								$limit,
				'place' => $item['place'],
				'id' => $item['item_id'],
				'items' => $item_comments,
			));
		}
		
		$this->get_navi($query, Database::get_counter(), $page, $perpage);
	}
Ejemplo n.º 11
0
 /**
  * check the db table for the need to update it
  *
  * @return void
  */
 function check()
 {
     $class = $this->class;
     $this->table = $class::$table;
     //db config
     $connect = Config::settings('database');
     //check for the existance of the table
     $table_check = static::$db->query("SHOW TABLES LIKE '" . $this->table . "' ")->fetch();
     //if we dont find the table, make it
     if ($table_check[0] !== $this->table) {
         return $this->forgeModel();
     }
     //if we have the table, check if we want to alter if
     return $this->alterTable();
 }
Ejemplo n.º 12
0
 private static function init()
 {
     $config_file = PROJECT_PATH . '/config.ini';
     if (!is_readable($config_file)) {
         throw new ConfigException('Cannot read config file');
     }
     self::$settings = parse_ini_file($config_file);
     $custom_config = PROJECT_PATH . '/custom.ini';
     if (is_readable($custom_config)) {
         $custom = parse_ini_file(PROJECT_PATH . '/custom.ini');
         if ($custom !== false) {
             self::$settings = array_merge(self::$settings, $custom);
         }
     }
 }
Ejemplo n.º 13
0
 /**
  * add our routes to the routes array as instances of the Route object
  *
  * @return object
  */
 public function addRoutes($array = null)
 {
     //get all of our routes from the config (plus all environments)
     $routes = Config::settings('routes');
     //incase more routes where added merge the arrays
     if (!is_null($array)) {
         $routes = $routes + $array;
     }
     //loop though our routes and add them new route instances
     foreach ($routes as $route) {
         //create our new Route instance and store
         $this->addRoute(new Route($route['uri'], $route['pattern'], $route['filter']));
     }
     return $this;
 }
Ejemplo n.º 14
0
	protected function get_latest_art () {	
		$latest_art_count = Config::settings('latest_art', 'count');
		
		$latest = Database::get_table(
			'art',
			array('id', 'user_id', 'name'),
			'area != "deleted" order by date desc limit '.$latest_art_count
		);
		
		$galleries = array();
		$image_limit = Config::settings('latest_art', 'image_limit');
		$galleries_limit =Config::settings('latest_art', 'galleries_limit');
		
		foreach ($latest as $art) {
			
			if (
				!empty($galleries[$art['user_id']]['images']) &&
				count($galleries[$art['user_id']]['images']) >= $image_limit
			) {
				continue;
			}
			
			$galleries[$art['user_id']]['images'][] = array(
				'id' => $art['id'],
				'name' => $art['name'],
			);
		}
		
		$galleries = array_slice($galleries, 0, $galleries_limit, true);
		
		$users = Database::get_vector(
			'user', 
			array('id', 'username'), 
			Database::array_in('id', $galleries),
			array_keys($galleries)
		);

		foreach ($users as $id => $user) {
			$alias = Meta_Author::get_alias_by_name($user);
			$galleries[$id]['link'] = empty($alias) ? $user : $alias;
			$galleries[$id]['username'] = $user;
		}

		$this->items['new'] = $galleries;
	}
Ejemplo n.º 15
0
 /**
  * our construct
  * setup config details and instantiate the s3 instance
  *
  * @return void
  */
 private function __construct()
 {
     //get our s3 connection details
     $s3_config = Config::settings('s3');
     //if the bucket name isnt provided, use the default site bucket from the config
     if (is_null($bucket_name)) {
         $bucket_name = $s3_config['bucket_name'];
     }
     //set our instance variables including our required bucket
     $this->bucket_name = $bucket_name;
     //set our keys
     $this->key = $s3_config['key'];
     $this->secret = $s3_config['secret'];
     //create and cache our new instance
     $this->s3 = new \Meagr\Vender\S3\S3($this->key, $this->secret);
     //set the default endpoint
     $this->setEndpoint($this->endpoints[$this->location]);
 }
Ejemplo n.º 16
0
 /**
  * return the current session
  *
  * @return mixed[object|bool]
  */
 static function current()
 {
     //if the user is logged in, they check() will return their ID as an INT
     //otherwise bool false
     $check = self::check();
     if (!is_int($check) and $check > 0) {
         return false;
     }
     //get our config memeber settings (table / column names)
     $config = Config::settings('member');
     //get the user - but we havent specified a table at this point
     $model = Model::init()->where('id', $check);
     //so force the table here
     $model->table = $config['table'];
     //now we can execute and request just the first result
     $result = $model->go(1);
     //check we have an object back and its not empty
     if ($result instanceof Model and !empty($result)) {
         //and return to muma.
         return $result;
     }
     //if we got here, they're not from around here
     return false;
 }
Ejemplo n.º 17
0
 /**
  * cache our output if required
  *
  * @return object
  */
 function cache($duration = null)
 {
     if ($duration === false) {
         return $this;
     }
     //if no value was passed into the function
     if (is_null($duration)) {
         //use the config value
         $config = Config::settings('cache');
         $duration = $config['duration'];
     }
     //init with the key
     $cache = Cache::init();
     //if cache is available and within the time limit
     if ($cache->setDuration($duration)->exists()) {
         //get the cache
         $this->body = $cache->get();
         //set the flag
         $this->cache_exists = true;
     } else {
         //run the body method to get the content before caching
         $this->body();
         //now we have a body set, set the cache with the time limit
         $cache->set($this->body);
     }
     return $this;
 }