WordPress.org

Forums

iThemes Security (formerly Better WP Security)
Internal 404 - Plugin Path (9 posts)

  1. macdonaldr93
    Member
    Posted 9 months ago #

    Hello,

    I'm having an issue with iThemes Security where it's getting an internal 404 error. This is causing all users to be locked out every time the log in. This WordPress site is running on a Windows server. I'm not sure if that's part of the issue.

    Basically all the css and js files are being referred to as so:

    /wp-content/plugins/better-wp-security/D:wwwrootCreativeEncounterswp-contentpluginsbetter-wp-securitymodulesfreecontent-directory/js/admin-content_directory.js

    I believe part of the issue is __DIR__ .

    Can anyone shine some light on the situation? :) If you need more information to help with a solution, just let me know. Much appreciated!

    https://wordpress.org/plugins/better-wp-security/

  2. macdonaldr93
    Member
    Posted 9 months ago #

    Figured out the problem. If anyone else is having this issue, check the version of php you're running. You can do this by creating a phpinfo.php page.

    <?php

    // Show all information, defaults to INFO_ALL
    phpinfo();

    ?>

    __DIR__ wasn't included until after 5.3 and I was running version 5.2 of PHP.

  3. macdonaldr93
    Member
    Posted 9 months ago #

    Nevermind that didn't fix it.

    HELP!

  4. macdonaldr93
    Member
    Posted 9 months ago #

    So I've figured out it's this that's the problem:

    $this->module_path = ITSEC_Lib::get_module_path( __FILE__ );
    
    /**
    	 * Returns the URL of the current module
    	 *
    	 * @since 4.0
    	 *
    	 * @param string $file     the module file from which to derive the path
    	 *
    	 * @return string the path of the current module
    	 */
    	public static function get_module_path( $file ) {
    
    		global $itsec_globals;
    
    		$path = str_replace( $itsec_globals['plugin_dir'], '', dirname( $file ) );
    
    		return trailingslashit( $itsec_globals['plugin_url'] . $path );
    
    	}

    Now if only I could find a solution...

  5. macdonaldr93
    Member
    Posted 9 months ago #

    So I've gotten even further along and it seems that dirname ( __FILE__ ) is returning the wrong path. Perhaps related to configuration on the server?

    Anyone??

  6. Jeff-Lewis
    Member
    Posted 9 months ago #

    I have seen the same issue. It's related to hosting on Windows.

    The code you posted is part of the problem, but also is how $itsec_globals are initialized on Windows.

    Line 82 in class-itsec-core.php
    'plugin_dir' => plugin_dir_path( $plugin_file ), //the path of the plugin directory

    plugin_dir_path( $plugin_file ) will return something like this on Windows -> "C:\wwwroot\mysite\wp-content\plugins\better-wp-security/"

    Notice difference in back and forward slashes.

    So later in the get_module_path( $file ) function you posted, it's trying to remove "C:\wwwroot\mysite\wp-content\plugins\better-wp-security/" from "C:\wwwroot\mysite\wp-content\plugins\better-wp-security\core" which never works because it doesn't match.

    Then we end up with the physical path in the script URL when it's used here.

    wp_enqueue_script( 'itsec_file_change_warning_js', $this->module_path . 'js/admin-file-change-warning.js', array( 'jquery' ), $itsec_globals['plugin_build'] );

    Essentially exposing to the world the physical path of your files on the server's disk. This is not helping security.

  7. iThemes Support
    Member
    Posted 9 months ago #

    Hey Guys,

    Thanks for reporting this, I received the bug report as well. We're doing some testing. I'll report back here when I know more.

    Thanks,

    Gerroald

  8. fgerneth
    Member
    Posted 9 months ago #

    Having the same issue on Windows as described and analyzed by Jeff-Lewis, there is an easy temporary fix until this is fixed by IThemes: replace the Windows Path Separators by the Linux ones. Luckily for us changes are only required in two places:

    - core/class-itsec-core.php:82 : Replace with 'plugin_dir' => str_replace('\\', '/', plugin_dir_path( $plugin_file )), //the path of the plugin directory
    - core/class-itsec-global-settings:388 : Replace with $path = str_replace( $itsec_globals['plugin_dir'], '', str_replace('\\', '/', dirname( $file )) );

  9. adamtba
    Member
    Posted 8 months ago #

    fgerneth: Thanks for this suggestion. I have the same issue as macdonaldr93 above. I see the relevant code to replace in that first location - core/class-itsec-core.php:82 - but in the second location - core/class-itsec-global-settings:388 - I just see the closing parenthesis and semicolon of an add_settings_field for itsec_global[user_lockout_message]. This doesn't seem like the right line to replace. Could you list the actual code that needs to be replaced in this file with the code you've provided above? That would be great. Fixing just the one location hasn't solved the 404 issue, so I'm assuming I need to also find a way to make that second fix.

    iThemes Support: Any word on a long-term fix for this issue? The 404s pile up because of the paths issue described above. I'm likewise hosting in a Windows environment.

    Thanks!

Reply

You must log in to post.

About this Plugin

About this Topic