svn自助修改密碼(PHP指令碼實現)

來源:互聯網
上載者:User

svn自助修改密碼(PHP指令碼實現)
#建立指令碼目錄
mkdir -p /var/www/svn/svntools
#建立apache設定檔
touch /etc/httpd/conf.d/alias.conf

#輸入以下內容:

Alias /svntools "/var/www/svn/svntools"        Require valid-user        AuthType Basic        AuthName "svn tools"        AuthUserFile "/var/www/svn/project/conf/passwd"

#重啟apache服務
service httpd restart
#建立修改密碼的php指令碼  <?  $username = $_SERVER["PHP_AUTH_USER"]; //經過 AuthType Basic 認證的使用者名稱  $authed_pass = $_SERVER["PHP_AUTH_PW"]; //經過 AuthType Basic 認證的密碼  $input_oldpass = (isset($_REQUEST["oldpass"]) ? $_REQUEST["oldpass"] : ""); //從介面上輸入的原密碼  $newpass = (isset($_REQUEST["newpass"]) ? $_REQUEST["newpass"] : ""); //介面上輸入的新密碼  $repeatpass = (isset($_REQUEST["repeatpass"]) ? $_REQUEST["repeatpass"] : ""); //介面上輸入的重複密碼  $action = (isset($_REQUEST["action"]) ? $_REQUEST["action"] : ""); //以hide方式提交到伺服器的action  if($action!="modify"){  $action = "view";  }  else if($authed_pass!=$input_oldpass){  $action = "oldpasswrong";  }  else if(empty($newpass)){  $action = "passempty";  }  else if($newpass!=$repeatpass){  $action = "passnotsame";  }  else{  $action = "modify";  }  ?>  <html>  <head>  <meta http-equiv="Content-Type" content="text/html; charset=GBK">  <title>Subversion 線上自助密碼修改</title>  </head>  <body>  <?  //action=view 顯示普通的輸入資訊  if ($action == "view"){  ?>  <script language = "javaScript">  <!--  function loginIn(myform)  {  var newpass=myform.newpass.value;  var repeatpass=myform.repeatpass.value;  if(newpass==""){  alert("請輸入密碼!");  return false;  }  if(repeatpass==""){  alert("請重複輸入密碼!");  return false;  }  if(newpass!=repeatpass){  alert("兩次輸入密碼不一致,請重新輸入!");  return false;  }  return true;  }  //-->  </script>  <style type="text/css">  <!--  table {  border: 1px solid #CCCCCC;  background-color: #f9f9f9;  text-align: center;  vertical-align: middle;  font-size: 9pt;  line-height: 15px;  }  th {  font-weight: bold;  line-height: 20px;  border-top-width: 1px;  border-right-width: 1px;  border-bottom-width: 1px;  border-left-width: 1px;  border-bottom-style: solid;  color: #333333;  background-color: f6f6f6;  }  input{  height: 18px;  }  .button {  height: 20px;  }  -->  </style>  <br><br><br>  <form method="post">  <input type="hidden" name="action" value="modify"/>  <table width="220" cellpadding="3" cellspacing="8" align="center">  <tr>  <th colspan=2>Subversion 密碼修改</th>  </tr>  <tr>  <td>使用者名稱:</td>  <td align="left"> <?=$username?></td>  </tr>  <tr>  <td>原密碼:</td>  <td><input type=password size=12 name=oldpass></td>  </tr>  <tr>  <td>使用者密碼:</td>  <td><input type=password size=12 name=newpass></td>  </tr>  <tr>  <td>確認密碼:</td>  <td><input type=password size=12 name=repeatpass></td>  </tr>  <tr>  <td colspan=2>  <input onclick="return loginIn(this.form)" class="button" type=submit value="修 改">  <input name="reset" type=reset class="button" value="取 消">  </td>  </tr>  </table>  </form>  <?  }  else if($action == "oldpasswrong"){  $msg="原密碼錯誤!";  }  else if($action == "passempty"){  $msg="請輸入新密碼!";  }  else if($action == "passnotsame"){  $msg="兩次輸入密碼不一致,請重新輸入!";  }  else{  $passwdfile="/var/www/svn/project/conf/passwd";  $command='"htpasswd" -b '.$passwdfile." ".$username." ".$newpass;  system($command, $result);  if($result==0){  $msg="使用者[".$username."]密碼修改成功,請用新密碼登陸.";  }  else{  $msg="使用者[".$username."]密碼修改失敗,傳回值為".$result.",請和管理員聯絡!";  }  }  if (isset($msg)){  ?>  <script language="javaScript">  <!--  alert("<?=$msg?>");  window.location.href="<?=$_SERVER["PHP_SELF"]?>"  //-->  </script>  <?  }  ?>  </body>  </html>  

相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.