1 | <? |
---|
2 | |
---|
3 | function addNetwork($addressNetwork, $nameNetwork, $interface, $routeur) { |
---|
4 | $link = mysql_connect($GLOBALS['hostDB'], $GLOBALS['userDB'], $GLOBALS['passwdDB']); |
---|
5 | if (!$link) { |
---|
6 | $buffer = "Connexion [FAILED]: " . mysql_error() ; |
---|
7 | return $buffer; |
---|
8 | } |
---|
9 | |
---|
10 | |
---|
11 | $db_selected = @mysql_select_db($GLOBALS['nameDB'], $link); |
---|
12 | if (!$db_selected) { |
---|
13 | $buffer .= "Impossible de sélectionner la base de données :$nameDB" . mysql_error(); |
---|
14 | } |
---|
15 | |
---|
16 | |
---|
17 | |
---|
18 | //Add switch |
---|
19 | $sql = "INSERT INTO NETWORK VALUE('$addressNetwork', '$nameNetwork', '$interface', '$routeur');"; |
---|
20 | |
---|
21 | if (mysql_query($sql, $link)) { |
---|
22 | $buffer = 1; |
---|
23 | } else { |
---|
24 | $buffer = "CREATE NETWORK $addressNetwork $nameNetwork : [FAILED] :" . mysql_error() ; |
---|
25 | } |
---|
26 | |
---|
27 | return $buffer; |
---|
28 | } |
---|
29 | |
---|
30 | |
---|
31 | |
---|
32 | function selectNetwork($filter) { |
---|
33 | //connect DB |
---|
34 | $link = mysql_connect($GLOBALS['hostDB'], $GLOBALS['userDB'], $GLOBALS['passwdDB']); |
---|
35 | if (!$link) { |
---|
36 | $buffer = "Connexion [FAILED]: " . mysql_error() ; |
---|
37 | return $buffer; |
---|
38 | } |
---|
39 | |
---|
40 | |
---|
41 | $db_selected = @mysql_select_db($GLOBALS['nameDB'], $link); |
---|
42 | if (!$db_selected) { |
---|
43 | $buffer .= "Impossible de sélectionner la base de données :$nameDB" . mysql_error(); |
---|
44 | } |
---|
45 | |
---|
46 | |
---|
47 | if (empty($filter)) { |
---|
48 | $sql = "SELECT * FROM NETWORK"; |
---|
49 | }else{ |
---|
50 | $sql = "SELECT * FROM NETWORK WHERE $filter ;" ; |
---|
51 | } |
---|
52 | |
---|
53 | |
---|
54 | if ($result = mysql_query($sql, $link)) { |
---|
55 | //test if $return is_array |
---|
56 | return $result ; |
---|
57 | |
---|
58 | } else { |
---|
59 | $buffer = "SELECT NETWORK : [FAILED] :" . mysql_error() ; |
---|
60 | return $buffer ; |
---|
61 | } |
---|
62 | |
---|
63 | |
---|
64 | } |
---|
65 | |
---|
66 | |
---|
67 | |
---|
68 | |
---|
69 | function delNetwork($addressNetwork) { |
---|
70 | |
---|
71 | $buffer = ""; |
---|
72 | |
---|
73 | //connect DB |
---|
74 | $link = mysql_connect($GLOBALS['hostDB'], $GLOBALS['userDB'], $GLOBALS['passwdDB']); |
---|
75 | if (!$link) { |
---|
76 | $buffer = "Connexion [FAILED]: " . mysql_error() ; |
---|
77 | return $buffer; |
---|
78 | } |
---|
79 | |
---|
80 | |
---|
81 | $db_selected = @mysql_select_db($GLOBALS['nameDB'], $link); |
---|
82 | if (!$db_selected) { |
---|
83 | $buffer .= "Impossible de sélectionner la base de données :$nameDB" . mysql_error(); |
---|
84 | } |
---|
85 | |
---|
86 | |
---|
87 | //del switch from SERVICESWITCH |
---|
88 | $sql = "DELETE FROM NETWORK WHERE idNetwork='$addressNetwork'"; |
---|
89 | if (mysql_query($sql, $link)) { |
---|
90 | $buffer .= "DELETE NETWORK $hostname : [OK]<BR />"; |
---|
91 | } else { |
---|
92 | $buffer = "DELETE NETWORK $hostname : [FAILED] :" . mysql_error() ; |
---|
93 | return $buffer; |
---|
94 | } |
---|
95 | |
---|
96 | |
---|
97 | return $buffer; |
---|
98 | } |
---|
99 | |
---|
100 | |
---|
101 | ?> |
---|