Changeset 2772930 for wp-cerber/trunk/cerber-load.php
- Timestamp:
- 08/20/2022 04:27:16 PM (3 years ago)
- File:
-
- 1 edited
-
wp-cerber/trunk/cerber-load.php (modified) (20 diffs)
Legend:
- Unmodified
- Added
- Removed
-
wp-cerber/trunk/cerber-load.php
r2721561 r2772930 818 818 cerber_upgrade_all(); 819 819 820 $use_eng = false;821 if ( is_admin() && crb_get_settings( 'admin_lang' ) ) {822 $use_eng = true;823 add_filter( 'override_load_textdomain', function ( $val, $domain, $mofile ) {824 if ( $domain == 'wp-cerber' ) {825 $val = true;826 }827 828 return $val;829 }, 100, 3 );830 }831 832 if ( ! $use_eng ) {833 load_plugin_textdomain( 'wp-cerber', false, 'wp-cerber/languages' );834 }835 836 820 get_wp_cerber(); 837 821 … … 1132 1116 if ( ! ( $user instanceof WP_User ) || ! $user->ID ) { 1133 1117 1134 if ( is_wp_error( $user ) ) {1118 if ( crb_is_wp_error( $user ) ) { 1135 1119 1136 1120 $err_code = $user->get_error_code(); … … 1197 1181 } 1198 1182 else { 1199 cerber_log( 5, $username, $user->ID );1183 cerber_log( CRB_EV_LIN, $username, $user->ID ); 1200 1184 } 1201 1185 } … … 1337 1321 $fa = CRB_2FA::enforce( $user_login, $user ); 1338 1322 1339 if ( is_wp_error( $fa ) ) {1323 if ( crb_is_wp_error( $fa ) ) { 1340 1324 cerber_error_log( $fa->get_error_message() . ' | RID: ' . get_wp_cerber()->getRequestID(), '2FA' ); 1341 1325 } … … 1343 1327 cerber_login_history( $user->ID ); 1344 1328 1345 cerber_log( 5, $user_login, $user->ID );1329 cerber_log( CRB_EV_LIN, $user_login, $user->ID ); 1346 1330 1347 1331 } … … 1868 1852 1869 1853 if ( $user 1870 && ! is_wp_error( $user )1854 && ! crb_is_wp_error( $user ) 1871 1855 && ( $to = cerber_get_user_policy( $policy, $user ) ) ) { 1872 1856 … … 2416 2400 2417 2401 cerber_post_control(); 2402 2403 // Load translations 2404 2405 $use_eng = false; 2406 2407 if ( is_admin() && crb_get_settings( 'admin_lang' ) ) { 2408 2409 $use_eng = true; 2410 2411 add_filter( 'override_load_textdomain', function ( $val, $domain, $mofile ) { 2412 if ( $domain == 'wp-cerber' ) { 2413 $val = true; 2414 } 2415 2416 return $val; 2417 }, 100, 3 ); 2418 } 2419 2420 if ( ! $use_eng ) { 2421 load_plugin_textdomain( 'wp-cerber', false, 'wp-cerber/languages' ); 2422 } 2418 2423 2419 2424 if ( ( ! defined( 'CERBER_OLD_LP' ) || ! CERBER_OLD_LP ) … … 2826 2831 } 2827 2832 2828 if ( is_numeric( trim( $a )) && ! is_admin() ) {2833 if ( preg_match( '/\d/', $a ) && ! is_admin() ) { 2829 2834 cerber_404_page(); 2830 2835 } … … 2850 2855 return $provider; 2851 2856 }, PHP_INT_MAX, 2 ); 2857 } 2858 2859 if ( crb_get_settings( 'nouserpages_bylogin' ) ) { 2860 add_action( 'template_redirect', function () { 2861 2862 if ( ( cerber_get_get( 'author_name' ) 2863 || cerber_get_post( 'author_name' ) ) 2864 && ! is_admin() ) { 2865 cerber_404_page(); 2866 } 2867 2868 }, 0 ); 2852 2869 } 2853 2870 … … 3443 3460 3444 3461 // Do not log 'clear_auth_cookie' event (logout/login sequence) that occurs after password reset 3445 CRB_Globals::$do_not_log[ 5] = true;3462 CRB_Globals::$do_not_log[ CRB_EV_LIN ] = true; 3446 3463 CRB_Globals::$do_not_log[6] = true; 3447 3464 } … … 3887 3904 if ( $tag = cerber_acl_check( $ip ) ) { 3888 3905 if ( $tag == 'W' ) { 3889 if ( in_array( $activity, array( 1, 2, 5, 20, CRB_EV_PRS ) ) ) {3906 if ( in_array( $activity, array( 1, 2, CRB_EV_LIN, 20, CRB_EV_PRS ) ) ) { 3890 3907 return 500; 3891 3908 } … … 4949 4966 } 4950 4967 4951 $footer .= "\n\n\n" . __( 'This message was sent by', 'wp-cerber' ) . ' WP Cerber Security ' . ( lab_lab() ? 'PRO ' : '' ) . CERBER_VER . "\n"; 4968 $footer .= "\n\n\n" . __( 'This message created by', 'wp-cerber' ) . ' WP Cerber Security ' . ( lab_lab() ? 'PRO ' : '' ) . CERBER_VER . "\n"; 4969 $footer .= __( 'Date:', 'wp-cerber' ) . ' ' . cerber_date( time(), false ); 4952 4970 $footer .= 'https://wpcerber.com'; 4953 4971 … … 4962 4980 $body_go = ( $type == 'send_alert' && crb_get_settings( 'pb_mask' ) ) ? $body_masked : $body; 4963 4981 $res = cerber_pb_send( $subj, $body_go, $more, $footer ); 4964 if ( $res && ! is_wp_error( $res ) ) {4982 if ( $res && ! crb_is_wp_error( $res ) ) { 4965 4983 $results[ $go ] = true; 4966 4984 $recipients[ $go ] = cerber_pb_get_active(); … … 5560 5578 if ( $d < ( time() - DAY_IN_SECONDS * crb_get_settings( 'scan_qcleanup' ) ) ) { 5561 5579 $fs = cerber_init_wp_filesystem(); 5562 if ( ! is_wp_error( $fs ) ) {5580 if ( ! crb_is_wp_error( $fs ) ) { 5563 5581 $fs->delete( $dir, true ); 5564 5582 $sync = true; … … 6050 6068 * @param string $limit 6051 6069 * 6052 * @return array|null6070 * @return object[]|null 6053 6071 */ 6054 6072 function cerber_get_log( $activity = array(), $user = array(), $order = array(), $limit = '' ) { … … 6102 6120 * @param $user_email string 6103 6121 * 6104 * @return array|null|object|string6122 * @return false|object 6105 6123 */ 6106 6124 function cerber_get_last_login( $user_id, $user_email = '' ) { … … 6111 6129 $u = array( 'email' => $user_email ); 6112 6130 } 6113 6114 if ( ! $u ) { 6115 return false; 6116 } 6117 6118 if ( $recs = cerber_get_log( array( 5 ), $u, array( 'DESC' => 'stamp' ), 1 ) ) { 6131 else { 6132 return false; 6133 } 6134 6135 if ( $recs = cerber_get_log( array( CRB_EV_LIN ), $u, array( 'DESC' => 'stamp' ), 1 ) ) { 6119 6136 return $recs[0]; 6120 6137 } 6121 6138 6122 6139 return false; 6140 } 6141 6142 /** 6143 * Finds the last failed/denied attempt to log in. Uses user login and email. 6144 * Returns an activity log entry. 6145 * 6146 * @param string $login 6147 * @param string $email 6148 * @param bool $denied 6149 * 6150 * @return false|object 6151 * 6152 * @since 9.0.2 6153 */ 6154 function crb_get_last_failed( $login, $email, $denied = false ) { 6155 $act = ( $denied ) ? 53 : CRB_EV_LFL; 6156 6157 return cerber_db_get_row( 'SELECT * FROM ' . CERBER_LOG_TABLE . ' WHERE ( user_login = "' . $login . '" OR user_login = "' . $email . '" ) AND activity = ' . $act . ' ORDER BY stamp DESC LIMIT 1', MYSQL_FETCH_OBJECT ); 6123 6158 } 6124 6159 … … 6234 6269 6235 6270 if ( ! crb_get_settings( 'no_white_my_ip' ) ) { 6236 cerber_add_white( $ip, 'My IP address ' ); // Protection for non-experienced users6271 cerber_add_white( $ip, 'My IP address (' . cerber_date( time(), false ) . ')' ); // Protection for non-experienced users 6237 6272 $whited = ' <p>' . sprintf( __( 'Your IP address %s has been added to the White IP Access List', 'wp-cerber' ), cerber_get_remote_ip() ); 6238 6273 } … … 6300 6335 if ( $dir && file_exists( $dir ) ) { 6301 6336 $fs = cerber_init_wp_filesystem(); 6302 if ( ! is_wp_error( $fs ) ) {6337 if ( ! crb_is_wp_error( $fs ) ) { 6303 6338 $fs->rmdir( $dir, true ); 6304 6339 } … … 6889 6924 } ); 6890 6925 6891 /* 6892 Fix an issue with the empty user_id field in the comments table. 6893 */ 6926 /** 6927 * Fixing an issue with the empty user_id field in the WordPress comments table. 6928 * We use it to count comments for the Users page. 6929 * 6930 */ 6894 6931 add_filter( 'preprocess_comment', 'cerber_add_uid' ); 6895 6932 function cerber_add_uid( $commentdata ) {
Note: See TracChangeset
for help on using the changeset viewer.