/** * Use this snippet to extract any currency out of a string * * @see icms_currency * @deprecated Use icms_currency * @todo remove in version 1.4 */ function icms_float($var) { return icms_currency($var); }
/** * clean values of all variables of the object for storage. * also add slashes whereever needed * * We had to put this method in the icms_ipf_Object because the XOBJ_DTYPE_ARRAY does not work properly * at least on PHP 5.1. So we have created a new type XOBJ_DTYPE_SIMPLE_ARRAY to handle 1 level array * as a string separated by | * * @return bool true if successful * @access public */ public function cleanVars() { $existing_errors = $this->getErrors(); $this->_errors = array(); foreach ($this->vars as $k => $v) { $cleanv = $v['value']; if (!$v['changed'] || $this->_isNewConfig) { } else { $cleanv = is_string($cleanv) ? trim($cleanv) : $cleanv; switch ($v['data_type']) { case XOBJ_DTYPE_TXTBOX: if ($v['required'] && $cleanv != '0' && $cleanv == '') { $this->setErrors(sprintf(_XOBJ_ERR_REQUIRED, $k)); continue; } if (isset($v['maxlength']) && strlen($cleanv) > (int) $v['maxlength']) { $this->setErrors(sprintf(_XOBJ_ERR_SHORTERTHAN, $k, (int) $v['maxlength'])); continue; } if (!$v['not_gpc']) { $cleanv = icms_core_DataFilter::stripSlashesGPC(icms_core_DataFilter::censorString($cleanv)); } else { $cleanv = icms_core_DataFilter::censorString($cleanv); } break; case XOBJ_DTYPE_TXTAREA: if ($v['required'] && $cleanv != '0' && $cleanv == '') { $this->setErrors(sprintf(_XOBJ_ERR_REQUIRED, $k)); continue; } if (!$v['not_gpc']) { $cleanv = icms_core_DataFilter::stripSlashesGPC($cleanv); $cleanv = icms_core_DataFilter::checkVar($cleanv, 'html', 'input'); } else { //$cleanv = icms_core_DataFilter::censorString($cleanv); $cleanv = icms_core_DataFilter::checkVar($cleanv, 'html', 'input'); } break; case XOBJ_DTYPE_SOURCE: if (!$v['not_gpc']) { $cleanv = icms_core_DataFilter::stripSlashesGPC($cleanv); } else { $cleanv = $cleanv; } break; case XOBJ_DTYPE_INT: case XOBJ_DTYPE_TIME_ONLY: $cleanv = (int) $cleanv; break; case XOBJ_DTYPE_CURRENCY: $cleanv = icms_currency($cleanv); break; case XOBJ_DTYPE_FLOAT: $cleanv = icms_float($cleanv); break; case XOBJ_DTYPE_EMAIL: if ($v['required'] && $cleanv == '') { $this->setErrors(sprintf(_XOBJ_ERR_REQUIRED, $k)); continue; } if ($cleanv != '' && !icms_core_DataFilter::checkVar($cleanv, 'email')) { $this->setErrors(_CORE_DB_INVALIDEMAIL); continue; } if (!$v['not_gpc']) { $cleanv = icms_core_DataFilter::stripSlashesGPC($cleanv); } break; case XOBJ_DTYPE_URL: if ($v['required'] && $cleanv == '') { $this->setErrors(sprintf(_XOBJ_ERR_REQUIRED, $k)); continue; } if ($cleanv != '' && !preg_match("/^http[s]*:\\/\\//i", $cleanv)) { $cleanv = 'http://' . $cleanv; } if (!$v['not_gpc']) { $cleanv = icms_core_DataFilter::stripSlashesGPC($cleanv); } break; case XOBJ_DTYPE_SIMPLE_ARRAY: $cleanv = implode('|', $cleanv); break; case XOBJ_DTYPE_ARRAY: $cleanv = is_array($cleanv) ? serialize($cleanv) : $cleanv; break; case XOBJ_DTYPE_STIME: case XOBJ_DTYPE_MTIME: case XOBJ_DTYPE_LTIME: $cleanv = !is_string($cleanv) ? (int) $cleanv : strtotime($cleanv); if (!($cleanv > 0)) { $cleanv = strtotime($cleanv); } break; default: break; } } $this->cleanVars[$k] =& $cleanv; unset($cleanv); } if (count($this->_errors) > 0) { $this->_errors = array_merge($existing_errors, $this->_errors); return false; } $this->_errors = array_merge($existing_errors, $this->_errors); $this->unsetDirty(); return true; }