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.
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.
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.
just installed this
works great - thanks for a great mod Lazuli π
~Spikey~
my site url: http://www.fanfictionworld.org
efic version:3.5.3
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.
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.
Well, it works. But apparently some people haven't logged in since Dec 31, 1969. How do I fix this?
eFiction:3.5.1
Latest Patche(s):Yes
bridged?:No
modified?:Yes.
PHP:2.11.9.4
MySQL:5.0.32
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.
is this mod likely to work with 3.3?
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:
site:
Available for skin/mod commission! π
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:
Nope. It isn't updating anymore since I upgraded to 3.3.
You have to change the variables to the new variables in the 3.3 upgrade ...
archive:
site:
Available for skin/mod commission! π
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
...
$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:
site:
Available for skin/mod commission! π
