first commit
This commit is contained in:
100
application/core/MY_Controller.php
Executable file
100
application/core/MY_Controller.php
Executable file
@@ -0,0 +1,100 @@
|
||||
<?php if (!defined('BASEPATH')) {
|
||||
exit('No direct script access allowed');
|
||||
}
|
||||
|
||||
use GO\Scheduler;
|
||||
|
||||
class MY_Controller extends CI_Controller
|
||||
{
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
$this->load->helper('general');
|
||||
$this->load->driver('cache', array('adapter' => 'file'));
|
||||
$this->setSite(0);
|
||||
date_default_timezone_set($this->config->item('time_reference'));
|
||||
define('SITE_NAME', $this->data['settings']->siteTitle);
|
||||
define('THEME', $this->data['settings']->siteTheme);
|
||||
define('THEME_FOLDER', BASE_URL . '/theme/' . THEME);
|
||||
if (defined('HOST_ONLY_MAINTENANCE') || $this->data['settings']->siteMaintenance) {
|
||||
$this->maintenance();
|
||||
} else {
|
||||
$this->schedule();
|
||||
if (isAdminSite()) {
|
||||
$this->load->model('post_model', 'post');
|
||||
$this->load->model('page_model', 'page');
|
||||
$this->load->model('category_model', 'category');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private function setSite($siteID)
|
||||
{
|
||||
r(
|
||||
function () use ($siteID) {
|
||||
$this->load->model('settings_model');
|
||||
$this->data = ['settings' => $this->settings_model->findBySiteID($siteID)];
|
||||
},
|
||||
['n' => 'settings', 't' => 60 * 60]
|
||||
);
|
||||
}
|
||||
|
||||
private function schedule()
|
||||
{
|
||||
$this->load->library('parser');
|
||||
$this->load->library('cacher');
|
||||
s(function () {
|
||||
$this->load->model('post_model');
|
||||
$posts = $this->post_model->getPostsScheduled();
|
||||
$publishing = [];
|
||||
$t = time();
|
||||
foreach ($posts as $p) {
|
||||
if (strtotime($p->run_at) < $t) {
|
||||
array_push($publishing, $p->postID);
|
||||
}
|
||||
}
|
||||
if (count($publishing)) {
|
||||
$this->post_model->publishPosts($publishing);
|
||||
}
|
||||
}, 60 * 10, 'publish');
|
||||
}
|
||||
|
||||
protected function isMobile()
|
||||
{
|
||||
return defined('MOBILE') || $this->ua->is_mobile();
|
||||
}
|
||||
|
||||
protected function error()
|
||||
{
|
||||
$this->data['page']['pageTitle'] = "Oops, Error";
|
||||
$this->data['page']['pageDescription'] = "Oops, Error";
|
||||
$this->data['page']['pageKeywords'] = "Oops, Error";
|
||||
$this->data['page']['pageID'] = "0";
|
||||
$this->data['page']['pageTemplate'] = "error";
|
||||
$this->data['header'] = $this->load->view('templates/header', $this->data, true);
|
||||
$this->data['footer'] = $this->load->view('templates/footer', '', true);
|
||||
$this->load->view('templates/' . $this->data['page']['pageTemplate'], $this->data);
|
||||
}
|
||||
|
||||
protected function maintenance()
|
||||
{
|
||||
// $this->data['page']['pageTitle'] = "Maintenance Mode";
|
||||
// $this->data['page']['pageDescription'] = "Maintenance Mode";
|
||||
// $this->data['page']['pageKeywords'] = "Maintenance Mode";
|
||||
// $this->data['page']['pageID'] = "0";
|
||||
// $this->data['page']['pageTemplate'] = "maintenance";
|
||||
// $this->data['header'] = $this->load->view('templates/header', $this->data, true);
|
||||
// $this->data['footer'] = $this->load->view('templates/footer', '', true);
|
||||
// $this->load->view('templates/' . $this->data['page']['pageTemplate'], $this->data);
|
||||
|
||||
echo $this->load->view('templates/others/underconstruct', null, true);
|
||||
exit(3);
|
||||
}
|
||||
|
||||
protected function response($body) {
|
||||
$this->output
|
||||
->set_status_header(200)
|
||||
->set_content_type('application/json')
|
||||
->set_output(json_encode($body));
|
||||
}
|
||||
}
|
||||
163
application/core/MY_Loader.php
Executable file
163
application/core/MY_Loader.php
Executable file
@@ -0,0 +1,163 @@
|
||||
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
|
||||
|
||||
// EXTENDS/MODIFIES LOADER CLASS TO BRANCH TO /CINCH/THEME DIRECTORY FOR PUBLIC FILES
|
||||
// SEE AROUND LINE 65
|
||||
|
||||
|
||||
class MY_Loader extends CI_Loader {
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* CUSTOMISED Loader function
|
||||
*
|
||||
* This function is used to load views and files.
|
||||
* Variables are prefixed with _ci_ to avoid symbol collision with
|
||||
* variables made available to view files
|
||||
*
|
||||
* @param array
|
||||
* @return void
|
||||
*/
|
||||
protected function _ci_load($_ci_data)
|
||||
{
|
||||
|
||||
// Set the default data variables
|
||||
foreach (array('_ci_view', '_ci_vars', '_ci_path', '_ci_return') as $_ci_val)
|
||||
{
|
||||
$$_ci_val = ( ! isset($_ci_data[$_ci_val])) ? FALSE : $_ci_data[$_ci_val];
|
||||
}
|
||||
|
||||
$file_exists = FALSE;
|
||||
|
||||
// Set the path to the requested file
|
||||
if ($_ci_path != '')
|
||||
{
|
||||
$_ci_x = explode('/', $_ci_path);
|
||||
$_ci_file = end($_ci_x);
|
||||
}
|
||||
else
|
||||
{
|
||||
$_ci_ext = pathinfo($_ci_view, PATHINFO_EXTENSION);
|
||||
$_ci_file = ($_ci_ext == '') ? $_ci_view.'.php' : $_ci_view;
|
||||
|
||||
|
||||
|
||||
foreach ($this->_ci_view_paths as $view_file => $cascade)
|
||||
{
|
||||
if (file_exists($view_file.$_ci_file))
|
||||
{
|
||||
$_ci_path = $view_file.$_ci_file;
|
||||
$file_exists = TRUE;
|
||||
break;
|
||||
}
|
||||
|
||||
if ( ! $cascade)
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if(!defined('HOOSK_ADMIN') || defined('HOOSK_ADMIN_PREVIEW')):
|
||||
$_ci_path = 'theme/'.THEME.'/'.$_ci_file;
|
||||
endif;
|
||||
##########################################################################################
|
||||
|
||||
if ( ! $file_exists && ! file_exists($_ci_path))
|
||||
{
|
||||
show_error('Unable to load the requested file: '.$_ci_file);
|
||||
}
|
||||
|
||||
|
||||
|
||||
// This allows anything loaded using $this->load (views, files, etc.)
|
||||
// to become accessible from within the Controller and Model functions.
|
||||
|
||||
$_ci_CI =& get_instance();
|
||||
foreach (get_object_vars($_ci_CI) as $_ci_key => $_ci_var)
|
||||
{
|
||||
if ( ! isset($this->$_ci_key))
|
||||
{
|
||||
$this->$_ci_key =& $_ci_CI->$_ci_key;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Extract and cache variables
|
||||
*
|
||||
* You can either set variables using the dedicated $this->load_vars()
|
||||
* function or via the second parameter of this function. We'll merge
|
||||
* the two types and cache them so that views that are embedded within
|
||||
* other views can have access to these variables.
|
||||
*/
|
||||
if (is_array($_ci_vars))
|
||||
{
|
||||
$this->_ci_cached_vars = array_merge($this->_ci_cached_vars, $_ci_vars);
|
||||
}
|
||||
extract($this->_ci_cached_vars);
|
||||
|
||||
/*
|
||||
* Buffer the output
|
||||
*
|
||||
* We buffer the output for two reasons:
|
||||
* 1. Speed. You get a significant speed boost.
|
||||
* 2. So that the final rendered template can be
|
||||
* post-processed by the output class. Why do we
|
||||
* need post processing? For one thing, in order to
|
||||
* show the elapsed page load time. Unless we
|
||||
* can intercept the content right before it's sent to
|
||||
* the browser and then stop the timer it won't be accurate.
|
||||
*/
|
||||
ob_start();
|
||||
|
||||
// If the PHP installation does not support short tags we'll
|
||||
// do a little string replacement, changing the short tags
|
||||
// to standard PHP echo statements.
|
||||
|
||||
|
||||
if ((bool) @ini_get('short_open_tag') === FALSE AND config_item('rewrite_short_tags') == TRUE)
|
||||
{
|
||||
echo eval('?>'.preg_replace("/;*\s*\?>/", "; ?>", str_replace('<?=', '<?php echo ', file_get_contents($_ci_path))));
|
||||
}
|
||||
else
|
||||
{
|
||||
include($_ci_path); // include() vs include_once() allows for multiple views with the same name
|
||||
}
|
||||
|
||||
log_message('debug', 'File loaded: '.$_ci_path);
|
||||
|
||||
// Return the file data if requested
|
||||
if ($_ci_return === TRUE)
|
||||
{
|
||||
$buffer = ob_get_contents();
|
||||
@ob_end_clean();
|
||||
return $buffer;
|
||||
}
|
||||
|
||||
/*
|
||||
* Flush the buffer... or buff the flusher?
|
||||
*
|
||||
* In order to permit views to be nested within
|
||||
* other views, we need to flush the content back out whenever
|
||||
* we are beyond the first level of output buffering so that
|
||||
* it can be seen and included properly by the first included
|
||||
* template and any subsequent ones. Oy!
|
||||
*
|
||||
*/
|
||||
if (ob_get_level() > $this->_ci_ob_level + 1)
|
||||
{
|
||||
ob_end_flush();
|
||||
}
|
||||
else
|
||||
{
|
||||
$_ci_CI->output->append_output(ob_get_contents());
|
||||
@ob_end_clean();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
16
application/core/MY_Model.php
Executable file
16
application/core/MY_Model.php
Executable file
@@ -0,0 +1,16 @@
|
||||
<?php if (!defined('BASEPATH')) {
|
||||
exit('No direct script access allowed');
|
||||
}
|
||||
|
||||
|
||||
class MY_Model extends CI_Model
|
||||
{
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
$this->load->database();
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
11
application/core/index.html
Executable file
11
application/core/index.html
Executable file
@@ -0,0 +1,11 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<title>403 Forbidden</title>
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<p>Directory access is forbidden.</p>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
Reference in New Issue
Block a user