Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Missing wp core files in includes/classes/utils-s2o.inc.php #39

Closed
troypesola opened this issue Jan 2, 2014 · 12 comments
Closed

Missing wp core files in includes/classes/utils-s2o.inc.php #39

troypesola opened this issue Jan 2, 2014 · 12 comments
Labels

Comments

@troypesola
Copy link

I think I found a problem in the ClickBank IPN code.

There is a script that is included but isn't loading at the foot of the document for the registration page. the src url is

/content/plugins/s2member/s2member-o.php?ws_plugin__s2member_js_w_globals=1&qcABC=1&ver=131126-131126-3930270073

If I load it from a browser I get a 500 error from line 48 from includes/classes/utils-s2o.inc.php

The path is correct. My wordpress is installed in a wp folder. The wp folder does NOT have a content sub-folder.

SO ... the function wp_dir will not find the wordpress core. To test it out I modified line 39 to include the base /wp directory


foreach(array($starting_dir, $alt_starting_dir, '../../../wp') as $directory)

@jaswrks
Copy link
Contributor

jaswrks commented Jan 11, 2014

Got it, thank you. I was able to reproduce this on a WP installation that has it's content outside of the WordPress installation path. It's an interesting problem to work around. I'll give this some more thought and come back. Your temporary solution seems like a good one for you.

@troypesola
Copy link
Author

Jason, Here's a thought. What about parsing (not running) the wp-config.php file to find the PATH variables? It looks like wp-config.php will load wp-settings, so running the file will do more than we need. But it would be a method to find where the WP install is located.

@jaswrks
Copy link
Contributor

jaswrks commented Jan 14, 2014

Hmm, well the /wp-config.php normally lives inside the WordPress core directory (or one directory up); so this would be very much the same issue; i.e. how to find the /wp-config.php file in this particular scenario is really the same issue as finding the WordPress installation directory.

In short, if s2Member is installed in a non-standard location that's fine, but if it's installed completely outside of the WordPress directory all together, this could become an issue in the case of s2member-o.php where the intention is to load WordPress with only the s2Member plugin being active.

I'm not sure there is a good way to achieve a detection in this scenario. Perhaps we could offer a workaround though. I will come back to this before the next maintenance release. In the mean time, if you think of anything else please let me know. Thanks!

@troypesola
Copy link
Author

Jason,

Here's a thought ....

What if we add an mu_plugin file that defines a variable for the wp_dir
location, then utils-s2o.inc.php first tests if the file exists and use the
value from it?

It adds four lines to the stock s2member code, but that code would only be
used if the mu_plugin file exists. (with the exception of the file_exists
test)

I've tested it out on my local dev environment and it appears to be working
as expected.

NOTE: This is all based on my assumption that s2member is installed as a
plugin, so it should know where the mu_plugin directory is relative to
itself.

I hope that helps.

-Troy

mu_plugin/s2mu_wp_dir.php

section from utils-s2o.inc.php starting at line 37

public static function wp_dir ($starting_dir = FALSE, $alt_starting_dir =
FALSE)
{
if (file_exists('../../mu-plugins/s2_mu_wp_dir.php')) {
require_once('../../mu-plugins/s2_mu_wp_dir.php');
return ($wp_dir = $s2_mu_wp_dir);
}

foreach(array($starting_dir, $alt_starting_dir) as $directory)

On Tue, Jan 14, 2014 at 10:38 AM, Jason Caldwell
notifications@github.heygears.comwrote:

Hmm, well the /wp-config.php normally lives inside the WordPress core
directory (or one directory up); so this would be very much the same issue;
i.e. how to find the /wp-config.php file in this particular scenario is
really the same issue as finding the WordPress installation directory.

In short, if s2Member is installed in a non-standard location that's fine,
but if it's installed completely outside of the WordPress directory all
together, this could become an issue in the case of s2member-o.php where
the intention is to load WordPress with only the s2Member plugin being
active.

I'm not sure there is a good way to achieve a detection in this scenario.
Perhaps we could offer a workaround though. I will come back to this before
the next maintenance release. In the mean time, if you think of anything
else please let me know. Thanks!


Reply to this email directly or view it on GitHubhttps://github.com//issues/39#issuecomment-32287551
.

Troy Pesola
troy@pesola.us - 719.351.9410
http://CubeDwellerFitness.com - http://gplus.to/troyp

@jaswrks
Copy link
Contributor

jaswrks commented Jan 14, 2014

I agree this could be a possible solution. Thank you!

@jaswrks
Copy link
Contributor

jaswrks commented Jan 15, 2014

Another possible solution would be an environment variable we could look for. That could be cleaner and less expensive than checking for a file. What do you think of this? Would this be easier or harder in your opinion.

if(!empty($_SERVER['WP_DIR']))
    $wp_dir = $_SERVER['WP_DIR'];

@troypesola
Copy link
Author

I haven't had a reason to mess with environment variables on share hosting
systems. How would I do that? Not sure if that's easier or harder. ;)

The thing that I like about the mu_plugin file is that it "seems" to fit
with the model of customization used in other parts of s2member. So it
feels consistent. But then again, I am very new to the product and still
trying to figure out how to get it to work.

On Wed, Jan 15, 2014 at 5:10 AM, Jason Caldwell notifications@github.heygears.comwrote:

Another possible solution would be an environment variable we could look
for. That could be cleaner and less expensive than checking for a file.
What do you think of this? Would this be easier or harder in your opinion.

if(!empty($_SERVER['WP_DIR']))
$wp_dir = $_SERVER['WP_DIR'];


Reply to this email directly or view it on GitHubhttps://github.com//issues/39#issuecomment-32356220
.

Troy Pesola
troy@pesola.us - 719.351.9410
http://CubeDwellerFitness.com - http://gplus.to/troyp

@jaswrks
Copy link
Contributor

jaswrks commented Jan 15, 2014

One way to set an environment variable in a shared hosting environment is via .htaccess

You can add this line...

SetEnv WP_DIR /path/to/wordpress

Or, this can also be done via Mod Rewrite.

<IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteRule .* - [E=WP_DIR:/path/to/wordpress]
</IfModule>

@troypesola
Copy link
Author

Jason,

In the fix in GitHub the code isn't setting the $wp_dir variable. Does
that need to be done?

That looks like a great fix. Adding the environment variable to htaccess
should be easy. I'm assuming that it just needs to be added to the
htaccess at the root of the site. (or does it need to be in others as
well?)

Thanks,
Troy

On Wed, Jan 15, 2014 at 1:48 PM, Jason Caldwell notifications@github.com
wrote:

Closed #39 #39 via d130398d130398
.


Reply to this email directly or view it on GitHubhttps://github.com//issues/39
.

Troy Pesola
troy@pesola.us - 719.351.9410
http://CubeDwellerFitness.com http://cubedwellerfitness.com/ -
http://gplus.to/troyp

On Wed, Jan 15, 2014 at 1:28 PM, Jason Caldwell notifications@github.heygears.comwrote:

One way to set an environment variable in a shared hosting environment is
via .htaccess

You can add this line...

SetEnv WP_DIR /path/to/wordpress

Or, this can also be done via Mod Rewrite.

RewriteEngine On RewriteRule .\* - [E=WP_DIR:/path/to/wordpress]


Reply to this email directly or view it on GitHubhttps://github.com//issues/39#issuecomment-32411487
.

Troy Pesola
troy@pesola.us - 719.351.9410
http://CubeDwellerFitness.com - http://gplus.to/troyp

@jaswrks
Copy link
Contributor

jaswrks commented Jan 15, 2014

In the fix in GitHub the code isn't setting the $wp_dir variable. Does
that need to be done?

No, it's not necessary.

That looks like a great fix. Adding the environment variable to htaccess
should be easy. I'm assuming that it just needs to be added to the
htaccess at the root of the site. (or does it need to be in others as
well?)

Just once in the root .htaccess will do the trick :-)

@troypesola
Copy link
Author

Great. I patched my local copy and tested it out. Looks good.

Do you know when this will be pushed? I'm debating about updating to the
most recent version, or wait for this to be included.

On Wed, Jan 15, 2014 at 4:06 PM, Jason Caldwell notifications@github.heygears.comwrote:

In the fix in GitHub the code isn't setting the $wp_dir variable. Does
that need to be done?

No, it's not necessary.

That looks like a great fix. Adding the environment variable to htaccess
should be easy. I'm assuming that it just needs to be added to the
htaccess at the root of the site. (or does it need to be in others as
well?)

Just once in the root .htaccess will do the trick :-)


Reply to this email directly or view it on GitHubhttps://github.com//issues/39#issuecomment-32425617
.

Troy Pesola
troy@pesola.us - 719.351.9410
http://CubeDwellerFitness.com - http://gplus.to/troyp

@jaswrks
Copy link
Contributor

jaswrks commented Jan 16, 2014

Great! Thanks for the test.
This is scheduled for release on Jan 20th, 2014.

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants