Uutiset:

Want to get involved in developing SMF, then why not lend a hand on our github!

Main Menu
Advertisement:

SSI and Polls

Aloittaja aLaaa, lokakuu 27, 2013, 11:34:11 AP

« edellinen - seuraava »

aLaaa

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

Ricky.


<?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.

Arantor

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.
Holder of controversial views, all of which my own.


aLaaa

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?

Arantor

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.
Holder of controversial views, all of which my own.


aLaaa

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.

Arantor

What are the URLs of the page where you're trying to add this poll, and of the forum as a whole?
Holder of controversial views, all of which my own.


aLaaa

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/ [nofollow]

http://www.rcrncommunity.com/forums [nofollow]

you can find the poll and the ssi login temporarily placed at the bottom of the home page right sidebar.

Arantor

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.
Holder of controversial views, all of which my own.


aLaaa

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 :(

Arantor

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.
Holder of controversial views, all of which my own.


aLaaa

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.

Arantor

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.
Holder of controversial views, all of which my own.


aLaaa

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/ [nofollow]

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.

Arantor

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.
Holder of controversial views, all of which my own.


aLaaa

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.

Arantor

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.
Holder of controversial views, all of which my own.


aLaaa

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!

aLaaa

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.

Arantor

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...
Holder of controversial views, all of which my own.


Advertisement: