| 1 |
<?php |
|---|
| 2 |
|
|---|
| 3 |
function main_cli() { |
|---|
| 4 |
echo "Changing password for eAccelerator Web Interface (eaccelerator.php)\n\n"; |
|---|
| 5 |
$stdin = fopen("php://stdin","r"); |
|---|
| 6 |
while (1) { |
|---|
| 7 |
echo "Enter admin name: "; |
|---|
| 8 |
$name = fgets($stdin,1024); |
|---|
| 9 |
if (feof($stdin)) {echo("\n"); exit;} |
|---|
| 10 |
$name = str_replace(array("\n","\r"),"",$name); |
|---|
| 11 |
if ($name == "") { |
|---|
| 12 |
echo "\nSorry, admin name can't be empty\n"; |
|---|
| 13 |
} else { |
|---|
| 14 |
break; |
|---|
| 15 |
} |
|---|
| 16 |
} |
|---|
| 17 |
while (1) { |
|---|
| 18 |
echo "New admin password: "; |
|---|
| 19 |
$p1 = fgets($stdin,1024); |
|---|
| 20 |
if (feof($stdin)) {echo("\n"); exit;} |
|---|
| 21 |
$p1 = str_replace(array("\n","\r"),"",$p1); |
|---|
| 22 |
if ($p1 == "") { |
|---|
| 23 |
echo "\nSorry, new admin password can't be empty\n"; |
|---|
| 24 |
} else { |
|---|
| 25 |
break; |
|---|
| 26 |
} |
|---|
| 27 |
} |
|---|
| 28 |
echo "Retype new admin password: "; |
|---|
| 29 |
$p2 = fgets($stdin,1024); |
|---|
| 30 |
if (feof($stdin)) {echo("\n"); exit;} |
|---|
| 31 |
$p2 = str_replace(array("\n","\r"),"",$p2); |
|---|
| 32 |
if ($p1 != $p2) { |
|---|
| 33 |
echo "\nSorry, passwords do not match\n"; |
|---|
| 34 |
exit; |
|---|
| 35 |
} |
|---|
| 36 |
$password = crypt($p1); |
|---|
| 37 |
echo "\nAdd the following lines into your php.ini and restart HTTPD\n\n". |
|---|
| 38 |
"eaccelerator.admin.name=\"$name\"\n". |
|---|
| 39 |
"eaccelerator.admin.password=\"$password\"\n"; |
|---|
| 40 |
} |
|---|
| 41 |
|
|---|
| 42 |
function main_web() { |
|---|
| 43 |
$admin_name = ""; |
|---|
| 44 |
$admin_password = ""; |
|---|
| 45 |
$admin_password2 = ""; |
|---|
| 46 |
$error = ""; |
|---|
| 47 |
if (isset($_POST["submit"])) { |
|---|
| 48 |
if (isset($_POST["admin_name"])) { |
|---|
| 49 |
$admin_name = $_POST["admin_name"]; |
|---|
| 50 |
} |
|---|
| 51 |
if (isset($_POST["admin_password"])) { |
|---|
| 52 |
$admin_password = $_POST["admin_password"]; |
|---|
| 53 |
} |
|---|
| 54 |
if (isset($_POST["admin_password2"])) { |
|---|
| 55 |
$admin_password2 = $_POST["admin_password2"]; |
|---|
| 56 |
} |
|---|
| 57 |
if (empty($admin_name)) { |
|---|
| 58 |
$error = "Sorry, admin name can't be empty"; |
|---|
| 59 |
} else if (empty($admin_password)) { |
|---|
| 60 |
$error = "Sorry, new admin password can't be empty"; |
|---|
| 61 |
} else if ($admin_password != $admin_password2) { |
|---|
| 62 |
$error = "Sorry, passwords do not match"; |
|---|
| 63 |
} else { |
|---|
| 64 |
$password = crypt($admin_password); |
|---|
| 65 |
echo "<html><head><title>Changing password for eAccelerator Web Interface (eaccelerator.php)</title></head>". |
|---|
| 66 |
"<body><h1 align=\"center\">Changing password for eAccelerator Web Interface (eaccelerator.php)</h1>". |
|---|
| 67 |
"Add the following lines into your php.ini and restart HTTPD<br><pre><b>". |
|---|
| 68 |
"eaccelerator.admin.name=\"$admin_name\"\n". |
|---|
| 69 |
"eaccelerator.admin.password=\"$password\"\n</b></pre></body></html>"; |
|---|
| 70 |
return; |
|---|
| 71 |
} |
|---|
| 72 |
} |
|---|
| 73 |
echo "<html><head><title>Changing password for eAccelerator Web Interface (eaccelerator.php)</title></head>". |
|---|
| 74 |
"<body><h1 align=\"center\">Changing password for eAccelerator Web Interface (eaccelerator.php)</h1>". |
|---|
| 75 |
"<h3 align=\"center\"><font color=\"#ff0000\">$error</font></h3>". |
|---|
| 76 |
"<form method=\"POST\">". |
|---|
| 77 |
"<table border=\"0\" cellpadding=\"3\" cellspacing=\"1\" width=\"600\" bgcolor=\"#000000\" align=\"center\">". |
|---|
| 78 |
"<tr valign=\"baseline\" bgcolor=\"#cccccc\"><td width=\"50%\" bgcolor=\"#ccccff\"><b>Admin name:</b></td><td width=\"50%\"><input type=\"text\" name=\"admin_name\" size=\"32\" value=\"$admin_name\" style=\"width:100%\"></td></tr>". |
|---|
| 79 |
"<tr valign=\"baseline\" bgcolor=\"#cccccc\"><td width=\"50%\" bgcolor=\"#ccccff\"><b>New admin password:</b></td><td width=\"50%\"><input type=\"text\" name=\"admin_password\" size=\"32\" value=\"$admin_password\" style=\"width:100%\"></td></tr>". |
|---|
| 80 |
"<tr valign=\"baseline\" bgcolor=\"#cccccc\"><td width=\"50%\" bgcolor=\"#ccccff\"><b>Retype new admin password:</b></td><td width=\"50%\"><input type=\"text\" name=\"admin_password2\" size=\"32\" value=\"$admin_password2\" style=\"width:100%\"></td></tr>". |
|---|
| 81 |
"<tr><td colspan=\"2\" align=\"center\" bgcolor=\"#cccccc\"><input type=\"submit\" name=\"submit\" value=\"OK\" style=\"width:100px\"></td></tr>". |
|---|
| 82 |
"</form></body></html>"; |
|---|
| 83 |
} |
|---|
| 84 |
|
|---|
| 85 |
function is_cli() { |
|---|
| 86 |
if (php_sapi_name() == "cli" || empty($_SERVER['PHP_SELF'])) { |
|---|
| 87 |
return 1; |
|---|
| 88 |
} else { |
|---|
| 89 |
return 0; |
|---|
| 90 |
} |
|---|
| 91 |
} |
|---|
| 92 |
|
|---|
| 93 |
if (is_cli()) { |
|---|
| 94 |
if (function_exists("ob_end_flush")) { |
|---|
| 95 |
ob_end_flush(); |
|---|
| 96 |
} |
|---|
| 97 |
if (function_exists("ob_implicit_flush")) { |
|---|
| 98 |
ob_implicit_flush(1); |
|---|
| 99 |
} |
|---|
| 100 |
main_cli(); |
|---|
| 101 |
} else { |
|---|
| 102 |
main_web(); |
|---|
| 103 |
} |
|---|
| 104 |
|
|---|
| 105 |
?> |
|---|
| 106 |
|
|---|