PHP Login System with Admin Features

This forum was created to talk about the PHP Login System with admin features created by jpmaster77 on evolt's website


    Change time() to date issues

    Share
    avatar
    ragtech

    Number of posts : 10
    Age : 57
    Registration date : 2009-04-08

    Change time() to date issues

    Post  ragtech on Sat Apr 18, 2009 7:23 am

    I followed these instructions
    http://jpmaster77forum.conceptbb.com/php-login-system-help-f1/changing-time-with-date-y-m-d-his-t66.htm#330
    for changing time() with date("y/m/d : H:i:s")

    I changed this in session.php $this->time = time() to $this->time = date("y/m/d : H:i:s") and I also changed this in my mysql_db tables "users", "active_users" and "active_guest" to timestamp as per that post

    Everything is working but the "Registered members" and "Guests" totals only increase... they never zero out.



    I also wanted to automatically log users out after a give amount of time but when I followed this posts
    http://jpmaster77forum.conceptbb.com/hacks-and-modifications-f4/automatically-log-out-inactive-users-t25.htm
    instructions I could not log in as a user or as an admin.

    function addActiveUser($username, $time){
    $q = "SELECT * FROM ".TBL_USERS." WHERE username = '$username'";
    $r = mysql_query($q, $this->connection);
    $t = mysql_fetch_array($r);
    $timeout = time()-USER_TIMEOUT*10;
    if($t['timestamp'] < $timeout) header("Location: ./process.php");
    $q = "UPDATE ".TBL_USERS." SET timestamp = '$time' WHERE username = '$username'";
    mysql_query($q, $this->connection);
    if(!TRACK_VISITORS) return;
    $q = "REPLACE INTO ".TBL_ACTIVE_USERS." VALUES ('$username', '$time')";
    mysql_query($q, $this->connection);
    $this->calcNumActiveUsers();
    }


    I tried changing $timeout = time()-USER_TIMEOUT*10; to $timeout = date("y/m/d : H:i:s")-USER_TIMEOUT*10; and this allowed me to log in but the "Registered members" and "Guests" totals still remain (they don't change... only increase)

    Can anyone help me with this... my site is up and running well (http://craftsitelinkexchange.com) but I would like to get this one tidbit working

    correctly.
    avatar
    Linchpin311

    Number of posts : 220
    Age : 32
    Localisation : Long Island
    Registration date : 2007-05-14

    Re: Change time() to date issues

    Post  Linchpin311 on Sun Apr 19, 2009 4:49 pm

    since the time() function is a large part of how the script keeps track of users and their behavior, swapping this function out for another one can be very messy. can i ask why you want to do this? maybe there is another more simple solution besides seeking out every time() function in the script and editing it for your needs.


    _________________
    in the end, the universe tends to unfold as it should...

    Also note that it is your responsibility to die() if necessary.
    avatar
    ragtech

    Number of posts : 10
    Age : 57
    Registration date : 2009-04-08

    Re: Change time() to date issues

    Post  ragtech on Sun Apr 19, 2009 5:30 pm

    I thought having an actual date / time format would help me keep track of knowing when my members have modified their information. Also, in the admin page I was enventually going to sort the list of members by date/time instead of alphabetically as it does by default.

    If you have a solution I would greatfully want to know how I might do this without changing the time() tag

    Thanks!
    avatar
    Linchpin311

    Number of posts : 220
    Age : 32
    Localisation : Long Island
    Registration date : 2007-05-14

    Re: Change time() to date issues

    Post  Linchpin311 on Sun Apr 19, 2009 5:36 pm

    the time function just generates a unix time stamp which is great for this cause you can sort them for whatever reason.

    if you wanted to actually make sense of the timestamp you might want to try retrieving the time stamp from the database and putting it in a variable. then try date("y/m/d : H:i:s", $timestamp). that will display the time stamp you supplied in the format you supplied.

    hope this helps!


    _________________
    in the end, the universe tends to unfold as it should...

    Also note that it is your responsibility to die() if necessary.
    avatar
    ragtech

    Number of posts : 10
    Age : 57
    Registration date : 2009-04-08

    Re: Change time() to date issues

    Post  ragtech on Sun Apr 19, 2009 5:42 pm

    Yes, I understand what you are saying... I'll try that and see how it works out. I'll reply back to this Post and let you know.

    Thanks for the assistance.
    This script and this forum is the BEST!
    -rg
    avatar
    ragtech

    Number of posts : 10
    Age : 57
    Registration date : 2009-04-08

    Re: Change time() to date issues

    Post  ragtech on Sun Apr 19, 2009 6:32 pm

    Ok! woohoo! That worked perfectly!


    Thank you Linchpin311
    -rg
    avatar
    Linchpin311

    Number of posts : 220
    Age : 32
    Localisation : Long Island
    Registration date : 2007-05-14

    Re: Change time() to date issues

    Post  Linchpin311 on Sun Apr 19, 2009 6:35 pm

    glad its all working for you! Very Happy


    _________________
    in the end, the universe tends to unfold as it should...

    Also note that it is your responsibility to die() if necessary.
    avatar
    Helios

    Number of posts : 9
    Registration date : 2009-04-21

    Re: Change time() to date issues

    Post  Helios on Mon Apr 27, 2009 1:31 pm

    Linchpin311 wrote:glad its all working for you! Very Happy

    Can you post your example variable please?
    avatar
    ragtech

    Number of posts : 10
    Age : 57
    Registration date : 2009-04-08

    Re: Change time() to date issues

    Post  ragtech on Mon Apr 27, 2009 3:48 pm

    added this to my admin.php to display the time in a readable format:

    $time = mysql_result($result,$i,"timestamp");
    $display = date("m/d/y : H:i:s", $time);

    echo "<tr><td><b>Time Stamp:</b></td><td>$time, $display</td></tr>";


    -rg
    avatar
    Helios

    Number of posts : 9
    Registration date : 2009-04-21

    Re: Change time() to date issues

    Post  Helios on Tue Apr 28, 2009 2:26 am

    thank you, i'll try to add this to mine tonight.

    Sponsored content

    Re: Change time() to date issues

    Post  Sponsored content


      Current date/time is Mon Nov 20, 2017 9:26 am