e107 bridge
e107 bridge

--- /dev/null
+++ b/bridges/e107/README.md
@@ -1,1 +1,37 @@
+This folder contains the default files for connecting to the default author
+table for eFiction.  
 
+They are included here as a backup in case you need 
+to restore from a failed bridge.
+
+This bridge can be used only for efiction installed as the subdirectory of e107 site
+
+1. add 
+`@ include_once(UN_FULLAPP_PATH."class2.php");`
+
+after 
+`@ include_once(_BASEDIR."config.php");`
+
+- you can't add this directly in config.php, because than ajax will stop to work
+
+`UN_FULLAPP_PATH` is constant defined in config.php - path to your e107 installation .  
+
+2.  replace files from this directory
+
+queries.php -  allows to use e107 user table as authors
+
+get_session_vars.php - allows to use e107 constants to detect if user is logged or not.  Thanks installation in subdirectory, all cookies/sessions are available for efiction site too.
+
+using class2.php allows use any e107 feature inside efiction script
+
+3. change paths in panels for login, signup and user info to e107 urls
+
+if your e107 use the same theme as efiction, user will not notice difference
+
+
+
+
+
+
+
+

--- /dev/null
+++ b/bridges/e107/get_session_vars.php
@@ -1,1 +1,62 @@
+<?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.
+//                                                                             user_id
+// To read the license please visit http://www.gnu.org/copyleft/gpl.html
+// ----------------------------------------------------------------------
 
+if(!defined("_CHARSET")) exit( );
+
+//replace with e107 stuff  */
+
+if (USERID) {
+    // is log in e107, so it's member
+    define("isMEMBER", true);
+    define("USERUID", USERID);
+    define("USERPENNAME", USERNAME);
+    // check if it's author, so they are in author table 
+    $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." = '".USERUID."'"));
+ 
+    if($userdata && $userdata['level'] != -1 ) {
+		define("USERUID", $userdata['uid']);
+		define("USERPENNAME", $userdata['penname']);
+		// the following line fixes missing authorpref rows
+		if(empty($userdata['userskin'] )) dbquery("INSERT INTO ".TABLEPREFIX."fanfiction_authorprefs(uid, userskin, storyindex, sortby, tinyMCE) VALUES('".$userdata['uid']."', '$defaultskin', '$displayindex', '$defaultsort', '$tinyMCE')");
+		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(!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;
+ 
+
+?>

--- /dev/null
+++ b/bridges/e107/queries.php
@@ -1,1 +1,23 @@
+<?php
 
+// Default query strings used throughout the script.  You may need to alter these to bridge to other scripts or databases.
+
+define ("_AUTHORPREFIX", defined("TABLEPREFIX") ? TABLEPREFIX : $tableprefix);
+
+define ("_UIDFIELD", "author.user_id");  // Do not change the aliasing (the "author." part)!
+define ("_PENNAMEFIELD", "author.user_name");  // Do not change the aliasing (the "author." part)!
+define ("_EMAILFIELD", "author.user_email");  // Do not change the aliasing (the "author." part)!
+define ("_PASSWORDFIELD", "author.user_password"); //  Do not change the aliasing (the "author." part)!
+define ("_AUTHORTABLE", _AUTHORPREFIX."user as author"); // Do not change the aliasing (the "as author" part)!
+
+define ("_STORYQUERY",  "SELECT stories.*, "._PENNAMEFIELD." as penname, UNIX_TIMESTAMP(stories.date) as date, UNIX_TIMESTAMP(stories.updated) as updated FROM ("._AUTHORTABLE.", ".TABLEPREFIX."fanfiction_stories as stories) WHERE "._UIDFIELD." = stories.uid AND stories.validated > 0 ");
+define ("_STORYCOUNT", "SELECT count(sid) FROM ".TABLEPREFIX."fanfiction_stories as stories WHERE validated > 0");
+define ("_SERIESQUERY", "SELECT series.*, "._PENNAMEFIELD." as penname FROM "._AUTHORTABLE.", ".TABLEPREFIX."fanfiction_series as series WHERE "._UIDFIELD." = series.uid ");
+define ("_SERIESCOUNT", "SELECT COUNT(seriesid) FROM ".TABLEPREFIX."fanfiction_series as series ");   
+define ("_MEMBERLIST", "SELECT "._PENNAMEFIELD." as penname, "._UIDFIELD." as uid, ap.stories FROM "._AUTHORTABLE." 
+LEFT JOIN ".TABLEPREFIX."fanfiction_authorprefs AS ap ON "._UIDFIELD." = ap.uid");
+define ("_MEMBERCOUNT", "SELECT COUNT("._UIDFIELD.") FROM "._AUTHORTABLE." LEFT JOIN ".TABLEPREFIX."fanfiction_authorprefs AS ap ON ap.uid = "._UIDFIELD);
+
+
+
+?>