Simple Machines Community Forum

Customizing SMF => SMF Coding Discussion => Aiheen aloitti: aLaaa - lokakuu 27, 2013, 11:34:11 AP

Otsikko: SSI and Polls
Kirjoitti: aLaaa - lokakuu 27, 2013, 11:34:11 AP
Hello everyone, i'm using SMF 2.x and i'm trying to understand the logic behind this SSI function: <?php ssi_showPoll($topicID); ?> is it supposed to just display a poll, or should it also allow people to vote into it?

At my side when i use it, it just display the poll results, but the voting buttons are not displayed.

I checked all the online docs, but i haven't managed to find anything. Is there any better way to display&vote into a SMF poll from an external forum page within the same domain?

Thank you very much for any reply, and keep up the good work!
Alain
Otsikko: Re: SSI and Polls
Kirjoitti: Ricky. - lokakuu 27, 2013, 01:52:28 IP

<?php ssi_showPoll($topicID); ?>

The above code is supposed to show Poll for that particular topic  (if it has poll) , if the member who is viewing can vote on it then will see option to vote else if has voted then will see results.

I hope that explains stuff.
Otsikko: Re: SSI and Polls
Kirjoitti: Arantor - lokakuu 27, 2013, 01:59:00 IP
Depending on how the code was using with SSI and your site's configuration, it might be thinking the current user is a guest even if they are not and not showing the option as a result.
Otsikko: Re: SSI and Polls
Kirjoitti: aLaaa - lokakuu 27, 2013, 05:41:33 IP
Lainaus käyttäjältä: Arantor - lokakuu 27, 2013, 01:59:00 IP
Depending on how the code was using with SSI and your site's configuration, it might be thinking the current user is a guest even if they are not and not showing the option as a result.

could be, is there any way to check how the SSI is considering an user browsering an off-forum page?
Otsikko: Re: SSI and Polls
Kirjoitti: Arantor - lokakuu 28, 2013, 12:34:35 AP
Easy test would be to use ssi_login() just before it. It won't display the login box if the user is currently logged in already.
Otsikko: Re: SSI and Polls
Kirjoitti: aLaaa - lokakuu 28, 2013, 07:37:51 AP
Lainaus käyttäjältä: Arantor - lokakuu 28, 2013, 12:34:35 AP
Easy test would be to use ssi_login() just before it. It won't display the login box if the user is currently logged in already.

So seems that there is an issue of some sort, the SSI loginbox log me in and redirect me to the boards, then when i go back to the main page where SSI is used, i'm asked to login again, also if in the boards i'm still logged in.
Otsikko: Re: SSI and Polls
Kirjoitti: Arantor - lokakuu 28, 2013, 07:39:52 AP
What are the URLs of the page where you're trying to add this poll, and of the forum as a whole?
Otsikko: Re: SSI and Polls
Kirjoitti: aLaaa - lokakuu 28, 2013, 08:27:39 AP
Lainaus käyttäjältä: Arantor - lokakuu 28, 2013, 07:39:52 AP
What are the URLs of the page where you're trying to add this poll, and of the forum as a whole?

http://www.rcrncommunity.com/

http://www.rcrncommunity.com/forums

you can find the poll and the ssi login temporarily placed at the bottom of the home page right sidebar.
Otsikko: Re: SSI and Polls
Kirjoitti: Arantor - lokakuu 28, 2013, 08:32:17 AP
Ah, I see the problem and I don't even have to look.

Admin > Configuration > Server Settings > Cookies and Sessions > Enable subdomain independent cookies

This option will be required in order for you to make that work as expected. You will need to log out and back in again for it to take effect once the option has been saved.
Otsikko: Re: SSI and Polls
Kirjoitti: aLaaa - lokakuu 28, 2013, 08:39:59 AP
Lainaus käyttäjältä: Arantor - lokakuu 28, 2013, 08:32:17 AP
Ah, I see the problem and I don't even have to look.

Admin > Configuration > Server Settings > Cookies and Sessions > Enable subdomain independent cookies

This option will be required in order for you to make that work as expected. You will need to log out and back in again for it to take effect once the option has been saved.

already enabled, cleaned the cookies and everything, still the same :(
Otsikko: Re: SSI and Polls
Kirjoitti: Arantor - lokakuu 28, 2013, 08:41:30 AP
I assume local cookies is not enabled?

Also, is SSI.php the first thing on the page? SMF's session handler may not work if you're trying to integrate this into a page that tries to do its own session handling.
Otsikko: Re: SSI and Polls
Kirjoitti: aLaaa - lokakuu 28, 2013, 08:46:58 AP
Lainaus käyttäjältä: Arantor - lokakuu 28, 2013, 08:41:30 AP
I assume local cookies is not enabled?

Also, is SSI.php the first thing on the page? SMF's session handler may not work if you're trying to integrate this into a page that tries to do its own session handling.

local cookies disabled as suggested in the documentation

SSI.php is loaded as first into the Wordpress header.
Otsikko: Re: SSI and Polls
Kirjoitti: Arantor - lokakuu 28, 2013, 08:49:41 AP
Yeah, that's probably not going to work. By that point in time, WP's session handling should already have kicked off meaning that as far as SMF is concerned, it can never get its own session started.

This is why we discourage people from using WP for this kind of thing and instead using SMF only with a portal mod.
Otsikko: Re: SSI and Polls
Kirjoitti: aLaaa - lokakuu 28, 2013, 10:31:11 AP
Lainaus käyttäjältä: Arantor - lokakuu 28, 2013, 08:49:41 AP
Yeah, that's probably not going to work. By that point in time, WP's session handling should already have kicked off meaning that as far as SMF is concerned, it can never get its own session started.

This is why we discourage people from using WP for this kind of thing and instead using SMF only with a portal mod.

Ok, i managed to figure that the issue could be this one (basically a problem between the WP cookies with magic quotes and the SMF fix for PHP 4.3.9): http://jdarwood.com/2012/01/smf-in-wordpress/

But i'm a bit unsure regarding the way i should use in order to fix it, I tried to strip out the SMF fix for PHP 4.3.9 from Sources/Load.php but it results in a cookie error within SMF during the login process.
Otsikko: Re: SSI and Polls
Kirjoitti: Arantor - lokakuu 28, 2013, 10:33:57 AP
Did you look at the snippet SleePy provided in the post? Essentially what he's doing there is getting the cookie name from Settings.php, and fixing it before providing it to SSI.php.
Otsikko: Re: SSI and Polls
Kirjoitti: aLaaa - lokakuu 28, 2013, 10:41:08 AP
Lainaus käyttäjältä: Arantor - lokakuu 28, 2013, 10:33:57 AP
Did you look at the snippet SleePy provided in the post? Essentially what he's doing there is getting the cookie name from Settings.php, and fixing it before providing it to SSI.php.

yes i stared at it for a while, but i'm still not understanding how to use it, should i use it into the header before calling the SSI? By doing so i'm getting an error regarding the pBS missing class.
Otsikko: Re: SSI and Polls
Kirjoitti: Arantor - lokakuu 28, 2013, 10:44:23 AP
Ugh, it was meant to be more illustrative than literal. I don't know WordPress' innards, the code I have seen has been unpleasant enough that I don't want to look at it any more than I absolutely have to.

Use require_once with the actual path to Settings.php and SSI.php rather than that class.
Otsikko: Re: SSI and Polls
Kirjoitti: aLaaa - lokakuu 30, 2013, 07:18:24 AP
Problem solved!

After this line in  ssi.php:
Lainaa// Get the forum's settings for database and file paths.
require_once(dirname(__FILE__) . '/Settings.php');
I added:
Lainaaif (isset($_COOKIE[$cookiename]))
      $_COOKIE[$cookiename] = stripslashes($_COOKIE[$cookiename]);

Maybe you should consider to add this fix also into the official SMF release (if possible), i know you don't like very much Wordpress, but personally i think that SMF works nicely with it, way better than the boards like bbpress which are supposed to be complementary to WP.

Thank you very much for all the help!
Otsikko: Re: SSI and Polls
Kirjoitti: aLaaa - lokakuu 30, 2013, 09:19:50 AP
Just a one more little question, is the SSI login redirect still bugged like was some time ago?

currently i'm using:

Lainaa$currentPage = 'http://'.$_SERVER['SERVER_NAME'].$_SERVER['REQUEST_URI'];
$_SESSION['login_url'] = $currentPage;
$_SESSION['logout_url'] = $currentPage;

for redirecting logins/logouts to the current page browsered by the user, the logout redirect works perfectly fine, but the login keeps redirecting me to the SMF boards index instead of the current page.
Otsikko: Re: SSI and Polls
Kirjoitti: Arantor - lokakuu 31, 2013, 08:22:36 IP
Why should it be added to SMF? SMF works just fine without it - it's only because WP screws up cookies that this is required...
Otsikko: Re: SSI and Polls
Kirjoitti: aLaaa - marraskuu 03, 2013, 10:04:40 AP
Lainaus käyttäjältä: Arantor - lokakuu 31, 2013, 08:22:36 IP
Why should it be added to SMF? SMF works just fine without it - it's only because WP screws up cookies that this is required...

Since the fix is already here, i don't see any reason for not applying it overall. And by doing so you will also prevent people from asking for it in future.

I perfectly understand that this is an issue at WP side and you prefer people using the CMS integrated in SMF, but Wordpress is the most popular CMS out there, and people will keep trying to use SMF together with it, so imho fixing those little compatibility issues may boost your users way more than simply redirecting people to the integrated SMF CMS.

I don't want to be offensive in any way, only my 2 cents on the matter.