6 require "epgservers.php";
7 require "networks.php";
15 // connect to main database
17 switch( $dconf['dbtype'] ){
19 $myc = sql_doconnect();
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
>
32 <body bgcolor
="#FFFFFF" text
="#000000">
36 function networkform( $es )
41 print "<h1>Edit details for network: " . $es['name'] . "</h1>\n";
42 print "<form name=network action=\"editnetwork.php\" method=post>\n";
48 print " <input type=\"hidden\" name=\"id\" value=\"" . $es['id'] . "\">\n";
54 print " <tr class=\"tableTitle\">\n";
55 print " <td colspan=\"2\">General details</td>\n";
59 print " <td class=\"tableBody\">\n";
60 print " <div align=\"right\">ID</div>\n";
62 print " <td class=\"tableBody\">";
71 print "<input type=\"text\" name=\"id\" value=\"" . $es['id'] . "\" size=\"12\" maxlength=\"12\">\n";
78 print " <td class=\"tableBody\">\n";
79 print " <div align=\"right\">Active</div>\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";
89 print " <td class=\"tableBody\">\n";
90 print " <div align=\"right\">EPG server</div>\n";
92 print " <td class=\"tableBody\">" . $es['epgserver'] . "</td>\n";
96 print " <td class=\"tableBody\">\n";
97 print " <div align=\"right\">Name</div>\n";
99 print " <td class=\"tableBody\">\n";
100 print " <input type=\"text\" name=\"name\" value=\"" . $es['name'] . "\" size=\"100\" maxlength=\"100\">\n";
105 print " <td class=\"tableBody\">\n";
106 print " <div align=\"right\">Operator</div>\n";
108 print " <td class=\"tableBody\">\n";
109 print " <input type=\"text\" name=\"operator\" value=\"" . $es['operator'] . "\" size=\"100\" maxlength=\"100\">\n";
114 print " <td class=\"tableBody\">\n";
115 print " <div align=\"right\">Description</div>\n";
117 print " <td class=\"tableBody\">\n";
118 print " <input type=\"text\" name=\"description\" value=\"" . $es['description'] . "\" size=\"100\" maxlength=\"100\">\n";
123 print " <td class=\"tableBody\">\n";
124 print " <div align=\"right\">Character set</div>\n";
126 print " <td class=\"tableBody\">\n";
127 print " <input type=\"text\" name=\"charset\" value=\"" . $es['charset'] . "\" size=\"100\" maxlength=\"100\">\n";
133 if( $action == 'new' ){
134 print " <input type=\"submit\" value=\"Add\" class=\"gumb\" name=\"Add\">\n";
137 if( $action == 'none' ){
139 print " <input type=\"submit\" value=\"Update\" class=\"gumb\" name=\"Update\">\n";
140 print " <input type=\"submit\" value=\"Delete\" class=\"gumb\" name=\"Delete\">\n";
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'];
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'] );
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'] ){
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 );
210 if( $found == false ){
212 case 'none': // if action==none -> this is edit, so it must be found
213 print ("<h3>Invalid network: " . $idarg . " </h3>\n");
216 //dbg($action,"...");
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];
231 networkform( $network );
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";
242 switch( $dconf['dbtype'] ){
244 sql_addNetwork( $myc , $networkpost );
248 print "<h1>Network " . $networkpost['id'] . " added</h1>\n";
249 addlog(true,"Network " . $networkpost['id'] . " added" );
252 switch( $dconf['dbtype'] ){
254 sql_updateNetwork( $myc , $networkpost );
258 print "<h1>Network " . $networkpost['id'] . " updated</h1>\n";
259 addlog(true,"Network " . $networkpost['id'] . " updated" );
262 switch( $dconf['dbtype'] ){
264 sql_deleteNetwork( $myc , $networkpost );
267 print "<h1>Network " . $networkpost['id'] . " deleted</h1>\n";
268 addlog(true,"Network " . $networkpost['id'] . " deleted" );
272 reloadUrl('Back to networks list' , 'listnetworks.php');
275 // disconnect from main database
277 switch( $dconf['dbtype'] ){
279 sql_dodisconnect( $myc );