[MOD] Last Visit 3....
 
Notifications
Clear all

[MOD] Last Visit 3.0

61 Posts
22 Users
0 Reactions
28.9 K Views
(@lazuli)
Posts: 61
Trusted Member
Topic starter
 

Description: Displays the last date your users visited your eFiction site.

As always my line numbers are approximate and meant to put you in the general ballpark.  They will likely change as you progress through the mod.

Requirements: eFiction 3.2

Mod History:
- 27 February, 2007, Marohi added mod to Test site, bug checking begins
- 1 March, 2007, Posted to eFiction forums
- 2 March, 2007, Fixed cookie issue, added language to en.php, changed mysql_query to dbquery

Difficulty: Easy

Files Involved:

  • user/login.php
  • user/profile.php
  • includes/get_session_vars.php
  • languages/en.php
  • skins/YOUR SKIN/profile.tpl
  • 1 database modification

Project Link: http://sally.lunaescence.com/2007/03/01/last-visit-mod/

Instructions:

Backup your files and database before you begin this or any other mod!

Database Modifications
FOR NEW INSTALL: For this mod, you will need to alter your database.  If you skip this step, THIS WILL NOT WORK!

FOR 2.0 UPGRADE: If you had Seiji's eFiction 2.0 last visit mod installed, you should be able to skip this step.

General Information (for phpMyAdmin, etc.)
Table: fanfiction_authors
Field: lastlog
Datatype: DATETIME
Null: Not Null

SQL Query:

ALTER TABLE `fanfiction_authors` ADD `lastlog` DATETIME NOT NULL ;

Open: user/login.php
Line 1, look for this:

<?php

After that, add this:

// Mod: Last Visit 3.0 ----------------------------------

Look for this: (line 50)

if($passwd['password'] == $encryptedpassword) {
if(!isset($_SESSION)) session_start( );
$_SESSION[$sitekey."_useruid"] = $passwd['uid'];
$_SESSION[$sitekey."_salt"] = md5($passwd['email']+$encryptedpassword);

After, add this:

			// Last visit mod
$update_lastlog = dbquery("UPDATE ".$tableprefix."fanfiction_authors SET lastlog = now() WHERE uid = '$passwd[uid]' LIMIT 1");
// end Last visit mod

Open: includes/get_session_vars.php
Line 1, look for this:

<?php

After that, add this:

// Mod: Last Visit 3.0 ----------------------------------

Look for this: (line 30)

if($userdata && $userdata['level'] != -1 && $_COOKIE[$sitekey.'_salt'] == md5($userdata['email']+$userdata['password'])) {
$useruid = $userdata['uid'];
$userpenname = $userdata['penname'];

After that, add this:

			// Last visit mod
$update_lastlog = dbquery("UPDATE ".$tableprefix."fanfiction_authors SET lastlog = now() WHERE uid = '$useruid' LIMIT 1");
// end Last visit mod

Open: user/profile.php
Line 1, look for this:

<?php

After that, add this:

// Mod: Last Visit 3.0 ----------------------------------

Look for this (Line 29):

$result2 = dbquery("SELECT *, UNIX_TIMESTAMP(date) as date FROM "._AUTHORTABLE." LEFT JOIN ".$tableprefix."fanfiction_authorprefs as ap ON ap.uid = "._UIDFIELD." WHERE "._UIDFIELD." = '$uid' LIMIT 1");

Inside that, look for:

UNIX_TIMESTAMP(date) as date

Immediately after that, add this: (Don't forget the comma!)

, UNIX_TIMESTAMP(lastlog) as lastlog

Look for this: (line 38)

$tpl->assign("userpenname", $userinfo['penname']." ".$nameinfo);

After that, add this:

if (date("$dateformat", $userinfo['lastlog']) == date("$dateformat", mktime(0, 0, 0, 0, 0, 0000)))   $tpl->assign("lastlog", ""._UNAVAILABLE."");   
else $tpl->assign("lastlog", date("$dateformat", $userinfo['lastlog']));

Open: languages/en.php (Or your language file)
At the end of the file, look for this

?>

BEFORE that, add this:

// Last Visit Mod
define ("_UNAVAILABLE", "Unavailable");

Finally, add {lastlog} to profile.tpl where you want it to appear.

Save, upload, and enjoy!


I'm sorry, but due to my schedule, I am not available for commissions.

Blog | DA Account

 
Posted : 02/03/2007 12:19 am
(@tammy)
Posts: 2577
Member Moderator
 

Lazuli,

I'd encourage you do use dbquery instead of mysql_query.  Using dbquery will let the script automatically output the query when debug is on to help you solve any problems.  It'll potentially also let someone go in and change eFiction to use a different database system by change the dbquery function without changing the entire script.  There's other reasons, but it's almost midnight and my brain shut down half an hour ago so I'll leave it there.


 
Posted : 02/03/2007 12:44 am
(@lazuli)
Posts: 61
Trusted Member
Topic starter
 

Okay, thanks Tammy.  I'll change it tomorrow.  My brain has shut down too.

EDIT: Fixed


I'm sorry, but due to my schedule, I am not available for commissions.

Blog | DA Account

 
Posted : 02/03/2007 1:00 am
(@fanfictionworld)
Posts: 149
Estimable Member
 

just installed this

works great - thanks for a great mod Lazuli  πŸ˜€


~Spikey~

my site url: http://www.fanfictionworld.org
efic version:3.5.3

 
Posted : 19/05/2007 6:28 pm
(@elizabeth)
Posts: 7
Active Member
 

I was wondering if this is going to be visible in the members page.  Because for my site, I have a lot of members that haven't signed on in awhile and I'd like to clean those out.


 
Posted : 06/06/2007 3:49 pm
(@lazuli)
Posts: 61
Trusted Member
Topic starter
 

Yes, this should be visible on people's profiles.  Just add {lastlog} to profile.tpl


I'm sorry, but due to my schedule, I am not available for commissions.

Blog | DA Account

 
Posted : 06/06/2007 4:47 pm
(@anarchicq)
Posts: 115
Estimable Member
 

Well, it works. But apparently some people haven't logged in since Dec 31, 1969. How do I fix this?


Silent Hill & Repo!
eFiction:3.5.1
Latest Patche(s):Yes
bridged?:No
modified?:Yes.
PHP:2.11.9.4
MySQL:5.0.32

 
Posted : 07/06/2007 7:06 pm
(@lazuli)
Posts: 61
Trusted Member
Topic starter
 

I'll take a look at it this weekend.  Sorry about that


I'm sorry, but due to my schedule, I am not available for commissions.

Blog | DA Account

 
Posted : 07/06/2007 7:14 pm
 laiq
(@laiq)
Posts: 19
Active Member
 

is this mod likely to work with 3.3?


 
Posted : 03/09/2007 4:16 am
 Elle
(@jenny)
Posts: 594
Honorable Member
 

It works, I'm using it.

I think I know how to fix the 1969, but because -- when I installed it -- I simply updated the column ... can't test it. πŸ˜›


archive: dramione.org
site: accio.nu

Available for skin/mod commission! πŸ™‚

 
Posted : 03/09/2007 9:50 am
(@chris)
Posts: 77
Trusted Member
 

I don't know. Even logging on and off several times, I keep getting "unavailable".


I charge into the light and need only yours to find my way. Archive of One: Sam Emme Tales

 
Posted : 03/09/2007 9:58 am
(@michelle)
Posts: 106
Estimable Member
 

Nope. It isn't updating anymore since I upgraded to 3.3.


 
Posted : 03/09/2007 2:29 pm
 Elle
(@jenny)
Posts: 594
Honorable Member
 

You have to change the variables to the new variables in the 3.3 upgrade ...


archive: dramione.org
site: accio.nu

Available for skin/mod commission! πŸ™‚

 
Posted : 03/09/2007 3:13 pm
(@jacynthe)
Posts: 242
Estimable Member
 

I get the December 31 1969 date too instead of the unavialable. I think it has tyo do with this part of the code in profile.php


if (date("$dateformat", $userinfo['lastlog']) == date("$dateformat", mktime(0, 0, 0, 0, 0, 0000)))  $tpl->assign("lastlog", ""._UNAVAILABLE.""); 

the mktime is what sets it to December 31 1969. How can that be fixed?


Jacynthe

Archives: http://fanfics.e-authors.net
Version: 3.5.3
Modified? Somewhat...
PHP:  5.3.3
MySQL: 5.0.91-community

 
Posted : 04/09/2007 2:12 pm
 Elle
(@jenny)
Posts: 594
Honorable Member
 

...

$date = gmdate("Y-m-d H:i:s");

Perhaps that might help. I'm currently backing up the files but I'm going to go in and see where that could possible be "stuck in". πŸ˜›


archive: dramione.org
site: accio.nu

Available for skin/mod commission! πŸ™‚

 
Posted : 08/09/2007 6:35 pm
Page 1 / 5
Share: