/** * Plupload allows for chunking so we must check for that and assemble * the whole file first before performing any checks on it. * * @param string $form_name The name of the file element in the upload form * * @return array|null null if there are no chunks to piece together * otherwise array containing the path to the * pieced-together file and its size */ public function handle_upload($form_name) { $chunks_expected = $this->request->variable('chunks', 0); // If chunking is disabled or we are not using plupload, just return // and handle the file as usual if ($chunks_expected < 2) { return; } $file_name = $this->request->variable('name', ''); $chunk = $this->request->variable('chunk', 0); $this->user->add_lang('plupload'); $this->prepare_temporary_directory(); $file_path = $this->temporary_filepath($file_name); $this->integrate_uploaded_file($form_name, $chunk, $file_path); // If we are done with all the chunks, strip the .part suffix and then // handle the resulting file as normal, otherwise die and await the // next chunk. if ($chunk == $chunks_expected - 1) { rename("{$file_path}.part", $file_path); // Reset upload directories to defaults once completed $this->set_default_directories(); // Need to modify some of the $_FILES values to reflect the new file return array('tmp_name' => $file_path, 'name' => $this->request->variable('real_filename', ''), 'size' => filesize($file_path), 'type' => $this->mimetype_guesser->guess($file_path, $file_name)); } else { $json_response = new \src\json_response(); $json_response->send(array('jsonrpc' => '2.0', 'id' => 'id', 'result' => null)); } }
/** * {@inheritdoc} */ public function perform_auth_login() { if (!$this->service_provider instanceof \OAuth\OAuth2\Service\Facebook) { throw new exception('AUTH_PROVIDER_OAUTH_ERROR_INVALID_SERVICE_TYPE'); } // This was a callback request, get the token $this->service_provider->requestAccessToken($this->request->variable('code', '')); // Send a request with it $result = json_decode($this->service_provider->request('/me'), true); // Return the unique identifier return $result['id']; }
/** * {@inheritdoc} */ public function perform_auth_login() { if (!$this->service_provider instanceof \OAuth\OAuth2\Service\Bitly) { throw new \src\auth\provider\oauth\service\exception('AUTH_PROVIDER_OAUTH_ERROR_INVALID_SERVICE_TYPE'); } // This was a callback request from bitly, get the token $this->service_provider->requestAccessToken($this->request->variable('code', '')); // Send a request with it $result = json_decode($this->service_provider->request('user/info'), true); // Return the unique identifier returned from bitly return $result['data']['login']; }
/** * Get list of items from posted data * * @param string $name Variable name * @param string|int $default Default value for array * @param bool $error If true, error will be triggered if list is empty * @return array Items */ protected function request_vars($name, $default, $error = false) { $item = $this->request->variable($name, $default); $items = $this->request->variable($name . 's', array($default)); if (count($items) == 1 && $items[0] == $default) { $items = array(); } if ($item != $default && !count($items)) { $items[] = $item; } if ($error && !count($items)) { trigger_error($this->user->lang['NO_MATCHING_STYLES_FOUND'] . adm_back_link($this->u_action), E_USER_WARNING); } return $items; }
/** * {@inheritdoc} */ public function link_account(array $link_data) { // Check for a valid link method (auth_link or login_link) if (!array_key_exists('link_method', $link_data) || !in_array($link_data['link_method'], array('auth_link', 'login_link'))) { return 'LOGIN_LINK_MISSING_DATA'; } // We must have an oauth_service listed, check for it two ways if (!array_key_exists('oauth_service', $link_data) || !$link_data['oauth_service']) { $link_data['oauth_service'] = $this->request->variable('oauth_service', ''); if (!$link_data['oauth_service']) { return 'LOGIN_LINK_MISSING_DATA'; } } $service_name = 'auth.provider.oauth.service.' . strtolower($link_data['oauth_service']); if (!array_key_exists($service_name, $this->service_providers)) { return 'LOGIN_ERROR_OAUTH_SERVICE_DOES_NOT_EXIST'; } switch ($link_data['link_method']) { case 'auth_link': return $this->link_account_auth_link($link_data, $service_name); case 'login_link': return $this->link_account_login_link($link_data, $service_name); } }
/** * Check and display the SQL report if requested. * * @param \src\request\request_interface $request Request object * @param \src\auth\auth $auth Auth object * @param \src\db\driver\driver_interface $db Database connection */ function src_check_and_display_sql_report(\src\request\request_interface $request, \src\auth\auth $auth, \src\db\driver\driver_interface $db) { if ($request->variable('explain', false) && $auth->acl_get('a_') && defined('DEBUG')) { $db->sql_report('display'); } }
/** * Bind the values of the request to the form * * @param \src\request\request_interface $request * @return null */ public function bind(\src\request\request_interface $request) { $this->cc_sender = $request->is_set_post('cc_sender'); $this->body = $request->variable('message', '', true); }
/** * Parses parameters found in $request, which is an instance of * \src\request\request_interface. * * It is expected to have a key f whose value is id of the forum to be pruned. * * @param \src\request\request_interface $request Request object. * * @return null */ public function parse_parameters(\src\request\request_interface $request) { $this->forum_data = null; if ($request->is_set('f')) { $forum_id = $request->variable('f', 0); $sql = 'SELECT forum_id, prune_next, enable_prune, prune_days, prune_viewed, forum_flags, prune_freq FROM ' . FORUMS_TABLE . "\n\t\t\t\tWHERE forum_id = {$forum_id}"; $result = $this->db->sql_query($sql); $row = $this->db->sql_fetchrow($result); $this->db->sql_freeresult($result); if ($row) { $this->forum_data = $row; } } }