예제 #1
0
 /**
  * Constructor
  */
 public function __construct()
 {
     if (!extension_loaded('apc') && !ini_get('apc.enabled') && APP_ENV === 'development') {
         error_dump('APC Cache is disabled!');
         die;
     }
 }
예제 #2
0
 /**
  * Initialize Session Library
  */
 public static function init()
 {
     if (app_config('session', 'driver') === 'file') {
         if (self::$sessionDriver === null) {
             self::$sessionDriver = new SessionFile();
             self::$sessionDriver->init(app_config('session'));
         }
     } elseif (APP_ENV === 'development') {
         error_dump('Session Driver \'' . app_config('session', 'driver') . '\' not avaiable.');
         die;
     }
 }
예제 #3
0
 /**
  * Render View
  *
  * @param $view
  * @param null $data
  * @param bool $buffered
  * @return mixed|null|string
  */
 public static function render($view, $data = null, $buffered = false)
 {
     $isModular = false;
     $GLOBALS['modulePath'] = trim($GLOBALS['modulePath'], '\\');
     $inSelfModule = false;
     if ($GLOBALS['modulePath'] != '' && strpos($view, '/') === false) {
         $inSelfModule = true;
     }
     $module_view = '';
     $paths = explode('/', $view);
     if (strpos($view, '/') !== false) {
         $GLOBALS['modulePath'] = str_replace('//', '/', 'Modules/' . $paths[0] . '/');
         $module_view = trim(str_replace($paths[0] . '/', '', $view), '/');
     }
     $view = str_replace('.', '/', $view);
     if (file_exists(APP_PATH . 'Views/' . $view . '.blade.php') && $module_view === '' && !$inSelfModule) {
         $__buffer = self::parse(read_file(APP_PATH . 'Views/' . $view . '.blade.php'));
         $__buffer = self::run($__buffer, $data);
         if ($buffered) {
             return $__buffer;
         } else {
             echo $__buffer;
         }
     } elseif (file_exists(APP_PATH . 'Modules/' . $GLOBALS['modulePath'] . '/Views/' . $view . '.blade.php')) {
         $__buffer = self::parse(read_file(APP_PATH . 'Modules/' . $GLOBALS['modulePath'] . '/Views/' . $view . '.blade.php'));
         $__buffer = self::run($__buffer, $data);
         if ($buffered) {
             return $__buffer;
         } else {
             echo $__buffer;
         }
     } elseif (APP_ENV === 'development') {
         if ($isModular == true) {
             error_dump('Blade : File \'' . APP_PATH . 'Modules/' . $GLOBALS['modulePath'] . '/Views/' . $view . '.blade.php\' not found!');
         } else {
             error_dump('Blade : File \'' . APP_PATH . 'Views/' . $view . '.blade.php\' not found!');
         }
         die;
     }
     return null;
 }
예제 #4
0
 /**
  * Decrypt Data
  *
  * @param $ciphertext
  * @param string $key
  * @return null|string
  */
 public static function decode($ciphertext, $key = '')
 {
     $ciphertext = self::removeSalt($ciphertext);
     if (preg_match('/[^a-zA-Z0-9\\/\\+=]/', $ciphertext)) {
         return false;
     }
     $key = self::getKey($key);
     $ciphertext_dec = base64_decode($ciphertext);
     $iv_size = mcrypt_get_iv_size(self::$cipher, self::$mode);
     $iv_dec = substr($ciphertext_dec, 0, $iv_size);
     $ciphertext_dec = substr($ciphertext_dec, $iv_size);
     ob_start();
     echo mcrypt_decrypt(self::$cipher, $key, $ciphertext_dec, self::$mode, $iv_dec);
     $result = ob_get_contents();
     @ob_end_clean();
     if (strpos($result, '<b>Warning</b>:  mcrypt_decrypt():') === false) {
         return trim($result);
     } elseif (APP_ENV === 'development') {
         error_dump($result);
         die;
     }
     return null;
 }
예제 #5
0
 public function __construct($config)
 {
     if ($config['driver'] === 'mysqli') {
         $this->dbDriver = new MySQLiDriver($config);
         $this->dbDriver->connect();
     } elseif ($config['driver'] === 'sqlite') {
         $this->dbDriver = new SQLiteDriver($config);
         $this->dbDriver->connect();
     } elseif (APP_ENV === 'development') {
         error_dump('Database Driver \'' . $config['driver'] . '\' not avaiable.');
         die;
     }
 }
예제 #6
0
 /**
  * Call method of class
  */
 private static function callClassMethod()
 {
     if ($GLOBALS['modulePath'] != '') {
         $GLOBALS['modulePath'] = str_replace('/', '\\', str_replace('Modules/', '', $GLOBALS['modulePath']));
         $_className = 'App\\Modules\\' . $GLOBALS['modulePath'] . 'Controllers\\' . self::$className;
     } else {
         $_className = 'App\\Controllers\\' . self::$className;
     }
     $class = new $_className();
     if (method_exists(self::$className, self::$methodName)) {
         $methodName = self::$methodName;
         $class->{$methodName}();
     } else {
         $separatorFound = substr_count(self::$methodName, self::$methodSeparator);
         if ($separatorFound > 0) {
             for ($i = 0; $i < $separatorFound; $i++) {
                 $separator_pos = strpos(self::$methodName, self::$methodSeparator);
                 if ($separator_pos !== false) {
                     self::$methodName = substr(self::$methodName, 0, $separator_pos) . ucfirst(substr(self::$methodName, $separator_pos + 1, strlen(self::$methodName) - $separator_pos - 1));
                 }
             }
         }
         if (APP_ENV === 'development') {
             $methodName = self::$methodName;
             $class->{$methodName}();
         } elseif (method_exists(self::$className, self::$methodName)) {
             $methodName = self::$methodName;
             $class->{$methodName}();
         } elseif (file_exists(APP_PATH . 'views/404.blade.php')) {
             require_once FW_PATH . 'core/' . self::$page404 . '.php';
             $class = new self::$page404();
             $class->index();
         } else {
             error_dump('404 Page Not Found!');
             die;
         }
     }
 }
예제 #7
0
 /**
  * Resize Image Using GD2 Library
  *
  * @param $sourceImagePath
  * @param $sourceNewImagePath
  */
 private static function resizeGD2($sourceImagePath, $sourceNewImagePath)
 {
     $ext = trim(pathinfo($sourceImagePath, PATHINFO_EXTENSION));
     list($width, $height) = getimagesize($sourceImagePath);
     $source = null;
     if ($ext === 'png') {
         $source = imagecreatefrompng($sourceImagePath);
     } elseif ($ext === 'jpg' || $ext === 'jpeg') {
         $source = imagecreatefromjpeg($sourceImagePath);
     } elseif ($ext === 'gif') {
         $source = imagecreatefromgif($sourceImagePath);
     } elseif ($ext === 'bmp') {
         $source = imagecreatefromwbmp($sourceImagePath);
     } elseif (APP_ENV === 'development') {
         error_dump('Image format not supported!');
         die;
     }
     if ($source != null) {
         $is_size_maintained = false;
         if (self::$maintainSize) {
             if (self::$width > $width && self::$height > $height) {
                 self::$width = $width;
                 self::$height = $height;
                 $is_size_maintained = true;
             }
         }
         if (!$is_size_maintained) {
             if (self::$maintainRatio) {
                 if ($width > $height) {
                     self::$height = self::$width / ($width / $height);
                 } elseif ($width < $height) {
                     self::$width = self::$height / ($height / $width);
                 } else {
                     self::$width = self::$height;
                 }
             }
         }
         $thumb = imagecreatetruecolor(self::$width, self::$height);
         imagecopyresized($thumb, $source, 0, 0, 0, 0, self::$width, self::$height, $width, $height);
         if ($ext === 'png') {
             self::$newImage != '' ? imagepng($thumb, $sourceNewImagePath, self::$quality) : imagepng($thumb, $sourceImagePath, self::$quality);
         } elseif ($ext === 'jpg' || $ext === 'jpeg') {
             self::$newImage != '' ? imagejpeg($thumb, $sourceNewImagePath, self::$quality) : imagejpeg($thumb, $sourceImagePath, self::$quality);
         } elseif ($ext === 'gif') {
             self::$newImage != '' ? imagegif($thumb, $sourceNewImagePath, self::$quality) : imagegif($thumb, $sourceImagePath, self::$quality);
         } elseif ($ext === 'bmp') {
             self::$newImage != '' ? imagewbmp($thumb, $sourceNewImagePath, self::$quality) : imagewbmp($thumb, $sourceImagePath, self::$quality);
         }
     }
 }
예제 #8
0
 /**
  * Loading Language
  *
  * @param $language
  */
 public static function language($language, $name = null)
 {
     global $modulePath;
     $paths = explode('/', $language);
     if (strpos($language, '/') !== false) {
         $modulePath = str_replace('//', '/', 'Modules/' . $paths[0] . '/');
         $language = trim(str_replace($paths[0] . '/', '', $language), '/');
     }
     if ($name === null) {
         $name = $language;
     }
     if (file_exists(APP_PATH . 'Lang/' . $language . '/' . $name . '.php')) {
         require_once APP_PATH . 'Lang/' . $language . '/' . $name . '.php';
     } elseif (file_exists(FW_PATH . 'Lang/' . $language . '/' . $name . '.php')) {
         require_once FW_PATH . 'Lang/' . $language . '/' . $name . '.php';
     } elseif (file_exists(FW_PATH . $modulePath . 'Lang/' . $language . '/' . $name . '.php')) {
         require_once FW_PATH . $modulePath . 'Lang/' . $language . '/' . $name . '.php';
     } elseif (APP_ENV === 'development') {
         error_dump('File \'' . APP_PATH . 'Helpers/' . $language . '.php\' not found!');
         die;
     }
 }
예제 #9
0
 /**
  * Handle Autoload
  */
 private function handleAutoload()
 {
     $autoload = null;
     if (file_exists(APP_PATH . 'Config/autoload.php')) {
         $autoload = (require APP_PATH . 'Config/autoload.php');
     } elseif (APP_ENV === 'development') {
         error_dump('File \'' . APP_PATH . 'Config/autoload.php\' not found!');
         die;
     }
     $this->autoloadLanguage($autoload);
     $this->autoloadHelpers($autoload);
 }