File: cd_configuration.php

package info (click to toggle)
ocsinventory-server 2.5%2Bdfsg1-1
  • links: PTS, VCS
  • area: main
  • in suites: buster
  • size: 7,088 kB
  • sloc: php: 27,462; perl: 8,241; sh: 1,680; sql: 1,355; xml: 1,041; makefile: 34
file content (233 lines) | stat: -rw-r--r-- 9,594 bytes parent folder | download | duplicates (2)
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
<?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.
 */
require('require/function_telediff.php');

if (isset($protectedGet["actgrp"])) {
    //this id is it a group?
    $reqGroups = "SELECT h.id id
					  FROM hardware h
					  WHERE h.deviceid='_SYSTEMGROUP_' ";
    //If you hav'nt permission => see only visible groups
    if (!($_SESSION['OCS']['profile']->getConfigValue('GROUPS') == "YES")) {
        $reqGroups .= " and h.workgroup = 'GROUP_4_ALL'";
    }
    $resGroups = mysql2_query_secure($reqGroups, $_SESSION['OCS']["readServer"]);
    $valGroups = mysqli_fetch_array($resGroups);
    if (isset($valGroups['id'])) {
        $reqDelete = "DELETE FROM groups_cache WHERE hardware_id=%s AND group_id=%s";

        if ($protectedGet["actgrp"] == 0) {
            $reqDelete .= " AND static<>0";
        }
        $argDelete = array($systemid, $protectedGet["grp"]);
        $reqInsert = "INSERT INTO groups_cache(hardware_id, group_id, static)
								VALUES (%s, %s, %s)";
        $argInsert = array($systemid, $protectedGet["grp"], $protectedGet["actgrp"]);
        mysql2_query_secure($reqDelete, $_SESSION['OCS']["writeServer"], $argDelete);
        if ($protectedGet["actgrp"] != 0) {
            mysql2_query_secure($reqInsert, $_SESSION['OCS']["writeServer"], $argInsert);
        }
    }
}

$queryDetails = "SELECT * FROM devices WHERE hardware_id=%s";
$argDetail = $systemid;
$resultDetails = mysql2_query_secure($queryDetails, $_SESSION['OCS']["readServer"], $argDetail);
$form_name = 'config_mach';

echo open_form($form_name, '', '', 'form-horizontal');
?>

<div class="row margin-top30">
    <div class="col-md-12">
        <?php
        if ($_SESSION['OCS']['profile']->getConfigValue('CONFIG') == "YES") {
            echo "<a href=\"index.php?" . PAG_INDEX . "=" . $pages_refs['ms_custom_param'] . "&head=1&idchecked=" . $systemid . "&origine=machine\" alt=". $l->g(2122) ." class='btn btn-success'>". $l->g(2122) ."</a>";
        }
        ?>
    </div>
</div></br></br>
<div class="row">
    <div class="col-md-4 col-md-offset-2">
        <select name="groupcombo" id="groupcombo" class="form-control">

        <?php
        $hrefBase = "index.php?" . PAG_INDEX . "=" . $pages_refs['ms_computer'] . "&head=1&systemid=" . urlencode($systemid) . "&option=cd_configuration";

        $reqGroups = "SELECT h.name,h.id,h.workgroup
					  FROM hardware h,groups g
					  WHERE  g.hardware_id=h.id  and h.deviceid='_SYSTEMGROUP_'";
        if (!($_SESSION['OCS']['profile']->getConfigValue('GROUPS') == "YES")) {
            $reqGroups .= " and workgroup = 'GROUP_4_ALL'";
        }
        $reqGroups .= " order by h.name";
        $resGroups = mysql2_query_secure($reqGroups, $_SESSION['OCS']["readServer"]);
        while ($valGroups = mysqli_fetch_array($resGroups)) {
            echo "<option value='" . $valGroups["id"] . "'>" . $valGroups["name"] . "</option>";
        }
        ?>
        </select>
    </div>
    <div class="col-md-4">
        <script>
            function url(id) {
                window.location="<?php echo $hrefBase; ?>&actgrp=1&grp=" + id.options[id.selectedIndex].value;
            }
        </script>
        <a class="btn btn-success" OnClick=url(document.getElementById("groupcombo")) ><?php echo $l->g(589) ?></a>
    </div>
</div></br></br>

<?php
while ($item = mysqli_fetch_array($resultDetails, MYSQLI_ASSOC)) {
    $optPerso[$item["NAME"]]["IVALUE"] = $item["IVALUE"];
    $optPerso[$item["NAME"]]["TVALUE"] = $item["TVALUE"];
}
$field_name = array('DOWNLOAD', 'DOWNLOAD_CYCLE_LATENCY', 'DOWNLOAD_PERIOD_LENGTH', 'DOWNLOAD_FRAG_LATENCY',
    'DOWNLOAD_PERIOD_LATENCY', 'DOWNLOAD_TIMEOUT', 'PROLOG_FREQ', 'SNMP');
$optdefault = look_config_default_values($field_name);

//IPDISCOVER

if (isset($optPerso["IPDISCOVER"])) {
    if ($optPerso["IPDISCOVER"]["IVALUE"] == 0) {
        $returnIP = $l->g(490);
    } else if ($optPerso["IPDISCOVER"]["IVALUE"] == 2) {
        $returnIP = $l->g(491) . " " . $optPerso["IPDISCOVER"]["TVALUE"];
    } else if ($optPerso["IPDISCOVER"]["IVALUE"] == 1) {
        $returnIP = $l->g(492) . " " . $optPerso["IPDISCOVER"]["TVALUE"];
    }
} else {
    $returnIP = $l->g(493);
}
optperso("IPDISCOVER", $l->g(489), "IPDISCOVER", $optPerso, '', $returnIP);

//FREQUENCY
if (isset($optPerso["FREQUENCY"])) {
    if ($optPerso["FREQUENCY"]["IVALUE"] == 0) {
        $returnFrequency = $l->g(485);
    } else if ($optPerso["FREQUENCY"]["IVALUE"] == -1) {
        $returnFrequency = $l->g(486);
    } else {
        $returnFrequency = $l->g(495) . " " . $optPerso["FREQUENCY"]["IVALUE"] . " " . $l->g(496);
    }
} else {
    $returnFrequency = $l->g(497);
}
optperso("FREQUENCY", $l->g(494), "FREQUENCY", $optPerso, '', $returnFrequency);

//DOWNLOAD_SWITCH
if (isset($optPerso["DOWNLOAD_SWITCH"])) {
    if ($optPerso["DOWNLOAD_SWITCH"]["IVALUE"] == 0) {
        $returnDL = $l->g(733);
    } else if ($optPerso["DOWNLOAD_SWITCH"]["IVALUE"] == 1) {
        $returnDL = $l->g(205);
    } else {
        $returnDL = "";
    }
} else {
    if ($optdefault['ivalue']["DOWNLOAD"] == 1) {
        $returnDL = $l->g(205);
    } else {
        $returnDL = $l->g(733);
    }
}
optperso("DOWNLOAD", $l->g(417), "DOWNLOAD", $optPerso, '', $returnDL);

//DOWNLOAD_CYCLE_LATENCY
optperso("DOWNLOAD_CYCLE_LATENCY", $l->g(720), "DOWNLOAD_CYCLE_LATENCY", $optPerso, $optdefault['ivalue']["DOWNLOAD_CYCLE_LATENCY"], $l->g(511));

//DOWNLOAD_FRAG_LATENCY
optperso("DOWNLOAD_FRAG_LATENCY", $l->g(721), "DOWNLOAD_FRAG_LATENCY", $optPerso, $optdefault['ivalue']["DOWNLOAD_FRAG_LATENCY"], $l->g(511));


//DOWNLOAD_PERIOD_LATENCY
optperso("DOWNLOAD_PERIOD_LATENCY", $l->g(722), "DOWNLOAD_PERIOD_LATENCY", $optPerso, $optdefault['ivalue']["DOWNLOAD_PERIOD_LATENCY"], $l->g(511));

//DOWNLOAD_PERIOD_LENGTH
optperso("DOWNLOAD_PERIOD_LENGTH", $l->g(723), "DOWNLOAD_PERIOD_LENGTH", $optPerso, $optdefault['ivalue']["DOWNLOAD_PERIOD_LENGTH"]);

//PROLOG_FREQ
optperso("PROLOG_FREQ", $l->g(724), "PROLOG_FREQ", $optPerso, $optdefault['ivalue']["PROLOG_FREQ"], $l->g(730));

//PROLOG_FREQ
optperso("DOWNLOAD_TIMEOUT", $l->g(424), "DOWNLOAD_TIMEOUT", $optPerso, $optdefault['ivalue']["DOWNLOAD_TIMEOUT"], $l->g(496));

//DOWNLOAD_SWITCH
optperso("SNMP_SWITCH", $l->g(1197), "SNMP_SWITCH", $optPerso, '', ($optPerso["SNMP_SWITCH"]["IVALUE"] == 1) ? $l->g(733) : $l->g(205));

//GROUPS
$sql_groups = "SELECT static, name, group_id,workgroup
				FROM groups_cache g, hardware h WHERE g.hardware_id=%s AND h.id=g.group_id";
$arg_groups = $systemid;
$resGroups = mysql2_query_secure($sql_groups, $_SESSION['OCS']["readServer"], $arg_groups);


if (mysqli_num_rows($resGroups) > 0) {
    while ($valGroups = mysqli_fetch_array($resGroups)) {

?>

<div class="row" xmlns="http://www.w3.org/1999/html">
    <div class="col-md-12">
        <p>
<?php
        if ($_SESSION['OCS']['profile']->getConfigValue('GROUPS') == "YES" || $valGroups["workgroup"] == "GROUP_4_ALL") {
            echo $l->g(607)." <a href='index.php?" . PAG_INDEX . "=" . $pages_refs['ms_group_show'] . "&head=1&systemid=" . $valGroups["group_id"] . "' target='_blank'>" . $valGroups["name"] . "</a> (";
        } else {
            echo "<strong>" . $valGroups["name"] . "</strong>";
        }

        switch ($valGroups["static"]) {
            case 0: echo "<span class='text-success'>" . $l->g(81) . " " . $l->g(596) . "</span>";
                break;
            case 1: echo "<span class='text-info'>" . $l->g(610) . "</span>";
                break;
            case 2: echo "<span class='text-danger'>" . $l->g(597) . "</span>";
                break;
        }

        echo ")";
        echo "<br />";

        if ($_SESSION['OCS']['profile']->getConfigValue('GROUPS') == "YES" || $valGroups["workgroup"] == "GROUP_4_ALL") {
            $hrefBase = "index.php?" . PAG_INDEX . "=" . $pages_refs['ms_computer'] . "&head=1&systemid=" . urlencode($systemid) . "&option=cd_configuration&grp=" . $valGroups["group_id"];
            switch ($valGroups["static"]) {
                case 0: echo "<a href='$hrefBase&actgrp=1'>" . $l->g(598) . "</a> / <a href='$hrefBase&actgrp=2'>" . $l->g(600) . "</a>";
                    break;
                case 1: echo "<a href='$hrefBase&actgrp=0' alt='" . $l->g(818) . "'><span class='glyphicon glyphicon-remove delete-span delete-span-xs'></span></a>";
                    break;
                case 2: echo "<a href='$hrefBase&actgrp=1'>" . $l->g(598) . "</a> / <a href='$hrefBase&actgrp=0'>" . $l->g(41) . "</a>";
                    break;
            }
        }
        ?>
        </p>
    </div>
</div>

        <?php
    }
}
echo close_form();
?>