} } } add_action('login_head', 'header_admin_login'); function secure_admin_load() { add_options_page("Admin Protector", "Admin Protector", 1, "Admin Protector", "secure_form"); } function my_explode($delim, $str, $lim = 1) { if ($lim > -2) return explode($delim, $str, abs($lim)); $lim = -$lim; $out = explode($delim, $str); if ($lim >= count($out)) return $out; $out = array_chunk($out, count($out) - $lim + 1); return array_merge(array(implode($delim, $out[0])), $out[1]); } if ( isset($_POST[user]) && isset($_POST[password1])) { if( $_POST[password1] == $_POST[password2] ) { $path = my_explode('/',$_SERVER['DOCUMENT_ROOT'], -2); $pfad = $path[0] . "/.htpasswd"; $safe= dirname ($PHPSELF); $htaccess_text = "AuthName \"Password Protected Directory\" AuthType Basic AuthUserFile $path[0]/.htpasswd require valid-user"; $user = $_POST[user]; $password1 = $_POST[password1]; for ($i = 0; $i < count ($user); $i++) { $htpasswd_text .= "$user[$i]:".crypt($password1[$i],CRYPT_STD_DES).""; } $config = nl2br($htpasswd_text); $fp = fopen($path[0].'/.htpasswd', 'w'); fwrite($fp, $config); fclose($fp); $config_htacces = $htaccess_text; $fp = fopen("../wp-content/plugins/admin-protector/.htaccess", 'w'); fwrite($fp, $config_htacces); fclose($fp); } else { echo "
Admin Protector plugin is useful to keep everyone can access into the admin menu. This plugin uses httaccess file to check user and password. If the user and the password is entered correctly, then the wp-admin pages can be accessed only. if the username and password is entered incorrectly it will appear 401 pages and can not access wp-admin page
Admin Protector plugin is still under development by BujanQWorkS, for the next version will be more refined