Skip to content

Commit

Permalink
FEAT: add patch to 3.1.5
Browse files Browse the repository at this point in the history
  • Loading branch information
drosanda committed Apr 13, 2021
1 parent 79b320a commit 03580ed
Show file tree
Hide file tree
Showing 7 changed files with 534 additions and 1,523 deletions.
72 changes: 14 additions & 58 deletions index.php
Original file line number Diff line number Diff line change
Expand Up @@ -108,63 +108,19 @@
if(!is_dir($controller_dir)) die("Seme framework directory missing : ".pathinfo(__FILE__, PATHINFO_BASENAME));
if(!is_dir($core_dir)) die("Seme framework directory missing : ".pathinfo(__FILE__, PATHINFO_BASENAME));

if(!defined('SENEROOT')) define('SENEROOT',__DIR__.DIRECTORY_SEPARATOR);
if(!defined('SENEAPP')) define('SENEAPP',str_replace("\\", "/",$apps_dir));
if(!defined('SENEASSETS')) define('SENEASSETS',$assets_dir);
if(!defined('SENESYS')) define('SENESYS',$ssys_dir);
if(!defined('SENEKEROSINE')) define('SENEKEROSINE',$kerosine_dir);
if(!defined('SENELIB')) define('SENELIB',$library_dir);
if(!defined('SENECACHE')) define('SENECACHE',$cache_dir);
if(!defined('SENECFG')) define('SENECFG',$config_dir);
if(!defined('SENEMODEL')) define('SENEMODEL',$model_dir);
if(!defined('SENEVIEW')) define('SENEVIEW',$view_dir);
if(!defined('SENECONTROLLER')) define('SENECONTROLLER',$controller_dir);
if(!defined('SENECORE')) define('SENECORE',$core_dir);

if(!isset($_SERVER['HTTP_HOST'])) $_SERVER['HTTP_HOST'] = 'localhost';
if(!file_exists(SENECFG."/config.php")) die('unable to load config file : config.php');
require_once(SENECFG."/config.php");
$GLOBALS['sene_method'] = $sene_method;

if(!file_exists(SENECFG."/controller.php")) die('unable to load config file : controller.php');
require_once(SENECFG."/controller.php");

if(!file_exists(SENECFG."/timezone.php")) die('unable to load config file : timezone.php');
require_once(SENECFG."/timezone.php");

if(!file_exists(SENECFG."/database.php")) die('unable to load config file : database.php');
require_once(SENECFG."/database.php");

if(!file_exists(SENECFG."/session.php")) die('unable to load config file : session.php');
require_once(SENECFG."/session.php");
if(!defined('SALTKEY')) define('SALTKEY',$saltkey);

if(!file_exists(SENECFG."/core.php")) die('unable to load config file : core.php');
require_once(SENECFG."/core.php");

$GLOBALS['core_prefix'] = $core_prefix;
$GLOBALS['core_controller'] = $core_controller;
$GLOBALS['core_model'] = $core_model;

if(!isset($default_controller,$notfound_controller)){
$default_controller="welcome";
$notfound_controller="notfound";
}
if(!defined('DEFAULT_CONTROLLER')) define("DEFAULT_CONTROLLER",$default_controller);
if(!defined('NOTFOUND_CONTROLLER')) define("NOTFOUND_CONTROLLER",$notfound_controller);

if(!isset($site)){
die('please fill site url / base url in : '.SENECFG.'config.php. Example: https://www.example.com/');
}
if(!defined('BASEURL')) define("BASEURL",$site);
if(!isset($admin_url)){
$admin_url=$admin_secret_url;
}
if(!defined('ADMIN_URL')) define("ADMIN_URL",$admin_url);
if(!defined('WEBSITE_VIEW_ID')) define("WEBSITE_VIEW_ID",$website_view_id);

$routing = array();
define('SENEROOT',__DIR__.DIRECTORY_SEPARATOR);
define('SENEAPP',str_replace("\\", "/",$apps_dir));
define('SENEASSETS',$assets_dir);
define('SENESYS',$ssys_dir);
define('SENEKEROSINE',$kerosine_dir);
define('SENELIB',$library_dir);
define('SENECACHE',$cache_dir);
define('SENECFG',$config_dir);
define('SENEMODEL',$model_dir);
define('SENEVIEW',$view_dir);
define('SENECONTROLLER',$controller_dir);
define('SENECORE',$core_dir);

require_once SENEKEROSINE."/SENE_Engine.php";
$se = new SENE_Engine();
$se->SENE_Engine();
$se = new SENE_Engine($db);
$se->run();
28 changes: 21 additions & 7 deletions kero/sine/SENE_Controller.php
Original file line number Diff line number Diff line change
Expand Up @@ -277,10 +277,17 @@ public function setDescription($description="en"){
public function setKeyword($keyword="lightweight,framework,php,api,generator"){
$this->keyword = $keyword;
}
public function setRobots($robots="INDEX,FOLLOW"){
if($robots != "INDEX,FOLLOW") $robots='NOINDEX,NOFOLLOW';
$this->robots = $robots;
}

/**
* Set robots properties for html meta head
* @param string $robots robots configuration (INDEX,FOLLOW|INDEX,NOFOLLOW)
*/
protected function setRobots($robots)
{
$this->robots = $robots;
return $this;
}

public function setIcon($icon="favicon.png"){
$this->icon = $icon;
}
Expand Down Expand Up @@ -369,9 +376,16 @@ public function getDescription(){
public function getKeyword(){
return $this->keyword;
}
public function getRobots(){
return $this->robots;
}

/**
* Return string for robots.txt location
* @return string keyword
*/
protected function getRobots()
{
return $this->robots;
}

public function getIcon($icon="favicon.png"){
return $this->icon;
}
Expand Down
123 changes: 84 additions & 39 deletions kero/sine/SENE_Engine.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,52 @@
<?php
DEFINE('SENE_VERSION','3.1.3');
define('SENE_VERSION','3.1.1');
if(isset($GLOBALS['saltkey'])){
define('SALTKEY',$GLOBALS['saltkey']);
}else{
define('SALTKEY','');
}

if(!isset($_SERVER))$_SERVER = array();
if(!isset($_SERVER['HTTP_HOST'])) $_SERVER['HTTP_HOST'] = 'localhost';
if(!isset($_SERVER['REQUEST_URI'])) $_SERVER['REQUEST_URI'] = '/';
if(!isset($_SERVER['DOCUMENT_ROOT'])) $_SERVER['DOCUMENT_ROOT'] = __DIR__;

if(!file_exists(SENECFG."/config.php")) die('unable to load config file : config.php');
require_once(SENECFG."/config.php");

if(!file_exists(SENECFG."/controller.php")) die('unable to load config file : controller.php');
require_once(SENECFG."/controller.php");

if(!file_exists(SENECFG."/timezone.php")) die('unable to load config file : timezone.php');
require_once(SENECFG."/timezone.php");

if(!file_exists(SENECFG."/database.php")) die('unable to load config file : database.php');
require_once(SENECFG."/database.php");

if(!file_exists(SENECFG."/session.php")) die('unable to load config file : session.php');
require_once(SENECFG."/session.php");

if(!file_exists(SENECFG."/core.php")) die('unable to load config file : core.php');
require_once(SENECFG."/core.php");

if(!isset($site)){
die('please fill site url / base url in : '.SENECFG.'config.php. Example: https://www.example.com/');
}
define("BASEURL",$site);
if(!isset($admin_url)){
$admin_url=$admin_secret_url;
}
if(!defined('ADMIN_URL')){
define("ADMIN_URL",$admin_url);
}
define("WEBSITE_VIEW_ID",$website_view_id);

if(!isset($default_controller,$notfound_controller)){
$default_controller="welcome";
$notfound_controller="notfound";
}
define("DEFAULT_CONTROLLER",$default_controller);
define("NOTFOUND_CONTROLLER",$notfound_controller);

class SENE_Engine{
protected static $__instance;
Expand All @@ -14,9 +61,10 @@ class SENE_Engine{
public function __construct(){
require_once SENEKEROSINE."/SENE_Controller.php";
require_once SENEKEROSINE."/SENE_Model.php";

if(isset($GLOBALS['core_prefix'])) if(!empty($GLOBALS['core_prefix'])) $this->core_prefix = $GLOBALS['core_prefix'];
if($GLOBALS['core_controller']) if(!empty($GLOBALS['core_controller'])) $this->core_controller = $GLOBALS['core_controller'];
if($GLOBALS['core_model']) if(!empty($GLOBALS['core_model'])) $this->core_model = $GLOBALS['core_model'];
if(isset($GLOBALS['core_controller'])) if(!empty($GLOBALS['core_controller'])) $this->core_controller = $GLOBALS['core_controller'];
if(isset($GLOBALS['core_model'])) if(!empty($GLOBALS['core_model'])) $this->core_model = $GLOBALS['core_model'];

$this->admin_url=ADMIN_URL;
self::$__instance = $this;
Expand All @@ -30,8 +78,8 @@ public function __construct(){
$rs[$key] = $val;
}
$this->routes = $rs;

$sene_method = $GLOBALS['sene_method'];
$sene_method = 'PATH_INFO';
if(isset($GLOBALS['sene_method'])) $sene_method = $GLOBALS['sene_method'];
if(isset($_SERVER['argv'])){
if(count($_SERVER['argv'])>1){
$i=0;
Expand All @@ -50,7 +98,7 @@ public function __construct(){
public static function getInstance(){
return self::$_instance;
}
public function SENE_Engine(){
public function run(){
$core_controller_file = SENECORE.$this->core_prefix.$this->core_controller.'.php';
$core_model_file = SENECORE.$this->core_prefix.$this->core_model.'.php';

Expand Down Expand Up @@ -135,14 +183,14 @@ private function ovrRoutes($paths=array()){
}
private function newRouteFolder(){
$found=0;
$sene_method = $GLOBALS['sene_method'];
$sene_method = 'PATH_INFO';
if(isset($GLOBALS['sene_method'])) $sene_method = $GLOBALS['sene_method'];
if(isset($_SERVER[$sene_method])){
$path = $_SERVER[$sene_method];
$path = str_replace("//","/",$path);
$path = explode("/",str_replace("//","/",$path));
$path=$_SERVER[$sene_method];
$path=explode("/",$path);
$i=0;
foreach($path as $p){
if(strlen($p)>0){
if(!empty($p)){
$pos = strpos($p, '?');
if ($pos !== false) {
//echo "pos: ".$pos;
Expand All @@ -166,7 +214,6 @@ private function newRouteFolder(){
}else{
$this->globalHandlerCMSPage($path);
}

$newpath = realpath(SENECONTROLLER.$path[1]);

if(is_dir($newpath)){
Expand Down Expand Up @@ -216,7 +263,6 @@ private function newRouteFolder(){
}
}
}
$_SERVER['SEME_CONTROLLER_CLASS'] = $cname;
$reflection->invokeArgs($cname,$args);
}else{
$this->notFound($newpath);
Expand Down Expand Up @@ -258,7 +304,6 @@ private function newRouteFolder(){
}
}
}
$_SERVER['SEME_CONTROLLER_CLASS'] = $cname;
$reflection->invokeArgs($cname,$args);
}else{
$this->notFound($newpath);
Expand Down Expand Up @@ -300,7 +345,6 @@ private function newRouteFolder(){
}
}
}
$_SERVER['SEME_CONTROLLER_CLASS'] = $cname;
$reflection->invokeArgs($cname,$args);
}else{

Expand Down Expand Up @@ -692,8 +736,6 @@ function redir($url,$time=0,$type=1){
}
function base_url($url=""){
if(empty($url)) $url = "";
//var_dump($url);
//die();
return BASEURL.$url;
}
function base_url_admin($url=""){
Expand Down Expand Up @@ -741,9 +783,13 @@ function get_caller_info() {
}
function seme_error_handling($errno, $errstr, $error_file,$error_line,$error_context){
if(isset($_SERVER['argv'])){
echo '======='.PHP_EOL;
echo 'ERROR '.PHP_EOL;
echo '======='.PHP_EOL;
$backtraces = debug_backtrace();
$bct = array();
$fls = array('index.php','sene_controller.php','sene_model.php','sene_engine.php','sene_mysqli_engine.php','runner_controller.php');
$bct = array();
$fls = array();
//$fls = array('index.php','sene_controller.php','sene_model.php','sene_engine.php','sene_mysqli_engine.php');

$ef = explode('/',str_replace('\\','/',$error_file));
if(isset($ef[count($ef)-1])) $ef = $ef[count($ef)-1];
Expand Down Expand Up @@ -772,36 +818,34 @@ function seme_error_handling($errno, $errstr, $error_file,$error_line,$error_con
$error_file = $bcts[0]['file'];
$error_line = $bcts[0]['line'];
}
$error_file = substr($error_file,strlen(SENEROOT));
print '================= ERROR ===================='.PHP_EOL;
print $error_file.''.PHP_EOL;
print 'Line: '.$error_line.PHP_EOL;
print 'Error: ['.$errno.'] '.$errstr.''.PHP_EOL;
$error_file = substr($error_file,strlen(SENEROOT));
print '--------------------------------------------'.PHP_EOL;
print 'Backtrace: ---------------------------------'.PHP_EOL;
echo $error_file.PHP_EOL;
echo $error_line.PHP_EOL;
echo "Error: [$errno] $errstr".PHP_EOL;
echo '-------'.PHP_EOL;
echo "Backtrace".PHP_EOL;
$i=0;
foreach($bct as $e){
$i++;
if($i<=-1) continue;
if(!isset($e['file'])) continue;
$e['file'] = substr($e['file'],strlen(SENEROOT));
print $i.'. File: '.$e['file'].PHP_EOL;
print 'Line: '.$e['line'].PHP_EOL;
echo 'File: '.$e['file'].PHP_EOL;
echo 'Line: '.$e['line'].PHP_EOL;
if(isset($e['class'])){
print 'Class: '.$e['class'].PHP_EOL;
print 'Method: '.$e['function'].PHP_EOL;
echo 'Class: '.$e['class'].PHP_EOL;
echo 'Method: '.$e['function'].PHP_EOL;
}else{
print 'Function: '.$e['function'].PHP_EOL;
echo 'Function: '.$e['function'].PHP_EOL;
}

echo '--'.PHP_EOL;
}
print '=========== Seme Framework v'.SENE_VERSION.' ============'.PHP_EOL;
die();
echo '--SEME FRAMEWORK v'.SENE_VERSION.'--'.PHP_EOL;
}else{
header($_SERVER['SERVER_PROTOCOL'] . ' 500 Internal Server Error', true, 500);
header($_SERVER['SERVER_PROTOCOL'] . ' 500 Internal Server Error', true, 500);
$backtraces = debug_backtrace();
$bct = array();
$fls = array('index.php','sene_controller.php','sene_model.php','sene_engine.php','sene_mysqli_engine.php');
$bct = array();
$fls = array();
//$fls = array('index.php','sene_controller.php','sene_model.php','sene_engine.php','sene_mysqli_engine.php');

$ef = explode('/',str_replace('\\','/',$error_file));
if(isset($ef[count($ef)-1])) $ef = $ef[count($ef)-1];
Expand Down Expand Up @@ -861,5 +905,6 @@ function seme_error_handling($errno, $errstr, $error_file,$error_line,$error_con
echo "<hr><p><small>Seme Framework v".SENE_VERSION." Error Handler</small></p>";
die();
}

}
if(!isset($_SERVER['SEME_ERR_BYPASS'])) set_error_handler("seme_error_handling");
set_error_handler("seme_error_handling");
2 changes: 1 addition & 1 deletion kero/sine/SENE_Model.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php
abstract class SENE_Model {
protected $db;
public $db;
public $field = array();

public function __construct(){
Expand Down
Loading

0 comments on commit 03580ed

Please sign in to comment.