Phalcon Framework 2.0.13

Exception: Image file not found: /home/cvkedu/public_html/beta/src/web/img/original/publication_preview_src/0/35.jpg

/home/cvkedu/public_html/beta/src/app/modules/Image/PHPThumb/ThumbBase.inc.php (193)
#0ThumbBase->triggerError(Image file not found: /home/cvkedu/public_html/beta/src/web/img/original/publication_preview_src/0/35.jpg)
/home/cvkedu/public_html/beta/src/app/modules/Image/PHPThumb/ThumbBase.inc.php (172)
<?php
/**
 * PhpThumb Base Class Definition File
 * 
 * This file contains the definition for the ThumbBase object
 * 
 * PHP Version 5 with GD 2.0+
 * PhpThumb : PHP Thumb Library <http://phpthumb.gxdlabs.com>
 * Copyright (c) 2009, Ian Selby/Gen X Design
 * 
 * Author(s): Ian Selby <ian@gen-x-design.com>
 * 
 * Licensed under the MIT License
 * Redistributions of files must retain the above copyright notice.
 * 
 * @author Ian Selby <ian@gen-x-design.com>
 * @copyright Copyright (c) 2009 Gen X Design
 * @link http://phpthumb.gxdlabs.com
 * @license http://www.opensource.org/licenses/mit-license.php The MIT License
 * @version 3.0
 * @package PhpThumb
 * @filesource
 */
 
/**
 * ThumbBase Class Definition
 * 
 * This is the base class that all implementations must extend.  It contains the 
 * core variables and functionality common to all implementations, as well as the functions that 
 * allow plugins to augment those classes.
 * 
 * @package PhpThumb
 * @subpackage Core
 */
abstract class ThumbBase 
{
  /**
   * All imported objects
   * 
   * An array of imported plugin objects
   * 
   * @var array
   */
  protected $imported;
  /**
   * All imported object functions
   * 
   * An array of all methods added to this class by imported plugin objects
   * 
   * @var array
   */
  protected $importedFunctions;
  /**
   * The last error message raised
   * 
   * @var string
   */
  protected $errorMessage;
  /**
   * Whether or not the current instance has any errors
   * 
   * @var bool
   */
  protected $hasError;
  /**
   * The name of the file we're manipulating
   * 
   * This must include the path to the file (absolute paths recommended)
   * 
   * @var string
   */
  protected $fileName;
  /**
   * What the file format is (mime-type)
   * 
   * @var string
   */
  protected $format;
  /**
   * Whether or not the image is hosted remotely
   * 
   * @var bool
   */
  protected $remoteImage;
  /**
   * Whether or not the current image is an actual file, or the raw file data
   *
   * By "raw file data" it's meant that we're actually passing the result of something
   * like file_get_contents() or perhaps from a database blob
   * 
   * @var bool
   */
  protected $isDataStream;
  
  /**
   * Class constructor
   * 
   * @return ThumbBase
   */
  public function __construct ($fileName, $isDataStream = false)
  {
    $this->imported        = array();
    $this->importedFunctions  = array();
    $this->errorMessage      = null;
    $this->hasError        = false;
    $this->fileName        = $fileName;
    $this->remoteImage      = false;
    $this->isDataStream      = $isDataStream;
    
    $this->fileExistsAndReadable();
  }
  
  /**
   * Imports plugins in $registry to the class
   * 
   * @param array $registry
   */
  public function importPlugins ($registry)
  {
    foreach ($registry as $plugin => $meta)
    {
      $this->imports($plugin);
    }
  }
  
  /**
   * Imports a plugin
   * 
   * This is where all the plugins magic happens!  This function "loads" the plugin functions, making them available as 
   * methods on the class.
   * 
   * @param string $object The name of the object to import / "load"
   */
  protected function imports ($object)
  {
    // the new object to import
    $newImport       = new $object();
    // the name of the new object (class name)
    $importName      = get_class($newImport);
    // the new functions to import
    $importFunctions   = get_class_methods($newImport);
    
    // add the object to the registry
    array_push($this->imported, array($importName, $newImport));
    
    // add the methods to the registry
    foreach ($importFunctions as $key => $functionName)
    {
      $this->importedFunctions[$functionName] = &$newImport;
    }
  }
  
  /**
   * Checks to see if $this->fileName exists and is readable
   * 
   */
  protected function fileExistsAndReadable ()
  {
    if ($this->isDataStream === true)
    {
      return;
    }
    
    if (stristr($this->fileName, 'http://') !== false)
    {
      $this->remoteImage = true;
      return;
    }
    
    if (!file_exists($this->fileName))
    {
      $this->triggerError('Image file not found: ' . $this->fileName);
    }
    elseif (!is_readable($this->fileName))
    {
      $this->triggerError('Image file not readable: ' . $this->fileName);
    }
  }
  
  /**
   * Sets $this->errorMessage to $errorMessage and throws an exception
   * 
   * Also sets $this->hasError to true, so even if the exceptions are caught, we don't
   * attempt to proceed with any other functions
   * 
   * @param string $errorMessage
   */
  protected function triggerError ($errorMessage)
  {
    $this->hasError   = true;
    $this->errorMessage  = $errorMessage;
    
    throw new Exception ($errorMessage);
  }
  
  /**
   * Calls plugin / imported functions
   * 
   * This is also where a fair amount of plugins magaic happens.  This magic method is called whenever an "undefined" class 
   * method is called in code, and we use that to call an imported function. 
   * 
   * You should NEVER EVER EVER invoke this function manually.  The universe will implode if you do... seriously ;)
   * 
   * @param string $method
   * @param array $args
   */
  public function __call ($method, $args)
  {
    if( array_key_exists($method, $this->importedFunctions))
    {
      $args[] = $this;
      return call_user_func_array(array($this->importedFunctions[$method], $method), $args);
    }
    
    throw new BadMethodCallException ('Call to undefined method/class function: ' . $method);
  }
 
    /**
     * Returns $imported.
     * @see ThumbBase::$imported
     * @return array
     */
    public function getImported ()
    {
        return $this->imported;
    }
    
    /**
     * Returns $importedFunctions.
     * @see ThumbBase::$importedFunctions
     * @return array
     */
    public function getImportedFunctions ()
    {
        return $this->importedFunctions;
    }
  
  /**
   * Returns $errorMessage.
   *
   * @see ThumbBase::$errorMessage
   */
  public function getErrorMessage ()
  {
    return $this->errorMessage;
  }
  
  /**
   * Sets $errorMessage.
   *
   * @param object $errorMessage
   * @see ThumbBase::$errorMessage
   */
  public function setErrorMessage ($errorMessage)
  {
    $this->errorMessage = $errorMessage;
  }
  
  /**
   * Returns $fileName.
   *
   * @see ThumbBase::$fileName
   */
  public function getFileName ()
  {
    return $this->fileName;
  }
  
  /**
   * Sets $fileName.
   *
   * @param object $fileName
   * @see ThumbBase::$fileName
   */
  public function setFileName ($fileName)
  {
    $this->fileName = $fileName;
  }
  
  /**
   * Returns $format.
   *
   * @see ThumbBase::$format
   */
  public function getFormat ()
  {
    return $this->format;
  }
  
  /**
   * Sets $format.
   *
   * @param object $format
   * @see ThumbBase::$format
   */
  public function setFormat ($format)
  {
    $this->format = $format;
  }
  
  /**
   * Returns $hasError.
   *
   * @see ThumbBase::$hasError
   */
  public function getHasError ()
  {
    return $this->hasError;
  }
  
  /**
   * Sets $hasError.
   *
   * @param object $hasError
   * @see ThumbBase::$hasError
   */
  public function setHasError ($hasError)
  {
    $this->hasError = $hasError;
  } 
  
 
}
#1ThumbBase->fileExistsAndReadable()
/home/cvkedu/public_html/beta/src/app/modules/Image/PHPThumb/ThumbBase.inc.php (110)
<?php
/**
 * PhpThumb Base Class Definition File
 * 
 * This file contains the definition for the ThumbBase object
 * 
 * PHP Version 5 with GD 2.0+
 * PhpThumb : PHP Thumb Library <http://phpthumb.gxdlabs.com>
 * Copyright (c) 2009, Ian Selby/Gen X Design
 * 
 * Author(s): Ian Selby <ian@gen-x-design.com>
 * 
 * Licensed under the MIT License
 * Redistributions of files must retain the above copyright notice.
 * 
 * @author Ian Selby <ian@gen-x-design.com>
 * @copyright Copyright (c) 2009 Gen X Design
 * @link http://phpthumb.gxdlabs.com
 * @license http://www.opensource.org/licenses/mit-license.php The MIT License
 * @version 3.0
 * @package PhpThumb
 * @filesource
 */
 
/**
 * ThumbBase Class Definition
 * 
 * This is the base class that all implementations must extend.  It contains the 
 * core variables and functionality common to all implementations, as well as the functions that 
 * allow plugins to augment those classes.
 * 
 * @package PhpThumb
 * @subpackage Core
 */
abstract class ThumbBase 
{
  /**
   * All imported objects
   * 
   * An array of imported plugin objects
   * 
   * @var array
   */
  protected $imported;
  /**
   * All imported object functions
   * 
   * An array of all methods added to this class by imported plugin objects
   * 
   * @var array
   */
  protected $importedFunctions;
  /**
   * The last error message raised
   * 
   * @var string
   */
  protected $errorMessage;
  /**
   * Whether or not the current instance has any errors
   * 
   * @var bool
   */
  protected $hasError;
  /**
   * The name of the file we're manipulating
   * 
   * This must include the path to the file (absolute paths recommended)
   * 
   * @var string
   */
  protected $fileName;
  /**
   * What the file format is (mime-type)
   * 
   * @var string
   */
  protected $format;
  /**
   * Whether or not the image is hosted remotely
   * 
   * @var bool
   */
  protected $remoteImage;
  /**
   * Whether or not the current image is an actual file, or the raw file data
   *
   * By "raw file data" it's meant that we're actually passing the result of something
   * like file_get_contents() or perhaps from a database blob
   * 
   * @var bool
   */
  protected $isDataStream;
  
  /**
   * Class constructor
   * 
   * @return ThumbBase
   */
  public function __construct ($fileName, $isDataStream = false)
  {
    $this->imported        = array();
    $this->importedFunctions  = array();
    $this->errorMessage      = null;
    $this->hasError        = false;
    $this->fileName        = $fileName;
    $this->remoteImage      = false;
    $this->isDataStream      = $isDataStream;
    
    $this->fileExistsAndReadable();
  }
  
  /**
   * Imports plugins in $registry to the class
   * 
   * @param array $registry
   */
  public function importPlugins ($registry)
  {
    foreach ($registry as $plugin => $meta)
    {
      $this->imports($plugin);
    }
  }
  
  /**
   * Imports a plugin
   * 
   * This is where all the plugins magic happens!  This function "loads" the plugin functions, making them available as 
   * methods on the class.
   * 
   * @param string $object The name of the object to import / "load"
   */
  protected function imports ($object)
  {
    // the new object to import
    $newImport       = new $object();
    // the name of the new object (class name)
    $importName      = get_class($newImport);
    // the new functions to import
    $importFunctions   = get_class_methods($newImport);
    
    // add the object to the registry
    array_push($this->imported, array($importName, $newImport));
    
    // add the methods to the registry
    foreach ($importFunctions as $key => $functionName)
    {
      $this->importedFunctions[$functionName] = &$newImport;
    }
  }
  
  /**
   * Checks to see if $this->fileName exists and is readable
   * 
   */
  protected function fileExistsAndReadable ()
  {
    if ($this->isDataStream === true)
    {
      return;
    }
    
    if (stristr($this->fileName, 'http://') !== false)
    {
      $this->remoteImage = true;
      return;
    }
    
    if (!file_exists($this->fileName))
    {
      $this->triggerError('Image file not found: ' . $this->fileName);
    }
    elseif (!is_readable($this->fileName))
    {
      $this->triggerError('Image file not readable: ' . $this->fileName);
    }
  }
  
  /**
   * Sets $this->errorMessage to $errorMessage and throws an exception
   * 
   * Also sets $this->hasError to true, so even if the exceptions are caught, we don't
   * attempt to proceed with any other functions
   * 
   * @param string $errorMessage
   */
  protected function triggerError ($errorMessage)
  {
    $this->hasError   = true;
    $this->errorMessage  = $errorMessage;
    
    throw new Exception ($errorMessage);
  }
  
  /**
   * Calls plugin / imported functions
   * 
   * This is also where a fair amount of plugins magaic happens.  This magic method is called whenever an "undefined" class 
   * method is called in code, and we use that to call an imported function. 
   * 
   * You should NEVER EVER EVER invoke this function manually.  The universe will implode if you do... seriously ;)
   * 
   * @param string $method
   * @param array $args
   */
  public function __call ($method, $args)
  {
    if( array_key_exists($method, $this->importedFunctions))
    {
      $args[] = $this;
      return call_user_func_array(array($this->importedFunctions[$method], $method), $args);
    }
    
    throw new BadMethodCallException ('Call to undefined method/class function: ' . $method);
  }
 
    /**
     * Returns $imported.
     * @see ThumbBase::$imported
     * @return array
     */
    public function getImported ()
    {
        return $this->imported;
    }
    
    /**
     * Returns $importedFunctions.
     * @see ThumbBase::$importedFunctions
     * @return array
     */
    public function getImportedFunctions ()
    {
        return $this->importedFunctions;
    }
  
  /**
   * Returns $errorMessage.
   *
   * @see ThumbBase::$errorMessage
   */
  public function getErrorMessage ()
  {
    return $this->errorMessage;
  }
  
  /**
   * Sets $errorMessage.
   *
   * @param object $errorMessage
   * @see ThumbBase::$errorMessage
   */
  public function setErrorMessage ($errorMessage)
  {
    $this->errorMessage = $errorMessage;
  }
  
  /**
   * Returns $fileName.
   *
   * @see ThumbBase::$fileName
   */
  public function getFileName ()
  {
    return $this->fileName;
  }
  
  /**
   * Sets $fileName.
   *
   * @param object $fileName
   * @see ThumbBase::$fileName
   */
  public function setFileName ($fileName)
  {
    $this->fileName = $fileName;
  }
  
  /**
   * Returns $format.
   *
   * @see ThumbBase::$format
   */
  public function getFormat ()
  {
    return $this->format;
  }
  
  /**
   * Sets $format.
   *
   * @param object $format
   * @see ThumbBase::$format
   */
  public function setFormat ($format)
  {
    $this->format = $format;
  }
  
  /**
   * Returns $hasError.
   *
   * @see ThumbBase::$hasError
   */
  public function getHasError ()
  {
    return $this->hasError;
  }
  
  /**
   * Sets $hasError.
   *
   * @param object $hasError
   * @see ThumbBase::$hasError
   */
  public function setHasError ($hasError)
  {
    $this->hasError = $hasError;
  } 
  
 
}
#2ThumbBase->__construct(/home/cvkedu/public_html/beta/src/web/img/original/publication_preview_src/0/35.jpg, false)
/home/cvkedu/public_html/beta/src/app/modules/Image/PHPThumb/GdThumb.inc.php (96)
<?php
/**
 * PhpThumb GD Thumb Class Definition File
 * 
 * This file contains the definition for the GdThumb object
 * 
 * PHP Version 5 with GD 2.0+
 * PhpThumb : PHP Thumb Library <http://phpthumb.gxdlabs.com>
 * Copyright (c) 2009, Ian Selby/Gen X Design
 * 
 * Author(s): Ian Selby <ian@gen-x-design.com>
 * 
 * Licensed under the MIT License
 * Redistributions of files must retain the above copyright notice.
 * 
 * @author Ian Selby <ian@gen-x-design.com>
 * @copyright Copyright (c) 2009 Gen X Design
 * @link http://phpthumb.gxdlabs.com
 * @license http://www.opensource.org/licenses/mit-license.php The MIT License
 * @version 3.0
 * @package PhpThumb
 * @filesource
 */
 
/**
 * GdThumb Class Definition
 * 
 * This is the GD Implementation of the PHP Thumb library.
 * 
 * @package PhpThumb
 * @subpackage Core
 */
class GdThumb extends ThumbBase
{
  /**
   * The prior image (before manipulation)
   * 
   * @var resource
   */
  protected $oldImage;
  /**
   * The working image (used during manipulation)
   * 
   * @var resource
   */
  protected $workingImage;
  /**
   * The current dimensions of the image
   * 
   * @var array
   */
  protected $currentDimensions;
  /**
   * The new, calculated dimensions of the image
   * 
   * @var array
   */
  protected $newDimensions;
  /**
   * The options for this class
   * 
   * This array contains various options that determine the behavior in
   * various functions throughout the class.  Functions note which specific 
   * option key / values are used in their documentation
   * 
   * @var array
   */
  protected $options;
  /**
   * The maximum width an image can be after resizing (in pixels)
   * 
   * @var int
   */
  protected $maxWidth;
  /**
   * The maximum height an image can be after resizing (in pixels)
   * 
   * @var int
   */
  protected $maxHeight;
  /**
   * The percentage to resize the image by
   * 
   * @var int
   */
  protected $percent;
  
  /**
   * Class Constructor
   * 
   * @return GdThumb 
   * @param string $fileName
   */
  public function __construct ($fileName, $options = array(), $isDataStream = false)
  {
    parent::__construct($fileName, $isDataStream);
    
    $this->determineFormat();
    
    if ($this->isDataStream === false)
    {
      $this->verifyFormatCompatiblity();
    }
    
    switch ($this->format)
    {
      case 'GIF':
        $this->oldImage = imagecreatefromgif($this->fileName);
        break;
      case 'JPG':
        $this->oldImage = imagecreatefromjpeg($this->fileName);
        break;
      case 'PNG':
        $this->oldImage = imagecreatefrompng($this->fileName);
        break;
      case 'STRING':
        $this->oldImage = imagecreatefromstring($this->fileName);
        break;
    }
  
    $this->currentDimensions = array
    (
      'width'   => imagesx($this->oldImage),
      'height'  => imagesy($this->oldImage)
    );
    
    $this->setOptions($options);
    
    // TODO: Port gatherImageMeta to a separate function that can be called to extract exif data
  }
  
  /**
   * Class Destructor
   * 
   */
  public function __destruct ()
  {
    if (is_resource($this->oldImage))
    {
      imagedestroy($this->oldImage);
    }
    
    if (is_resource($this->workingImage))
    {
      imagedestroy($this->workingImage);
    }
  }
  
  ##############################
  # ----- API FUNCTIONS ------ #
  ##############################
  
  /**
   * Resizes an image to be no larger than $maxWidth or $maxHeight
   * 
   * If either param is set to zero, then that dimension will not be considered as a part of the resize.
   * Additionally, if $this->options['resizeUp'] is set to true (false by default), then this function will
   * also scale the image up to the maximum dimensions provided.
   * 
   * @param int $maxWidth The maximum width of the image in pixels
   * @param int $maxHeight The maximum height of the image in pixels
   * @return GdThumb
   */
  public function resize ($maxWidth = 0, $maxHeight = 0)
  {
    // make sure our arguments are valid
    if (!is_numeric($maxWidth))
    {
      throw new InvalidArgumentException('$maxWidth must be numeric');
    }
    
    if (!is_numeric($maxHeight))
    {
      throw new InvalidArgumentException('$maxHeight must be numeric');
    }
    
    // make sure we're not exceeding our image size if we're not supposed to
    if ($this->options['resizeUp'] === false)
    {
      $this->maxHeight  = (intval($maxHeight) > $this->currentDimensions['height']) ? $this->currentDimensions['height'] : $maxHeight;
      $this->maxWidth    = (intval($maxWidth) > $this->currentDimensions['width']) ? $this->currentDimensions['width'] : $maxWidth;
    }
    else
    {
      $this->maxHeight  = intval($maxHeight);
      $this->maxWidth    = intval($maxWidth);
    }
    
    // get the new dimensions...
    $this->calcImageSize($this->currentDimensions['width'], $this->currentDimensions['height']);
    
    // create the working image
    if (function_exists('imagecreatetruecolor'))
    {
      $this->workingImage = imagecreatetruecolor($this->newDimensions['newWidth'], $this->newDimensions['newHeight']);
    }
    else
    {
      $this->workingImage = imagecreate($this->newDimensions['newWidth'], $this->newDimensions['newHeight']);
    }
    
    $this->preserveAlpha();    
    
    // and create the newly sized image
    imagecopyresampled
    (
      $this->workingImage,
      $this->oldImage,
      0,
      0,
      0,
      0,
      $this->newDimensions['newWidth'],
      $this->newDimensions['newHeight'],
      $this->currentDimensions['width'],
      $this->currentDimensions['height']
    );
 
    // update all the variables and resources to be correct
    $this->oldImage           = $this->workingImage;
    $this->currentDimensions['width']   = $this->newDimensions['newWidth'];
    $this->currentDimensions['height']   = $this->newDimensions['newHeight'];
    
    return $this;
  }
  
  /**
   * Adaptively Resizes the Image
   * 
   * This function attempts to get the image to as close to the provided dimensions as possible, and then crops the 
   * remaining overflow (from the center) to get the image to be the size specified
   * 
   * @param int $maxWidth
   * @param int $maxHeight
   * @return GdThumb
   */
  public function adaptiveResize ($width, $height)
  {
    // make sure our arguments are valid
    if (!is_numeric($width) || $width  == 0)
    {
      throw new InvalidArgumentException('$width must be numeric and greater than zero');
    }
    
    if (!is_numeric($height) || $height == 0)
    {
      throw new InvalidArgumentException('$height must be numeric and greater than zero');
    }
    
    // make sure we're not exceeding our image size if we're not supposed to
    if ($this->options['resizeUp'] === false)
    {
      $this->maxHeight  = (intval($height) > $this->currentDimensions['height']) ? $this->currentDimensions['height'] : $height;
      $this->maxWidth    = (intval($width) > $this->currentDimensions['width']) ? $this->currentDimensions['width'] : $width;
    }
    else
    {
      $this->maxHeight  = intval($height);
      $this->maxWidth    = intval($width);
    }
    
    $this->calcImageSizeStrict($this->currentDimensions['width'], $this->currentDimensions['height']);
    
    // resize the image to be close to our desired dimensions
    $this->resize($this->newDimensions['newWidth'], $this->newDimensions['newHeight']);
    
    // reset the max dimensions...
    if ($this->options['resizeUp'] === false)
    {
      $this->maxHeight  = (intval($height) > $this->currentDimensions['height']) ? $this->currentDimensions['height'] : $height;
      $this->maxWidth    = (intval($width) > $this->currentDimensions['width']) ? $this->currentDimensions['width'] : $width;
    }
    else
    {
      $this->maxHeight  = intval($height);
      $this->maxWidth    = intval($width);
    }
    
    // create the working image
    if (function_exists('imagecreatetruecolor'))
    {
      $this->workingImage = imagecreatetruecolor($this->maxWidth, $this->maxHeight);
    }
    else
    {
      $this->workingImage = imagecreate($this->maxWidth, $this->maxHeight);
    }
    
    $this->preserveAlpha();
    
    $cropWidth  = $this->maxWidth;
    $cropHeight  = $this->maxHeight;
    $cropX     = 0;
    $cropY     = 0;
    
    // now, figure out how to crop the rest of the image...
    if ($this->currentDimensions['width'] > $this->maxWidth)
    {
      $cropX = intval(($this->currentDimensions['width'] - $this->maxWidth) / 2);
    }
    elseif ($this->currentDimensions['height'] > $this->maxHeight)
    {
      $cropY = intval(($this->currentDimensions['height'] - $this->maxHeight) / 2);
    }
    
    imagecopyresampled
    (
            $this->workingImage,
            $this->oldImage,
            0,
            0,
            $cropX,
            $cropY,
            $cropWidth,
            $cropHeight,
            $cropWidth,
            $cropHeight
    );
    
    // update all the variables and resources to be correct
    $this->oldImage           = $this->workingImage;
    $this->currentDimensions['width']   = $this->maxWidth;
    $this->currentDimensions['height']   = $this->maxHeight;
    
    return $this;
  }
  
  /**
   * Resizes an image by a given percent uniformly
   * 
   * Percentage should be whole number representation (i.e. 1-100)
   * 
   * @param int $percent
   * @return GdThumb
   */
  public function resizePercent ($percent = 0)
  {
    if (!is_numeric($percent))
    {
      throw new InvalidArgumentException ('$percent must be numeric');
    }
    
    $this->percent = intval($percent);
    
    $this->calcImageSizePercent($this->currentDimensions['width'], $this->currentDimensions['height']);
    
    if (function_exists('imagecreatetruecolor'))
    {
      $this->workingImage = imagecreatetruecolor($this->newDimensions['newWidth'], $this->newDimensions['newHeight']);
    }
    else
    {
      $this->workingImage = imagecreate($this->newDimensions['newWidth'], $this->newDimensions['newHeight']);
    }
    
    $this->preserveAlpha();
    
    ImageCopyResampled(
      $this->workingImage,
      $this->oldImage,
      0,
      0,
      0,
      0,
      $this->newDimensions['newWidth'],
      $this->newDimensions['newHeight'],
      $this->currentDimensions['width'],
      $this->currentDimensions['height']
    );
 
    $this->oldImage           = $this->workingImage;
    $this->currentDimensions['width']   = $this->newDimensions['newWidth'];
    $this->currentDimensions['height']   = $this->newDimensions['newHeight'];
    
    return $this;
  }
  
  /**
   * Crops an image from the center with provided dimensions
   * 
   * If no height is given, the width will be used as a height, thus creating a square crop
   * 
   * @param int $cropWidth
   * @param int $cropHeight
   * @return GdThumb
   */
  public function cropFromCenter ($cropWidth, $cropHeight = null)
  {
    if (!is_numeric($cropWidth))
    {
      throw new InvalidArgumentException('$cropWidth must be numeric');
    }
    
    if ($cropHeight !== null && !is_numeric($cropHeight))
    {
      throw new InvalidArgumentException('$cropHeight must be numeric');
    }
    
    if ($cropHeight === null)
    {
      $cropHeight = $cropWidth;
    }
    
    $cropWidth  = ($this->currentDimensions['width'] < $cropWidth) ? $this->currentDimensions['width'] : $cropWidth;
    $cropHeight = ($this->currentDimensions['height'] < $cropHeight) ? $this->currentDimensions['height'] : $cropHeight;
    
    $cropX = intval(($this->currentDimensions['width'] - $cropWidth) / 2);
    $cropY = intval(($this->currentDimensions['height'] - $cropHeight) / 2);
    
    $this->crop($cropX, $cropY, $cropWidth, $cropHeight);
    
    return $this;
  }
  
  /**
   * Vanilla Cropping - Crops from x,y with specified width and height
   * 
   * @param int $startX
   * @param int $startY
   * @param int $cropWidth
   * @param int $cropHeight
   * @return GdThumb
   */
  public function crop ($startX, $startY, $cropWidth, $cropHeight)
  {
    // validate input
    if (!is_numeric($startX))
    {
      throw new InvalidArgumentException('$startX must be numeric');
    }
    
    if (!is_numeric($startY))
    {
      throw new InvalidArgumentException('$startY must be numeric');
    }
    
    if (!is_numeric($cropWidth))
    {
      throw new InvalidArgumentException('$cropWidth must be numeric');
    }
    
    if (!is_numeric($cropHeight))
    {
      throw new InvalidArgumentException('$cropHeight must be numeric');
    }
    
    // do some calculations
    $cropWidth  = ($this->currentDimensions['width'] < $cropWidth) ? $this->currentDimensions['width'] : $cropWidth;
    $cropHeight = ($this->currentDimensions['height'] < $cropHeight) ? $this->currentDimensions['height'] : $cropHeight;
    
    // ensure everything's in bounds
    if (($startX + $cropWidth) > $this->currentDimensions['width'])
    {
      $startX = ($this->currentDimensions['width'] - $cropWidth);
      
    }
    
    if (($startY + $cropHeight) > $this->currentDimensions['height'])
    {
      $startY = ($this->currentDimensions['height'] - $cropHeight);
    }
    
    if ($startX < 0) 
    {
      $startX = 0;
    }
    
      if ($startY < 0) 
    {
      $startY = 0;
    }
    
    // create the working image
    if (function_exists('imagecreatetruecolor'))
    {
      $this->workingImage = imagecreatetruecolor($cropWidth, $cropHeight);
    }
    else
    {
      $this->workingImage = imagecreate($cropWidth, $cropHeight);
    }
    
    $this->preserveAlpha();
    
    imagecopyresampled
    (
      $this->workingImage,
      $this->oldImage,
      0,
      0,
      $startX,
      $startY,
      $cropWidth,
      $cropHeight,
      $cropWidth,
      $cropHeight
    );
    
    $this->oldImage           = $this->workingImage;
    $this->currentDimensions['width']   = $cropWidth;
    $this->currentDimensions['height']   = $cropHeight;
    
    return $this;
  }
  
  /**
   * Rotates image either 90 degrees clockwise or counter-clockwise
   * 
   * @param string $direction
   * @retunrn GdThumb
   */
  public function rotateImage ($direction = 'CW') 
  {
      if ($direction == 'CW') 
    {
        $this->rotateImageNDegrees(90);
      }
      else 
    {
      $this->rotateImageNDegrees(-90);
    }
    
    return $this;
    }
  
  /**
   * Rotates image specified number of degrees
   * 
   * @param int $degrees
   * @return GdThumb
   */
  public function rotateImageNDegrees ($degrees)
  {
    if (!is_numeric($degrees))
    {
      throw new InvalidArgumentException('$degrees must be numeric');
    }
    
    if (!function_exists('imagerotate'))
    {
      throw new RuntimeException('Your version of GD does not support image rotation.');
    }
    
    $this->workingImage = imagerotate($this->oldImage, $degrees, 0);
      
    $newWidth               = $this->currentDimensions['height'];
      $newHeight               = $this->currentDimensions['width'];
    $this->oldImage           = $this->workingImage;
    $this->currentDimensions['width']   = $newWidth;
    $this->currentDimensions['height']   = $newHeight;
    
    return $this;
  }
  
  /**
   * Shows an image
   * 
   * This function will show the current image by first sending the appropriate header
   * for the format, and then outputting the image data. If headers have already been sent, 
   * a runtime exception will be thrown 
   * 
   * @param bool $rawData Whether or not the raw image stream should be output
   * @return GdThumb
   */
  public function show ($rawData = false) 
  {
    if (headers_sent())
    {
      throw new RuntimeException('Cannot show image, headers have already been sent');
    }
    
    switch ($this->format) 
    {
      case 'GIF':
        if ($rawData === false) 
        { 
          header('Content-type: image/gif'); 
        }
        imagegif($this->oldImage);
        break;
      case 'JPG':
        if ($rawData === false) 
        { 
          header('Content-type: image/jpeg'); 
        }
        imagejpeg($this->oldImage, null, $this->options['jpegQuality']);
        break;
      case 'PNG':
      case 'STRING':
        if ($rawData === false) 
        { 
          header('Content-type: image/png'); 
        }
        imagepng($this->oldImage);
        break;
    }
    
    return $this;
  }
  
  /**
   * Returns the Working Image as a String
   *
   * This function is useful for getting the raw image data as a string for storage in
   * a database, or other similar things.
   *
   * @return string
   */
  public function getImageAsString ()
  {
    $data = null;
    ob_start();
    $this->show(true);
    $data = ob_get_contents();
    ob_end_clean();
    
    return $data;
  }
  
  /**
   * Saves an image
   * 
   * This function will make sure the target directory is writeable, and then save the image.
   * 
   * If the target directory is not writeable, the function will try to correct the permissions (if allowed, this
   * is set as an option ($this->options['correctPermissions']).  If the target cannot be made writeable, then a
   * RuntimeException is thrown.
   * 
   * TODO: Create additional paramter for color matte when saving images with alpha to non-alpha formats (i.e. PNG => JPG)
   * 
   * @param string $fileName The full path and filename of the image to save
   * @param string $format The format to save the image in (optional, must be one of [GIF,JPG,PNG]
   * @return GdThumb
   */
  public function save ($fileName, $format = null)
  {
    $validFormats = array('GIF', 'JPG', 'PNG');
    $format = ($format !== null) ? strtoupper($format) : $this->format;
    
    if (!in_array($format, $validFormats))
    {
      throw new InvalidArgumentException ('Invalid format type specified in save function: ' . $format);
    }
    
    // make sure the directory is writeable
    if (!is_writeable(dirname($fileName)))
    {
      // try to correct the permissions
      if ($this->options['correctPermissions'] === true)
      {
        @chmod(dirname($fileName), 0777);
        
        // throw an exception if not writeable
        if (!is_writeable(dirname($fileName)))
        {
          throw new RuntimeException ('File is not writeable, and could not correct permissions: ' . $fileName);
        }
      }
      // throw an exception if not writeable
      else
      {
        throw new RuntimeException ('File not writeable: ' . $fileName);
      }
    }
    
    switch ($format) 
    {
      case 'GIF':
        imagegif($this->oldImage, $fileName);
        break;
      case 'JPG':
        imagejpeg($this->oldImage, $fileName, $this->options['jpegQuality']);
        break;
      case 'PNG':
        imagepng($this->oldImage, $fileName);
        break;
    }
    
    return $this;
  }
  
  #################################
  # ----- GETTERS / SETTERS ----- #
  #################################
  
  /**
   * Sets $this->options to $options
   * 
   * @param array $options
   */
  public function setOptions ($options = array())
  {
    // make sure we've got an array for $this->options (could be null)
    if (!is_array($this->options))
    {
      $this->options = array();
    }
    
    // make sure we've gotten a proper argument
    if (!is_array($options))
    {
      throw new InvalidArgumentException ('setOptions requires an array');
    }
    
    // we've yet to init the default options, so create them here
    if (sizeof($this->options) == 0)
    {
      $defaultOptions = array 
      (
        'resizeUp'        => false,
        'jpegQuality'      => 100,
        'correctPermissions'  => false,
        'preserveAlpha'      => true,
        'alphaMaskColor'    => array (255, 255, 255),
        'preserveTransparency'  => true,
        'transparencyMaskColor'  => array (0, 0, 0)
      );
    }
    // otherwise, let's use what we've got already
    else
    {
      $defaultOptions = $this->options;
    }
    
    $this->options = array_merge($defaultOptions, $options);
  }
  
  /**
   * Returns $currentDimensions.
   *
   * @see GdThumb::$currentDimensions
   */
  public function getCurrentDimensions ()
  {
    return $this->currentDimensions;
  }
  
  /**
   * Sets $currentDimensions.
   *
   * @param object $currentDimensions
   * @see GdThumb::$currentDimensions
   */
  public function setCurrentDimensions ($currentDimensions)
  {
    $this->currentDimensions = $currentDimensions;
  }
  
  /**
   * Returns $maxHeight.
   *
   * @see GdThumb::$maxHeight
   */
  public function getMaxHeight ()
  {
    return $this->maxHeight;
  }
  
  /**
   * Sets $maxHeight.
   *
   * @param object $maxHeight
   * @see GdThumb::$maxHeight
   */
  public function setMaxHeight ($maxHeight)
  {
    $this->maxHeight = $maxHeight;
  }
  
  /**
   * Returns $maxWidth.
   *
   * @see GdThumb::$maxWidth
   */
  public function getMaxWidth ()
  {
    return $this->maxWidth;
  }
  
  /**
   * Sets $maxWidth.
   *
   * @param object $maxWidth
   * @see GdThumb::$maxWidth
   */
  public function setMaxWidth ($maxWidth)
  {
    $this->maxWidth = $maxWidth;
  }
  
  /**
   * Returns $newDimensions.
   *
   * @see GdThumb::$newDimensions
   */
  public function getNewDimensions ()
  {
    return $this->newDimensions;
  }
  
  /**
   * Sets $newDimensions.
   *
   * @param object $newDimensions
   * @see GdThumb::$newDimensions
   */
  public function setNewDimensions ($newDimensions)
  {
    $this->newDimensions = $newDimensions;
  }
  
  /**
   * Returns $options.
   *
   * @see GdThumb::$options
   */
  public function getOptions ()
  {
    return $this->options;
  }
  
  /**
   * Returns $percent.
   *
   * @see GdThumb::$percent
   */
  public function getPercent ()
  {
    return $this->percent;
  }
  
  /**
   * Sets $percent.
   *
   * @param object $percent
   * @see GdThumb::$percent
   */
  public function setPercent ($percent)
  {
    $this->percent = $percent;
  } 
  
  /**
   * Returns $oldImage.
   *
   * @see GdThumb::$oldImage
   */
  public function getOldImage ()
  {
    return $this->oldImage;
  }
  
  /**
   * Sets $oldImage.
   *
   * @param object $oldImage
   * @see GdThumb::$oldImage
   */
  public function setOldImage ($oldImage)
  {
    $this->oldImage = $oldImage;
  }
  
  /**
   * Returns $workingImage.
   *
   * @see GdThumb::$workingImage
   */
  public function getWorkingImage ()
  {
    return $this->workingImage;
  }
  
  /**
   * Sets $workingImage.
   *
   * @param object $workingImage
   * @see GdThumb::$workingImage
   */
  public function setWorkingImage ($workingImage)
  {
    $this->workingImage = $workingImage;
  } 
  
  
  #################################
  # ----- UTILITY FUNCTIONS ----- #
  #################################
  
  /**
   * Calculates a new width and height for the image based on $this->maxWidth and the provided dimensions
   * 
   * @return array 
   * @param int $width
   * @param int $height
   */
  protected function calcWidth ($width, $height)
  {
    $newWidthPercentage  = (100 * $this->maxWidth) / $width;
    $newHeight      = ($height * $newWidthPercentage) / 100;
    
    return array
    (
      'newWidth'  => intval($this->maxWidth),
      'newHeight'  => intval($newHeight)
    );
  }
  
  /**
   * Calculates a new width and height for the image based on $this->maxWidth and the provided dimensions
   * 
   * @return array 
   * @param int $width
   * @param int $height
   */
  protected function calcHeight ($width, $height)
  {
    $newHeightPercentage  = (100 * $this->maxHeight) / $height;
    $newWidth         = ($width * $newHeightPercentage) / 100;
    
    return array
    (
      'newWidth'  => ceil($newWidth),
      'newHeight'  => ceil($this->maxHeight)
    );
  }
  
  /**
   * Calculates a new width and height for the image based on $this->percent and the provided dimensions
   * 
   * @return array 
   * @param int $width
   * @param int $height
   */
  protected function calcPercent ($width, $height)
  {
    $newWidth  = ($width * $this->percent) / 100;
    $newHeight  = ($height * $this->percent) / 100;
    
    return array 
    (
      'newWidth'  => ceil($newWidth),
      'newHeight'  => ceil($newHeight)
    );
  }
  
  /**
   * Calculates the new image dimensions
   * 
   * These calculations are based on both the provided dimensions and $this->maxWidth and $this->maxHeight
   * 
   * @param int $width
   * @param int $height
   */
  protected function calcImageSize ($width, $height)
  {
    $newSize = array
    (
      'newWidth'  => $width,
      'newHeight'  => $height
    );
    
    if ($this->maxWidth > 0)
    {
      $newSize = $this->calcWidth($width, $height);
      
      if ($this->maxHeight > 0 && $newSize['newHeight'] > $this->maxHeight)
      {
        $newSize = $this->calcHeight($newSize['newWidth'], $newSize['newHeight']);
      }
    }
    
    if ($this->maxHeight > 0)
    {
      $newSize = $this->calcHeight($width, $height);
      
      if ($this->maxWidth > 0 && $newSize['newWidth'] > $this->maxWidth)
      {
        $newSize = $this->calcWidth($newSize['newWidth'], $newSize['newHeight']);
      }
    }
    
    $this->newDimensions = $newSize;
  }
  
  /**
   * Calculates new image dimensions, not allowing the width and height to be less than either the max width or height 
   * 
   * @param int $width
   * @param int $height
   */
  protected function calcImageSizeStrict ($width, $height)
  {
    // first, we need to determine what the longest resize dimension is..
    if ($this->maxWidth >= $this->maxHeight)
    {
      // and determine the longest original dimension
      if ($width > $height)
      {
        $newDimensions = $this->calcHeight($width, $height);
        
        if ($newDimensions['newWidth'] < $this->maxWidth)
        {
          $newDimensions = $this->calcWidth($width, $height);
        }
      }
      elseif ($height >= $width)
      {
        $newDimensions = $this->calcWidth($width, $height);
        
        if ($newDimensions['newHeight'] < $this->maxHeight)
        {
          $newDimensions = $this->calcHeight($width, $height);
        }
      }
    }
    elseif ($this->maxHeight > $this->maxWidth)
    {
      if ($width >= $height)
      {
        $newDimensions = $this->calcWidth($width, $height);
        
        if ($newDimensions['newHeight'] < $this->maxHeight)
        {
          $newDimensions = $this->calcHeight($width, $height);
        }
      }
      elseif ($height > $width)
      {
        $newDimensions = $this->calcHeight($width, $height);
        
        if ($newDimensions['newWidth'] < $this->maxWidth)
        {
          $newDimensions = $this->calcWidth($width, $height);
        }
      }
    }
    
    $this->newDimensions = $newDimensions;
  }
  
  /**
   * Calculates new dimensions based on $this->percent and the provided dimensions
   * 
   * @param int $width
   * @param int $height
   */
  protected function calcImageSizePercent ($width, $height)
  {
    if ($this->percent > 0)
    {
      $this->newDimensions = $this->calcPercent($width, $height);
    }
  }
  
  /**
   * Determines the file format by mime-type
   * 
   * This function will throw exceptions for invalid images / mime-types
   * 
   */
  protected function determineFormat ()
  {
    if ($this->isDataStream === true)
    {
      $this->format = 'STRING';
      return;
    }
    
    $formatInfo = getimagesize($this->fileName);
    
    // non-image files will return false
    if ($formatInfo === false)
    {
      if ($this->remoteImage)
      {
        $this->triggerError('Could not determine format of remote image: ' . $this->fileName);
      }
      else
      {
        $this->triggerError('File is not a valid image: ' . $this->fileName);
      }
      
      // make sure we really stop execution
      return;
    }
    
    $mimeType = isset($formatInfo['mime']) ? $formatInfo['mime'] : null;
    
    switch ($mimeType)
    {
      case 'image/gif':
        $this->format = 'GIF';
        break;
      case 'image/jpeg':
        $this->format = 'JPG';
        break;
      case 'image/png':
        $this->format = 'PNG';
        break;
      default:
        $this->triggerError('Image format not supported: ' . $mimeType);
    }
  }
  
  /**
   * Makes sure the correct GD implementation exists for the file type
   * 
   */
  protected function verifyFormatCompatiblity ()
  {
    $isCompatible   = true;
    $gdInfo      = gd_info();
    
    switch ($this->format)
    {
      case 'GIF':
        $isCompatible = $gdInfo['GIF Create Support'];
        break;
      case 'JPG':
        $isCompatible = (isset($gdInfo['JPG Support']) || isset($gdInfo['JPEG Support'])) ? true : false;
        break;
      case 'PNG':
        $isCompatible = $gdInfo[$this->format . ' Support'];
        break;
      default:
        $isCompatible = false;
    }
    
    if (!$isCompatible)
    {
      // one last check for "JPEG" instead
      $isCompatible = $gdInfo['JPEG Support'];
      
      if (!$isCompatible)
      {
        $this->triggerError('Your GD installation does not support ' . $this->format . ' image types');
      }
    }
  }
  
  /**
   * Preserves the alpha or transparency for PNG and GIF files
   * 
   * Alpha / transparency will not be preserved if the appropriate options are set to false.
   * Also, the GIF transparency is pretty skunky (the results aren't awesome), but it works like a 
   * champ... that's the nature of GIFs tho, so no huge surprise.
   * 
   * This functionality was originally suggested by commenter Aimi (no links / site provided) - Thanks! :)
   *   
   */
  protected function preserveAlpha ()
  {
    if ($this->format == 'PNG' && $this->options['preserveAlpha'] === true)
    {
      imagealphablending($this->workingImage, false);
      
      $colorTransparent = imagecolorallocatealpha
      (
        $this->workingImage, 
        $this->options['alphaMaskColor'][0], 
        $this->options['alphaMaskColor'][1], 
        $this->options['alphaMaskColor'][2], 
        0
      );
      
      imagefill($this->workingImage, 0, 0, $colorTransparent);
      imagesavealpha($this->workingImage, true);
    }
    // preserve transparency in GIFs... this is usually pretty rough tho
    if ($this->format == 'GIF' && $this->options['preserveTransparency'] === true)
    {
      $colorTransparent = imagecolorallocate
      (
        $this->workingImage, 
        $this->options['transparencyMaskColor'][0], 
        $this->options['transparencyMaskColor'][1], 
        $this->options['transparencyMaskColor'][2] 
      );
      
      imagecolortransparent($this->workingImage, $colorTransparent);
      imagetruecolortopalette($this->workingImage, true, 256);
    }
  }
}
#3GdThumb->__construct(/home/cvkedu/public_html/beta/src/web/img/original/publication_preview_src/0/35.jpg, Array(), false)
/home/cvkedu/public_html/beta/src/app/modules/Image/PHPThumb/ThumbLib.inc.php (127)
<?php
/**
 * PhpThumb Library Definition File
 * 
 * This file contains the definitions for the PhpThumbFactory class.
 * It also includes the other required base class files.
 * 
 * If you've got some auto-loading magic going on elsewhere in your code, feel free to
 * remove the include_once statements at the beginning of this file... just make sure that
 * these files get included one way or another in your code.
 * 
 * PHP Version 5 with GD 2.0+
 * PhpThumb : PHP Thumb Library <http://phpthumb.gxdlabs.com>
 * Copyright (c) 2009, Ian Selby/Gen X Design
 * 
 * Author(s): Ian Selby <ian@gen-x-design.com>
 * 
 * Licensed under the MIT License
 * Redistributions of files must retain the above copyright notice.
 * 
 * @author Ian Selby <ian@gen-x-design.com>
 * @copyright Copyright (c) 2009 Gen X Design
 * @link http://phpthumb.gxdlabs.com
 * @license http://www.opensource.org/licenses/mit-license.php The MIT License
 * @version 3.0
 * @package PhpThumb
 * @filesource
 */
 
// define some useful constants
define('THUMBLIB_BASE_PATH', dirname(__FILE__));
define('THUMBLIB_PLUGIN_PATH', THUMBLIB_BASE_PATH . '/thumb_plugins/');
define('DEFAULT_THUMBLIB_IMPLEMENTATION', 'gd');
 
/**
 * Include the PhpThumb Class
 */
require_once THUMBLIB_BASE_PATH . '/PhpThumb.inc.php';
/**
 * Include the ThumbBase Class
 */
require_once THUMBLIB_BASE_PATH . '/ThumbBase.inc.php';
/**
 * Include the GdThumb Class
 */
require_once THUMBLIB_BASE_PATH . '/GdThumb.inc.php';
 
/**
 * PhpThumbFactory Object
 * 
 * This class is responsible for making sure everything is set up and initialized properly,
 * and returning the appropriate thumbnail class instance.  It is the only recommended way 
 * of using this library, and if you try and circumvent it, the sky will fall on your head :)
 * 
 * Basic use is easy enough.  First, make sure all the settings meet your needs and environment...
 * these are the static variables defined at the beginning of the class.
 * 
 * Once that's all set, usage is pretty easy.  You can simply do something like:
 * <code>$thumb = PhpThumbFactory::create('/path/to/file.png');</code>
 * 
 * Refer to the documentation for the create function for more information
 * 
 * @package PhpThumb
 * @subpackage Core
 */
class PhpThumbFactory
{
  /**
   * Which implemenation of the class should be used by default
   * 
   * Currently, valid options are:
   *  - imagick
   *  - gd
   *  
   * These are defined in the implementation map variable, inside the create function
   * 
   * @var string
   */
  public static $defaultImplemenation = DEFAULT_THUMBLIB_IMPLEMENTATION;
  /**
   * Where the plugins can be loaded from
   * 
   * Note, it's important that this path is properly defined.  It is very likely that you'll 
   * have to change this, as the assumption here is based on a relative path.
   * 
   * @var string
   */
  public static $pluginPath = THUMBLIB_PLUGIN_PATH;
  
  /**
   * Factory Function
   * 
   * This function returns the correct thumbnail object, augmented with any appropriate plugins.  
   * It does so by doing the following:
   *  - Getting an instance of PhpThumb
   *  - Loading plugins
   *  - Validating the default implemenation
   *  - Returning the desired default implementation if possible
   *  - Returning the GD implemenation if the default isn't available
   *  - Throwing an exception if no required libraries are present
   * 
   * @return GdThumb
   * @uses PhpThumb
   * @param string $filename The path and file to load [optional]
   */
  public static function create ($filename = null, $options = array(), $isDataStream = false)
  {
    // map our implementation to their class names
    $implementationMap = array
    (
      'imagick'  => 'ImagickThumb',
      'gd'     => 'GdThumb'
    );
    
    // grab an instance of PhpThumb
    $pt = PhpThumb::getInstance();
    // load the plugins
    $pt->loadPlugins(self::$pluginPath);
    
    $toReturn = null;
    $implementation = self::$defaultImplemenation;
    
    // attempt to load the default implementation
    if ($pt->isValidImplementation(self::$defaultImplemenation))
    {
      $imp = $implementationMap[self::$defaultImplemenation];
      $toReturn = new $imp($filename, $options, $isDataStream);
    }
    // load the gd implementation if default failed
    else if ($pt->isValidImplementation('gd'))
    {
      $imp = $implementationMap['gd'];
      $implementation = 'gd';
      $toReturn = new $imp($filename, $options, $isDataStream);
    }
    // throw an exception if we can't load
    else
    {
      throw new Exception('You must have either the GD or iMagick extension loaded to use this library');
    }
    
    $registry = $pt->getPluginRegistry($implementation);
    $toReturn->importPlugins($registry);
    return $toReturn;
  }
}
#4PhpThumbFactory::create(/home/cvkedu/public_html/beta/src/web/img/original/publication_preview_src/0/35.jpg)
/home/cvkedu/public_html/beta/src/app/modules/Image/Storage.php (315)
<?php
 
namespace Image;
 
use Phalcon\Mvc\User\Component;
 
define('IMG_ROOT_REL_PATH', 'img');
define('DIR_SEP', '/');
define('IMG_ROOT_PATH', ROOT . DIR_SEP);
define('IMG_STORAGE_SERVER', '');
define('IMG_EXTENSION', 'jpg');
define('NOIMAGE', '/static/images/noimage.jpg');
 
define('IMG_DEBUG_MODE', false);
 
class Storage extends Component
{
 
  private static $STRATEGIES = [
    'w', // Scales width
    'wh', // Scalable from a given width and height. The image is adjusted in this rectangle
    'a', // Center the image and crop for a given height and width so that it completely fills the space
  ];
  private $id = null;
  private $image_hash = null;
  private $type = 'publication';
  private $strategy = 'w';
  private $width = 100;
  private $height = null;
  private $container = false;
  private $hash = false;
  private $attributes = [];
  private $exists = true;
  private $widthHeight = true;
  private $stretch = true;
 
  public function __construct (array $params = [], array $attributes = [])
  {
    $this->setIdFromParams($params);
    $this->attributes = $attributes;
 
    $this->type = (isset($params['type'])) ? $params['type'] : 'publication';
    $this->strategy = (isset($params['strategy'])) ? $params['strategy'] : 'w';
    $this->container = (isset($params['container'])) ? $params['container'] : false;
    $this->image_hash = (isset($params['image_hash'])) ? $params['image_hash'] : null;
    $this->hash = (isset($params['hash'])) ? $params['hash'] : false;
 
    $this->setDimensionsAttributes($params);
  }
 
  private function setDimensionsAttributes (array $params = [])
  {
    $this->width = (isset($params['width'])) ? $params['width'] : 100;
    $this->height = (isset($params['height'])) ? $params['height'] : null;
 
    $this->widthHeight = (isset($params['widthHeight'])) ? $params['widthHeight'] : true;
    $this->widthHeight = (isset($params['widthHeight']) && MOBILE_DEVICE) ? false : true;
 
    $this->stretch = (isset($params['stretch'])) ? $params['stretch'] : null;
  }
 
  private function setIdFromParams ($params)
  {
    if (isset($params['id'])) {
      if (preg_match('/^\d+$/', $params['id'])) {
        $this->id = (int)$params['id'];
      } else {
        $this->id = $params['id'];
      }
    } else {
      if (IMG_DEBUG_MODE) {
        throw new \Exception("ID is not certain");
      }
    }
  }
 
  /**
   * HTML-tag images, ready for use
   * <img src="" alt="" />
   */
  public function imageHtml ()
  {
    // From the given parameters and attributes make up html-tag
    $attributes = $this->attributesForImageHtml();
 
    // Get the relative address of the scanned image file
    $src = $this->cachedRelPath();
 
    if ($this->exists) {
      if ($this->hash) {
        $src .= '?' . microtime();
      }
    } else {
      $src = NOIMAGE;
      $attributes['width'] = $this->width;
      $attributes['height'] = $this->height;
    }
 
    $attr_src = 'src="' . $this->config->base_path . $src . '"';
    $result = '<img ' . $attr_src . $this->attributesResultForImageHtml($attributes) . '/>';
 
    if ($this->container) {
      $result = '<div class="img-container" style="width:' . $this->width . 'px; height:' . $this->height . 'px">' . $result . '</div>';
    }
 
    return $result;
  }
 
  private function attributesForImageHtml ()
  {
    $attributes = $this->attributes;
    if ($this->widthHeight) {
      if ($this->stretch && in_array($this->strategy, ['wh', 'a'])) {
        $this->stretch = false;
      }
      if ($this->stretch) {
        if ($this->width) {
          $attributes['width'] = $this->width;
        }
        if ($this->height) {
          $attributes['height'] = $this->height;
        }
      } else {
        $widthHeight = $this->getImageWidthHeight();
        if ($widthHeight['width']) {
          $attributes['width'] = $widthHeight['width'];
        }
        if ($widthHeight['height']) {
          $attributes['height'] = $widthHeight['height'];
        }
      }
    }
    $attributes['alt'] = (isset($attributes['alt'])) ? htmlspecialchars($attributes['alt'], ENT_QUOTES) : '';
    return $attributes;
  }
 
  private function attributesResultForImageHtml ($attributes)
  {
    $attributesHtmlArray = [];
    foreach ($attributes as $el => $val) {
      $attributesHtmlArray[] = $el . '="' . $val . '"';
    }
    $attributesHtml = implode(' ', $attributesHtmlArray);
    $attributesHtmlResult = ($attributesHtml) ? ' ' . $attributesHtml : '';
 
    return $attributesHtmlResult;
  }
 
  /**
   * Relative address of the scanned image file
   * /img/preview/405102/405102_1_w_100.jpg
   */
  public function cachedRelPath ()
  {
    // We count on incoming parameters relative path to the encrypted file
    $cachedRelPath = $this->calculateCachedRelPath();
    // We combine the relative path to the root, we get the absolute path
    $cachedAbsPath = IMG_ROOT_PATH . $cachedRelPath;
    // Undefined. Please check the existence of such a file. If the file does not exist:
    if (!file_exists($cachedAbsPath)) {
      // Generate hash file on the given parameters
      $this->generateCachedImage();
    }
    return IMG_STORAGE_SERVER . $cachedRelPath;
 
  }
 
  public function cachedAbsPath ()
  {
    return IMG_ROOT_PATH . $this->cachedRelPath();
 
  }
 
  /**
   * Relative address of the original image file
   */
  public function originalRelPath ()
  {
    return IMG_STORAGE_SERVER . $this->calculateOriginalRelPath();
 
  }
 
  /**
   * Absolute address of the original image file
   */
  public function originalAbsPath ()
  {
    return $this->getOriginalAbsPath();
 
  }
 
  public function save ($file)
  {
    if (file_exists($file)) {
      return copy($file, $this->originalAbsPath());
    }
  }
 
  public function originalWidthHeight ()
  {
    $imageSize = getimagesize($this->originalAbsPath());
    if (!empty($imageSize)) {
      return [
        'width' => $imageSize[0],
        'height' => $imageSize[1]
      ];
    }
  }
 
  public function cachedFileSize ()
  {
    $path = $this->cachedAbsPath();
    if (file_exists($path)) {
      return filesize($path);
    }
  }
 
  public function isExists ()
  {
    if (file_exists($this->getOriginalAbsPath())) {
      return true;
    } else {
      return false;
    }
  }
 
  /**
   * We count on incoming parameters relative path to the encrypted file
   * /img/preview/405/405102_1_w_100.jpg
   */
  private function calculateCachedRelPath ()
  {
    $pathParts = [];
    $pathParts[] = IMG_ROOT_REL_PATH;
    $pathParts[] = 'cache';
    $pathParts[] = $this->type;
 
    if (is_int($this->id)) {
      $idPart = floor($this->id / 1000);
    } else {
      $idPart = $this->id;
    }
    $pathParts[] = $idPart;
 
    $fileParts = [];
    $fileParts[] = $this->id;
    if ($this->image_hash) {
      $fileParts[] = $this->image_hash;
    }
    if (in_array($this->strategy, self::$STRATEGIES)) {
      $fileParts[] = $this->strategy;
    } else {
      if (IMG_DEBUG_MODE) {
        throw new \Exception("'Strategy' parameter is incorrect");
      }
      return;
    }
    $fileParts[] = $this->width;
    if ($this->height) {
      $fileParts[] = $this->height;
    }
 
    // "img/preview/405"
    $path = implode(DIR_SEP, $pathParts);
    // "405102_1_w_100"
    $file = implode('_', $fileParts);
 
    return $path . DIR_SEP . $file . '.jpg';
 
  }
 
  /**
   * We count on incoming parameters relative path to the original file
   * /img/original/preview/405/405102_1.jpg
   */
  private function calculateOriginalRelPath ()
  {
    $pathParts = [];
    $pathParts[] = IMG_ROOT_REL_PATH;
    $pathParts[] = 'original';
    $pathParts[] = $this->type;
 
    if (is_int($this->id)) {
      $idPart = floor($this->id / 1000);
    } else {
      $idPart = $this->id;
    }
    $pathParts[] = $idPart;
 
    $fileParts = [];
    $fileParts[] = $this->id;
    if ($this->image_hash) {
      $fileParts[] = $this->image_hash;
    }
 
    // "img/original/preview/405"
    $path = implode(DIR_SEP, $pathParts);
    // "405102_1"
    $file = implode('_', $fileParts);
 
    return $path . DIR_SEP . $file . '.jpg';
 
  }
 
  /**
   * Generate a hash file on the given parameters
   */
  private function generateCachedImage ()
  {
    // The absolute path of the original image
    $originalAbsPath = IMG_ROOT_PATH . $this->calculateOriginalRelPath();
    $this->checkOriginalExists($originalAbsPath);
 
    require_once __DIR__ . '/PHPThumb/ThumbLib.inc.php';
    $image = \PhpThumbFactory::create($originalAbsPath);
    // Mobile give an image quality of 60%
    if (MOBILE_DEVICE) {
      $options = ['jpegQuality' => 100];
      $image->setOptions($options);
    }
    switch ($this->strategy) {
      case 'w':
        // Scales width
        $image->resize($this->width);
        break;
      case 'wh':
        // Scalable from a given width and height. The image is adjusted in this rectangle
        $image->resize($this->width, $this->height);
        break;
      case 'a':
        // Center the image and crop for a given height and width so that it completely fills the space
        $image->adaptiveResize($this->width, $this->height);
        break;
    }
 
    $this->saveImage($image, $originalAbsPath);
  }
 
  public function cropOriginal ($left, $top, $width, $height)
  {
    $originalAbsPath = IMG_ROOT_PATH . $this->calculateOriginalRelPath(); // Абсолютный путь оригинального изображения
    $this->checkOriginalExists($originalAbsPath);
 
    require_once __DIR__ . '/PHPThumb/ThumbLib.inc.php';
    $image = \PhpThumbFactory::create($originalAbsPath);
    $image->crop($left, $top, $width, $height);
 
    $this->saveImage($image, $originalAbsPath);
  }
 
  private function checkOriginalExists ($originalAbsPath)
  {
    if (!file_exists($originalAbsPath)) {
      if (IMG_DEBUG_MODE) {
        throw new \Exception("File {$originalAbsPath} does not exist");
      } else {
        $this->exists = false;
      }
      return;
    }
  }
 
  private function saveImage ($image, $originalAbsPath)
  {
    // If the original is not blocked, suspending. This is to prevent multiple-cache-file parallel inquiries
    if ($this->lockOriginal($originalAbsPath)) {
      // Save the cached image
      $image->save($this->getCachedAbsPath());
      // Unlock
      $this->unlockOriginal($originalAbsPath);
    } else {
      if (IMG_DEBUG_MODE) {
        throw new \Exception("File {$originalAbsPath} checking mechanism is blocked or does not exist _LOCK");
      } else {
        $this->exists = false;
      }
      return;
    }
  }
 
  /**
   * It deletes the original and cached images
   */
  public function remove ($removeAll = true)
  {
    $this->removeCached();
    $this->removeOriginal($removeAll);
  }
 
  /**
   * Deletes the original images
   */
  public function removeOriginal ($removeAll = true)
  {
    if (!$removeAll) {
      if (file_exists($this->originalAbsPath())) {
        unlink($this->originalAbsPath());
      }
      return;
    }
 
    $originalAbsPath = IMG_ROOT_PATH . $this->calculateOriginalRelPath();
    $originalAbsPathDir = implode(DIR_SEP, array_slice(explode(DIR_SEP, $originalAbsPath), 0, -1)); // Абсолютный путь директории
 
    if ($this->image_hash) {
      $search = $originalAbsPathDir . "/" . $this->id . "_*.jpg";
    } else {
      $search = $originalAbsPathDir . "/" . $this->id . ".jpg";
    }
    $files = glob($search);
    if (!empty($files)) {
      foreach ($files as $file) {
        if (is_file($file)) {
          unlink($file);
        }
      }
    }
  }
 
  /**
   * Deletes the cached image
   */
  public function removeCached ()
  {
    $cachedAbsPath = IMG_ROOT_PATH . $this->calculateCachedRelPath();
    $cachedAbsPathDir = implode(DIR_SEP, array_slice(explode(DIR_SEP, $cachedAbsPath), 0, -1)); // Абсолютный путь директории
 
    $search = $cachedAbsPathDir . "/" . $this->id . "_*.jpg";
    $files = glob($search);
    if (!empty($files)) {
      foreach ($files as $file) {
        if (is_file($file)) {
          unlink($file);
        }
      }
    }
  }
 
  /**
   * Dimensions cached image
   */
  public function getImageWidthHeight ()
  {
    $cachedAbsPath = IMG_ROOT_PATH . $this->calculateCachedRelPath();
    if (file_exists($cachedAbsPath)) {
      $imageSize = getimagesize($cachedAbsPath);
      if (!empty($imageSize)) {
        return [
          'width' => $imageSize[0],
          'height' => $imageSize[1]
        ];
      }
    } else {
      return [
        'width' => null,
        'height' => null
      ];
    }
  }
 
  /**
   * Check the lock on the original image. If not, then block the
   * @param string $originalAbsPath
   * @return boolean true|false
   */
  private function lockOriginal ($originalAbsPath)
  {
    $lockFileName = $this->getLockFileName($originalAbsPath);
    if (file_exists($lockFileName)) {
      return false;
    } else {
      $handle = fopen($lockFileName, 'w+');
      if (flock($handle, LOCK_EX)) {
        fwrite($handle, '1');
        flock($handle, LOCK_UN);
        fclose($handle);
        return true;
      } else {
        if ($handle) {
          fclose($handle);
        }
        return false;
      }
    }
  }
 
  /**
   * Unlock the original image
   * @param string $originalAbsPath
   */
  private function unlockOriginal ($originalAbsPath)
  {
    unlink($this->getLockFileName($originalAbsPath));
  }
 
  /**
   * Returns the file name for the block of the original image
   * @param string $originalAbsPath
   * @return string
   */
  private function getLockFileName ($originalAbsPath)
  {
    return preg_replace('/\.' . IMG_EXTENSION . '/i', '_lock.' . IMG_EXTENSION, $originalAbsPath);
  }
 
  /**
   * Returns the absolute path to the original image.
   * If you want to generate a directory tree to store the origin
   */
  private function getOriginalAbsPath ()
  {
    $originalAbsPath = IMG_ROOT_PATH . $this->calculateOriginalRelPath();
    // The absolute path of the directory
    $originalAbsPathDir = implode(DIR_SEP, array_slice(explode(DIR_SEP, $originalAbsPath), 0, -1));
 
    // If the directory is missing
    if (!is_dir($originalAbsPathDir)) {
      // Create a directory tree
      mkdir($originalAbsPathDir, 0777, true);
    }
 
    return $originalAbsPath;
  }
 
  /**
   * Returns the absolute path to the encrypted image.
   * If you want to generate a directory tree to store the cache files
   */
  private function getCachedAbsPath ()
  {
    $cachedAbsPath = IMG_ROOT_PATH . $this->calculateCachedRelPath();
    // The absolute path of the directory
    $cachedAbsPathDir = implode(DIR_SEP, array_slice(explode(DIR_SEP, $cachedAbsPath), 0, -1));
 
    // If the directory is missing
    if (!is_dir($cachedAbsPathDir)) {
      // Create a directory tree
      mkdir($cachedAbsPathDir, 0777, true);
    }
    return $cachedAbsPath;
 
  }
 
}
#5Image\Storage->generateCachedImage()
/home/cvkedu/public_html/beta/src/app/modules/Image/Storage.php (162)
<?php
 
namespace Image;
 
use Phalcon\Mvc\User\Component;
 
define('IMG_ROOT_REL_PATH', 'img');
define('DIR_SEP', '/');
define('IMG_ROOT_PATH', ROOT . DIR_SEP);
define('IMG_STORAGE_SERVER', '');
define('IMG_EXTENSION', 'jpg');
define('NOIMAGE', '/static/images/noimage.jpg');
 
define('IMG_DEBUG_MODE', false);
 
class Storage extends Component
{
 
  private static $STRATEGIES = [
    'w', // Scales width
    'wh', // Scalable from a given width and height. The image is adjusted in this rectangle
    'a', // Center the image and crop for a given height and width so that it completely fills the space
  ];
  private $id = null;
  private $image_hash = null;
  private $type = 'publication';
  private $strategy = 'w';
  private $width = 100;
  private $height = null;
  private $container = false;
  private $hash = false;
  private $attributes = [];
  private $exists = true;
  private $widthHeight = true;
  private $stretch = true;
 
  public function __construct (array $params = [], array $attributes = [])
  {
    $this->setIdFromParams($params);
    $this->attributes = $attributes;
 
    $this->type = (isset($params['type'])) ? $params['type'] : 'publication';
    $this->strategy = (isset($params['strategy'])) ? $params['strategy'] : 'w';
    $this->container = (isset($params['container'])) ? $params['container'] : false;
    $this->image_hash = (isset($params['image_hash'])) ? $params['image_hash'] : null;
    $this->hash = (isset($params['hash'])) ? $params['hash'] : false;
 
    $this->setDimensionsAttributes($params);
  }
 
  private function setDimensionsAttributes (array $params = [])
  {
    $this->width = (isset($params['width'])) ? $params['width'] : 100;
    $this->height = (isset($params['height'])) ? $params['height'] : null;
 
    $this->widthHeight = (isset($params['widthHeight'])) ? $params['widthHeight'] : true;
    $this->widthHeight = (isset($params['widthHeight']) && MOBILE_DEVICE) ? false : true;
 
    $this->stretch = (isset($params['stretch'])) ? $params['stretch'] : null;
  }
 
  private function setIdFromParams ($params)
  {
    if (isset($params['id'])) {
      if (preg_match('/^\d+$/', $params['id'])) {
        $this->id = (int)$params['id'];
      } else {
        $this->id = $params['id'];
      }
    } else {
      if (IMG_DEBUG_MODE) {
        throw new \Exception("ID is not certain");
      }
    }
  }
 
  /**
   * HTML-tag images, ready for use
   * <img src="" alt="" />
   */
  public function imageHtml ()
  {
    // From the given parameters and attributes make up html-tag
    $attributes = $this->attributesForImageHtml();
 
    // Get the relative address of the scanned image file
    $src = $this->cachedRelPath();
 
    if ($this->exists) {
      if ($this->hash) {
        $src .= '?' . microtime();
      }
    } else {
      $src = NOIMAGE;
      $attributes['width'] = $this->width;
      $attributes['height'] = $this->height;
    }
 
    $attr_src = 'src="' . $this->config->base_path . $src . '"';
    $result = '<img ' . $attr_src . $this->attributesResultForImageHtml($attributes) . '/>';
 
    if ($this->container) {
      $result = '<div class="img-container" style="width:' . $this->width . 'px; height:' . $this->height . 'px">' . $result . '</div>';
    }
 
    return $result;
  }
 
  private function attributesForImageHtml ()
  {
    $attributes = $this->attributes;
    if ($this->widthHeight) {
      if ($this->stretch && in_array($this->strategy, ['wh', 'a'])) {
        $this->stretch = false;
      }
      if ($this->stretch) {
        if ($this->width) {
          $attributes['width'] = $this->width;
        }
        if ($this->height) {
          $attributes['height'] = $this->height;
        }
      } else {
        $widthHeight = $this->getImageWidthHeight();
        if ($widthHeight['width']) {
          $attributes['width'] = $widthHeight['width'];
        }
        if ($widthHeight['height']) {
          $attributes['height'] = $widthHeight['height'];
        }
      }
    }
    $attributes['alt'] = (isset($attributes['alt'])) ? htmlspecialchars($attributes['alt'], ENT_QUOTES) : '';
    return $attributes;
  }
 
  private function attributesResultForImageHtml ($attributes)
  {
    $attributesHtmlArray = [];
    foreach ($attributes as $el => $val) {
      $attributesHtmlArray[] = $el . '="' . $val . '"';
    }
    $attributesHtml = implode(' ', $attributesHtmlArray);
    $attributesHtmlResult = ($attributesHtml) ? ' ' . $attributesHtml : '';
 
    return $attributesHtmlResult;
  }
 
  /**
   * Relative address of the scanned image file
   * /img/preview/405102/405102_1_w_100.jpg
   */
  public function cachedRelPath ()
  {
    // We count on incoming parameters relative path to the encrypted file
    $cachedRelPath = $this->calculateCachedRelPath();
    // We combine the relative path to the root, we get the absolute path
    $cachedAbsPath = IMG_ROOT_PATH . $cachedRelPath;
    // Undefined. Please check the existence of such a file. If the file does not exist:
    if (!file_exists($cachedAbsPath)) {
      // Generate hash file on the given parameters
      $this->generateCachedImage();
    }
    return IMG_STORAGE_SERVER . $cachedRelPath;
 
  }
 
  public function cachedAbsPath ()
  {
    return IMG_ROOT_PATH . $this->cachedRelPath();
 
  }
 
  /**
   * Relative address of the original image file
   */
  public function originalRelPath ()
  {
    return IMG_STORAGE_SERVER . $this->calculateOriginalRelPath();
 
  }
 
  /**
   * Absolute address of the original image file
   */
  public function originalAbsPath ()
  {
    return $this->getOriginalAbsPath();
 
  }
 
  public function save ($file)
  {
    if (file_exists($file)) {
      return copy($file, $this->originalAbsPath());
    }
  }
 
  public function originalWidthHeight ()
  {
    $imageSize = getimagesize($this->originalAbsPath());
    if (!empty($imageSize)) {
      return [
        'width' => $imageSize[0],
        'height' => $imageSize[1]
      ];
    }
  }
 
  public function cachedFileSize ()
  {
    $path = $this->cachedAbsPath();
    if (file_exists($path)) {
      return filesize($path);
    }
  }
 
  public function isExists ()
  {
    if (file_exists($this->getOriginalAbsPath())) {
      return true;
    } else {
      return false;
    }
  }
 
  /**
   * We count on incoming parameters relative path to the encrypted file
   * /img/preview/405/405102_1_w_100.jpg
   */
  private function calculateCachedRelPath ()
  {
    $pathParts = [];
    $pathParts[] = IMG_ROOT_REL_PATH;
    $pathParts[] = 'cache';
    $pathParts[] = $this->type;
 
    if (is_int($this->id)) {
      $idPart = floor($this->id / 1000);
    } else {
      $idPart = $this->id;
    }
    $pathParts[] = $idPart;
 
    $fileParts = [];
    $fileParts[] = $this->id;
    if ($this->image_hash) {
      $fileParts[] = $this->image_hash;
    }
    if (in_array($this->strategy, self::$STRATEGIES)) {
      $fileParts[] = $this->strategy;
    } else {
      if (IMG_DEBUG_MODE) {
        throw new \Exception("'Strategy' parameter is incorrect");
      }
      return;
    }
    $fileParts[] = $this->width;
    if ($this->height) {
      $fileParts[] = $this->height;
    }
 
    // "img/preview/405"
    $path = implode(DIR_SEP, $pathParts);
    // "405102_1_w_100"
    $file = implode('_', $fileParts);
 
    return $path . DIR_SEP . $file . '.jpg';
 
  }
 
  /**
   * We count on incoming parameters relative path to the original file
   * /img/original/preview/405/405102_1.jpg
   */
  private function calculateOriginalRelPath ()
  {
    $pathParts = [];
    $pathParts[] = IMG_ROOT_REL_PATH;
    $pathParts[] = 'original';
    $pathParts[] = $this->type;
 
    if (is_int($this->id)) {
      $idPart = floor($this->id / 1000);
    } else {
      $idPart = $this->id;
    }
    $pathParts[] = $idPart;
 
    $fileParts = [];
    $fileParts[] = $this->id;
    if ($this->image_hash) {
      $fileParts[] = $this->image_hash;
    }
 
    // "img/original/preview/405"
    $path = implode(DIR_SEP, $pathParts);
    // "405102_1"
    $file = implode('_', $fileParts);
 
    return $path . DIR_SEP . $file . '.jpg';
 
  }
 
  /**
   * Generate a hash file on the given parameters
   */
  private function generateCachedImage ()
  {
    // The absolute path of the original image
    $originalAbsPath = IMG_ROOT_PATH . $this->calculateOriginalRelPath();
    $this->checkOriginalExists($originalAbsPath);
 
    require_once __DIR__ . '/PHPThumb/ThumbLib.inc.php';
    $image = \PhpThumbFactory::create($originalAbsPath);
    // Mobile give an image quality of 60%
    if (MOBILE_DEVICE) {
      $options = ['jpegQuality' => 100];
      $image->setOptions($options);
    }
    switch ($this->strategy) {
      case 'w':
        // Scales width
        $image->resize($this->width);
        break;
      case 'wh':
        // Scalable from a given width and height. The image is adjusted in this rectangle
        $image->resize($this->width, $this->height);
        break;
      case 'a':
        // Center the image and crop for a given height and width so that it completely fills the space
        $image->adaptiveResize($this->width, $this->height);
        break;
    }
 
    $this->saveImage($image, $originalAbsPath);
  }
 
  public function cropOriginal ($left, $top, $width, $height)
  {
    $originalAbsPath = IMG_ROOT_PATH . $this->calculateOriginalRelPath(); // Абсолютный путь оригинального изображения
    $this->checkOriginalExists($originalAbsPath);
 
    require_once __DIR__ . '/PHPThumb/ThumbLib.inc.php';
    $image = \PhpThumbFactory::create($originalAbsPath);
    $image->crop($left, $top, $width, $height);
 
    $this->saveImage($image, $originalAbsPath);
  }
 
  private function checkOriginalExists ($originalAbsPath)
  {
    if (!file_exists($originalAbsPath)) {
      if (IMG_DEBUG_MODE) {
        throw new \Exception("File {$originalAbsPath} does not exist");
      } else {
        $this->exists = false;
      }
      return;
    }
  }
 
  private function saveImage ($image, $originalAbsPath)
  {
    // If the original is not blocked, suspending. This is to prevent multiple-cache-file parallel inquiries
    if ($this->lockOriginal($originalAbsPath)) {
      // Save the cached image
      $image->save($this->getCachedAbsPath());
      // Unlock
      $this->unlockOriginal($originalAbsPath);
    } else {
      if (IMG_DEBUG_MODE) {
        throw new \Exception("File {$originalAbsPath} checking mechanism is blocked or does not exist _LOCK");
      } else {
        $this->exists = false;
      }
      return;
    }
  }
 
  /**
   * It deletes the original and cached images
   */
  public function remove ($removeAll = true)
  {
    $this->removeCached();
    $this->removeOriginal($removeAll);
  }
 
  /**
   * Deletes the original images
   */
  public function removeOriginal ($removeAll = true)
  {
    if (!$removeAll) {
      if (file_exists($this->originalAbsPath())) {
        unlink($this->originalAbsPath());
      }
      return;
    }
 
    $originalAbsPath = IMG_ROOT_PATH . $this->calculateOriginalRelPath();
    $originalAbsPathDir = implode(DIR_SEP, array_slice(explode(DIR_SEP, $originalAbsPath), 0, -1)); // Абсолютный путь директории
 
    if ($this->image_hash) {
      $search = $originalAbsPathDir . "/" . $this->id . "_*.jpg";
    } else {
      $search = $originalAbsPathDir . "/" . $this->id . ".jpg";
    }
    $files = glob($search);
    if (!empty($files)) {
      foreach ($files as $file) {
        if (is_file($file)) {
          unlink($file);
        }
      }
    }
  }
 
  /**
   * Deletes the cached image
   */
  public function removeCached ()
  {
    $cachedAbsPath = IMG_ROOT_PATH . $this->calculateCachedRelPath();
    $cachedAbsPathDir = implode(DIR_SEP, array_slice(explode(DIR_SEP, $cachedAbsPath), 0, -1)); // Абсолютный путь директории
 
    $search = $cachedAbsPathDir . "/" . $this->id . "_*.jpg";
    $files = glob($search);
    if (!empty($files)) {
      foreach ($files as $file) {
        if (is_file($file)) {
          unlink($file);
        }
      }
    }
  }
 
  /**
   * Dimensions cached image
   */
  public function getImageWidthHeight ()
  {
    $cachedAbsPath = IMG_ROOT_PATH . $this->calculateCachedRelPath();
    if (file_exists($cachedAbsPath)) {
      $imageSize = getimagesize($cachedAbsPath);
      if (!empty($imageSize)) {
        return [
          'width' => $imageSize[0],
          'height' => $imageSize[1]
        ];
      }
    } else {
      return [
        'width' => null,
        'height' => null
      ];
    }
  }
 
  /**
   * Check the lock on the original image. If not, then block the
   * @param string $originalAbsPath
   * @return boolean true|false
   */
  private function lockOriginal ($originalAbsPath)
  {
    $lockFileName = $this->getLockFileName($originalAbsPath);
    if (file_exists($lockFileName)) {
      return false;
    } else {
      $handle = fopen($lockFileName, 'w+');
      if (flock($handle, LOCK_EX)) {
        fwrite($handle, '1');
        flock($handle, LOCK_UN);
        fclose($handle);
        return true;
      } else {
        if ($handle) {
          fclose($handle);
        }
        return false;
      }
    }
  }
 
  /**
   * Unlock the original image
   * @param string $originalAbsPath
   */
  private function unlockOriginal ($originalAbsPath)
  {
    unlink($this->getLockFileName($originalAbsPath));
  }
 
  /**
   * Returns the file name for the block of the original image
   * @param string $originalAbsPath
   * @return string
   */
  private function getLockFileName ($originalAbsPath)
  {
    return preg_replace('/\.' . IMG_EXTENSION . '/i', '_lock.' . IMG_EXTENSION, $originalAbsPath);
  }
 
  /**
   * Returns the absolute path to the original image.
   * If you want to generate a directory tree to store the origin
   */
  private function getOriginalAbsPath ()
  {
    $originalAbsPath = IMG_ROOT_PATH . $this->calculateOriginalRelPath();
    // The absolute path of the directory
    $originalAbsPathDir = implode(DIR_SEP, array_slice(explode(DIR_SEP, $originalAbsPath), 0, -1));
 
    // If the directory is missing
    if (!is_dir($originalAbsPathDir)) {
      // Create a directory tree
      mkdir($originalAbsPathDir, 0777, true);
    }
 
    return $originalAbsPath;
  }
 
  /**
   * Returns the absolute path to the encrypted image.
   * If you want to generate a directory tree to store the cache files
   */
  private function getCachedAbsPath ()
  {
    $cachedAbsPath = IMG_ROOT_PATH . $this->calculateCachedRelPath();
    // The absolute path of the directory
    $cachedAbsPathDir = implode(DIR_SEP, array_slice(explode(DIR_SEP, $cachedAbsPath), 0, -1));
 
    // If the directory is missing
    if (!is_dir($cachedAbsPathDir)) {
      // Create a directory tree
      mkdir($cachedAbsPathDir, 0777, true);
    }
    return $cachedAbsPath;
 
  }
 
}
#6Image\Storage->cachedRelPath()
/home/cvkedu/public_html/beta/src/data/cache/volt/%%home%%cvkedu%%public_html%%beta%%src%%app%%modules%%index%%views%%index%%index.volt.php (117)
<style>
 
  .skyblue {
    background-color: transparent;
  }
 
  .deepskyblue {
    background-color: transparent;
  }
 
  .darkerskyblue {
    background-color: transparent;
  }
 
  .carousel-indicators {
    bottom: 15px;
  }
 
  .carousel-control.right,
  .carousel-control.left {
    background-image: none;
  }
 
  .carousel .item {
    min-height: 670px;
    height: 100%;
    width: 100%;
    background-size: cover;
    background-position: center center;
  }
 
  .carousel-caption h3,
  .carousel .icon-container,
  .carousel-caption button {
  }
 
  .carousel-caption h3 {
    margin-bottom: 0px;
  }
 
  .carousel .icon-container {
    display: inline-block;
    font-size: 25px;
    line-height: 25px;
    padding: 1em;
    text-align: center;
    border-radius: 50%;
  }
 
  .carousel-caption button {
    border-color: transparent;
    margin-top: 1em;
  }
 
  /* Animation delays */
  .carousel-caption .slider-description:first-child {
    animation-delay: 1s;
  }
 
  .carousel-caption .slider-description:nth-child(2) {
    animation-delay: 2s;
  }
 
  .carousel-caption button {
    animation-delay: 3s;
  }
 
  h1 {
    text-align: center;
    margin-bottom: 30px;
    font-size: 30px;
    font-weight: bold;
  }
 
  .p {
    padding-top: 125px;
    text-align: center;
  }
 
  .p a {
    text-decoration: underline;
  }
 
  .right.carousel-control .next {
    position: absolute;
    top: 50%;
  }
 
  .left.carousel-control .prev {
    position: absolute;
    top: 50%;
  }
 
  .carousel-caption {
    text-shadow: none;
    padding-bottom: 0px;
    font-family: 'Baloo', cursive;
    bottom: 50px;
  }
 
 
</style>
<div class="home-template">
 
 
  <?php echo $this->helper->widget('Slider')->slider('banner-slider-homepage'); ?>
  <?php $image = $this->helper->image(array('id' => $why_love_cvk->getId(), 'type' => $why_love_cvk->getImgFolder('cover_photo'), 'width' => 334, 'height' => 334, 'strategy' => 'a', 'stretch' => 'false', 'widthHeight' => 'false', 'hash' => true), array('class' => 'img-responsive')); ?>
  <?php $data = array('image' => $why_love_cvk->getCoverPhoto(), 'text' => $why_love_cvk->getText(), 'learn_more_href' => $this->helper->staticWidget('why_love_cvk_learn_more_href')); ?>
  <?php echo $this->helper->modulePartial('index/_partials/why_love_cvk', array('data' => $data), 'index'); ?>
 
  <?php $dataLatestNews = array(); ?>
  <?php $eventList = array(); ?>
 
  <?php $v32877544711198167831iterator = $latestNews; $v32877544711198167831incr = 0; $v32877544711198167831loop = new stdClass(); $v32877544711198167831loop->length = count($v32877544711198167831iterator); $v32877544711198167831loop->index = 1; $v32877544711198167831loop->index0 = 1; $v32877544711198167831loop->revindex = $v32877544711198167831loop->length; $v32877544711198167831loop->revindex0 = $v32877544711198167831loop->length - 1; ?><?php foreach ($v32877544711198167831iterator as $news) { ?><?php $v32877544711198167831loop->first = ($v32877544711198167831incr == 0); $v32877544711198167831loop->index = $v32877544711198167831incr + 1; $v32877544711198167831loop->index0 = $v32877544711198167831incr; $v32877544711198167831loop->revindex = $v32877544711198167831loop->length - $v32877544711198167831incr; $v32877544711198167831loop->revindex0 = $v32877544711198167831loop->length - ($v32877544711198167831incr + 1); $v32877544711198167831loop->last = ($v32877544711198167831incr == ($v32877544711198167831loop->length - 1)); ?>
    <?php $index = $v32877544711198167831loop->index; ?>
    <?php $newsImage = $this->helper->image(array('id' => $news->getId(), 'type' => $news->getImgFolder('preview_src'), 'width' => 334, 'height' => 334, 'strategy' => 'a', 'stretch' => 'false', 'widthHeight' => 'false', 'hash' => true), array('class' => 'img-responsive')); ?>
    <?php $newsItem = array('event_name' => $news->getTitle(), 'event_image' => $newsImage->cachedRelPath(), 'event_description' => $news->getShortDescription(), 'event_date' => date($this->helper->getDateFormat(constant('LANG')), $news->getDate()), 'index' => $index, 'url' => $this->helper->langUrl(array('for' => 'publication', 'type' => $news->getTypeSlug(), 'slug' => $news->getSlug()))); ?>
 
    <?php $eventList[$news->getId()] = $newsItem; ?>
  <?php $v32877544711198167831incr++; } ?>
 
  <?php $dataLatestNews = array('event_list' => $eventList, 'underline' => array('position' => 'center', 'icon' => 'icon-star', 'color' => '#FFFFFF'), 'component_title' => array('position' => 'center', 'text_color' => '#FFFFFF', 'title' => $this->helper->translate('LIFE AT CVK')), 'view_more' => array('href' => $this->helper->staticWidget('life_at_cvk_view_more', array('lifetime' => 0)), 'label' => $this->helper->translate('learn more'))); ?>
 
  <?php echo $this->helper->modulePartial('index/_partials/life_at_cvk', array('data' => $dataLatestNews), 'index'); ?>
  <?php $eventImages = $eventGallery->sliderImages; ?><?php $this->_macros['getLastImageInGallery'] = function($__p = null) { if (isset($__p[0])) { $items = $__p[0]; } else { if (isset($__p["items"])) { $items = $__p["items"]; } else {  throw new \Phalcon\Mvc\View\Exception("Macro 'getLastImageInGallery' was called without parameter: items");  } }  ?>
    <?php $v32877544711198167831iterator = $items; $v32877544711198167831incr = 0; $v32877544711198167831loop = new stdClass(); $v32877544711198167831loop->length = count($v32877544711198167831iterator); $v32877544711198167831loop->index = 1; $v32877544711198167831loop->index0 = 1; $v32877544711198167831loop->revindex = $v32877544711198167831loop->length; $v32877544711198167831loop->revindex0 = $v32877544711198167831loop->length - 1; ?><?php foreach ($v32877544711198167831iterator as $item) { ?><?php $v32877544711198167831loop->first = ($v32877544711198167831incr == 0); $v32877544711198167831loop->index = $v32877544711198167831incr + 1; $v32877544711198167831loop->index0 = $v32877544711198167831incr; $v32877544711198167831loop->revindex = $v32877544711198167831loop->length - $v32877544711198167831incr; $v32877544711198167831loop->revindex0 = $v32877544711198167831loop->length - ($v32877544711198167831incr + 1); $v32877544711198167831loop->last = ($v32877544711198167831incr == ($v32877544711198167831loop->length - 1)); ?>
      <?php if ($v32877544711198167831loop->last) { ?>
        <?php $image = $this->helper->image(array('id' => $item->getId(), 'type' => 'slider', 'width' => 1440, 'height' => 700, 'strategy' => 'a', 'stretch' => 'false', 'widthHeight' => 'false', 'hash' => true), array('class' => 'img-responsive', 'alt' => $item->getCaption())); ?>
        <?php return $image->cachedRelPath(); ?>
      <?php } ?>
    <?php $v32877544711198167831incr++; } ?><?php }; $this->_macros['getLastImageInGallery'] = \Closure::bind($this->_macros['getLastImageInGallery'], $this); ?>
 
 
  <?php $dataGallery = array('galleries' => array(array('image' => $this->callMacro('getLastImageInGallery', array($eventGallery->sliderImages)), 'name' => $eventGallery->getTitle(), 'href' => $pageGalleryEvent->generateUrl()), array('image' => $this->callMacro('getLastImageInGallery', array($facilityGallery->sliderImages)), 'name' => $facilityGallery->getTitle(), 'href' => $pageGalleryFacility->generateUrl()), array('image' => $this->callMacro('getLastImageInGallery', array($motNgayCuaBeGallery->sliderImages)), 'name' => $motNgayCuaBeGallery->getTitle(), 'href' => $pageGalleryMotNgayCuaBe->generateUrl())), 'underline' => array('position' => 'center', 'icon' => 'icon-heart', 'color' => '#eb4141'), 'title_data' => array('title' => $this->helper->translate('Our gallery'), 'position' => 'center', 'text_color' => '#eb4141')); ?>
 
  <?php echo $this->helper->modulePartial('index/_partials/gallery', array('data' => $dataGallery), 'index'); ?>
 
  <?php $testimonialsArr = array(); ?>
  <?php $v32877544711198167831iterator = $testimonials; $v32877544711198167831incr = 0; $v32877544711198167831loop = new stdClass(); $v32877544711198167831loop->length = count($v32877544711198167831iterator); $v32877544711198167831loop->index = 1; $v32877544711198167831loop->index0 = 1; $v32877544711198167831loop->revindex = $v32877544711198167831loop->length; $v32877544711198167831loop->revindex0 = $v32877544711198167831loop->length - 1; ?><?php foreach ($v32877544711198167831iterator as $testimonial) { ?><?php $v32877544711198167831loop->first = ($v32877544711198167831incr == 0); $v32877544711198167831loop->index = $v32877544711198167831incr + 1; $v32877544711198167831loop->index0 = $v32877544711198167831incr; $v32877544711198167831loop->revindex = $v32877544711198167831loop->length - $v32877544711198167831incr; $v32877544711198167831loop->revindex0 = $v32877544711198167831loop->length - ($v32877544711198167831incr + 1); $v32877544711198167831loop->last = ($v32877544711198167831incr == ($v32877544711198167831loop->length - 1)); ?>
 
    <?php $authorImage = $this->helper->image(array('id' => $testimonial->getId(), 'type' => $testimonial->getImgFolder('photo'), 'width' => 334, 'height' => 334, 'strategy' => 'a', 'stretch' => 'false', 'widthHeight' => 'false', 'hash' => true), array('class' => 'img-responsive')); ?>
    <?php $item = array('author' => $testimonial->getName(), 'position' => $testimonial->getPosition(), 'text' => $testimonial->getDescription(), 'image' => '/' . $authorImage->cachedRelPath(), 'url' => $testimonial->getSlug()); ?>
    <?php $testimonialsArr[$testimonial->getId()] = $item; ?>
 
  <?php $v32877544711198167831incr++; } ?>
  <?php $dataTestimonials = array('testimonials' => $testimonialsArr, 'title_data' => array('title' => $this->helper->translate('Talk about us'), 'position' => 'center', 'text_color' => '#eb4141'), 'underline' => array('position' => 'center', 'icon' => 'icon-bubble', 'color' => '#eb4141')); ?>
  <?php echo $this->helper->modulePartial('index/_partials/talk_about_us', array('data' => $dataTestimonials), 'index'); ?>
</div>
<button type="button" data-url="<?php echo $this->helper->langUrl(array('for' => 'save-popup')); ?>" id="popup" style="display: none"></button>
 
<?php if ($popup) { ?>
  <?php if ($popup->type == 2) { ?>
    <div class="modal fade popupModalImage" id="popupModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel">
      <div class="modal-dialog" role="document">
        <div class="modal-content" style="border-radius: 5px;">
          <div class="modal-header">
            <button type="button" class="close" data-dismiss="modal" aria-label="Close">
              <i class="icon-close-md"></i>
            </button>
          </div>
          <div class="modal-body">
          </div>
        </div>
      </div>
    </div>
  <?php } else { ?>
    <div class="modal modal-fullscreen fade popupModalForm" id="popupModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel">
      <div class="modal-dialog" role="document">
        <div class="modal-content" style="border-radius: 5px;">
          <div class="modal-header">
            <button type="button" class="close" data-dismiss="modal" aria-label="Close">
              <i class="icon-close-md"></i>
            </button>
          </div>
          <div class="modal-body">
          </div>
        </div>
      </div>
    </div>
  <?php } ?>
  <script>
    $(document).ready(function () {
      $(".modal-transparent").on('show.bs.modal', function () {
        setTimeout(function () {
          $(".modal-backdrop").addClass("modal-backdrop-transparent");
        }, 0);
      });
      $(".modal-transparent").on('hidden.bs.modal', function () {
        $(".modal-backdrop").addClass("modal-backdrop-transparent");
      });
 
      $(".modal-fullscreen").on('show.bs.modal', function () {
        setTimeout(function () {
          $(".modal-backdrop").addClass("modal-backdrop-fullscreen");
        }, 0);
      });
      $(".modal-fullscreen").on('hidden.bs.modal', function () {
        $(".modal-backdrop").addClass("modal-backdrop-fullscreen");
      });
      $("#popup").click(function () {
        $.ajax({
          url: $(this).data("url"),
          success: function (res) {
            $("#popupModal .modal-body").html(res);
            $("#popupModal").modal("show");
            submitSubscribe();
            setTimeout(function () {
              $(".popup-content").height($(".popup-content .col-md-5").height());
            }, 200)
 
          }
        });
      });
      $("#popup").trigger("click");
 
 
      function submitSubscribe() {
        $(".popup-content form #submit").click(function () {
          var form = $(".popup-content form");
          $.ajax({
            url: form.attr("action"),
            method: "POST",
            data: form.serialize(),
            success: function (res) {
              if (typeof (res) == "object") {
                $("#popupModal").find(".popup-content").find("p").after("<p><?php echo $this->helper->translate('Your information has been sent to us successfully.'); ?></p>");
                setTimeout(function () {
                  $(".popup-content").height($(".popup-content .col-md-5").height());
                  $("#popupModal").modal("hide");
                }, 2000);
                return;
              }
              $("#popupModal").find(".modal-body").html(res);
              submitSubscribe();
            }
          });
          return false;
        });
      }
 
    })
  </script>
<?php } ?>
 
<script>
  $(document).ready(function () {
    window.sr = ScrollReveal();
    var owl = $('.owl-carousel');
    var owlNavigation = owl.next(".navigation");
    var nextSlideButton = $(".next", owlNavigation);
    var prevSlideButton = $(".prev", owlNavigation);
 
    prevSlideButton.click(function () {
      owl.trigger('prev.owl.carousel');
    });
 
    nextSlideButton.click(function () {
      owl.trigger('next.owl.carousel', [300]);
    });
 
    owl.owlCarousel({
      items: 1,
      loop: true,
      autoplay: true,
      stopOnHover: false,
      autoplayHoverPause: false,
      onChange: function (event) {
      }
    });
  })
</script>
#7Phalcon\Mvc\View\Engine\Volt->render(/home/cvkedu/public_html/beta/src/app/modules/Index/views/index/index.volt, Array(12), true)
#8Phalcon\Mvc\View->_engineRender(Array([.volt] => Object(Application\Mvc\View\Engine\Volt), [.phtml] => Object(Phalcon\Mvc\View\Engine\Php)), index/index, true, true, null)
#9Phalcon\Mvc\View->render(index, index, Array())
/home/cvkedu/public_html/beta/src/app/Bootstrap.php (386)
<?php
 
namespace YonaCMS;
 
/**
 * Bootstrap
 * @copyright Copyright (c) 2011 - 2014 Aleksandr Torosh (http://wezoom.com.ua)
 * @author Aleksandr Torosh <webtorua@gmail.com>
 */
class Bootstrap
{
 
  public function run ()
  {
    $di = new \Phalcon\DI\FactoryDefault();
 
    // Config
    require_once APPLICATION_PATH . '/modules/Cms/Config.php';
    $config = \Cms\Config::get();
    $di->set('config', $config);
 
    // Registry
    $registry = new \Phalcon\Registry();
    $di->set('registry', $registry);
 
    // Loader
    $loader = new \Phalcon\Loader();
    $loader->registerNamespaces($config->loader->namespaces->toArray());
    $loader->registerDirs([APPLICATION_PATH . "/plugins/"]);
    $loader->register();
    require_once APPLICATION_PATH . '/../vendor/autoload.php';
 
    // Database
    //print_r($config->database);die;
    $db = new \Phalcon\Db\Adapter\Pdo\Mysql([
      "host" => $config->database->host,
      "username" => $config->database->username,
      "password" => $config->database->password,
      "dbname" => $config->database->dbname,
      "charset" => $config->database->charset,
    ]);
    $di->set('db', $db);
 
    // View
    $this->initView($di);
 
    // URL
    $url = new \Phalcon\Mvc\Url();
    $url->setBasePath($config->base_path);
    $url->setBaseUri($config->base_path);
    $di->set('url', $url);
 
    // Cache
    $this->initCache($di);
 
    // CMS
    $cmsModel = new \Cms\Model\Configuration();
    $registry->cms = $cmsModel->getConfig(); // Отправляем в Registry
 
    // Application
    $application = new \Phalcon\Mvc\Application();
    $application->registerModules($config->modules->toArray());
 
    // Events Manager, Dispatcher
    $this->initEventManager($di);
 
    // Session
    $session = new \Phalcon\Session\Adapter\Files();
    $session->start();
    $di->set('session', $session);
 
    $acl = new \Application\Acl\DefaultAcl();
    $di->set('acl', $acl);
 
    // JS Assets
    $this->initAssetsManager($di);
 
    // Flash helper
    $flash = new \Phalcon\Flash\Session([
      'error' => 'alert alert-danger',
      'success' => 'alert alert-success',
      'notice' => 'alert alert-info',
      'warning' => 'alert alert-warning',
    ]);
    $di->set('flash', $flash);
 
    $di->set('helper', new \Application\Mvc\Helper());
 
 
    /**
     * Custom DI
     */
    $di->set('email', function () {
      return new \Application\Mvc\EmailHelper();
    });
 
    // Routing
    $this->initRouting($application, $di);
 
    $application->setDI($di);
 
    // Main dispatching process
    $this->dispatch($di);
 
  }
 
  private function initRouting ($application, $di)
  {
    $router = new \Application\Mvc\Router\DefaultRouter();
    $router->setDi($di);
    foreach ($application->getModules() as $module) {
      $routesClassName = str_replace('Module', 'Routes', $module['className']);
      if (class_exists($routesClassName)) {
        $routesClass = new $routesClassName();
        $router = $routesClass->init($router);
      }
      $initClassName = str_replace('Module', 'Init', $module['className']);
      if (class_exists($initClassName)) {
        new $initClassName();
      }
    }
    $di->set('router', $router);
  }
 
  private function initAssetsManager ($di)
  {
    $config = $di->get('config');
    $isProductionEnv = APPLICATION_ENV == "production";
    $locator = $isProductionEnv ? ROOT . '/' : '/';
    $jsMin = $isProductionEnv ? new \Phalcon\Assets\Filters\Jsmin() : new \Phalcon\Assets\Filters\None();
    $cssMin = $isProductionEnv ? new \Phalcon\Assets\Filters\Cssmin() : new \Phalcon\Assets\Filters\None();
 
    $assetsManager = new \Application\Assets\Manager();
    if ($isProductionEnv) {
      $js_collection = $assetsManager->collection('js')
        ->setLocal(true)
        ->addFilter($jsMin)
        ->setTargetPath(ROOT . '/assets/main.js')
        ->setTargetUri('assets/main.js')
        ->join($isProductionEnv);
    } else {
      $js_collection = $assetsManager->collection('js')->setLocal(true);
    }
    if ($config->assets->js) {
      foreach ($config->assets->js as $js) {
        $js_collection->addJs($locator . $js);
      }
    }
 
    if ($isProductionEnv) {
      $css_collection = $assetsManager->collection('css')
        ->setLocal(true)
        ->addFilter($cssMin)
        ->setTargetPath(ROOT . '/assets/main.min.css')
        ->setTargetUri('/assets/main.min.css')
        ->join($isProductionEnv);
    } else {
      $css_collection = $assetsManager->collection('css')->setLocal(true);
    }
    if ($config->assets->css) {
      foreach ($config->assets->css as $css) {
        $css_collection->addCss($locator . $css);
      }
    }
 
    // Admin JS Assets
    $assetsManager->collection('modules-admin-js')
      ->setLocal(true)
      ->addFilter(new \Phalcon\Assets\Filters\Jsmin())
      ->setTargetPath(ROOT . '/assets/modules-admin.js')
      ->setTargetUri('assets/modules-admin.js')
      ->join(true);
 
    // Admin LESS Assets
    $assetsManager->collection('modules-admin-less')
      ->setLocal(true)
      ->addFilter(new \Application\Assets\Filter\Less())
      ->setTargetPath(ROOT . '/assets/modules-admin.less')
      ->setTargetUri('assets/modules-admin.less')
      ->join(true)
      ->addCss(APPLICATION_PATH . '/modules/Admin/assets/admin.less');
 
    $di->set('assets', $assetsManager);
    $admin_js_collection = $assetsManager->collection('admin_js')->join($isProductionEnv);
    if ($config->assets->admin_js) {
      foreach ($config->assets->admin_js as $js) {
        $admin_js_collection->addJs('/' . $js);
      }
    }
 
    $admin_css_collection = $assetsManager->collection('admin_css')->setLocal(true);
    if ($config->assets->admin_css) {
      foreach ($config->assets->admin_css as $css) {
        $admin_css_collection->addCss('/' . $css);
      }
    }
  }
 
  private function initEventManager ($di)
  {
    $eventsManager = new \Phalcon\Events\Manager();
    $dispatcher = new \Phalcon\Mvc\Dispatcher();
 
    $eventsManager->attach("dispatch:beforeDispatchLoop", function ($event, $dispatcher) use ($di) {
      new \YonaCMS\Plugin\CheckPoint($di->get('request'));
      new \YonaCMS\Plugin\Localization($dispatcher);
      new \YonaCMS\Plugin\AdminLocalization($di->get('config'));
      new \YonaCMS\Plugin\Acl($di->get('acl'), $dispatcher, $di->get('view'));
      new \YonaCMS\Plugin\MobileDetect($di->get('session'), $di->get('view'), $di->get('request'));
    });
 
    $eventsManager->attach("dispatch:afterDispatchLoop", function ($event, $dispatcher) use ($di) {
      new \Seo\Plugin\SeoManager($dispatcher, $di->get('request'), $di->get('router'), $di->get('view'));
      new \YonaCMS\Plugin\Title($di);
    });
 
    // Profiler
    $registry = $di->get('registry');
    if ($registry->cms['PROFILER']) {
      $profiler = new \Phalcon\Db\Profiler();
      $di->set('profiler', $profiler);
 
      $eventsManager->attach('db', function ($event, $db) use ($profiler) {
        if ($event->getType() == 'beforeQuery') {
          $profiler->startProfile($db->getSQLStatement());
        }
        if ($event->getType() == 'afterQuery') {
          $profiler->stopProfile();
        }
      });
    }
 
    $db = $di->get('db');
    $db->setEventsManager($eventsManager);
 
    $dispatcher->setEventsManager($eventsManager);
    $di->set('dispatcher', $dispatcher);
  }
 
  private function initView ($di)
  {
    $view = new \Phalcon\Mvc\View();
 
    $theme = $di->get('config')['theme'];
    if ($theme) {
      $themePath = __DIR__ . '/themes/' . $di->get('config')['theme'] . '/';
      if (file_exists($themePath)) {
        define('MAIN_VIEW_PATH', '../../../themes/' . $theme . '/');
      }
    } else {
      define('MAIN_VIEW_PATH', '../../../views/');
    }
 
    $view->setMainView(MAIN_VIEW_PATH . 'main');
    $view->setLayoutsDir(MAIN_VIEW_PATH . '/layouts/');
    $view->setLayout('main');
    $view->setPartialsDir(MAIN_VIEW_PATH . '/partials/');
 
    // Volt
    $volt = new \Application\Mvc\View\Engine\Volt($view, $di);
    $volt->setOptions(['compiledPath' => APPLICATION_PATH . '/../data/cache/volt/']);
    $volt->initCompiler();
 
 
    $phtml = new \Phalcon\Mvc\View\Engine\Php($view, $di);
    $viewEngines = [
      ".volt" => $volt,
      ".phtml" => $phtml,
    ];
 
    $view->registerEngines($viewEngines);
 
    $ajax = $di->get('request')->getQuery('_ajax');
    if ($ajax) {
      $view->setRenderLevel(\Phalcon\Mvc\View::LEVEL_LAYOUT);
    }
 
    $di->set('view', $view);
 
    return $view;
  }
 
  private function initCache ($di)
  {
    $config = $di->get('config');
 
    $cacheFrontend = new \Phalcon\Cache\Frontend\Data([
      "lifetime" => 60,
      "prefix" => HOST_HASH,
    ]);
 
    $cache = null;
    switch ($config->cache) {
      case 'file':
        $cache = new \Phalcon\Cache\Backend\File($cacheFrontend, [
          "cacheDir" => APPLICATION_PATH . "/../data/cache/backend/"
        ]);
        break;
      case 'memcache':
        $cache = new \Phalcon\Cache\Backend\Memcache(
          $cacheFrontend, [
          "host" => $config->memcache->host,
          "port" => $config->memcache->port,
        ]);
        break;
    }
    $di->set('cache', $cache, true);
    $di->set('modelsCache', $cache, true);
 
    \Application\Widget\Proxy::$cache = $cache; // Modules Widget System
 
    $modelsMetadata = new \Phalcon\Mvc\Model\Metadata\Memory();
    $di->set('modelsMetadata', $modelsMetadata);
  }
 
  private function dispatch ($di)
  {
    $router = $di['router'];
 
    $router->handle();
 
    $view = $di['view'];
 
    $dispatcher = $di['dispatcher'];
 
    $response = $di['response'];
 
    $dispatcher->setModuleName($router->getModuleName());
    $dispatcher->setControllerName($router->getControllerName());
    $dispatcher->setActionName($router->getActionName());
    $dispatcher->setParams($router->getParams());
 
    $moduleName = \Application\Utils\ModuleName::camelize($router->getModuleName());
 
    $ModuleClassName = $moduleName . '\Module';
    if (class_exists($ModuleClassName)) {
      $module = new $ModuleClassName;
      $module->registerAutoloaders();
      $module->registerServices($di);
 
      $theme = $di->get('config')['theme'];
      if ($theme) {
        $themePath = '/themes/' . $di->get('config')['theme'] . '/' . $moduleName . '/';
        if (file_exists($themePath)) {
          $view->setViewsDir(__DIR__ . $themePath);
        }
      }
    }
 
    $view->start();
 
    $registry = $di['registry'];
    if ($registry->cms['DEBUG_MODE']) {
      $debug = new \Phalcon\Debug();
      $debug->listen();
 
      $dispatcher->dispatch();
    } else {
      try {
        $dispatcher->dispatch();
      } catch (\Phalcon\Exception $e) {
        // Errors catching
 
        $view->setViewsDir(__DIR__ . '/modules/Index/views/');
        $view->setPartialsDir('');
        $view->e = $e;
 
        if ($e instanceof \Phalcon\Mvc\Dispatcher\Exception) {
          $response->setHeader(404, 'Not Found');
          $view->partial('error/error404');
        } else {
          $response->setHeader(503, 'Service Unavailable');
          $view->partial('error/error503');
        }
        $response->sendHeaders();
        echo $response->getContent();
        return;
 
      }
    }
 
    $view->render(
      $dispatcher->getControllerName(),
      $dispatcher->getActionName(),
      $dispatcher->getParams()
    );
 
    $view->finish();
 
    $response = $di['response'];
 
    // AJAX
    $request = $di['request'];
    $_ajax = $request->getQuery('_ajax');
    if ($_ajax) {
      $contents = $view->getContent();
 
      $return = new \stdClass();
      $return->html = $contents;
      $return->title = $di->get('helper')->title()->get();
      $return->success = true;
 
      if ($view->bodyClass) {
        $return->bodyClass = $view->bodyClass;
      }
 
      $headers = $response->getHeaders()->toArray();
      if (isset($headers[404]) || isset($headers[503])) {
        $return->success = false;
      }
      $response->setContentType('application/json', 'UTF-8');
      $response->setContent(json_encode($return));
    } else {
      $response->setContent($view->getContent());
    }
 
    $response->sendHeaders();
 
    echo $response->getContent();
  }
 
}
#10YonaCMS\Bootstrap->dispatch(Object(Phalcon\Di\FactoryDefault))
/home/cvkedu/public_html/beta/src/app/Bootstrap.php (103)
<?php
 
namespace YonaCMS;
 
/**
 * Bootstrap
 * @copyright Copyright (c) 2011 - 2014 Aleksandr Torosh (http://wezoom.com.ua)
 * @author Aleksandr Torosh <webtorua@gmail.com>
 */
class Bootstrap
{
 
  public function run ()
  {
    $di = new \Phalcon\DI\FactoryDefault();
 
    // Config
    require_once APPLICATION_PATH . '/modules/Cms/Config.php';
    $config = \Cms\Config::get();
    $di->set('config', $config);
 
    // Registry
    $registry = new \Phalcon\Registry();
    $di->set('registry', $registry);
 
    // Loader
    $loader = new \Phalcon\Loader();
    $loader->registerNamespaces($config->loader->namespaces->toArray());
    $loader->registerDirs([APPLICATION_PATH . "/plugins/"]);
    $loader->register();
    require_once APPLICATION_PATH . '/../vendor/autoload.php';
 
    // Database
    //print_r($config->database);die;
    $db = new \Phalcon\Db\Adapter\Pdo\Mysql([
      "host" => $config->database->host,
      "username" => $config->database->username,
      "password" => $config->database->password,
      "dbname" => $config->database->dbname,
      "charset" => $config->database->charset,
    ]);
    $di->set('db', $db);
 
    // View
    $this->initView($di);
 
    // URL
    $url = new \Phalcon\Mvc\Url();
    $url->setBasePath($config->base_path);
    $url->setBaseUri($config->base_path);
    $di->set('url', $url);
 
    // Cache
    $this->initCache($di);
 
    // CMS
    $cmsModel = new \Cms\Model\Configuration();
    $registry->cms = $cmsModel->getConfig(); // Отправляем в Registry
 
    // Application
    $application = new \Phalcon\Mvc\Application();
    $application->registerModules($config->modules->toArray());
 
    // Events Manager, Dispatcher
    $this->initEventManager($di);
 
    // Session
    $session = new \Phalcon\Session\Adapter\Files();
    $session->start();
    $di->set('session', $session);
 
    $acl = new \Application\Acl\DefaultAcl();
    $di->set('acl', $acl);
 
    // JS Assets
    $this->initAssetsManager($di);
 
    // Flash helper
    $flash = new \Phalcon\Flash\Session([
      'error' => 'alert alert-danger',
      'success' => 'alert alert-success',
      'notice' => 'alert alert-info',
      'warning' => 'alert alert-warning',
    ]);
    $di->set('flash', $flash);
 
    $di->set('helper', new \Application\Mvc\Helper());
 
 
    /**
     * Custom DI
     */
    $di->set('email', function () {
      return new \Application\Mvc\EmailHelper();
    });
 
    // Routing
    $this->initRouting($application, $di);
 
    $application->setDI($di);
 
    // Main dispatching process
    $this->dispatch($di);
 
  }
 
  private function initRouting ($application, $di)
  {
    $router = new \Application\Mvc\Router\DefaultRouter();
    $router->setDi($di);
    foreach ($application->getModules() as $module) {
      $routesClassName = str_replace('Module', 'Routes', $module['className']);
      if (class_exists($routesClassName)) {
        $routesClass = new $routesClassName();
        $router = $routesClass->init($router);
      }
      $initClassName = str_replace('Module', 'Init', $module['className']);
      if (class_exists($initClassName)) {
        new $initClassName();
      }
    }
    $di->set('router', $router);
  }
 
  private function initAssetsManager ($di)
  {
    $config = $di->get('config');
    $isProductionEnv = APPLICATION_ENV == "production";
    $locator = $isProductionEnv ? ROOT . '/' : '/';
    $jsMin = $isProductionEnv ? new \Phalcon\Assets\Filters\Jsmin() : new \Phalcon\Assets\Filters\None();
    $cssMin = $isProductionEnv ? new \Phalcon\Assets\Filters\Cssmin() : new \Phalcon\Assets\Filters\None();
 
    $assetsManager = new \Application\Assets\Manager();
    if ($isProductionEnv) {
      $js_collection = $assetsManager->collection('js')
        ->setLocal(true)
        ->addFilter($jsMin)
        ->setTargetPath(ROOT . '/assets/main.js')
        ->setTargetUri('assets/main.js')
        ->join($isProductionEnv);
    } else {
      $js_collection = $assetsManager->collection('js')->setLocal(true);
    }
    if ($config->assets->js) {
      foreach ($config->assets->js as $js) {
        $js_collection->addJs($locator . $js);
      }
    }
 
    if ($isProductionEnv) {
      $css_collection = $assetsManager->collection('css')
        ->setLocal(true)
        ->addFilter($cssMin)
        ->setTargetPath(ROOT . '/assets/main.min.css')
        ->setTargetUri('/assets/main.min.css')
        ->join($isProductionEnv);
    } else {
      $css_collection = $assetsManager->collection('css')->setLocal(true);
    }
    if ($config->assets->css) {
      foreach ($config->assets->css as $css) {
        $css_collection->addCss($locator . $css);
      }
    }
 
    // Admin JS Assets
    $assetsManager->collection('modules-admin-js')
      ->setLocal(true)
      ->addFilter(new \Phalcon\Assets\Filters\Jsmin())
      ->setTargetPath(ROOT . '/assets/modules-admin.js')
      ->setTargetUri('assets/modules-admin.js')
      ->join(true);
 
    // Admin LESS Assets
    $assetsManager->collection('modules-admin-less')
      ->setLocal(true)
      ->addFilter(new \Application\Assets\Filter\Less())
      ->setTargetPath(ROOT . '/assets/modules-admin.less')
      ->setTargetUri('assets/modules-admin.less')
      ->join(true)
      ->addCss(APPLICATION_PATH . '/modules/Admin/assets/admin.less');
 
    $di->set('assets', $assetsManager);
    $admin_js_collection = $assetsManager->collection('admin_js')->join($isProductionEnv);
    if ($config->assets->admin_js) {
      foreach ($config->assets->admin_js as $js) {
        $admin_js_collection->addJs('/' . $js);
      }
    }
 
    $admin_css_collection = $assetsManager->collection('admin_css')->setLocal(true);
    if ($config->assets->admin_css) {
      foreach ($config->assets->admin_css as $css) {
        $admin_css_collection->addCss('/' . $css);
      }
    }
  }
 
  private function initEventManager ($di)
  {
    $eventsManager = new \Phalcon\Events\Manager();
    $dispatcher = new \Phalcon\Mvc\Dispatcher();
 
    $eventsManager->attach("dispatch:beforeDispatchLoop", function ($event, $dispatcher) use ($di) {
      new \YonaCMS\Plugin\CheckPoint($di->get('request'));
      new \YonaCMS\Plugin\Localization($dispatcher);
      new \YonaCMS\Plugin\AdminLocalization($di->get('config'));
      new \YonaCMS\Plugin\Acl($di->get('acl'), $dispatcher, $di->get('view'));
      new \YonaCMS\Plugin\MobileDetect($di->get('session'), $di->get('view'), $di->get('request'));
    });
 
    $eventsManager->attach("dispatch:afterDispatchLoop", function ($event, $dispatcher) use ($di) {
      new \Seo\Plugin\SeoManager($dispatcher, $di->get('request'), $di->get('router'), $di->get('view'));
      new \YonaCMS\Plugin\Title($di);
    });
 
    // Profiler
    $registry = $di->get('registry');
    if ($registry->cms['PROFILER']) {
      $profiler = new \Phalcon\Db\Profiler();
      $di->set('profiler', $profiler);
 
      $eventsManager->attach('db', function ($event, $db) use ($profiler) {
        if ($event->getType() == 'beforeQuery') {
          $profiler->startProfile($db->getSQLStatement());
        }
        if ($event->getType() == 'afterQuery') {
          $profiler->stopProfile();
        }
      });
    }
 
    $db = $di->get('db');
    $db->setEventsManager($eventsManager);
 
    $dispatcher->setEventsManager($eventsManager);
    $di->set('dispatcher', $dispatcher);
  }
 
  private function initView ($di)
  {
    $view = new \Phalcon\Mvc\View();
 
    $theme = $di->get('config')['theme'];
    if ($theme) {
      $themePath = __DIR__ . '/themes/' . $di->get('config')['theme'] . '/';
      if (file_exists($themePath)) {
        define('MAIN_VIEW_PATH', '../../../themes/' . $theme . '/');
      }
    } else {
      define('MAIN_VIEW_PATH', '../../../views/');
    }
 
    $view->setMainView(MAIN_VIEW_PATH . 'main');
    $view->setLayoutsDir(MAIN_VIEW_PATH . '/layouts/');
    $view->setLayout('main');
    $view->setPartialsDir(MAIN_VIEW_PATH . '/partials/');
 
    // Volt
    $volt = new \Application\Mvc\View\Engine\Volt($view, $di);
    $volt->setOptions(['compiledPath' => APPLICATION_PATH . '/../data/cache/volt/']);
    $volt->initCompiler();
 
 
    $phtml = new \Phalcon\Mvc\View\Engine\Php($view, $di);
    $viewEngines = [
      ".volt" => $volt,
      ".phtml" => $phtml,
    ];
 
    $view->registerEngines($viewEngines);
 
    $ajax = $di->get('request')->getQuery('_ajax');
    if ($ajax) {
      $view->setRenderLevel(\Phalcon\Mvc\View::LEVEL_LAYOUT);
    }
 
    $di->set('view', $view);
 
    return $view;
  }
 
  private function initCache ($di)
  {
    $config = $di->get('config');
 
    $cacheFrontend = new \Phalcon\Cache\Frontend\Data([
      "lifetime" => 60,
      "prefix" => HOST_HASH,
    ]);
 
    $cache = null;
    switch ($config->cache) {
      case 'file':
        $cache = new \Phalcon\Cache\Backend\File($cacheFrontend, [
          "cacheDir" => APPLICATION_PATH . "/../data/cache/backend/"
        ]);
        break;
      case 'memcache':
        $cache = new \Phalcon\Cache\Backend\Memcache(
          $cacheFrontend, [
          "host" => $config->memcache->host,
          "port" => $config->memcache->port,
        ]);
        break;
    }
    $di->set('cache', $cache, true);
    $di->set('modelsCache', $cache, true);
 
    \Application\Widget\Proxy::$cache = $cache; // Modules Widget System
 
    $modelsMetadata = new \Phalcon\Mvc\Model\Metadata\Memory();
    $di->set('modelsMetadata', $modelsMetadata);
  }
 
  private function dispatch ($di)
  {
    $router = $di['router'];
 
    $router->handle();
 
    $view = $di['view'];
 
    $dispatcher = $di['dispatcher'];
 
    $response = $di['response'];
 
    $dispatcher->setModuleName($router->getModuleName());
    $dispatcher->setControllerName($router->getControllerName());
    $dispatcher->setActionName($router->getActionName());
    $dispatcher->setParams($router->getParams());
 
    $moduleName = \Application\Utils\ModuleName::camelize($router->getModuleName());
 
    $ModuleClassName = $moduleName . '\Module';
    if (class_exists($ModuleClassName)) {
      $module = new $ModuleClassName;
      $module->registerAutoloaders();
      $module->registerServices($di);
 
      $theme = $di->get('config')['theme'];
      if ($theme) {
        $themePath = '/themes/' . $di->get('config')['theme'] . '/' . $moduleName . '/';
        if (file_exists($themePath)) {
          $view->setViewsDir(__DIR__ . $themePath);
        }
      }
    }
 
    $view->start();
 
    $registry = $di['registry'];
    if ($registry->cms['DEBUG_MODE']) {
      $debug = new \Phalcon\Debug();
      $debug->listen();
 
      $dispatcher->dispatch();
    } else {
      try {
        $dispatcher->dispatch();
      } catch (\Phalcon\Exception $e) {
        // Errors catching
 
        $view->setViewsDir(__DIR__ . '/modules/Index/views/');
        $view->setPartialsDir('');
        $view->e = $e;
 
        if ($e instanceof \Phalcon\Mvc\Dispatcher\Exception) {
          $response->setHeader(404, 'Not Found');
          $view->partial('error/error404');
        } else {
          $response->setHeader(503, 'Service Unavailable');
          $view->partial('error/error503');
        }
        $response->sendHeaders();
        echo $response->getContent();
        return;
 
      }
    }
 
    $view->render(
      $dispatcher->getControllerName(),
      $dispatcher->getActionName(),
      $dispatcher->getParams()
    );
 
    $view->finish();
 
    $response = $di['response'];
 
    // AJAX
    $request = $di['request'];
    $_ajax = $request->getQuery('_ajax');
    if ($_ajax) {
      $contents = $view->getContent();
 
      $return = new \stdClass();
      $return->html = $contents;
      $return->title = $di->get('helper')->title()->get();
      $return->success = true;
 
      if ($view->bodyClass) {
        $return->bodyClass = $view->bodyClass;
      }
 
      $headers = $response->getHeaders()->toArray();
      if (isset($headers[404]) || isset($headers[503])) {
        $return->success = false;
      }
      $response->setContentType('application/json', 'UTF-8');
      $response->setContent(json_encode($return));
    } else {
      $response->setContent($view->getContent());
    }
 
    $response->sendHeaders();
 
    echo $response->getContent();
  }
 
}
#11YonaCMS\Bootstrap->run()
/home/cvkedu/public_html/beta/src/web/index.php (24)
<?php
chdir(dirname(__DIR__));
 
define('ROOT', __DIR__);
define('HOST_HASH', substr(md5($_SERVER['HTTP_HOST']), 0, 12));
 
defined('APPLICATION_ENV') || define('APPLICATION_ENV', (getenv('APPLICATION_ENV') ? getenv('APPLICATION_ENV') : 'production'));
//if (APPLICATION_ENV === 'development' || APPLICATION_ENV === 'staging') {
  //@TODO: fixed me by update docker to allow config php.ini
  error_reporting(E_ALL & ~E_NOTICE & ~E_STRICT);
 
  ini_set('display_errors', 1);
  ini_set('display_startup_errors', 1);
  ini_set('log_errors', 0);
//}
define('APPLICATION_PATH', __DIR__ . '/../app');
 
$debug = new \Phalcon\Debug();
$debug->listen();
 
 
require_once APPLICATION_PATH . '/Bootstrap.php';
$bootstrap = new YonaCMS\Bootstrap();
$bootstrap->run();
KeyValue
KeyValue
PHPRC/home/cvkedu/fcgi-bin/../etc/php5
SCRIPT_FILENAME/home/cvkedu/public_html/beta/src/web/index.php
PATH/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
PWD/home/cvkedu/fcgi-bin
SHLVL0
PHP_FCGI_MAX_REQUESTS99999
CONTENT_LENGTH0
HTTP_CONNECTIONclose
SCRIPT_NAME/index.php
REQUEST_URI/
QUERY_STRING
REQUEST_METHODGET
SERVER_PROTOCOLHTTP/1.0
GATEWAY_INTERFACECGI/1.1
REMOTE_PORT49474
SERVER_ADMIN[no address given]
CONTEXT_DOCUMENT_ROOT/home/cvkedu/public_html/beta/src/web
CONTEXT_PREFIX
REQUEST_SCHEMEhttp
DOCUMENT_ROOT/home/cvkedu/public_html/beta/src/web
REMOTE_ADDR54.80.227.189
SERVER_PORT80
SERVER_ADDR172.16.0.42
SERVER_NAMEcvk.edu.vn
SERVER_SOFTWAREApache/2.4.7
SERVER_SIGNATURE
HTTP_IF_MODIFIED_SINCESat, 21 Oct 2017 06:21:20 GMT
HTTP_ACCEPTtext/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
HTTP_USER_AGENTCCBot/2.0 (http://commoncrawl.org/faq/)
HTTP_ACCEPT_ENCODINGx-gzip, gzip, deflate
HTTP_HOSTcvk.edu.vn
APPLICATION_ENVproduction
SCRIPT_URIhttp://cvk.edu.vn/
SCRIPT_URL/
FCGI_ROLERESPONDER
PHP_SELF/index.php
REQUEST_TIME_FLOAT1511515525.8328
REQUEST_TIME1511515525
#Path
0/home/cvkedu/public_html/beta/src/web/index.php
1/home/cvkedu/public_html/beta/src/app/Bootstrap.php
2/home/cvkedu/public_html/beta/src/app/modules/Cms/Config.php
3/home/cvkedu/public_html/beta/src/app/config/environment/production.php
4/home/cvkedu/public_html/beta/src/app/config/global.php
5/home/cvkedu/public_html/beta/src/app/config/modules.php
6/home/cvkedu/public_html/beta/src/app/modules/Application/Loader/Modules.php
7/home/cvkedu/public_html/beta/src/vendor/autoload.php
8/home/cvkedu/public_html/beta/src/vendor/composer/autoload_real.php
9/home/cvkedu/public_html/beta/src/vendor/composer/ClassLoader.php
10/home/cvkedu/public_html/beta/src/vendor/composer/autoload_namespaces.php
11/home/cvkedu/public_html/beta/src/vendor/composer/autoload_psr4.php
12/home/cvkedu/public_html/beta/src/vendor/composer/autoload_classmap.php
13/home/cvkedu/public_html/beta/src/vendor/composer/autoload_files.php
14/home/cvkedu/public_html/beta/src/vendor/symfony/polyfill-mbstring/bootstrap.php
15/home/cvkedu/public_html/beta/src/vendor/donatj/phpuseragentparser/Source/UserAgentParser.php
16/home/cvkedu/public_html/beta/src/app/modules/Application/Mvc/View/Engine/Volt.php
17/home/cvkedu/public_html/beta/src/app/modules/Application/Widget/Proxy.php
18/home/cvkedu/public_html/beta/src/app/modules/Cms/Model/Configuration.php
19/home/cvkedu/public_html/beta/src/app/modules/Application/Acl/DefaultAcl.php
20/home/cvkedu/public_html/beta/src/app/config/acl.php
21/home/cvkedu/public_html/beta/src/app/modules/Application/Assets/Manager.php
22/home/cvkedu/public_html/beta/src/app/modules/Application/Assets/Filter/Less.php
23/home/cvkedu/public_html/beta/src/app/modules/Application/Mvc/Helper.php
24/home/cvkedu/public_html/beta/src/app/modules/Menu/Helper/Menu.php
25/home/cvkedu/public_html/beta/src/app/modules/Application/Mvc/Router/DefaultRouter.php
26/home/cvkedu/public_html/beta/src/app/modules/Index/Routes.php
27/home/cvkedu/public_html/beta/src/app/modules/Application/Mvc/Helper/CmsCache.php
28/home/cvkedu/public_html/beta/src/app/modules/Admin/Routes.php
29/home/cvkedu/public_html/beta/src/app/modules/Staff/Routes.php
30/home/cvkedu/public_html/beta/src/app/modules/Staff/Model/Type.php
31/home/cvkedu/public_html/beta/src/app/modules/Application/Mvc/Model/Model.php
32/home/cvkedu/public_html/beta/src/app/modules/Widget/Routes.php
33/home/cvkedu/public_html/beta/src/app/modules/Page/Routes.php
34/home/cvkedu/public_html/beta/src/app/modules/Page/Model/Page.php
35/home/cvkedu/public_html/beta/src/app/modules/Publication/Routes.php
36/home/cvkedu/public_html/beta/src/app/modules/Publication/Model/Type.php
37/home/cvkedu/public_html/beta/src/app/modules/Slider/Routes.php
38/home/cvkedu/public_html/beta/src/app/modules/Seo/Routes.php
39/home/cvkedu/public_html/beta/src/app/modules/Menu/Routes.php
40/home/cvkedu/public_html/beta/src/app/modules/Menu/Model/Type.php
41/home/cvkedu/public_html/beta/src/app/modules/Tree/Routes.php
42/home/cvkedu/public_html/beta/src/app/modules/Tree/Init.php
43/home/cvkedu/public_html/beta/src/app/modules/Tree/Mvc/Helper.php
44/home/cvkedu/public_html/beta/src/app/modules/Sitemap/Routes.php
45/home/cvkedu/public_html/beta/src/app/modules/Testimonial/Routes.php
46/home/cvkedu/public_html/beta/src/app/modules/Popup/Routes.php
47/home/cvkedu/public_html/beta/src/app/modules/Subscribe/Routes.php
48/home/cvkedu/public_html/beta/src/app/modules/Application/Utils/ModuleName.php
49/home/cvkedu/public_html/beta/src/app/modules/Index/Module.php
50/home/cvkedu/public_html/beta/src/app/plugins/CheckPoint.php
51/home/cvkedu/public_html/beta/src/app/plugins/Localization.php
52/home/cvkedu/public_html/beta/src/app/modules/Cms/Model/Translate.php
53/home/cvkedu/public_html/beta/src/app/plugins/AdminLocalization.php
54/home/cvkedu/public_html/beta/src/data/translations/admin/en.php
55/home/cvkedu/public_html/beta/src/app/plugins/Acl.php
56/home/cvkedu/public_html/beta/src/app/plugins/MobileDetect.php
57/home/cvkedu/public_html/beta/src/vendor/mobiledetect/mobiledetectlib/Mobile_Detect.php
58/home/cvkedu/public_html/beta/src/app/modules/Index/Controller/IndexController.php
59/home/cvkedu/public_html/beta/src/app/modules/Application/Mvc/Controller.php
60/home/cvkedu/public_html/beta/src/app/modules/Page/Model/Translate/PageTranslate.php
61/home/cvkedu/public_html/beta/src/app/modules/Application/Mvc/Model/Translate.php
62/home/cvkedu/public_html/beta/src/app/modules/Publication/Model/Publication.php
63/home/cvkedu/public_html/beta/src/app/modules/Testimonial/Model/Testimonial.php
64/home/cvkedu/public_html/beta/src/app/modules/Slider/Model/Slider.php
65/home/cvkedu/public_html/beta/src/app/modules/Slider/Model/Translate/SliderTranslate.php
66/home/cvkedu/public_html/beta/src/app/modules/Application/Mvc/Helper/Title.php
67/home/cvkedu/public_html/beta/src/app/modules/Cms/Model/Language.php
68/home/cvkedu/public_html/beta/src/app/modules/Application/Mvc/Helper/ActiveMenu.php
69/home/cvkedu/public_html/beta/src/app/modules/Application/Mvc/Helper/Meta.php
70/home/cvkedu/public_html/beta/src/app/modules/Image/Storage.php
71/home/cvkedu/public_html/beta/src/app/modules/Popup/Model/Popup.php
72/home/cvkedu/public_html/beta/src/app/modules/Seo/Plugin/SeoManager.php
73/home/cvkedu/public_html/beta/src/app/modules/Seo/Model/Manager.php
74/home/cvkedu/public_html/beta/src/app/plugins/Title.php
75/home/cvkedu/public_html/beta/src/data/cache/volt/%%home%%cvkedu%%public_html%%beta%%src%%app%%modules%%index%%views%%index%%index.volt.php
76/home/cvkedu/public_html/beta/src/app/modules/Slider/Widget/SliderWidget.php
77/home/cvkedu/public_html/beta/src/app/modules/Application/Widget/AbstractWidget.php
78/home/cvkedu/public_html/beta/src/data/cache/volt/%%home%%cvkedu%%public_html%%beta%%src%%app%%modules%%slider%%views%%widget%%banner_slider.volt.php
79/home/cvkedu/public_html/beta/src/app/modules/Slider/Model/SliderImage.php
80/home/cvkedu/public_html/beta/src/app/modules/Slider/Model/Translate/SliderImageTranslate.php
81/home/cvkedu/public_html/beta/src/app/modules/Application/Mvc/Helper/Announce.php
82/home/cvkedu/public_html/beta/src/app/modules/Widget/Model/Widget.php
83/home/cvkedu/public_html/beta/src/data/cache/volt/%%home%%cvkedu%%public_html%%beta%%src%%app%%modules%%index%%views%%index%%_partials%%why_love_cvk.volt.php
84/home/cvkedu/public_html/beta/src/data/cache/volt/%%home%%cvkedu%%public_html%%beta%%src%%app%%views%%partials%%patternlab%%organisms-why-love-cvk.volt.php
85/home/cvkedu/public_html/beta/src/data/cache/volt/%%home%%cvkedu%%public_html%%beta%%src%%app%%views%%partials%%patternlab%%atoms-home-component-title.volt.php
86/home/cvkedu/public_html/beta/src/data/cache/volt/%%home%%cvkedu%%public_html%%beta%%src%%app%%views%%partials%%patternlab%%molecules-primary-button.volt.php
87/home/cvkedu/public_html/beta/src/app/modules/Publication/Model/Translate/PublicationTranslate.php
88/home/cvkedu/public_html/beta/src/app/modules/Image/PHPThumb/ThumbLib.inc.php
89/home/cvkedu/public_html/beta/src/app/modules/Image/PHPThumb/PhpThumb.inc.php
90/home/cvkedu/public_html/beta/src/app/modules/Image/PHPThumb/ThumbBase.inc.php
91/home/cvkedu/public_html/beta/src/app/modules/Image/PHPThumb/GdThumb.inc.php
92/home/cvkedu/public_html/beta/src/app/modules/Image/PHPThumb/thumb_plugins/gd_reflection.inc.php
Memory
Usage3145728