Firefox PHP

Something is not connecting

Posted by KingsleyHill 
Something is not connecting
August 12, 2009 10:28PM
Hi,
I am sure that my newness to php is at the root of this problem.

I have a web page containing html and php code in a directory called DFA. I have the forum software in a parallel directory ../forum (ie at the same level). The web page is a css formatted page with nice header, footer, etc.

When I put the chdir() to ../forum and then use include (for example) common.php I get the errors saying: "Warning: Cannot modify header information - headers already sent by (output started at /home/public_html/DFA/index.php:3) in /home/public_html/forum/include/api/user.php on line 2629" and the same error for user.php on line 2633.

If I also add the command phorum_api_user_session_restore( PHORUM_FORUM_SESSION)) I get the errors twice.

My objective is to use the "login.php" function on MY page. Upon logging in the user is to be returned to my page. Upon returning to my page I want to know that the user is logged on (something to do with phorum_api_user_session_restore( PHORUM_FORUM_SESSION)) and say "Hello <username>" or some such drivel.

Please help me. Is there a detailed example of doing this somewhere? Is there something I doing wrong that is causing the headers to conflict?

Thank you
Re: Something is not connecting
August 13, 2009 03:15AM
From what you describe, I think you want the quick authentication script, which checks if a user is logged into Phorum. See this thread

For putting a login form on your page, simply copy the login form code from Phorum and put it in your pages. One extra thing to take care of, is placing a cookie to prove Phorum that the browser supports cookies. This cookie must be present in the browser when the user posts the login form. You can set the cookie using code like:
setcookie("phorum_tmp_cookie", "I can do cookies!", 0);


Maurice Makaay
Phorum Development Team
my blog linkedin profile secret sauce
Re: Something is not connecting
August 13, 2009 02:47PM
The quick authentication script does the trick..I seem to be checking authentication correctly.

The setcookie() call above causes the usual header conflict error though!

Also, I use the login code from the page as you suggest. I want the successful (or even unsuccessful) login to return to my index.php page rather than going to the forum. I changed the code in the login html to:
<input type="hidden" name="redir" value="[dukeflyers.org]; />

but when I log in it still takes me to the forum. Am I doing something wrong? There is mention of a variable to set in the documentation, so maybe I am just doing it wrong.???

Thank you.
Re: Something is not connecting
August 13, 2009 03:55PM
The header conflict is because you are doing the setcookie call after displaying your own header or so. The setcookie call must be done before any output, so before outputing your page header. An option could be to put

ob_start();

at the very start of your PHP code, to suppress outputting the page data immediately.

The redir system should work, but for security reasons, you need to register the URLs to which Phorum is allowed to jump. Check the setting "Allow Login-Redirection to the following URLs" in the general settings of admin.php.


Maurice Makaay
Phorum Development Team
my blog linkedin profile secret sauce



Edited 1 time(s). Last edit at 08/13/2009 03:57PM by Maurice Makaay.
Re: Something is not connecting
August 13, 2009 04:56PM
I may be nuts, but I don't see a setting for ""Allow Login-Redirection to the following URLs" in the general settings of admin.php." I am using v5.2.8, reportedly the latest version. Am I missing something?
Re: Something is not connecting
August 13, 2009 06:16PM
Yes, you are missing a recent version of Phorum ;-)
In 5.2.8, the redirect URLs aren't restricted yet, so there they should work without further special tweaks. I urge you to upgrade though.


Maurice Makaay
Phorum Development Team
my blog linkedin profile secret sauce
Re: Something is not connecting
August 13, 2009 07:00PM
Fascinating. Pressing the "Check for New Version" button says I am up to date AND the redir URL does not work. (I recall seeing a fair amount of chatter in the forum about the redir URL..so I will do some more reading). Thanks. I have to say I have always been very pleased with your responsiveness to this forum...it makes Phorum a pleasure to use.
Re: Something is not connecting
August 14, 2009 06:18AM
there was exactly one version which didn't check correctly for new versions. you seem to be running that one.
But you should see at least in this forum in the announcements part that new releases were done and also contain security fixes.


Thomas Seifert
Re: Something is not connecting
August 14, 2009 09:48AM
I will check with the hosting provider and make sure I am running my very own version of Phorum. If I am I will upgrade mine, if not I will urge him to upgrade the common version.

BUT...redir still does not work.

I have copied your "login" code and inserted into my webpage and modified the hidden redir variable. I have even tried to include common.php and called $redir = phorum_hook("after_login", "[dukeflyers.org];); and the result variable is set correctly BUT...I still get taken to the list page. INTERESTINGLY, even though I do "setcookie("phorum_tmp_cookie", "I can do cookies!", 0);" at the top of my index.php, the URL to the list page (where I go after I login) contains the phorum_session_v5=<stuff> suggesting that for some reason Phorum is unable (or unwilling) to set the cookie. My cookie (phorum_tmp_cookie) is set and checked. I have Phorum configuration set to "Allow Cookies"

Am I missing something?
Re: Something is not connecting
August 14, 2009 09:51AM
Is there a URL where we can see this in action?


Maurice Makaay
Phorum Development Team
my blog linkedin profile secret sauce
Sorry, only registered users may post in this forum.

Click here to login