System will be undergoing maintenance on November 24th from 20:00 CET to November 25th 05:00 CET Some downtime might happen. Sorry for the inconvenience.

Commit f93664c4 authored by Bastien Pujos's avatar Bastien Pujos

Multiple fixes based on modifications on my old eonweb

parent c1f83f12
......@@ -97,6 +97,9 @@ $path_menu_limited="$path_languages/menus-limited";
$path_menu_limited_custom="$path_languages/custom.menus-limited";
$path_reports="$path_eonweb/include/reports";
// # Backup Manager
$path_backupconf="/etc/backup-manager.conf";
// # Nagios
$path_nagios="$path_eon/nagios";
$path_notifier="$path_eon/notifier";
......@@ -112,6 +115,7 @@ $path_nagiosbpcfg_bu="/tmp/nagios-bp.conf";
$path_nagiosbpcfg_lock="/tmp/nagios_bp";
$path_nagiosdowntime="$path_nagios/plugins/Downtime/downtime_list.txt";
$path_notification="$path_notifier/etc/notifier.rules";
$path_notifier="$path_eon/notifier";
// # GED
$ged_prefix="";
......@@ -126,6 +130,11 @@ $path_gedtcfg="$path_ged/etc/gedt.cfg";
$path_notifier_rules="$path_notifier/etc/notifier.rules";
$path_notifier_methods="$path_notifier/etc/notifier.cfg";
// # Net-SNMP
$path_snmpwalk="/usr/bin/snmpwalk";
$path_snmpconf="/etc/snmp/snmpd.conf";
$path_snmptrapconf="/etc/snmp/snmptrapd.conf";
// # NetCAT
$default_minport=1;
$default_maxport=1024;
......
......@@ -739,7 +739,7 @@ function ldap_escape($str, $login=false, $escape=false){
}
// User creation
function insert_user($user_name, $user_descr, $user_group, $user_password1, $user_password2, $user_type, $user_location, $user_mail, $user_limitation, $message, $in_nagvis = false, $in_cacti = false, $nagvis_group = false, $user_language = false){
function insert_user($user_name, $user_descr, $user_group, $user_password1, $user_password2, $user_type, $user_location, $user_mail, $user_limitation, $message, $in_nagvis = false, $in_cacti = false, $nagvis_group = false, $user_language = false, $user_defaultpage = 0){
global $database_host;
global $database_cacti;
global $database_username;
......@@ -774,7 +774,7 @@ function insert_user($user_name, $user_descr, $user_group, $user_password1, $use
$user_password = md5($user_password1);
// Insert into eonweb
sqlrequest("$database_eonweb","INSERT INTO users (user_name,user_descr,group_id,user_passwd,user_type,user_location,user_limitation,user_language) VALUES('$user_name', '$user_descr', '$user_group', '$user_password', '$user_type', '$user_location', '$user_limitation', '$user_language')");
sqlrequest("$database_eonweb","INSERT INTO users (user_name,user_descr,group_id,user_passwd,user_type,user_location,user_limitation,user_language,user_defaultpage) VALUES('$user_name', '$user_descr', '$user_group', '$user_password', '$user_type', '$user_location', '$user_limitation', '$user_language', '$user_defaultpage')");
$user_id=mysqli_result(sqlrequest("$database_eonweb","SELECT user_id FROM users WHERE user_name='$user_name'"),0,"user_id");
$group_name=mysqli_result(sqlrequest("$database_eonweb","SELECT group_name FROM groups WHERE group_id='$user_group'"),0,"group_name");
......@@ -889,6 +889,44 @@ function getLabel($reference){
}
// Display user language selection
function GetUserLang($user_id) {
global $database_eonweb;
global $path_languages;
// definition of variables and Research language files
$path_label_lang = "label.admin_user.user_lang_";
$files = array('en');
$handler = opendir($path_languages);
while ($file = readdir($handler)) {
if(preg_match('#messages-(.+).json#', $file, $matches)){
$files[] = $matches[1];
}
}
closedir($handler);
$files = array_filter($files);
array_unshift($files,"0");
$files = array_unique($files);
// creation of a select and catch values
$langtmp = mysqli_result(sqlrequest("$database_eonweb","SELECT user_language FROM users WHERE user_id='".$user_id."'"),0);
$res = '<select class="form-control" name="user_language">';
foreach($files as $v) {
if($v == $langtmp){
$res.="<option value='".$v."' selected=selected>".getLabel($path_label_lang.$v)."</option>";
}
else{
$res.="<option value='".$v."'>".getLabel($path_label_lang.$v)."</option>";
}
}
$res .= '</select>';
return $res;
}
// get default page
function getDefaultPage($usrlimit=0){
......@@ -899,6 +937,8 @@ function getDefaultPage($usrlimit=0){
global $path_menu_limited_custom;
global $path_menus;
global $path_menus_custom;
global $database_eonweb;
global $user_id;
// load dictionnary if not isset
if(!isset($t)) {
......@@ -921,8 +961,15 @@ function getDefaultPage($usrlimit=0){
}
}
return $defaultpage;
if(isset($_COOKIE["user_id"])) {
$tempDefaultpage = mysqli_result(sqlrequest("$database_eonweb","SELECT user_defaultpage FROM users WHERE user_id='".$_COOKIE["user_id"]."'"),0);
if($tempDefaultpage != '0'){
$defaultpage = $tempDefaultpage;
}
}
return $defaultpage;
}
// get frame url
......
......@@ -90,6 +90,15 @@
"label.admin_device.remove_cacti": "Hosts cacti à supprimer",
"label.admin_device.snmp_v3_title": "Paramètres SNMP v3",
"label.admin_device.title": "Synchronisation cacti",
"label.admin_files.title_backupconf": "Paramètres de sauvegarde",
"label.admin_files.title_gedcfg": "Paramètres du service GED",
"label.admin_files.title_gedhdb": "Paramètres du stockage GED",
"label.admin_files.title_gedqcfg": "Paramètres du client GED",
"label.admin_files.title_gedtcfg": "Paramètres de relais GED",
"label.admin_files.title_nagiosdowntime": "Programmation des arrêts planifiés",
"label.admin_files.title_notification": "Notification avancées",
"label.admin_files.title_snmpconf": "Paramètres du service SNMPD",
"label.admin_files.title_snmptrapconf": "Paramètres du service SNMPDTRAPD",
"label.admin_group.dn_group": "DN LDAP",
"label.admin_group.group_desc": "Description du groupe",
"label.admin_group.group_name": "Nom du groupe",
......
......@@ -36,6 +36,8 @@
"action.unselect_all": "Unselect all",
"action.update": "Update",
"action.verify": "Verify",
"calendar.July": "July",
"calendar.June": "June",
"calendar.april": "April",
"calendar.august": "August",
"calendar.december": "December",
......@@ -90,6 +92,15 @@
"label.admin_device.remove_cacti": "Cacti hosts to remove",
"label.admin_device.snmp_v3_title": "SNMP v3 settings",
"label.admin_device.title": "Cacti synchronization",
"label.admin_files.title_backupconf": "Backup settings",
"label.admin_files.title_gedcfg": "GED settings",
"label.admin_files.title_gedhdb": "GED backends settings",
"label.admin_files.title_gedqcfg": "GED queue settings",
"label.admin_files.title_gedtcfg": "GED relay settings",
"label.admin_files.title_nagiosdowntime": "Downtime scheduling",
"label.admin_files.title_notification": "Advanced notifications",
"label.admin_files.title_snmpconf": "SNMPD service settings",
"label.admin_files.title_snmptrapconf": "SNMPDTRAPD service settings",
"label.admin_group.dn_group": "LDAP DN",
"label.admin_group.group_desc": "Group description",
"label.admin_group.group_name": "Groupe name",
......
......@@ -42,13 +42,10 @@ include("../../side.php");
$group_mgt_list=retrieve_form_data("group_mgt_list",null);
$group_selected=retrieve_form_data("group_selected",null);
if ($action == 'submit')
if (isset($group_mgt_list))
{
switch($group_mgt_list)
{
case "add_group":
echo "<meta http-equiv=refresh content='0;URL=add_modify_group.php'>";
break;
case "delete_group":
if (isset($group_selected[0]))
{
......@@ -194,31 +191,8 @@ include("../../side.php");
</table>
</div>
<div class="form-group">
<select class="form-control" name="group_mgt_list" size=1>
<?php
// Get the global table
global $array_group_mgt;
// Get the first array key
reset($array_group_mgt);
// Display the list of management choices
$cpt = 1;
while (list($mgt_name, $mgt_url) = each($array_group_mgt)) {
if($cpt == 3){
if($ldap_conf){
echo "<option value='$mgt_url'>".getLabel($mgt_name)."</option>";
}
} else {
echo "<option value='$mgt_url'>".getLabel($mgt_name)."</option>";
}
$cpt++;
}
?>
</select>
</div>
<button id="mgt_group_submit" class="btn btn-primary" type="submit" name="action" value="submit"><?php echo getLabel("action.submit"); ?></button>
<a href="./add_modify_group.php" class="btn btn-success" role="button"><?php echo getLabel("action.add");?></a>
<button id="mgt_group_submit" class="btn btn-danger" type="submit" name="group_mgt_list" value="delete_group"><?php echo getLabel("action.clear"); ?></button>
<button class="btn btn-primary hidden" id="show_ldap_users"><?php echo getLabel("action.show_ldap_users"); ?></button>
</form>
......
......@@ -36,52 +36,13 @@ include("../../side.php");
function retrieve_user_info($user_id)
{
global $database_eonweb;
return sqlrequest("$database_eonweb","SELECT user_name, user_descr, group_id, user_passwd, user_type, user_location, user_limitation, user_language FROM users WHERE user_id='$user_id'");
}
// Display user language selection
function GetUserLang() {
global $database_eonweb;
global $user_id;
global $path_languages;
// definition of variables and Research language files
$path_label_lang = "label.admin_user.user_lang_";
$files = array('en');
$handler = opendir($path_languages);
while ($file = readdir($handler)) {
if(preg_match('#messages-(.+).json#', $file, $matches)){
$files[] = $matches[1];
}
}
closedir($handler);
$files = array_filter($files);
array_unshift($files,"0");
$files = array_unique($files);
// creation of a select and catch values
$langtmp = mysqli_result(sqlrequest("$database_eonweb","SELECT user_language FROM users WHERE user_id='".$user_id."'"),0);
$res = '<select class="form-control" name="user_language">';
foreach($files as $v) {
if($v == $langtmp){
$res.="<option value='".$v."' selected=selected>".getLabel($path_label_lang.$v)."</option>";
}
else{
$res.="<option value='".$v."'>".getLabel($path_label_lang.$v)."</option>";
}
}
$res .= '</select>';
return $res;
return sqlrequest("$database_eonweb","SELECT user_name, user_descr, group_id, user_passwd, user_type, user_location, user_limitation, user_language, user_defaultpage FROM users WHERE user_id='$user_id'");
}
//--------------------------------------------------------
// Update User Information & Right
function update_user($user_id, $user_name, $user_descr, $user_group, $user_password1, $user_password2 ,$user_type, $user_location, $user_mail, $user_limitation, $old_group_id, $old_name, $create_user_in_nagvis, $create_user_in_cacti, $nagvis_role_id, $user_language)
function update_user($user_id, $user_name, $user_descr, $user_group, $user_password1, $user_password2 ,$user_type, $user_location, $user_mail, $user_limitation, $old_group_id, $old_name, $create_user_in_nagvis, $create_user_in_cacti, $nagvis_role_id, $user_language, $user_defaultpage)
{
global $database_host;
global $database_cacti;
......@@ -111,11 +72,11 @@ include("../../side.php");
if ($user_password1 != "abcdefghijklmnopqrstuvwxyz") {
$passwd_temp = md5($user_password1);
// Update into eonweb
sqlrequest("$database_eonweb","UPDATE users set user_name='$user_name', user_descr='$user_descr',group_id='$user_group',user_passwd='$passwd_temp',user_type='$user_type',user_location='$user_location',user_limitation='$user_limitation',user_language='$user_language' WHERE user_id ='$user_id'");
sqlrequest("$database_eonweb","UPDATE users set user_name='$user_name', user_descr='$user_descr',group_id='$user_group',user_passwd='$passwd_temp',user_type='$user_type',user_location='$user_location',user_limitation='$user_limitation',user_language='$user_language', user_defaultpage='$user_defaultpage' WHERE user_id ='$user_id'");
}
else {
// Update into eonweb
sqlrequest("$database_eonweb","UPDATE users set user_name='$user_name', user_descr='$user_descr',group_id='$user_group',user_type='$user_type',user_location='$user_location',user_limitation='$user_limitation',user_language='$user_language' WHERE user_id ='$user_id'");
sqlrequest("$database_eonweb","UPDATE users set user_name='$user_name', user_descr='$user_descr',group_id='$user_group',user_type='$user_type',user_location='$user_location',user_limitation='$user_limitation',user_language='$user_language', user_defaultpage='$user_defaultpage' WHERE user_id ='$user_id'");
}
// Update into lilac
......@@ -221,6 +182,7 @@ include("../../side.php");
$user_type = retrieve_form_data("user_type","");
$user_limitation = retrieve_form_data("user_limitation","");
$user_language = retrieve_form_data("user_language","");
$user_defaultpage = retrieve_form_data("user_defaultpage","");
$old_group_id = mysqli_result(sqlrequest($database_eonweb,"select group_id from users where user_id='$user_id'"),0,"group_id");
$old_name = retrieve_form_data("user_name_old","");
......@@ -265,7 +227,7 @@ include("../../side.php");
$user_group = retrieve_form_data("user_group","");
$nagvis_grp = retrieve_form_data("nagvis_group", "");
$user_id=insert_user(stripAccents($user_name), $user_descr, $user_group, $user_password1, $user_password2, $user_type, $user_location,$user_mail,$user_limitation, true, $create_user_in_nagvis, $create_user_in_cacti, $nagvis_grp, $user_language);
$user_id=insert_user(stripAccents($user_name), $user_descr, $user_group, $user_password1, $user_password2, $user_type, $user_location,$user_mail,$user_limitation, true, $create_user_in_nagvis, $create_user_in_cacti, $nagvis_grp, $user_language, $user_defaultpage);
//message(8,"User location: $user_location",'ok'); // For debug pupose, to be removed
// Retrieve Group Information from database
......@@ -276,8 +238,9 @@ include("../../side.php");
$user_descr=mysqli_result($user_name_descr,0,"user_descr");
$user_group=mysqli_result($user_name_descr,0,"group_id");
$user_type=mysqli_result($user_name_descr,0,"user_type");
$user_limitation = retrieve_form_data("user_limitation","");
$user_language = retrieve_form_data("user_language","");
$user_limitation = mysqli_result($user_name_descr,0,"user_limitation","");
$user_language = mysqli_result($user_name_descr,0,"user_language");
$user_defaultpage = mysqli_result($user_name_descr,0,"user_defaultpage");
$user_location=mysqli_result($user_name_descr,0,"user_location");
$user_password1= "abcdefghijklmnopqrstuvwxyz";
$user_password2= "abcdefghijklmnopqrstuvwxyz";
......@@ -297,7 +260,7 @@ include("../../side.php");
// ACCOUNT UPDATE (and retrieve parameters)
//------------------------------------------------------------------------------------------------
if (isset($_POST['update'])){
update_user($user_id, stripAccents($user_name), $user_descr, $user_group, $user_password1, $user_password2, $user_type, $user_location, $user_mail, $user_limitation, $old_group_id, $old_name, $create_user_in_nagvis, $create_user_in_cacti, $nagvis_role_id, $user_language);
update_user($user_id, stripAccents($user_name), $user_descr, $user_group, $user_password1, $user_password2, $user_type, $user_location, $user_mail, $user_limitation, $old_group_id, $old_name, $create_user_in_nagvis, $create_user_in_cacti, $nagvis_role_id, $user_language, $user_defaultpage);
//message(8,"Update: User location = $user_location",'ok'); // For debug pupose, to be removed
//message(8,"Update: User name = $user_name",'ok'); // For debug pupose, to be removed
}
......@@ -310,6 +273,7 @@ include("../../side.php");
$user_group=mysqli_result($user_name_descr,0,"group_id");
$user_type=mysqli_result($user_name_descr,0,"user_type");
$user_limitation=mysqli_result($user_name_descr,0,"user_limitation");
$user_defaultpage=mysqli_result($user_name_descr,0,"user_defaultpage");
$user_location=mysqli_result($user_name_descr,0,"user_location");
$user_password1="abcdefghijklmnopqrstuvwxyz";
$user_password2="abcdefghijklmnopqrstuvwxyz";
......@@ -437,7 +401,38 @@ include("../../side.php");
<div class="row form-group">
<label class="col-md-3"><?php echo getLabel("label.admin_user.user_lang"); ?></label>
<div class="col-md-9">
<?php echo GetUserLang(); ?>
<?php echo GetUserLang($user_id); ?>
</div>
</div>
<!-- Adding a default page defined by user -->
<div class="row form-group">
<label class="col-md-3"><?php echo getLabel("label.admin_user.user_defaultpage"); ?></label>
<div class="col-md-9">
<?php
global $menus;
$res2 = "<input id='user_defaultpage' class='form-control' type='text' name='user_defaultpage' value='".$user_defaultpage."' onFocus='$(this).autocomplete({source: [";
foreach($menus["menutab"] as $menutab){
if(isset($menutab["link"])){
foreach($menutab["link"] as $menulink) {
if($menulink["target"]=="frame") { $res2 .= '"'.$path_frame.urlencode($menulink['url']).'",'; }
else{$res2 .= '"'.$menulink["url"].'",';}
}
}
if(isset($menutab["menusubtab"])){
foreach($menutab["menusubtab"] as $menusubtab) {
foreach($menusubtab["link"] as $menulink) {
if($menulink["target"]=="frame") { $res2 .= '"'.$path_frame.urlencode($menulink['url']).'",'; }
else{$res2 .= '"'.$menulink["url"].'",';}
}
}
}
}
$res2 = rtrim($res2, ",");
$res2 .= "]})'>";
echo $res2;
?>
</div>
</div>
......
......@@ -40,13 +40,10 @@ include("../../side.php");
$user_mgt_list=retrieve_form_data("user_mgt_list",null);
$user_selected=retrieve_form_data("user_selected",null);
if($action == 'submit')
if(isset($user_mgt_list))
{
switch($user_mgt_list)
{
case "add_user":
echo "<meta http-equiv=refresh content='0;url=add_modify_user.php'>";
break;
case "delete_user":
if (isset($user_selected[0]))
{
......@@ -178,24 +175,8 @@ include("../../side.php");
</tbody>
</table>
</div>
<div class="form-group">
<select class="form-control" name="user_mgt_list" size=1>
<?php
// Get the global table
global $array_user_mgt;
// Get the first array key
reset($array_user_mgt);
// Display the list of management choices
while (list($mgt_name, $mgt_url) = each($array_user_mgt)) {
echo "<option value='$mgt_url'>".getLabel($mgt_name)."</option>";
}
?>
</select>
</div>
<button class="btn btn-primary" type="submit" name="action" value="submit"><?php echo getLabel("action.submit"); ?></button>
<a href="./add_modify_user.php" class="btn btn-success" role="button"><?php echo getLabel("action.add");?></a>
<button class="btn btn-danger" type="submit" name="user_mgt_list" value="delete_user"><?php echo getLabel("action.clear"); ?></button>
</form>
</div>
......
......@@ -37,16 +37,19 @@ include("../../side.php");
$usrid=$_COOKIE['user_id'];
$user_password1= "abcdefghijklmnopqrstuvwxyz";
$user_password2= "abcdefghijklmnopqrstuvwxyz";
$user_defaultpage = mysqli_result(sqlrequest("$database_eonweb","SELECT user_defaultpage FROM users WHERE user_id='".$usrid."'"),0);
if(isset($_POST["update"])) {
$user_password1 = retrieve_form_data("user_password1","");
$user_password2 = retrieve_form_data("user_password2","");
$user_language = retrieve_form_data("user_language","");
$user_defaultpage = retrieve_form_data("user_defaultpage","");
if (($user_password1 != "") && ($user_password1 != null) && ($user_password1 == $user_password2)) {
if($user_password1!="abcdefghijklmnopqrstuvwxyz") {
$user_password = md5($user_password1);
// Insert into eonweb
sqlrequest("$database_eonweb","UPDATE users set user_passwd='$user_password' WHERE user_id='$usrid';");
sqlrequest("$database_eonweb","UPDATE users set user_passwd='$user_password',user_defaultpage='$user_defaultpage' WHERE user_id='$usrid';");
// update password into nagvis if user is in
$bdd = new PDO('sqlite:/srv/eyesofnetwork/nagvis/etc/auth.db');
......@@ -92,6 +95,54 @@ include("../../side.php");
</div>
</div>
</div>
<div class="row form-group">
<label class="col-md-3"><?php echo getLabel("label.admin_user.user_lang"); ?></label>
<div class="col-md-9">
<?php echo GetUserLang($_COOKIE["user_id"]); ?>
</div>
</div>
<div class="row form-group">
<label class="col-md-3"><?php echo getLabel("label.admin_user.user_defaultpage"); ?></label>
<div class="col-md-9">
<?php
global $menus;
$res2 = "<input id='user_defaultpage' class='form-control' type='text' name='user_defaultpage' value='".$user_defaultpage."' onFocus='$(this).autocomplete({source: [";
if(isset($menus["menutab"])){
foreach($menus["menutab"] as $menutab){
$tab_request = "SELECT tab_".$menutab["id"]." FROM groupright WHERE group_id=".$_COOKIE["group_id"].";";
$tab_right = mysqli_result(sqlrequest($database_eonweb, $tab_request),0);
if($tab_right == 0){ continue; }
if(isset($menutab["link"])){
foreach($menutab["link"] as $menulink) {
if($menulink["target"]=="frame") { $res2 .= '"'.$path_frame.urlencode($menulink['url']).'",'; }
else{$res2 .= '"'.$menulink["url"].'",';}
}
}
if(isset($menutab["menusubtab"])){
foreach($menutab["menusubtab"] as $menusubtab) {
foreach($menusubtab["link"] as $menulink) {
if($menulink["target"]=="frame") { $res2 .= '"'.$path_frame.urlencode($menulink['url']).'",'; }
else{$res2 .= '"'.$menulink["url"].'",';}
}
}
}
}
}
else{
foreach($menus["link"] as $menulink) {
$res2 .= '"'.$menulink["url"].'",';
if($menulink["target"]=="frame") { $res2 .= '"'.$path_frame.urlencode($menulink['url']).'",'; }
}
}
$res2 = rtrim($res2, ",");
$res3=$res2;
$res2 .= "]})'>";
echo $res2;
?>
</div>
</div>
<button class='btn btn-primary' type='submit' name='update' value='update'><?php echo getLabel("action.update"); ?></button>
<button id="back_btn" class='btn btn-default' type='button' onclick='history.go(-1);'><?php echo getLabel("action.cancel"); ?></button>
</form>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment