当前位置: 首页>>代码示例>>PHP>>正文


PHP SS_HTTPRequest::postVar方法代码示例

本文整理汇总了PHP中SS_HTTPRequest::postVar方法的典型用法代码示例。如果您正苦于以下问题:PHP SS_HTTPRequest::postVar方法的具体用法?PHP SS_HTTPRequest::postVar怎么用?PHP SS_HTTPRequest::postVar使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在SS_HTTPRequest的用法示例。


在下文中一共展示了SS_HTTPRequest::postVar方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: zip

 /**
  * @param SS_HTTPRequest $req
  * @return HTMLText
  */
 public function zip(SS_HTTPRequest $req)
 {
     $orderID = (int) $req->postVar('OrderID');
     $hashes = $req->postVar('Files');
     $files = array();
     // check inputs - should we respond more intelligently if they just didn't check anything?
     if (empty($hashes)) {
         $this->httpError(404);
     }
     // grab a list of file objects
     foreach ($hashes as $hash) {
         $link = DownloadLink::get_by_hash($hash);
         if ($link && $link->exists()) {
             $file = $link->File();
             if ($file && $file->exists()) {
                 $files[] = $file;
             }
         }
     }
     if (count($files) == 0) {
         $this->httpError(404);
     }
     // display a temporary loading page and start processing the zip
     return $this->initiateOfflineProcessing($files, $orderID);
 }
开发者ID:helpfulrobot,项目名称:markguinn-silverstripe-shop-downloadable,代码行数:29,代码来源:DownloadController.php

示例2: register

 public function register(SS_HTTPRequest $request)
 {
     if ($request->isPOST()) {
         try {
             if (Customer::get()->filter('Email', $request->postVar('Email'))->count()) {
                 throw new ValidationException("Sorry a member with that email address already exists");
             }
             $password = Customer::create_new_password();
             /** @var Customer $member */
             $member = Injector::inst()->create('ProfiledMemberClass');
             $member->changePassword($password);
             // update member with cleansed posted variables
             $updateData = array_merge(ProfiledMemberForm::update_models('register', array_merge($request->postVars(), ['Password' => $password]), $member));
             /** @var CryptofierImplementation $crypto */
             $crypto = Injector::inst()->get('CryptofierService');
             $token = $crypto->friendly($crypto->encrypt($member->Email));
             $member->{ProfiledMemberExtension::VerificationFieldName} = $token;
             $member->write();
             $member->addToGroupByCode(self::CustomerGroupCode);
             // add verification link and HasRegisteredFlag
             $updateData = array_merge(['Password' => $password, 'VerificationLink' => Controller::join_links(Director::absoluteBaseURL(), $this()->ActionLink("verify/{$token}"))], $updateData);
             $this->sendEmail('Register', $member, $updateData);
             Session::set(self::SessionEmailKey, $member->Email);
             $url = CrackerjackModule::get_config_setting(__CLASS__, 'post_register_url') ?: $this()->ActionLink('thanks');
             return $this()->redirect($url);
         } catch (ValidationException $e) {
             ProfiledMemberForm::set_form_message($e->getMessage(), CrackerjackForm::Bad);
             return $this()->redirectBack();
         }
     } else {
         return array();
     }
 }
开发者ID:CrackerjackDigital,项目名称:silverstripe-profiled,代码行数:33,代码来源:Controller.php

示例3: GetOembedData

 public function GetOembedData(SS_HTTPRequest $request)
 {
     $response = "{}";
     $this->getResponse()->addHeader("Content-Type", "application/json; charset=utf-8");
     $url = $request->postVar('url') ? $request->postVar('url') : $request->getVar("mediaurl");
     if (Director::is_site_url($url) && VideoEmbed::GetByURL($url)) {
         $video = VideoEmbed::GetByURL($url);
         $response = $video->GetOembedJson();
     } else {
         $oembed = Oembed::get_oembed_from_url($url);
         if ($oembed && $oembed->exists()) {
             $response = $oembed->toJson();
         }
     }
     echo $response;
 }
开发者ID:helpfulrobot,项目名称:gdmedia-silverstripe-video-embed,代码行数:16,代码来源:VideoEmbedController.php

示例4: handlePostAction

 /**
  * Returns the serialized data list after the requested relation has
  * been created
  * @param SS_HTTPRequest $request
  * @return SS_HTTPResponse
  */
 public function handlePostAction(SS_HTTPRequest $request)
 {
     $list = $this->getList();
     $dataClass = $list->dataClass();
     $object = DataObject::get($dataClass, $request->postVar('ID'));
     $list->add($object);
     return $this->handleGetAction($request);
 }
开发者ID:helpfulrobot,项目名称:tom-alexander-silverstripe-griddle,代码行数:14,代码来源:RelationEditorField.php

示例5: index

 public function index(SS_HTTPRequest $r)
 {
     $username = $r->postVar('username');
     $password = $r->postVar('password');
     if (!$username || !$password) {
         return $this->httpError(400, "You must provide 'username' and 'password' parameters in the request");
     }
     if ($member = Member::get()->filter('Email', $username)->first()) {
         if ($member->checkPassword($password)) {
             $member->assignToken();
             $member->write();
             $response = new SS_HTTPResponse(200);
             $response->addHeader('Content-type', 'application/json')->setBody(Convert::array2json(array('token' => $member->AuthenticationToken)));
             return $response;
         }
     }
     return $this->httpError(403, "Invalid login");
 }
开发者ID:OpenStackweb,项目名称:openstack-org,代码行数:18,代码来源:PresentationAPITokenGenerator.php

示例6: makePackageSelectorField

 /**
  * Returns a drop-down field configured from an api.listPackages call.
  *
  * NB commented code is for if they (checkfront) get events and items returning at same
  * time for packages via API at the moment can be one or the other depedning on the package
  * 'parent' or 'group' type.
  *
  * @param CheckfrontAPIPackagesResponse $apiResponse
  * @param SS_HTTPRequest $request
  * @param string $name
  *
  * @return DropdownField
  */
 protected function makePackageSelectorField(CheckfrontAPIPackagesResponse $apiResponse, SS_HTTPRequest $request, $name = self::PackageIDFieldName)
 {
     $options = $this->getAvailablePackagesMap($apiResponse);
     $field = new DropdownField($name, $this->getFieldLabel($name), $options, $request->postVar($name));
     //  $field->addExtraClass(self::PackageSelector);
     $field->setAttribute('placeholder', $this->getFieldLabel($name, 'FieldEmptyString'));
     $field->setEmptyString($this->getFieldLabel($name, 'FieldEmptyString'));
     return $field;
 }
开发者ID:CrackerjackDigital,项目名称:silverstripe-checkfront,代码行数:22,代码来源:LinkGenerator.php

示例7: getregions

 public function getregions(SS_HTTPRequest $request)
 {
     $country = $request->postVar('Country');
     if (!$country) {
         return $this->error('Country not provided');
     }
     $regions = CountrySubdivison::get_by_country($country);
     if (!$regions) {
         return $this->error('There are no regions for that country');
     }
     return json_encode(array('success' => true, 'regions' => $regions->toNestedArray()));
 }
开发者ID:spekulatius,项目名称:silverstripe-regionaldata,代码行数:12,代码来源:RegionalDataAPI.php

示例8: save

 /**
  * Store new version of variables.
  *
  * @param \SS_HTTPRequest $request
  *
  * @return \SS_HTTPResponse|void
  */
 public function save(\SS_HTTPRequest $request)
 {
     $this->setCurrentActionType(self::ACTION_CONFIGURATION);
     $this->checkSecurityToken();
     // Performs canView permission check by limiting visible projects
     $project = $this->getCurrentProject();
     if (!$project) {
         return $this->project404Response();
     }
     if (!$project->allowed(self::ALLOW_ENVIRONMENT_CONFIG_WRITE)) {
         return \Security::permissionFailure();
     }
     // Performs canView permission check by limiting visible projects
     $env = $this->getCurrentEnvironment($project);
     if (!$env) {
         return $this->environment404Response();
     }
     // TODO once this dispatcher extends \Dispatcher, use getFormData.
     $data = json_decode($request->postVar('Variables'), true);
     $data = $this->stripNonPrintables($data);
     // Validate against unsafe inputs.
     $blacklist = $env->Backend()->config()->environment_config_blacklist ?: array();
     if (!empty($blacklist)) {
         foreach ($data as $variable => $value) {
             foreach ($blacklist as $filter) {
                 if (preg_match("/{$filter}/", $variable)) {
                     return new \SS_HTTPResponse(sprintf('Variable %s is blacklisted.', $variable), 403);
                 }
             }
         }
     }
     // Coerce risky "false" value.
     $message = null;
     $changed = [];
     foreach ($data as $variable => $value) {
         if ($value === "false") {
             $data[$variable] = '0';
             $changed[] = $variable;
         }
     }
     if (!empty($changed)) {
         $message = sprintf('We have converted some of the values to "0" to avoid the ambiguity of "false" string ' . 'which resolves to true in PHP boolean context. ' . 'The following variable values have been changed: %s.', implode(', ', $changed));
     }
     ksort($data);
     $env->getEnvironmentConfigBackend()->setVariables($data);
     return $this->asJSON(['Variables' => $env->getEnvironmentConfigBackend()->getVariables(), 'Message' => $message]);
 }
开发者ID:helpfulrobot,项目名称:silverstripe-deploynaut-environmentconfig,代码行数:54,代码来源:Dispatcher.php

示例9: incoming

 /**
  * Handle incoming webhook
  *
  * @link http://help.mandrill.com/entries/21738186-introduction-to-webhooks
  * @link http://help.mandrill.com/entries/22092308-What-is-the-format-of-inbound-email-webhooks-
  * @param SS_HTTPRequest $req
  */
 public function incoming(SS_HTTPRequest $req)
 {
     $json = $req->postVar('mandrill_events');
     // By default, return a valid response
     $response = $this->getResponse();
     $response->setStatusCode(200);
     $response->setBody('');
     if (!$json) {
         return $response;
     }
     $events = json_decode($json);
     foreach ($events as $ev) {
         $this->handleAnyEvent($ev);
         $event = $event->event;
         switch ($event) {
             // Sync type
             case self::EVENT_BLACKLIST:
             case self::EVENT_WHITELIST:
                 $this->handleSyncEvent($ev);
                 break;
                 // Inbound type
             // Inbound type
             case self::EVENT_INBOUND:
                 $this->handleInboundEvent($ev);
                 break;
                 // Message type
             // Message type
             case self::EVENT_CLICK:
             case self::EVENT_HARD_BOUNCE:
             case self::EVENT_INBOUND:
             case self::EVENT_OPEN:
             case self::EVENT_REJECT:
             case self::EVENT_SEND:
             case self::EVENT_SOFT_BOUNCE:
             case self::EVENT_SPAM:
             case self::EVENT_UNSUB:
                 $this->handleMessageEvent($ev);
                 break;
         }
     }
     return $response;
 }
开发者ID:zarocknz,项目名称:silverstripe-mandrill,代码行数:49,代码来源:MandrillController.php

示例10: set_message

 /**
  * sends a message to user
  * @param POST 'Message'
  * @param POST 'To'
  * @param SS_HTTPRequest $request
  */
 public function set_message(SS_HTTPRequest $request)
 {
     if (!Permission::checkMember(Member::currentUser(), "CMS_ACCESS_LiveChatAdmin")) {
         header("HTTP/1.0 403 Forbidden");
         die('You do not have permission to use the live chat module');
     }
     if (!$request->postVar('Message')) {
         header("HTTP/1.0 400 Bad Request");
         die('No Message found');
     }
     if (!$request->postVar('To')) {
         header("HTTP/1.0 400 Bad Request");
         die('No target user ID found');
     }
     // redirecting one user to another
     if (substr($request->postVar('Message'), 0, 9) == '/redirect') {
         $this->redirectChatToUser($request->postVar('To'), substr($request->postVar('Message'), 10));
         die;
     }
     LiveChatMessage::create(array('Message' => htmlentities($request->postVar('Message')), 'ToID' => is_numeric($request->postVar('To')) ? $request->postVar('To') : 0, 'Read' => false, 'FromID' => Member::currentUserID(), 'FromIP' => $request->getIP(), 'FromName' => is_numeric($request->postVar('To')) ? "" : $request->postVar('To')))->write();
     die;
     // success
 }
开发者ID:helpfulrobot,项目名称:otago-livechat,代码行数:29,代码来源:LiveChatController.php

示例11: DetailEditForm

 /**
  * Url handler for edit form
  *
  * @param SS_HTTPRequest $request
  * @return Form
  */
 public function DetailEditForm($request)
 {
     // Get ID either from posted back value, or url parameter
     $id = $request->param('ID') ?: $request->postVar('ID');
     return $this->getDetailEditForm($id);
 }
开发者ID:jacobbuck,项目名称:silverstripe-framework,代码行数:12,代码来源:CampaignAdmin.php

示例12: publicevents

 /**
  * Handles returning the JSON events data for a time range.
  *
  * @param SS_HTTPRequest $request
  * @return SS_HTTPResponse
  */
 public function publicevents($request, $json = true, $calendars = null, $offset = 30)
 {
     $calendarsSupplied = false;
     if ($calendars) {
         $calendarsSupplied = true;
     }
     $events = PublicEvent::get()->filter(array('StartDateTime:GreaterThan' => $this->eventlistOffsetDate('start', $request->postVar('start'), $offset), 'EndDateTime:LessThan' => $this->eventlistOffsetDate('end', $request->postVar('end'), $offset)));
     //If shaded events are enabled we need to filter shaded calendars out
     //note that this only takes effect when no calendars have been supplied
     //if calendars are supplied, this needs to be taken care of from that method
     $sC = CalendarConfig::subpackage_settings('calendars');
     if ($sC['shading']) {
         if (!$calendars) {
             $calendars = PublicCalendar::get();
             $calendars = $calendars->filter(array('shaded' => false));
         }
     }
     if ($calendars) {
         $calIDList = $calendars->getIdList();
         //adding in 0 to allow for showing events without a calendar
         if (!$calendarsSupplied) {
             $calIDList[0] = 0;
         }
         //Debug::dump($calIDList);
         $events = $events->filter('CalendarID', $calIDList);
     }
     $result = array();
     if ($events) {
         foreach ($events as $event) {
             $calendar = $event->Calendar();
             $bgColor = '#999';
             //default
             $textColor = '#FFF';
             //default
             $borderColor = '#555';
             if ($calendar->exists()) {
                 $bgColor = $calendar->getColorWithHash();
                 $textColor = '#FFF';
                 $borderColor = $calendar->getColorWithHash();
             }
             $resultArr = self::format_event_for_fullcalendar($event);
             $resultArr = array_merge($resultArr, array('backgroundColor' => $bgColor, 'textColor' => '#FFF', 'borderColor' => $borderColor));
             $result[] = $resultArr;
         }
     }
     if ($json) {
         $response = new SS_HTTPResponse(Convert::array2json($result));
         $response->addHeader('Content-Type', 'application/json');
         return $response;
     } else {
         return $result;
     }
 }
开发者ID:andrewandante,项目名称:silverstripe-calendar,代码行数:59,代码来源:FullcalendarController.php

示例13: modifiedUpload

 public function modifiedUpload(SS_HTTPRequest $request)
 {
     if ($this->isDisabled() || $this->isReadonly() || !$this->canUpload()) {
         return $this->httpError(403);
     }
     // Protect against CSRF on destructive action
     $token = $this->getForm()->getSecurityToken();
     //if(!$token->checkRequest($request)) return $this->httpError(400);
     $name = $this->getName();
     $contentFieldName = $this->contentModuleFieldName;
     $postVars = $request->postVars();
     $tmpfile = $request->postVar('ContentModule');
     $record = $this->getRecord();
     // Check if the file has been uploaded into the temporary storage.
     if (!$tmpfile) {
         $return = array('error' => _t('UploadField.FIELDNOTSET', 'File information not found'));
     } else {
         $return = array('name' => $tmpfile['name'][$this->getRecord()->ID][$name], 'size' => $tmpfile['size'][$this->getRecord()->ID][$name], 'type' => $tmpfile['type'][$this->getRecord()->ID][$name], 'error' => $tmpfile['error'][$this->getRecord()->ID][$name], 'tmp_name' => $tmpfile['tmp_name'][$this->getRecord()->ID][$name]);
     }
     // Check for constraints on the record to which the file will be attached.
     if (!$return['error'] && $this->relationAutoSetting && $record && $record->exists()) {
         $tooManyFiles = false;
         // Some relationships allow many files to be attached.
         if ($this->getConfig('allowedMaxFileNumber') && ($record->has_many($name) || $record->many_many($name))) {
             if (!$record->isInDB()) {
                 $record->write();
             }
             $tooManyFiles = $record->{$name}()->count() >= $this->getConfig('allowedMaxFileNumber');
             // has_one only allows one file at any given time.
         } elseif ($record->has_one($name)) {
             // If we're allowed to replace an existing file, clear out the old one
             if ($record->{$name} && $this->getConfig('replaceExistingFile')) {
                 $record->{$name} = null;
             }
             $tooManyFiles = $record->{$name}() && $record->{$name}()->exists();
         }
         // Report the constraint violation.
         if ($tooManyFiles) {
             if (!$this->getConfig('allowedMaxFileNumber')) {
                 $this->setConfig('allowedMaxFileNumber', 1);
             }
             $return['error'] = _t('UploadField.MAXNUMBEROFFILES', 'Max number of {count} file(s) exceeded.', array('count' => $this->getConfig('allowedMaxFileNumber')));
         }
     }
     // Process the uploaded file
     if (!$return['error']) {
         $fileObject = null;
         if ($this->relationAutoSetting) {
             // Search for relations that can hold the uploaded files.
             if ($relationClass = $this->getRelationAutosetClass()) {
                 // Create new object explicitly. Otherwise rely on Upload::load to choose the class.
                 $fileObject = Object::create($relationClass);
             }
         }
         // Get the uploaded file into a new file object.
         try {
             $this->upload->loadIntoFile($return, $fileObject, $this->folderName);
         } catch (Exception $e) {
             // we shouldn't get an error here, but just in case
             $return['error'] = $e->getMessage();
         }
         if (!$return['error']) {
             if ($this->upload->isError()) {
                 $return['error'] = implode(' ' . PHP_EOL, $this->upload->getErrors());
             } else {
                 $file = $this->upload->getFile();
                 // Attach the file to the related record.
                 if ($this->relationAutoSetting) {
                     $this->attachFile($file);
                 }
                 // Collect all output data.
                 $file = $this->customiseFile($file);
                 $return = array_merge($return, array('id' => $file->ID, 'name' => $file->getTitle() . '.' . $file->getExtension(), 'url' => $file->getURL(), 'thumbnail_url' => $file->UploadFieldThumbnailURL, 'edit_url' => $file->UploadFieldEditLink, 'size' => $file->getAbsoluteSize(), 'buttons' => $file->UploadFieldFileButtons));
             }
         }
     }
     $response = new SS_HTTPResponse(Convert::raw2json(array($return)));
     $response->addHeader('Content-Type', 'text/plain');
     return $response;
 }
开发者ID:webtorque7,项目名称:inpage-modules,代码行数:80,代码来源:ContentModuleUploadField.php

示例14: handleBlockTypeAssignment

 /**
  * Handles requests to assign a new block area to a block item
  *
  * @param GridField $grid
  * @param SS_HTTPRequest $request
  * @return SS_HTTPResponse
  */
 public function handleBlockTypeAssignment($grid, $request)
 {
     $list = $grid->getList();
     // @TODO: do we need this? (copied from GridFieldOrderableRows::handleReorder)
     //		$modelClass = $grid->getModelClass();
     //		if ($list instanceof ManyManyList && !singleton($modelClass)->canView()) {
     //			$this->httpError(403);
     //		} else if(!($list instanceof ManyManyList) && !singleton($modelClass)->canEdit()) {
     //			$this->httpError(403);
     //		}
     $blockid = $request->postVar('block_id');
     $blocktype = $request->postVar('block_type');
     $block = $list->byID($blockid);
     // Update item with correct Area assigned (custom query required to write m_m_extraField)
     $block->ClassName = $blocktype;
     $block->write();
     //print_r($block->record);
     //        // @TODO: improve this custom query to be more robust?
     //        DB::query(sprintf(
     //            "UPDATE `%s` SET `%s` = '%s' WHERE `BlockID` = %d",
     //            'SiteTree_Blocks',
     //            'BlockArea',
     //            $blockarea,
     //            $blockid
     //        ));
     return $grid->FieldHolder();
 }
开发者ID:micschk,项目名称:silverstripe-block_enhancements,代码行数:34,代码来源:GF_BlockEnhancements.php

示例15: handleCreateFolder

 /**
  * Creates a folder, ensures uniqueness
  * 
  * @param  SS_HTTPRequest $r
  * @return SS_HTTPResponse
  */
 public function handleCreateFolder(SS_HTTPRequest $r)
 {
     if (!Injector::inst()->get('Folder')->canCreate()) {
         return $this->httpError(403);
     }
     $parentID = (int) $r->postVar('parentID');
     $parentRecord = Folder::get()->byID($parentID);
     $name = $r->postVar('title') ? $r->postVar('title') : _t('AssetAdmin.NEWFOLDER', "NewFolder");
     if ($parentRecord && $parentRecord->ID) {
         $filename = $parentRecord->FullPath . $name;
     } else {
         $filename = ASSETS_PATH . '/' . $name;
     }
     $record = Folder::create(array('ParentID' => $parentID, 'Name' => basename($filename), 'Title' => basename($filename), 'Filename' => $filename));
     // Ensure uniqueness
     $i = 2;
     if (substr($record->Filename, -1) == "/") {
         $baseFilename = substr($record->Filename, 0, -1);
     } else {
         $baseFilename = $record->Filename;
     }
     $baseFilename .= "-";
     while (file_exists($record->FullPath)) {
         $record->Filename = $baseFilename . $i . '/';
         $i++;
     }
     $record->Name = $record->Title = basename($record->Filename);
     mkdir($record->FullPath);
     @chmod($record->FullPath, Config::inst()->get('Filesystem', 'file_create_mask'));
     $record->write();
     return (new SS_HTTPResponse(Convert::array2json($this->createFolderJSON($record))))->addHeader('Content-Type', 'application/json');
 }
开发者ID:helpfulrobot,项目名称:unclecheese-kickassets,代码行数:38,代码来源:KickAssets.php


注:本文中的SS_HTTPRequest::postVar方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。