Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function changePassword($newPassword) {
- $db = Loader::db();
- if ($this->uID) {
- $v = array(User::encryptPassword($newPassword), $this->uID);
- $q = "update Users set uPassword = ? where uID = ?";
- $r = $db->prepare($q);
- $res = $db->execute($r, $v);
- Events::fire('on_user_change_password', $this, $newPassword);
- return $res;
- }
- }
- public function db($server = null, $username = null, $password = null, $database = null, $create = false) {
- static $_db;
- if (!isset($_db) || $create) {
- if ($server == null && defined('DB_SERVER')) {
- $dsn = DB_TYPE . '://' . DB_USERNAME . ':' . rawurlencode(DB_PASSWORD) . '@' . rawurlencode(DB_SERVER) . '/' . DB_DATABASE;
- } else if ($server) {
- $dsn = DB_TYPE . '://' . $username . ':' . rawurlencode($password) . '@' . rawurlencode($server) . '/' . $database;
- }
- if (isset($dsn) && $dsn) {
- $_dba = @NewADOConnection($dsn);
- if (is_object($_dba)) {
- $_dba->setFetchMode(ADODB_FETCH_ASSOC);
- if (DB_CHARSET != '') {
- $names = 'SET NAMES \'' . DB_CHARSET . '\'';
- if (DB_COLLATE != '') {
- $names .= ' COLLATE \'' . DB_COLLATE . '\'';
- }
- $charset = 'SET CHARACTER SET \'' . DB_CHARSET . '\'';
- if (DB_COLLATE != '') {
- $charset .= ' COLLATE \'' . DB_COLLATE . '\'';
- }
- $_dba->Execute($names);
- $_dba->Execute($charset);
- }
- ADOdb_Active_Record::SetDatabaseAdapter($_dba);
- $_db = new Database();
- $_db->setDatabaseObject($_dba);
- //$_db->setLogging(true);
- } else if (defined('DB_SERVER')) {
- $v = View::getInstance();
- $v->renderError(t('Unable to connect to database.'), t('A database error occurred while processing this request.'));
- }
- } else {
- return false;
- }
- }
- return $_db;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement