Debugger support
This commit is contained in:
parent
0f144307e9
commit
72170689d9
|
@ -371,7 +371,7 @@ class user{
|
|||
}
|
||||
|
||||
public function requireRole($role, $adminGranted=true){
|
||||
return $this->auth->hasRole($role) || $this->auth->hasRole(Role::SUPER_ADMIN) || ($this->auth->hasRole(Role::ADMIN) && $adminGranted && $role !== Role::DEVELOPER);
|
||||
return $this->auth->hasRole($role) || $adminGranted && $role !== Role::DEVELOPER && $this->auth->hasRole(Role::ADMIN) || $role !== Role::DEVELOPER && $this->auth->hasRole(Role::SUPER_ADMIN);
|
||||
}
|
||||
|
||||
public function name($replace=false){
|
||||
|
@ -423,7 +423,7 @@ class user{
|
|||
}
|
||||
|
||||
public function info(){
|
||||
return array("id" => $this->auth->getUserId(), "name" => $this->name(), "full_viewer" => $this->requireRole(Role::FULL_VIEWER), "tester" => $this->requireRole(Role::TESTER), "developer" => $this->requireRole(Role::DEVELOPER));
|
||||
return array("autenticated" => $this->authenticated(), "id" => $this->auth->getUserId(), "name" => $this->name(), "full_viewer" => $this->requireRole(Role::FULL_VIEWER), "tester" => $this->requireRole(Role::TESTER), "developer" => $this->requireRole(Role::DEVELOPER));
|
||||
}
|
||||
|
||||
public function login($name, $password, $twofa=null){
|
||||
|
@ -585,11 +585,11 @@ function init_class($enableDebugger=true){
|
|||
$translations = new translations();
|
||||
}
|
||||
if($enableDebugger){
|
||||
//if($user->requireRole(Role::DEVELOPER)){
|
||||
Debugger::enable(Debugger::DEVELOPMENT, __DIR__ . '/error-log');
|
||||
//} else {
|
||||
//Debugger::enable(Debugger::PRODUCTION, __DIR__ . '/error-log');
|
||||
//}
|
||||
if($user->requireRole(Role::DEVELOPER)){
|
||||
Debugger::enable(Debugger::DEVELOPMENT, __DIR__ . '/error-log');
|
||||
} else {
|
||||
Debugger::enable(Debugger::PRODUCTION, __DIR__ . '/error-log');
|
||||
}
|
||||
}
|
||||
bdump(get_included_files());
|
||||
bdump($translations->loaded_translations);
|
||||
|
|
|
@ -222,7 +222,17 @@ if(!is_cli()){
|
|||
<label for="admin_visible"><input name="admin_visible" type="checkbox" id="admin_visible" value="0">
|
||||
Rendi l'user admin visibile agli altri user</label>
|
||||
<p class="description">Attivando questa opzione, l'user che verrà creato sarà visibile negli elenchi e nelle procedure.</p>
|
||||
</fieldset>
|
||||
</fieldset>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th scope="row">Aggiungi i permessi di sviluppatore</th>
|
||||
<td>
|
||||
<fieldset>
|
||||
<label for="developer"><input name="developer" type="checkbox" id="developer" value="0">
|
||||
Aggiungi all'utente admin i permessi di sviluppatore</label>
|
||||
<p class="description">Attivando questa opzione, l'utente potrà eseguire il debug e accedere a varie console amministrative.</p>
|
||||
</fieldset>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
|
@ -242,7 +252,7 @@ if(!is_cli()){
|
|||
</p>
|
||||
<?php
|
||||
} else if (in_array("5",$_POST)) {
|
||||
initOptions($_POST["user_name"], isset($_POST["admin_visible"]), $_POST["admin_password"], $_POST["admin_email"], $_POST["owner"]);
|
||||
initOptions($_POST["user_name"], isset($_POST["admin_visible"]), isset($_POST["developer"]), $_POST["admin_password"], $_POST["admin_email"], $_POST["owner"]);
|
||||
header("Location: install.php");
|
||||
} else if ($userPopulated) {
|
||||
?>
|
||||
|
|
|
@ -369,14 +369,6 @@ INSERT INTO `".$prefix."_tipo` (`id`, `name`) VALUES (NULL, 'type1'), (NULL, 'ty
|
|||
}
|
||||
}
|
||||
|
||||
final class Role {
|
||||
//https://github.com/delight-im/PHP-Auth/blob/master/src/Role.php
|
||||
const SUPER_ADMIN = \Delight\Auth\Role::SUPER_ADMIN;
|
||||
|
||||
public function __construct() {}
|
||||
|
||||
}
|
||||
|
||||
function full_path()
|
||||
{
|
||||
$s = &$_SERVER;
|
||||
|
@ -393,14 +385,17 @@ function full_path()
|
|||
return $url;
|
||||
}
|
||||
|
||||
function initOptions($name, $visible, $password, $report_email, $owner){
|
||||
function initOptions($name, $visible, $developer, $password, $report_email, $owner){
|
||||
try{
|
||||
require_once "../config.php";
|
||||
$connection = new PDO("mysql:host=".DB_HOST.";dbname=".DB_NAME, DB_USER, DB_PASSWORD,[PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION]);
|
||||
$prefix = DB_PREFIX;
|
||||
$auth = new \Delight\Auth\Auth($connection, $_SERVER['REMOTE_ADDR'], $prefix."_");
|
||||
$userId = $auth->register($report_email, $password, $name);
|
||||
$auth->admin()->addRoleForUserById($userId, Role::SUPER_ADMIN);
|
||||
$auth->admin()->addRoleForUserById($userId, \Delight\Auth\Role::SUPER_ADMIN);
|
||||
if($developer){
|
||||
$auth->admin()->addRoleForUserById($userId, \Delight\Auth\Role::DEVELOPER);
|
||||
}
|
||||
$option_check_cf_ip = empty($_SERVER['HTTP_CF_CONNECTING_IP']) ? "INSERT INTO `".$prefix."_options` (`id`, `name`, `value`, `enabled`, `created_time`, `last_edit`, `user_id`) VALUES ('11', 'check_cf_ip', 1, '1', current_timestamp(), current_timestamp(), '1');" : "INSERT INTO `".$prefix."_options` (`id`, `name`, `value`, `enabled`, `created_time`, `last_edit`, `user_id`) VALUES ('10', 'check_cf_ip', 0, '1', current_timestamp(), current_timestamp(), '1');";
|
||||
$prep = $connection->prepare("
|
||||
INSERT INTO `".$prefix."_profiles` (`id`, `hidden`) VALUES (NULL, :hidden);
|
||||
|
|
|
@ -300,6 +300,7 @@
|
|||
}
|
||||
});
|
||||
</script>
|
||||
{% if user.autenticated %}
|
||||
<script>
|
||||
function check() {
|
||||
var xhr = new XMLHttpRequest();
|
||||
|
@ -319,6 +320,7 @@
|
|||
check();
|
||||
}, 30000);
|
||||
</script>
|
||||
{% endif %}
|
||||
{% block menu %}
|
||||
<!-- Menu -->
|
||||
<div class="topnav" id="myTopnav">
|
||||
|
|
Loading…
Reference in New Issue