News:

Wondering if this will always be free?  See why free is better.

Main Menu

Configuration for external login

Started by -Mirco-, April 29, 2017, 12:17:01 PM

Previous topic - Next topic

-Mirco-

Hello,
on my domain Site have 1 portal, 1 forum (with SMF) and 1 repository with indexer html.

What i want do now is to use user e password of SMF to access the Repository.

Repository is actually public, but what i want is that every one must have an smf forum account to use it.

Is there a way?

I watched about ssi_login function on ssi.php but is not clear, in this way i can do only an external login to forum, not to another location.

Thx in advance.

Gluz

The most simple way to do that is something like this, in your Repository have a index.php that handles that (or modify the one you already have)

<?php

require_once('here_the_path_to_SSI.php');

global 
$user_info;

if (!
$user_info['is_guest']) {
// Here the code/page you want logged users to see

} else {
// Here some alert that says that they must be logged in to see the content of the page

}

?>

-Mirco-

Hello, first of all thx for reply.
I have changed my index.php of repository and inserted this code, at the top, to test  it:


<?php
require_once('../../../public_html/forum/SSI.php');

global 
$user_info;

if (!
$user_info['is_guest']) {
continue;
} else {
print_r('You must have registred and logged on forum to watch repository');
header("location: https://www.ilpuntotecnicoeadsl.com/forum");
}
?>



In this way i expect to continue to watch clearly repository in case of user logged, in alternative i choose to redirect on forum to choose from registration or login.

Problem in this case is that every time i go in "else", also if i'm logged on forum.

What is wrong?

Arantor

Configure the cookies to be subdomain independent in the configuration.

Also, everything about your code won't work properly anyway - continue is designed for skipping things in a loop which is not what this is doing, and a redirect won't work if you output something first. (Though if you do redirect, you also need to exit afterwards to avoid an EAR vulnerability)

Suggestion: change the cookies as outlined above, then remove all of that other code after the SSI call and replace with:

is_not_guest();

which will direct them to the login page.

-Mirco-

Hello,
thx for reply.

Can you explain bettere what you mean with "Configure the cookies to be subdomain independent in the configuration."
I suppose that i have allow the share of cookies between domain in php code?
How can i do that?

Actually my repository is in the following url https://repository.ilpuntotecnicoeadsl.com and forum on https://www.ilpuntotecnicoeadsl.com/forum

What i have change with cookies?
About redirect i put the code on the top of code page index.php, so i suppose that everything lower then is skipped.

Anyway i'm just in doubt about what i have to do with cookies to allow visibility of cookies  forum.
I tried to do a var_dump($_COOKIES); on index page of repository but cookies of forum (i'm logged) are not visibile.

Thx in advance for attention.

Arantor

Configuration > Server Settings > Cookies and Sessions > tick the box titled Use subdomain independent cookies

QuoteAbout redirect i put the code on the top of code page index.php, so i suppose that everything lower then is skipped.

No. The print statement you have negates the header and a header on its own will run - but it will still do whatever the rest of the page would do anyway.

This is why I suggest switching to is_not_guest() which will do the check for you and redirect for you appropriately.

-Mirco-

Ok i have done change on configuration.

Now code is more simply as your advice:

<?php
require_once('../../../public_html/forum/SSI.php');
global 
$user_info;

is_not_guest();
?>


But i receive this message on index.php of repository

Error including file PATH_TO_CLASSESclassTTConnection.php - cannot load class.

Arantor

I actually said to remove the global call as well, it's not needed.

And the error is related to a mod you have rather than core SMF... not sure which mod, possibly Tapatalk?

-Mirco-

Ok i remove global:

require_once('../../../public_html/forum/SSI.php');

is_not_guest('Per visualizzare il repository è necessario essere registrati e loggati al forum.');


Error is related to tapatalk yes, file is present on the path  forum/mobiquo/lib/classTTConnection.php
I tried to add this code

require_once('../../../public_html/forum/SSI.php');
require_once('../../../public_html/forum/mobiquo/lib/classTTConnection.php');
is_not_guest('Per visualizzare il repository è necessario essere registrati e loggati al forum.');


But error is the same, how can i fix it?

Arantor

It's probably because Tapatalk expects to find all its files relative to SMF and never expects to have to be called from outside.

Before the require_once, try adding a chdir() statement to move the current directory to the SMF folder itself and then remove the ../../../ and other path stuff.

-Mirco-

Done in this way

<?php
$path 
="../../../public_html/forum"
chdir($path); 
require_once(
'SSI.php');
is_not_guest('Per visualizzare il repository è necessario essere registrati e loggati al forum.');
?>



But error is the same  :(
Error including file PATH_TO_CLASSESclassTTConnection.php - cannot load class.


<?php
$path 
="../../../public_html/forum"
chdir($path); 

require_once(
'SSI.php');
require_once(
'mobiquo/lib/classTTConnection.php');

is_not_guest('Per visualizzare il repository è necessario essere registrati e loggati al forum.');

?>



Tried in this way to but the error not change

Arantor

I don't even understand why you have the path as complex as you do.

Why can't you just have it as chdir ('/home/user/public_html/forum'); and be done with it?

But this is still clearly a bug in Tapatalk, where even though you've loaded the class, it doesn't matter, because it's trying to do its own specific load instruction which is failing.

-Mirco-

I can chance path about chdir but, ad i read, problem retain with tapatalk.
Any advice for solve It?

Arantor

Remove Tapatalk?

Honestly, it's a problem with their code, it probably never works in SSI without them changing it, and frankly given their history of not fixing bugs properly, I'd doubt it would ever work correctly - even with chdir() trying to work around Tapatalk's bad coding.

-Mirco-

Hello,
i removed tapatalk but now i have another issue  :(

Error including file ./classes/Url.php - cannot load class.

Illori

the folder classes is not a default folder for SMF, so you need to find out what mod adds it and try to fix it or reach out to that mod author to fix the issue.

-Mirco-

The strange thing is that this class is located in source of my repository  dir.

Why ask for this file php if code is this?

<?php
$path 
="../../../public_html/forum"
chdir($path); 
require_once(
'SSI.php');
is_not_guest('Per visualizzare il repository è necessario essere registrati e loggati al forum.');
?>



Arantor

SSI loads the SMF core files. These files load Tapatalk. But because Tapatalk don't ever deal with paths correctly (it's not hard either), they will fail to load.

Though using chdir() with a relative path is a really bad idea and I already suggested that you don't do it.

Kindred

Why are you even using chdir at all?

Just call ssi.php with with absolute path in the require statement
Слaва
Украинi

Please do not PM, IM or Email me with support questions.  You will get better and faster responses in the support boards.  Thank you.

"Loki is not evil, although he is certainly not a force for good. Loki is... complicated."

Arantor

He's doing so because I suggested it to try to work around Tapatalk.

The issue is that Tapatalk does its own thing to include its own files which fails - I presumed the reason was related to it expecting to be in the forum folder and suggested a chdir() to that folder so that Tapatalk wouldn't flail and fall over.

However, the multiple levels of pathing (which are likely not correct) won't help matters.

Advertisement: