Ejemplo n.º 1
0
 protected function parseAll()
 {
     $d = dir(Path::real('css'));
     while (false !== ($file = $d->read())) {
         if (strncmp($file, '.', 1) != 0) {
             $filename = Path::rawjoin(array($d->path, $file));
             if (is_readable($filename)) {
                 $this->css[$filename] = $this->parse(file_get_contents($filename));
             }
         }
     }
     $d->close();
 }
Ejemplo n.º 2
0
 /**
  * Read file and assign properties.
  *
  * If $width and $height are not null, and $exact:
  * - is true: if image dimensions are other then $width x $height, raise
  *   CETypeError;
  * - is false: propportional scale image to specified dimensions.
  *
  * $width or $height can be false ({@link Image::scaleProp() more}).
  *
  * @param string  $fname  filename to read
  * @param mixed   $width
  * @param mixed   $height
  * @param boolean $exact
  *
  * @return mixed
  * @throws CEFileSystemError ({@link CEFileSystemError description})
  * @throws CETypeError       ({@link CETypeError description})
  *
  * @access public
  */
 public function open($fname, $width = null, $height = null, $exact = true)
 {
     $fname = Path::real($fname);
     if (!file_exists($fname) || !is_readable($fname)) {
         throw new CEFileSystemError(sprintf('Cannot read "%s".', $fname), 100);
     }
     $dst = imagecreatefromstring(file_get_contents($fname));
     $this->swap($dst);
     if (!is_null($width) && !is_null($height)) {
         if (false === $width && false === $height) {
             throw new CETypeError('Both values: $max_width and $max_height ' . 'cannot be false', 200);
         }
         if ($exact) {
             // if image has other dimensions then specified
             if (false !== $width && $width != $this->width || false !== $height && $height != $this->height) {
                 throw new CETypeError(sprintf('Specified image (%s) has ' . 'dimensions different then %dx%d.', $fname, $width, $height), 201);
             }
         } else {
             return $this->scaleProp($width, $height, 'ffffff', false, 'c', 0);
         }
     }
     return true;
 }
Ejemplo n.º 3
0
 public function real_with_array()
 {
     $folder = $this->existingFolder();
     $this->assertEquals($folder->path, Path::real([$folder->path, '.', $folder->dirname, '..'])->toString());
 }
Ejemplo n.º 4
0
 /**
  * Recursive walk into directory and return it's content.
  *
  * @param string  $dir directory to scan
  * @param boolean $assoc return associative or normal array
  * @param integer $maxLevel how deep scan $dir
  *
  * @return array
  * @throws CENotFound ({@link CENotFound description})
  *
  * @access public
  */
 public static function walk($dir, $assoc = false, $maxLevel = false, $curLevel = 1)
 {
     $dir = Path::real($dir);
     $ret = array();
     $data = Path::listdir($dir, self::SORT_ASC, true);
     if ($assoc) {
         $ret[$dir] = array('dirs' => $data['dirs'], 'files' => $data['files']);
     } else {
         $ret[] = array($dir, $data['dirs'], $data['files']);
     }
     if (false === $maxLevel || $maxLevel > $curLevel) {
         foreach ($data['dirs'] as $d) {
             $path = Path::join($dir, $d);
             $ret = array_merge($ret, Path::walk($path, $assoc, $maxLevel, $curLevel + 1));
         }
     }
     return $ret;
 }
Ejemplo n.º 5
0
<?php

include_once Path::real('inc/web.php');
include_once Path::real('inc/db.php');
include_once Path::real('inc/cookies.php');
include_once Path::real('inc/json.php');
Db::open($dbConfig);
$config = array();
if ($data = Db::query('SELECT * FROM config')) {
    $config = array_merge($config, $data);
}
ini_set('session.cookie_domain', strpos($_SERVER['HTTP_HOST'], '.') !== false ? $_SERVER['HTTP_HOST'] : '');
ini_set('session.cookie_path', '/');
Ejemplo n.º 6
0
<?php

$urls = array('hello/(.*)/' => 'HelloWorld', 'hello/' => 'HelloWorld', 'api/(.*)/' => 'Api', '\\+/(.*)/' => 'Css', '\\+/' => 'Css', '@@/(.*)/' => 'Icon', '\\*/(.*)/' => 'JavaScript', '\\*/' => 'JavaScript', '(nocookies)/' => 'Html', '(nobrowser)/' => 'Html', '(i3t)/' => 'Html', '(login)/' => 'Html', '' => 'Html');
include_once 'inc/path.php';
Path::$path = realpath(dirname(__FILE__));
include_once Path::real('config.php');
include_once Path::real('inc/common.php');
Web::dispatch($urls);