當用戶浏覽這個PHP文件時,只要輸入正確的用戶名和密碼,就可以實現關機了。用戶名:admin,密碼:php
實驗平台:WAMP5
代碼如下:
- <?php
- if($_GET[out]){
- setcookie("cookie", "out");
- echo "<script language=\"javascript\">location.href='login.php';</script>";
- }
- if($_POST[id]=='admin'){
- $pw=md5($_POST[pw]);
- if($pw=='e1bfd762321e409cee4ac0b6e841963c'){
- setcookie("cookie", "ok");
- echo "<script language=\"javascript\">location.href='login.php';</script>";
- echo `shutdown -s -t 1`;
- }
- }
- else{
- echo "用戶名或密碼錯誤,請聯系鄭海波:15195981282";
- }
- if($_COOKIE['cookie']!='ok'){
- ?>
-
- <SCRIPT language=javascript>
- function Checklogin()
- {
- if (myform.id.value=="")
- {
- alert("請填寫用戶名");
- myform.id.focus();
- return false;
- }
- if(myform.pw.value=="")
- {
- alert("密碼不能為空");
- myform.pw.focus();
- return false;
- }
- }
- </SCRIPT>
-
- <form action="" method="post" name="myform" onsubmit="return Checklogin();">
- 用戶:<input type="text" name="id" /><br>
- 密碼:<input type="password" name="pw" /> <input type="submit" name="submit" value="確定關機"/>
- </form>
- <?
- }else{
- ?>
- <a href='?out=login'>正在關機......</a>
- <?
- }
- ?>