密碼修改
使用者名稱 :
目前使用的密碼 :
新的密碼 :
確認新的密碼 :
"); if ((!$newpasswd1)||(!$newpasswd2)) { echo "

Please input new password!!

"; echo "

"; exit; } if ((!$username)||(!$oldpasswd)){ echo "

Please input your username and old password!!

"; echo "

"; exit; } Class poppass { function err_handle($err) { $this->error = $err; printf("

"); printf("Error:
%s\n
\n", $this->error); printf("

"); echo "

"; exit; } function setuser($user){ $this->user = $user; } function setserver($server){ $this->server = $server; } function oldpass($oldpass){ $this->oldpass = $oldpass; } function newpass($newpass1, $newpass2) { if ($newpass1 == $newpass2) { $this->newpass = $newpass1; } else { $this->err_handle("New password not confirmed."); } } function logit($line){ /* Log transactions */ $date = date('d M Y H:i:s'); openlog("[php-poppass]", LOG_PID, LOG_LOCAL7); syslog(LOG_INFO, "$line"); closelog(); } function getline($filepointer) { /* Make sure status is always 200, else error out. */ $output = fgets($filepointer, 128); $v = substr($output, 0, 3); if ($v != 200){ $this->err_handle("Error: $output"); } } function connect() { $fp = fsockopen($this->server, 106, &$errno , &$errstr, 30); if(!$fp) { $this->err_handle("Cannot connect to $this->server"); } else { $this->getline($fp); $this->fp = $fp; } } function login() { fputs($this->fp, "user $this->user\n"); $this->getline($this->fp); } function sendoldpass() { fputs($this->fp, "pass $this->oldpass\n"); $this->getline($this->fp); } function sendnewpass() { fputs($this->fp, "newpass $this->newpass\n"); $this->getline($this->fp); } function close() { fputs($this->fp, "quit\n"); fclose($this->fp); } } $server='127.0.0.1'; $pop = new poppass; $pop->setuser("$username"); $pop->setserver("$server"); $pop->oldpass("$oldpasswd"); $pop->newpass("$newpasswd1", "$newpasswd2"); $pop->connect(); $pop->login(); $pop->sendoldpass(); $pop->sendnewpass(); $pop->close(); echo "

"; echo "Your password have been

successfully modified.

"; echo "
"; echo "

Back to Community

"; printf("
"); } // end of do chpasswd ?>