-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathutilities.php
34 lines (26 loc) · 860 Bytes
/
utilities.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
<?php
/**
* Reads in a password from standard input, masking typed characters.
*
* @see http://docstore.mik.ua/orelly/webprog/pcook/ch20_05.htm
* @param string $os The name of the current operating system
* @return string
*/
function readPassword($os)
{
$password = "";
if (strtoupper(substr($os, 0, 3)) === 'WIN') {
// Windows. Use custom C++ hidden input reader
// read password
$password = rtrim(shell_exec('utilities\win32\hiddenInput.exe'));
} else {
// *nix. Can use stty
// turn off echo
`/bin/stty -echo`;
// read password
$password = rtrim(fgets(STDIN), "\r\n");
// turn echo back on
`/bin/stty echo`;
}
return $password;
}