Beispiel #1
0
 /**
  * Write data to a file
  */
 public function write($data = '')
 {
     $path = $this->getPath();
     $parent = $this->getParent();
     $ext = $this->getExtension();
     $data = Sanitize::toString($data);
     $output = false;
     if (!empty($path) && !empty($parent) && !empty($ext)) {
         if (is_dir($parent) || mkdir($parent, 0777, true)) {
             $stream = fopen($path, 'wb');
             $output = fwrite($stream, $data);
             fclose($stream);
         }
     }
     return $output;
 }
Beispiel #2
0
 /**
  * Saves a new cookie value
  */
 public function save($value = null, $expire = null, $encrypt = false)
 {
     if (!empty($this->_name)) {
         $value = Sanitize::toString($value);
         $expire = Sanitize::toTime($expire);
         if ($encrypt === true) {
             $value = $this->encrypt($value);
         }
         return setcookie($this->_name, $value, $expire, $this->_path, $this->_domain, $this->_secure, $this->_http);
     }
     return false;
 }
Beispiel #3
0
 /**
  * Adds col BETWEEN( min AND max ) to the WHERE clause
  */
 public function between($column = '', $min = null, $max = null, $next = '')
 {
     if (!empty($column) && !is_null($min) && !is_null($max)) {
         $column = $this->_clause($column);
         $values = array($min, $max);
         $next = strtoupper(trim($next));
         $keys = array();
         foreach ($values as $value) {
             $key = ':val' . $this->_num;
             $keys[] = $key;
             $this->_data['query'][$key] = Sanitize::toString($value);
             $this->_num++;
         }
         $this->_maps['where'][$column] = $this->_clause('(%s BETWEEN ' . implode(' AND ', $keys) . ') ' . $next);
     }
     return $this;
 }