result = null; $this->error = null; $this-> id = $id; } protected function getResponse(){ return array( 'result' => $this->result, 'error' => $this->error, 'id' => $this->id ); } protected function isLoggedIn($params){ list($sessionid, $kp3) = explode(":", $params['auth']); if($GLOBALS['phpgw']->session->verify($sessionid, $kp3)){ return true; } else{ $this-> error = "You are not logged in"; return false; } } public function login($params){ if(!$this-> isLoggedIn($params)) { if($params['auth'] != "") { $this->error = "Your auth is invalid"; } elseif($sessionid = $GLOBALS['phpgw']->session->create($params['user'], $params['password'])) { $this->error = null; $this->result = array('auth' => $sessionid.":".$GLOBALS['phpgw']->session->kp3); } else { $this-> error = $GLOBALS['phpgw']->session->reason; } } else { $this->result = array('auth' => $params['auth']); } return $this->getResponse(); } public function logout($params){ if($this->isLoggedIn($params)) { if (file_exists($GLOBALS['phpgw_info']['server']['temp_dir'].SEP.$_SESSION['phpgw_session']['session_id'])) { $dh = opendir($GLOBALS['phpgw_info']['server']['temp_dir']. SEP . $_SESSION['phpgw_session']['session_id']); while ($file = readdir($dh)) { if ($file != '.' && $file != '..') { unlink($GLOBALS['phpgw_info']['server']['temp_dir'].SEP.$_SESSION['phpgw_session']['session_id'].SEP.$file); } } rmdir($GLOBALS['phpgw_info']['server']['temp_dir'].SEP.$_SESSION['phpgw_session']['session_id']); } $GLOBALS['phpgw']->hooks->process('logout'); $GLOBALS['phpgw']->session->destroy($_SESSION['phpgw_session']['session_id'], $GLOBALS['kp3']); $this->result = true; } return $this->getResponse(); } }