latest stable versions: v150827 (changelog)

Old Forums (READ-ONLY): The community now lives at WP Sharks™. If you have an s2Member® Pro question, please use our new Support System.

Problem with wordpress folder search code

Home Forums Community Forum Problem with wordpress folder search code

This topic contains 2 replies, has 3 voices. Last updated by  Jason (Lead Developer) 3 years, 5 months ago.

Topic Author Topic
Posted: Thursday Jul 18th, 2013 at 1:00 pm #53644
ROBERT WHENT
Username: swento

This is regarding a bug that was causing errors in our installation of s2member using wordpress plugins path re-assignment. The following code in the s2member plugin s2member/includes/classes/utils-s2o.inc.php wp_dir function has a problem in that it does not search all directories in the hierarchy because it reassigns $dir on each iteration but then tries to traverse from that point…focus on the code in the $one_dir_up loop and it’s effect on the outer loops…

foreach (array ($starting_dir, $alt_starting_dir) as $directory)
if ($directory && is_string ($directory) && is_dir ($directory))
for ($i = 0, $dir = $directory; $i <= 20; $i++)
{
for ($one_dir_up = 0; $one_dir_up < $i; $one_dir_up++)
$dir = dirname ($dir);
if (file_exists ($dir . "/wp-settings.php"))
return ($wp_dir = $dir);
}

Also this unnecessarily starts the search in the s2member folder itself… Sample fixed implementation that successfully searches all folders is as follows:

foreach (array ($starting_dir, $alt_starting_dir) as $directory)
if ($directory && is_string ($directory) && is_dir ($directory))
for ($i = 0, $dir = $directory, $dir2=''; $i <= 20; $i++)
{
$dir = dirname ($dir);
if ($dir2 == $dir) break;
$dir2 = $dir;
if (file_exists ($dir . "/wp-settings.php"))
return ($wp_dir = $dir);
}

Thank you for looking into correcting this…

List Of Topic Replies

Viewing 2 replies - 1 through 2 (of 2 total)
Author Replies
Author Replies
Posted: Saturday Jul 20th, 2013 at 6:12 am #53705

Thanks, Robert. I’ll forward it to Jason for review. :)

Posted: Thursday Jul 25th, 2013 at 10:45 am #54047
Staff Member

Thank you!

I’m having this fixed in development. This will get pushed out in the next maintenance release.
Viewing 2 replies - 1 through 2 (of 2 total)

This topic is closed to new replies. Topics with no replies for 2 weeks are closed automatically.

Old Forums (READ-ONLY): The community now lives at WP Sharks™. If you have an s2Member® Pro question, please use our new Support System.

Contacting s2Member: Please use our Support Center for bug reports, pre-sale questions & technical assistance.