change_passwd.php 886 Bytes
<?php
 //include('../cfg/file_name.php');
 $open_passwd = '../default/login_config.php';
 $open_passwd_admin = '../default/admin_config.php';
 if($_POST['passwd'] == $_POST['cpass']){
  $hash=hash("md5",$_POST['passwd']);
  if($_POST['user'] == 'admin'){
   $content = "<?php define('AD_ACCOUNT','admin'); define('AD_PASSWORD','".$hash."'); ?>";
   $fp = @fopen($open_passwd_admin,'w')  or die("Unable to open file!");
   fwrite($fp, $content);
   fclose($fp);
   echo '1';
   //echo "<script>location.href='index.php'</script>";

  }elseif($_POST['user'] == 'pi'){
   $content = "<?php define('ACCOUNT','pi'); define('PASSWORD','".$hash."'); ?>";
   $fp = @fopen($open_passwd,'w')  or die("Unable to open file!");
   fwrite($fp, $content);
   fclose($fp);
   echo '1';
   //echo "<script>location.href='index.php'</script>";
  }
  
 }else{
  echo '0';
 }
?>