// ------------------------------------------------------------------------
/**
* Get all data
*
* Internal method to get all the relevant data about a cache item
*
* @param string $id Cache ID
* @return mixed Data array on success or false on failure
*/
protected function _get($id)
{
if ( ! is_file($this->_cache_path.$id))
{
return false;
}
$data = unserialize(file_get_contents($this->_cache_path.$id));
if ($data['ttl'] > 0 && time() > $data['time'] + $data['ttl'])
{
file_exists($this->_cache_path.$id) && unlink($this->_cache_path.$id);
return false;
}
return $data;
}
}
Arguments
"Trying to access array offset on false"
// ------------------------------------------------------------------------
/**
* Get all data
*
* Internal method to get all the relevant data about a cache item
*
* @param string $id Cache ID
* @return mixed Data array on success or false on failure
*/
protected function _get($id)
{
if ( ! is_file($this->_cache_path.$id))
{
return false;
}
$data = unserialize(file_get_contents($this->_cache_path.$id));
if ($data['ttl'] > 0 && time() > $data['time'] + $data['ttl'])
{
file_exists($this->_cache_path.$id) && unlink($this->_cache_path.$id);
return false;
}
return $data;
}
}
*/
public function __construct()
{
$CI =& get_instance();
$CI->load->helper('file');
$path = $CI->config->item('cache_path');
$this->_cache_path = ($path === '') ? CACHE_PATH : $path;
}
// ------------------------------------------------------------------------
/**
* Fetch from cache
*
* @param string $id Cache ID
* @return mixed Data on success, false on failure
*/
public function get($id)
{
$data = $this->_get($id);
return is_array($data) ? $data['data'] : false;
}
// ------------------------------------------------------------------------
/**
* Save into cache
*
* @param string $id Cache ID
* @param mixed $data Data to store
* @param int $ttl Time to live in seconds
* @param bool $raw Whether to store the raw value (unused)
* @return bool true on success, false on failure
*/
public function save($id, $data, $ttl = 60, $raw = false)
{
$contents = [
'time' => time(),
'ttl' => $ttl,
'data' => $data
// --------------------------------------------------------------------------
/**
* Compiles a template and saves it in the cache
*/
protected function compile(string $template): string
{
$viewPath = $this->exists($template, true);
$cacheName = md5((string) $viewPath) . $this->cacheExtension;
$platesPath = $this->ci->config->item('plates_cache_path') . DIRECTORY_SEPARATOR;
$this->viewPath = $viewPath;
$this->cacheName = $cacheName;
$this->platesPath = $platesPath;
// Save cached files to cache/web/plates folder
$this->ci->config->set_item('cache_path', $platesPath);
// Verifies if a cached version of the file exists
if ($cachedVersion = $this->ci->cache->file->get($cacheName)) {
if (ENVIRONMENT == 'production') {
return $cachedVersion;
}
$cachedMeta = $this->ci->cache->file->get_metadata($cacheName);
if ($cachedMeta['mtime'] > filemtime($viewPath)) {
return $cachedVersion;
}
}
$content = file_get_contents($viewPath);
// Compile the content
foreach ($this->compilers as $compiler) {
$method = sprintf('compile_%s', $compiler);
$content = $this->$method($content);
}
// Store in the cache
return $this;
}
// --------------------------------------------------------------------------
/**
* Outputs template content
*
* @param array $data
*
* @return string
*/
public function view(string $template, $data = null, bool $return = false)
{
if (isset($data)) {
$this->set($data);
}
// Compile and execute the template
$content = $this->run($this->compile($template), $this->plateData);
if (config_item('compress_content')) {
$content = $this->minifyHtml($content);
}
if (!$return) {
$this->ci->output->append_output($content);
}
return $content;
}
/**
* Minify compiled html
*
* @return string
*/
protected function minifyHtml(string $content, bool $removeComments = true)
{
$commentCount = null;
* @param array $view_data
* @param bool $return
* @return object|string
*/
function view($view_path, $view_data = [], $return = false)
{
$view_path = dot2slash($view_path);
if (config('view')['view_engine'] === '') {
return app()->use->view($view_path, $view_data, $return);
}
// Get the evaluated view contents for the given plates view
if (config('view')['view_engine'] === 'plates') {
if ($view_data === null) {
return plates()->view($view_path, $return);
}
return plates()->set($view_data)->view($view_path, $return);
}
// Render view blade views
if (config('view')['view_engine'] === 'blade') {
if (!function_exists('blade')) {
throw new \Exception("Make sure Blade/View Package is installed");
}
return blade()->view($view_path, $view_data);
}
// Fall on plates to render view
return plates()->set($view_data)->view($view_path, $return);
}
}
if ( ! function_exists('blade'))
{
/**
* Load views in a layout format
*
* @param string $layout_path
* @param string $view_path
* @param array $view_data
* @return string
*/
function layout(
$layout_path,
$view_path = null,
$view_data = null
) {
if (! is_null($view_path) && isset($view_path) )
{
$view_data['content'] = $view_path;
}
return view($layout_path, $view_data);
}
}
<?php
use App\Enums\UserType;
use App\Middleware\WebMiddleware;
class App extends WebMiddleware
{
public function __construct()
{
parent::__construct();
}
public function index()
{
$this->setTitle('Home');
return layout('website.layouts.home', 'website.pages.index', $this->data);
}
public function why()
{
$this->setTitle('Why JuxBuy');
return layout('website.layouts.main', 'website.pages.why', $this->data);
}
public function pricing()
{
$this->setTitle('Pricing');
return layout('website.layouts.main', 'website.pages.pricing', $this->data);
}
public function learn()
{
$this->setTitle('Learn');
return layout('website.layouts.main', 'website.pages.learn', $this->data);
}
public function login()
{
$this->setTitle('Login');
* ------------------------------------------------------
*/
// Mark a start point so we can benchmark the controller
$BM->mark('controller_execution_time_( ' . $class . ' / ' . $method . ' )_start');
$CI = new $class();
/*
* ------------------------------------------------------
* Is there a "post_controller_constructor" hook?
* ------------------------------------------------------
*/
$EXT->call_hook('post_controller_constructor');
/*
* ------------------------------------------------------
* Call the requested method
* ------------------------------------------------------
*/
call_user_func_array([&$CI, $method], $params);
// Mark a benchmark end point
$BM->mark('controller_execution_time_( ' . $class . ' / ' . $method . ' )_end');
/*
* ------------------------------------------------------
* Is there a "post_controller" hook?
* ------------------------------------------------------
*/
$EXT->call_hook('post_controller');
/*
* ------------------------------------------------------
* Send the final rendered output to the browser
* ------------------------------------------------------
*/
if ($EXT->call_hook('display_override') === false) {
$OUT->_display();
}
error_reporting(E_ALL & ~E_NOTICE & ~E_DEPRECATED & ~E_STRICT & ~E_USER_NOTICE & ~E_USER_DEPRECATED);
} else {
error_reporting(E_ALL & ~E_NOTICE & ~E_STRICT & ~E_USER_NOTICE);
}
break;
default:
header('HTTP/1.1 503 Service Unavailable.', true, 503);
echo 'The application environment is not set correctly.';
exit(1); // EXIT_ERROR
}
/*
* --------------------------------------------------------------------
* LOAD CODEIGNITER BOOTSTRAP FILE
* --------------------------------------------------------------------
*
* And away we go...
*/
require_once CIPATH . 'core/CodeIgniter.php';
Arguments
"/home/juxbuyc7/web.juxbuy.com/vendor/sylynder/engine/CodeIgniter/Framework/core/CodeIgniter.php"