How do I make a login box display if the user isn't logged i How do I make a login box display if the user isn't logged i
 

News:

cpg1.5.48 Security release - upgrade mandatory!
The Coppermine development team is releasing a security update for Coppermine in order to counter a recently discovered vulnerability. It is important that all users who run version cpg1.5.46 or older update to this latest version as soon as possible.
[more]

Main Menu

How do I make a login box display if the user isn't logged i

Started by bit bit spears, January 31, 2004, 04:33:39 PM

Previous topic - Next topic

0 Members and 2 Guests are viewing this topic.

bit bit spears

How do I make a login box display if the user isn't logged in? Like ~> i have this front page of the gallery, and i want it to ask you for your username and password if you are not logged in, and if you are (when you come to that page) then it will say, Welcome, please enter the gallery. or something?

Casper

I'm trying to code this, and I got most of it to work, except I can't get the if() code right.

Can anyone tell me how to do the test 'if(user_logged_on)'.
It has been a long time now since I did my little bit here, and have done no coding or any other such stuff since. I'm back to being a noob here


Casper

Thanks nibbler.  I had tried that, and it didn't work, but I've now discovered my other code was causing it.

I have made this code work on my test site, but it is not otherwise tested, so back-up before trying.

To redirect an unlogged user to the login.php.

Open index.php.

find;
/**
 * Local functions definition
 */


Add, after it;

if (USER_ID){

 } else {
{
    $redirect = $redirect . "login.php";
        header("Location: $redirect");

    exit();
}}

 

Open displayimage.php.

find;
require('include/init.inc.php');

Add after;
if (USER_ID){

} else {
{
    $redirect = $redirect . "login.php";
        header("Location: $redirect");

    exit();
}}



Now do the same for thumbnails.php, and search.php.
It has been a long time now since I did my little bit here, and have done no coding or any other such stuff since. I'm back to being a noob here

bit bit spears

OMG you are a saint! Thanks a lot casper! i really want to thank you for all of your hard work on here! you are a nice guy who got me virtually everything i wanted!

Casper

Hi tb,

I think what you are asking is easily achievable, by creating a new file, let's call it 'welcome.php' which has the welcome page you want, and then adding a re-direct to the logged in user, BUT the hard bit may be to make it only work the first time someone goes to the index page each visit to your site.

You don't want it to happen when a logged on user goes from thumbnail.php to index.php, just when they come from outside the site.

I think it would be easier to change the cookie settings, so that when someone actually leaves, they are automatically logged out, then when they come back, they will go straight to the login page.

The welcome everyone already gets when logging on can be changed to what you want.
It has been a long time now since I did my little bit here, and have done no coding or any other such stuff since. I'm back to being a noob here

fuderyuu

You ARE a god send.. this has to be placed as a sticky  cause this is great!
MANY THANKS

elzeviro

Hi all, I made login page the default page for my gallery (as descripted in http://forum.coppermine-gallery.net/index.php?topic=3503). How can I hide menus (album list, favorites... login) ONLY from the login page? But I'd like t display these menus in the user pages... deleting them from the theme.php file is not good...
thanks

Casper

provided you completed the mod, including doing it to thumbnails.php and search.php, it does not matter that the links are there, because they also redirect to login.php.
It has been a long time now since I did my little bit here, and have done no coding or any other such stuff since. I'm back to being a noob here

elzeviro

I made all the mod in thumbnails.php or search.php but the main menus (login, album list, favorites etc.) are still there in the login page...
I would like that only registered users could see these menus

bit bit spears

I think you would need to move these under a certain span class in order to be only shown if you are logged in. What I did was take all of the stuff out of the menu, but login and logout, and made a frame page that would use redirection if the user was logged in.

elzeviro

excuse me... :oops: could you show me how to do?
thanks a lot!

bit bit spears

ok-i am not sure this works-but it might.

i would just move all of the links or whatever you don't want to be displayed without logging in under these span classes in theme.php

<!-- BEGIN logout -->
<a href="{LOGOUT_TGT}">{LOGOUT_LNK}</a>
<!-- END logout -->


Move them into that span class:

<!-- BEGIN logout -->
 <!-- END logout -->


please be sure to back up-because i am not certain that this will work:)

elzeviro

It works! great: thank you so much and excuse me for my insistence!

bit bit spears


Casper

TB, you sound surprised.  Have a bit more faith in yourself  :wink:
It has been a long time now since I did my little bit here, and have done no coding or any other such stuff since. I'm back to being a noob here

Leighm0


jarekn

The login works fine on the first attempt, but after I log out and try going back to the forum, instead of being redirected to the login page I get the following error message:

Fatal error : There was an error while processing a database query

If I delete cookies and temp files the redirection to the login page works fine.

Any ideas?

Casper

Did you do the basic mod, or did you apply tb's changes as well?
Log in, and turn on debug mode in config, and report what it says when the problem happens.

Edit;  I just saw your other post, and you are bridged with VB3, and I suspect this is to dowith that, and the 'remember me' issue.
It has been a long time now since I did my little bit here, and have done no coding or any other such stuff since. I'm back to being a noob here

Joachim Müller

#19
@jarekn: you reported a login issue as well on the thread dealing with vbulletin integration!
  • Do not double-post!
  • login issues differ for standalone and bbs-integrated coppermine. Specify your version and post on the appropriate thread only!
:evil: GauGau