Beispiel #1
0
 /**
  * Get a cookie value, or default fallback
  */
 public function get($default = '', $decrypt = false)
 {
     if ($this->exists()) {
         $value = trim($_COOKIE[$this->_name]);
         if ($decrypt === true) {
             $value = $this->decrypt($value);
         }
         return Sanitize::toType($value);
     }
     return $default;
 }
Beispiel #2
0
 /**
  * Recursive filter for input data arrays
  */
 private function _filter($value = null)
 {
     if (is_numeric($value)) {
         return $value + 0;
     }
     if (is_string($value)) {
         $value = trim($value);
         if (!empty($this->_encoding)) {
             $value = mb_convert_encoding($value, $this->_encoding, $this->_encoding);
         }
         if (get_magic_quotes_gpc()) {
             $value = stripslashes($value);
         }
         return Sanitize::toType($value);
     }
     if (is_array($value)) {
         foreach ($value as $k => $v) {
             $value[$k] = $this->_filter($v);
         }
     }
     return $value;
 }
Beispiel #3
0
 /**
  * Loads data from a text/plain file as INI data and put it into the _ENV array.
  */
 public function loadEnv($file = '')
 {
     if (is_file($file)) {
         $data = @parse_ini_file($file, false);
         if (is_array($data)) {
             foreach ($data as $key => $value) {
                 $key = Sanitize::toKey($key);
                 $value = Sanitize::toType($value);
                 if (empty($key) || is_numeric($key) || is_string($key) !== true) {
                     continue;
                 }
                 if (array_key_exists($key, $_ENV)) {
                     continue;
                 }
                 putenv($key . '=' . $value);
                 $_ENV[$key] = $value;
             }
         }
     }
 }
Beispiel #4
0
 /**
  * Decodes string data for a column
  */
 public function decodeType($row = array(), $column = '')
 {
     if (!empty($column) && array_key_exists($column, $row)) {
         $row[$column] = Sanitize::toType($row[$column]);
     }
     return $row;
 }