/** * Redirect the page after a POST form is submitted and forward any user notices * @return mixed */ public function check_for_redirect() { if (array_key_exists('no_redirect', $this->module_exec->handler_response) && $this->module_exec->handler_response['no_redirect']) { return 'noredirect'; } if (!empty($this->request->post) && $this->request->type == 'HTTP') { $msgs = Hm_Msgs::get(); if (!empty($msgs)) { $this->session->secure_cookie($this->request, 'hm_msgs', base64_encode(serialize($msgs)), 0); } $this->session->end(); if (array_key_exists('REQUEST_URI', $this->request->server)) { Hm_Dispatch::page_redirect($this->request->server['REQUEST_URI']); } return 'redirect'; } elseif (array_key_exists('hm_msgs', $this->request->cookie) && trim($this->request->cookie['hm_msgs'])) { $msgs = @unserialize(base64_decode($this->request->cookie['hm_msgs'])); if (is_array($msgs)) { array_walk($msgs, function ($v) { Hm_Msgs::add($v); }); } $this->session->secure_cookie($this->request, 'hm_msgs', '', 0); return 'msg_forward'; } return false; }
public function process() { if (array_key_exists('state', $this->request->get) && $this->request->get['state'] == 'github_authorization') { if (array_key_exists('code', $this->request->get)) { $details = github_connect_details($this->config); $oauth2 = new Hm_Oauth2($details['client_id'], $details['client_secret'], $details['redirect_uri']); $result = $oauth2->request_token($details['token_url'], $this->request->get['code']); if (!empty($result) && array_key_exists('access_token', $result)) { Hm_Msgs::add('Github connection established'); $this->user_config->set('github_connect_details', $result); $user_data = $this->user_config->dump(); $this->session->set('user_data', $user_data); $this->session->record_unsaved('Github connection'); $this->session->secure_cookie($this->request, 'hm_reload_folders', '1'); $this->session->close_early(); } else { Hm_Msgs::add('ERRAn Error Occurred'); } } elseif (array_key_exists('error', $this->request->get)) { Hm_Msgs::add('ERR' . ucwords(str_replace('_', ' ', $this->request->get['error']))); } else { Hm_Msgs::add('ERRAn Error Occurred'); } $msgs = Hm_Msgs::get(); $this->session->secure_cookie($this->request, 'hm_msgs', base64_encode(serialize($msgs)), 0); Hm_Dispatch::page_redirect('?page=servers'); } }
/** * Validate a form key. If this is a non-empty POST form from an * HTTP request or AJAX update, it will take the user to the home * page if the page_key value is either not present or not valid * @return void */ public function process_key() { if (empty($this->request->post)) { return false; } $key = array_key_exists('hm_page_key', $this->request->post) ? $this->request->post['hm_page_key'] : false; $valid = Hm_Request_Key::validate($key); if (!$valid) { if ($this->request->type == 'AJAX') { if (DEBUG_MODE) { Hm_Debug::add('REQUEST KEY check failed'); Hm_Debug::load_page_stats(); Hm_Debug::show('log'); } Hm_Functions::cease(json_encode(array('status' => 'not callable'))); return 'exit'; } else { if ($this->session->loaded) { $this->session->destroy($this->request); } Hm_Debug::add('REQUEST KEY check failed'); Hm_Dispatch::page_redirect('?page=home'); return 'redirect'; } } return false; }
public function process() { if (array_key_exists('state', $this->request->get) && $this->request->get['state'] == 'nux_authorization') { if (array_key_exists('code', $this->request->get)) { $details = $this->session->get('nux_add_service_details'); $oauth2 = new Hm_Oauth2($details['client_id'], $details['client_secret'], $details['redirect_uri']); $result = $oauth2->request_token($details['token_uri'], $this->request->get['code']); if (!empty($result) && array_key_exists('access_token', $result)) { Hm_IMAP_List::add(array('name' => $details['name'], 'server' => $details['server'], 'port' => $details['port'], 'tls' => $details['tls'], 'user' => $details['email'], 'pass' => $result['access_token'], 'expiration' => strtotime(sprintf("+%d seconds", $result['expires_in'])), 'refresh_token' => $result['refresh_token'], 'auth' => 'xoauth2')); if (isset($details['smtp'])) { Hm_SMTP_List::add(array('name' => $details['name'], 'server' => $details['smtp']['server'], 'port' => $details['smtp']['port'], 'tls' => $details['smtp']['tls'], 'auth' => 'xoauth2', 'user' => $details['email'], 'pass' => $result['access_token'], 'expiration' => strtotime(sprintf("+%d seconds", $result['expires_in'])), 'refresh_token' => $result['refresh_token'])); $this->session->record_unsaved('SMTP server added'); $smtp_servers = Hm_SMTP_List::dump(false, true); $this->user_config->set('smtp_servers', $smtp_servers); } Hm_Msgs::add('E-mail account successfully added'); $servers = Hm_IMAP_List::dump(false, true); $this->user_config->set('imap_servers', $servers); Hm_IMAP_List::clean_up(); $user_data = $this->user_config->dump(); if (!empty($user_data)) { $this->session->set('user_data', $user_data); } $this->session->del('nux_add_service_details'); $this->session->record_unsaved('IMAP server added'); $this->session->secure_cookie($this->request, 'hm_reload_folders', '1'); $this->session->close_early(); } else { Hm_Msgs::add('ERRAn Error Occurred'); } } elseif (array_key_exists('error', $this->request->get)) { Hm_Msgs::add('ERR' . ucwords(str_replace('_', ' ', $this->request->get['error']))); } else { Hm_Msgs::add('ERRAn Error Occurred'); } $msgs = Hm_Msgs::get(); $this->session->secure_cookie($this->request, 'hm_msgs', base64_encode(serialize($msgs)), 0); Hm_Dispatch::page_redirect('?page=servers'); } }
protected function output() { if (!$this->get('internal_users') || !$this->get('is_admin', false)) { Hm_Dispatch::page_redirect('?page=home'); } return '<div class="content_title">' . $this->trans('Create Account') . '</div>' . '<div class="create_user">' . '<form method="POST" autocomplete="off" >' . '<input type="hidden" name="hm_page_key" value="' . Hm_Request_Key::generate() . '" />' . '<input style="display:none" type="text" name="fake_username" />' . '<input style="display:none" type="password" name="fake_password" />' . ' <input required type="text" placeholder="' . $this->trans('Username') . '" name="create_username" value="">' . ' <input type="password" required placeholder="' . $this->trans('Password') . '" name="create_password">' . ' <input type="password" required placeholder="' . $this->trans('Password Again') . '" name="create_password_again">' . ' <input type="submit" name="create_hm_user" value="' . $this->trans('Create') . '" />' . '</form></div>'; }