Help with Last Visi...
 
Notifications
Clear all

Help with Last Visit Mod

6 Posts
2 Users
0 Reactions
1,960 Views
(@somethingblue42)
Posts: 13
Active Member
Topic starter
 

I tried adding the Last Visit mod following the instructions in this topic > https://efiction.org/forums/index.php?topic=4781.0 and when I was done adding everything I ended up getting:

A fatal MSQL error was encountered.
Query: UPDATE fanfiction_authors SET lastlog = now() WHERE uid="LIMIT 1
Error: (1146) Table 'nsync908_archive.fanfiction_authors' doesn't exist

I figured out the error showed up when I uploaded the get_sessions_vars.php file (I've included that code below) but I can't for the life of me figure out what I've done wrong. Any help would be greatly appreciated.

<?php
// Mod: Last Visit 3.0 ----------------------------------
// ----------------------------------------------------------------------
// eFiction 3.2
// Copyright (c) 2007 by Tammy Keefer
// Valid HTML 4.01 Transitional
// Based on eFiction 1.1
// Copyright (C) 2003 by Rebecca Smallwood.
// http://efiction.sourceforge.net/
// ----------------------------------------------------------------------
// LICENSE
//
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License (GPL)
// as published by the Free Software Foundation; either version 2
// of the License, or (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
// GNU General Public License for more details.
//
// To read the license please visit http://www.gnu.org/copyleft/gpl.html
// ----------------------------------------------------------------------

if(!defined("_CHARSET")) exit( );
// Get session variables from cookie data if not logged in.
// To bridge to another program replace (or add to) this information with the bridge to your other script.  See examples in the includes/bridges/ folder.
if (!empty($_COOKIE[$sitekey."_useruid"])) {
$userdata = dbassoc(dbquery("SELECT ap.*, "._UIDFIELD." as uid, "._PENNAMEFIELD." as penname, "._EMAILFIELD." as email, "._PASSWORDFIELD." as password FROM "._AUTHORTABLE." LEFT JOIN ".TABLEPREFIX."fanfiction_authorprefs as ap ON ap.uid = "._UIDFIELD." WHERE "._UIDFIELD." = '".$_COOKIE[$sitekey."_useruid"]."'"));
if($userdata && $userdata['level'] != -1 && $_COOKIE[$sitekey.'_salt'] == md5($userdata['email']+$userdata['password'])) {
define("USERUID", $userdata['uid']);
define("USERPENNAME", $userdata['penname']);
// Last visit mod
$update_lastlog = dbquery("UPDATE ".$tableprefix."fanfiction_authors SET lastlog = now() WHERE uid = '$useruid' LIMIT 1");
// end Last visit mod
if(!isset($_SESSION[$sitekey."_skin"]) && !empty($userdata['userskin'])) $siteskin = $userdata['userskin'];
else if(isset($_SESSION[$sitekey."_skin"])) $siteskin = $_SESSION[$sitekey."_skin"];
else $siteskin = $defaultskin;
define("uLEVEL", $userdata['level']);
define("isADMIN", uLEVEL > 0 ? true : false);
define("isMEMBER", true);
if(EMPTY($_SESSION[$sitekey."_agecontsent"])) $ageconsent = $userdata['ageconsent'];
else $ageconsent = $_SESSION[$sitekey."_agecontsent"];
}
}
if(!empty($_SESSION[$sitekey."_useruid"]) && !defined("USERUID")) {
$userdata = dbassoc(dbquery("SELECT ap.*, "._UIDFIELD." as uid, "._PENNAMEFIELD." as penname, "._EMAILFIELD." as email, "._PASSWORDFIELD." as password FROM "._AUTHORTABLE." LEFT JOIN ".TABLEPREFIX."fanfiction_authorprefs as ap ON ap.uid = "._UIDFIELD." WHERE "._UIDFIELD." = '".$_SESSION[$sitekey."_useruid"]."'"));
if($userdata && $userdata['level'] != -1 && $_SESSION[$sitekey.'_salt'] == md5($userdata['email']+$userdata['password'])) {
define("USERUID", $userdata['uid']);
define("USERPENNAME", $userdata['penname']);
if(!isset($_SESSION[$sitekey."_skin"]) && !empty($userdata['userskin'])) $siteskin = $userdata['userskin'];
else if(isset($_SESSION[$sitekey."_skin"])) $siteskin = $_SESSION[$sitekey."_skin"];
else $siteskin = $defaultskin;
define("uLEVEL", $userdata['level']);
define("isADMIN", uLEVEL > 0 ? true : false);
define("isMEMBER", true);
if(!isset($_SESSION[$sitekey."_agecontsent"])) $ageconsent = $userdata['ageconsent'];
else $ageconsent = $_SESSION[$sitekey."_agecontsent"];
}
}
if(!defined("USERUID")) define("USERUID", 0);
if(!defined("USERPENNAME")) define("USERPENNAME", false);
if(!defined("uLEVEL")) define("uLEVEL", 0);
if(!defined("isMEMBER")) define("isMEMBER", false);
if(!defined("isADMIN")) define("isADMIN", false);
if(empty($siteskin)) $siteskin = $defaultskin;

?>

 
Posted : 03/03/2011 7:06 pm
(@lyndsie)
Posts: 1263
Member Moderator
 

It's old school code, probably from before that change in 3.3. I'm guessing your site has a prefix.

change


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

to


$update_lastlog = dbquery("UPDATE ".TABLEPREFIX."fanfiction_authors SET lastlog = now() WHERE uid = '$useruid' LIMIT 1");

 
Posted : 03/03/2011 8:38 pm
(@somethingblue42)
Posts: 13
Active Member
Topic starter
 

Awesome! That solved the problem with crashing the site but the modification itself isn't working. I've added the code from the other pages I modded (had to split up the posts because of max message length) if you don't mind taking a look. Thanks so much for your help I really appreciate it!

login.php

<?php
// ----------------------------------------------------------------------
// eFiction 3.2
// Copyright (c) 2007 by Tammy Keefer
// Valid HTML 4.01 Transitional
// Based on eFiction 1.1
// Copyright (C) 2003 by Rebecca Smallwood.
// http://efiction.sourceforge.net/
// ----------------------------------------------------------------------
// LICENSE
//
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License (GPL)
// as published by the Free Software Foundation; either version 2
// of the License, or (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
// GNU General Public License for more details.
//
// To read the license please visit http://www.gnu.org/copyleft/gpl.html
// ----------------------------------------------------------------------

if(isset($_POST['submit']) && preg_match("!^[-a-z0-9_ ]{3,30}$!i", $_POST['penname'])) {
if(!defined("_LOGINCHECK")) exit( );
define("_BASEDIR", "");
include_once("config.php");
$settings = dbquery("SELECT tableprefix, maintenance, sitekey, debug FROM ".$settingsprefix."fanfiction_settings WHERE sitekey = '".$sitekey."'");
list($tableprefix, $maintenance, $sitekey, $debug) = dbrow($settings);
$tempdebug = $debug;
$debug = 0;
define("TABLEPREFIX", $tableprefix);
define("SITEKEY", $sitekey);
include_once("includes/queries.php");
$result = dbquery("SELECT *, "._UIDFIELD." as uid FROM "._AUTHORTABLE." LEFT JOIN ".$tableprefix."fanfiction_authorprefs AS ap ON ap.uid = "._UIDFIELD." WHERE "._PENNAMEFIELD." = '".$_POST['penname']."'");
$passwd = dbassoc($result);
if(!dbnumrows($result)) {
require_once("header.php");
//make a new TemplatePower object
if(file_exists("$skindir/default.tpl")) $tpl = new TemplatePower( "$skindir/default.tpl" );
else $tpl = new TemplatePower("default_tpls/default.tpl");
include_once("includes/pagesetup.php");
$output = write_error(_NOSUCHACCOUNT);
$tpl->assign("output", $output);
$tpl->printToScreen( );
dbclose( );
exit( );
}
if($maintenance && $passwd['level'] < 0) {
header("Location: maintenance.php");
exit( );
}
$encryptedpassword = md5($_POST['password']);
if($passwd['level'] == -1) {
require_once("header.php");
//make a new TemplatePower object
if(file_exists("$skindir/default.tpl")) $tpl = new TemplatePower( "$skindir/default.tpl" );
else $tpl = new TemplatePower("default_tpls/default.tpl");
include_once("includes/pagesetup.php");
$output = write_error(_ACCOUNTLOCKED);
$tpl->assign("output", $output);
$tpl->printToScreen( );
dbclose( );
exit( );
}
if($passwd['password'] == $encryptedpassword) {
if(isset($_POST['cookiecheck'])) {
setcookie($sitekey."_useruid",$passwd['uid'], time()+60*60*24*30, "/");
setcookie($sitekey."_salt", md5($passwd['email']+$encryptedpassword),  time()+60*60*24*30, "/");
}
if(!isset($_SESSION)) session_start( );
$_SESSION[$sitekey."_useruid"] = $passwd['uid'];
$_SESSION[$sitekey."_salt"] = md5($passwd['email']+$encryptedpassword);
// Last visit mod
$update_lastlog = dbquery("UPDATE ".$tableprefix."fanfiction_authors SET lastlog = now() WHERE uid = '$passwd[uid]' LIMIT 1");
// end Last visit mod
$logincode = dbquery("SELECT * FROM ".TABLEPREFIX."fanfiction_codeblocks WHERE code_type = 'login'");
while($code = dbassoc($logincode)) {
eval($code['code_text']);
}
}

else {
require_once("header.php");
//make a new TemplatePower object
if(file_exists("$skindir/default.tpl")) $tpl = new TemplatePower( "$skindir/default.tpl" );
else $tpl = new TemplatePower("default_tpls/default.tpl");
include_once("includes/pagesetup.php");
$output .= "<div id="pagetitle">"._MEMBERLOGIN."</div>";
$output .= "<div style='text-align: center;'>"._WRONGPASSWORD."</div>";
$tpl->assign("output", $output);
$tpl->printToScreen( );
dbclose( );
exit( );
}
$debug = $tempdebug;
}
else if(!isMEMBER) {
$output .= "<div id="pagetitle">"._MEMBERLOGIN."</div>";
$output .= "<div style="width: 250px; margin: 0 auto; text-align: center;"><form method="POST" enctype="multipart/form-data" action="user.php?action=login".(isset($_GET['sid']) && isNumber($_GET['sid']) ? "&amp;sid=".$_GET['sid'] : "")."">
<div class="label" style="float: left;  width: 30%; text-align: right;"><label for="penname">"._PENNAME.":</label></div><INPUT type="text" class="textbox" name="penname" id="penname"><br />
<div class="label" style="float: left; width: 30%; text-align: right;"><label for="pswd">"._PASSWORD.":</label></div><INPUT type="password" class="textbox" id="pswd" name="password"><br />
<INPUT type="checkbox" class="checkbox" name="cookiecheck" id="cookiecheck" value="1"><label for="cookiecheck">"._REMEMBERME."</label><br />
<INPUT type="submit" class="button" name="submit" value=""._SUBMIT."">
</form></div>";
$linkquery = dbquery("SELECT * from ".TABLEPREFIX."fanfiction_pagelinks WHERE link_name = 'login' OR link_name = 'lostpassword'");
while($link = dbassoc($linkquery)) {
if($link['link_access'] && !isMEMBER) continue;
if($link['link_access'] == 2 && !isADMIN) continue;
$pagelinks[$link['link_name']] = array("id" => $link['link_id'], "text" => $link['link_text'], "url" => _BASEDIR.$link['link_url'], "link" => "<a href=""".$link['link_url'"]."" title="".$link['link_text'].""".($link['link_target'] ? " target="_blank"" : "").($current == $link['link_name'] ? " id="current"" : "").">".$link['link_text']."</a>");
}
$output .= "<div style='text-align: center;'>".$pagelinks['register']['link']." | ".$pagelinks['lostpassword']['link']."</div>";
}
?>

user.php

<?php
// ----------------------------------------------------------------------
// Copyright (c) 2007 by Tammy Keefer
// Based on eFiction 1.1
// Copyright (C) 2003 by Rebecca Smallwood.
// http://efiction.sourceforge.net/
// ----------------------------------------------------------------------
// LICENSE
//
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License (GPL)
// as published by the Free Software Foundation; either version 2
// of the License, or (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
// GNU General Public License for more details.
//
// To read the license please visit http://www.gnu.org/copyleft/gpl.html
// ----------------------------------------------------------------------
if(isset($_GET['action'])) $current = $_GET['action'];
else $current = "login";

if($current == "logout" ) {
define("_LOGOUTCHECK", true);
include("user/logout.php");
}

if(!empty($_POST['submit']) && $current == "login") {
session_start();
define("_LOGINCHECK", true);
include("user/login.php");
}

require_once("header.php");
//make a new TemplatePower object
if(file_exists("$skindir/default.tpl")) $tpl = new TemplatePower( "$skindir/default.tpl" );
else $tpl = new TemplatePower("default_tpls/default.tpl");
if(file_exists("$skindir/listings.tpl")) $tpl->assignInclude( "listings", "./$skindir/listings.tpl" );
else $tpl->assignInclude( "listings", "./default_tpls/listings.tpl" );
include("includes/pagesetup.php");

if($action) $current = $action;
else $current = "user";
// end main function
if((empty($action) || $action == "login") && isMEMBER) {
$output .= "<div id="pagetitle">"._USERACCOUNT."</div>
<div class="tblborder" id="useropts" style="padding: 5px; width: 50%; margin: 1em 25%;">";
$panelquery = dbquery("SELECT * FROM ".TABLEPREFIX."fanfiction_panels WHERE panel_hidden != '1' AND panel_level = '1' AND (panel_type = 'U' ".(!$submissionsoff || isADMIN ? " OR panel_type = 'S'" : "").($favorites ? " OR panel_type = 'F'" : "").") ORDER BY panel_type, panel_order, panel_title ASC");
if(!dbnumrows($panelquery)) $output .= _FATALERROR;
while($panel = dbassoc($panelquery)) {
if(!$panel['panel_url']) $output .=  "<a href=""user.php?action=".$panel['panel_name'"]."">".$panel['panel_title']."</a><br />n";
else $output .= "<a href=""".$panel['panel_url'"]."">".$panel['panel_title']."</a><br />n";
}
$output .= "</div>n";
}
else if(!empty($action)) {
$panelquery = dbquery("SELECT * FROM ".TABLEPREFIX."fanfiction_panels WHERE panel_name = '$action' AND (panel_type='U' ".(!$submissionsoff || isADMIN ? " OR panel_type = 'S'" : "").($favorites ? " OR panel_type = 'F'" : "").") LIMIT 1");
if(dbnumrows($panelquery)) {
$panel = dbassoc($panelquery);
if($panel['panel_level'] > 0 && !isMEMBER) accessDenied( );
if($panel['panel_url'] && file_exists(_BASEDIR.$panel['panel_url'])) require_once(_BASEDIR.$panel['panel_url']);
else if(file_exists("user/{$action}.php")) require_once("user/{$action}.php");
else $output = write_error(_ERROR);
}
else $output .= write_error(_ERROR);
}
else $output = write_error(_NOTAUTHORIZED);
$tpl->assign( "output", $output );
$tpl->printToScreen();
dbclose( );
?>

 
Posted : 03/03/2011 9:02 pm
(@somethingblue42)
Posts: 13
Active Member
Topic starter
 

profile.php

<?php
// ----------------------------------------------------------------------
// eFiction 3.2
// Copyright (c) 2007 by Tammy Keefer
// Valid HTML 4.01 Transitional
// Based on eFiction 1.1
// Copyright (C) 2003 by Rebecca Smallwood.
// http://efiction.sourceforge.net/
// ----------------------------------------------------------------------
// LICENSE
//
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License (GPL)
// as published by the Free Software Foundation; either version 2
// of the License, or (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
// GNU General Public License for more details.
//
// To read the license please visit http://www.gnu.org/copyleft/gpl.html
// ----------------------------------------------------------------------

if(!defined("_CHARSET")) exit( );

// Build the user's profile information
$tpl->newBlock("profile");
$result2 = dbquery("SELECT *, UNIX_TIMESTAMP(date) as date, UNIX_TIMESTAMP(lastlog) as lastlog FROM "._AUTHORTABLE." LEFT JOIN ".TABLEPREFIX."fanfiction_authorprefs as ap ON ap.uid = "._UIDFIELD." WHERE "._UIDFIELD." = '$uid' LIMIT 1");
$userinfo = dbassoc($result2);
$nameinfo = "";
if($userinfo['email'])
$nameinfo .= " [<a href=""viewuser.php?action=contact&amp;uid=".$userinfo['uid'"]."">"._CONTACT."</a>]";
if(!empty($favorites) && isMEMBER && $userinfo['uid'] != USERUID) {
$fav = dbquery("SELECT * FROM ".TABLEPREFIX."fanfiction_favorites WHERE uid = '".USERUID."' AND type = 'AU' AND item = '".$userinfo['uid']."'");
if(dbnumrows($fav) == 0) $nameinfo .= " [<a href=""user.php?action=favau&amp;uid=".USERUID."&amp;add=".$userinfo['uid'"]."">"._ADDAUTHOR2FAVES."</a>]";
}
$tpl->assign("userpenname", $userinfo['penname']." ".$nameinfo);
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']));
$tpl->assign("membersince", date("$dateformat", $userinfo['date']));
if($userinfo['realname'])
$tpl->assign("realname", $userinfo['realname']);
if($userinfo['bio']) {
$bio = nl2br($userinfo['bio']);
$tpl->assign("bio", stripslashes($bio));
}
if($userinfo['image'])
$tpl->assign("image", "<img src=""".$userinfo['image'"]."">");
$tpl->assign("userlevel", isset($userinfo['level']) && $userinfo['level'] > 0 && $userinfo['level'] < 4 ? _ADMINISTRATOR.(isADMIN ? " - ".$userinfo['level'] : "") : _MEMBER);
/* Dynamic authorinfo fields */
$result2 = dbquery("SELECT * FROM ".TABLEPREFIX."fanfiction_authorinfo WHERE uid = '$uid'");
$dynamicfields = "";
while($field = dbassoc($result2)) {
if($field['info'] == "") continue;
$fieldinfo = dbassoc(dbquery("SELECT * FROM ".TABLEPREFIX."fanfiction_authorfields WHERE field_id = '".$field['field']."' LIMIT 1"));
if($fieldinfo) {
$thisfield = "";
if($fieldinfo['field_on'] == 0) continue;
if($fieldinfo['field_type'] == 1) { $thisfield = format_link($field['info']);
}
if($fieldinfo['field_type'] == 4) {
$thisfield = preg_replace("@{info}@", $field['info'], $fieldinfo['field_options']);
$thisfield = format_link($thisfield);
}
if($fieldinfo['field_type'] == 2 || $fieldinfo['field_type'] == 6) {
$thisfield = stripslashes($field['info']);
}
if($fieldinfo['field_type'] == 3) {
$thisfield = $field['info'];
}
else eval($fieldinfo['field_code_out']);
$tpl->assign($fieldinfo['field_name'], $thisfield);
$dynamicfields .= "<div class='authorfields'><span class='label'>".$fieldinfo['field_title'].":</span> ".$thisfield."</div>";
}
}
$codequery = dbquery("SELECT * FROM ".TABLEPREFIX."fanfiction_codeblocks WHERE code_type = 'userprofile'");
while($code = dbassoc($codequery)) {
eval($code['code_text']);
}
if(!empty($dynamicfields)) $tpl->assign("authorfields", $dynamicfields);
/* End dynamic fields */
$tpl->assign("reportthis", "[<a href="""._BASEDIR."contact.php?action=report&amp;url=viewuser.php?uid=".$uid."">"._REPORTTHIS."</a>"]");
$adminopts = "";
if(isADMIN && uLEVEL < 3) {
$adminopts .= "<div class="adminoptions"><span class='label'>"._ADMINOPTIONS.":</span> ".(isset($userinfo['validated']) && $userinfo['validated'] ? "[<a href=""admin.php?action=members&amp;revoke=$uid"" class="vuadmin">"._REVOKEVAL."</a>] " : "[<a href=""admin.php?action=members&amp;validate=$uid"" class="vuadmin">"._VALIDATE."</a>] ")."[<a href=""user.php?action=editbio&amp;uid=$uid"" class="vuadmin">"._EDIT."</a>] [<a href=""admin.php?action=members&amp;delete=$uid"" class="vuadmin">"._DELETE."</a>]";
$adminopts .= " [<a href=""admin.php?action=members&amp;".($userinfo['level'"] < 0 ? "unlock=".$userinfo['uid']."" class="vuadmin">"._UNLOCKMEM : "lock=".$userinfo['uid']."" class="vuadmin">"._LOCKMEM)."</a>]";
$adminopts .= " [<a href=""admin.php?action=admins&amp;".(isset($userinfo['level'"]) && $userinfo['level'] > 0 ? "revoke=$uid" class="vuadmin">"._REVOKEADMIN."</a>] [<a href=""admin.php?action=admins&amp;do=edit&amp;uid=$uid"" class="vuadmin">"._EDITADMIN : "do=new&amp;uid=$uid" class="vuadmin">"._MAKEADMIN)."</a>]</div>";
$tpl->assign("adminoptions", $adminopts);
}
$tpl->gotoBlock("_ROOT");
?>

 
Posted : 03/03/2011 9:04 pm
(@lyndsie)
Posts: 1263
Member Moderator
 

The mod was written for 3.2 so it's going to have a lot of issues. For version 3.3, a bunch of variables were changed to constants, ie $tableprefix to TABLEPREFIX. This topic has details: https://efiction.org/forums/index.php?topic=5247.0. So you'll want to comb through for those, at the very least. There have also been some database changes.


 
Posted : 03/03/2011 9:13 pm
(@somethingblue42)
Posts: 13
Active Member
Topic starter
 

Okay thanks!!!


 
Posted : 03/03/2011 9:46 pm
Share: