强制更新屏幕,重启服务器并使用Javascript刷新

时间:2017-03-06 15:15:32

标签: javascript screen flush reboot

我正在尝试使用基于Web服务器的应用程序。我正在研究服务器的内部配置,我希望它能够被用户修改。我正在使用raspberry pi 3作为Web服务器。

现在我正在尝试配置静态IP,为此我用php代码修改了dhcpc.conf文件。之后,我想重新启动覆盆子,以便采用新的配置。我已经能够做到这一点,但是当我强制重启时,服务器不会将信息发送到Web浏览器,而且我找不到页面。

我想知道的是如何强制服务器在关机前更新网页,然后如何(使用javascript)在XX秒后重新加载页面(当再次启动树莓时)。

这是我的代码,直到现在:

update t2
set data1 = case when exists (select 1 from table1 t1 where t1.record_id = t2.record_id and t1.type = 123) then 1 else 0 end,
    data2 = case when exists (select 1 from table1 t1 where t1.record_id = t2.record_id and t1.type = 456) then 1 else 0 end,
    data3 = case when exists (select 1 from table1 t1 where t1.record_id = t2.record_id and t1.type = 789) then 1 else 0 end
from table2 t2;

写入新文件后的文件phpCode / chNetConf.php调用另一个shutdown.php文件:

<!doctype html>
<html>
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1" />
    <title>Configuración: Red</title>
    <link href="/TrafficVC/ccs/main.css" rel="stylesheet" type="text/css">
    <script type="text/javascript" src="js/configuraRed.js"></script>

    <style>

    </style>
</head>

<body>
    <h1 class="pagesTitle">Configuración: Red</h1>

    <form action="" method="post" name="chNetConf">
        <table class="tbChNetConf" id="chNetConfTable">
            <tr>
                    <td class="izq">Hostname:</td>
                    <td class="der"> <input type="text" name="Hostname" <?php echo "value=".gethostname();?>> </td>
            </tr>
            <tr>
                <td class="izq" style="font-weight:bold">Conexión Ethernet: </td>
                <td class="der">

                    <label>
                        <span>IP Estática</span>
                        <input type="checkbox" id="chbEthStaticEnable" name="chbEthStaticEnable" onchange="enableEthStatic(this)">
                    </label>
                </td>
                <td class="izq" style="font-weight:bold">Conexión Wireless: </td>
                <td class="der">
                    <label>
                        <span>Habilitar</span>
                        <input type="checkbox" id="chbWlanEnable" name="chbWlanEnable" onchange="enableWlan(this)">
                    </label>
                    <label>
                        <span>IP Estática</span>
                        <input type="checkbox" id="chbWlanStaticEnable" name="chbWlanStaticEnable" onchange="enableWlanStatic(this)" disabled>
                    </label>
                </td>
            </tr>
            <tr>
                <td colspan="2" style="vertical-align:top">
                    <table class="tbChNetConf">
                        <tr>
                            <td class="izq">IP:</td>
                            <td class="der">
                                <input type="text" id="EthIP1" name="EthIP1" disabled style="width:15%">
                                .
                                <input type="text" id="EthIP2" name="EthIP2" disabled style="width:15%">
                                .
                                <input type="text" id="EthIP3" name="EthIP3" disabled style="width:15%">
                                .
                                <input type="text" id="EthIP4" name="EthIP4" disabled style="width:15%">
                            </td>
                        </tr>
                        <tr>
                            <td class="izq">Mascara:</td>
                            <td class="der">
                                <input type="text" id="EthMask1" name="EthMask1" disabled style="width:15%">
                                .
                                <input type="text" id="EthMask2" name="EthMask2" disabled style="width:15%">
                                .
                                <input type="text" id="EthMask3" name="EthMask3" disabled style="width:15%">
                                .
                                <input type="text" id="EthMask4" name="EthMask4" disabled style="width:15%">
                            </td>
                        </tr>
                        <tr>
                            <td class="izq">Puerta de enlace:</td>
                            <td class="der"> 
                                <input type="text" id="EthGate1" name="EthGate1" disabled style="width:15%">
                                .
                                <input type="text" id="EthGate2" name="EthGate2" disabled style="width:15%">
                                .
                                <input type="text" id="EthGate3" name="EthGate3" disabled style="width:15%">
                                .
                                <input type="text" id="EthGate4" name="EthGate4" disabled style="width:15%">                                    
                            </td>
                        </tr>
                    </table>
                </td>
                <td colspan="2";>
                    <table class="tbChNetConf">
                        <tr>
                            <td class="izq">SSID:</td>
                            <td class="der"> 
                                <input type="text" id="WlanSSID" name="WlanSSID" disabled style="width:80%"> 
                            </td>
                        </tr>
                        <tr>
                            <td class="izq">Contraseña:</td>
                            <td class="der"> 
                                <input type="password" id="WlanPass" name="WlanPass" disabled> 
                            </td>
                        </tr>

                        <tr>
                            <td class="izq">IP:</td>
                            <td class="der" > 
                                <input type="text" id="WlanIP1" name="WlanIP1" disabled style="width:15%">
                                .
                                <input type="text" id="WlanIP2" name="WlanIP2" disabled style="width:15%">
                                .
                                <input type="text" id="WlanIP3" name="WlanIP3" disabled style="width:15%">
                                .
                                <input type="text" id="WlanIP4" name="WlanIP4" disabled style="width:15%">
                            </td>
                        </tr>
                        <tr>
                            <td class="izq">Mascara:</td>
                            <td class="der" style="table-layout: fixed; width=100%"> 
                                <input type="text" id="WlanMask1" name="WlanMask1" disabled style="width:15%"> 
                                .
                                <input type="text" id="WlanMask2" name="WlanMask2" disabled style="width:15%"> 
                                .
                                <input type="text" id="WlanMask3" name="WlanMask3" disabled style="width:15%"> 
                                .
                                <input type="text" id="WlanMask4" name="WlanMask4" disabled style="width:15%"> 
                            </td>
                        </tr>
                        <tr>
                            <td class="izq">Puerta de enlaceqe:</td>
                            <td class="der"> 
                                <input type="text" id="WlanGate1" name="WlanGate1" disabled style="width:15%">  
                                .
                                <input type="text" id="WlanGate2" name="WlanGate2" disabled style="width:15%">  
                                .
                                <input type="text" id="WlanGate3" name="WlanGate3" disabled style="width:15%">  
                                .
                                <input type="text" id="WlanGate4" name="WlanGate4" disabled style="width:15%">  
                            </td>
                        </tr>
                    </table>
                </td>
            </tr>
            <tr>
                <td colspan="4" style="text-align:center;"> 
                    <input type="submit" value="Guardar" name="submitChNet">
                </td>
            </tr>
        </table>
    </form>

    <?php
        if (isset($_GET['Err']))
        {
            echo "Error " . $_GET['Err']. ": ";
            if ($_GET['Err']=="EthIP")
                echo "La dirección IP de la conexión ethernet no es correcta";
            if ($_GET['Err']=="EthMask")
                echo "La máscara de la conexión ethernet no es correcta";
            if ($_GET['Err']=="EthGate")
                echo "La puerta de enlace de la conexión ethernet no es correcta";
        }
    ?>

</body>
</html>

<?php
if (isset($_POST['submitChNet']))
{
    include('phpCode/chNetConf.php');
}
?>

我希望我足够清楚,你可以帮助我。

顺便说一下,不需要安全。此外,我知道这可以做到,因为我已经了解了如何配置路由器。

0 个答案:

没有答案