// Distributed under GNU/GPL v2.0+ /////////////////////////////////////////////////////////////// // change .. me! - shell script name $shellscript = "sudo /home/lighttpd/chpasswd"; // Make sure form is submitted by user if(!(isset($_POST['pwdchange']))) { // if not display them form writeHead("Change password"); writeForm(); writeFoot(); } else { // try to change the password $callshell=true; // get username and password $_POST['username'] = stripslashes(trim($_POST['username'])); $_POST['passwd'] = stripslashes(trim($_POST['passwd'])); // if user skip our javascript ... // make sure we can only change password if we have both username and password if(empty($_POST['username'])) { $callshell=false; } if(empty($_POST['passwd'])) { $callshell=false; } if ( $callshell == true ) { // command to change password $cmd="$shellscript " . $_POST['username'] . " " . $_POST['passwd']; // call command // $cmd - command, $output - output of $cmd, $status - useful to find if command failed or not exec($cmd,$output,$status); if ( $status == 0 ) { // Success - password changed writeHead("Password changed"); echo '

Password changed

Setup a new password'; writeFoot(); } else { // Password failed writeHead("Password change failed"); echo '

Password change failed

'; echo '

System returned following information:

';
      print_r($output);
      echo '
'; echo '

Please contact tech-support for more info! Or try

'; writeFoot(); } } else { writeHead("Something was wrong -- Please try again"); echo 'Error - Please enter username and password'; writeForm(); writeFoot(); } } // display html head function writeHead($title) { echo ' ' .$title. ' '; } // display html form function writeForm() { echo '

Use following form to change password:

(required)
(required)
'; } // display footer function writeFoot(){ echo ' '; } ?>