| 1: | <?php |
| 2: | |
| 3: | |
| 4: | |
| 5: | |
| 6: | |
| 7: | |
| 8: | if (!defined('DEBUG_MODE')) { die(); } |
| 9: | |
| 10: | |
| 11: | |
| 12: | |
| 13: | class Hm_Handler_api_login_step_two extends Hm_Handler_login { |
| 14: | public function process() { |
| 15: | list($success, $form) = $this->process_form(array('hm_id', 'hm_session', 'api_login_key')); |
| 16: | if (!$success) { |
| 17: | return; |
| 18: | } |
| 19: | if ($form['api_login_key'] != $this->config->get('api_login_key')) { |
| 20: | return; |
| 21: | } |
| 22: | list($secure, $path, $domain) = $this->session->set_session_params($this->request); |
| 23: | Hm_Functions::setcookie('hm_id', stripslashes($form['hm_id']), 0, $path, $domain, $secure, true, 'Lax'); |
| 24: | Hm_Functions::setcookie('hm_session', stripslashes($form['hm_session']), 0, $path, $domain, $secure, true, 'Lax'); |
| 25: | Hm_Dispatch::page_redirect('?page=home'); |
| 26: | } |
| 27: | } |
| 28: | |
| 29: | |
| 30: | |
| 31: | |
| 32: | class Hm_Handler_process_api_login extends Hm_Handler_login { |
| 33: | public function process() { |
| 34: | if (array_key_exists('api_login_key', $this->request->post) && |
| 35: | $this->request->post['api_login_key'] == $this->config->get('api_login_key')) { |
| 36: | $this->validate_request = false; |
| 37: | } |
| 38: | parent::process(); |
| 39: | if (!$this->validate_request && $this->session->is_active()) { |
| 40: | $this->user_config->load(rtrim($this->request->post['username']), $this->request->post['password']); |
| 41: | $user_data = $this->user_config->dump(); |
| 42: | $this->session->set('user_data', $user_data); |
| 43: | header('Content-Type: application/json'); |
| 44: | $res = array( |
| 45: | 'hm_id' => $this->session->enc_key, |
| 46: | 'hm_session' => $this->session->session_key |
| 47: | ); |
| 48: | echo json_encode($res); |
| 49: | $this->session->end(); |
| 50: | Hm_Debug::load_page_stats(); |
| 51: | Hm_Debug::show(); |
| 52: | Hm_Functions::cease(); |
| 53: | } |
| 54: | } |
| 55: | } |
| 56: | |