Example #1
0
<?php

/**
 * Config settings
 *
 * @package Quantum
 * @package Config
 */
Config::setArray(array('database.connect.user' => 'databaseUser', 'database.connect.password' => 'databasePassword', 'database.connect.host' => 'databaseHost', 'database.connect.charset' => 'utf8', 'database.connect.database' => 'database', 'page.title' => 'Page Title', 'enabled.languages' => array('en', 'de', 'es'), 'default.language' => 'en', 'multilanguage' => true, 'admin.pager.curremt.page' => 1, 'admin.pager.rows.per.page' => 100, 'memcache.host' => 'localhost', 'memcache.port' => '11211'));
Example #2
0
 /**
  * Handles data coming from a post request  
  * @param array HTTP request
  */
 public function handleHttpPostRequest()
 {
     $request = Request::getInstance();
     try {
         if (!$request->exists('dsn')) {
             throw new Exception('DSN is missing.');
         }
         if (!$request->exists('username')) {
             throw new Exception('Username is missing.');
         }
         $sqlfile = DIF_ROOT . 'sql/dif.sql';
         if (!file_exists($sqlfile)) {
             throw new Exception('Database file is missing');
         }
         $this->configValues['login_username'] = $request->getValue('username');
         if ($request->getValue('password')) {
             if ($request->getValue('password') != $request->getValue('password1')) {
                 throw new Exception('Passwords do not match.');
             }
             $this->configValues['login_password'] = crypt($request->getValue('password'));
             $this->log->info("change administration password");
         }
         $this->configValues['enable_caching'] = $request->exists('caching') ? true : false;
         $this->configValues['admin_section_ip_allow'] = $request->getValue('admin_section_ip_allow');
         $this->configValues['email_address'] = $request->getValue('email_address');
         $this->configValues['email_host'] = $request->getValue('email_host');
         $this->configValues['email_username'] = $request->getValue('email_username');
         $this->configValues['email_password'] = $request->getValue('email_password');
         $this->configValues['dsn'] = $request->getValue('dsn');
         $config = new Config();
         $config->setArray($this->configValues);
         $this->director->setConfig($config);
         // log actions
         $this->log->info("set administration username to {$this->configValues['login_username']}");
         $this->log->info("set DSN to {$this->configValues['dsn']}");
         $this->log->info("set caching to {$this->configValues['enable_caching']}");
         // insert or update dif tables
         $db = $this->getDb();
         $query = file_get_contents($sqlfile);
         $queries = explode(';', $query);
         foreach ($queries as $table) {
             $table = trim($table);
             if (!$table) {
                 continue;
             }
             $res = $db->query($table);
             if ($db->isError($res)) {
                 throw new Exception($res->getDebugInfo());
             }
         }
         Utils::storeIniValues($this->configFile, $this->configFile, $this->configValues);
         $logging = array();
         // install plugins
         if ($request->exists('plugin')) {
             $logging = $this->installPlugins();
         }
         // install themes
         if ($request->exists('theme')) {
             array_merge($logging, $this->installThemes());
         }
         // install extensions
         if ($request->exists('extension')) {
             array_merge($logging, $this->installExtensions());
         }
         if ($logging) {
             throw new Exception(join("<br />", $logging));
         }
         // if virtual webroot is set, create symlinks to global directories
         /*TODO remove because new version uses copies instead of symlinks
         			if(strlen(DIF_VIRTUAL_WEB_ROOT) > 1)
         			{
         				if(!file_exists(DIF_INDEX_ROOT.'/images'))
         					symlink(DIF_WEB_ROOT.'images', DIF_INDEX_ROOT.'images');
         
         				if(!file_exists(DIF_INDEX_ROOT.'/userfiles'))
         					symlink(DIF_WEB_ROOT.'userfiles', DIF_INDEX_ROOT.'userfiles');
         
         				if(!file_exists(DIF_INDEX_ROOT.'/js'))
         					symlink(DIF_WEB_ROOT.'js', DIF_INDEX_ROOT.'js');
         
         				if(!file_exists(DIF_INDEX_ROOT.'/css'))
         					symlink(DIF_WEB_ROOT.'css', DIF_INDEX_ROOT.'css');
         			}
         			*/
         // redirect to Site
         $admintree = $this->director->adminManager->tree;
         $sitePath = $admintree->getPath($admintree->getIdFromClassname('Site'));
         header("Location: {$sitePath}");
         exit;
     } catch (Exception $e) {
         $template = new TemplateEngine();
         $template->setVariable('errorMessage', $e->getMessage(), false);
         $this->log->error($e->getMessage());
         $this->handleHttpGetRequest();
     }
 }