Welcome to Geeklog, Anonymous Sunday, November 24 2024 @ 10:11 am EST
Geeklog Forums
Login page before main display
tearl42
Anonymous
Greetings to all,
I'm not sure if this is the right place to post this question, but it seems like I need a hack to do what I want here since I don't see a plugin for it. I would like a login page that forces people to log in before they get to the main display.
Please let me know if and how this can be done.
Thanks,
Tom
I'm not sure if this is the right place to post this question, but it seems like I need a hack to do what I want here since I don't see a plugin for it. I would like a login page that forces people to log in before they get to the main display.
Please let me know if and how this can be done.
Thanks,
Tom
12
13
Quote
Status: offline
Dirk
Site Admin
Admin
Registered: 01/12/02
Posts: 13073
Location:Stuttgart, Germany
What you should do is make all the objects on your site that anonymous users should not be able to see invisible to them by unchecking the "Anonymous R" checkbox for all the topics, stories, blocks, etc.
bye, Dirk
bye, Dirk
12
11
Quote
bigjames
Anonymous
On top of making everything anonymous by unchecking the "Anonymous R," willthis patch by squatty still function with Geeklog 1.4.0sr5-1?
I'd like my anonymous members to become members first.
I'd like my anonymous members to become members first.
12
11
Quote
Status: offline
jmucchiello
Forum User
Full Member
Registered: 08/29/05
Posts: 985
You can do this as a partial hack. It prevents anyone from seeing your website unless they login (or hit the registration link). If more of the functions in users.php were in system/lib-user.php, you could make this look better but then this wouldn't be a hack.
Create a file called /path_to_geeklog/plugins/require_reg/function.inc and put the following function into it::
function plugin_centerblock_require_reg($where, $page, $topic)
{
global $_USER;
$ret = '';
if (where == 0 and (!isset($_USER) || !isset($_USER['uid']) || $_USER['uid'] == 1))
{
$ret .= COM_UserMenu();
}
return $ret;
}
?>
Then perform the following SQL:
INSERT INTO $_TABLES['plugins'] (pi_name, pi_version, pi_gl_version, pi_enabled) VALUES ('require_reg', '0.1', '1.4', 1)
Anything you add around the COM_UserMenu() call will also appear on this screen. It's not perfect, but it may be useful.
Create a file called /path_to_geeklog/plugins/require_reg/function.inc and put the following function into it::
Text Formatted Code
<?function plugin_centerblock_require_reg($where, $page, $topic)
{
global $_USER;
$ret = '';
if (where == 0 and (!isset($_USER) || !isset($_USER['uid']) || $_USER['uid'] == 1))
{
$ret .= COM_UserMenu();
}
return $ret;
}
?>
INSERT INTO $_TABLES['plugins'] (pi_name, pi_version, pi_gl_version, pi_enabled) VALUES ('require_reg', '0.1', '1.4', 1)
Anything you add around the COM_UserMenu() call will also appear on this screen. It's not perfect, but it may be useful.
9
14
Quote
Status: offline
jmucchiello
Forum User
Full Member
Registered: 08/29/05
Posts: 985
After a little more research, if you don't mind people seeing some of your layout, you can replace the above functions.inc file entirely by just putting this in the file:
if (!isset($_USER) || !isset($_USER['uid']) || $_USER['uid'] == 1)<br />{<br /> $split = explode('?', $_SERVER['PHP_SELF']);<br /> if (basename($split[0]) != 'users.php')<br /> {<br /> echo COM_refresh($_CONF['site_url'] . '/users.php');<br /> exit;<br /> }<br />}<br />?><br />
Text Formatted Code
if (!isset($_USER) || !isset($_USER['uid']) || $_USER['uid'] == 1)<br />{<br /> $split = explode('?', $_SERVER['PHP_SELF']);<br /> if (basename($split[0]) != 'users.php')<br /> {<br /> echo COM_refresh($_CONF['site_url'] . '/users.php');<br /> exit;<br /> }<br />}<br />?><br />
10
10
Quote
bigjames
Anonymous
how do I perform the SQL exactly? I have phpMyAdmin, but I'm not seing $_TABLES there
12
9
Quote
Status: offline
jmucchiello
Forum User
Full Member
Registered: 08/29/05
Posts: 985
Actually, I now have a third way to do this and it just uses a phpblock. Go into lib-custom.php and add this function to the end:Then login as admin and create a new block as follows:
Title: No Anonymous Access
Enabled: checked
Block Name: no_anonymous_access
Topic: All
Side: Left
Block Order: 1
Type: PHP Block
PHP Block Options
Block Function: phpblock_no_anonymous_access
In the access rights section, remove the checkmark from Group Read and Members Read. (This isn't necessary, it just skips the block for users who are already logged in.)
If you don't want anonymous users to see any of your content, you should move any custom content out of the left side block. If you don't care, don't worry about it. With this block active the only pages an anonymous user can see are the users.php pages that handle login and registration.
The benefit to blocking access this way (rather than removing read from anonymous all throughout the system) is that if at some later date you want to open the system, all you have to do is disable this block.
Enjoy.
Text Formatted Code
function phpblock_no_anonymous_access()<br />{<br /> global $_USER;<br /> <br /> if (!isset($_USER) || !isset($_USER['uid']) || $_USER['uid'] == 1)<br /> {<br /> $split = explode('?', $_SERVER['PHP_SELF']);<br /> if (basename($split[0]) != 'users.php')<br /> {<br /> echo COM_refresh($_CONF['site_url'] . '/users.php');<br /> exit;<br /> }<br /> }<br /> return '';<br />}<br />Title: No Anonymous Access
Enabled: checked
Block Name: no_anonymous_access
Topic: All
Side: Left
Block Order: 1
Type: PHP Block
PHP Block Options
Block Function: phpblock_no_anonymous_access
In the access rights section, remove the checkmark from Group Read and Members Read. (This isn't necessary, it just skips the block for users who are already logged in.)
If you don't want anonymous users to see any of your content, you should move any custom content out of the left side block. If you don't care, don't worry about it. With this block active the only pages an anonymous user can see are the users.php pages that handle login and registration.
The benefit to blocking access this way (rather than removing read from anonymous all throughout the system) is that if at some later date you want to open the system, all you have to do is disable this block.
Enjoy.
12
9
Quote
bigjames
Anonymous
Using your php_block method, whenever I apply the code to lib common the page fails when I log out.
12
11
Quote
Status: offline
jmucchiello
Forum User
Full Member
Registered: 08/29/05
Posts: 985
What fails? It works on my test system with Apache on Windows. And I just installed in on my production system without a problem.
The only real problem I've encountered is the LOGIN speedlimit and I don't know if that's just because to test this you have to logout, login, logout and login again. Since I'm not planning to run it, I'm not sure if this is a real problem.
Are you sure you didn't mistakenly add any spaces or line breaks after the "?>" at the end of the file?
The only real problem I've encountered is the LOGIN speedlimit and I don't know if that's just because to test this you have to logout, login, logout and login again. Since I'm not planning to run it, I'm not sure if this is a real problem.
Are you sure you didn't mistakenly add any spaces or line breaks after the "?>" at the end of the file?
10
12
Quote
Status: offline
jmucchiello
Forum User
Full Member
Registered: 08/29/05
Posts: 985
Did you have any luck, bigjames? The only other problem you might have is $SERVER['PHP_SELF'] is not defined correctly in your webserver. echo that variable inside the function (in place of the "exit") to see if this is the case. I plan to switch to the COM_getCurrentURL() function when I next get a chance to fool around with this. (And then I'll post this to the Blocks forum.)
If any of the core programmers sees this: While testing this, I've had to alter my login speed limits since GL doesn't clear them on successful login. Shouldn't there be something like:
DB_query("DELETE FROM {$_TABLES['speedlimit']} WHERE type = 'login' and ipaddress = '{$_SERVER['REMOTE_ADDR']}'");
whenever users.php logs you in successfully (Somewhere inside this IF: ) ?
if ($status == USER_ACCOUNT_ACTIVE) { // logged in AOK.
I often have to switch between an admin and a normal user account when testing stuff and this line of code would make it so I don't have to change the config.php and turn off login speedlimits when I'm testing something out. Stuff like blocks and static page seem to most often require a lot of account switching.
If any of the core programmers sees this: While testing this, I've had to alter my login speed limits since GL doesn't clear them on successful login. Shouldn't there be something like:
DB_query("DELETE FROM {$_TABLES['speedlimit']} WHERE type = 'login' and ipaddress = '{$_SERVER['REMOTE_ADDR']}'");
whenever users.php logs you in successfully (Somewhere inside this IF: ) ?
if ($status == USER_ACCOUNT_ACTIVE) { // logged in AOK.
I often have to switch between an admin and a normal user account when testing stuff and this line of code would make it so I don't have to change the config.php and turn off login speedlimits when I'm testing something out. Stuff like blocks and static page seem to most often require a lot of account switching.
11
11
Quote
All times are EST. The time is now 10:11 am.
- Normal Topic
- Sticky Topic
- Locked Topic
- New Post
- Sticky Topic W/ New Post
- Locked Topic W/ New Post
- View Anonymous Posts
- Able to post
- Filtered HTML Allowed
- Censored Content