/** * {@inheritdoc} */ public function set($key, $value) { if (!is_array($value) && !$value instanceof UploadedFile) { throw new \InvalidArgumentException('An uploaded file must be an array or an instance of FilesystemFile.'); } parent::set($key, $this->convertFileInformation($value)); }
/** * check whether a an XMLHttpRequest was submitted * this will look for a key 'xmlHttpRequest' in both GET and POST and * set the Controller::isXhr flag and * decode the parameters accordingly into their ParameterBages * in addition the presence of ifuRequest in GET is checked for handling IFRAME uploads * * this method is geared to fully support the vxJS.widget.xhrForm() */ private function prepareForXhr() { // do we have a GET XHR? if ($this->request->getMethod() === 'GET' && $this->request->query->get('xmlHttpRequest')) { $this->xhrBag = $this->request->query; foreach (json_decode($this->xhrBag->get('xmlHttpRequest'), TRUE) as $key => $value) { $this->xhrBag->set($key, $value); } } else { if ($this->request->getMethod() === 'POST' && $this->request->request->get('xmlHttpRequest')) { $this->xhrBag = $this->request->request; foreach (json_decode($this->xhrBag->get('xmlHttpRequest'), TRUE) as $key => $value) { $this->xhrBag->set($key, $value); } } else { if ($this->request->query->get('ifuRequest')) { // POST already contains all the parameters $this->request->request->set('httpRequest', 'ifuSubmit'); } else { $this->isXhr = FALSE; return; } } } $this->isXhr = TRUE; // handle request for apc upload poll, this will not be left to individual controller if ($this->xhrBag && $this->xhrBag->get('httpRequest') === 'apcPoll') { $id = $this->xhrBag->get('id'); if ($this->config->server['apc_on'] && $id) { $apcData = apc_fetch('upload_' . $id); } if (isset($apcData['done']) && $apcData['done'] == 1) { apc_clear_cache('user'); } JsonResponse::create($apcData)->send(); exit; } }
/** * check for spam * * @return boolean $spam_detected */ public function detectSpam(array $fields = [], $threshold = 3) { $verify = $this->requestValues->get('verify'); $timer = Session::getSessionDataBag()->get('antiSpamTimer'); if (!$verify || !isset($timer[$verify]) || microtime(true) - $timer[$verify] < 1) { return TRUE; } $label = md5($verify); if (is_null($this->requestValues->get('confirm_entry_' . $label)) || $this->requestValues->get('confirm_entry_' . $label) !== '') { return TRUE; } foreach ($fields as $f) { if (preg_match_all('~<\\s*a\\s+href\\s*\\=\\s*(\\\\*"|\\\\*\'){0,1}http://~i', $this->requestValues->get($f), $tmp) > $threshold) { return TRUE; } if (preg_match('~\\[\\s*url.*?\\]~i', $this->requestValues->get($f))) { return TRUE; } } return FALSE; }