public function __construct() { $this->db = Lib_Registry::get('db'); $tbl1 = $this->db->fetchCol('SHOW COLUMNS FROM auth'); $tbl2 = $this->db->fetchCol('SHOW COLUMNS FROM useraccounts'); $this->fields = array_merge($tbl1, $tbl2); }
public function put() { if (!($id = $this->getRequest()->getId())) { $this->getResponse()->setBody(array('status' => 'failed', 'message' => 'ID required')); return; } $db = Lib_Registry::get('db'); $password = $this->getRequest()->getParam('password', false); if (!$password) { $this->getResponse()->setBody(array('status' => 'failed', 'message' => 'Required parameter: password')); return; } // verify if the account exists $res = $db->fetchRow("SELECT UUID,passwordHash,passwordSalt FROM auth WHERE UUID=\"{$id}\""); if (!$res) { $this->getResponse()->setBody(array('status' => 'failed', 'message' => 'Account not found')); return; } Lib_Registry::get('db')->update('auth', array('passwordHash' => md5(md5($password) . ':' . $res['passwordSalt'])), "UUID=\"{$id}\""); $this->getResponse()->setBody(array('status' => 'success', 'message' => 'Password updated')); }
public function __construct() { $this->db = Lib_Registry::get('db'); }