Simple Machines Community Forum

Customizing SMF => SMF Coding Discussion => Aiheen aloitti: zmc - elokuu 25, 2014, 10:16:28 AP

Otsikko: SMF 2.0.8 Login
Kirjoitti: zmc - elokuu 25, 2014, 10:16:28 AP
Hi,

Sorry, I speak a little english. My SMF Forum installed: ~/forum/*.*

I would like login page the ~/index.php


<?php
if ($login === true) {
header 'location: http://localhost/forum/index.php' );
} else {
if (
$_POST['login']) {
if (
$_POST['username'] & $_POST['password']) {// if the user data is correct from the SMF mysql db
header'location: http://localhost/forum/index.php' );
} else { 
// if not correct user data
print 'error';
}
} else {}
print 
'Login form: <form method="post"><input type="text" name="username"><input type="password" name="password"><input type="submit" name="login"></form>';
}
?>



Please help me & write a code this simple login form.

Thanks! Have a nice days!
Otsikko: Re: SMF 2.0.8 Login
Kirjoitti: Arantor - elokuu 25, 2014, 01:26:06 IP
I don't quite understand what you want to do.

But it seems to me you want ssi_login(), as per SSI Readme (http://wiki.simplemachines.org/smf/Category:SSI) and How do I integrate SMF into my PHP coded website? (http://wiki.simplemachines.org/smf/How_do_I_integrate_SMF_into_my_PHP_coded_website) and How to use the SMF user system outside of SMF (http://wiki.simplemachines.org/smf/How_to_use_the_SMF_user_system_outside_of_SMF)
Otsikko: Re: SMF 2.0.8 Login
Kirjoitti: zmc - elokuu 25, 2014, 03:42:10 IP
It works! My forum is private forum. See only registered users after login. Not see guests.

http://localhost/forum/Settings.php


<?php

$ssi_guest_access true;


http://localhost/index.php


<?php

require_once(
"forum/SSI.php");
if ($context['user']['is_logged']) {
header 'location: http://localhost/forum' );
} else {
print '<form method="post" name="login">';
}

?>



How to change the login form page is redirect to http://localhost/index.php (login form)

I would like, If not login all http://localhost/forum/* pages redirect to http://localhost/index.php the login form.
Otsikko: Re: SMF 2.0.8 Login
Kirjoitti: zmc - elokuu 26, 2014, 04:56:19 AP
Please help me!

Guests are not see the forum. I would like see the guests are only all-time login page: http://localhost/index.php (login form)
Registered users are see the forum after login. http://localhost/index.php (login form) -> http://localhost/forum/index.php (main page of SMF forum)

I would like the guests are all time see the login page http://localhost/index.php (login form).

Very sorry my bad english.
Otsikko: Re: SMF 2.0.8 Login
Kirjoitti: Hj Ahmad Rasyid Hj Ismail - elokuu 26, 2014, 05:16:06 AP
Admin > Config > Feature. Untick allow guest to browse.
Otsikko: Re: SMF 2.0.8 Login
Kirjoitti: zmc - elokuu 26, 2014, 05:51:15 AP
Lainaus käyttäjältä: ahrasis - elokuu 26, 2014, 05:16:06 AP
Admin > Config > Feature. Untick allow guest to browse.

Yes, it's ok, it is my settings. I would like guests (not login users) are:

http://localhost/forum/index.php -> http://localhost/index.php (login form)
http://localhost/forum/index.php?action=help -> http://localhost/index.php (login form)
http://localhost/forum/index.php?action=search -> http://localhost/index.php (login form)
http://localhost/forum/index.php?action=login -> http://localhost/index.php (login form)
http://localhost/forum/index.php?action=register -> http://localhost/index.php (login form)
http://localhost/forum/index.php?action=credits -> http://localhost/index.php (login form)
http://localhost/forum/index.php?wap2 -> http://localhost/index.php (login form)
http://localhost/forum/index.php?action=reminder -> http://localhost/index.php (login form)
http://localhost/forum/* -> http://localhost/index.php (login form)

I would like private forum. Not registering, only invite.
Otsikko: Re: SMF 2.0.8 Login
Kirjoitti: Hj Ahmad Rasyid Hj Ismail - elokuu 26, 2014, 06:05:48 AP
Then disable registration as well. Admin > Members > Registration > Settings. Select Registration Disabled in the dropdown. This will totally disable registration while you configure a mod to enable invitation. You can find it at the mod page. This one can be useful: http://custom.simplemachines.org/mods/index.php?mod=2567
Otsikko: Re: SMF 2.0.8 Login
Kirjoitti: zmc - elokuu 26, 2014, 06:08:12 AP
Lainaus käyttäjältä: ahrasis - elokuu 26, 2014, 06:05:48 AP
Then disable registration as well. Admin > Members > Registration > Settings. Select Registration Disabled in the dropdown.

Ok, but the redirectings are how to? All $_SESSION [ 'login' ] is FALSE then http://localhost/forum/* forwarding to http://localhost/index.php (login form this).
Otsikko: Re: SMF 2.0.8 Login
Kirjoitti: Hj Ahmad Rasyid Hj Ismail - elokuu 26, 2014, 06:31:18 AP
Lainaus käyttäjältä: ahrasis - elokuu 26, 2014, 05:16:06 AP
Admin > Config > Feature. Untick allow guest to browse.
This already cover all that. That's a basic SMF settings. All menu link will only display login form.

Plus, I am not sure why the moderator is merging your topics. It kinda confusing now as I am not dealing with your coding or anything.

As for SSI, that is something I am not very familiar with. Wait for Arantor or others to reply.