1.Mar.2007

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.

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

Requirements: eFiction 3.2 or later

Difficulty: Easy

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

Files Involved:

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

Modification & Support Link: eFiction.org

Instructions:

 

 

 

 

 

 

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:

MySQL:
  1. ALTER TABLE `fanfiction_authors` ADD `lastlog` DATETIME NOT NULL ;

 

 

 

 

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

PHP:
  1. <?php

After that, add this:

PHP:
  1. // Mod: Last Visit 3.0 ----------------------------------

 

 

Look for this: (line 50)

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

After, add this:

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

 

 

 

 

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

PHP:
  1. <?php

After that, add this:

PHP:
  1. // Mod: Last Visit 3.0 ----------------------------------

 

 

Look for this: (line 30)

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

After that, add this:

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

 

 

 

 

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

PHP:
  1. <?php

After that, add this:

PHP:
  1. // Mod: Last Visit 3.0 ----------------------------------

 

 

Look for this (Line 29):

PHP:
  1. $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:

PHP:
  1. UNIX_TIMESTAMP(date) as date

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

PHP:
  1. , UNIX_TIMESTAMP(lastlog) as lastlog

 

 

Look for this: (line 38)

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

After that, add this:

PHP:
  1. if (date("$dateformat", $userinfo['lastlog']) == date("$dateformat", mktime(0, 0, 0, 0, 0, 0000)))   $tpl->assign("lastlog", ""._UNAVAILABLE."");   
  2. 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

PHP:
  1. ?>

BEFORE that, add this:

PHP:
  1. // Last Visit Mod
  2. define ("_UNAVAILABLE", "Unavailable");

 

 

 

 

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

Save, upload, and enjoy!

You can leave a response, or trackback from your own site.

One Response to “Last Visit Mod”

  1. Beth Says:

    I’ve followed the Last Visit mod for eFic 2.x, but the one part that’s not clear to me is where I put “ALTER TABLE `fanfiction_authors` ADD `lastlog` DATETIME NOT NULL.” For now, I’ve placed it in /docs/upgrade-tables-step6.sql right below “ADD `alertson` CHAR( 1 ) DEFAULT ‘0′ NOT NULL,” in the ALTER TABLE ‘fanfiction_authors’ section, but it’s still not working for me :/ I posted in the forums, but since the thread has been in disuse, no one has answered.

    Thank you in advance :D

Leave a Reply