CodeCharge Studio
search Register Login  

Web Reports

Visually create Web Reports in PHP, ASP, .NET, Java, Perl and ColdFusion.
CodeCharge.com

YesSoftware Forums -> CodeCharge Studio -> PHP

 who is loged on

Print topic Send  topic

Author Message
pjcltd

Posts: 34
Posted: 03/19/2008, 6:18 AM

Hi i have setup a system on our server using CCS4 with PHP

now i have setup users / admins but i would like to be able to see who is loged on
i have a admin table setup with the following
CREATE TABLE `admin` (
`id` int(11) NOT NULL auto_increment,
`admin-name` varchar(150) NOT NULL default '',
`admin-email` varchar(255) NOT NULL default '',
`admin-password` varchar(250) NOT NULL default '',
`admin-level` char(2) NOT NULL default '3',
`costcenter` varchar(100) NOT NULL default 'None',
`online` char(2) NOT NULL default '0',
PRIMARY KEY (`id`),
KEY `admin-name` (`admin-name`,`admin-password`)
) TYPE=MyISAM AUTO_INCREMENT=7 ;

Now what i would like is for ccs4 to set the 'online' = 1 whe the users logs on
and back to '0' when thay log off
can any one assist me with this please.

thanks
Paul
View profile  Send private message
Waspman

Posts: 948
Posted: 03/20/2008, 1:45 AM

I do this on the intranets I build.

I use a custom script to update the users record to say they are online when they login. I show the list of who's on to the administrator and how long they've been on and what they've done. I don't show the numbers of who's on to the rest of the users, but that could be a simple set session thing even if you want to show how many and what types.

When they log off, the page they are referred to once they have logged off has another customer script that marks their record as being logged off. I also update a seperate table with visit details again for the administrator.


Hope this helps,


Tony



_________________
http://www.waspmedia.co.uk
View profile  Send private message
pjcltd

Posts: 34
Posted: 03/20/2008, 2:14 AM

Quote Waspman:
I do this on the intranets I build.

I use a custom script to update the users record to say they are online when they login. I show the list of who's on to the administrator and how long they've been on and what they've done. I don't show the numbers of who's on to the rest of the users, but that could be a simple set session thing even if you want to show how many and what types.

When they log off, the page they are referred to once they have logged off has another customer script that marks their record as being logged off. I also update a seperate table with visit details again for the administrator.


Hope this helps,


Tony



hi
thats what i am looking for.
Would i be able to get the code or is there a cost involved ?
thanks
Paul
View profile  Send private message
Waspman

Posts: 948
Posted: 03/20/2008, 2:42 AM

Sorry man! Didn't realise...

$db = new clsDBConnection1;
$db->query("UPDATE users SET LoggedIn = 1, LastVisit = Now() WHERE UserName =".$db->ToSQL(CCGetParam("login"),ccsText));
unset($db);

Stick it in the login page code after the bit that says "OnClick = true" (or similar)

....

Then add the reverse (set LoggedIn = 0) of the code on the before show of the log off page. This can also be your login page just add a form that loads the users details based on the session UserID and make it do the updating thing and un-setting the sessions etc.


Let me know if you need anymore help...

T
_________________
http://www.waspmedia.co.uk
View profile  Send private message
pjcltd

Posts: 34
Posted: 03/20/2008, 3:15 AM

Hi Tony
ok i am haveing a problem getting the logedin name right
if i change this
$db->query("UPDATE users SET LoggedIn = 1, LastVisit = Now() WHERE UserName =".$db->ToSQL(CCGetParam("login"),ccsText));

to

This

$db->query("UPDATE users SET LoggedIn = 1, LastVisit = Now() ");

then it updats all the users so that i know its talking to my DB
but i can not get the code to work with my login name

$db->query("UPDATE admin SET online = '1', LastVisit = Now() when admin-name =" . CCGetSession("UserLogin"). "");

i tryed this as i am setting the UserLogin and that works if i display it after the user has loged in

thanks
for your help so far

thanks
Paul


View profile  Send private message
Waspman

Posts: 948
Posted: 03/20/2008, 3:32 AM

It compares the UserName with the login field content. No session is set so it wouldn't have anything to compare.


$db->query("UPDATE admin SET online = 1, LastVisit = Now() WHERE admin-name =".$db->ToSQL(CCGetParam("loginfield"),ccsText));


_________________
http://www.waspmedia.co.uk
View profile  Send private message
pjcltd

Posts: 34
Posted: 03/20/2008, 5:23 AM

HI no stillnot working

$db = new clsDBmysql_server;
$db->query("UPDATE admin SET online = 1, LastVisit = Now() WHERE admin-name =".$db->ToSQL(CCGetParam("Login"),ccsText));
unset($db);
Now not sure if this matters but the login name is like this

Username Dave Smith
Password *************

The loging feild on the login page is login
this is doingmy head in cos i know i am so close to sorting this out with your help

thanks
Paul


View profile  Send private message
pjcltd

Posts: 34
Posted: 03/20/2008, 5:56 AM

Now i get the foloowing error

Fatal error: Only variables can be passed by reference in /home/sites/home/web/modules/cusers/index_events.php on line 22
View profile  Send private message
pjcltd

Posts: 34
Posted: 03/20/2008, 6:03 AM

is there a way i can display the sql input and output on the screen so that i can see whats going on ?


View profile  Send private message
Waspman

Posts: 948
Posted: 03/20/2008, 6:04 AM

I'll get it working ina php app and send it to ya...T
_________________
http://www.waspmedia.co.uk
View profile  Send private message
pjcltd

Posts: 34
Posted: 03/20/2008, 6:07 AM

Quote Waspman:
I'll get it working ina php app and send it to ya...T


thanks very much
View profile  Send private message
Waspman

Posts: 948
Posted: 03/20/2008, 6:11 AM

This is what works for me:

global $CCSLocales;
global $Redirect;
if ($Container->autoLogin->Value != $Container->autoLogin->CheckedValue) {
CCSetCookie("TcentixLogin", "");
}
if ( !CCLoginUser( $Container->login->Value, $Container->password->Value)) {
$Container->Errors->addError($CCSLocales->GetText("CCS_LoginError"));
$Container->password->SetValue("");
$Login_Button_DoLogin_OnClick = 0;
CCSetCookie("TcentixLogin", "");
} else {
global $Redirect;
if ($Container->autoLogin->Value == $Container->autoLogin->CheckedValue) {
$ALLogin = $Container->login->Value;
$ALPassword = $Container->password->Value;
CCSetALCookie($ALLogin, $ALPassword);
}
$Redirect = CCGetParam("ret_link", $Redirect);
$Login_Button_DoLogin_OnClick = 1;
CCSetSession("Logged",'YES');
$db = new clsDBConnection1;
$db->query("UPDATE users SET LastVisit = Now() WHERE UserName =".$db->ToSQL(CCGetParam("login"),ccsText));
unset($db);
}

T
_________________
http://www.waspmedia.co.uk
View profile  Send private message
pjcltd

Posts: 34
Posted: 03/20/2008, 6:36 AM

Hi this is what i am usging

global $CCSLocales;
global $Redirect;
if ($Container->autoLogin->Value != $Container->autoLogin->CheckedValue) {
CCSetCookie("HomeGroupUsersLogin", "");
}
if ( !CCLoginUser( $Container->login->Value, $Container->password->Value)) {
$Container->Errors->addError($CCSLocales->GetText("CCS_LoginError"));
$Container->password->SetValue("");
$Login_Button_DoLogin_OnClick = 0;
CCSetCookie("HomeGroupUsersLogin", "");
} else {
global $Redirect;
if ($Container->autoLogin->Value == $Container->autoLogin->CheckedValue) {
$ALLogin = $Container->login->Value;
$ALPassword = $Container->password->Value;
CCSetALCookie($ALLogin, $ALPassword);
}
$Redirect = CCGetParam("ret_link", $Redirect);
$Login_Button_DoLogin_OnClick = 1;
$db = new clsDBmysql_server;
$db->query("UPDATE admin SET online = 1, LastVisit = Now() WHERE admin-name =".$db->ToSQL(CCGetParam("Login"),ccsText));
unset($db);
}


but it is still not working
View profile  Send private message
Waspman

Posts: 948
Posted: 03/20/2008, 6:42 AM

Sorry to state the obvious, but you have got the field names right re case?


_________________
http://www.waspmedia.co.uk
View profile  Send private message
pjcltd

Posts: 34
Posted: 03/20/2008, 6:50 AM

hi
yes i have checked them all

now is there a way to see what the hole sql statment is when it is sent to the server ie
if the login name is 'Dave Smith'

i would expect to see the sql statment to be somthing like this

UPDATE admin SET online = 1, LastVisit = Now() WHERE admin-name ="Dave Smith'

is there a way i can see if the statment is getting made right

thanks
Paul
View profile  Send private message
Waspman

Posts: 948
Posted: 03/20/2008, 7:32 AM

Do that, use the actual known value.


_________________
http://www.waspmedia.co.uk
View profile  Send private message
pjcltd

Posts: 34
Posted: 03/20/2008, 8:04 AM

Quote Waspman:
Do that, use the actual known value.


Done that still dose not work

Going home now

Thanks for all you heard Work
View profile  Send private message
ckroon

Posts: 869
Posted: 03/20/2008, 9:23 AM

This is something I am going to add to my components this weekend. I will try to assist you then if you haven't got it working yet.

Thanks for the code Waspman!
_________________
Walter Kempees...you are dearly missed.
View profile  Send private message
wkempees


Posts: 1679
Posted: 03/20/2008, 12:02 PM

Connectionname ????
$DBmysql_server ??? Check if that is actually you connectionname.

_________________
Origin: NL, T:GMT+1 (Forumtime +9)
CCS3/4.01.006 PhP, MySQL .Net/InMotion(Vista/XP, XAMPP)

if you liked this info PAYPAL me: http://donate.consultair.eu
View profile  Send private message
wkempees


Posts: 1679
Posted: 03/20/2008, 12:05 PM

Also :
If you get this to work, by setting your connection right, typing in coorect SQL and using the right fieldnames, be advised that if your user logs in, and the switch is set to 1, you have a logged in user.
If the user than closes his browser, shuts down his pc, he will still be marked as logged in.
You need to also register the datetime of login, and regularly update that datetimestamp.
Then you will be able to do a timed interval check and see if your logged in status actualy is true.
Walter

_________________
Origin: NL, T:GMT+1 (Forumtime +9)
CCS3/4.01.006 PhP, MySQL .Net/InMotion(Vista/XP, XAMPP)

if you liked this info PAYPAL me: http://donate.consultair.eu
View profile  Send private message
pjcltd

Posts: 34
Posted: 03/21/2008, 12:58 AM

Quote wkempees:
Connectionname ????
$DBmysql_server ??? Check if that is actually you connectionname.

Hi yes this is right as the hole site uses this connection

View profile  Send private message
Waspman

Posts: 948
Posted: 03/21/2008, 3:04 AM

Quote wkempees:
Also :
If you get this to work, by setting your connection right, typing in coorect SQL and using the right fieldnames, be advised that if your user logs in, and the switch is set to 1, you have a logged in user.
If the user than closes his browser, shuts down his pc, he will still be marked as logged in.
You need to also register the datetime of login, and regularly update that datetimestamp.
Then you will be able to do a timed interval check and see if your logged in status actualy is true.
Walter



yeah, we never actually got round the log off issue properly. Where it mattered (our telesales system) we had a team leader to ensure that people got into the habit of logging off, otherwise they wouldn't get paid. - Enforced discipline:-D

T
_________________
http://www.waspmedia.co.uk
View profile  Send private message
wkempees


Posts: 1679
Posted: 03/21/2008, 8:29 AM

Enforced discipline..... I love it, lol

_________________
Origin: NL, T:GMT+1 (Forumtime +9)
CCS3/4.01.006 PhP, MySQL .Net/InMotion(Vista/XP, XAMPP)

if you liked this info PAYPAL me: http://donate.consultair.eu
View profile  Send private message
pjcltd

Posts: 34
Posted: 03/25/2008, 1:17 AM

Hi All

Well back at work now
and i still have the same problem

if i use the following

UPDATE admin SET online = '1', LastVisit = Now()

then the DB gets updated and shows all the usres online.

ollowing

UPDATE admin SET online = '1', LastVisit = Now() WHERE admin-name='Dave Smith"

nothing happens

and Dave Smith is a user on the system and he can login with this username and his password





View profile  Send private message
maxhugen

Posts: 272
Posted: 03/25/2008, 3:06 AM

I'm a novice here, but I'm wondering if the following is missing quotations to enclose the Login string:

$db->query("UPDATE admin SET online = 1, LastVisit = Now() WHERE admin-name =".$db->ToSQL(CCGetParam("Login"),ccsText));

maybe should be:

$db->query("UPDATE admin SET online = '1', LastVisit = Now() WHERE admin-name ='".$db->ToSQL(CCGetParam("Login"),ccsText)."';")

Just as your last example should perhaps be:

UPDATE admin SET online = '1', LastVisit = Now() WHERE admin-name='Dave Smith'

(it was mixing single and double quotes around Dave Smith)

_________________
Max
www.gardenloco.com | www.eipdna.com | www.chrisarminson.com
View profile  Send private message
maxhugen

Posts: 272
Posted: 03/25/2008, 3:22 AM

Re the logging out issue, you can change the 'online' field to a timestamp, then use an include on all pages (eg in a header file) that uses ajax to update the timestamp regularly.

If the user logs out, the timestamp is cleared; a proc at the db checks every x mins for any timestamps more than y mins old, and clears it.
_________________
Max
www.gardenloco.com | www.eipdna.com | www.chrisarminson.com
View profile  Send private message
Waspman

Posts: 948
Posted: 03/25/2008, 4:31 AM

Quote maxhugen:
Re the logging out issue, you can change the 'online' field to a timestamp, then use an include on all pages (eg in a header file) that uses ajax to update the timestamp regularly.

If the user logs out, the timestamp is cleared; a proc at the db checks every x mins for any timestamps more than y mins old, and clears it.

Thanks Max, sounds good. I did do something similar using and refreshing iframe in the footer - worked OK. If I need it again I'll use your method.;-)

T
_________________
http://www.waspmedia.co.uk
View profile  Send private message
pjcltd

Posts: 34
Posted: 03/26/2008, 6:25 AM

Hi Guys

Thanks for all your hard work with my problems
i could not get it to work the way i wanted it to work
so what i have done is this

in the ccLoginUser part of the common.php i have used the sql
$db->query("UPDATE admin SET online = '1', LastVisit = Now() WHERE adminname ='".$login."'");

and in the CCLogoutUser I used the following code

$db = new clsDBmysql_server;
$SQL= "UPDATE admin SET online = '0', logout = Now() WHERE adminname ='".CCGetSession("UserLogin")."'";
$db->query($SQL);


This all works very well
thanks again for all your help.


Paul

View profile  Send private message

Add new topic Subscribe to topic   


These are Community Forums for users to exchange information.
If you would like to obtain technical product help please visit http://support.yessoftware.com.

MS Access to Web

Convert MS Access to Web.
Join thousands of Web developers who build Web applications with minimal coding.

CodeCharge.com

Home   |    Search   |    Members   |    Register   |    Login


Powered by UltraApps Forum created with CodeCharge Studio
Copyright © 2003-2004 by UltraApps.com  and YesSoftware, Inc.