Exemple #1
0
 function onAppExit($render = TRUE)
 {
     if (APP_USE_CART) {
         $this->_shoppingCart->save();
     }
     $ltime = microtime() - MateApplication::$startTime;
     Logger::log("LogicTime", "{$ltime} segs");
     Logger::log("RenderTime", "{PUT_RENDER_TIME_HERE} segs");
     Logger::log("TotalTime", "{PUT_TOTAL_TIME_HERE} segs");
     $renderStart = microtime();
     import("view.Cache");
     if ($render !== FALSE) {
         if (APP_USE_TEMPLATES) {
             if (APP_DEBUG_MODE) {
                 $debugContent = Config::exists("APP_DEBUG_TEMPLATE") ? View::load(APP_DEBUG_TEMPLATE, array("debug" => Logger::render(console))) : "<div class=\"debug\">" . Logger::render(console) . "</div>";
                 $this->view->set("debug", $debugContent);
             }
             switch ($render) {
                 case "referer":
                     echo redirectToReferer();
                     return false;
                     die("");
                 case "error404":
                     header("HTTP/1.0 404 Not Found");
                     $this->setContent("error/404");
                     break;
                 default:
                     //							$result = $this->view->render();
                     break;
             }
             $result = $this->view->render();
             /*$cache = new Cache("cache");
             		$ca*/
             if (VIEW_USE_TIDY) {
                 if (function_exists(tidy)) {
                     $config = array('indent' => true, 'output-xhtml' => true, 'wrap' => 200);
                     $tidy = new tidy();
                     $tidy->parseString($result, $config, 'utf8');
                     $tidy->cleanRepair();
                     $result = $tidy;
                 }
             }
             echo str_replace(array("{PUT_RENDER_TIME_HERE}", "{PUT_TOTAL_TIME_HERE}"), array(microtime() - $renderStart, microtime() - MateApplication::$startTime), $result);
         } else {
             if (APP_DEBUG_MODE) {
                 echo "<div class=\"debug\">" . Logger::render("console") . "</div>";
             }
         }
     } else {
         //if(APP_DEBUG_MODE) echo "<div class=\"debug\">".Logger::render()."</div>";
     }
     //echo Logger::log("LogicTime",MateApplication::$endTime-MateApplication::$startTime);
 }
Exemple #2
0
 /**
  * @param string $username
  *
  * @return boolean
  */
 public function inWhitelist($username)
 {
     $username = strtolower($username);
     if ($this->isOp($username)) {
         return true;
     } elseif ($this->server->api->dhandle("api.ban.whitelist.check", $username) === false) {
         return true;
     } elseif ($this->whitelist->exists($username, true)) {
         return true;
     }
     return false;
 }
 public static function getAll($context)
 {
     if (self::$loader == null) {
         new self();
     }
     if (!Config::exists($context)) {
         return array();
     }
     if (!isset(self::$configurations[$context])) {
         return array();
     }
     return self::$configurations[$context];
 }
 public function __construct()
 {
     parent::__construct();
     // Let's register the options page form so we can use it with ajax
     $self = $this;
     FormUI::register('admin_options', function ($form, $name, $extra_data) use($self) {
         $option_items = array();
         $timezones = \DateTimeZone::listIdentifiers();
         $timezones = array_merge(array('' => ''), array_combine(array_values($timezones), array_values($timezones)));
         $option_items[_t('Name & Tagline')] = array('title' => array('label' => _t('Site Name'), 'type' => 'text', 'helptext' => ''), 'tagline' => array('label' => _t('Site Tagline'), 'type' => 'text', 'helptext' => ''), 'about' => array('label' => _t('About'), 'type' => 'textarea', 'helptext' => ''));
         $option_items[_t('Publishing')] = array('pagination' => array('label' => _t('Items per Page'), 'type' => 'text', 'helptext' => ''), 'atom_entries' => array('label' => _t('Entries to show in Atom feed'), 'type' => 'text', 'helptext' => ''), 'comments_require_id' => array('label' => _t('Require Comment Author Email'), 'type' => 'checkbox', 'helptext' => ''), 'spam_percentage' => array('label' => _t('Comment SPAM Threshold'), 'type' => 'text', 'helptext' => _t('The likelihood a comment is considered SPAM, in percent.')));
         $option_items[_t('Time & Date')] = array('timezone' => array('label' => _t('Time Zone'), 'type' => 'select', 'selectarray' => $timezones, 'helptext' => _t('Current Date Time: %s', array(DateTime::create()->format()))), 'dateformat' => array('label' => _t('Date Format'), 'type' => 'text', 'helptext' => _t('Current Date: %s', array(DateTime::create()->date))), 'timeformat' => array('label' => _t('Time Format'), 'type' => 'text', 'helptext' => _t('Current Time: %s', array(DateTime::create()->time))));
         $option_items[_t('Language')] = array('locale' => array('label' => _t('Locale'), 'type' => 'select', 'selectarray' => array_merge(array('' => 'default'), array_combine(Locale::list_all(), Locale::list_all())), 'helptext' => Config::exists('locale') ? _t('International language code : This value is set in your config.php file, and cannot be changed here.') : _t('International language code'), 'disabled' => Config::exists('locale'), 'value' => Config::get('locale', Options::get('locale', 'en-us'))), 'system_locale' => array('label' => _t('System Locale'), 'type' => 'text', 'helptext' => _t('The appropriate locale code for your server')));
         $option_items[_t('Troubleshooting')] = array('log_min_severity' => array('label' => _t('Minimum Severity'), 'type' => 'select', 'selectarray' => LogEntry::list_severities(), 'helptext' => _t('Only log entries with a this or higher severity.')), 'log_backtraces' => array('label' => _t('Log Backtraces'), 'type' => 'checkbox', 'helptext' => _t('Logs error backtraces to the log table\'s data column. Can drastically increase log size!')));
         $option_items = Plugins::filter('admin_option_items', $option_items);
         $tab_index = 3;
         foreach ($option_items as $name => $option_fields) {
             /** @var FormControlFieldset $fieldset  */
             $fieldset = $form->append(FormControlWrapper::create(Utils::slugify(_u($name)))->set_properties(array('class' => 'container main settings')));
             $fieldset->append(FormControlStatic::create($name)->set_static('<h2 class="lead">' . htmlentities($name, ENT_COMPAT, 'UTF-8') . '</h2>'));
             $fieldset->set_wrap_each('<div>%s</div>');
             foreach ($option_fields as $option_name => $option) {
                 /** @var FormControlLabel $label */
                 $label = $fieldset->append(FormControlLabel::create('label_for_' . $option_name, null)->set_label($option['label']));
                 /** @var FormControl $field */
                 $field = $label->append($option['type'], $option_name, $option_name);
                 $label->set_for($field);
                 if (isset($option['value'])) {
                     $field->set_value($option['value']);
                 }
                 if (isset($option['disabled']) && $option['disabled'] == true) {
                     $field->set_properties(array('disabled' => 'disabled'));
                 }
                 if ($option['type'] == 'select' && isset($option['selectarray'])) {
                     $field->set_options($option['selectarray']);
                 }
                 $field->tabindex = $tab_index;
                 $tab_index++;
                 if (isset($option['helptext'])) {
                     $field->set_helptext($option['helptext']);
                 }
             }
         }
         $buttons = $form->append(new FormControlWrapper('buttons', null, array('class' => 'container')));
         $buttons->append(FormControlSubmit::create('apply', null, array('tabindex' => $tab_index))->set_caption(_t('Apply')));
         $form->on_success(array($self, 'form_options_success'));
         $form = Plugins::filter('admin_options_form', $form);
     });
 }
Exemple #5
0
 static function init()
 {
     define("DS", DIRECTORY_SEPARATOR);
     // Constants
     define('DOCROOT', dirname($_SERVER["SCRIPT_FILENAME"]) . DS);
     // Derive Some Config variables from URL
     $_base = function () {
         $_b = explode(DS, $_SERVER["SCRIPT_NAME"]);
         return substr($_SERVER["SCRIPT_NAME"], 0, strlen($_b[sizeof(explode(DS, $_SERVER["SCRIPT_NAME"])) - 1]) * -1);
     };
     \Fw\Config::set("base", $_base());
     $_SERVER["HTTPS"] = isset($_SERVER["HTTPS"]) ? $_SERVER["HTTPS"] : "off";
     if (isset($_SERVER["SERVER_NAME"])) {
         \Fw\Config::set("domain", @$_SERVER["HTTPS"] == "on" ? "https://" . $_SERVER["SERVER_NAME"] : "http://" . $_SERVER["SERVER_NAME"]);
     } else {
         \Fw\Config::set("domain", "");
     }
     // Set Application Directory to server path
     if (!Config::exists("apppath")) {
         $app_path = DOCROOT;
     } else {
         $app_path = Config::get("apppath");
     }
     // Autoload Application Class
     \Fw\Autoload::add_path($app_path . "classes");
     // PHP Composer Autoloader
     if (file_exists($app_path . "/vendor/autoload.php")) {
         include $app_path . "/vendor/autoload.php";
     }
     // Configuration
     \Fw\Config::set("docroot", DOCROOT);
     // doc root
     \Fw\Config::set("apppath", $app_path);
     // application path
     // Finder Paths
     Find::add_path_to("controllers", \Fw\Config::get("apppath") . "controllers");
     Find::add_path_to("views", Config::get("apppath") . "views");
     Find::add_path_to("assets", Config::get("apppath") . "assets");
     Find::add_path_to("assets", Config::get("apppath") . "bower_components");
     Find::add_path_to("modules", Config::get("apppath") . "modules");
 }
Exemple #6
0
 /**
  * @param $key
  *
  * @return mixed
  *
  * @since 1.0.0
  */
 public function exists($key)
 {
     return $this->data->exists($key);
 }
Exemple #7
0
 protected function checkModule()
 {
     if (Config::exists('modules.Session.User.enabled')) {
         if (Config::read('modules.Session.User.enabled') === true) {
             $this->User = UserSession::getInstance();
         }
     } else {
         if (Config::exists('modules.Session.enabled')) {
             if (Config::read('modules.Session.User.enabled') === true) {
                 $this->Session = Session::getInstance();
             }
         }
     }
 }
Exemple #8
0
 public function __construct($uri, $method = null, array $params = [])
 {
     $this->_from_ajax = isset($_SERVER['HTTP_X_REQUESTED_WITH']);
     $this->_response = new Response();
     //Request method
     if (empty($method)) {
         if (isset($_POST['__method__'])) {
             $this->_method = strtolower($_POST['__method__']);
         } else {
             if (isset($_GET['__method__'])) {
                 $this->_method = strtolower($_GET['__method__']);
             } else {
                 $this->_method = strtolower($_SERVER['REQUEST_METHOD']);
             }
         }
     } else {
         $this->_method = strtolower($method);
     }
     if (empty($params)) {
         $this->_post_params = $_POST;
         $this->_get_params = $_GET;
         $this->_put_params = self::getPutParams();
     } else {
         switch ($this->_method) {
             case self::GET:
                 $this->_get_params = $params;
                 break;
             case self::POST:
                 $this->_post_params = $params;
                 break;
             case self::PUT:
                 $this->_put_params = $params;
                 break;
         }
         //Add GET params from URI
         $indexParams = strrpos($uri, '?');
         if ($indexParams > -1) {
             $additionnal_params = [];
             parse_str(substr($uri, $indexParams + 1), $additionnal_params);
             $this->_get_params = array_merge($this->_get_params, $additionnal_params);
         }
     }
     //Get URI
     $this->_uri = $uri;
     if (empty(self::$routing)) {
         self::$routing = Config('main')->ROUTING;
         // Add routes from the routing config file if it exists
         if (Config::exists('routing') !== null) {
             self::$routing = array_replace_recursive(self::$routing, Config('routing')->ROUTING);
         }
     }
     if (strpos($this->_uri, self::$routing['BASE_URL']) !== 0) {
         if (empty($method) && empty($params)) {
             $this->_response->error('Constant ROUTING.BASE_URL (' . self::$routing['BASE_URL'] . ') from main configuration file does not start with received URI.');
             return;
         } else {
             $this->_uri = self::$routing['BASE_URL'] . $this->_uri;
         }
     }
     $this->_checkPath();
 }
Exemple #9
0
 function set($cnfgName, $cnfgValue)
 {
     if (!Config::exists($cnfgName)) {
         define($cnfgName, $cnfgValue);
     }
 }
Exemple #10
0
 /**
  * @test
  */
 public function testComplexSubKeys()
 {
     $c = new Config();
     // 1
     $c->set('t3.test1.foo.bar.asd', false);
     $this->assertTrue($c->exists('t3.test1.foo.bar.asd'));
     $this->assertTrue($c->exists('t3.test1.foo.bar'));
     $this->assertTrue($c->exists('t3.test1.foo'));
     $this->assertTrue($c->exists('t3.test1'));
     // 2
     $t2a->a = 'b';
     $t2b->foo = 'bar';
     $t2b->bar = array('a' => $t2a, 'b' => false);
     $t2c = array('foo' => $t2b, 'bar' => 666);
     $c->set('t3.test2', $t2c);
     // 2 - getting
     $this->assertEquals($t2c, $c->get('t3.test2'));
     $this->assertEquals($t2b, $c->get('t3.test2.foo'));
     $this->assertSame(666, $c->get('t3.test2.bar'));
     $this->assertSame('bar', $c->get('t3.test2.foo.foo'));
     $this->assertEquals($t2b->bar, $c->get('t3.test2.foo.bar'));
     $this->assertFalse($c->get('t3.test2.foo.bar.b'));
     $this->assertSame($t2a, $c->get('t3.test2.foo.bar.a'));
     $this->assertSame('b', $c->get('t3.test2.foo.bar.a.a'));
     // 2 - exists
     $this->assertTrue($c->exists('t3.test2'));
     $this->assertTrue($c->exists('t3.test2.foo'));
     $this->assertTrue($c->exists('t3.test2.bar'));
     $this->assertTrue($c->exists('t3.test2.foo.foo'));
     $this->assertTrue($c->exists('t3.test2.foo.bar'));
     $this->assertTrue($c->exists('t3.test2.foo.bar.b'));
     $this->assertTrue($c->exists('t3.test2.foo.bar.a'));
     // 2 - setting
     $c->set('t3.test2.foo.bar.a.a', true);
     $this->assertTrue($c->get('t3.test2.foo.bar.a.a'));
     // 2 - deleting
     $c->delete('t3.test2.foo.bar.a');
     $this->assertFalse($c->exists('t3.test2.foo.bar.a'));
     $this->assertFalse($c->exists('t3.test2.foo.bar.a.a'));
     $c->delete('t3.test2.foo.bar');
     $this->assertFalse($c->exists('t3.test2.foo.bar'));
     $this->assertFalse($c->exists('t3.test2.foo.bar.b'));
     $this->assertFalse($c->exists('t3.test2.foo.bar.a'));
     $c->delete('t3.test2.nosuchkey');
 }
Exemple #11
0
 /**
  * Run checks
  */
 public static function run()
 {
     $all_pass = true;
     foreach (self::$checks as $parameter => $checks) {
         $value = Config::get($parameter);
         foreach ($checks as $ored) {
             $pass = false;
             $error = '';
             if (is_array($ored)) {
                 $error = '"' . implode('|', $ored) . '"';
                 foreach ($ored as $check) {
                     if (substr($check, 0, 3) == 'is_') {
                         $check = substr($check, 3);
                     }
                     switch ($check) {
                         case 'set':
                             $pass |= Config::exists($parameter);
                             break;
                         case 'not_empty':
                             $pass |= !empty($value);
                             break;
                         case 'null':
                             $pass |= $value === null;
                             break;
                         case 'bool':
                             $pass |= is_bool($value);
                             break;
                         case 'string':
                             $pass |= is_string($value);
                             break;
                         case 'int':
                             $pass |= is_int($value);
                             break;
                         case 'float':
                             $pass |= is_float($value);
                             break;
                         case 'array':
                             $pass |= is_array($value);
                             break;
                         case 'callable':
                             $pass |= is_callable($value);
                             break;
                     }
                     if ($pass) {
                         break;
                     }
                     // Stop on first true or component
                 }
             } elseif (is_callable($ored)) {
                 $pass = $ored($value, $error);
             }
             if (!$pass) {
                 error_log('ConfigValidator "' . $parameter . '" does not validate check : ' . $error);
                 $all_pass = false;
                 break;
             }
         }
     }
     if (!$all_pass) {
         die('Configuration error(s), please check the server logs or ask an admin to do so.');
     }
 }
 /**
  * Handles POST requests from the options admin page
  */
 public function post_options()
 {
     $option_items = array();
     $timezones = DateTimeZone::listIdentifiers();
     $timezones = array_merge(array('' => ''), array_combine(array_values($timezones), array_values($timezones)));
     $option_items[_t('Name & Tagline')] = array('title' => array('label' => _t('Site Name'), 'type' => 'text', 'helptext' => ''), 'tagline' => array('label' => _t('Site Tagline'), 'type' => 'text', 'helptext' => ''), 'about' => array('label' => _t('About'), 'type' => 'textarea', 'helptext' => ''));
     $option_items[_t('Publishing')] = array('pagination' => array('label' => _t('Items per Page'), 'type' => 'text', 'helptext' => ''), 'atom_entries' => array('label' => _t('Entries to show in Atom feed'), 'type' => 'text', 'helptext' => ''), 'comments_require_id' => array('label' => _t('Require Comment Author Info'), 'type' => 'checkbox', 'helptext' => ''), 'spam_percentage' => array('label' => _t('Comment SPAM Threshold'), 'type' => 'text', 'helptext' => _t('The likelihood a comment is considered SPAM, in percent.')));
     $option_items[_t('Time & Date')] = array('timezone' => array('label' => _t('Time Zone'), 'type' => 'select', 'selectarray' => $timezones, 'helptext' => _t('Current Date Time: %s', array(HabariDateTime::date_create()->format()))), 'dateformat' => array('label' => _t('Date Format'), 'type' => 'text', 'helptext' => _t('Current Date: %s', array(HabariDateTime::date_create()->date))), 'timeformat' => array('label' => _t('Time Format'), 'type' => 'text', 'helptext' => _t('Current Time: %s', array(HabariDateTime::date_create()->time))));
     $option_items[_t('Language')] = array('locale' => array('label' => _t('Locale'), 'type' => 'select', 'selectarray' => array_merge(array('' => 'default'), array_combine(HabariLocale::list_all(), HabariLocale::list_all())), 'helptext' => Config::exists('locale') ? _t('International language code : This value is set in your config.php file, and cannot be changed here.') : _t('International language code'), 'disabled' => Config::exists('locale'), 'value' => Config::get('locale', Options::get('locale', 'en-us'))), 'system_locale' => array('label' => _t('System Locale'), 'type' => 'text', 'helptext' => _t('The appropriate locale code for your server')));
     $option_items[_t('Troubleshooting')] = array('log_min_severity' => array('label' => _t('Minimum Severity'), 'type' => 'select', 'selectarray' => LogEntry::list_severities(), 'helptext' => _t('Only log entries with a this or higher severity.')), 'log_backtraces' => array('label' => _t('Log Backtraces'), 'type' => 'checkbox', 'helptext' => _t('Logs error backtraces to the log table\'s data column. Can drastically increase log size!')));
     /*$option_items[_t('Presentation')] = array(
     		'encoding' => array(
     			'label' => _t('Encoding'),
     			'type' => 'select',
     			'selectarray' => array(
     				'UTF-8' => 'UTF-8'
     				),
     			'helptext' => '',
     			),
     		);*/
     $option_items = Plugins::filter('admin_option_items', $option_items);
     $form = new FormUI('Admin Options');
     $tab_index = 3;
     foreach ($option_items as $name => $option_fields) {
         $fieldset = $form->append('wrapper', Utils::slugify(_u($name)), $name);
         $fieldset->class = 'container settings';
         $fieldset->append('static', $name, '<h2>' . htmlentities($name, ENT_COMPAT, 'UTF-8') . '</h2>');
         foreach ($option_fields as $option_name => $option) {
             $field = $fieldset->append($option['type'], $option_name, $option_name, $option['label']);
             $field->template = 'optionscontrol_' . $option['type'];
             $field->class = 'item clear';
             if (isset($option['value'])) {
                 $field->value = $option['value'];
             }
             if (isset($option['disabled'])) {
                 $field->disabled = $option['disabled'];
             }
             if ($option['type'] == 'select' && isset($option['selectarray'])) {
                 $field->options = $option['selectarray'];
             }
             $field->tabindex = $tab_index;
             $tab_index++;
             if (isset($option['helptext'])) {
                 $field->helptext = $option['helptext'];
             } else {
                 $field->helptext = '';
             }
         }
     }
     /* @todo: filter for additional options from plugins
      * We could either use existing config forms and simply extract
      * the form controls, or we could create something different
      */
     $buttons = $form->append(new FormControlWrapper('buttons', 'buttons'));
     $buttons->class = 'container';
     $submit = $buttons->append('submit', 'apply', _t('Apply'), 'admincontrol_submit');
     $submit->tabindex = $tab_index;
     $form->on_success(array($this, 'form_options_success'));
     $this->theme->form = $form->get();
     $this->theme->option_names = array_keys($option_items);
     $this->theme->display('options');
 }
 /**
  * Get database table name
  * 
  * Database table has the same name as the class, except it plural (class User => table Users).
  * 
  * @return string table name
  */
 public static function getDBTable()
 {
     $class = static::getClassName();
     $name = property_exists($class, 'dataTable') ? static::$dataTable : $class . 's';
     if (Config::exists('db_table_prefix')) {
         $name = Config::get('db_table_prefix') . $name;
     }
     return $name;
 }
 /**
  * Returns some info about the status of this api
  *
  */
 public function getStatus()
 {
     $timestamp = $this->compiler ? $this->compiler->getTimestampSQL() : null;
     return array('version_libs' => Config::VERSION_LIBS, 'timestampSQL' => $timestamp ? date("Y-m-d H:i:s", $timestamp) : null, 'configExists' => Config::exists($this->configFile), 'dbError' => $this->dbError, 'dbStatus' => $this->db && $this->db->connected() ? 'Connected with ' . $this->db->dbname . ' at ' . $this->db->host : 'Not connected');
 }
Exemple #15
0
/**
 * We make sure the configuration file exist.
 * If it does, we load it and check it's validity.
 *
 * @todo Call the installer from the database classes.
 */
if (file_exists($config)) {
    require_once $config;
    // Set the default locale.
    HabariLocale::set(isset($locale) ? $locale : 'en-us');
    if (!defined('DEBUG')) {
        define('DEBUG', false);
    }
    // Make sure we have a DSN string and database credentials.
    // db_connection is an array with necessary informations to connect to the database.
    if (!Config::exists('db_connection')) {
        $installer = new InstallHandler();
        $installer->begin_install();
    }
    // Try to connect to the database.
    if (DB::connect()) {
        // Make sure Habari is installed properly.
        // If the 'installed' option is missing, we assume the database tables are missing or corrupted.
        // @todo Find a decent solution, we have to compare tables and restore or upgrade them.
        if (!@Options::get('installed')) {
            $installer = new InstallHandler();
            $installer->begin_install();
        }
    } else {
        $installer = new InstallHandler();
        $installer->begin_install();
Exemple #16
0
 /**
  * Writes the configuration file with the variables needed for
  * initialization of the application
  *
  * @param Bool $ignore_registry skip the configuration registry check (used in config rewrite)
  * @return  bool  Did the file get written?
  */
 private function write_config_file($ignore_registry = false)
 {
     // first, check if a config.php file exists
     if (file_exists(Site::get_dir('config_file'))) {
         // set the defaults for comparison
         $db_host = $this->handler_vars['db_host'];
         $db_file = $this->handler_vars['db_file'];
         $db_type = $this->handler_vars['db_type'];
         $db_schema = $this->handler_vars['db_schema'];
         $db_user = $this->handler_vars['db_user'];
         $db_pass = $this->handler_vars['db_pass'];
         $table_prefix = $this->handler_vars['table_prefix'];
         // set the connection string
         switch ($db_type) {
             case 'mysql':
                 $connection_string = "{$db_type}:host={$db_host};dbname={$db_schema}";
                 break;
             case 'pgsql':
                 $connection_string = "{$db_type}:host={$db_host} dbname={$db_schema}";
                 break;
             case 'sqlite':
                 $connection_string = "{$db_type}:{$db_file}";
                 break;
         }
         // load the config.php file
         include Site::get_dir('config_file');
         // and now we compare the values defined there to
         // the values POSTed to the installer
         if (!$ignore_registry && Config::exists('db_connection') && Config::get('db_connection')->connection_string == $connection_string && Config::get('db_connection')->username == $db_user && Config::get('db_connection')->password == $db_pass && Config::get('db_connection')->prefix == $table_prefix) {
             // the values are the same, so don't bother
             // trying to write to config.php
             return true;
         }
     }
     if (!($file_contents = file_get_contents(HABARI_PATH . "/system/schema/" . $this->handler_vars['db_type'] . "/config.php"))) {
         return false;
     }
     if ($file_contents = html_entity_decode($this->get_config_file())) {
         if ($file = @fopen(Site::get_dir('config_file'), 'w')) {
             if (fwrite($file, $file_contents, strlen($file_contents))) {
                 fclose($file);
                 return true;
             }
         }
         $this->handler_vars['config_file'] = Site::get_dir('config_file');
         $this->handler_vars['file_contents'] = Utils::htmlspecialchars($file_contents);
         $this->display('config');
         return false;
     }
     return false;
     // Only happens when config.php template does not exist.
 }
Exemple #17
0
 /**
  * Check if an option was set via the config, making it unsettable
  * @static
  * @param string $name The name of the option to check
  * @return bool True if the option is set in the config
  */
 public static function is_static($name)
 {
     if ($static_options = Config::exists('static_options')) {
         if (isset($static_options[$name])) {
             return true;
         }
     }
     return false;
 }
Exemple #18
0
 /**
  * Fetch all options from the options table into local storage
  */
 public function get_all_options()
 {
     // Set some defaults here
     $this->options = array('pagination' => 10, 'comments_require_id' => false);
     if (Config::exists('default_options')) {
         $this->options = array_merge($this->options, Config::get('default_options'));
     }
     $results = DB::get_results('SELECT name, value, type FROM {options}', array(), 'QueryRecord');
     foreach ($results as $result) {
         if ($result->type == 1) {
             $this->options[$result->name] = unserialize($result->value);
         } else {
             $this->options[$result->name] = $result->value;
         }
     }
     if (Config::exists('static_options')) {
         $this->options = array_merge($this->options, Config::get('static_options'));
     }
 }