public function query($query, array $values = NULL, $returnType = 'DBCMySQLResult') { $start = self::__precisionTimer(); $result = parent::query($query, $values, $returnType); $query = preg_replace(array('/[\\r\\n]/', '/\\s{2,}/'), ' ', $query); if (!is_array(self::$query_log)) { self::$query_log = array(); } self::$query_log[] = (object) array('query' => $query, 'time' => self::__precisionTimer('stop', $start)); return $result; }
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; }
// Missing password // Missing first name // Missing Last name // Missing Email Address if (missing(array($settings['user']['username'], $settings['user']['password'], $settings['user']['first-name'], $settings['user']['last-name'], $settings['user']['email-address']))) { $errors->append('user', 'Username, Password, First Name, Last Name and Email Address are all required fields.'); } elseif (preg_match('/[\\s]/i', $settings['user']['username'])) { $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);