Example #1
0
 /**
  * cleanVar prepare variable for persistence
  *
  * @param XoopsObject $obj object containing variable
  * @param string      $key name of variable
  *
  * @return string
  */
 public function cleanVar(XoopsObject $obj, $key)
 {
     $value = trim($obj->vars[$key]['value']);
     if ($obj->vars[$key]['required'] && $value == '') {
         $obj->setErrors(sprintf(\XoopsLocale::F_IS_REQUIRED, $key));
         return $value;
     }
     if ($value != '' && !preg_match("/^[_a-z0-9-]+(\\.[_a-z0-9-]+)*@[a-z0-9-]+([\\.][a-z0-9-]+)+\$/i", $value)) {
         $obj->setErrors("Invalid Email");
         return $value;
     }
     return $value;
 }
Example #2
0
 /**
  * cleanVar prepare variable for persistence
  *
  * @param XoopsObject $obj object containing variable
  * @param string      $key name of variable
  *
  * @return string
  */
 public function cleanVar(XoopsObject $obj, $key)
 {
     $value = $obj->vars[$key]['value'];
     if ($obj->vars[$key]['required'] && $value != '0' && $value == '') {
         $obj->setErrors(sprintf(\XoopsLocale::F_IS_REQUIRED, $key));
         return $value;
     }
     if (isset($obj->vars[$key]['maxlength']) && mb_strlen($value) > (int) $obj->vars[$key]['maxlength']) {
         $obj->setErrors(sprintf(\XoopsLocale::F_MUST_BE_SHORTER_THAN, $key, (int) $obj->vars[$key]['maxlength']));
         return $value;
     }
     $value = $this->ts->censorString($value);
     return $value;
 }
Example #3
0
 /**
  * cleanVar prepare variable for persistence
  *
  * @param XoopsObject $obj object containing variable
  * @param string      $key name of variable
  *
  * @return string
  */
 public function cleanVar(XoopsObject $obj, $key)
 {
     $value = $obj->vars[$key]['value'];
     if (!in_array($value, $obj->vars[$key]['enumeration'])) {
         $obj->setErrors("Invalid Enumeration");
         return $value;
     }
     return $value;
 }
Example #4
0
 /**
  * cleanVar prepare variable for persistence
  *
  * @param XoopsObject $obj object containing variable
  * @param string      $key name of variable
  *
  * @return string
  */
 public function cleanVar(XoopsObject $obj, $key)
 {
     $value = $obj->vars[$key]['value'];
     if ($obj->vars[$key]['required'] && $value != '0' && $value == '') {
         $obj->setErrors(sprintf(\XoopsLocale::F_IS_REQUIRED, $key));
         return $value;
     }
     $value = $this->ts->censorString($value);
     return $value;
 }
Example #5
0
 /**
  * @param XoopsObject $obj
  * @param string      $key
  * @param bool        $quote
  *
  * @return string
  */
 public function cleanVar(XoopsObject $obj, $key, $quote = true)
 {
     $value = trim($obj->vars[$key]['value']);
     if ($obj->vars[$key]['required'] && $value == '') {
         $obj->setErrors(sprintf(\XoopsLocale::F_IS_REQUIRED, $key));
         return $value;
     }
     if ($value != '' && !preg_match("/^[_a-z0-9-]+(\\.[_a-z0-9-]+)*@[a-z0-9-]+([\\.][a-z0-9-]+)+\$/i", $value)) {
         $obj->setErrors("Invalid Email");
         return $value;
     }
     if (!$obj->vars[$key]['not_gpc']) {
         $value = $this->ts->stripSlashesGPC($value);
     }
     if ($quote) {
         $value = str_replace('\\"', '"', $this->db->quote($value));
     }
     return $value;
 }
Example #6
0
 /**
  * cleanVar prepare variable for persistence
  *
  * @param XoopsObject $obj object containing variable
  * @param string      $key name of variable
  *
  * @return string
  */
 public function cleanVar(XoopsObject $obj, $key)
 {
     $value = trim($obj->vars[$key]['value']);
     if ($obj->vars[$key]['required'] && $value == '') {
         $obj->setErrors(sprintf(\XoopsLocale::F_IS_REQUIRED, $key));
         return $value;
     }
     if ($value != '' && !preg_match("/^http[s]*:\\/\\//i", $value)) {
         $value = 'http://' . $value;
     }
     return $value;
 }
Example #7
0
 /**
  * @param XoopsObject $obj
  * @param string      $key
  * @param bool        $quote
  *
  * @return string
  */
 public function cleanVar(XoopsObject $obj, $key, $quote = true)
 {
     $value = $obj->vars[$key]['value'];
     if (!in_array($value, $obj->vars[$key]['enumeration'])) {
         $obj->setErrors("Invalid Enumeration");
         return $value;
     }
     if ($quote) {
         $value = str_replace('\\"', '"', $this->db->quote($value));
     }
     return $value;
 }
Example #8
0
 /**
  * @param XoopsObject $obj
  * @param string      $key
  * @param bool        $quote
  *
  * @return string
  */
 public function cleanVar(XoopsObject $obj, $key, $quote = true)
 {
     $value = $obj->vars[$key]['value'];
     if ($obj->vars[$key]['required'] && $value != '0' && $value == '') {
         $obj->setErrors(sprintf(\XoopsLocale::F_IS_REQUIRED, $key));
         return $value;
     }
     if (isset($obj->vars[$key]['maxlength']) && mb_strlen($value) > (int) $obj->vars[$key]['maxlength']) {
         $obj->setErrors(sprintf(\XoopsLocale::F_MUST_BE_SHORTER_THAN, $key, (int) $obj->vars[$key]['maxlength']));
         return $value;
     }
     if (!$obj->vars[$key]['not_gpc']) {
         $value = $this->ts->stripSlashesGPC($this->ts->censorString($value));
     } else {
         $value = $this->ts->censorString($value);
     }
     if ($quote) {
         $value = str_replace('\\"', '"', $this->db->quote($value));
     }
     return $value;
 }
Example #9
0
 /**
  * @param XoopsObject $obj
  * @param string      $key
  * @param bool        $quote
  *
  * @return string
  */
 function cleanVar(XoopsObject $obj, $key, $quote = true)
 {
     $value = trim($obj->vars[$key]['value']);
     if ($obj->vars[$key]['required'] && $value == '') {
         $obj->setErrors(sprintf(\XoopsLocale::F_IS_REQUIRED, $key));
         return $value;
     }
     if ($value != '' && !preg_match("/^http[s]*:\\/\\//i", $value)) {
         $value = 'http://' . $value;
     }
     if (!$obj->vars[$key]['not_gpc']) {
         $value = $this->ts->stripSlashesGPC($value);
     }
     if ($quote) {
         $value = str_replace('\\"', '"', $this->db->quote($value));
     }
     return $value;
 }