Redaxscript\Filter\Special::sanitize PHP Method

sanitize() public method

sanitize the special
Since: 3.0.0
public sanitize ( string $special = null ) : string
$special string target with special character
return string
    public function sanitize($special = null)
    {
        return preg_replace('/[^a-zA-Z0-9]/i', null, $special);
    }

Usage Example

Esempio n. 1
0
 /**
  * process
  *
  * @since 3.0.0
  *
  * @return string
  */
 public function process()
 {
     $specialFilter = new Filter\Special();
     $emailFilter = new Filter\Email();
     /* process post */
     $postArray = ['name' => $specialFilter->sanitize($this->_request->getPost('name')), 'user' => $specialFilter->sanitize($this->_request->getPost('user')), 'email' => $emailFilter->sanitize($this->_request->getPost('email')), 'task' => $this->_request->getPost('task'), 'solution' => $this->_request->getPost('solution')];
     /* handle error */
     $messageArray = $this->_validate($postArray);
     if ($messageArray) {
         return $this->_error(['message' => $messageArray]);
     }
     /* handle success */
     $passwordHash = new Hash(Config::getInstance());
     $passwordHash->init(uniqid());
     $createArray = ['name' => $postArray['name'], 'user' => $postArray['user'], 'password' => $passwordHash->getHash(), 'email' => $postArray['email'], 'language' => $this->_registry->get('language'), 'groups' => Db::forTablePrefix('groups')->where('alias', 'members')->findOne()->id, 'status' => Db::getSetting('verification') ? 0 : 1];
     $mailArray = ['name' => $postArray['name'], 'user' => $postArray['user'], 'password' => $passwordHash->getRaw(), 'email' => $postArray['email']];
     /* create */
     if (!$this->_create($createArray)) {
         return $this->_error(['message' => $this->_language->get('something_wrong')]);
     }
     /* mail */
     if (!$this->_mail($mailArray)) {
         return $this->_error(['message' => $this->_language->get('email_failed')]);
     }
     return $this->_success(['message' => Db::getSetting('verification') ? $this->_language->get('registration_verification') : $this->_language->get('registration_sent')]);
 }
All Usage Examples Of Redaxscript\Filter\Special::sanitize
Special