本文整理汇总了PHP中Zend\Http\PhpEnvironment\Request::getPost方法的典型用法代码示例。如果您正苦于以下问题:PHP Request::getPost方法的具体用法?PHP Request::getPost怎么用?PHP Request::getPost使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Zend\Http\PhpEnvironment\Request
的用法示例。
在下文中一共展示了Request::getPost方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: authenticate
/**
* Attempt to authenticate the current user. Throws exception if login fails.
*
* @param \Zend\Http\PhpEnvironment\Request $request Request object containing
* account credentials.
*
* @throws AuthException
* @return \VuFind\Db\Row\User Object representing logged-in user.
*/
public function authenticate($request)
{
$target = trim($request->getPost()->get('target'));
$username = trim($request->getPost()->get('username'));
$password = trim($request->getPost()->get('password'));
if ($username == '' || $password == '') {
throw new AuthException('authentication_error_blank');
}
// We should have target either separately or already embedded into username
if ($target) {
$username = "{$target}.{$username}";
}
// Connect to catalog:
try {
$patron = $this->getCatalog()->patronLogin($username, $password);
} catch (AuthException $e) {
// Pass Auth exceptions through
throw $e;
} catch (\Exception $e) {
throw new AuthException('authentication_error_technical');
}
// Did the patron successfully log in?
if ($patron) {
return $this->processILSUser($patron);
}
// If we got this far, we have a problem:
throw new AuthException('authentication_error_invalid');
}
示例2: DoPost
public function DoPost()
{
$request = new Request();
$login = $request->getPost("login");
$password = $request->getPost("password");
$repo = CommonController::$EntityManager->getRepository('user');
$user = $repo->findOneBy(["pseudo" => $login, "password" => $password]);
if ($user === null) {
return 'false';
}
return json_encode(['jwt' => $this->GetJsonWebToken($user->getIdUser(), $_POST['login']), 'id' => $user->getIdUser()]);
}
示例3: authenticate
/**
* Attempt to authenticate the current user. Throws exception if login fails.
*
* @param \Zend\Http\PhpEnvironment\Request $request Request object containing
* account credentials.
*
* @throws AuthException
* @return \VuFind\Db\Row\User Object representing logged-in user.
*/
public function authenticate($request)
{
$username = trim($request->getPost()->get('username', ''));
$password = trim($request->getPost()->get('password', ''));
if ($username == '' || $password == '') {
throw new AuthException('authentication_error_blank');
}
// Attempt SIP2 Authentication
$mysip = new \sip2();
$config = $this->getConfig();
if (isset($config->SIP2)) {
$mysip->hostname = $config->SIP2->host;
$mysip->port = $config->SIP2->port;
}
if (!$mysip->connect()) {
throw new AuthException('authentication_error_technical');
}
//send selfcheck status message
$in = $mysip->msgSCStatus();
$msg_result = $mysip->get_message($in);
// Make sure the response is 98 as expected
if (!preg_match("/^98/", $msg_result)) {
$mysip->disconnect();
throw new AuthException('authentication_error_technical');
}
$result = $mysip->parseACSStatusResponse($msg_result);
// Use result to populate SIP2 setings
$mysip->AO = $result['variable']['AO'][0];
$mysip->AN = $result['variable']['AN'][0];
$mysip->patron = $username;
$mysip->patronpwd = $password;
$in = $mysip->msgPatronStatusRequest();
$msg_result = $mysip->get_message($in);
// Make sure the response is 24 as expected
if (!preg_match("/^24/", $msg_result)) {
$mysip->disconnect();
throw new AuthException('authentication_error_technical');
}
$result = $mysip->parsePatronStatusResponse($msg_result);
$mysip->disconnect();
if ($result['variable']['BL'][0] == 'Y' and $result['variable']['CQ'][0] == 'Y') {
// Success!!!
$user = $this->processSIP2User($result, $username, $password);
// Set login cookie for 1 hour
$user->password = $password;
// Need this for Metalib
} else {
throw new AuthException('authentication_error_invalid');
}
return $user;
}
示例4: uploadImageAction
public function uploadImageAction()
{
$this->checkAuth();
$request = $this->getRequest();
if ($request->isPost()) {
// File upload input
$file = new FileInput('avatar');
// Special File Input type
$file->getValidatorChain()->attach(new Validator\File\UploadFile());
$file->getFilterChain()->attach(new Filter\File\RenameUpload(array('target' => './public/files/users/avatar/origin/', 'use_upload_name' => true, 'randomize' => true)));
// Merge $_POST and $_FILES data together
$request = new Request();
$postData = array_merge_recursive($request->getPost()->toArray(), $request->getFiles()->toArray());
$inputFilter = new InputFilter();
$inputFilter->add($file)->setData($postData);
if ($inputFilter->isValid()) {
// FileInput validators are run, but not the filters...
$data = $inputFilter->getValues();
// This is when the FileInput filters are run.
$avatar = basename($data['avatar']['tmp_name']);
$this->databaseService->updateAvatar($this->user->id, $avatar);
$this->user->avatar = $avatar;
} else {
// error
}
}
return $this->redirect()->toRoute('profile');
}
示例5: authenticate
/**
* Attempt to authenticate the current user. Throws exception if login fails.
*
* @param \Zend\Http\PhpEnvironment\Request $request Request object containing
* account credentials.
*
* @throws AuthException
* @return \VuFind\Db\Row\User Object representing logged-in user.
*/
public function authenticate($request)
{
// Make sure the credentials are non-blank:
$this->username = trim($request->getPost()->get('username'));
$this->password = trim($request->getPost()->get('password'));
if ($this->username == '' || $this->password == '') {
throw new AuthException('authentication_error_blank');
}
// Validate the credentials:
$user = $this->getUserTable()->getByUsername($this->username, false);
if (!is_object($user) || !$this->checkPassword($this->password, $user)) {
throw new AuthException('authentication_error_invalid');
}
// If we got this far, the login was successful:
return $user;
}
示例6: request
/**
* @param string $name
* @param mixed $default
* @return mixed
*/
public function request($name, $default = null)
{
//The RequestInterface expects this method to return values from a form submission or from
//the decoded JSON body
if ($this->data === null) {
/* @var $contentType ContentType */
$mediaType = $this->httpRequest->getHeaders('Content-type') ? $this->httpRequest->getHeaders('Content-type')->getFieldValue() : null;
if ($mediaType == 'application/x-www-form-urlencoded' && ($this->httpRequest->isPut() || $this->httpRequest->isDelete())) {
parse_str($this->httpRequest->getContent(), $this->data);
} else {
if ($mediaType == 'application/json' && ($this->httpRequest->isPost() || $this->httpRequest->isPut() || $this->httpRequest->isDelete())) {
$this->data = json_decode($this->httpRequest->getContent(), true);
} else {
$this->data = $this->httpRequest->getPost()->toArray();
}
}
}
return isset($this->data[$name]) ? $this->data[$name] : $default;
}
示例7: authenticate
/**
* Attempt to authenticate the current user. Throws exception if login fails.
*
* @param \Zend\Http\PhpEnvironment\Request $request Request object containing
* account credentials.
*
* @throws AuthException
* @return \VuFind\Db\Row\User Object representing logged-in user.
*/
public function authenticate($request)
{
$username = trim($request->getPost()->get('username'));
$password = trim($request->getPost()->get('password'));
if ($username == '' || $password == '') {
throw new AuthException('authentication_error_blank');
}
// Connect to catalog:
try {
$patron = $this->getCatalog()->patronLogin($username, $password);
} catch (\Exception $e) {
throw new AuthException('authentication_error_technical');
}
// Did the patron successfully log in?
if ($patron) {
return $this->processILSUser($patron);
}
// If we got this far, we have a problem:
throw new AuthException('authentication_error_invalid');
}
示例8: getSessionIdFromRequest
/**
* @param \Zend\Http\PhpEnvironment\Request $request
* @return string|null
*/
protected function getSessionIdFromRequest($request)
{
$ssid = $request->getPost(static::SESSION_ID_ALIAS);
if (!$ssid) {
$ssid = $request->getQuery(static::SESSION_ID_ALIAS);
}
if (!$ssid) {
return null;
}
return $ssid;
}
示例9: saveAction
public function saveAction(Request $request, Create $createService, Form $form, View $view, Redirect $redirect)
{
if ($request->isPost()) {
$form->setData($request->getPost());
if ($form->isValid()) {
$createService->create($form->getData());
return $redirect->toRoute('admin-translate-words');
}
}
$view->setForm($form);
$view->setTemplate('translate/admin/word/edit');
return $view;
}
示例10: DoPost
public function DoPost()
{
$request = new Request();
$id = $request->getPost("id");
$label = $request->getPost("label");
$description = $request->getPost("description");
if (!(is_null($id) || is_null($label) || is_null($description))) {
/** @var EntityManager $em */
$em = CommonController::$EntityManager;
/** @var \Collection $collection */
$collection = $em->find("collection", $id);
if (!is_null($collection)) {
$collection->setDescription($description);
$collection->setLabel($label);
$collection->setUpdateOn(new \DateTime("now"));
$em->persist($collection);
$em->flush();
return "true";
}
}
return "false";
}
示例11: Edit
public function Edit()
{
if (CommonController::IsAuthentified()) {
$request = new Request();
if ($request->isGet()) {
$data = json_decode($this->GetCurrentCollection(), true);
if (!is_null($data)) {
CommonController::SetView("collection", "edit", array_merge($data, array('url' => array('edit' => CommonController::GetLink("Collection", "edit", $data['collection']['id'])))));
return;
}
} else {
if ($request->isPost()) {
$label = $request->getPost('label');
$description = $request->getPost('description');
$id = $request->getPost('id');
if (!is_null($label) && !is_null($description)) {
if (!is_null($id)) {
$WSCtrl = new WebServicesController();
$return = $WSCtrl->Call("Collection", "POST", array("id" => $id, "label" => $label, "description" => $description));
var_dump($return);
if ($return == "true") {
CommonController::Redirect("Collection", "Index", $id);
} else {
$data = json_decode($this->GetCurrentCollection(), true);
if (!is_null($data)) {
CommonController::SetView("collection", "index", array_merge($data, array('url' => array('edit' => CommonController::GetLink("Collection", "edit", $data['collection']['id']), 'delete' => CommonController::GetLink("Collection", "delete", $data['collection']['id'])), 'error' => 'Impossible de sauver la collection')));
return;
}
}
} else {
//Create
}
}
}
}
}
CommonController::Redirect("home");
}
示例12: createFromRequest
public static function createFromRequest(BaseRequest $request)
{
$new = static::fromString($request->toString());
$new->setQuery($request->getQuery());
$new->setPost($request->getPost());
$new->setCookies($request->getCookie());
$new->setFiles($request->getFiles());
$new->setServer($request->getServer());
$new->setContent($request->getContent());
$new->setEnv($request->getEnv());
$headers = $request->getHeaders();
$new->setHeaders($headers);
return $new;
}
示例13: authenticate
/**
* Attempt to authenticate the current user. Throws exception if login fails.
*
* @param \Zend\Http\PhpEnvironment\Request $request Request object containing
* account credentials.
*
* @throws AuthException
* @return \VuFind\Db\Row\User Object representing logged-in user.
*/
public function authenticate($request)
{
$assertion = $request->getPost('assertion');
if ($assertion === null) {
throw new AuthException('authentication_missing_assertion');
}
$protocol = $request->getServer('HTTPS');
$audience = (empty($protocol) ? 'http://' : 'https://') . $request->getServer('SERVER_NAME') . ':' . $request->getServer('SERVER_PORT');
$client = $this->httpService->createClient('https://verifier.login.persona.org/verify', \Zend\Http\Request::METHOD_POST);
$client->setParameterPost(['assertion' => $assertion, 'audience' => $audience]);
$response = $client->send();
$result = json_decode($response->getContent());
if ($result->status !== 'okay') {
throw new AuthException('authentication_error_invalid');
}
$username = $result->email;
$user = $this->getUserTable()->getByUsername($username, false);
if ($user === false) {
$user = $this->createPersonaUser($username, $result->email);
}
return $user;
}
示例14: editAction
public function editAction()
{
$this->accessRights(17);
//Accept Parent Module, Return Main Menu Lists with Active Menu Indicator
$this->childModuleAccessRights(17, 'edit');
//Accept Child Module ID & it's Actions: add, edit, view, disable
//$msgs means message, it will show if data had been changed.
$msgs = '';
//get the id from parameter
$id = (int) $this->params()->fromRoute('id', 0);
if (!$id) {
return $this->redirect()->toRoute('media_profile', array('action' => 'add', 'access_rights' => $this->getSubModuleAccessRights(17)));
}
try {
$media_profile = $this->getMediaProfileTable()->getMediaProfile($this->serviceLocator(), $id);
$media_profile_education = $this->getMediaProfileTable()->getMediaProfileEducation($this->serviceLocator(), $id);
$media_profile_career = $this->getMediaProfileTable()->getMediaProfileCareer($this->serviceLocator(), $id);
} catch (\Exception $ex) {
return $this->redirect()->toRoute('media_profile', array('action' => 'index', 'access_rights' => $this->getSubModuleAccessRights(17)));
}
//instantiate the Media Profile's Form
//populate the data
$form_media_profile = new MediaProfileForm($this->serviceLocator());
$form_media_profile->get('relation_id')->setAttribute('options', $this->optionRelations());
$form_media_profile->get('additional_position_id[]')->setAttribute('options', $this->optionPositions());
$form_media_profile->get('additional_beat_id[]')->setAttribute('options', $this->optionBeats());
$form_media_profile->get('additional_section_id[]')->setAttribute('options', $this->optionSections());
$form_media_profile->get('additional_radio_station_id[]')->setAttribute('options', $this->optionRadioStations());
$form_media_profile->get('additional_tv_channel_id[]')->setAttribute('options', $this->optionTVChannels());
$form_media_profile->get('additional_source_id[]')->setAttribute('options', $this->optionSources());
$form_media_profile->get('submit')->setAttribute('value', 'Save');
$form_media_profile->setData($media_profile);
//remove inputfilter for select element due to conflict
$formInputFilter = $form_media_profile->getInputFilter();
$formInputFilter->remove('year[]');
$formInputFilter->remove('educ_course[]');
$formInputFilter->remove('educ_school[]');
$formInputFilter->remove('additional_year[]');
$formInputFilter->remove('additional_educ_course[]');
$formInputFilter->remove('additional_educ_school[]');
//remove inputfilter for select element due to conflict
//CAREER
$formInputFilter = $form_media_profile->getInputFilter();
$formInputFilter->remove('from[]');
$formInputFilter->remove('to[]');
$formInputFilter->remove('position_id[]');
$formInputFilter->remove('beat_id[]');
$formInputFilter->remove('section_id[]');
$formInputFilter->remove('source_id[]');
$formInputFilter->remove('circulation[]');
$formInputFilter->remove('other_affiliation[]');
$formInputFilter->remove('additional_from[]');
$formInputFilter->remove('additional_to[]');
$formInputFilter->remove('additional_position_id[]');
$formInputFilter->remove('additional_beat_id[]');
$formInputFilter->remove('additional_section_id[]');
$formInputFilter->remove('additional_source_id[]');
$formInputFilter->remove('additional_circulation[]');
$formInputFilter->remove('additional_other_affiliation[]');
//check if the data request is post
//update the data
$request = $this->getRequest();
if ($request->isPost()) {
//prepare audit trail parameters
$from = (array) $media_profile;
$to = $this->getRequest()->getPost()->toArray();
$diff = array_diff_assoc($to, $from);
unset($diff['submit'], $diff['media_profles_id'], $diff['media_profile_careers_id'], $diff['media_profile_educations_id'], $diff['year'], $diff['educ_course'], $diff['educ_school'], $diff['additional_year'], $diff['additional_educ_course'], $diff['additional_educ_school'], $diff['from'], $diff['to'], $diff['media_profile_type'], $diff['position_id'], $diff['beat_id'], $diff['section_id'], $diff['circulation'], $diff['source_id'], $diff['other_affiliation'], $diff['additional_from'], $diff['additional_to'], $diff['additional_media_profile_type'], $diff['additional_position_id'], $diff['additional_beat_id'], $diff['additional_section_id'], $diff['additional_circulation'], $diff['additional_source_id'], $diff['additional_other_affiliation']);
$changes = $this->prepare_modified_data($from, $to, $diff);
//end audit trail parameters
$media_profile = new MediaProfile();
$post = array_merge_recursive($request->getPost()->toArray(), $request->getFiles()->toArray());
$form_media_profile->setData($post);
//uploading file
$request = new Request();
//request to get the file
$files = $request->getFiles();
//get the details of uploading file
if ($files['photo']['name']) {
$filter = new \Zend\Filter\File\Rename(array("target" => "./public/img/" . $files['photo']['name'], "overwrite" => true));
$filter->filter($files['photo']);
//resize image
$imagine = $this->getImagineService();
$size = new \Imagine\Image\Box(150, 150);
$mode = \Imagine\Image\ImageInterface::THUMBNAIL_INSET;
$image = $imagine->open('./public/img/' . $files['photo']['name']);
$image->thumbnail($size, $mode)->save('./public/img/' . $files['photo']['name']);
//resize image
$imagine = $this->getImagineService();
$image = $imagine->open('./public/img/' . $files['photo']['name']);
$image->resize(new Box(150, 150))->save('./public/img/' . $files['photo']['name']);
}
$media_profile->exchangeArray($post);
if (isset($_POST['year']) || isset($_POST['educ_course']) || isset($_POST['educ_school']) || isset($_POST['additional_year']) || isset($_POST['additional_educ_course']) || !empty($to) || isset($_POST['additional_educ_school'])) {
$this->getMediaProfileTable()->saveProfileEducation($this->serviceLocator());
}
if (isset($_POST['from']) || isset($_POST['to']) || isset($_POST['media_profile_type']) || isset($_POST['position_id']) || isset($_POST['beat_id']) || isset($_POST['section_id']) || isset($_POST['source_id']) || isset($_POST['circulation']) || isset($_POST['other_affiliation']) || isset($_POST['additional_from']) || isset($_POST['additional_to']) || isset($_POST['additional_media_profile_type']) || isset($_POST['additional_position_id']) || isset($_POST['additional_beat_id']) || isset($_POST['additional_section_id']) || isset($_POST['additional_source_id']) || isset($_POST['additional_circulation']) || isset($_POST['additional_other_affiliation'])) {
$this->getMediaProfileTable()->saveProfileCareer($this->serviceLocator());
}
$this->getMediaProfileTable()->saveMediaProfile($media_profile);
//.........这里部分代码省略.........
示例15: testCreate
/**
* Test successful account creation
*
* @return void
*/
public function testCreate()
{
$request = new Request();
$request->getPost()->set('auth_method', 'Database');
$user = $this->getMockUser();
$pm = $this->getMockPluginManager();
$db = $pm->get('Database');
$db->expects($this->once())->method('create')->with($this->equalTo($request))->will($this->returnValue($user));
$ca = $this->getChoiceAuth($pm);
$this->assertEquals($user, $ca->create($request));
$this->assertEquals('Database', $ca->getSelectedAuthOption());
}