Plugin Directory

Changeset 995775


Ignore:
Timestamp:
09/23/2014 11:24:05 PM (12 years ago)
Author:
askapache
Message:

Bug fixes in preparation for upcoming 4.7

Location:
askapache-password-protect
Files:
21 added
4 edited

Legend:

Unmodified
Added
Removed
  • askapache-password-protect/trunk/askapache-password-protect.php

    r986713 r995775  
    66 * Author: askapache
    77 * Contributors: askapache
    8  * Version: 4.6.9
     8 * Version: 4.6.10
    99 * Requires at least: 2.7
    1010 * Tested up to: 4.0
     
    4141 COMPAT FUNCTIONS
    4242 ********************************************************************************************************************************************************************************************************/
    43 if (!function_exists('wp_die')) : function wp_die ($message = 'wp_die') { die($message); } endif;
    44 if (!function_exists('absint')): function absint( $maybeint ) { return abs( intval( $maybeint ) ); } endif;
    4543if (!function_exists('is_a')) : function is_a($o, $c) { return (!is_object($o)) ? false : ((strtolower(get_class($o)) == strtolower($c)) ? true : is_subclass_of($o, $c)); } endif;
    4644if (!function_exists('stripos')) : function stripos($haystack, $needle, $offset = 0) { return strpos(strtolower($haystack), strtolower($needle), $offset); } endif;
     
    5048 DEFINES
    5149 ********************************************************************************************************************************************************************************************************/
     50! defined( '__DIR__' ) && define( '__DIR__', realpath( dirname( __FILE__ ) ) ); // Added in PHP 5.3.0
    5251!defined('NET_SOCKET_READ') && define('NET_SOCKET_READ',  1);
    5352!defined('NET_SOCKET_WRITE') && define('NET_SOCKET_WRITE', 2);
     
    7170
    7271// AA_PP DEFINES
    73 !defined('AA_PP_DIR') && define('AA_PP_DIR', dirname(__FILE__));
    74 !defined('AA_PP_URL') && define('AA_PP_URL', WP_PLUGIN_URL . '/' . basename(dirname(__FILE__)));
     72!defined('AA_PP_DIR') && define('AA_PP_DIR', __DIR__);
     73!defined('AA_PP_URL') && define('AA_PP_URL', WP_PLUGIN_URL . '/' . basename(__DIR__));
    7574
    7675define( 'AA_PP_DEBUG', 0 ); // set this to 1 for verbose debugging
     
    114113
    115114    $scheme = ( isset($_SERVER['HTTPS']) && ( 'on' == strtolower($_SERVER['HTTPS']) ||  '1' == $_SERVER['HTTPS'] )  || ( isset($_SERVER['SERVER_PORT']) && ( '443' == $_SERVER['SERVER_PORT'] ) )) ? 'https' : 'http';
    116     $home = get_option( 'home' );
    117     $siteurl=get_option('siteurl');
    118     if($scheme=='https' && strpos($siteurl.$home,'https://')!==FALSE)$scheme='http';
     115    $home = get_home_url();
     116    $siteurl= get_site_url();
     117    if($scheme=='https' && strpos($siteurl.$home,'https://')!==false)$scheme='http';
    119118
    120119    $su = parse_url( $home );
     
    125124    !defined('WP_PLUGIN_URL') && define( 'WP_PLUGIN_URL', WP_CONTENT_URL . '/plugins' );
    126125
    127     $home = get_option( 'siteurl' );
     126    $home = get_site_url();
    128127   
    129128    $su = parse_url( $home );
     
    210209                ),
    211210
    212             21030002 => array( 'Version' => '1.3',
     211            21030002 => array( 'Version' => '1.4',
    213212                'Name' => 'Password Protect wp-admin',
    214213                'Description' => 'Requires a valid user/pass to access any non-static (css, js, images) file in this directory...',
     
    484483    }
    485484
    486     foreach( array( 'a_user', 'a_authdomain', 'a_authtype', 'a_algorithm', 'a_authname', 'a_authuserfile', 'a_step', 'a_admin_email', 'a_root_htaccess', ) as $k )
    487     {
    488         if ( isset( $_POST[$k] ) && !empty( $_POST[$k] ) && $_POST[$k] != $v[$k] )
     485    foreach( array( 'a_user', 'a_authdomain', 'a_authtype', 'a_algorithm', 'a_authname', 'a_authuserfile', 'a_step', 'a_admin_email', 'a_root_htaccess' ) as $k )
     486    {
     487        if ( array_key_exists( $k, $_POST )  && !empty( $_POST[ $k ] ) )
    489488        {
    490489            check_admin_referer( 'askapache-passpro-form' );
    491             $v[substr( $k, 2 )] = $_POST[$k];
     490            $v[ substr( $k, 2 ) ] = $_POST[ $k ];
    492491        }
    493492    }
     
    534533    }
    535534
    536     if ( isset( $_POST['a_user'] ) && isset( $_POST['a_admin_email'] ) )
    537     {
    538         if ( empty( $_POST['a_user'] ) )$errors->add( 'username-required', __( '<strong>ERROR</strong>: A username is required.' ) );
     535    if ( isset( $_POST['a_user'] ) ) {
     536        if ( empty( $_POST['a_user'] ) ) {
     537            $errors->add( 'username-required', __( '<strong>ERROR</strong>: A username is required.' ) );
     538        } else {
     539            $v['user'] = $_POST['a_user'];
     540        }
     541    }
     542   
     543    if ( isset( $_POST['a_admin_email'] ) )
     544    {
    539545        if ( empty( $_POST['a_admin_email'] ) )$errors->add( 'adminemail-required', __( '<strong>ERROR</strong>: An admin email is required.' ) );
    540546        if ( !is_email( $_POST['a_admin_email'] ) )$errors->add( 'adminemail-bad', __( '<strong>ERROR</strong>: A valid admin email is required.' ) );
     
    600606        if ( isset( $pass ) && count( $errors->errors ) == 0 )
    601607        {
    602             $message_headers = 'From: "' . $blog_title . '" <wordpress@' . str_replace( 'www.', '', $aa_PP['host'] ) . '>';
    603             $message = sprintf( __( "Your new username and password has been successfully set up at:\n\n%1\$s\n\nYou can log in to the administrator area with the following information:\n\n\nUsername: %2\$s\n\nWe hope you enjoy your new protection. Thanks!\n\n--The AskApache Team\nhttp://www.askapache.com/" ), get_option( 'siteurl' ) . '/wp-admin/', $v['user'] );
    604 
    605             if ( !aa_pp_file_put_c( $v['authuserfile'], aa_pp_hashit( $v['authtype'], $v['user'], $pass, $v['authname'] ), false ) )
     608            $message_headers = 'From: "' . get_bloginfo( 'name' ) . '" <wordpress@' . str_replace( 'www.', '', $aa_PP['host'] ) . '>';
     609            $message = sprintf( __( "Your new username and password has been successfully set up at:\n\n%1\$s\n\nYou can log in to the administrator area with the following information:\n\n\nUsername: %2\$s\n\nWe hope you enjoy your new protection. Thanks!\n\n--The AskApache Team\nhttp://www.askapache.com/" ), get_site_url() . '/wp-admin/', $v['user'] );
     610
     611            if ( !aa_pp_file_put_c( $v['authuserfile'], aa_pp_hashit( $v['algorithm'], $v['user'], $pass, $v['authname'] ), false ) ) {
    606612                $errors->add( 'failed-create-authuserfile', __( '<strong>ERROR</strong>: Failed to create ' . $v['authuserfile'] ) );
     613            }
    607614               
    608             else if ( !wp_mail( $aa_PP['admin_email'], __( '__New AskApache User' ), $message, $message_headers ) )
    609                 $errors->add( 'failed-wp-mail', __( '<strong>ERROR</strong>: Failed to mail to ' . $aa_PP['admin_email'] ) );
     615            /*
     616            if ( !wp_mail( $aa_PP['admin_email'], __( '__New AskApache User' ), $message, $message_headers ) ) {
     617                echo '<strong>ERROR</strong>: Failed to mail to ' . $aa_PP['admin_email'];
     618            }
     619            */
    610620        }
    611621    }
     
    632642    global $aa_PP, $aa_SIDS, $aa_PLUGIN;
    633643   
     644    if (!current_user_can("manage_options"))wp_die("manage_options cap required");
     645
    634646    echo '<div class="wrap">';
     647
    635648   
    636649    $aa_PLUGIN=aa_pp_get_plugin_data();
     
    638651    $aa_PP = get_option( 'askapache_password_protect' );
    639652    $aa_PP['scheme'] = ( isset($_SERVER['HTTPS']) && ( 'on' == strtolower($_SERVER['HTTPS']) ||  '1' == $_SERVER['HTTPS'] )  || ( isset($_SERVER['SERVER_PORT']) && ( '443' == $_SERVER['SERVER_PORT'] ) )) ? 'https' : 'http';
    640     $home = get_option( 'home' );
    641     $siteurl=get_option('siteurl');
    642     if($aa_PP['scheme']=='https' && strpos($siteurl.$home,'https://')!==FALSE)$aa_PP['scheme']='http';
     653    $home = get_home_url();
     654    $siteurl=get_site_url();
     655    if($aa_PP['scheme']=='https' && strpos($siteurl.$home,'https://')!==false)$aa_PP['scheme']='http';
    643656
    644657    $aa_SIDS = get_option( 'askapache_password_protect_sids' );
    645     if (!current_user_can("manage_options"))wp_die("manage_options cap required");
    646658
    647659
    648660
    649661    $errors = aa_pp_get_post_values( $aa_PP );
     662    if ( ! array_key_exists('user', $aa_PP ) ) {
     663        $aa_PP['user'] = '';
     664    }
    650665    aa_pp_errors( $errors );
    651666
     
    688703    if ( isset($_POST,$_POST['notice'] ) ) echo '<div id="message" class="updated fade"><p>' . $_POST['notice'] . '</p></div>';
    689704
    690     $aa_PP['test_dir']=dirname(__FILE__).'/tests';
     705    $aa_PP['test_dir']=__DIR__.'/tests';
    691706   
    692707   
     
    698713            ?>
    699714            <div class="wrap" style="max-width:95%;">
    700                   <h3>Still waiting for that 4.7 version update</h3>
     715                <h3>Still waiting for that 4.7 version update</h3>
     716                <p>2014-09-23 - Still not finished with it.  Wait for the 4.7 release!!!!!!!!!!!</p>
     717                <p><br class="clear" /></p>
     718
     719                <h3>Still waiting for that 4.7 version update</h3>
    701720                <p>2013-03-07 - I've completely re-written this plugin, its' 100x better.  Still not finished with it.  Wait for the 4.7 release!!!!!!!!!!!</p>
    702721                <p><br class="clear" /></p>
     
    763782    ?>
    764783    <div style="overflow:hidden;position:relative;">
    765     <h3 style="color:red; text-decoration:blink">Warning! Warning! Warning! Warning! Warning! Warning! Warning!</h3>
     784    <h3 style="color:red">Warning! Warning!  (Look for a big update soon :)</h3>
    766785    <div style="background-color: #FFEBE8; border-color: #CC0000; border:1px solid; padding: 0 0.6em;margin: 5px 0 15px;">
    767786        <p>WARNING: <strong>If you lock YOURSELF out of your site:</strong>  DO NOT JUST DELETE PLUGIN.  This plugin ONLY edits 2 files. It does <strong>NOT</strong> modify other files, it does <strong>NOT</strong> modify database, it does <strong>NOT</strong> modify rewrites, just these 2 files:</p>
     
    9971016       <?php
    9981017           
    999             $c=array();$vb=false;
     1018            $c=array();
     1019            $vb=false;
    10001020            foreach ((array)(aa_pp_checkfunction('get_defined_constants')?@get_defined_constants():array())as $k=>$v) {
    1001                 if(($vb||(!$vb&&$k=='WP_ADMIN'&&$vb=true)) && (strlen($v)>10||strpos($v,'/')!==FALSE))$c[$k]=$v;
     1021                if( ($vb||(!$vb&&$k=='WP_ADMIN'&&$vb=true)) ) {
     1022                    if ( substr_count($v,DIRECTORY_SEPARATOR) > 2 ) $c[$k]=$v;
     1023                }
    10021024            }
    10031025           
    10041026            echo '<pre>';
    10051027            ksort($c);
     1028            unset( $c['DB_PASSWORD'] );
    10061029            echo htmlspecialchars(print_r(array('Plugin Options'=>$aa_PP,'Active SIDS'=>aa_pp_active_sids(),'Constants'=>$c),1));
    10071030            echo '</pre>';
    10081031           
    10091032            aa_pp_pls(WP_CONTENT_DIR, 1);
    1010             aa_pp_pls(dirname(__FILE__), 1);
     1033            aa_pp_pls(__DIR__, 1);
    10111034            aa_pp_pls(ABSPATH, 1);
    10121035        ?>
     
    10421065            <tr valign="top">
    10431066                <th scope="row"><label for="a_user">Username</label></th>
    1044                 <td><input size="40" name="a_user" type="text" id="a_user" value="<?php echo $aa_PP['user'];?>" /></td>
     1067                <td><input size="40" name="a_user" type="text" id="a_user" value="<?php echo ( isset( $aa_PP['user'] ) ? $aa_PP['user'] : '' );?>" /></td>
    10451068            </tr>
    10461069            <tr valign="top">
     
    11531176
    11541177    $data = aa_pp_readfile( $file );
    1155     if ( $aa_PP['gzip_support'] != 1 )$data_compress = base64_encode( $data );
    1156     else $data_compress = base64_encode( gzcompress( $data, 9 ) );
     1178    if ( $aa_PP['gzip_support'] != 1 ) {
     1179        $data_compress = base64_encode( $data );
     1180    } else {
     1181        $data_compress = base64_encode( gzcompress( $data, 9 ) );
     1182    }
    11571183
    11581184    $tag = ( strpos( $file, 'wp-admin' ) !== false )?1:0;
     
    15041530    global $aa_PP, $aa_SIDS;
    15051531    $scheme = ( isset($_SERVER['HTTPS']) && ( 'on' == strtolower($_SERVER['HTTPS']) ||  '1' == $_SERVER['HTTPS'] )  || ( isset($_SERVER['SERVER_PORT']) && ( '443' == $_SERVER['SERVER_PORT'] ) )) ? 'https' : 'http';
    1506     $home = get_option( 'home' );
     1532    $home = get_home_url();
    15071533    $siteurl=get_option('siteurl');
    1508     if($scheme=='https' && strpos($siteurl.$home,'https://')!==FALSE)$aa_PP['scheme']='http';
     1534    if($scheme=='https' && strpos($siteurl.$home,'https://')!==false)$aa_PP['scheme']='http';
    15091535
    15101536    if ( $aa_PP['authtype'] == 'Basic' ) $replacement = 'AuthType %authtype%%n%AuthName "%authname%"%n%AuthUserFile %authuserfile%%n%Require user %user%';
     
    18101836    aa_pp_notify( __FUNCTION__ . ':' . __LINE__ );
    18111837    global $wpdb, $wp_version, $aa_PP, $aa_SIDS, $aa_PLUGIN;
    1812     require_once dirname(__FILE__).'/class-askapache-net.php';
     1838    require_once __DIR__.'/class-askapache-net.php';
    18131839     
    18141840     
     
    18261852  'mod_mime_magic', 'mod_negotiation', 'mod_netware', 'mod_nw_ssl', 'mod_optional_fn_export', 'mod_optional_fn_import',
    18271853  'mod_optional_hook_export', 'mod_optional_hook_import', 'mod_passenger', 'mod_proxy', 'mod_proxy_ajp', 'mod_proxy_balancer',
    1828   'mod_proxy_connect', 'mod_proxy_ftp', 'mod_proxy_http', 'mod_rewrite', 'mod_security', 'mod_setenvif', 'mod_so',
     1854  'mod_proxy_connect', 'mod_proxy_ftp', 'mod_proxy_http', 'mod_rewrite', 'mod_security', 'mod_security2', 'mod_setenvif', 'mod_so',
    18291855  'mod_speling', 'mod_ssl', 'mod_status', 'mod_substitute', 'mod_suexec', 'mod_test', 'mod_unique_id', 'mod_userdir',
    18301856  'mod_usertrack', 'mod_version', 'mod_vhost_alias', 'mod_win32', 'prefork', 'sapi_apache2'
     
    18341860    $ap = $aa_PP;
    18351861    $scheme = ( isset($_SERVER['HTTPS']) && ( 'on' == strtolower($_SERVER['HTTPS']) ||  '1' == $_SERVER['HTTPS'] )  || ( isset($_SERVER['SERVER_PORT']) && ( '443' == $_SERVER['SERVER_PORT'] ) )) ? 'https' : 'http';
    1836     $home = get_option( 'home' );
    1837     $siteurl=get_option('siteurl');
    1838     if($scheme=='https' && strpos($siteurl.$home,'https://')!==FALSE)$scheme='http';
    1839     $home = get_option( 'siteurl' );
     1862    $home = get_home_url();
     1863    $siteurl=get_site_url();
     1864    if($scheme=='https' && strpos($siteurl.$home,'https://')!==false)$scheme='http';
     1865    $home = get_site_url();
    18401866    $hu = str_replace( $scheme . '://', '', $home );
    18411867    $uri =  plugins_url('/tests/',__FILE__);
    18421868    aa_pp_notify('uri: '.$uri);
    1843     $test_root_path = str_replace(ABSPATH,'/',dirname(__FILE__).'/tests/');
     1869    $test_root_path = str_replace(ABSPATH,'/',__DIR__.'/tests/');
    18441870    aa_pp_notify('test_root_path: '.$test_root_path);
    18451871    $test_url_base = plugins_url('/tests/',__FILE__);
     
    19261952<h2>Why Test?</h2>
    19271953<p>First we need to run a series of tests on your server to determine what capabilities your site has and also to locate any potential installation problems.</p>
    1928 <p>The tests will be run on temporary files I'll create in your <?php echo dirname(__FILE__).'/tests';?> folder.  They will create .htaccess and .htpasswd files in that location and then use
     1954<p>The tests will be run on temporary files I'll create in your <?php echo __DIR__.'/tests';?> folder.  They will create .htaccess and .htpasswd files in that location and then use
    19291955 fsockopen networking functions to query those files.  This tells us exactly how your server handles .htaccess configurations, HTTP authentication schemes, Apache Module capability, etc..</p></p>
    19301956<p>Several tests send specially crafted HTTP requests which are designed to elicit very specific HTTP Protocol Responses to accurately determine your servers capabilities.</p>
     
    19471973        $tester = new AskApacheNet;
    19481974        $atest = ( $tester->sockit( "{$siteurl}" ) == 200 ) ? 1 : 0;
     1975       
     1976        if ( ! $atest ) {
     1977            $atest = ( $tester->sockit( "{$siteurl}/" ) == 200 ) ? 1 : 0;
     1978        }
     1979
    19491980        $msg = ( $atest ) ? $aok : $fail;
    19501981        $tester->print_tcp_trace();
     
    19631994    echo $m_s . $msg . " open_basedir on/off {$open_basedir}" . $m_e;
    19641995
     1996
     1997
    19651998    $htaccess_test1 = $atest = ( @is_writable( $ap['admin_htaccess'] ) || @touch( $ap['admin_htaccess'] ) ) ? 1 : 0;
    19661999    $msg = ( $atest ) ? $aok : $fail;
     
    20292062    echo $m_s . $msg . " Apache Version:  " . $apache_version . $m_e;
    20302063
    2031     $msg = ( @version_compare( phpversion(), '4.2.0', '=<' ) ) ? $info : $aok;
     2064    $msg = ( @version_compare( phpversion(), '5.0', '=<' ) ) ? $info : $aok;
    20322065    echo $m_s . $msg . " PHP Version " . phpversion() . $m_e;?>
    20332066
     
    20412074
    20422075    $memm = 10;
    2043     if ( function_exists( "memory_get_peak_usage" ) )$memm = memory_get_peak_usage( true );
    2044     else if ( function_exists( "memory_get_usage" ) )$memm = memory_get_usage( true );
     2076    if ( function_exists( "memory_get_peak_usage" ) ) {
     2077        $memm = @memory_get_peak_usage( true );
     2078    } elseif ( function_exists( "memory_get_usage" ) ) {
     2079        $memm = @memory_get_usage( true );
     2080    }
    20452081    echo $m_s . $info . "Memory Usage: " . round( $memm / 1024 / 1024, 2 ) . $m_e;
    20462082
    20472083    $mem = abs( intval( @ini_get( 'memory_limit' ) ) );
    20482084    echo $m_s . $info . 'Memory Limit: ' . "{$mem}" . $m_e;
    2049     if ( $mem && $mem < abs( intval( 32 ) ) )@ini_set( 'memory_limit', 64 );
     2085    if ( $mem && $mem < abs( intval( 32 ) ) ) {
     2086        @ini_set( 'memory_limit', 64 );
     2087    }
    20502088
    20512089    $phpini = @get_cfg_var( 'cfg_file_path' );
     
    20542092    $safe_mode = @ini_get( 'safe_mode' );
    20552093    $msg = ( empty( $safe_mode ) ) ? $info : $warn;
    2056     echo $m_s . $msg . " safe_mode on/off {$safe_mode}" . $m_e;
     2094    echo $m_s . $msg . " safe_mode on/off: {$safe_mode}" . $m_e;
    20572095
    20582096    $disabled_functions = @ini_get( 'disable_functions' );
    20592097    $msg = ( empty( $disabled_functions ) ) ? $info : $warn;
    2060     echo $m_s . $msg . " disable_functions {$disabled_functions}" . $m_e;?>
     2098    echo $m_s . $msg . " disable_functions: {$disabled_functions}" . $m_e;?>
    20612099
    20622100
     
    21032141    {
    21042142        $data = aa_pp_readfile( $ap['test_dir'] . '/.htaccess' );
    2105         $data_md5 = md5_file( $ap['test_dir'] . '/.htaccess' );
    2106 
    2107         $data_compress = base64_encode( gzcompress( $data, 9 ) );
    2108         aa_pp_file_put_c( $ap['test_dir'] . '/.htaccess-compress', $data_compress );
    2109 
    2110         $data_decompress = gzuncompress( base64_decode( aa_pp_readfile( $ap['test_dir'] . '/.htaccess-compress' ) ) );
    2111         aa_pp_file_put_c( $ap['test_dir'] . '/.htaccess-decompress', $data_decompress );
    2112 
    2113         $data_decompress_md5 = md5_file( $ap['test_dir'] . '/.htaccess-decompress' );
    2114 
    2115         $atest = ( $data_decompress_md5 == $data_md5 ) ? 1 : 0;
     2143       
     2144        if ( ! is_object( $data ) ) {
     2145       
     2146            $data_md5 = md5_file( $ap['test_dir'] . '/.htaccess' );
     2147   
     2148            $data_compress = base64_encode( gzcompress( $data, 9 ) );
     2149            aa_pp_file_put_c( $ap['test_dir'] . '/.htaccess-compress', $data_compress );
     2150   
     2151            $data_decomp = aa_pp_readfile( $ap['test_dir'] . '/.htaccess-compress' );
     2152           
     2153            if ( ! is_object( $data_decomp ) ) {
     2154                $data_decompress = gzuncompress( base64_decode( $data_decomp ) );
     2155                aa_pp_file_put_c( $ap['test_dir'] . '/.htaccess-decompress', $data_decompress );
     2156       
     2157                $data_decompress_md5 = md5_file( $ap['test_dir'] . '/.htaccess-decompress' );
     2158       
     2159                $atest = ( $data_decompress_md5 == $data_md5 ) ? 1 : 0;
     2160            } else {
     2161                $atest = false;
     2162            }
     2163
     2164        } else {
     2165            $atest = false;
     2166        }
     2167       
    21162168        $msg = ( $atest ) ? $aok : $fail;
    21172169        echo $m_s . $msg . " Revisions Enabled" . $m_e;
     
    21632215
    21642216    $tester = new AskApacheNet;
    2165     $ap['mod_security_support'] = $atest = ( $tester->sockit( "{$test_url_base}modsec_check.gif?modsecuritytest" ) == 403 ) ? 1 : 0;
     2217    $ap['mod_security_support'] = $atest = ( $tester->sockit( "{$test_url_base}modsec_check.gif?modsecuritytest" ) == 503 ) ? 1 : 0;
    21662218    $msg = ( $atest ) ? $aok : $fail;
    2167     echo $m_s . $msg . " mod_security detection [!403]" . $m_e;
     2219    echo $m_s . $msg . " mod_security detection [!503]" . $m_e;
    21682220    if ( (bool)AA_PP_DEBUG === true || !$atest )$tester->print_tcp_trace();
    21692221
     
    23022354    $vb=false;
    23032355    foreach ((array)(aa_pp_checkfunction('get_defined_constants')?@get_defined_constants():array())as $k=>$v) {
    2304         if(($vb||(!$vb&&$k=='WP_ADMIN'&&$vb=true)) && (strlen($v)>10||strpos($v,'/')!==FALSE))$c[$k]=$v;
     2356        if( ($vb||(!$vb&&$k=='WP_ADMIN'&&$vb=true)) ) {
     2357            if ( substr_count($v,DIRECTORY_SEPARATOR) > 2 ) $c[$k]=$v;
     2358        }
    23052359    }
    23062360    echo '<pre>';
     
    23112365
    23122366    aa_pp_pls(WP_CONTENT_DIR, 1);
    2313     aa_pp_pls(dirname(__FILE__), 1);
     2367    aa_pp_pls(__DIR__, 1);
    23142368    aa_pp_pls(ABSPATH, 1);
    23152369
     
    23332387    aa_pp_notify( __FUNCTION__ . ":" . __LINE__ . ' ' . "Creating  $alg of $u for $an");
    23342388
     2389    if ( ! empty( $an ) && strtoupper( $alg ) == 'MD5' ) {
     2390        $alg = 'DIGEST';
     2391    }
     2392       
    23352393    switch (strtoupper($alg))
    23362394    {
     
    24122470    return $files;
    24132471}
     2472
    24142473/** aa_pp_mkdir
    24152474* aa_pp_mkdir()
     
    24202479function aa_pp_mkdir( $dir )
    24212480{
    2422     $old=@umask( 0 );
     2481    //$old=@umask( 0 );
    24232482    $dirname = ( @is_readable( $dir ) ) ? realpath( rtrim( $dir, '/' ) ) : rtrim( $dir, '/' );
    24242483    $dirname = str_replace( '//', '/', $dirname );
     
    24262485    @chmod( $dirname, 0755 );
    24272486    if ( is_dir( $dirname ) || @wp_mkdir_p( $dirname ) ) {
    2428         $new=@umask($old);
     2487        //$new=@umask($old);
    24292488        return $dirname;
    24302489    }
    24312490    elseif ( is_writable( $dirname ) && @wp_mkdir_p( $dirname ) ) {
    2432         $new=@umask($old);
     2491        //$new=@umask($old);
    24332492        return $dirname;
    24342493    }
    24352494    else {
    24362495        $ok=@mkdir( $dirname, 0755 );
    2437         $new=@umask($old);
     2496        //$new=@umask($old);
    24382497        return( (bool)$ok ? $dirname : new WP_Error( 'mkdir-failed', __( "Failed to create directory {$dirname}" ) ));
    24392498    }
    24402499}
     2500
    24412501/** aa_pp_unlink
    24422502* aa_pp_unlink()
     
    24482508function aa_pp_unlink( $f, $backup = false )
    24492509{
    2450     $old=@umask( 0 );
     2510    //$old=@umask( 0 );
    24512511    $f = ( @is_readable( $f ) ) ? realpath( rtrim( $f, '/' ) ) : rtrim( $f, '/' );
    24522512    $f = str_replace( '//', '/', $f );
    24532513
    24542514    if ( !@file_exists( $f ) ) {
    2455         $new=@umask($old);
     2515        //$new=@umask($old);
    24562516        return true;
    24572517    }
     
    24612521
    24622522    if ( is_dir( $f ) ) {
    2463         $new=@umask($old);
     2523        //$new=@umask($old);
    24642524        return aa_pp_rmdir( $f );
    24652525    }
     
    24672527
    24682528    if ( !@file_exists( $f ) ) {
    2469         $new=@umask($old);
     2529        //$new=@umask($old);
    24702530        return true;
    24712531    }
    24722532    $ret=( @chmod( $f, 0777 ) && @unlink( $f ) ) ? true : ( @chmod( dirname( $f ), 0777 ) && @unlink( $f ) ) ? true : new WP_Error( 'delete-failed', __( "Failed to delete {$f} in aa_pp_unlink" ) );
    24732533   
    2474     $new=@umask($old);
     2534    //$new=@umask($old);
    24752535    return $ret;
    24762536}
     2537
    24772538/** aa_pp_backup
    24782539* aa_pp_backup()
     
    24922553    else return $bf;
    24932554}
     2555
    24942556/** aa_pp_bytes
    24952557* aa_pp_bytes()
     
    25002562function aa_pp_bytes($b = 0)
    25012563{
    2502     static $s=NULL;
     2564    static $s=null;
    25032565    if(is_null($s)) $s = array('B', 'Kb', 'MB', 'GB', 'TB', 'PB');
    25042566    $e = floor(log($b) / log(1024));
    25052567    return sprintf('%.2f ' . $s[$e], (($b > 0) ? ($b / pow(1024, floor($e))) : 0));
    25062568}
     2569
    25072570/** aa_pp_file_put_c
    25082571* aa_pp_file_put_c()
     
    25152578function aa_pp_file_put_c( $f, $content, $backup = false )
    25162579{
    2517     $old=@umask( 0 );
     2580    //$old=@umask( 0 );
    25182581    //$f = ( @is_readable( $f ) ) ? realpath( rtrim( $f, '/' ) ) : rtrim( $f, '/' );
    25192582    aa_pp_notify( __FUNCTION__ . ":" . __LINE__ . ' ' . "Creating {$f}" );
    25202583    if ( !is_dir( dirname( $f ) ) ) aa_pp_mkdir( dirname( $f ) );
    25212584
    2522     if ( file_exists( $f ) && is_readable( $f ) && $backup ) $backedup = aa_pp_backup( $f );
     2585    if ( file_exists( $f ) && is_readable( $f ) && $backup ) {
     2586        $backedup = aa_pp_backup( $f );
     2587    }
    25232588
    25242589    if ( aa_pp_checkfunction( "file_put_contents" ) ) {
    2525         $new=@umask($old);
    2526         return @file_put_contents( $f, $content );
    2527     }
    2528 
    2529     if ( !$fh = @fopen( $f, 'wb' ) ) {
    2530         $new=@umask($old);
     2590        //$new=@umask($old);
     2591        return file_put_contents( $f, $content );
     2592    }
     2593
     2594    if ( ( $fh = fopen( $f, 'wb' ) ) === false || ! is_resource( $fh ) ) {
     2595        //$new=@umask($old);
    25312596        return new WP_Error( 'fopen-failed', __( "Couldnt fopen {$f}" ) );
    25322597    }
    2533     if ( !@fwrite( $fh, $content, strlen( $content ) ) ) {
    2534         $new=@umask($old);
     2598   
     2599    if ( fwrite( $fh, $content, strlen( $content ) ) === false ) {
     2600        //$new=@umask($old);
    25352601        return new WP_Error( 'fwrite-failed', __( "Couldnt fwrite {$f}" ) );
    25362602    }
    2537     if ( !@fclose( $fh ) ) {
    2538         $new=@umask($old);
     2603    if ( is_resource( $fh ) && ! fclose( $fh ) ) {
     2604        //$new=@umask($old);
    25392605        return new WP_Error( 'fclose-failed', __( "Couldnt fclose {$f}" ) );
    25402606    }
    25412607   
    2542     $new=@umask($old);
     2608    //$new=@umask($old);
    25432609    return true;
    25442610}
     
    25512617function aa_pp_readfile( $f, $size='all' )
    25522618{
    2553     $old=@umask( 0 );
    2554     $f = ( @is_readable( $f ) ) ? realpath( rtrim( $f, '/' ) ) : rtrim( $f, '/' );
     2619    $f = ( @is_readable( $f ) ) ? @realpath( rtrim( $f, '/' ) ) : rtrim( $f, '/' );
    25552620    aa_pp_notify( __FUNCTION__ . ":" . __LINE__ . ' ' . "Reading {$f}" );
    25562621
    2557    
    2558     if ( !$fh = @fopen( $f, 'rb' ) ) {
    2559         $new=@umask($old);
     2622    if ( ! @file_exists( $f ) ) {
     2623        // file doesn't exist homes
     2624        return '';
     2625    }
     2626   
     2627    if ( $size == 'all' ) {
     2628        $size = @filesize( $f );
     2629    }
     2630    $size = absint( $size );
     2631
     2632
     2633    if ( ( $fh = @fopen( $f, 'rb' ) ) === false || ! is_resource( $fh ) ) {
    25602634        return new WP_Error( 'fopen-failed', __( "Couldnt fopen {$f}" ) );
    25612635    }
    2562     if  ($size=='all' ) $size=@filesize( $f );
    2563     if ( !$filecontent = @fread( $fh, $size ) ) {
    2564         $new=@umask($old);
     2636   
     2637    // fopen succeeded but size is 0, empty file so return empty string
     2638    if ( $size == 0 ) {
     2639        return '';
     2640    }
     2641
     2642    if ( ( $filecontent = @fread( $fh, $size ) ) === false ) {
    25652643        return new WP_Error( 'fread-failed', __( "Couldnt fread {$f}" ) );
    25662644    }
    2567     if ( !@fclose( $fh ) ) {
    2568         $new=@umask($old);
     2645   
     2646    if ( is_resource( $fh ) && !fclose( $fh ) ) {
    25692647        return new WP_Error( 'fclose-failed', __( "Couldnt fclose {$f}" ) );
    25702648    }
    25712649
    2572     $new=@umask($old);
    25732650    return $filecontent;
    25742651}
     
    26232700function aa_pp_checkfunction($f)
    26242701{
    2625     static $b,$g = array();
    2626 
    2627     if(!isset($b)) {
    2628         $b=$disabled=array();
    2629         $disabled=array( @ini_get('disable_functions'), @ini_get('suhosin.executor.func.blacklist'), @get_cfg_var('disable_functions'),@get_cfg_var('suhosin.executor.func.blacklist'));
    2630         if (@ini_get('safe_mode')) {
    2631             $disabled[]='shell_exec';
    2632             $disabled[]='set_time_limit';
     2702    static $b, $g = array();
     2703
     2704    if ( ! isset( $b ) ) {
     2705        $b = $disabled = array();
     2706        $disabled = array(
     2707            (string) @ini_get('disable_functions'),
     2708            (string) @ini_get('suhosin.executor.func.blacklist'),
     2709            (string) @get_cfg_var('disable_functions'),
     2710            (string) @get_cfg_var('suhosin.executor.func.blacklist')
     2711        );
     2712        if ( @ini_get( 'safe_mode' ) ) {
     2713            $disabled[] = 'shell_exec';
     2714            $disabled[] = 'set_time_limit';
    26332715        }
    2634         $b=aa_pp_array_iunique(array_map('trim',explode(',',strtolower(preg_replace('/[,]+/',',',trim(join(',',$disabled),','))))));
    2635     }
    2636 
    2637     $f=strtolower($f);
    2638     if ( ( in_array($f, $g) || in_array($f, $b)) ) return (in_array($f, $g));
    2639     else return ( in_array($f,array($g,$b)) ? in_array($f, $g) : ( (!function_exists($f)) ? !( $b[]=$f ) : !!( $g[]=$f ) ) );
    2640 }
     2716        $b = aa_pp_array_iunique( array_map( 'trim', explode( ',', strtolower( preg_replace( '/[,]+/', ',', trim( join( ',', $disabled ), ',' ) ) ) ) ) );
     2717    }
     2718
     2719    $f = strtolower( $f );
     2720
     2721    if ( ( in_array( $f, $g ) || in_array( $f, $b ) ) ) {
     2722        return ( in_array( $f, $g ) );
     2723    } else {
     2724        return ( in_array( $f, array( $g, $b ) ) ? in_array( $f, $g ) : ( ( ! function_exists( $f ) ) ? ! ( $b[] = $f ) : !! ( $g[] = $f ) ) );
     2725    }
     2726}
     2727
    26412728
    26422729/** aa_pp_array_iunique
     
    27752862
    27762863
    2777 ?>
     2864
     2865
     2866
     2867// EOF
  • askapache-password-protect/trunk/class-askapache-net.php

    r305486 r995775  
    66 * @author askapache.com
    77 * @copyright Copyright (c) 2008 AskApache.com
    8  * @version 1.6
     8 * @version 1.6.1
    99 * @access public
    1010*/
     
    2525{
    2626    var $socket = array(
    27     'protocol' => '1.0', 'method' => 'GET', 'ua' => 'Mozilla/5.0 (compatible; AskApacheNet/1.0; http://www.askapache.com)', 'referer' => 'http://www.askapache.com',
    28     'port' => '80',
    29     'url' => '',
    30     'scheme' => '',
    31     'host' => '',
    32     'ip' => '',
    33     'user' => '',
    34     'pass' => '',
    35     'path' => '',
    36     'query' => '',
    37     'fragment' => ''
     27        'protocol' => '1.0',
     28        'method' => 'GET',
     29        'ua' => 'Mozilla/5.0 (compatible; AskApacheNet/1.0; http://www.askapache.com)',
     30        'referer' => 'http://www.askapache.com',
     31        'port' => '80',
     32        'url' => '',
     33        'scheme' => '',
     34        'host' => '',
     35        'ip' => '',
     36        'user' => '',
     37        'pass' => '',
     38        'path' => '',
     39        'query' => '',
     40        'fragment' => ''
    3841    );
    3942   
    4043    var $Digests = array(
    41     'realm' => '',
    42     'nonce' => '',
    43     'uri' => '',
    44     'algorithm' => 'MD5',
    45     'qop' => 'auth',
    46     'opaque' => '',
    47     'domain' => '',
    48     'nc' => '00000001',
    49     'cnonce' => '82d057852a9dc497',
    50     'A1' => '',
    51     'A2' => '',
    52     'response' => ''
     44        'realm' => '',
     45        'nonce' => '',
     46        'uri' => '',
     47        'algorithm' => 'MD5',
     48        'qop' => 'auth',
     49        'opaque' => '',
     50        'domain' => '',
     51        'nc' => '00000001',
     52        'cnonce' => '82d057852a9dc497',
     53        'A1' => '',
     54        'A2' => '',
     55        'response' => ''
    5356    );
    5457   
     
    480483}
    481484endif;
    482 ?>
     485
     486
     487
     488
     489// EOF
  • askapache-password-protect/trunk/readme.txt

    r986713 r995775  
    55Requires at least: 2.7
    66Tested up to: 4.0
    7 Stable tag: 4.6.9
     7Stable tag: 4.6.10
    88This plugin Adds Crazy Additional Password Protection and Security to your blog. 
    99
  • askapache-password-protect/trunk/tests/err.php

    r305488 r995775  
    11<?php
     2
    23ob_start();
    34//http://www.askapache.com/htaccess/apache-status-code-headers-errordocument.html
     
    142143 if ($err_code == '405') @header('Allow: GET,HEAD,POST,OPTIONS,TRACE');
    143144 echo "<!DOCTYPE HTML PUBLIC \"-//IETF//DTD HTML 2.0//EN\">\n<html>\n<head>\n<title>{$err_code} {$err_phrase}</title>\n<h1>{$err_phrase}</h1>\n<p>{$err_body}<br>\n</p>\n</body></html>";
    144 } else echo '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
     145} else {
     146    echo '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
    145147       "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
    146148<html xml:lang="en" lang="en">
     
    157159  </body>
    158160</html>';
    159 ?>
     161
     162}
     163
     164
     165
     166exit();
     167exit();
     168
     169
     170//EOF
Note: See TracChangeset for help on using the changeset viewer.