set double authentication : create, send link, usable with FreeOTP (opensource) AEgis (opensource) and Google Authenticator 1. OTP : prevent direct access without going throught the 2FA mechanism 2. Go back to the url where you were disconnected 3. Cosmetic
221 lines
7.7 KiB
PHP
221 lines
7.7 KiB
PHP
<?php
|
|
/*
|
|
* This file is part of NOALYSS.
|
|
*
|
|
* NOALYSS is free software; you can redistribute it and/or modify
|
|
* it under the terms of the GNU General Public License as published by
|
|
* the Free Software Foundation; either version 2 of the License, or
|
|
* (at your option) any later version.
|
|
*
|
|
* NOALYSS is distributed in the hope that it will be useful,
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
* GNU General Public License for more details.
|
|
*
|
|
* You should have received a copy of the GNU General Public License
|
|
* along with NOALYSS; if not, write to the Free Software
|
|
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
|
*/
|
|
// Copyright Author Dany De Bontridder danydb@aevalys.eu
|
|
/*!
|
|
*\file
|
|
*\brief Administration of the repository : creation of user, folder, security,
|
|
* templates... Accessible only by the administrator
|
|
*/
|
|
if ( ! defined ('ALLOWED')) { die (_('Non autorisé'));}
|
|
if ( ! defined ('ALLOWED_ADMIN')) { die (_('Non autorisé'));}
|
|
\Noalyss\Dbg::echo_file(__FILE__);
|
|
include_once NOALYSS_INCLUDE . "/class/noalyss_user.class.php";
|
|
require_once NOALYSS_INCLUDE."/lib/user_common.php";
|
|
include_once NOALYSS_INCLUDE."/lib/ac_common.php";
|
|
require_once NOALYSS_INCLUDE."/lib/user_menu.php";
|
|
$http=new HttpInput();
|
|
$action = $http->request("action","string", "");
|
|
|
|
$rep=new Database();
|
|
$User=new Noalyss_user($rep);
|
|
$User->Check();
|
|
/**
|
|
* check if 2FA is completed
|
|
*/
|
|
if ( ! $User->is_double_identified()) {
|
|
exit();
|
|
}
|
|
$audit=true;
|
|
|
|
if ($User->admin != 1)
|
|
{
|
|
$theme=(isset($User->theme))?$User->theme:"";
|
|
$User->audit('FAIL',"ADMIN : [$action]".var_export($_REQUEST,true));
|
|
html_page_start($theme);
|
|
echo '<div class=content" style="padding:5%">';
|
|
echo "<h1 class=\"title\">";
|
|
echo _("Accès interdit");
|
|
echo "</h1>";
|
|
echo '<span class="warning">';
|
|
echo _("Vous n'êtes pas administateur");
|
|
echo '</span>';
|
|
$reconnect=http_build_query(array("reconnect"=>1,"backurl"=>"admin-noalyss.php?action=upgrade"));
|
|
echo '<a class="mtitle" style="text-decoration:underline" href="'.NOALYSS_URL.'/index.php?'.$reconnect.'">';
|
|
|
|
echo _("Cliquez ici pour vous connecter comme administrateur");
|
|
echo '</a>';
|
|
html_page_stop();
|
|
return;
|
|
}
|
|
$User->audit('SUCCESS',"ADMIN : [$action] ".var_export($_REQUEST,true));
|
|
|
|
// For a backup , we must avoid to send anything before the
|
|
// dump file
|
|
if ( $action== 'backup') {
|
|
/* take backup */
|
|
require_once NOALYSS_INCLUDE."/backup.inc.php";
|
|
exit();
|
|
}
|
|
html_page_start($_SESSION[SESSION_KEY.'g_theme']);
|
|
load_all_script();
|
|
echo '<H2 class="info w100"> '._('Administration').'</H2>';
|
|
echo '<div class="topmenu">';
|
|
|
|
echo MenuAdmin()."</div>";
|
|
|
|
?>
|
|
<DIV >
|
|
<?php
|
|
echo js_include("admin.js");
|
|
if ( $action=="user_mgt" )
|
|
{
|
|
//----------------------------------------------------------------------
|
|
// User management
|
|
//----------------------------------------------------------------------
|
|
require_once NOALYSS_INCLUDE."/user.inc.php";
|
|
}
|
|
|
|
if ( $action=="dossier_mgt")
|
|
{
|
|
//-----------------------------------------------------------------------
|
|
// action = dossier_mgt
|
|
//-----------------------------------------------------------------------
|
|
require_once NOALYSS_INCLUDE."/dossier.inc.php";
|
|
}
|
|
if ( $action== "modele_mgt" )
|
|
{
|
|
//-----------------------------------------------------------------------
|
|
// Template Management
|
|
//-----------------------------------------------------------------------
|
|
require_once NOALYSS_INCLUDE."/modele.inc.php";
|
|
} // action is set
|
|
if ( $action== 'restore')
|
|
{
|
|
// Backup and restaure folders
|
|
require_once NOALYSS_INCLUDE."/restore.inc.php";
|
|
}
|
|
if ($action== 'audit_log')
|
|
{
|
|
/* List the connexion successfull and failed */
|
|
require_once NOALYSS_INCLUDE."/audit_log.php";
|
|
}
|
|
/*
|
|
* Display information about current installation
|
|
*/
|
|
if ( $action == "info" && SYSINFO_DISPLAY == true) {
|
|
global $version_noalyss;
|
|
echo "<h2>"._("Version Noalyss")."</h2>";
|
|
echo "Noalyss : ", $version_noalyss;
|
|
|
|
echo "<h2>"._('Variables').":".NOALYSS_INCLUDE.'/config.inc.php </h2>';
|
|
echo '<ul style="list-style:square">';
|
|
echo "<li>". "NOALYSS_HOME".": ".NOALYSS_HOME."</li>";
|
|
echo "<li>"."NOALYSS_INCLUDE".": ".NOALYSS_INCLUDE."</li>";
|
|
echo "<li>"."NOALYSS_TEMPLATE".": ".NOALYSS_TEMPLATE."</li>";
|
|
echo "<li>"."DEBUG".": ".DEBUGNOALYSS."</li>";
|
|
echo "<li>"."LOGINPUT".": ".LOGINPUT."</li>";
|
|
echo "<li>"."LOCALE".": ".LOCALE."</li>";
|
|
echo "<li>"."MULTI".": ".MULTI."</li>";
|
|
echo "<li>"."DOMAINE".": ".domaine."</li>";
|
|
echo "<li>"."PG_PATH".": ".PG_PATH."</li>";
|
|
echo "<li>"."PG_DUMP".": ".PG_DUMP."</li>";
|
|
echo "<li>"."PG_RESTORE".": ".PG_RESTORE."</li>";
|
|
echo "<li>"."PSQL".": ".PSQL."</li>";
|
|
echo "</ul>";
|
|
echo "<h2>"._("Paramètre base de données")."</h2>";
|
|
$a_option = array ("client_encoding","lc_collate","listen_addresses",
|
|
"server_encoding","work_mem","shared_buffers","server_version",
|
|
"hba_file","config_file","data_directory","effective_cache_size");
|
|
/*
|
|
* For old version of noalyss config file
|
|
*/
|
|
$noalyss_user=(defined("noalyss_user"))?noalyss_user:phpcompta_user;
|
|
$port=(defined("noalyss_psql_port"))?noalyss_psql_port:phpcompta_psql_port;
|
|
$host=(!defined("noalyss_psql_host") )?'127.0.0.1':noalyss_psql_host;
|
|
|
|
echo '<ul style="list-style:square">';
|
|
echo "<li>";
|
|
echo _('Hôte')." = ".$host;
|
|
echo "</li>";
|
|
echo "<li>";
|
|
echo _('Port')." = ".$port;
|
|
echo "</li>";
|
|
echo "<li>";
|
|
echo _('Utilisateur')." = ".$noalyss_user;
|
|
echo "</li>";
|
|
|
|
for ( $i = 0 ; $i < count($a_option); $i++) {
|
|
$name=$a_option[$i];
|
|
|
|
$sql="select setting from pg_settings where name=$1";
|
|
$value=$rep->get_value($sql,array($name));
|
|
echo "<li> ".$name." = ".$value."</li>";
|
|
}
|
|
|
|
echo "</ul>";
|
|
|
|
echo "<h2>"._('Paramètre PHP')."</h2>";
|
|
ob_start();
|
|
echo phpinfo(INFO_GENERAL | INFO_CONFIGURATION | INFO_MODULES | INFO_ENVIRONMENT | INFO_VARIABLES);
|
|
$r=ob_get_clean();
|
|
$html=new DOMDocument();
|
|
libxml_use_internal_errors(true);
|
|
$html->loadHTML($r);
|
|
$nodelist=$html->getElementsByTagName("style");
|
|
$nodelist->item(0)->nodeValue='
|
|
.p {text-align: left;}
|
|
.e {background-color: #ccccff; font-weight: bold; color: #000000;}
|
|
.h {background-color: #9999cc; font-weight: bold; color: #000000;word-wrap:break-word;word-break: break-all;}
|
|
.v {background-color: #cccccc; color: #000000;;word-wrap:break-word;word-break: break-all}
|
|
.vr {background-color: #cccccc; text-align: right; color: #000000;word-wrap:break-word;word-break: break-all}
|
|
img {float: right; border: 0px;}
|
|
hr {width: 600px; background-color: #cccccc; border: 0px; height: 1px; color: #000000;}
|
|
';
|
|
$a_table=$html->getElementsByTagName("table");
|
|
|
|
// For PHP < 7 , we must change the attribute "width"
|
|
if ( substr(phpversion(),0,1) < 7 )
|
|
{
|
|
for ( $i = 0 ; $i < $a_table->length;$i++) {
|
|
$node=$a_table->item($i);
|
|
$node_width = $node->attributes->getNamedItem("width");
|
|
if ( $node_width != null ) $node_width->nodeValue="100%";
|
|
|
|
}
|
|
}
|
|
$a_title = $html->getElementsByTagName("title");
|
|
for ( $i = 0;$i<$a_title->length;$i++) {
|
|
$a_title->item($i)->nodeValue="";
|
|
}
|
|
echo $html->saveHTML();
|
|
|
|
}
|
|
//------------------------------------------------------------------------------
|
|
// Upgrade
|
|
//------------------------------------------------------------------------------
|
|
if ( $action == "upgrade" ) {
|
|
|
|
|
|
require_once NOALYSS_INCLUDE."/upgrade.inc.php";
|
|
}
|
|
?>
|
|
</DIV>
|
|
<?php
|
|
html_page_stop();
|
|
?>
|