ryxeo-glpi-git / front / networking.port.php @ b67d8923
Historique | Voir | Annoter | Télécharger (6,55 ko)
1 |
<?php
|
---|---|
2 |
/*
|
3 |
* @version $Id: networking.port.php 7763 2009-01-06 18:44:50Z moyo $
|
4 |
-------------------------------------------------------------------------
|
5 |
GLPI - Gestionnaire Libre de Parc Informatique
|
6 |
Copyright (C) 2003-2009 by the INDEPNET Development Team.
|
7 |
|
8 |
http://indepnet.net/ http://glpi-project.org
|
9 |
-------------------------------------------------------------------------
|
10 |
|
11 |
LICENSE
|
12 |
|
13 |
This file is part of GLPI.
|
14 |
|
15 |
GLPI is free software; you can redistribute it and/or modify
|
16 |
it under the terms of the GNU General Public License as published by
|
17 |
the Free Software Foundation; either version 2 of the License, or
|
18 |
(at your option) any later version.
|
19 |
|
20 |
GLPI is distributed in the hope that it will be useful,
|
21 |
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
22 |
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
23 |
GNU General Public License for more details.
|
24 |
|
25 |
You should have received a copy of the GNU General Public License
|
26 |
along with GLPI; if not, write to the Free Software
|
27 |
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
28 |
--------------------------------------------------------------------------
|
29 |
*/
|
30 |
|
31 |
// ----------------------------------------------------------------------
|
32 |
// Original Author of file:
|
33 |
// Purpose of file:
|
34 |
// ----------------------------------------------------------------------
|
35 |
|
36 |
|
37 |
$NEEDED_ITEMS=array("networking","computer","printer","phone","peripheral"); |
38 |
|
39 |
define('GLPI_ROOT', '..'); |
40 |
include (GLPI_ROOT . "/inc/includes.php"); |
41 |
|
42 |
//print_r($_POST);
|
43 |
|
44 |
|
45 |
if (isset($_SERVER['HTTP_REFERER'])) |
46 |
$REFERER=$_SERVER['HTTP_REFERER']; |
47 |
|
48 |
if (isset($_GET["referer"])) $REFERER=$_GET["referer"]; |
49 |
else if (isset($_POST["referer"])) $REFERER=$_POST["referer"]; |
50 |
|
51 |
$REFERER=rawurldecode($REFERER); |
52 |
|
53 |
$REFERER=preg_replace("/&/","&",$REFERER); |
54 |
$REFERER=preg_replace("/&/","&",$REFERER); |
55 |
|
56 |
$ADDREFERER=""; |
57 |
if (!ereg("&referer=",$_SERVER['HTTP_REFERER']))$ADDREFERER="&referer=".urlencode($REFERER); |
58 |
|
59 |
$np=new Netport(); |
60 |
if(isset($_POST["add"])){ |
61 |
checkRight("networking","w"); |
62 |
|
63 |
unset($_POST["referer"]); |
64 |
|
65 |
// Is a preselected mac adress selected ?
|
66 |
if (isset($_POST['pre_mac'])){ |
67 |
if (!empty($_POST['pre_mac'])) |
68 |
$_POST['ifmac']=$_POST['pre_mac']; |
69 |
unset($_POST['pre_mac']); |
70 |
|
71 |
} |
72 |
|
73 |
|
74 |
if (!isset($_POST["several"])){ |
75 |
$np->add($_POST); |
76 |
logEvent(0, "networking", 5, "inventory", $_SESSION["glpiname"]." ".$LANG["log"][70]); |
77 |
glpi_header($_SERVER['HTTP_REFERER'].$ADDREFERER); |
78 |
} |
79 |
else {
|
80 |
$input=$_POST; |
81 |
unset($input['several']); |
82 |
unset($input['from_logical_number']); |
83 |
unset($input['to_logical_number']); |
84 |
for ($i=$_POST["from_logical_number"];$i<=$_POST["to_logical_number"];$i++){ |
85 |
$add=""; |
86 |
if ($i<10) $add="0"; |
87 |
$input["logical_number"]=$i; |
88 |
$input["name"]=$_POST["name"].$add.$i; |
89 |
unset($np->fields["ID"]); |
90 |
$np->add($input); |
91 |
} |
92 |
logEvent(0, "networking", 5, "inventory", $_SESSION["glpiname"]." ".($_POST["to_logical_number"]-$_POST["from_logical_number"]+1)." ".$LANG["log"][71]); |
93 |
glpi_header($_SERVER['HTTP_REFERER'].$ADDREFERER); |
94 |
} |
95 |
|
96 |
} |
97 |
else if(isset($_POST["delete"])) |
98 |
{ |
99 |
checkRight("networking","w"); |
100 |
$np->delete($_POST); |
101 |
logEvent(0, "networking", 5, "inventory", $_SESSION["glpiname"]." ".$LANG["log"][73]); |
102 |
glpi_header(preg_replace("/&/","&",rawurldecode($_POST["referer"]))); |
103 |
} |
104 |
else if(isset($_POST["delete_several"])) |
105 |
{ |
106 |
checkRight("networking","w"); |
107 |
if (isset($_POST["del_port"])&&count($_POST["del_port"])) |
108 |
foreach ($_POST["del_port"] as $port_id => $val){ |
109 |
$np->delete(array("ID"=>$port_id)); |
110 |
} |
111 |
|
112 |
logEvent(0, "networking", 5, "inventory", $_SESSION["glpiname"]." ".$LANG["log"][74]); |
113 |
glpi_header($_SERVER['HTTP_REFERER']); |
114 |
} |
115 |
else if(isset($_POST["move"])) |
116 |
{ |
117 |
checkRight("networking","w"); |
118 |
if (isset($_POST["del_port"])&&count($_POST["del_port"])) |
119 |
foreach ($_POST["del_port"] as $port_id => $val){ |
120 |
if ($np->getFromDB($port_id)){ |
121 |
$input=array(); |
122 |
$input['ID']=$port_id; |
123 |
$input['on_device']=$_POST["device"]; |
124 |
$np->update($input); |
125 |
} |
126 |
} |
127 |
|
128 |
logEvent(0, "networking", 5, "inventory", $_SESSION["glpiname"]." ".$LANG["log"][75]); |
129 |
glpi_header($_SERVER['HTTP_REFERER']); |
130 |
} |
131 |
else if(isset($_POST["update"])) |
132 |
{ |
133 |
checkRight("networking","w"); |
134 |
|
135 |
$np->update($_POST); |
136 |
glpi_header($_SERVER['HTTP_REFERER'].$ADDREFERER); |
137 |
} |
138 |
else if (isset($_POST["connect"])){ |
139 |
if (isset($_POST["dport"])&&count($_POST["dport"])) |
140 |
foreach ($_POST["dport"] as $sport => $dport){ |
141 |
if($sport && $dport){ |
142 |
makeConnector($sport,$dport); |
143 |
} |
144 |
} |
145 |
glpi_header($_SERVER['HTTP_REFERER']); |
146 |
} |
147 |
else if (isset($_GET["disconnect"])){ |
148 |
checkRight("networking","w"); |
149 |
if (isset($_GET["ID"])){ |
150 |
removeConnector($_GET["ID"]); |
151 |
$fin=""; |
152 |
if (isset($_GET["sport"])) $fin="?sport=".$_GET["sport"]; |
153 |
|
154 |
glpi_header($_SERVER['HTTP_REFERER'].$fin); |
155 |
} |
156 |
|
157 |
glpi_header($_SERVER['HTTP_REFERER']); |
158 |
} |
159 |
else if(isset($_POST["assign_vlan_several"])) |
160 |
{ |
161 |
checkRight("networking","w"); |
162 |
if ($_POST["vlan"]>0){ |
163 |
if (isset($_POST["del_port"])&&count($_POST["del_port"])) |
164 |
foreach ($_POST["del_port"] as $port_id => $val){ |
165 |
assignVlan($port_id,$_POST["vlan"]); |
166 |
} |
167 |
|
168 |
logEvent(0, "networking", 5, "inventory", $_SESSION["glpiname"]." ".$LANG["log"][78]); |
169 |
} |
170 |
glpi_header($_SERVER['HTTP_REFERER']); |
171 |
} |
172 |
else if (isset($_POST['assign_vlan'])){ |
173 |
checkRight("networking","w"); |
174 |
|
175 |
if (isset($_POST["vlan"])&&$_POST["vlan"]>0){ |
176 |
assignVlan($_POST["ID"],$_POST["vlan"]); |
177 |
logEvent(0, "networking", 5, "inventory", $_SESSION["glpiname"]." ".$LANG["log"][77]); |
178 |
} |
179 |
glpi_header($_SERVER['HTTP_REFERER'].$ADDREFERER); |
180 |
} |
181 |
else if(isset($_POST["unassign_vlan_several"])) |
182 |
{ |
183 |
checkRight("networking","w"); |
184 |
if ($_POST["vlan"]>0){ |
185 |
if (isset($_POST["del_port"])&&count($_POST["del_port"])) |
186 |
foreach ($_POST["del_port"] as $port_id => $val){ |
187 |
unassignVlan($port_id,$_POST["vlan"]); |
188 |
} |
189 |
|
190 |
logEvent(0, "networking", 5, "inventory", $_SESSION["glpiname"]." ".$LANG["log"][80]); |
191 |
} |
192 |
glpi_header($_SERVER['HTTP_REFERER']); |
193 |
} |
194 |
else if (isset($_GET['unassign_vlan'])){ |
195 |
checkRight("networking","w"); |
196 |
|
197 |
unassignVlanbyID($_GET['ID']); |
198 |
logEvent(0, "networking", 5, "inventory", $_SESSION["glpiname"]." ".$LANG["log"][79]); |
199 |
glpi_header($_SERVER['HTTP_REFERER'].$ADDREFERER); |
200 |
} |
201 |
else
|
202 |
{ |
203 |
if(empty($_GET["on_device"])) $_GET["on_device"] =""; |
204 |
if(empty($_GET["device_type"])) $_GET["device_type"] =""; |
205 |
if(empty($_GET["several"])) $_GET["several"] =""; |
206 |
|
207 |
checkRight("networking","w"); |
208 |
commonHeader($LANG["title"][6],$_SERVER['PHP_SELF'],"inventory"); |
209 |
|
210 |
if(isset($_GET["ID"])) |
211 |
{ |
212 |
showNetportForm($_SERVER['PHP_SELF'],$_GET["ID"],$_GET["on_device"],$_GET["device_type"],$_GET["several"]); |
213 |
} |
214 |
else
|
215 |
{ |
216 |
showNetportForm($_SERVER['PHP_SELF'],"",$_GET["on_device"],$_GET["device_type"],$_GET["several"]); |
217 |
} |
218 |
commonFooter(); |
219 |
} |
220 |
|
221 |
?>
|
222 |
|