Blame view
view/edit_network.html
3.17 KB
cf76164e6 20190709 |
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 |
<?php //include('cfg/file_name.php'); //開啟network檔案 $open_network = '/etc/network/interfaces'; $network_dhcp = 'iface eth0 inet dhcp'; $network_static = 'iface eth0 inet static'; shell_exec("sudo chmod 777 ".$open_network); $nn = 0; $i = 0; $handle = @fopen($open_network,"r"); while(($data = fgetcsv($handle,1000," ")) != false){ foreach($data as $key => $value){ $aa[] = $value; if($value == "iface eth0 inet dhcp"){ $str = "checked='checked'"; } } } $address = explode('address ',$aa[7]); $netmask = explode('netmask ',$aa[8]); $gateway = explode('gateway ',$aa[9]); ?> <main class="mn-inner"> <div class="row"> <div class="card"> <div class="card-content"> <span class="card-title"><?=network_set?></span><br> <div class="row"> <form class="col s12" id="edit_network" action='php/change_network.php' method="post"> <div class="row" > <div class="switch m-b-md"> <label> <?=stop_dhcp?></lable> <input type="checkbox" <?php echo $str ?> name="dhcp"> <span class="lever"></span> <lable> <?=start_dhcp?> </label> <label for="last_name"> </label> </div> <div class="input-field col s12"> <input type="text" name="address" value="<?php echo $address[1];?>" placeholder='<?=fix_ip?>'/> <label for="last_name"><?=fix_ip?></label> </div> <div class="input-field col s12"> <input type="text" name="netmask" value="<?php echo $netmask[1];?>" placeholder='<?=mask_ip?>'/> <label for="last_name"><?=mask_ip?></label> </div> <div class="input-field col s12"> <input type="text" name="gateway" value="<?php echo $gateway[1];?>" placeholder='<?=default_ip?>'/> <label for="last_name"><?=default_ip?></label> </div> </div> <a class="waves-effect waves-light btn m-b-xs update"><?=UPDATE?></a> <a class="waves-effect waves-light btn m-b-xs network_restart"><?=ntp_restart?></a> </form> </div> </div> </div> </div> </main> <div class="left-sidebar-hover"></div> <!-- Javascripts --> <script src="assets/plugins/jquery/jquery-2.2.0.min.js"></script> <script src="assets/plugins/materialize/js/materialize.min.js"></script> <script src="assets/plugins/material-preloader/js/materialPreloader.min.js"></script> <script src="assets/plugins/jquery-blockui/jquery.blockui.js"></script> <script src="assets/plugins/select2/js/select2.min.js"></script> <script src="assets/js/alpha.min.js"></script> <script src="assets/js/pages/form-select2.js"></script> <script> $('.update').click(function(){ $.ajax( { type: "POST", url: $('#edit_network').attr( 'action' ), data: $('#edit_network').serialize(), success: function( response ) { /*if(response == '1'){ alert('Success !'); location.href='index.php?item=edit_network'; }else{ alert('Error !'); }*/ console.log(response); } }); }) $('.network_restart').click(function(){ $.ajax({ url: "php/network_restart.php", data: "type=network_restart", type:"POST", dataType:'text', success: function(html){ alert("<?php echo ntp_restart; ?>"); } }); }) </script> </body> </html> |