Postfixadmin forgot the password after the Change password method detailed _php example

Source: Internet
Author: User
Tags chr md5 ord php programming php regular expression strlen

The example in this article describes the modified password method after postfixadmin forgot the password. Share to everyone for your reference, specific as follows:

Postfix admin is a web-based Postfix mail delivery Server management tool that can directly manage Postfix virtual domain names and users.

Because there is a period of time did not use postfixadmin additions and deletions users, suddenly need to use when forget the management password, the way to use the foreigner directly in the database to modify the password, after the successful login

PHP Source:

<?php Echo md5crypt ("New password"); Md5crypt//action:creates MD5 encrypted password//call:md5crypt (string cleartextpassword) function Md5crypt ($PW,
  $salt = "", $magic = "") {$MAGIC = "$1$";
  if ($magic = = "") {$magic = $MAGIC;
  } if ($salt = = "") {$salt = Create_salt ();
  } $slist = Explode ("$", $salt);
  if (isset ($slist [0]) && $slist [0] = = "1") {$salt = $slist [1];
  $salt = substr ($salt, 0, 8);
  $ctx = $pw. $magic. $salt;
  $final = Hex2bin (MD5 ($PW. $salt. $pw));
    for ($i = strlen ($PW); $i > 0; $i-= {if ($i >) {$ctx. = substr ($final, 0,16);
    else {$ctx. = substr ($final, 0, $i);
  }} $i = strlen ($PW);
    while ($i > 0) {if ($i & 1) {$ctx. = chr (0);
    else {$ctx. = $PW [0];
  $i = $i >> 1;
  } $final = Hex2bin (MD5 ($CTX));
    For ($i =0 $i <1000; $i + +) {$ctx 1 = "";
    if ($i & 1) {$ctx 1. = $PW; } ELSE {$CTX 1. = substr ($final, 0,16);
    } if ($i% 3) {$ctx 1. = $salt;
    } if ($i% 7) {$ctx 1. = $PW;
    } if ($i & 1) {$ctx 1. = substr ($final, 0, 16);
    else {$ctx 1. = $PW;
  } $final = Hex2bin (MD5 ($ctx 1));
  } $passwd = ""; $passwd. = To64 ((ord ($final [0]) << 16) | (Ord ($final [6]) << 8) |
  (Ord ($final [12]))), 4); $passwd. = To64 ((Ord ($final [1]) << 16) | (Ord ($final [7]) << 8) |
  (Ord ($final [13]))), 4); $passwd. = To64 ((Ord ($final [2]) << 16) | (Ord ($final [8]) << 8) |
  (Ord ($final [14]))), 4); $passwd. = To64 ((Ord ($final [3]) << 16) | (Ord ($final [9]) << 8) |
  (Ord ($final [15]))), 4); $passwd. = To64 ((Ord ($final [4]) << 16) | (Ord ($final [ten]) << 8) |
  (Ord ($final [5]))), 4);
  $passwd. = To64 (Ord ($final [11]), 2); Return $magic. $salt. '
$ '. $passwd;
  function Create_salt () {srand (double) microtime () * 1000000); Return substr (MD5 ranD (0,9999999)), 0, 8); }//PHP around 5.3.8 includes hex2bin as native Function-http://php.net/hex2bin function Hex2bin ($str) {$len = str
    Len ($STR);
    $nstr = "";
      for ($i = 0; $i < $len; $i + + 2) {$num = sscanf (substr ($str, $i, 2), "%x");
    $nstr. = Chr ($num [0]);
return $nstr;
  function To64 ($v, $n) {$ITOA = "./0123456789abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz";
  $ret = "";
    while (($n-1) >= 0) {$n-;
    $ret. = $ITOA 64[$v & 0x3f];
  $v = $v >> 6;
return $ret;

 }

For more information on PHP related content readers can view the site topics: "PHP Encryption Method Summary", "PHP code and transcoding Operation Skills Summary", "PHP object-oriented Program Design Introductory Course", "PHP Mathematical Arithmetic Skills summary", "PHP Array" operation Skills Encyclopedia, " Summary of PHP string usage, PHP data structure and algorithm tutorial, PHP programming algorithm Summary, PHP Regular Expression usage summary, and PHP Common database operation Skills Summary

I hope this article will help you with the PHP program design.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

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.