note 105668 added to function.crack-check
| From: | desmatic at gmail dot com | Date: | Tue, 06 Sep 2011 11:45:21 +0000 |
| Subject: | note 105668 added to function.crack-check | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-182965@lists.php.net to get a copy of this message | ||
for those having trouble installing the php module, this function works well
function cracklib_check($password, $username, &$mesg = null) {
if (!strlen($password)) {
$mesg = "it is empty";
return false;
}
if (strpos($username, $password) !== false) {
$mesg = "it is part of the username";
return false;
}
$fhdls = array(
0 => array("pipe", "r"), // stdin is a pipe that the child will
read from
1 => array("pipe", "w"), // stdout is a pipe that the child will
write to
2 => array("pipe", "a") // stderr is a pipe that the child will
write to
);
$return = false;
$output = "";
$error = "";
$bin = "/usr/sbin/cracklib-check";
if ($phdl = proc_open($bin, $fhdls, $pipes)) {
/* stdin */
fwrite($pipes[0], $password);
fclose($pipes[0]);
/* stdout */
$output = stream_get_contents($pipes[1]);
fclose($pipes[1]);
/* stderr */
$error = stream_get_contents($pipes[2]);
fclose($pipes[2]);
$proc_return = proc_close($phdl);
}
if (($output) && (strlen($output) > 3)) {
for ($i = strlen($output) - 1; $i > 0; $i--) {
if ($output[$i] == ":") {
break;
}
}
$mesg = trim(substr($output, $i + 2));
$return = (strtolower($mesg) == "ok");
}
return $return;
}
----
Server IP: 69.147.83.197
Probable Submitter: 82.20.75.197
----
Manual Page -- http://www.php.net/manual/en/function.crack-check.php
Edit -- https://master.php.net/note/edit/105668
Del: integrated -- https://master.php.net/note/delete/105668/integrated
Del: useless -- https://master.php.net/note/delete/105668/useless
Del: bad code -- https://master.php.net/note/delete/105668/bad+code
Del: spam -- https://master.php.net/note/delete/105668/spam
Del: non-english -- https://master.php.net/note/delete/105668/non-english
Del: in docs -- https://master.php.net/note/delete/105668/in+docs
Del: other reasons-- https://master.php.net/note/delete/105668
Reject -- https://master.php.net/note/reject/105668
Search -- https://master.php.net/manage/user-notes.php