Fixes for load libraries using php autoload
This commit is contained in:
parent
0b21909a78
commit
47c7003e3b
4 changed files with 82 additions and 9 deletions
24
index.php
24
index.php
|
|
@ -7,6 +7,16 @@ ob_start();
|
|||
include('libraries/Utils.php');
|
||||
include('libraries/Routes.php');
|
||||
|
||||
if(is_file(__DIR__.'/vendor/autoload.php')) {
|
||||
|
||||
include(__DIR__.'/vendor/autoload.php');
|
||||
|
||||
}
|
||||
|
||||
//ob_start();
|
||||
|
||||
Utils::load_config('config');
|
||||
|
||||
/*spl_autoload_register(function ($class_name) {
|
||||
|
||||
//include($nombre_clase . '.php';
|
||||
|
|
@ -23,15 +33,19 @@ include('libraries/Routes.php');
|
|||
|
||||
});*/
|
||||
|
||||
if(is_file(__DIR__.'/vendor/autoload.php')) {
|
||||
spl_autoload_register(function($class_name) {
|
||||
|
||||
include(__DIR__.'/vendor/autoload.php');
|
||||
//Simple autoload for modules, first element is module, second element is the file to load.
|
||||
|
||||
}
|
||||
$arr_library=explode('\\', $class_name);
|
||||
|
||||
//ob_start();
|
||||
$module=strtolower($arr_library[0]);
|
||||
$library=strtolower($arr_library[1]);
|
||||
|
||||
Utils::load_config('config');
|
||||
include('modules/'.$module.'/libraries/'.$library.'.php');
|
||||
|
||||
|
||||
});
|
||||
|
||||
if(!PhangoApp\PhaRouter\Config::$on_other) {
|
||||
|
||||
|
|
|
|||
|
|
@ -9,6 +9,8 @@ class Config {
|
|||
|
||||
static public $modules_allowed=['welcome' => 'modules/welcome'];
|
||||
|
||||
static public $libraries_allowed=[];
|
||||
|
||||
static public $base_url='';
|
||||
|
||||
static public $data=[];
|
||||
|
|
|
|||
|
|
@ -1,10 +1,11 @@
|
|||
<?php
|
||||
|
||||
//use PhangoApp\PhaView\View;
|
||||
//use PhangoApp\WPDO\WPDO;
|
||||
use PhangoApp\WPDO\WPDO;
|
||||
use PhangoApp\PhaRouter\Url;
|
||||
//use PhangoApp\PhaModels\Webmodel;
|
||||
|
||||
include('./modules/admin/libraries/login.php');
|
||||
//include('./modules/admin/libraries/login.php');
|
||||
|
||||
include('modules/admin/libraries/tplcontroller.php');
|
||||
|
||||
|
|
@ -31,7 +32,19 @@ class AppController extends TplController{
|
|||
|
||||
case 'login':
|
||||
|
||||
echo 'login';
|
||||
$this->db->connect();
|
||||
|
||||
$c_user=$this->db->select_count('', []);
|
||||
|
||||
if(!$c_user) {
|
||||
|
||||
header('Location: '.Url::make_url('admin', 'app', ['signup']));
|
||||
|
||||
}
|
||||
|
||||
//print_r($this->db->table);
|
||||
|
||||
|
||||
|
||||
/*$conn=MySQL::get_pdo_connection();
|
||||
|
||||
|
|
@ -47,6 +60,12 @@ class AppController extends TplController{
|
|||
|
||||
echo View::load_view(['login' => 1], 'login');*/
|
||||
|
||||
break;
|
||||
|
||||
case 'signup':
|
||||
|
||||
|
||||
|
||||
break;
|
||||
|
||||
case 'login_check':
|
||||
|
|
|
|||
38
modules/admin/libraries/tplcontroller.php
Normal file
38
modules/admin/libraries/tplcontroller.php
Normal file
|
|
@ -0,0 +1,38 @@
|
|||
<?php
|
||||
|
||||
use PhangoApp\WPDO;
|
||||
use PhaTemplates\Templates;
|
||||
|
||||
class TplController {
|
||||
|
||||
public $tpl;
|
||||
public $db;
|
||||
|
||||
public function __construct() {
|
||||
|
||||
session_start();
|
||||
|
||||
$table=new WPDO\WTable('useradmin', ['username', 'password', 'email']);
|
||||
|
||||
$this->db=new WPDO\WPDO($table);
|
||||
|
||||
$this->tpl=new Templates(['theme/admin/templates', 'modules/admin/templates']);
|
||||
|
||||
}
|
||||
|
||||
public function check_login() {
|
||||
|
||||
if(isset($_SESSION['admin_login'])) {
|
||||
|
||||
return true;
|
||||
|
||||
}
|
||||
else {
|
||||
|
||||
return false;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue