Is it possible to force PHP to use absolute paths over relative?

Need some custom code changes to the phpBB core simple enough that you feel doesn't require an extension? Then post your request here so that community members can provide some assistance.

NOTE: NO OFFICIAL SUPPORT IS PROVIDED IN THIS SUB-FORUM
Forum rules
READ: phpBB.com Board-Wide Rules and Regulations

NOTE: NO OFFICIAL SUPPORT IS PROVIDED IN THIS SUB-FORUM
Post Reply
Rogerjwilkinson
Registered User
Posts: 33
Joined: Wed Jan 17, 2018 2:42 pm

Is it possible to force PHP to use absolute paths over relative?

Post by Rogerjwilkinson » Tue Jan 23, 2018 5:15 pm

As the title says. I'm having a look at the server settings, and "Force Server URL settings" doesn't seem to affect it. I'm guessing this is probably a no if that doesn't do it, was just praying there might be a "cheap fix" for my jquery .load issue (won't work correctly with relative paths)... Thank you.


Edit: changing the phpbb rootpath location in viewtopic.php to

$phpbb_root_path = (defined('PHPBB_ROOT_PATH')) ? PHPBB_ROOT_PATH : './../forum/';

Seems to have done the trick for now. I'm getting an AJAX error on post submit but this is good so far.

User avatar
AbaddonOrmuz
Registered User
Posts: 414
Joined: Wed Dec 25, 2013 9:06 pm
Location: /dev/null
Name: Alfredo Ramos
Contact:

Re: Is it possible to force PHP to use absolute paths over relative?

Post by AbaddonOrmuz » Tue Jan 23, 2018 6:18 pm

Explain what are you trying to do, because it looks like you're providing a wrong path and that's not going to get fixed "forcing" absolute paths.
A proudly user of Arch Linux :: /r/sddm_themes

Rogerjwilkinson
Registered User
Posts: 33
Joined: Wed Jan 17, 2018 2:42 pm

Re: Is it possible to force PHP to use absolute paths over relative?

Post by Rogerjwilkinson » Tue Jan 23, 2018 6:33 pm

I am, in the simplest terms possible, trying to display a forum topic on my website externally (so on site.com/page.html forum located in site.com/forum). All of the pages in the wiki I can't make work. I am almost, almost ALMOST there with Jquery. After chaning the phpbb root path as I just did, I'm now at the point where jquery .load is loading all of the necessary headers and scripts for viewtopic.php?f=2&t=6, my only issue now is when I post from the external form, it says Post successful, fetching the result then a pop-up that says "AJAX Error - Something went wrong when processing your request." even though the post went through.

This tells me the issue has something to do with the forum topic refreshing after the ajax post goes through, this may be a jquery .load limiation, it may be that I've broken my paths for viewtopic.php, I'm not sure. Do you have any ideas?

I thought maybe it had to do with having replaced

Code: Select all

				$json_response->send(array(
					'MESSAGE_TITLE'		=> $msg_title,
					'MESSAGE_TEXT'		=> $msg_text,
					'S_USER_WARNING'	=> ($errno == E_USER_WARNING) ? true : false,
					'S_USER_NOTICE'		=> ($errno == E_USER_NOTICE) ? true : false,
					'REFRESH_DATA'		=> (!empty($refresh_data)) ? $refresh_data : null
				));
to

Code: Select all

                                            $json_response->send;
earlier on to hide some error outputs, but it is not. Reverting that fix, and clearing cache, throws up the same AJAX Error with my .load reply form.

Should I just give up and use an iframe, since jquery can strip elements out of iframes the same way it can with .load?

User avatar
AmigoJack
Registered User
Posts: 5361
Joined: Tue Jun 15, 2010 11:33 am
Location: グリーン ヒル ゾーン
Contact:

Re: Is it possible to force PHP to use absolute paths over relative?

Post by AmigoJack » Fri Jan 26, 2018 8:43 am

Rogerjwilkinson wrote:
Tue Jan 23, 2018 6:33 pm
I'm not sure. Do you have any ideas?
Yes: trace requests and responses. Either do this thru a program (i.e. WireShark) or thru one of many web browser extensions (i.e. HTTP trace) and then you see which request and/or response makes no sense. Because error messages like "Something went wrong when processing your request" are never helpful - no idea why this is still done today.
The worst thing about censorship is ███████████

User avatar
posey
Registered User
Posts: 706
Joined: Tue Oct 06, 2009 7:34 pm
Location: The Netherlands
Name: Gijs

Re: Is it possible to force PHP to use absolute paths over relative?

Post by posey » Sat Jan 27, 2018 9:16 am

Replacing the JSON response shouldn't make a difference, you either send an array or an empty array. That doesn't trigger an error.

AJAX is a lot harder to debug, as the error handling is less optimal, as AmigoJack already pointed out. If you're working with Chrome or Firefox, you can right click on your page and click on 'Inspect'. That will give you the developers tools for your browsers. In there select the 'Network' tab. Then make the request of posting the page, you will see all AJAX requests performed by this action. You can check them all, especially the last, for their 'Preview' and 'Response'. There are often more detailed error messages.

Regards,
''I'm pretty sure there's a lot more to life than being really, really, ridiculously good looking. And I plan on finding out what that is.''

Post Reply

Return to “phpBB Custom Coding”

Who is online

Users browsing this forum: No registered users and 3 guests