Changeset 995775
- Timestamp:
- 09/23/2014 11:24:05 PM (12 years ago)
- Location:
- askapache-password-protect
- Files:
-
- 21 added
- 4 edited
-
tags/4.6.10 (added)
-
tags/4.6.10/askapache-password-protect.php (added)
-
tags/4.6.10/class-askapache-net.php (added)
-
tags/4.6.10/license.txt (added)
-
tags/4.6.10/readme.txt (added)
-
tags/4.6.10/screenshot-1.png (added)
-
tags/4.6.10/screenshot-2.png (added)
-
tags/4.6.10/screenshot-3.png (added)
-
tags/4.6.10/screenshot-4.png (added)
-
tags/4.6.10/screenshot-5.png (added)
-
tags/4.6.10/screenshot-6.png (added)
-
tags/4.6.10/tests (added)
-
tags/4.6.10/tests/.htaccess (added)
-
tags/4.6.10/tests/authdigestfile_test.gif (added)
-
tags/4.6.10/tests/authuserfile_test.gif (added)
-
tags/4.6.10/tests/basic_auth_test.gif (added)
-
tags/4.6.10/tests/digest_check.gif (added)
-
tags/4.6.10/tests/err.php (added)
-
tags/4.6.10/tests/modsec_check.gif (added)
-
tags/4.6.10/tests/test.gif (added)
-
tags/4.6.10/tests/txt.txt (added)
-
trunk/askapache-password-protect.php (modified) (45 diffs)
-
trunk/class-askapache-net.php (modified) (3 diffs)
-
trunk/readme.txt (modified) (1 diff)
-
trunk/tests/err.php (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
askapache-password-protect/trunk/askapache-password-protect.php
r986713 r995775 6 6 * Author: askapache 7 7 * Contributors: askapache 8 * Version: 4.6. 98 * Version: 4.6.10 9 9 * Requires at least: 2.7 10 10 * Tested up to: 4.0 … … 41 41 COMPAT FUNCTIONS 42 42 ********************************************************************************************************************************************************************************************************/ 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;45 43 if (!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; 46 44 if (!function_exists('stripos')) : function stripos($haystack, $needle, $offset = 0) { return strpos(strtolower($haystack), strtolower($needle), $offset); } endif; … … 50 48 DEFINES 51 49 ********************************************************************************************************************************************************************************************************/ 50 ! defined( '__DIR__' ) && define( '__DIR__', realpath( dirname( __FILE__ ) ) ); // Added in PHP 5.3.0 52 51 !defined('NET_SOCKET_READ') && define('NET_SOCKET_READ', 1); 53 52 !defined('NET_SOCKET_WRITE') && define('NET_SOCKET_WRITE', 2); … … 71 70 72 71 // 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__)); 75 74 76 75 define( 'AA_PP_DEBUG', 0 ); // set this to 1 for verbose debugging … … 114 113 115 114 $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'; 119 118 120 119 $su = parse_url( $home ); … … 125 124 !defined('WP_PLUGIN_URL') && define( 'WP_PLUGIN_URL', WP_CONTENT_URL . '/plugins' ); 126 125 127 $home = get_ option( 'siteurl');126 $home = get_site_url(); 128 127 129 128 $su = parse_url( $home ); … … 210 209 ), 211 210 212 21030002 => array( 'Version' => '1. 3',211 21030002 => array( 'Version' => '1.4', 213 212 'Name' => 'Password Protect wp-admin', 214 213 'Description' => 'Requires a valid user/pass to access any non-static (css, js, images) file in this directory...', … … 484 483 } 485 484 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 ] ) ) 489 488 { 490 489 check_admin_referer( 'askapache-passpro-form' ); 491 $v[ substr( $k, 2 )] = $_POST[$k];490 $v[ substr( $k, 2 ) ] = $_POST[ $k ]; 492 491 } 493 492 } … … 534 533 } 535 534 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 { 539 545 if ( empty( $_POST['a_admin_email'] ) )$errors->add( 'adminemail-required', __( '<strong>ERROR</strong>: An admin email is required.' ) ); 540 546 if ( !is_email( $_POST['a_admin_email'] ) )$errors->add( 'adminemail-bad', __( '<strong>ERROR</strong>: A valid admin email is required.' ) ); … … 600 606 if ( isset( $pass ) && count( $errors->errors ) == 0 ) 601 607 { 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['a uthtype'], $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 ) ) { 606 612 $errors->add( 'failed-create-authuserfile', __( '<strong>ERROR</strong>: Failed to create ' . $v['authuserfile'] ) ); 613 } 607 614 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 */ 610 620 } 611 621 } … … 632 642 global $aa_PP, $aa_SIDS, $aa_PLUGIN; 633 643 644 if (!current_user_can("manage_options"))wp_die("manage_options cap required"); 645 634 646 echo '<div class="wrap">'; 647 635 648 636 649 $aa_PLUGIN=aa_pp_get_plugin_data(); … … 638 651 $aa_PP = get_option( 'askapache_password_protect' ); 639 652 $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'; 643 656 644 657 $aa_SIDS = get_option( 'askapache_password_protect_sids' ); 645 if (!current_user_can("manage_options"))wp_die("manage_options cap required");646 658 647 659 648 660 649 661 $errors = aa_pp_get_post_values( $aa_PP ); 662 if ( ! array_key_exists('user', $aa_PP ) ) { 663 $aa_PP['user'] = ''; 664 } 650 665 aa_pp_errors( $errors ); 651 666 … … 688 703 if ( isset($_POST,$_POST['notice'] ) ) echo '<div id="message" class="updated fade"><p>' . $_POST['notice'] . '</p></div>'; 689 704 690 $aa_PP['test_dir']= dirname(__FILE__).'/tests';705 $aa_PP['test_dir']=__DIR__.'/tests'; 691 706 692 707 … … 698 713 ?> 699 714 <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> 701 720 <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> 702 721 <p><br class="clear" /></p> … … 763 782 ?> 764 783 <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> 766 785 <div style="background-color: #FFEBE8; border-color: #CC0000; border:1px solid; padding: 0 0.6em;margin: 5px 0 15px;"> 767 786 <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> … … 997 1016 <?php 998 1017 999 $c=array();$vb=false; 1018 $c=array(); 1019 $vb=false; 1000 1020 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 } 1002 1024 } 1003 1025 1004 1026 echo '<pre>'; 1005 1027 ksort($c); 1028 unset( $c['DB_PASSWORD'] ); 1006 1029 echo htmlspecialchars(print_r(array('Plugin Options'=>$aa_PP,'Active SIDS'=>aa_pp_active_sids(),'Constants'=>$c),1)); 1007 1030 echo '</pre>'; 1008 1031 1009 1032 aa_pp_pls(WP_CONTENT_DIR, 1); 1010 aa_pp_pls( dirname(__FILE__), 1);1033 aa_pp_pls(__DIR__, 1); 1011 1034 aa_pp_pls(ABSPATH, 1); 1012 1035 ?> … … 1042 1065 <tr valign="top"> 1043 1066 <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> 1045 1068 </tr> 1046 1069 <tr valign="top"> … … 1153 1176 1154 1177 $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 } 1157 1183 1158 1184 $tag = ( strpos( $file, 'wp-admin' ) !== false )?1:0; … … 1504 1530 global $aa_PP, $aa_SIDS; 1505 1531 $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(); 1507 1533 $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'; 1509 1535 1510 1536 if ( $aa_PP['authtype'] == 'Basic' ) $replacement = 'AuthType %authtype%%n%AuthName "%authname%"%n%AuthUserFile %authuserfile%%n%Require user %user%'; … … 1810 1836 aa_pp_notify( __FUNCTION__ . ':' . __LINE__ ); 1811 1837 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'; 1813 1839 1814 1840 … … 1826 1852 'mod_mime_magic', 'mod_negotiation', 'mod_netware', 'mod_nw_ssl', 'mod_optional_fn_export', 'mod_optional_fn_import', 1827 1853 '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_se tenvif', 'mod_so',1854 'mod_proxy_connect', 'mod_proxy_ftp', 'mod_proxy_http', 'mod_rewrite', 'mod_security', 'mod_security2', 'mod_setenvif', 'mod_so', 1829 1855 'mod_speling', 'mod_ssl', 'mod_status', 'mod_substitute', 'mod_suexec', 'mod_test', 'mod_unique_id', 'mod_userdir', 1830 1856 'mod_usertrack', 'mod_version', 'mod_vhost_alias', 'mod_win32', 'prefork', 'sapi_apache2' … … 1834 1860 $ap = $aa_PP; 1835 1861 $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(); 1840 1866 $hu = str_replace( $scheme . '://', '', $home ); 1841 1867 $uri = plugins_url('/tests/',__FILE__); 1842 1868 aa_pp_notify('uri: '.$uri); 1843 $test_root_path = str_replace(ABSPATH,'/', dirname(__FILE__).'/tests/');1869 $test_root_path = str_replace(ABSPATH,'/',__DIR__.'/tests/'); 1844 1870 aa_pp_notify('test_root_path: '.$test_root_path); 1845 1871 $test_url_base = plugins_url('/tests/',__FILE__); … … 1926 1952 <h2>Why Test?</h2> 1927 1953 <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 use1954 <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 1929 1955 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> 1930 1956 <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> … … 1947 1973 $tester = new AskApacheNet; 1948 1974 $atest = ( $tester->sockit( "{$siteurl}" ) == 200 ) ? 1 : 0; 1975 1976 if ( ! $atest ) { 1977 $atest = ( $tester->sockit( "{$siteurl}/" ) == 200 ) ? 1 : 0; 1978 } 1979 1949 1980 $msg = ( $atest ) ? $aok : $fail; 1950 1981 $tester->print_tcp_trace(); … … 1963 1994 echo $m_s . $msg . " open_basedir on/off {$open_basedir}" . $m_e; 1964 1995 1996 1997 1965 1998 $htaccess_test1 = $atest = ( @is_writable( $ap['admin_htaccess'] ) || @touch( $ap['admin_htaccess'] ) ) ? 1 : 0; 1966 1999 $msg = ( $atest ) ? $aok : $fail; … … 2029 2062 echo $m_s . $msg . " Apache Version: " . $apache_version . $m_e; 2030 2063 2031 $msg = ( @version_compare( phpversion(), ' 4.2.0', '=<' ) ) ? $info : $aok;2064 $msg = ( @version_compare( phpversion(), '5.0', '=<' ) ) ? $info : $aok; 2032 2065 echo $m_s . $msg . " PHP Version " . phpversion() . $m_e;?> 2033 2066 … … 2041 2074 2042 2075 $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 } 2045 2081 echo $m_s . $info . "Memory Usage: " . round( $memm / 1024 / 1024, 2 ) . $m_e; 2046 2082 2047 2083 $mem = abs( intval( @ini_get( 'memory_limit' ) ) ); 2048 2084 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 } 2050 2088 2051 2089 $phpini = @get_cfg_var( 'cfg_file_path' ); … … 2054 2092 $safe_mode = @ini_get( 'safe_mode' ); 2055 2093 $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; 2057 2095 2058 2096 $disabled_functions = @ini_get( 'disable_functions' ); 2059 2097 $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;?> 2061 2099 2062 2100 … … 2103 2141 { 2104 2142 $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 2116 2168 $msg = ( $atest ) ? $aok : $fail; 2117 2169 echo $m_s . $msg . " Revisions Enabled" . $m_e; … … 2163 2215 2164 2216 $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; 2166 2218 $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; 2168 2220 if ( (bool)AA_PP_DEBUG === true || !$atest )$tester->print_tcp_trace(); 2169 2221 … … 2302 2354 $vb=false; 2303 2355 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 } 2305 2359 } 2306 2360 echo '<pre>'; … … 2311 2365 2312 2366 aa_pp_pls(WP_CONTENT_DIR, 1); 2313 aa_pp_pls( dirname(__FILE__), 1);2367 aa_pp_pls(__DIR__, 1); 2314 2368 aa_pp_pls(ABSPATH, 1); 2315 2369 … … 2333 2387 aa_pp_notify( __FUNCTION__ . ":" . __LINE__ . ' ' . "Creating $alg of $u for $an"); 2334 2388 2389 if ( ! empty( $an ) && strtoupper( $alg ) == 'MD5' ) { 2390 $alg = 'DIGEST'; 2391 } 2392 2335 2393 switch (strtoupper($alg)) 2336 2394 { … … 2412 2470 return $files; 2413 2471 } 2472 2414 2473 /** aa_pp_mkdir 2415 2474 * aa_pp_mkdir() … … 2420 2479 function aa_pp_mkdir( $dir ) 2421 2480 { 2422 $old=@umask( 0 );2481 //$old=@umask( 0 ); 2423 2482 $dirname = ( @is_readable( $dir ) ) ? realpath( rtrim( $dir, '/' ) ) : rtrim( $dir, '/' ); 2424 2483 $dirname = str_replace( '//', '/', $dirname ); … … 2426 2485 @chmod( $dirname, 0755 ); 2427 2486 if ( is_dir( $dirname ) || @wp_mkdir_p( $dirname ) ) { 2428 $new=@umask($old);2487 //$new=@umask($old); 2429 2488 return $dirname; 2430 2489 } 2431 2490 elseif ( is_writable( $dirname ) && @wp_mkdir_p( $dirname ) ) { 2432 $new=@umask($old);2491 //$new=@umask($old); 2433 2492 return $dirname; 2434 2493 } 2435 2494 else { 2436 2495 $ok=@mkdir( $dirname, 0755 ); 2437 $new=@umask($old);2496 //$new=@umask($old); 2438 2497 return( (bool)$ok ? $dirname : new WP_Error( 'mkdir-failed', __( "Failed to create directory {$dirname}" ) )); 2439 2498 } 2440 2499 } 2500 2441 2501 /** aa_pp_unlink 2442 2502 * aa_pp_unlink() … … 2448 2508 function aa_pp_unlink( $f, $backup = false ) 2449 2509 { 2450 $old=@umask( 0 );2510 //$old=@umask( 0 ); 2451 2511 $f = ( @is_readable( $f ) ) ? realpath( rtrim( $f, '/' ) ) : rtrim( $f, '/' ); 2452 2512 $f = str_replace( '//', '/', $f ); 2453 2513 2454 2514 if ( !@file_exists( $f ) ) { 2455 $new=@umask($old);2515 //$new=@umask($old); 2456 2516 return true; 2457 2517 } … … 2461 2521 2462 2522 if ( is_dir( $f ) ) { 2463 $new=@umask($old);2523 //$new=@umask($old); 2464 2524 return aa_pp_rmdir( $f ); 2465 2525 } … … 2467 2527 2468 2528 if ( !@file_exists( $f ) ) { 2469 $new=@umask($old);2529 //$new=@umask($old); 2470 2530 return true; 2471 2531 } 2472 2532 $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" ) ); 2473 2533 2474 $new=@umask($old);2534 //$new=@umask($old); 2475 2535 return $ret; 2476 2536 } 2537 2477 2538 /** aa_pp_backup 2478 2539 * aa_pp_backup() … … 2492 2553 else return $bf; 2493 2554 } 2555 2494 2556 /** aa_pp_bytes 2495 2557 * aa_pp_bytes() … … 2500 2562 function aa_pp_bytes($b = 0) 2501 2563 { 2502 static $s= NULL;2564 static $s=null; 2503 2565 if(is_null($s)) $s = array('B', 'Kb', 'MB', 'GB', 'TB', 'PB'); 2504 2566 $e = floor(log($b) / log(1024)); 2505 2567 return sprintf('%.2f ' . $s[$e], (($b > 0) ? ($b / pow(1024, floor($e))) : 0)); 2506 2568 } 2569 2507 2570 /** aa_pp_file_put_c 2508 2571 * aa_pp_file_put_c() … … 2515 2578 function aa_pp_file_put_c( $f, $content, $backup = false ) 2516 2579 { 2517 $old=@umask( 0 );2580 //$old=@umask( 0 ); 2518 2581 //$f = ( @is_readable( $f ) ) ? realpath( rtrim( $f, '/' ) ) : rtrim( $f, '/' ); 2519 2582 aa_pp_notify( __FUNCTION__ . ":" . __LINE__ . ' ' . "Creating {$f}" ); 2520 2583 if ( !is_dir( dirname( $f ) ) ) aa_pp_mkdir( dirname( $f ) ); 2521 2584 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 } 2523 2588 2524 2589 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); 2531 2596 return new WP_Error( 'fopen-failed', __( "Couldnt fopen {$f}" ) ); 2532 2597 } 2533 if ( !@fwrite( $fh, $content, strlen( $content ) ) ) { 2534 $new=@umask($old); 2598 2599 if ( fwrite( $fh, $content, strlen( $content ) ) === false ) { 2600 //$new=@umask($old); 2535 2601 return new WP_Error( 'fwrite-failed', __( "Couldnt fwrite {$f}" ) ); 2536 2602 } 2537 if ( !@fclose( $fh ) ) {2538 $new=@umask($old);2603 if ( is_resource( $fh ) && ! fclose( $fh ) ) { 2604 //$new=@umask($old); 2539 2605 return new WP_Error( 'fclose-failed', __( "Couldnt fclose {$f}" ) ); 2540 2606 } 2541 2607 2542 $new=@umask($old);2608 //$new=@umask($old); 2543 2609 return true; 2544 2610 } … … 2551 2617 function aa_pp_readfile( $f, $size='all' ) 2552 2618 { 2553 $old=@umask( 0 ); 2554 $f = ( @is_readable( $f ) ) ? realpath( rtrim( $f, '/' ) ) : rtrim( $f, '/' ); 2619 $f = ( @is_readable( $f ) ) ? @realpath( rtrim( $f, '/' ) ) : rtrim( $f, '/' ); 2555 2620 aa_pp_notify( __FUNCTION__ . ":" . __LINE__ . ' ' . "Reading {$f}" ); 2556 2621 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 ) ) { 2560 2634 return new WP_Error( 'fopen-failed', __( "Couldnt fopen {$f}" ) ); 2561 2635 } 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 ) { 2565 2643 return new WP_Error( 'fread-failed', __( "Couldnt fread {$f}" ) ); 2566 2644 } 2567 if ( !@fclose( $fh ) ) {2568 $new=@umask($old);2645 2646 if ( is_resource( $fh ) && !fclose( $fh ) ) { 2569 2647 return new WP_Error( 'fclose-failed', __( "Couldnt fclose {$f}" ) ); 2570 2648 } 2571 2649 2572 $new=@umask($old);2573 2650 return $filecontent; 2574 2651 } … … 2623 2700 function aa_pp_checkfunction($f) 2624 2701 { 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'; 2633 2715 } 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 2641 2728 2642 2729 /** aa_pp_array_iunique … … 2775 2862 2776 2863 2777 ?> 2864 2865 2866 2867 // EOF -
askapache-password-protect/trunk/class-askapache-net.php
r305486 r995775 6 6 * @author askapache.com 7 7 * @copyright Copyright (c) 2008 AskApache.com 8 * @version 1.6 8 * @version 1.6.1 9 9 * @access public 10 10 */ … … 25 25 { 26 26 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' => '' 38 41 ); 39 42 40 43 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' => '' 53 56 ); 54 57 … … 480 483 } 481 484 endif; 482 ?> 485 486 487 488 489 // EOF -
askapache-password-protect/trunk/readme.txt
r986713 r995775 5 5 Requires at least: 2.7 6 6 Tested up to: 4.0 7 Stable tag: 4.6. 97 Stable tag: 4.6.10 8 8 This plugin Adds Crazy Additional Password Protection and Security to your blog. 9 9 -
askapache-password-protect/trunk/tests/err.php
r305488 r995775 1 1 <?php 2 2 3 ob_start(); 3 4 //http://www.askapache.com/htaccess/apache-status-code-headers-errordocument.html … … 142 143 if ($err_code == '405') @header('Allow: GET,HEAD,POST,OPTIONS,TRACE'); 143 144 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" 145 147 "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> 146 148 <html xml:lang="en" lang="en"> … … 157 159 </body> 158 160 </html>'; 159 ?> 161 162 } 163 164 165 166 exit(); 167 exit(); 168 169 170 //EOF
Note: See TracChangeset
for help on using the changeset viewer.