DasErsteDE: handle rating attribute, ignore end times for now, leads to DataStore...
[nonametv.git] / web-admin / editnetwork.php
blob12efcb3c301b6972579377cb7d11a76498b84d93
1 <?php
3 require "config.php";
4 require "common.php";
5 require "mysql.php";
6 require "epgservers.php";
7 require "networks.php";
9 $debug=false;
11 $action='none';
12 $found = false;
14 //
15 // connect to main database
16 //
17 switch( $dconf['dbtype'] ){
18 case 'mysql':
19 $myc = sql_doconnect();
20 if( !$myc ) exit;
21 break;
25 <html>
26 <head>
27 <title>Network details</title>
28 <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
29 <link href="css/nonametv.css" rel=stylesheet>
30 <script language="JavaScript1.2" src="js/common.js"></script>
31 </head>
32 <body bgcolor="#FFFFFF" text="#000000">
34 <?php
36 function networkform( $es )
38 global $action;
39 global $dconf;
41 print "<h1>Edit details for network: " . $es['name'] . "</h1>\n";
42 print "<form name=network action=\"editnetwork.php\" method=post>\n";
43 switch( $action ){
44 case 'none':
45 case 'add':
46 case 'update':
47 case 'delete':
48 print " <input type=\"hidden\" name=\"id\" value=\"" . $es['id'] . "\">\n";
49 break;
52 print " <table>\n";
54 print " <tr class=\"tableTitle\">\n";
55 print " <td colspan=\"2\">General details</td>\n";
56 print " </tr>\n";
58 print " <tr>\n";
59 print " <td class=\"tableBody\">\n";
60 print " <div align=\"right\">ID</div>\n";
61 print " </td>\n";
62 print " <td class=\"tableBody\">";
63 switch( $action ){
64 case 'none':
65 case 'add':
66 case 'update':
67 case 'delete':
68 print $es['id'];
69 break;
70 case 'new':
71 print "<input type=\"text\" name=\"id\" value=\"" . $es['id'] . "\" size=\"12\" maxlength=\"12\">\n";
72 break;
74 print "</td>\n";
75 print " </tr>\n";
77 print " <tr>\n";
78 print " <td class=\"tableBody\">\n";
79 print " <div align=\"right\">Active</div>\n";
80 print " </td>\n";
81 print " <td class=\"tableBody\">\n";
82 print " <input type=\"checkbox\" name=\"active\" value=\"1\"" ;
83 if( $es['active'] == '1' ) print " checked";
84 print "> check if you want to make this network active\n";
85 print " </td>\n";
86 print " </tr>\n";
88 print " <tr>\n";
89 print " <td class=\"tableBody\">\n";
90 print " <div align=\"right\">EPG server</div>\n";
91 print " </td>\n";
92 print " <td class=\"tableBody\">" . $es['epgserver'] . "</td>\n";
93 print " </tr>\n";
95 print " <tr>\n";
96 print " <td class=\"tableBody\">\n";
97 print " <div align=\"right\">Name</div>\n";
98 print " </td>\n";
99 print " <td class=\"tableBody\">\n";
100 print " <input type=\"text\" name=\"name\" value=\"" . $es['name'] . "\" size=\"100\" maxlength=\"100\">\n";
101 print " </td>\n";
102 print " </tr>\n";
104 print " <tr>\n";
105 print " <td class=\"tableBody\">\n";
106 print " <div align=\"right\">Operator</div>\n";
107 print " </td>\n";
108 print " <td class=\"tableBody\">\n";
109 print " <input type=\"text\" name=\"operator\" value=\"" . $es['operator'] . "\" size=\"100\" maxlength=\"100\">\n";
110 print " </td>\n";
111 print " </tr>\n";
113 print " <tr>\n";
114 print " <td class=\"tableBody\">\n";
115 print " <div align=\"right\">Description</div>\n";
116 print " </td>\n";
117 print " <td class=\"tableBody\">\n";
118 print " <input type=\"text\" name=\"description\" value=\"" . $es['description'] . "\" size=\"100\" maxlength=\"100\">\n";
119 print " </td>\n";
120 print " </tr>\n";
122 print " <tr>\n";
123 print " <td class=\"tableBody\">\n";
124 print " <div align=\"right\">Character set</div>\n";
125 print " </td>\n";
126 print " <td class=\"tableBody\">\n";
127 print " <input type=\"text\" name=\"charset\" value=\"" . $es['charset'] . "\" size=\"100\" maxlength=\"100\">\n";
128 print " </td>\n";
129 print " </tr>\n";
131 print " </table>\n";
133 if( $action == 'new' ){
134 print " <input type=\"submit\" value=\"Add\" class=\"gumb\" name=\"Add\">\n";
137 if( $action == 'none' ){
138 print "<p>\n";
139 print " <input type=\"submit\" value=\"Update\" class=\"gumb\" name=\"Update\">\n";
140 print " <input type=\"submit\" value=\"Delete\" class=\"gumb\" name=\"Delete\">\n";
141 print "</p>\n";
144 print "</form>\n";
148 // main
151 // arguments from the command line/url
152 if( $debug ) dbg( "REQUEST" , $_REQUEST );
153 if( isset($_REQUEST['action']) ) $action = $_REQUEST['action'];
154 if( isset($_REQUEST['id']) ) $idarg = $_REQUEST['id'];
156 // posted data
157 if( $debug ) dbg( "_POST" , $_POST );
159 if(isset($_POST['id'])) $networkpost['id'] = $_POST['id'];
160 if(isset($_POST['active'])) $networkpost['active'] = $_POST['active'];
161 if(isset($_POST['name'])) $networkpost['name'] = $_POST['name'];
162 if(isset($_POST['operator'])) $networkpost['operator'] = $_POST['operator'];
163 if(isset($_POST['description'])) $networkpost['description'] = $_POST['description'];
164 if(isset($_POST['charset'])) $networkpost['charset'] = $_POST['charset'];
166 if( $debug ) dbg( "networkpost" , $networkpost );
168 // set default values if not set
169 if( isset($networkpost) ) $networkpost = set_network_defaults( $networkpost );
171 // convert to lowercase
172 if( $dconf['lowercase'] && isset($networkpost) ){
173 //$networkpost['name'] = strtolower( $networkpost['name'] );
177 // action from form
179 if( isset($_POST['Add']) && $_POST['Add'] == 'Add' ) $action = 'add';
180 if( isset($_POST['Update']) && $_POST['Update'] == 'Update' ) $action = 'update';
181 if( isset($_POST['Delete']) && $_POST['Delete'] == 'Delete' ) $action = 'delete';
184 // check if there is already a network with this name
186 if( $action != 'new' ){
187 switch( $dconf['dbtype'] ){
188 case 'mysql':
190 // first try to find from posted data
191 if( !$found && isset($networkpost['id']) ) $found = sql_findNetwork( $myc , 'id' , $networkpost['id'] );
192 if( $debug && $found ){
193 dbg( "sql: found from posted data" , $found );
196 // if !found with posted data
197 // try to find with data from arguments
198 if( !$found && $idarg ) $found = sql_findNetwork( $myc , 'id' , $idarg );
199 if( $debug && $found ){
200 dbg( "sql: found from arguments" , $found );
202 break;
208 // not found
210 if( $found == false ){
211 switch( $action ){
212 case 'none': // if action==none -> this is edit, so it must be found
213 print ("<h3>Invalid network: " . $idarg . " </h3>\n");
214 exit;
215 default:
216 //dbg($action,"...");
217 break;
220 $network = set_network_defaults( false );
222 else $network = $found;
224 // remember current dhcp group
225 // on delete or update network should be removed from old group
226 //$network[olddhcpgroup] = $network[dhcpgroup];
228 switch( $action ){
229 case 'none':
230 case 'new':
231 networkform( $network );
232 break;
233 case 'add':
234 if( $found && !strcasecmp($found['id'],$networkpost['id'] )){
235 print "<h1>Network with ID " . $networkpost['id'] . " exists</h1>\n";
236 print "<script language=\"javascript\">\n";
237 print " url = 'shownetwork.php?name=" . $found[name] . "';\n";
238 print " openDialog( url , 'shownetwork' , 'width=300,height=300,resizable=yes,scrollbars=yes,status=yes' );\n";
239 print "</script>\n";
240 break;
242 switch( $dconf['dbtype'] ){
243 case 'mysql':
244 sql_addNetwork( $myc , $networkpost );
245 break;
248 print "<h1>Network " . $networkpost['id'] . " added</h1>\n";
249 addlog(true,"Network " . $networkpost['id'] . " added" );
250 break;
251 case 'update':
252 switch( $dconf['dbtype'] ){
253 case 'mysql':
254 sql_updateNetwork( $myc , $networkpost );
255 break;
258 print "<h1>Network " . $networkpost['id'] . " updated</h1>\n";
259 addlog(true,"Network " . $networkpost['id'] . " updated" );
260 break;
261 case 'delete':
262 switch( $dconf['dbtype'] ){
263 case 'mysql':
264 sql_deleteNetwork( $myc , $networkpost );
265 break;
267 print "<h1>Network " . $networkpost['id'] . " deleted</h1>\n";
268 addlog(true,"Network " . $networkpost['id'] . " deleted" );
269 break;
272 reloadUrl('Back to networks list' , 'listnetworks.php');
275 // disconnect from main database
277 switch( $dconf['dbtype'] ){
278 case 'mysql':
279 sql_dodisconnect( $myc );
280 break;
285 </body>
286 </html>