コード例 #1
0
 public function initialiseDatabase()
 {
     $details = (object) Symphony::Configuration()->db();
     $db = new DBCMySQLProfiler();
     if ($details->runtime_character_set_alter == 'yes') {
         $db->character_encoding = $details->character_encoding;
         $db->character_set = $details->character_set;
     }
     $connection_string = sprintf('mysql://%s:%s@%s:%s/%s/', $details->user, $details->password, $details->host, $details->port, $details->db);
     $db->connect($connection_string);
     $db->prefix = $details->{'table-name-prefix'};
     $db->force_query_caching = NULL;
     if (!is_null($details->disable_query_caching)) {
         $db->force_query_caching = $details->disable_query_caching == 'yes' ? true : false;
     }
     self::$Database = $db;
     return true;
 }
コード例 #2
0
ファイル: index.php プロジェクト: brendo/symphony-3
     $errors->append('user', 'Username is invalid.');
 } elseif ($settings['user']['password'] != $settings['user']['confirm-password']) {
     $errors->append('user', 'Passwords do not match.');
 } elseif (!preg_match('/^\\w(?:\\.?[\\w%+-]+)*@\\w(?:[\\w-]*\\.)+?[a-z]{2,}$/i', $settings['user']['email-address'])) {
     $errors->append('user', 'Email Address is invalid.');
 }
 if ($errors->length() == 0) {
     /// Create a DB connection --------------------------------------------------------------------------
     $db = new DBCMySQLProfiler();
     $db->character_encoding = 'utf8';
     $db->character_set = 'utf8';
     $db->force_query_caching = false;
     $db->prefix = $settings['database']['table-prefix'];
     $connection_string = sprintf('mysql://%s:%s@%s:%s/%s/', $settings['database']['username'], $settings['database']['password'], $settings['database']['host'], $settings['database']['port'], $settings['database']['database']);
     try {
         $db->connect($connection_string);
     } catch (DatabaseException $e) {
         $errors->append('database', 'Could not establish database connection. The following error was returned: ' . $e->getMessage());
     }
     if ($errors->length() == 0) {
         $permission = intval($settings['server-preferences']['directory-permissions'], 8);
         /// Create the .htaccess ------------------------------------------------------------------
         $rewrite_base = preg_replace('/\\/install$/i', NULL, dirname($_SERVER['PHP_SELF']));
         $htaccess = sprintf(file_get_contents('assets/template.htaccess.txt'), empty($rewrite_base) ? '/' : $rewrite_base);
         // Cannot write .htaccess
         if (!General::writeFile(sprintf('%s/.htaccess', rtrim($settings['server-preferences']['path'], '/')), $htaccess, $settings['server-preferences']['file-permissions'])) {
             throw new Exception('Could not write .htaccess file. TODO: Handle this by recording to the log and showing nicer error page.');
         }
         /// Create Folder Structures ---------------------------------------------------------------
         // These folders are necessary, and can be created if missing
         $folders = array('workspace', 'workspace/views', 'workspace/utilities', 'workspace/sections', 'workspace/data-sources', 'workspace/events', 'manifest', 'manifest/conf', 'manifest/logs', 'manifest/templates', 'manifest/tmp', 'manifest/cache');