Configuration
Version: 4.3
Author: AskApache
Author URI: http://www.askapache.com/
== Installation ==
1. Extract zip in plugins directory
2. Activate the Plugin
3. Setup plugin options
*/
/*
/--------------------------------------------------------------------\
| |
| License: GPL |
| |
| AskApache Password Protect Plugin - Adds HTTP Basic Authentication |
| Copyright (C) 2008, AskApache, www.askapache.com |
| All rights reserved. |
| |
| This program is free software; you can redistribute it and/or |
| modify it under the terms of the GNU General Public License |
| as published by the Free Software Foundation; either version 2 |
| of the License, or (at your option) any later version. |
| |
| This program is distributed in the hope that it will be useful, |
| but WITHOUT ANY WARRANTY; without even the implied warranty of |
| MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| GNU General Public License for more details. |
| |
| You should have received a copy of the GNU General Public License |
| along with this program; if not, write to the |
| Free Software Foundation, Inc. |
| 51 Franklin Street, Fifth Floor |
| Boston, MA 02110-1301, USA |
| |
\--------------------------------------------------------------------/
*/
?>
45)$newrealm1=substr($newrealm1, 0, 45);
$aa_PP['realm']=$newrealm1;
if($aa_PP['S']['sid900']['ON']=='1')aa_pp_activate_sid('sid900');
if($aa_PP['S']['sid800']['ON']=='1')aa_pp_activate_sid('sid800');
}
if(isset($_POST['htpasswdfile']) && $_POST['htpasswdfile']!=$aa_PP['htpasswd']){
if(!is_writable(dirname($_POST['htpasswdfile'])) && !touch($_POST['htpasswdfile'])) return aa_pp_err($_POST['htpasswdfile'].' location is not writable!');
else {
if(!aa_pp_insert_mark($_POST['htpasswdfile'],'AskApache PassPro',aa_pp_extract_mark($aa_PP['htpasswd'],'AskApache PassPro')))return aa_pp_err('error writing new password file.');
else aa_pp_unlink($aa_PP['htpasswd']);
$aa_PP['htpasswd']=$_POST['htpasswdfile'];
if($aa_PP['S']['sid900']['ON']=='1')aa_pp_activate_sid('sid900');
if($aa_PP['S']['sid800']['ON']=='1')aa_pp_activate_sid('sid800');
}
}
}
else if(isset($_POST['aappsetupcomplete'])){
if(isset($_POST['aapassformat']))$aa_PP['format']=$_POST['aapassformat'];
if(isset($_POST['htaccessuser']) && isset($_POST['htaccesspass'])) $aa_PP['user']=$_POST['htaccessuser'];
if(isset($_POST['htaccessrealm']) && $aa_PP['realm']!=$_POST['htaccessrealm']) {
if(strlen($aa_PP['realm'])>45)$aa_PP['realm']=substr($aa_PP['realm'], 0, 45);
}
if(isset($_POST['htpasswdfile'])){
if(!is_writable(dirname($_POST['htpasswdfile'])) && !touch($_POST['htpasswdfile'])) return aa_pp_err($_POST['htpasswdfile'].' location is not writable!');
else $aa_PP['htpasswd']=$_POST['htpasswdfile'];
}
$aa_PP['HTPASSWD_RULES']=array(aa_pp_hashit($_POST['aapassformat'],$_POST['htaccessuser'],$_POST['htaccesspass']));
if(!aa_pp_insert_mark($aa_PP['htpasswd'],'AskApache PassPro',$aa_PP['HTPASSWD_RULES'])) return aa_pp_err('Error Creating '.$aa_PP['htpasswd']);
if(isset($_POST['sid900']))aa_pp_activate_sid('sid900');
else aa_pp_erase_sid('sid900');
}
else if(isset($_POST['updatemodules'])){
if(isset($_POST['sid700']))aa_pp_activate_sid('sid700');
else aa_pp_erase_sid('sid700');
if(isset($_POST['sid800']))aa_pp_activate_sid('sid800');
else aa_pp_erase_sid('sid800');
if(isset($_POST['sid900']))aa_pp_activate_sid('sid900');
else aa_pp_erase_sid('sid900');
if($aa_PP['mod_rewrite_support']=='1'){
if(isset($_POST['sid1000']) || isset($_POST['sid1010']) || isset($_POST['sid1012']) || isset($_POST['sid1015']) || isset($_POST['sid1017']) || isset($_POST['sid1030'])) aa_pp_activate_sid('modrewrite');
else aa_pp_erase_sid('modrewrite');
if(isset($_POST['sid1000']))aa_pp_activate_sid('sid1000');
else aa_pp_erase_sid('sid1000');
if(isset($_POST['sid1010']))aa_pp_activate_sid('sid1010');
else aa_pp_erase_sid('sid1010');
if(isset($_POST['sid1011']))aa_pp_activate_sid('sid1011');
else aa_pp_erase_sid('sid1011');
if(isset($_POST['sid1012']))aa_pp_activate_sid('sid1012');
else aa_pp_erase_sid('sid1012');
if(isset($_POST['sid1015']))aa_pp_activate_sid('sid1015');
else aa_pp_erase_sid('sid1015');
if(isset($_POST['sid1017']))aa_pp_activate_sid('sid1017');
else aa_pp_erase_sid('sid1017');
if(isset($_POST['sid1018']))aa_pp_activate_sid('sid1018');
else aa_pp_erase_sid('sid1018');
if(isset($_POST['sid1019']))aa_pp_activate_sid('sid1019');
else aa_pp_erase_sid('sid1019');
if(isset($_POST['sid1020']))aa_pp_activate_sid('sid1020');
else aa_pp_erase_sid('sid1020');
if(isset($_POST['sid1021']))aa_pp_activate_sid('sid1021');
else aa_pp_erase_sid('sid1021');
if(isset($_POST['sid1022']))aa_pp_activate_sid('sid1022');
else aa_pp_erase_sid('sid1022');
if(isset($_POST['sid1023']))aa_pp_activate_sid('sid1023');
else aa_pp_erase_sid('sid1023');
if(isset($_POST['sid1024']))aa_pp_activate_sid('sid1024');
else aa_pp_erase_sid('sid1024');
if(isset($_POST['sid1025']))aa_pp_activate_sid('sid1025');
else aa_pp_erase_sid('sid1025');
if(isset($_POST['sid1026']))aa_pp_activate_sid('sid1026');
else aa_pp_erase_sid('sid1026');
if(isset($_POST['sid1027']))aa_pp_activate_sid('sid1027');
else aa_pp_erase_sid('sid1027');
if(isset($_POST['sid1028']))aa_pp_activate_sid('sid1028');
else aa_pp_erase_sid('sid1028');
if(isset($_POST['sid1029']))aa_pp_activate_sid('sid1029');
else aa_pp_erase_sid('sid1029');
if(isset($_POST['sid1030']))aa_pp_activate_sid('sid1030');
else aa_pp_erase_sid('sid1030');
}
if($aa_PP['mod_security_support']=='1') {
if(isset($_POST['sid2000']))aa_pp_activate_sid('modsecurity');
else aa_pp_erase_sid('modsecurity');
if(isset($_POST['sid2000']))aa_pp_activate_sid('sid2000');
else aa_pp_erase_sid('sid2000');
}
}
if(AA_PP_DEBUG){echo '
';print_r($_POST);echo '
';}
update_option('askapache_password_protect',$aa_PP);
}//=========================================================================================================================
// aa_pp_main_page
//-------------------------------------------------------------------------------------------------------------------------
function aa_pp_main_page() {
global $aa_PP;
aa_pp_print_header();
?>
0){
foreach($cu as $key){
$CURRENT_USERS[]=preg_replace('/(.+):(.+)/', "\\1", $key, 1);
}
}
return $CURRENT_USERS;
}//=========================================================================================================================
//---------------------------
function aa_pp_microtime(){
global $aa_pp_script_time,$aa_pp_socket_read_time;
return (float)array_sum(explode(' ', microtime()));
}//=====================================================================================
/* very cool! this is run during socket reads and checks whether the script
execution time limit or the socket read time limit has been met, killing
the script if so, otherwise returns true. Run with a cron-like process */
//---------------------------
function aa_pp_time_ok($print=0) {
global $aa_pp_script_time,$aa_pp_socket_read_time;
$current_time=aa_pp_microtime();
$total_time=($current_time - $aa_pp_script_time);
$sock_time=($current_time - $aa_pp_socket_read_time);
if($print) echo ($print==1) ? round($total_time,4)."\n" : round($sock_time,4)."\n";
else {
if((float)$total_time > AA_PP_MAX_TIME) return aa_pp_err('killed script.. time exceeded '.AA_PP_MAX_TIME.' Total: '.$total_time);
if((float)$sock_time > AA_PP_SOCKET_TIME) return aa_pp_err('Killed socket.. time exceeded '.AA_PP_SOCKET_TIME.' Total: '.$sock_time);
}
return true;
}//=====================================================================================
/* returns a socket pointer if valid or displays an error message
sets stream timeout, starts the clock to check for socket read time */
//---------------------------
function aa_pp_get_sock($target,$port){
global $aa_pp_script_time,$aa_pp_socket_read_time;
if(false===($fp = @fsockopen($target,$port,$errno,$errstr,AA_PP_CONNECT_TIME))||!is_resource($fp)) return aa_pp_sock_strerror($errno,$errstr);
@stream_set_timeout($fp, AA_PP_SOCKET_TIME);
return $fp;
}//=====================================================================================
/* writes request, then reads response until EOF, script max, or socket max
returns response on success. Uses buffer to allow size>100megs */
//---------------------------
function aa_pp_txrx($fp,$request,$chunk=128){
global $aa_pp_script_time,$aa_pp_socket_read_time;
$aa_pp_socket_read_time=aa_pp_microtime();
$rec=$buf='';
if(!@fwrite($fp, $request, strlen($request)))return aa_pp_err('fwrite error');
while ( !@feof($fp) && aa_pp_time_ok() && strpos( $response, AA_CRLF )===false){
$buf = @fread($fp, $chunk);
$rec .= $buf;
}
if(!@fclose($fp))return aa_pp_err('fclose error');
return $rec;
}//=====================================================================================
/* handles fsockopen errors, printing them out though you may want to die on err */
//---------------------------
function aa_pp_sock_strerror($errno,$errstr){
switch($errno){
case -3: $err="Socket creation failed"; break;
case -4: $err="DNS lookup failure"; break;
case -5: $err="Connection refused or timed out"; break;
case 111: $err="Connection refused"; break;
case 113: $err="No route to host"; break;
case 110: $err="Connection timed out"; break;
case 104: $err="Connection reset by client"; break;
default: $err="Connection failed"; break;
}
return aa_pp_err("Fsockopen failed! [{$errno}] {$err} ({$errstr})");
}//=====================================================================================
function aa_pp_run_tests($dir){
global $wpdb, $aa_PP, $aa_pp_script_time,$aa_pp_socket_read_time;
$aa_pp_script_time=microtime_float();
$sep = "\n
NOTE: This is an incredibly powerful plugin. This can easily take your site down temporarily.
This plugin modifies 2 files on your server /.htaccess + /wp-admin/.htaccess this plugin does NOT modify wordpress.
If you experience an error that you can't fix by disabling a security SID from the AskApache Password Protection Option Panel or resetting/re-activating the plugin, all you need to do is remove the sections added by the plugin from the 2 .htaccess files using ftp, ssh, webftp, or contact support, etc.. You should definately figure out how to do access those 2 files before you get going. That said, this plugin is sweet have fun! ;)