572

everycode2

每日代码汇第四期:用PHP实现手机关闭电脑

用法:复制代码新建.php文件放在你的web项目文件夹

适合有手机和电脑,用wifi的php web开发。方便关闭你的电脑(尤其在你想睡觉时),适合局域网

代码:

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
< !DOCTYPE html>
<html lang="zh-CN">
<head>
    <title>computer-manager</title>
</head>

<body>
    <p>

    <?php
    if($_POST){
        $shutdown = array(
            'shutdown' =>'shutdown -s -t 0',
            'restart' => 'shutdown -r',
            'logout' => 'shutdown -l',
        );

        $cmdk = $_POST['cmd'];
        echo $cmd = $shutdown[$cmdk];
        system($cmd); // 执行操作
    }
    ?>

    </p>

    <form action="#top" method="post">
        <p>choose you want.</p>
        <select name="cmd">
            <option value="shutdown" selected="selected">shutdown/ go to sleep.</option>
            <option value="restart">restart computer/ ok, if no password.</option>
            <option value="logout">logout/ you don't want this.</option>
        </select>
        <input type="submit" name="submit" value="submit" />
    </form>
</body>
</html>

来源:http://www.oschina.net/code/snippet_1024009_20446(oschina.net)

生产:邪云子

主页:http://my.oschina.net/xieyunzi

至顶 至底