1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268
|
<?php
/*
* Copyright 2005-2016 OCSInventory-NG/OCSInventory-ocsreports contributors.
* See the Contributors file for more details about them.
*
* This file is part of OCSInventory-NG/OCSInventory-ocsreports.
*
* OCSInventory-NG/OCSInventory-ocsreports 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.
*
* OCSInventory-NG/OCSInventory-ocsreports 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 OCSInventory-NG/OCSInventory-ocsreports. if not, write to the
* Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
* MA 02110-1301, USA.
*/
if (AJAX) {
parse_str($protectedPost['ocs']['0'], $params);
$protectedPost += $params;
ob_start();
}
require_once('require/function_config_generale.php');
$form_name = "console";
if ($protectedPost['RESET'] == 'FIRST') {
unset($_SESSION['OCS']['COUNT_CONSOLE']);
}
if ($protectedPost['ADMIN'] == 'ADMIN' && !isset($_SESSION['OCS']['ADMIN_CONSOLE'])) {
$_SESSION['OCS']['ADMIN_CONSOLE'] = 'ADMIN';
} elseif ($protectedPost['ADMIN'] == 'ADMIN' && isset($_SESSION['OCS']['ADMIN_CONSOLE'])) {
unset($_SESSION['OCS']['ADMIN_CONSOLE']);
}
if (is_defined($protectedPost['VISIBLE']) && isset($_SESSION['OCS']['ADMIN_CONSOLE'])) {
insert_update($protectedPost['VISIBLE'], 1, '', 'IVALUE');
}
if (is_defined($protectedPost['NO_VISIBLE']) && isset($_SESSION['OCS']['ADMIN_CONSOLE'])) {
delete($protectedPost['NO_VISIBLE']);
}
if (is_defined($protectedPost['UPDATE_VALUE']) && isset($_SESSION['OCS']['ADMIN_CONSOLE'])) {
$arg = look_config_default_values($protectedPost['UPDATE_VALUE']);
insert_update($protectedPost['UPDATE_VALUE'], $protectedPost[$protectedPost['UPDATE_VALUE']], $arg['ivalue'][$protectedPost['UPDATE_VALUE']], 'IVALUE');
}
require_once('require/function_console.php');
$data_on = define_tab();
$data_tab = show_active_tab($data_on);
echo open_form($form_name);
if (isset($protectedPost["onglet"]) and !isset($data_tab['DATA'][$protectedPost["onglet"]]))
$protectedPost["onglet"]=$data_tab['DEFAULT'];
if ($data_tab['DATA'] != array()){
show_tabs($data_tab['DATA'],$form_name,"onglet",true);
echo '<div class="col col-md-10">';
if ($_SESSION['OCS']['profile']->getConfigValue('CONSOLE') == 'YES'){
echo "<table align='right' border='0'><tr><td colspan=10 align='right'><a href=# OnClick='pag(\"ADMIN\",\"ADMIN\",\"".$form_name."\");'>";
if (isset($_SESSION['OCS']['ADMIN_CONSOLE']) and $_SESSION['OCS']['ADMIN_CONSOLE'] == 'ADMIN')
echo "<span class='glyphicon glyphicon-ok'></span>";
else if($protectedPost['onglet'] != 'MSG')
echo "<span class='glyphicon glyphicon-edit'></span>";
echo "</a></td></tr></table>";
}
if ($data_on['DATA'][$protectedPost['onglet']]){
$fields=list_field($protectedPost['onglet']);
show_console_field($fields,$form_name);
}else{
$array_group="";
$sql_group="select id,name from hardware where deviceid='_SYSTEMGROUP_'";
$res=mysql2_query_secure($sql_group,$_SESSION['OCS']["readServer"]);
while ($value = mysqli_fetch_object($res)){
$array_group[$value->id]=$value->name;
}
if (is_array($array_group)){
if (isset($protectedPost["SUP_PROF"]) and $protectedPost["SUP_PROF"]!=''){
delete($protectedPost['SUP_PROF']);
}
if (isset($protectedPost["Valid_modif"]) and $protectedPost["Valid_modif"] != '') {
$sql_msg="select name from config where name like '%s'";
$arg="GUI_REPORT_MSG%";
$result_msg = mysql2_query_secure($sql_msg,$_SESSION['OCS']["readServer"],$arg);
while($item_msg = mysqli_fetch_object($result_msg)){
$list_name_msg[]=substr($item_msg ->name,14);
}
if (isset($list_name_msg)){
$i=1;
foreach ($list_name_msg as $k=>$v){
if ($v == $i)
$i++;
}
} else {
$i=1;
}
$tab_options=$protectedPost;
if (trim($protectedPost['GROUP']) != "" and is_numeric($protectedPost['GROUP']) and trim($protectedPost['MESSAGE'])!=""){
$sql="insert into config (NAME,IVALUE,TVALUE) values ('%s',%s,'%s')";
$arg=array("GUI_REPORT_MSG".$i,$protectedPost['GROUP'],$protectedPost['MESSAGE']);
mysql2_query_secure( $sql, $_SESSION['OCS']["writeServer"],$arg );
$tab_options['CACHE']='RESET';
$protectedPost['MESSAGE'] = "";
} else {
msg_error($l->g(239));
}
}else{
$tab_options=$protectedPost;
}
$table_name=$protectedPost['onglet'];
$tab_options['table_name']=$table_name;
$tab_options['form_name']=$form_name;
$list_fields=array('GROUP_NAME'=>'h.NAME',
$l->g(915) => 'tvalue',
'SUP'=>'CNAME');
$sql=prepare_sql_tab($list_fields,array('SUP'));
$list_col_cant_del=$list_fields;
$default_fields= $list_fields;
$sql['SQL'] = $sql['SQL'].",c.name as CNAME,ID FROM %s WHERE (c.name like '%s')";
$sql['ARG'][]='config c left join hardware h on c.ivalue=h.id';
$sql['ARG'][]='GUI_REPORT_MSG%';
$tab_options['ARG_SQL']=$sql['ARG'];
$tab_options['LBL_POPUP']['SUP']=$l->g(919);
$tab_options['LBL']['GROUP_NAME']=$l->g(49);
ajaxtab_entete_fixe($list_fields,$default_fields,$tab_options,$list_col_cant_del);
echo "<input type='submit' name='NEW' id='NEW' value='".$l->g(617)."' class='btn btn-success' >";
if ($protectedPost["NEW"]){
$name_field=array("GROUP","MESSAGE");
$tab_name=array($l->g(577).": ",$l->g(449).":");
$type_field= array(2,1);
$value_field=array($array_group,'');
$tab_typ_champ=show_field($name_field,$type_field,$value_field);
foreach ($tab_typ_champ as $id=>$values){
$tab_typ_champ[$id]['CONFIG']['SIZE']=20;
}
if (isset($tab_typ_champ)){
echo "<p>";
modif_values($tab_name,$tab_typ_champ,$tab_hidden);
echo "</p>";
}
}
}
}
echo "</div>";
echo "<input type=hidden name='ADMIN' value='' id='ADMIN'>";
echo "<input type=hidden name='VISIBLE' value='' id='VISIBLE'>";
echo "<input type=hidden name='NO_VISIBLE' value='' id='NO_VISIBLE'>";
echo "<input type=hidden name='VALID_MODIF' value='' id='VALID_MODIF'>";
echo "<input type=hidden name='SHOW_ME' value='' id='SHOW_ME'>";
echo "<input type=hidden name='UPDATE_VALUE' value='' id='UPDATE_VALUE'>";
}else
echo "<table align=center><tr><td align=center><img src='image/fond.png'></td></tr></table>";
if (isset($protectedPost["onglet"]) and isset($protectedPost["old_onglet"])
and $protectedPost["onglet"]!=$protectedPost["old_onglet"])
unset($protectedPost["SHOW_ME"],$protectedPost["SHOW_ME_SAUV"]);
if (is_defined($protectedPost["SHOW_ME"]) && $protectedPost["SHOW_ME_SAUV"] != "" && $protectedPost["SHOW_ME"] != $protectedPost["SHOW_ME_SAUV"]) {
unset($protectedPost["SHOW_ME_SAUV"]);
}
if (is_defined($protectedPost["SHOW_ME_SAUV"]) && $protectedPost["SHOW_ME"] == "") {
$protectedPost["SHOW_ME"] = $protectedPost["SHOW_ME_SAUV"];
}
if ((is_defined($protectedPost["SHOW_ME"]))) {
$array_fields = array_values($table_field[$protectedPost["SHOW_ME"]]);
echo "<input type=hidden name='SHOW_ME_SAUV' value='" . $protectedPost["SHOW_ME"] . "' id='SHOW_ME_SAUV'>";
$table_name = $protectedPost["SHOW_ME"];
$tab_options = $protectedPost;
$tab_options['form_name'] = $form_name;
$tab_options['table_name'] = $table_name;
if (!isset($sql_field[$protectedPost["SHOW_ME"]]['SQL'])) {
$sql_field[$protectedPost["SHOW_ME"]]['SQL'] = "SELECT %s FROM %s %s ";
}
$list_fields = $table_field[$protectedPost["SHOW_ME"]];
$list_fields[$l->g(1120)] = 'c';
foreach ($table_field[$protectedPost["SHOW_ME"]] as $lbl => $value) {
$recup_list_add_field[] = $value;
}
$sql_field[$protectedPost["SHOW_ME"]]['ARG'][0] = "count(*) c," . implode(',', $recup_list_add_field);
if (!preg_match("/where/i", $sql_field[$protectedPost["SHOW_ME"]]['ARG'][2])) {
$sql_field[$protectedPost["SHOW_ME"]]['SQL'] = "SELECT %s FROM %s WHERE %s";
} else {
$sql_field[$protectedPost["SHOW_ME"]]['ARG'][2] .= " AND ";
}
//restriction on computer id
if (isset($myids)) {
if (mb_strtoupper($sql_field[$protectedPost["SHOW_ME"]]['ARG'][1]) == "HARDWARE") {
$sql_field[$protectedPost["SHOW_ME"]]['ARG'][2] .= "id ";
} else {
$sql_field[$protectedPost["SHOW_ME"]]['ARG'][2] .= "hardware_id";
}
$sql_field[$protectedPost["SHOW_ME"]]['ARG'][2] .= " in (" . implode(',', $myids['ARG']) . ") AND ";
}
$sql_field[$protectedPost["SHOW_ME"]]['ARG'][2] .= $recup_list_add_field[0] . " is not null GROUP BY " . implode(',', $recup_list_add_field);
$tab_options['SQL_COUNT'] = "SELECT %s FROM %s %s";
$tab_options['ARG_SQL_COUNT'] = array("count(distinct " . implode(',', $recup_list_add_field) . ") count_nb_ligne",
$sql_field[$protectedPost["SHOW_ME"]]['ARG'][1], $sql_field[$protectedPost["SHOW_ME"]]['ARG'][2]);
$list_col_cant_del = $list_fields;
$default_fields = $list_fields;
$tab_options['ARG_SQL'] = $sql_field[$protectedPost["SHOW_ME"]]['ARG'];
if (isset($multi_search[$protectedPost["SHOW_ME"]])) {
$tab_options['LIEN_LBL'][$l->g(1120)] = 'index.php?' . PAG_INDEX . '=' . $pages_refs['ms_multi_search'] . '&fields=';
$tab_options['LIEN_LBL'][$l->g(1120)] .= $multi_search[$protectedPost["SHOW_ME"]]['FIELD'] . "&comp=" . $multi_search[$protectedPost["SHOW_ME"]]['COMP'] . "&values=";
$tab_options['LIEN_CHAMP'][$l->g(1120)] = $array_fields[0];
}
ajaxtab_entete_fixe($list_fields, $default_fields, $tab_options, $list_col_cant_del);
}
echo close_form();
//show messages
if ($_SESSION['OCS']['profile']->getRestriction('GUI') == "YES") {
$info_msg = look_config_default_values('GUI_REPORT_MSG%', 'LIKE');
if (is_array($info_msg['ivalue'])) {
$list_id_groups = implode(',', $info_msg['ivalue']);
}
if ($list_id_groups != "") {
$sql_my_msg = "select distinct g_c.group_id groups
FROM accountinfo a ,groups_cache g_c
WHERE g_c.HARDWARE_ID=a.HARDWARE_ID
AND g_c.GROUP_ID in (" . $list_id_groups . ")";
if (is_defined($_SESSION['OCS']['mesmachines'])) {
$sql_my_msg .= " AND " . $_SESSION['OCS']['mesmachines'];
}
$result_my_msg = mysqli_query($_SESSION['OCS']["readServer"], $sql_my_msg);
while ($item_my_msg = mysqli_fetch_object($result_my_msg)) {
foreach ($info_msg['ivalue'] as $key => $value) {
if ($value == $item_my_msg->groups) {
$msg_group[$key] = $info_msg['tvalue'][$key];
}
}
}
if (isset($msg_group) && $msg_group != '') {
msg_warning(implode('<br>', $msg_group));
}
}
}
if (AJAX) {
ob_end_clean();
if (isset($sql_field[$protectedPost["SHOW_ME"]]['SQL'])) {
tab_req($list_fields, $default_fields, $list_col_cant_del, $sql_field[$protectedPost["SHOW_ME"]]['SQL'], $tab_options);
} else {
tab_req($list_fields, $default_fields, $list_col_cant_del, $sql['SQL'], $tab_options);
}
}
?>
|