Skip to content

Commit

Permalink
ADDED: Support for PHP 8.0, CodeIgniter 4 & MySQL 8.0.11
Browse files Browse the repository at this point in the history
  • Loading branch information
SagnikGanguly96 committed Nov 27, 2021
1 parent 851a99f commit c4ae428
Show file tree
Hide file tree
Showing 18 changed files with 393 additions and 384 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
/logs/
/release/
/info.php
/system/assets/captcha/images/
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ the power of two frameworks in one. Ceramic is released under its exclusive lice
### Core Requirements
| Technology | Version | Link |
|------------|----------------|------------------------------------------------------------------------|
| PHP | 8.0.0 - 8.1.0 | [www.php.net/downloads](https://www.php.net/downloads/) |
| PHP | 8.0.0 - 8.0.12 | [www.php.net/downloads](https://www.php.net/downloads/) |
| MySQL | 8.0.11+ | [downloads.mysql.com](https://downloads.mysql.com/archives/community/) |


Expand Down
13 changes: 6 additions & 7 deletions application/config/config.php
Original file line number Diff line number Diff line change
Expand Up @@ -261,12 +261,12 @@
| codes to set your own date formatting
|
*/
$config['log_date_format'] = 'Y-m-d H:i:s';
$config['default_controller'] = 'Home';
$config['project_name'] = 'Ceramic';
$config['project_version'] = '1.1.0';
$config['log_date_format'] = 'Y-m-d H:i:s';
$config['default_controller'] = 'Welcome';
$config['case_insensitive'] = true;
$config['globals'] = array(
//dirname(dirname(ROOT)) . DIRECTORY_SEPARATOR . "config" . DIRECTORY_SEPARATOR . "config.php"
$config['globals'] = array(//dirname(dirname(ROOT)) . DIRECTORY_SEPARATOR . "config" . DIRECTORY_SEPARATOR . "config.php"
);
//$config['includes'] = array(dirname(dirname(ROOT)) . DIRECTORY_SEPARATOR . "config" . DIRECTORY_SEPARATOR);
//$config['includes'] = array(dirname(dirname(ROOT)) . DIRECTORY_SEPARATOR . "config" . DIRECTORY_SEPARATOR . "config.php");
Expand All @@ -281,6 +281,5 @@
'type' => ''
); */

define("ENVIRONMENT", ENVIRONMENT_DEVELOPMENT);
//define('SHOW_DEBUG_BACKTRACE', true);
?>
const ENVIRONMENT = ENVIRONMENT_DEVELOPMENT;
//const SHOW_DEBUG_BACKTRACE = true;
1 change: 0 additions & 1 deletion application/config/database.php
Original file line number Diff line number Diff line change
Expand Up @@ -96,4 +96,3 @@

$active_group = 'default';
$query_builder = TRUE;
?>
4 changes: 4 additions & 0 deletions application/config/mimes.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
<?php
$mimes = [
"text/html",
];
56 changes: 30 additions & 26 deletions application/controllers/Demo.php
Original file line number Diff line number Diff line change
@@ -1,13 +1,21 @@
<?php
defined('CORE_PATH') OR exit('No direct script access allowed');
use JetBrains\PhpStorm\NoReturn;

defined('CORE_PATH') or exit('No direct script access allowed');

/**
* @property \Autoindex $autoindex
* @property \Input $input
* @property \Session $session
*/
class Demo extends Controller {
private $copyright = "Ceramic";
private string $copyright = "Ceramic";

public function __common(){
public function __common() {
$this->forceHTTPS(true);
}

public function __default(){
#[NoReturn] public function __default() {
$cmtemplate = $this->load->getTemplate();
$cmtemplate->set("cmproduct", "Ceramic");
$cmtemplate->set("cmfeature", "AutoIndex");
Expand All @@ -20,7 +28,7 @@ public function __default(){
$this->load->view('demo/footer');
}

public function captcha(){
public function captcha() {
$cmtemplate = $this->load->getTemplate();
$cmtemplate->set("cmproduct", "Ceramic");
$cmtemplate->set("cmfeature", "CAPTCHA Helper");
Expand All @@ -34,50 +42,46 @@ public function captcha(){
$this->load->library('Session/session');

// If captcha form is submitted
if($this->input->post('submit')){
if($this->input->post('submit')) {
$inputCaptcha = $this->input->post('captcha');
$sessCaptcha = $this->session->userdata('captchaCode');
if($inputCaptcha === $sessCaptcha){
if($inputCaptcha === $sessCaptcha) {
$this->user_success('Captcha code matched.');
}else{
} else {
$this->user_error('Captcha code does not match, please try again.');
}
}
$captcha = create_captcha();
$captcha = create_captcha();
$data['captcha'] = $captcha;
// Unset previous captcha and set new captcha word
$this->session->unset_userdata('captchaCode');
//$this->session->set_userdata('captchaCode', $data['captcha']['word']);
$this->session->set_userdata('captchaCode', $data['captcha']['word']);
$this->load->view('demo/header', $data);
$this->load->view('demo/captcha', $data);
$this->load->view('demo/footer', $data);
}

private function user_success($msg, $heading = 'Success'){
if($heading){
$html = '<h3 style="background-color: #36f146; padding: 10px 15px; margin: 0; border-radius: 10px 10px 0 0; color: #fff;">'.$heading.'</h3>';
private function user_success($msg, $heading = 'Success') {
if($heading) {
$html = '<h3 style="background-color: #36f146; padding: 10px 15px; margin: 0; border-radius: 10px 10px 0 0; color: #fff;">' . $heading . '</h3>';
$html .= '<div style="border:1px solid #36f146; border-radius: 0 0 10px 10px; padding: 15px 0 15px 15px;">';
$html .= $msg;
$html .= '</div>';
} else {
$html = '<div style="border:1px solid #baffba; border-radius: 10px; color: #009900; background-color: #baffba; padding: 15px;">';
$html .= $msg;
$html .= '</div>';
}
$html .= $msg;
$html .= '</div>';
echo $html;
}

private function user_error($msg, $heading = 'Error'){
if($heading){
$html = '<h3 style="background-color: #f13646; padding: 10px 15px; margin: 0; border-radius: 10px 10px 0 0; color: #fff;">'.$heading.'</h3>';
private function user_error($msg, $heading = 'Error') {
if($heading) {
$html = '<h3 style="background-color: #f13646; padding: 10px 15px; margin: 0; border-radius: 10px 10px 0 0; color: #fff;">' . $heading . '</h3>';
$html .= '<div style="border:1px solid #f13646; border-radius: 0 0 10px 10px; padding: 15px 0 15px 15px;">';
$html .= $msg;
$html .= '</div>';
} else {
$html = '<div style="border:1px solid #ffbaba; border-radius: 10px; color: #990000; background-color: #ffbaba; padding: 15px;">';
$html .= $msg;
$html .= '</div>';
}
$html .= $msg;
$html .= '</div>';
echo $html;
}

Expand Down Expand Up @@ -112,12 +116,12 @@ public function templating() {
$this->load->view('demo/footer');
}

private function refresh(){
private function refresh() {
$captcha = create_captcha();

// Unset previous captcha and set new captcha word
$this->session->unset_userdata('captchaCode');
$this->session->set_userdata('captchaCode',$captcha['word']);
$this->session->set_userdata('captchaCode', $captcha['word']);

// Display captcha image
echo $captcha['image'];
Expand Down
58 changes: 18 additions & 40 deletions system/core/Ceramic.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,11 @@
defined('CM_VERSION') OR exit('No direct script access allowed');
// system/core/Ceramic.class.php
class Ceramic {
private static $instance;
private static Ceramic $instance;
public string $contentType = 'text/html';
public array $headers = array();
public bool $urlArgumentAsView = false;
public string $urlArgumentName = "";

/**
* Ceramic constructor.
Expand All @@ -13,7 +15,6 @@ public function __construct() {
self::$instance =& $this;
}


public static function run() {
self::init();
self::autoload();
Expand Down Expand Up @@ -50,47 +51,36 @@ private static function init() {

if(!empty($baseURL)){
if(!empty($indexPage)){
$indexURL = "{$baseURL}/{$indexPage}";
$cv = substr($url, strpos($url, $baseURL));
$cv = ($baseURL == '/') ? $cv : substr($cv, strpos($cv, "{$baseURL}/") + strlen($baseURL));
$cv = ($baseURL == '/') ? $cv : substr($cv, strpos($cv, "$baseURL/") + strlen($baseURL));
}
} else {
$cv = substr($url, strpos($url, "/index.php") + strlen("/index.php"));
}
$cv = explode('/',$cv);
$argCount = count($cv);
if(!empty($cv)) {
$e = $c = $v = $a = "";
$a = "";
if(!empty($cv[4])) {
$e = $cv[1];
$c = $cv[2];
$v = $cv[3];
$a = $cv[4];
define("PLATFORM", $e);
define("CURR_CONTROLLER_PATH", CONTROLLER_PATH . PLATFORM . DS);
define("CURR_VIEW_PATH", VIEW_PATH . PLATFORM . DS);
} elseif(!empty($cv[3])) {
if(in_array($cv[1], ENVIRONMENT_NAME)){
$e = $cv[1];
$c = $cv[2];
$v = $cv[3];
define("PLATFORM", $e);
define("CURR_CONTROLLER_PATH", CONTROLLER_PATH . PLATFORM . DS);
define("CURR_VIEW_PATH", VIEW_PATH . PLATFORM . DS);
} else {
$c = $cv[1];
$v = $cv[2];
$a = $cv[3];
define("CURR_CONTROLLER_PATH", CONTROLLER_PATH . DS);
define("CURR_VIEW_PATH", VIEW_PATH . DS);
}
} elseif(!empty($cv[2])) {
$c = $cv[1];
$v = $cv[2];
define("CURR_CONTROLLER_PATH", CONTROLLER_PATH . DS);
define("CURR_VIEW_PATH", VIEW_PATH . DS);
} else {
$c = (!empty($cv[1])) ? $cv[1] : $cv[0];
define("CURR_CONTROLLER_PATH", CONTROLLER_PATH . DS);
define("CURR_VIEW_PATH", VIEW_PATH . DS);
}
Expand All @@ -104,16 +94,14 @@ private static function init() {
define("VIEW", $v);
define("ARGUMENT", $a);
} else {
define("PLATFORM", isset($_REQUEST['e']) ? $_REQUEST['e'] : '');
define("CONTROLLER", isset($_REQUEST['c']) ? $_REQUEST['c'] : '');
define("VIEW", isset($_REQUEST['v']) ? $_REQUEST['v'] : '');
define("ARGUMENT", isset($_REQUEST['a']) ? $_REQUEST['a'] : '');
define("PLATFORM", $_REQUEST['e'] ?? '');
define("CONTROLLER", $_REQUEST['c'] ?? '');
define("VIEW", $_REQUEST['v'] ?? '');
define("ARGUMENT", $_REQUEST['a'] ?? '');
define("CURR_CONTROLLER_PATH", CONTROLLER_PATH . PLATFORM . DS);
define("CURR_VIEW_PATH", VIEW_PATH . PLATFORM . DS);
}
/*define("APP_MODEL_PATH", VIEW_PATH);
define("APP_CONTROLLER_PATH", CONTROLLER_PATH);
define("APP_VIEW_PATH", VIEW_PATH);*/ // Load core classes

// Start session
session_start();
}
Expand All @@ -122,14 +110,9 @@ private static function autoload() {
spl_autoload_register(array(__CLASS__, 'load'));
}

// Autoloading

private function dispatch() {
// Instantiate the controller class and call its action method

/*if(!headers_sent())
header("Content-type: {$this->contentType}");
//header("Content-type:image/png");*/
if(!headers_sent()) {
if(!empty($this->headers)) {
foreach($this->headers as $headers) {
Expand All @@ -142,15 +125,10 @@ private function dispatch() {
}

if(!empty(CONTROLLER)) {
//$file = find_file(APP_PATH . "controllers", CONTROLLER . ".php");
$file = CONTROLLER_FILE;
$page = (!empty(VIEW))?CONTROLLER_PAGE.'/'.VIEW : CONTROLLER.'/__default';
$page_url = (empty(VIEW) || VIEW == '__default')?CONTROLLER_PAGE.'/' : $page;

/*if(empty(VIEW) || VIEW == '__default')
define('CURRENT_PAGE', CONTROLLER_PAGE);
else
define('CURRENT_PAGE', $page);*/
define('CURRENT_PAGE', $page_url);

if(file_exists($file)) {
Expand Down Expand Up @@ -198,8 +176,8 @@ private function dispatch() {
$controller = config_item("default_controller");
$page = (!empty(VIEW))?$controller.'/'.VIEW : $controller.'/__default';
if(!empty($controller)) {
$file = find_file(APP_PATH . "controllers", "{$controller}.php");
if(file_exists($file)) {
$file = find_file(APP_PATH . "controllers", "$controller.php");
if(!empty($file) && file_exists($file)) {
if(!class_exists($controller)) {
include_once($file);
$controller_name = $controller;
Expand Down Expand Up @@ -248,23 +226,23 @@ private function dispatch() {
// Define a custom load method

/**
* Reference to the CI_Controller method.
* Returns current CI instance object
* Reference to the CM_Controller method.
* Returns current CM instance object
*
* @return object
* @return \Ceramic
*/
public static function &get_instance() {
public static function &get_instance(): Ceramic {
return self::$instance;
}

// Routing and dispatching

private static function load($classname) {
// Here simply autoload app’s controller and model classes
if(substr($classname, -10) == "Controller") {
if(str_ends_with($classname, "Controller")) {
// Controller
require_once CURR_CONTROLLER_PATH . "$classname.php";
} elseif(substr($classname, -5) == "Model") {
} elseif(str_ends_with($classname, "Model")) {
// Model
require_once MODEL_PATH . "$classname.php";
}
Expand Down
Loading

0 comments on commit c4ae428

Please sign in to comment.