Browse code

e107 bridge

Jimako authored on 2020/02/28 08:31:56
Showing 3 changed files
1 1
new file mode 100644
... ...
@@ -0,0 +1,36 @@
1
+This folder contains the default files for connecting to the default author
2
+table for eFiction.  
3
+
4
+They are included here as a backup in case you need 
5
+to restore from a failed bridge.
6
+
7
+This bridge can be used only for efiction installed as the subdirectory of e107 site
8
+
9
+1. add 
10
+`@ include_once(UN_FULLAPP_PATH."class2.php");`
11
+
12
+after 
13
+`@ include_once(_BASEDIR."config.php");`
14
+
15
+- you can't add this directly in config.php, because than ajax will stop to work
16
+
17
+`UN_FULLAPP_PATH` is constant defined in config.php - path to your e107 installation .  
18
+
19
+2.  replace files from this directory
20
+
21
+queries.php -  allows to use e107 user table as authors
22
+
23
+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.
24
+
25
+using class2.php allows use any e107 feature inside efiction script
26
+
27
+3. change paths in panels for login, signup and user info to e107 urls
28
+
29
+if your e107 use the same theme as efiction, user will not notice difference
30
+
31
+
32
+
33
+
34
+
35
+
36
+
0 37
new file mode 100644
... ...
@@ -0,0 +1,62 @@
1
+<?php
2
+// ----------------------------------------------------------------------
3
+// eFiction 3.2
4
+// Copyright (c) 2007 by Tammy Keefer
5
+// Valid HTML 4.01 Transitional
6
+// Based on eFiction 1.1
7
+// Copyright (C) 2003 by Rebecca Smallwood.
8
+// http://efiction.sourceforge.net/
9
+// ----------------------------------------------------------------------
10
+// LICENSE
11
+//
12
+// This program is free software; you can redistribute it and/or
13
+// modify it under the terms of the GNU General Public License (GPL)
14
+// as published by the Free Software Foundation; either version 2
15
+// of the License, or (at your option) any later version.
16
+//
17
+// This program is distributed in the hope that it will be useful,
18
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
19
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
20
+// GNU General Public License for more details.
21
+//                                                                             user_id
22
+// To read the license please visit http://www.gnu.org/copyleft/gpl.html
23
+// ----------------------------------------------------------------------
24
+
25
+if(!defined("_CHARSET")) exit( );
26
+
27
+//replace with e107 stuff  */
28
+
29
+if (USERID) {
30
+    // is log in e107, so it's member
31
+    define("isMEMBER", true);
32
+    define("USERUID", USERID);
33
+    define("USERPENNAME", USERNAME);
34
+    // check if it's author, so they are in author table 
35
+    $userdata = dbassoc(dbquery("SELECT ap.*, "._UIDFIELD." as uid, "._PENNAMEFIELD." as penname, "._EMAILFIELD." as email, "._PASSWORDFIELD." as password FROM "._AUTHORTABLE." 
36
+    LEFT JOIN ".TABLEPREFIX."fanfiction_authorprefs as ap ON ap.uid = "._UIDFIELD." WHERE "._UIDFIELD." = '".USERUID."'"));
37
+ 
38
+    if($userdata && $userdata['level'] != -1 ) {
39
+		define("USERUID", $userdata['uid']);
40
+		define("USERPENNAME", $userdata['penname']);
41
+		// the following line fixes missing authorpref rows
42
+		if(empty($userdata['userskin'] )) dbquery("INSERT INTO ".TABLEPREFIX."fanfiction_authorprefs(uid, userskin, storyindex, sortby, tinyMCE) VALUES('".$userdata['uid']."', '$defaultskin', '$displayindex', '$defaultsort', '$tinyMCE')");
43
+		if(!isset($_SESSION[$sitekey."_skin"]) && !empty($userdata['userskin'])) $siteskin = $userdata['userskin'];
44
+		else if(isset($_SESSION[$sitekey."_skin"])) $siteskin = $_SESSION[$sitekey."_skin"];
45
+		else $siteskin = $defaultskin;
46
+		define("uLEVEL", $userdata['level']);
47
+		define("isADMIN", uLEVEL > 0 ? true : false);
48
+		define("isMEMBER", true);
49
+		if(EMPTY($_SESSION[$sitekey."_agecontsent"])) $ageconsent = $userdata['ageconsent'];
50
+		else $ageconsent = $_SESSION[$sitekey."_agecontsent"];
51
+	} 
52
+}
53
+ 
54
+if(!defined("USERUID")) define("USERUID", 0);
55
+if(!defined("USERPENNAME")) define("USERPENNAME", false);
56
+if(!defined("uLEVEL")) define("uLEVEL", 0);
57
+if(!defined("isMEMBER")) define("isMEMBER", false);
58
+if(!defined("isADMIN")) define("isADMIN", false);
59
+if(empty($siteskin)) $siteskin = $defaultskin;
60
+ 
61
+
62
+?>
0 63
\ No newline at end of file
1 64
new file mode 100644
... ...
@@ -0,0 +1,23 @@
1
+<?php
2
+
3
+// Default query strings used throughout the script.  You may need to alter these to bridge to other scripts or databases.
4
+
5
+define ("_AUTHORPREFIX", defined("TABLEPREFIX") ? TABLEPREFIX : $tableprefix);
6
+
7
+define ("_UIDFIELD", "author.user_id");  // Do not change the aliasing (the "author." part)!
8
+define ("_PENNAMEFIELD", "author.user_name");  // Do not change the aliasing (the "author." part)!
9
+define ("_EMAILFIELD", "author.user_email");  // Do not change the aliasing (the "author." part)!
10
+define ("_PASSWORDFIELD", "author.user_password"); //  Do not change the aliasing (the "author." part)!
11
+define ("_AUTHORTABLE", _AUTHORPREFIX."user as author"); // Do not change the aliasing (the "as author" part)!
12
+
13
+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 ");
14
+define ("_STORYCOUNT", "SELECT count(sid) FROM ".TABLEPREFIX."fanfiction_stories as stories WHERE validated > 0");
15
+define ("_SERIESQUERY", "SELECT series.*, "._PENNAMEFIELD." as penname FROM "._AUTHORTABLE.", ".TABLEPREFIX."fanfiction_series as series WHERE "._UIDFIELD." = series.uid ");
16
+define ("_SERIESCOUNT", "SELECT COUNT(seriesid) FROM ".TABLEPREFIX."fanfiction_series as series ");   
17
+define ("_MEMBERLIST", "SELECT "._PENNAMEFIELD." as penname, "._UIDFIELD." as uid, ap.stories FROM "._AUTHORTABLE." 
18
+LEFT JOIN ".TABLEPREFIX."fanfiction_authorprefs AS ap ON "._UIDFIELD." = ap.uid");
19
+define ("_MEMBERCOUNT", "SELECT COUNT("._UIDFIELD.") FROM "._AUTHORTABLE." LEFT JOIN ".TABLEPREFIX."fanfiction_authorprefs AS ap ON ap.uid = "._UIDFIELD);
20
+
21
+
22
+
23
+?>
0 24
\ No newline at end of file