Browse code

Add eFic2eFic bridge and default file copies

Clarissa Walker authored on 2026/09/08 09:57:23
Showing 14 changed files
1 1
new file mode 100644
... ...
@@ -0,0 +1,3 @@
1
+This folder contains the default files for connecting to the default author
2
+table for eFiction.  They are included here as a backup in case you need 
3
+to restore from a failed bridge.
0 4
\ No newline at end of file
1 5
new file mode 100644
... ...
@@ -0,0 +1,224 @@
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
+//
22
+// To read the license please visit http://www.gnu.org/copyleft/gpl.html
23
+// ----------------------------------------------------------------------
24
+
25
+if(!defined("_CHARSET")) exit( );
26
+if(!function_exists("random_char")) {
27
+
28
+function random_char($string)
29
+{
30
+	$length = strlen($string);
31
+	$position = mt_rand(0, $length - 1);
32
+	$output = ($string[$position]);
33
+	return $output;
34
+}
35
+
36
+function random_string ($charset_string, $length)
37
+{
38
+	$return_string = random_char($charset_string);
39
+	for ($x = 1; $x < $length; $x++)
40
+	$return_string .= random_char($charset_string);
41
+	return $return_string;
42
+}
43
+
44
+}
45
+	$uid = isset($_REQUEST['uid']) ? $_REQUEST['uid'] : false;
46
+	if(!$uid) $uid = USERUID;
47
+
48
+	if((!isADMIN || uLEVEL > 2) && $uid != USERUID && $action == "editbio") $output .= write_error(_NOTAUTHORIZED);
49
+	if(isMEMBER) $output .= "<div id=\"pagetitle\">"._EDITPERSONAL."</div>";
50
+	else $output .= "<div id=\"pagetitle\">"._NEWACCOUNT."</div>";
51
+	if(!empty($_POST['submit'])) {
52
+		$penname = isset($_POST['newpenname']) ? escapestring($_POST['newpenname']) : false;
53
+		$email = escapestring($_POST[email]);
54
+		if(!isset($email) && !isADMIN) $output .= "<div style='text-align: center;'>"._EMAILREQUIRED."</div>";
55
+		else if($penname && !preg_match("!^[a-z0-9_ ]{3,30}$!i", $penname)) $output .= "<div style='text-align: center;'>"._BADUSERNAME."</div>";
56
+		else if(!eregi("^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,3})$", $email)) $output .= "<div style='text-align: center;'>"._INVALIDEMAIL." "._TRYAGAIN."</div>";
57
+		else if($action == "register") {
58
+			if(!$penname || empty($email) || !eregi("^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,3})$", $email) || !preg_match("/^[-0-9A-Z_-\s]+$/i", $penname)) $output .= write_error(_PENEMAILREQUIRED);
59
+			else if($pwdsetting && empty($_POST['password'])) $output .= write_error(_PWDREQUIRED."  "._TRYAGAIN);
60
+			else  {
61
+				$result = dbquery("SELECT "._PENNAMEFIELD." FROM "._AUTHORTABLE." WHERE "._PENNAMEFIELD." = '".escapestring($penname)."'");
62
+				$result2 = dbquery("SELECT "._EMAILFIELD." as email FROM "._AUTHORTABLE." WHERE "._EMAILFIELD." = ''");
63
+				if($captcha && !captcha_confirm()) $output .= write_error(_CAPTCHAFAIL);
64
+				else if(dbnumrows($result) > 0) $output .= write_error(_PENNAMEINUSE."  "._TRYAGAIN);
65
+				else if(dbnumrows($result2) > 0) $output .= write_error(_EMAILINUSE."  "._TRYAGAIN);
66
+				else if(preg_match("!^[a-z0-9_ ]{3,30}$!i", $penname)) {
67
+					if(!$pwdsetting) {
68
+						$charset = '23456789' . 'abcdefghijkmnpqrstuvwxyz' . 'ABCDEFGHJKLMNPQRSTUVWXYZ';
69
+						$pass = random_string($charset, 10);
70
+						$encryppass = md5($pass);
71
+					}
72
+					else {
73
+						if($_POST['password'] != $_POST['password2']) {
74
+							$output .=  write_error(_PASSWORDTWICE);
75
+							$tpl->assign("output", $output);
76
+							$tpl->printToScreen( );
77
+							dbclose( );
78
+							exit( );
79
+						}
80
+						$pass = $_POST['password2'];
81
+						$encryppass = md5($pass);
82
+					}
83
+					dbquery("INSERT INTO ".substr(_AUTHORTABLE, 0, strpos(_AUTHORTABLE, "as author"))." (penname, realname, bio, email, date, password) VALUES ('".escapestring($penname)."', '".escapestring(strip_tags($_POST['realname']))."', '".strip_tags(escapestring($_POST['bio']), $allowed_tags)."', '$email', now(), '$encryppass')");
84
+					$useruid = dbinsertid( );
85
+					if($logging) dbquery("INSERT INTO ".TABLEPREFIX."fanfiction_log (`log_action`, `log_uid`, `log_ip`, `log_type`) VALUES('".escapestring(sprintf(_LOG_REGISTER, $penname, USERUID, $_SERVER['REMOTE_ADDR']))."', '".$useruid."', INET_ATON('".$_SERVER['REMOTE_ADDR']."'), 'RG')");
86
+					if(empty($siteskin)) {
87
+						$skinquery = dbquery("SELECT skin FROM ".$settingsprefix."fanfiction_settings WHERE sitekey ='".SITEKEY."'");
88
+						list($skin) = dbrow($skinquery);
89
+					}
90
+					else $skin = $siteskin;
91
+					dbquery("INSERT INTO ".TABLEPREFIX."fanfiction_authorprefs(uid, userskin, storyindex, sortby, tinyMCE) VALUES('".USERUID."', '$skin', '$displayindex', '$defaultsort', '$tinyMCE')");
92
+/* The section adds fields from the authorfields table to the authorinfo table allowing dynamic additions to the bio/registration page */
93
+					$fields = dbquery("SELECT * FROM ".TABLEPREFIX."fanfiction_authorfields WHERE field_on = '1'");
94
+					while($field = dbassoc($fields)) {
95
+						$uid = isset($_POST['uid']) && isNumber($_POST['uid']) ? $_POST['uid'] : false;
96
+						if(!$uid) continue;
97
+						$oldfield = dbquery("SELECT * FROM ".TABLEPREFIX."fanfiction_authorinfo WHERE field='".$field['field_id']."' AND uid = '".$uid."'");
98
+						if(dbnumrows($oldfield) > 0) {
99
+							$newinfo = isset($_POST["af_".$field['field_name']]) ? escapestring($_POST["af_".$field['field_name']]) : false;
100
+							if(!empty($newinfo)) dbquery("UPDATE ".TABLEPREFIX."fanfiction_authorinfo SET info='$newinfo' WHERE uid = '$uid' AND field = '".$field['field_id']."'");
101
+							else dbquery("DELETE FROM ".TABLEPREFIX."fanfiction_authorinfo WHERE uid = '$uid' AND field = '".$field['field_id']."'");
102
+						}
103
+						else if(!empty($_POST["af_".$field['field_name']])) dbquery("INSERT INTO ".TABLEPREFIX."fanfiction_authorinfo(`uid`, `info`, `field`) VALUES('$uid', '".escapestring($_POST["af_".$field['field_name']])."', '".$field['field_id']."');");
104
+					}
105
+/* End dynamic fields */
106
+					$subject = _SIGNUPSUBJECT;
107
+					$mailtext = _SIGNUPMESSAGE._LOGIN.": $penname\n"._PASSWORD.": $pass \n\n";
108
+					if(!$pwdsetting) $mailtext .= _SIGNUPWARNING;
109
+					include("includes/emailer.php");
110
+					sendemail($penname, $email, $sitename, $siteemail, $subject, $mailtext, "html");
111
+					dbquery("UPDATE ".TABLEPREFIX."fanfiction_stats SET newestmember = '$penname', members = members + 1");
112
+					unset($_POST['submit']);
113
+					$output = write_message(_ACTIONSUCCESSFUL);
114
+					include("user/login.php");
115
+				}
116
+				else $output .= _BADUSERNAME;
117
+			}
118
+		}
119
+		else{
120
+			$oldinfo = dbassoc(dbquery("SELECT * FROM "._AUTHORTABLE." WHERE uid = '".USERUID."' LIMIT 1"));
121
+			// Update the password
122
+			if(($_POST['password']) || ($_POST['password2'])) {
123
+				if($_POST['password'] == $_POST['password2']) {
124
+					$encryppassword = md5($_POST['password']);
125
+					dbquery("UPDATE "._AUTHORTABLE." SET password='$encryppassword' WHERE uid = '$uid'");
126
+				}
127
+				else $output .=  write_error(_PASSWORDTWICE);
128
+			}
129
+			// Update the penname.
130
+			if(isset($_POST['oldpenname']) && $penname != $_POST['oldpenname']) {
131
+				$checkresult = dbquery("SELECT * FROM "._AUTHORTABLE." WHERE penname = '".escapestring($penname)."'");
132
+				if(dbnumrows($checkresult)) {
133
+					$output .= write_message(_PENNAMEINUSE."  "._TRYAGAIN);
134
+				}
135
+				else {
136
+					dbquery("UPDATE "._AUTHORTABLE." SET penname = '".escapestring($penname)."' WHERE uid = '$_POST[uid]'");
137
+					if($logging) dbquery("INSERT INTO ".TABLEPREFIX."fanfiction_log (`log_action`, `log_uid`, `log_ip`, `log_type`) VALUES('".escapestring(sprintf(_NEWPEN, USERPENNAME, USERUID, $_POST[oldpenname], $uid, $penname))."', '".USERUID."', INET_ATON('".$_SERVER['REMOTE_ADDR']."'), 'EB')");
138
+				}
139
+			}
140
+/* This section adds fields from the authorfields table to the authorinfo table allowing dynamic additions to the bio/registration page */
141
+			$fields = dbquery("SELECT * FROM ".TABLEPREFIX."fanfiction_authorfields WHERE field_on = '1'");
142
+			while($field = dbassoc($fields)) {
143
+				$uid = isset($_POST['uid']) && isNumber($_POST['uid']) ? $_POST['uid'] : false;
144
+				if(!$uid) continue;
145
+				$oldfield = dbquery("SELECT * FROM ".TABLEPREFIX."fanfiction_authorinfo WHERE field='".$field['field_id']."' AND uid = '".$uid."'");
146
+				if(dbnumrows($oldfield) > 0) {
147
+					$newinfo = isset($_POST["af_".$field['field_name']]) ? escapestring(descript($_POST["af_".$field['field_name']])) : false;
148
+					if(!empty($newinfo)) dbquery("UPDATE ".TABLEPREFIX."fanfiction_authorinfo SET info='".$newinfo."' WHERE uid = '$uid' AND field = '".descript($field['field_id'])."'");
149
+					else dbquery("DELETE FROM ".TABLEPREFIX."fanfiction_authorinfo WHERE uid = '$uid' AND field = '".$field['field_id']."'");
150
+				}
151
+				else if(!empty($_POST["af_".$field['field_name']])) dbquery("INSERT INTO ".TABLEPREFIX."fanfiction_authorinfo(`uid`, `info`, `field`) VALUES('$uid', '".escapestring($_POST["af_".$field['field_name']])."', '".$field['field_id']."');");
152
+			}
153
+/* End dynamic fields */
154
+			// Now we'll update the rest.
155
+			$result = dbquery("UPDATE "._AUTHORTABLE." SET realname='".descript(strip_tags(escapestring($_POST['realname'])), $allowed_tags)."', email='$email', bio='".descript(strip_tags(escapestring($_POST['bio']), $allowed_tags))."', image='".($imageupload && !empty($_POST['image']) ? escapestring($_POST['image']) : "")."' WHERE uid = '$uid'");
156
+			if($result) { // only if the info actually got updated.
157
+				if($oldinfo['email'] != $email) { // Need to reset the session and cookies in this case.
158
+					$_SESSION[SITEKEY."_salt"] = md5($email+$encryptedpassword);
159
+					if(isset($_COOKIE[SITEKEY."_salt"])) setcookie(SITEKEY."_salt", md5($email+$encryptedpassword),  time()+60*60*24*30, "/");		
160
+				}
161
+			}
162
+			$output .= write_message(_ACTIONSUCCESSFUL."  ".(isset($_GET['uid']) ? _BACK2ADMIN : _BACK2ACCT));
163
+		}
164
+	}
165
+	else {
166
+		if($action != "register") {
167
+			$result = dbquery("SELECT * FROM "._AUTHORTABLE." WHERE "._UIDFIELD." = '$uid' LIMIT 1");
168
+			$user = dbassoc($result);
169
+			$result2 = dbquery("SELECT * FROM ".TABLEPREFIX."fanfiction_authorinfo WHERE uid = '$uid'");
170
+			while($field = dbassoc($result2)) {
171
+				$user["af_".$field['field']] = $field['info'];
172
+			}
173
+		}
174
+		if($action == "register") {
175
+			$query = dbquery("SELECT message_text FROM ".TABLEPREFIX."fanfiction_messages WHERE message_name = 'tos'");
176
+			list($tos) = dbrow($query);
177
+			$output .= "<div class='tblborder' style='width: 90%; margin: 1em auto;'>$tos</div>";
178
+		}
179
+		$output .= "<div id='settingsform'><form method=\"POST\" enctype=\"multipart/form-data\" style='margin: 0 auto;' action=\"user.php?action=$action".($uid != USERUID ? "&uid=".$uid : "")."\">
180
+		<div><label for='newpenname'>"._PENNAME.":</label>";
181
+		if((isADMIN && uLEVEL == 1) || $action == "register")
182
+			$output .= "<INPUT name=\"newpenname\" type=\"text\" class=\"textbox\" maxlength=\"200\" value=\"".(isset($user) ? $user['penname'] : "")."\"><INPUT name=\"oldpenname\" type=\"hidden\" value=\"".(isset($user) ? $user['penname'] : "")."\"><font color=\"red\">*</font> ";
183
+		else if(isset($user)) $output .= " ".$user['penname'];
184
+		$output .= "</div>
185
+	 	<div><label for='realname'>"._REALNAME.": </label><INPUT type=\"text\" class=\"textbox=\" name=\"realname\" maxlength=\"200\" value=\"".(isset($user) ? $user['realname'] : "")."\"></div>
186
+	 	<div><label for='email'>"._EMAIL.":</label><INPUT  type=\"text\" class=\"textbox=\" name=\"email\" value=\"".(isset($user) ? $user['email'] : "")."\" maxlength=\"200\" size=\"35\"><font color=\"red\">*</font></div>
187
+	 	<div><label for='bio'>"._BIO.":</label></div>
188
+		<div style='width: 450px; margin: 0 auto;'><textarea class=\"textbox\" name=\"bio\" cols=\"50\" rows=\"6\">".(isset($user) ? stripslashes($user['bio']) : "")."</TEXTAREA></div>";
189
+/* The section adds fields to the form from the authorfields table to the authorinfo table allowing dynamic additions to the bio/registration page */
190
+		$authorfields = dbquery("SELECT * FROM ".TABLEPREFIX."fanfiction_authorfields WHERE field_on = '1'");
191
+		while($field = dbassoc($authorfields)) {
192
+			if($field['field_type'] == 1 || $field['field_type'] == 4 || $field['field_type'] == 6) 
193
+				$output .= "<div><label for='".$field['field_name']."'>".$field['field_title'].":</label>\n<input type='text' class='textbox' name='af_".$field['field_name']."'".(!empty($user["af_".$field['field_id']]) ? "value='".$user["af_".$field['field_id']]."'" : "").">\n</div>\n";
194
+			if($field['field_type'] == 2) {
195
+				$output .= "<div><label for='".$field['field_name']."'>".$field['field_title'].":</label>\n
196
+						<select class='textbox' name='af_".$field['field_name']."'>\n";
197
+				$opts = explode("|#|", $field['field_options']);
198
+				foreach($opts as $opt) {
199
+					$output .= "<option".(!empty($user["af_".$field['field_id']]) && $user["af_".$field['field_id']] == $opt ? " selected" : "").">$opt</option>\n";
200
+				}
201
+				$output .= "</select>\n</div>\n";
202
+			}
203
+			if($field['field_type'] == 5) eval(stripslashes($field['field_code_in']));
204
+			if($field['field_type'] == 3) {
205
+				$output .= "<div class='fieldset'><span class='label'>".$field['field_title'].":</span>\n";
206
+				$output .= "<input type='radio' name='af_".$field['field_name']."' id='af_".$field['field_name']._YES."' value='"._YES."'".(!empty($user["af_".$field['field_id']]) && $user["af_".$field['field_id']] == _YES ? "checked='checked'" : "")."> <label for='".$field['field_name']._YES."'>"._YES."</label>\n
207
+					<input type='radio' name='af_".$field['field_name']."' id='af_".$field['field_name']._NO."' value='"._NO."'".(!empty($user["af_".$field['field_id']]) && $user["af_".$field['field_id']] == _NO ? "checked='checked'" : "")."> <label for='".$field['field_name']._NO."'>"._NO."</label></div>\n";
208
+			}
209
+		}
210
+/* End dynamic fields */
211
+	 	if($imageupload == "1")
212
+	 		$output .= "<div><label for='image'>"._IMAGE.":</label> <INPUT  type=\"text\" class=\"textbox=\" name=\"image\" maxlength=\"200\" value=\"".(!empty($user['image']) ? $user['image'] : "")."\"></div>";
213
+		if($action != "register" || $pwdsetting)
214
+	 	$output .= "<div><label for='password'>"._PASSWORD.":</label>  <INPUT name=\"password\" class=\"textbox\" value=\"\" type=\"password\">".($action == "register" ? "<font color=\"red\">*</font>" : "")."</div>
215
+			<div><label for='password2'>"._PASSWORD2.":</label> <INPUT name=\"password2\" class=\"textbox=\" value=\"\" type=\"password\">".($action == "register" ? "<font color=\"red\">*</font>" : "")."</div>";
216
+		if(!empty($captcha) && $action == "register") $output .= "<div><label for='userdigit'>"._CAPTCHANOTE."</label><input MAXLENGTH=5 SIZE=5 name=\"userdigit\" type=\"text\" value=\"\"><div style='text-align: center;'><img width=120 height=40 src=\""._BASEDIR."includes/button.php\" style=\"border: 1px solid #111;\"></div></div>";
217
+	 	$output .= "<div style='text-align: center; margin: 1em;'><INPUT type=\"hidden\" name=\"uid\" value=\"".(isset($user) ? $user['uid'] : "")."\"><INPUT type=\"submit\" class=\"button\" name=\"submit\" value=\""._SUBMIT."\">";
218
+	 	if(!isADMIN)
219
+	 	{
220
+			 	$output .= " [<a href=\"admin.php?action=deleteuser&amp;uid=$uid\">"._DELETE."</a>]";
221
+	 	}
222
+	 	$output .= "</div></form></div>".write_message("<font color=\"red\">*</font> "._REQUIREDFIELDS);
223
+	}
224
+?>
0 225
\ No newline at end of file
1 226
new file mode 100644
... ...
@@ -0,0 +1,65 @@
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
+//
22
+// To read the license please visit http://www.gnu.org/copyleft/gpl.html
23
+// ----------------------------------------------------------------------
24
+
25
+if(!defined("_CHARSET")) exit( );
26
+// Get session variables from cookie data if not logged in.
27
+// 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.
28
+if (!empty($_COOKIE[$sitekey."_useruid"])) {
29
+	$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"]."'"));
30
+	if($userdata && $userdata['level'] != -1 && $_COOKIE[$sitekey.'_salt'] == md5($userdata['email']+$userdata['password'])) {
31
+		define("USERUID", $userdata['uid']);
32
+		define("USERPENNAME", $userdata['penname']);
33
+		if(!isset($_SESSION[$sitekey."_skin"]) && !empty($userdata['userskin'])) $siteskin = $userdata['userskin'];
34
+		else if(isset($_SESSION[$sitekey."_skin"])) $siteskin = $_SESSION[$sitekey."_skin"];
35
+		else $siteskin = $defaultskin;
36
+		define("uLEVEL", $userdata['level']);
37
+		define("isADMIN", uLEVEL > 0 ? true : false);
38
+		define("isMEMBER", true);
39
+		if(!isset($_SESSION[$sitekey."_agecontsent"])) $ageconsent = $userdata['ageconsent'];
40
+		else $ageconsent = $_SESSION[$sitekey."_agecontsent"];
41
+	}
42
+}
43
+if(!empty($_SESSION[$sitekey."_useruid"]) && !defined("USERUID")) {
44
+	$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"]."'"));
45
+	if($userdata && $userdata['level'] != -1 && $_SESSION[$sitekey.'_salt'] == md5($userdata['email']+$userdata['password'])) {
46
+		define("USERUID", $userdata['uid']);
47
+		define("USERPENNAME", $userdata['penname']);
48
+		if(!isset($_SESSION[$sitekey."_skin"]) && !empty($userdata['userskin'])) $siteskin = $userdata['userskin'];
49
+		else if(isset($_SESSION[$sitekey."_skin"])) $siteskin = $_SESSION[$sitekey."_skin"];
50
+		else $siteskin = $defaultskin;
51
+		define("uLEVEL", $userdata['level']);
52
+		define("isADMIN", uLEVEL > 0 ? true : false);
53
+		define("isMEMBER", true);
54
+		if(!isset($_SESSION[$sitekey."_agecontsent"])) $ageconsent = $userdata['ageconsent'];
55
+		else $ageconsent = $_SESSION[$sitekey."_agecontsent"];
56
+	}
57
+}
58
+if(!defined("USERUID")) define("USERUID", false);
59
+if(!defined("USERPENNAME")) define("USERPENNAME", false);
60
+if(!defined("uLEVEL")) define("uLEVEL", 0);
61
+if(!defined("isMEMBER")) define("isMEMBER", false);
62
+if(!defined("isADMIN")) define("isADMIN", false);
63
+if(empty($siteskin)) $siteskin = $defaultskin;
64
+
65
+?>
0 66
\ No newline at end of file
1 67
new file mode 100644
2 68
new file mode 100644
... ...
@@ -0,0 +1,87 @@
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
+//
22
+// To read the license please visit http://www.gnu.org/copyleft/gpl.html
23
+// ----------------------------------------------------------------------
24
+
25
+if(!defined("_LOGINCHECK")) exit( );
26
+	if(isset($_POST['submit']) && preg_match("!^[a-z0-9_ ]{3,30}$!i", $_POST['penname'])) {
27
+		define("_BASEDIR", "");
28
+		include_once("config.php");
29
+		$settings = dbquery("SELECT tableprefix, maintenance, sitekey, debug FROM ".$settingsprefix."fanfiction_settings WHERE sitekey = '".$sitekey."'");
30
+		list($tableprefix, $maintenance, $sitekey, $debug) = dbrow($settings);
31
+		include_once("includes/queries.php");
32
+		$result = dbquery("SELECT *, "._UIDFIELD." as uid FROM "._AUTHORTABLE." LEFT JOIN ".$tableprefix."fanfiction_authorprefs AS ap ON ap.uid = "._UIDFIELD." WHERE "._PENNAMEFIELD." = '".$_POST['penname']."'");
33
+		$passwd = dbassoc($result);
34
+		if($maintenance && $passwd['level'] < 0) {
35
+			header("Location: maintenance.php");
36
+			exit( );
37
+		}
38
+		$encryptedpassword = md5($_POST['password']);
39
+		if($passwd['level'] == -1) {
40
+			require_once("header.php");
41
+			//make a new TemplatePower object
42
+			if(file_exists("$skindir/default.tpl")) $tpl = new TemplatePower( "$skindir/default.tpl" );
43
+			else $tpl = new TemplatePower("default_tpls/default.tpl");
44
+			include_once("includes/corefunctions.php");
45
+			accessDenied( );
46
+		}
47
+		if(isset($_POST['cookiecheck'])) {
48
+			setcookie($sitekey."_useruid",$passwd['uid'], time()+60*60*24*30, "/");
49
+			setcookie($sitekey."_salt", md5($passwd['email']+$encryptedpassword),  time()+60*60*24*30, "/");
50
+		}
51
+		if($passwd['password'] == $encryptedpassword) {
52
+			if(!isset($_SESSION)) session_start( );
53
+			$_SESSION[$sitekey."_useruid"] = $passwd['uid'];
54
+			$_SESSION[$sitekey."_salt"] = md5($passwd['email']+$encryptedpassword);
55
+		}
56
+
57
+		else { 
58
+			require_once("header.php");
59
+			//make a new TemplatePower object
60
+			if(file_exists("$skindir/default.tpl")) $tpl = new TemplatePower( "$skindir/default.tpl" );
61
+			else $tpl = new TemplatePower("default_tpls/default.tpl");
62
+			include_once("includes/pagesetup.php");
63
+			$output .= "<div id=\"pagetitle\">"._MEMBERLOGIN."</div>";
64
+			$output .= "<div style='text-align: center;'>"._WRONGPASSWORD."</div>";
65
+			$tpl->assign("output", $output);
66
+			$tpl->printToScreen( );
67
+			dbclose( );
68
+			exit( );
69
+		}
70
+	}
71
+	else if(!isMEMBER) {
72
+		$output .= "<div id=\"pagetitle\">"._MEMBERLOGIN."</div>";
73
+		$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'] : "")."\">
74
+		<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 />
75
+		<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 />
76
+		<INPUT type=\"checkbox\" class=\"checkbox\" name=\"cookiecheck\" id=\"cookiecheck\" value=\"1\"><label for=\"cookiecheck\">"._REMEMBERME."</label><br />
77
+		<INPUT type=\"submit\" class=\"button\" name=\"submit\" value=\""._SUBMIT."\">
78
+		</form></div>";
79
+		$linkquery = dbquery("SELECT * from ".TABLEPREFIX."fanfiction_pagelinks WHERE link_name = 'login' OR link_name = 'lostpassword'");
80
+		while($link = dbassoc($linkquery)) {
81
+			if($link['link_access'] && !isMEMBER) continue;
82
+			if($link['link_access'] == 2 && !isADMIN) continue;
83
+			$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>");
84
+		}
85
+		$output .= "<div style='text-align: center;'>".$pagelinks['register']['link']." | ".$pagelinks['lostpassword']['link']."</div>";
86
+	}
87
+?>
0 88
\ No newline at end of file
1 89
new file mode 100644
... ...
@@ -0,0 +1,33 @@
1
+<?php
2
+if(!defined("_LOGOUTCHECK")) exit( );
3
+	define("_BASEDIR", "");
4
+	include("config.php");
5
+	include("includes/queries.php");
6
+	session_start( );
7
+	foreach ($_SESSION as $VarName => $Value)  { 
8
+		if(substr($VarName, 0, strlen($sitekey)) == $sitekey) {
9
+			if(strpos($VarName, "skin")) continue;
10
+			$_SESSION[$VarName] = "";
11
+			unset($_SESSION[$VarName]);
12
+			unset($_COOKIE[$VarName]);
13
+			setcookie($VarName, '', time() - 1000, '/', '', '' );
14
+		}
15
+	} 
16
+	foreach ($_COOKIE as $VarName => $Value)  { 
17
+		if(substr($VarName, 0, strlen($sitekey)) == $sitekey) {
18
+			unset($_COOKIE[$VarName]);
19
+			setcookie($VarName, "", time() - 1000, '/', '', '' );
20
+		}
21
+	} 
22
+require_once("header.php");
23
+//make a new TemplatePower object
24
+if(file_exists("$skindir/default.tpl")) $tpl = new TemplatePower( "$skindir/default.tpl" );
25
+else $tpl = new TemplatePower("default_tpls/default.tpl");
26
+if(file_exists("$skindir/listings.tpl")) $tpl->assignInclude( "listings", "./$skindir/listings.tpl" );
27
+else $tpl->assignInclude( "listings", "./default_tpls/listings.tpl" );
28
+include("includes/pagesetup.php");
29
+
30
+$output .= write_message(_ACTIONSUCCESSFUL);
31
+$tpl->assign("output", $output);
32
+$tpl->printToScreen( );
33
+?>
0 34
\ No newline at end of file
1 35
new file mode 100644
... ...
@@ -0,0 +1,80 @@
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
+//
22
+// To read the license please visit http://www.gnu.org/copyleft/gpl.html
23
+// ----------------------------------------------------------------------
24
+
25
+if(!defined("_CHARSET")) exit( );
26
+if(!function_exists("random_char")) {
27
+
28
+function random_char($string)
29
+{
30
+	$length = strlen($string);
31
+	$position = mt_rand(0, $length - 1);
32
+	return ($string[$position]);
33
+}
34
+
35
+function random_string ($charset_string, $length)
36
+{
37
+	$return_string = random_char($charset_string);
38
+	for ($x = 1; $x < $length; $x++)
39
+	$return_string .= random_char($charset_string);
40
+	return $return_string;
41
+}
42
+
43
+}
44
+if($loggedin) accessDenied( );
45
+	$output = "<div id=\"pagetitle\">"._LOSTPASSWORD."</div>";
46
+
47
+	  if(isset($_POST['submit'])) {
48
+		  $result = dbquery("SELECT "._UIDFIELD." as uid, "._PENNAMEFIELD." as penname FROM "._AUTHORTABLE." WHERE email = '$_POST[email]'");
49
+		  list($uid, $penname) = dbrow($result);
50
+		  if(dbnumrows($result) == 0) $output .= write_message(_BADEMAIL);
51
+		  else {
52
+			include("includes/emailer.php");
53
+			mt_srand((double)microtime() * 1000000);
54
+			$charset = '23456789' . 'abcdefghijkmnpqrstuvwxyz' . 'ABCDEFGHJKLMNPQRSTUVWXYZ';		
55
+			$pass = random_string($charset, 10);
56
+			$encryppass = md5($pass);
57
+			$subject = _NEWPWDSUB;
58
+			$mailtext = sprintf(_NEWPWDMSG, $pass);
59
+
60
+		
61
+			$result = sendemail($penname, $_POST['email'], $sitename, $siteemail, $subject, $mailtext, "html");
62
+			if($result) {
63
+				$output .= write_message(_PASSWORDSENT);
64
+				dbquery("UPDATE "._AUTHORTABLE." SET password='$encryppass' WHERE uid = '".$uid."'");
65
+			}
66
+			else $output .=  write_message(_EMAILFAILED);
67
+			if($logging) 
68
+				dbquery("INSERT INTO ".TABLEPREFIX."fanfiction_log (`log_action`, `log_uid`, `log_ip`, `log_type`) VALUES('".escapestring(sprintf(_LOG_LOST_PASSWORD, $penname, $uid, ($result ? _YES : _NO)))."', '$uid', INET_ATON('".$_SERVER['REMOTE_ADDR']."'), 'LP')");
69
+
70
+		}
71
+	}
72
+	else {
73
+		$output .= "<form method=\"POST\" enctype=\"multipart/form-data\" action=\"user.php?action=lostpassword\">
74
+		<table align=\"center\" width=\"300\">
75
+		<tr><td>"._ENTEREMAIL."</td></tr>
76
+		<tr><td><INPUT  type=\"text\" class=\"textbox=\" name=\"email\"> <INPUT type=\"submit\" class=\"button\" name=\"submit\" value=\""._SUBMIT."\"></form>
77
+		</td></tr></table>";
78
+	}
79
+
80
+?>
0 81
\ No newline at end of file
1 82
new file mode 100644
... ...
@@ -0,0 +1,86 @@
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
+//
22
+// To read the license please visit http://www.gnu.org/copyleft/gpl.html
23
+// ----------------------------------------------------------------------
24
+
25
+if(!defined("_CHARSET")) exit( );
26
+
27
+// Build the user's profile information
28
+$tpl->newBlock("profile");
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");
30
+$userinfo = dbassoc($result2);
31
+$nameinfo = "";
32
+if($userinfo['email'])
33
+	$nameinfo .= " [<a href=\"viewuser.php?action=contact&amp;uid=".$userinfo['uid']."\">"._CONTACT."</a>]";
34
+if(!empty($favorites) && $loggedin && $userinfo['uid'] != USERUID) {
35
+	$fav = dbquery("SELECT * FROM ".TABLEPREFIX."fanfiction_favorites WHERE uid = '".USERUID."' AND type = 'AU' AND item = '".$userinfo['uid']."'");
36
+	if(dbnumrows($fav) == 0) $nameinfo .= " [<a href=\"user.php?uid=USERUID&amp;action=favau&amp;author=".$userinfo['uid']."\">"._ADDAUTHOR2FAVES."</a>]";
37
+}
38
+$tpl->assign("userpenname", $userinfo['penname']." ".$nameinfo);
39
+$tpl->assign("membersince", date("$dateformat", $userinfo['date']));
40
+if($userinfo['realname'])
41
+	$tpl->assign("realname", $userinfo['realname']);
42
+if($userinfo['bio']) {
43
+	$bio = nl2br($userinfo['bio']);	
44
+	$tpl->assign("bio", stripslashes($bio));
45
+}
46
+if($userinfo['image'])
47
+	$tpl->assign("image", "<img src=\"".$userinfo['image']."\">");
48
+$tpl->assign("userlevel", isset($userinfo['level']) && $userinfo['level'] > 0 && $userinfo['level'] < 4 ? _ADMINISTRATOR.(isADMIN ? " - ".$userinfo['level'] : "") : _MEMBER);
49
+/* Dynamic authorinfo fields */
50
+$result2 = dbquery("SELECT * FROM ".TABLEPREFIX."fanfiction_authorinfo WHERE uid = '$uid'");
51
+$dynamicfields = "";
52
+while($field = dbassoc($result2)) {
53
+	if($field['info'] == "") continue;
54
+	$fieldinfo = dbassoc(dbquery("SELECT * FROM ".TABLEPREFIX."fanfiction_authorfields WHERE field_id = '".$field['field']."' LIMIT 1"));
55
+	if($fieldinfo) {
56
+		$thisfield = "";
57
+		if($fieldinfo['field_on'] == 0) continue;
58
+		if($fieldinfo['field_type'] == 1) { $thisfield = format_link($field['info']);
59
+		}
60
+		if($fieldinfo['field_type'] == 4) {
61
+			$thisfield = preg_replace("@\{info\}@", $field['info'], $fieldinfo['field_options']);
62
+			$thisfield = format_link($thisfield);
63
+		}
64
+		if($fieldinfo['field_type'] == 2 || $fieldinfo['field_type'] == 6) {
65
+			$thisfield = stripslashes($field['info']);
66
+		}
67
+		if($fieldinfo['field_type'] == 3) {
68
+			$thisfield = $field['info'];
69
+		}
70
+		else eval($fieldinfo['field_code_out']);
71
+		$tpl->assign($fieldinfo['field_name'], $thisfield);
72
+		$dynamicfields .= "<div class='authorfields'><span class='label'>".$fieldinfo['field_title'].":</span> ".$thisfield."</div>";
73
+	}
74
+}
75
+if(!empty($dynamicfields)) $tpl->assign("authorfields", $dynamicfields);
76
+$tpl->assign("reportthis", "[<a href=\""._BASEDIR."contact.php?action=report&amp;url=viewuser.php?uid=".$uid."\">"._REPORTTHIS."</a>]");
77
+/* End dynamic fields */
78
+$adminopts = "";
79
+if(isADMIN && uLEVEL < 3) {
80
+	$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>]";
81
+	$adminopts .= " [<a href=\"admin.php?action=members&amp;".($userinfo['level'] < 0 ? "unlock=".$userinfo['uid']."\" class=\"vuadmin\">"._UNLOCKMEM : "lock=".$userinfo['uid']."\" class=\"vuadmin\">"._LOCKMEM)."</a>]";
82
+	$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>";
83
+	$tpl->assign("adminoptions", $adminopts);
84
+}
85
+$tpl->gotoBlock("_ROOT");
86
+?>
0 87
\ No newline at end of file
1 88
new file mode 100644
... ...
@@ -0,0 +1,17 @@
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 ("_UIDFIELD", "author.uid");  // Do not change the aliasing (the "author." part)!
6
+define ("_PENNAMEFIELD", "author.penname");  // Do not change the aliasing (the "author." part)!
7
+define ("_EMAILFIELD", "author.email");  // Do not change the aliasing (the "author." part)!
8
+define ("_PASSWORDFIELD", "author.password"); //  Do not change the aliasing (the "author." part)!
9
+define ("_AUTHORTABLE", $tableprefix."fanfiction_authors as author"); // Do not change the aliasing (the "as author" part)!
10
+
11
+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 ");
12
+define ("_STORYCOUNT", "SELECT count(sid) FROM ".$tableprefix."fanfiction_stories as stories WHERE validated > 0");
13
+define ("_SERIESQUERY", "SELECT series.*, "._PENNAMEFIELD." as penname FROM "._AUTHORTABLE.", ".$tableprefix."fanfiction_series as series WHERE "._UIDFIELD." = series.uid ");
14
+define ("_SERIESCOUNT", "SELECT COUNT(seriesid) FROM ".$tableprefix."fanfiction_series as series ");
15
+define ("_MEMBERLIST", "SELECT count( stories.sid ) as stories, "._PENNAMEFIELD." as penname, "._UIDFIELD." as uid FROM "._AUTHORTABLE." LEFT JOIN ".$tableprefix."fanfiction_authorprefs AS ap ON "._UIDFIELD." = ap.uid LEFT JOIN ".$tableprefix."fanfiction_stories AS stories ON stories.validated > 0 AND (FIND_IN_SET("._UIDFIELD.", stories.coauthors) > 0 OR stories.uid = "._UIDFIELD.") ");
16
+define ("_MEMBERCOUNT", "SELECT COUNT(DISTINCT "._UIDFIELD.") FROM "._AUTHORTABLE." LEFT JOIN ".$tableprefix."fanfiction_stories as stories ON stories.validated > 0 AND (FIND_IN_SET("._UIDFIELD.", stories.coauthors) > 0 OR stories.uid = "._UIDFIELD.")  LEFT JOIN ".$tableprefix."fanfiction_authorprefs as ap ON "._UIDFIELD." = ap.uid");
17
+?>
0 18
\ No newline at end of file
1 19
new file mode 100644
... ...
@@ -0,0 +1,28 @@
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
+//
22
+// To read the license please visit http://www.gnu.org/copyleft/gpl.html
23
+// ----------------------------------------------------------------------
24
+
25
+if(!defined("_CHARSET")) exit( );
26
+
27
+include("user/editbio.php");
28
+?>
0 29
\ No newline at end of file
1 30
new file mode 100644
... ...
@@ -0,0 +1,3 @@
1
+This folder contains the default files for connecting to the default author
2
+table for eFiction.  They are included here as a backup in case you need 
3
+to restore from a failed bridge.
0 4
\ No newline at end of file
1 5
new file mode 100644
... ...
@@ -0,0 +1,216 @@
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
+//
22
+// To read the license please visit http://www.gnu.org/copyleft/gpl.html
23
+// ----------------------------------------------------------------------
24
+
25
+if(!defined("_CHARSET")) exit( );
26
+if(!function_exists("random_char")) {
27
+
28
+function random_char($string)
29
+{
30
+	$length = strlen($string);
31
+	$position = mt_rand(0, $length - 1);
32
+	$output = ($string[$position]);
33
+	return $output;
34
+}
35
+
36
+function random_string ($charset_string, $length)
37
+{
38
+	$return_string = random_char($charset_string);
39
+	for ($x = 1; $x < $length; $x++)
40
+	$return_string .= random_char($charset_string);
41
+	return $return_string;
42
+}
43
+
44
+}
45
+	$uid = isset($_REQUEST['uid']) ? $_REQUEST['uid'] : false;
46
+	if(!$uid) $uid = USERUID;
47
+
48
+	if((!isADMIN || uLEVEL > 2) && $uid != USERUID && $action == "editbio") $output .= write_error(_NOTAUTHORIZED);
49
+	if(isMEMBER) $output .= "<div id=\"pagetitle\">"._EDITPERSONAL."</div>";
50
+	else $output .= "<div id=\"pagetitle\">"._NEWACCOUNT."</div>";
51
+	if(!empty($_POST['submit'])) {
52
+		$penname = isset($_POST['newpenname']) ? escapestring($_POST['newpenname']) : false;
53
+		$email = escapestring($_POST['email']);
54
+		if(!isset($email) && !isADMIN) $output .= "<div style='text-align: center;'>"._EMAILREQUIRED."</div>";
55
+		else if($penname && !preg_match("!^[a-z0-9-_ ]{3,30}$!i", $penname)) $output .= "<div style='text-align: center;'>"._BADUSERNAME."</div>";
56
+		else if(!eregi("^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,3})$", $email)) $output .= "<div style='text-align: center;'>"._INVALIDEMAIL." "._TRYAGAIN."</div>";
57
+		else if($action == "register") {
58
+			if(!$penname || empty($email) || !eregi("^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,3})$", $email) || !preg_match("!^[a-z0-9-_ ]{3,30}$!i", $penname)) $output .= write_error(_PENEMAILREQUIRED);
59
+			else if($pwdsetting && empty($_POST['password'])) $output .= write_error(_PWDREQUIRED."  "._TRYAGAIN);
60
+			else  {
61
+				$result = dbquery("SELECT "._PENNAMEFIELD." FROM "._AUTHORTABLE." WHERE "._PENNAMEFIELD." = '".escapestring($penname)."'");
62
+				$result2 = dbquery("SELECT "._EMAILFIELD." as email FROM "._AUTHORTABLE." WHERE "._EMAILFIELD." = '$email'");
63
+				if($captcha && !captcha_confirm()) $output .= write_error(_CAPTCHAFAIL);
64
+				else if(dbnumrows($result) > 0) $output .= write_error(_PENNAMEINUSE."  "._TRYAGAIN);
65
+				else if(dbnumrows($result2) > 0) $output .= write_error(_EMAILINUSE."  "._TRYAGAIN);
66
+				else if(preg_match("!^[a-z0-9-_ ]{3,30}$!i", $penname)) {
67
+					if(!$pwdsetting) {
68
+						$charset = '23456789' . 'abcdefghijkmnpqrstuvwxyz' . 'ABCDEFGHJKLMNPQRSTUVWXYZ';
69
+						$pass = random_string($charset, 10);
70
+						$encryppass = md5($pass);
71
+					}
72
+					else {
73
+						if($_POST['password'] != $_POST['password2']) {
74
+							$output .=  write_error(_PASSWORDTWICE);
75
+							$tpl->assign("output", $output);
76
+							$tpl->printToScreen( );
77
+							dbclose( );
78
+							exit( );
79
+						}
80
+						$pass = $_POST['password2'];
81
+						$encryppass = md5($pass);
82
+					}
83
+					dbquery("INSERT INTO ".substr(_AUTHORTABLE, 0, strpos(_AUTHORTABLE, "as author"))." (penname, realname, bio, email, date, password) VALUES ('".escapestring($penname)."', '".escapestring(strip_tags($_POST['realname']))."', '".strip_tags(escapestring($_POST['bio']), $allowed_tags)."', '$email', now(), '$encryppass')");
84
+					$useruid = dbinsertid();
85
+					if($logging) dbquery("INSERT INTO ".TABLEPREFIX."fanfiction_log (`log_action`, `log_uid`, `log_ip`, `log_type`) VALUES('".escapestring(sprintf(_LOG_REGISTER, $penname, $useruid, $_SERVER['REMOTE_ADDR']))."', '".$useruid."', INET_ATON('".$_SERVER['REMOTE_ADDR']."'), 'RG')");
86
+					if(empty($siteskin)) {
87
+						$skinquery = dbquery("SELECT skin FROM ".$settingsprefix."fanfiction_settings WHERE sitekey = '".SITEKEY."'");
88
+						list($skin) = dbrow($skinquery);
89
+					}
90
+					else $skin = $siteskin;
91
+					dbquery("INSERT INTO ".TABLEPREFIX."fanfiction_authorprefs(uid, userskin, storyindex, sortby, tinyMCE) VALUES('".$useruid."', '$skin', '$displayindex', '$defaultsort', '$tinyMCE')");
92
+/* The section adds fields from the authorfields table to the authorinfo table allowing dynamic additions to the bio/registration page */
93
+					$fields = dbquery("SELECT * FROM ".TABLEPREFIX."fanfiction_authorfields WHERE field_on = '1'");
94
+					while($field = dbassoc($fields)) {
95
+						$uid = isset($_POST['uid']) && isNumber($_POST['uid']) ? $_POST['uid'] : false;
96
+						if(!$uid) continue;
97
+						$oldfield = dbquery("SELECT * FROM ".TABLEPREFIX."fanfiction_authorinfo WHERE field='".$field['field_id']."' AND uid = '".$uid."'");
98
+						if(dbnumrows($oldfield) > 0) {
99
+							$newinfo = isset($_POST["af_".$field['field_name']]) ? escapestring($_POST["af_".$field['field_name']]) : false;
100
+							if(!empty($newinfo)) dbquery("UPDATE ".TABLEPREFIX."fanfiction_authorinfo SET info='$newinfo' WHERE uid = '$uid' AND field = '".$field['field_id']."'");
101
+							else dbquery("DELETE FROM ".TABLEPREFIX."fanfiction_authorinfo WHERE uid = '$uid' AND field = '".$field['field_id']."'");
102
+						}
103
+						else if(!empty($_POST["af_".$field['field_name']])) dbquery("INSERT INTO ".TABLEPREFIX."fanfiction_authorinfo(`uid`, `info`, `field`) VALUES('$uid', '".escapestring($_POST["af_".$field['field_name']])."', '".$field['field_id']."');");
104
+					}
105
+/* End dynamic fields */
106
+					$subject = _SIGNUPSUBJECT;
107
+					$mailtext = _SIGNUPMESSAGE._LOGIN.": $penname\n"._PASSWORD.": $pass \n\n";
108
+					if(!$pwdsetting) $mailtext .= _SIGNUPWARNING;
109
+					include("includes/emailer.php");
110
+					sendemail($penname, $email, $sitename, $siteemail, $subject, $mailtext, "html");
111
+					dbquery("UPDATE ".TABLEPREFIX."fanfiction_stats SET newestmember = '".$useruid."', members = members + 1");
112
+					if(defined("AUTHORPREFIX")) dbquery("UPDATE ".AUTHORPREFIX."fanfiction_stats SET newestmember = '".$useruid."', members = members + 1");
113
+					unset($_POST['submit']);
114
+					$output = write_message(_ACTIONSUCCESSFUL);
115
+					define("_LOGINCHECK", true);
116
+					include("user/login.php");
117
+				}
118
+				else $output .= _BADUSERNAME;
119
+			}
120
+		}
121
+		else{
122
+			 if(($_POST['password']) && ($_POST['password2'])) {
123
+				if($_POST['password'] == $_POST['password2']) {
124
+					$encryppassword = md5($_POST['password']);
125
+					dbquery("UPDATE "._AUTHORTABLE." SET password='$encryppassword' WHERE uid = '$uid'");
126
+				}
127
+				else $output .=  write_error(_PASSWORDTWICE);
128
+			}
129
+			if(isset($_POST['oldpenname']) && $penname != $_POST['oldpenname']) {
130
+				$checkresult = dbquery("SELECT * FROM "._AUTHORTABLE." WHERE penname = '".escapestring($penname)."'");
131
+				if(dbnumrows($checkresult)) {
132
+					$output .= write_message(_PENNAMEINUSE."  "._TRYAGAIN);
133
+				}
134
+				else {
135
+					dbquery("UPDATE "._AUTHORTABLE." SET penname = '".escapestring($penname)."' WHERE uid = '$_POST[uid]'");
136
+					if($logging) dbquery("INSERT INTO ".TABLEPREFIX."fanfiction_log (`log_action`, `log_uid`, `log_ip`, `log_type`) VALUES('".escapestring(sprintf(_NEWPEN, USERPENNAME, USERUID, $_POST[oldpenname], $uid, $penname))."', '".USERUID."', INET_ATON('".$_SERVER['REMOTE_ADDR']."'), 'EB')");
137
+				}
138
+			}
139
+/* The section adds fields from the authorfields table to the authorinfo table allowing dynamic additions to the bio/registration page */
140
+			$fields = dbquery("SELECT * FROM ".TABLEPREFIX."fanfiction_authorfields WHERE field_on = '1'");
141
+			while($field = dbassoc($fields)) {
142
+				$uid = isset($_POST['uid']) && isNumber($_POST['uid']) ? $_POST['uid'] : false;
143
+				if(!$uid) continue;
144
+				$oldfield = dbquery("SELECT * FROM ".TABLEPREFIX."fanfiction_authorinfo WHERE field='".$field['field_id']."' AND uid = '".$uid."'");
145
+				if(dbnumrows($oldfield) > 0) {
146
+					$newinfo = isset($_POST["af_".$field['field_name']]) ? escapestring(descript($_POST["af_".$field['field_name']])) : false;
147
+					if(!empty($newinfo)) dbquery("UPDATE ".TABLEPREFIX."fanfiction_authorinfo SET info='".$newinfo."' WHERE uid = '$uid' AND field = '".descript($field['field_id'])."'");
148
+					else dbquery("DELETE FROM ".TABLEPREFIX."fanfiction_authorinfo WHERE uid = '$uid' AND field = '".$field['field_id']."'");
149
+				}
150
+				else if(!empty($_POST["af_".$field['field_name']])) dbquery("INSERT INTO ".TABLEPREFIX."fanfiction_authorinfo(`uid`, `info`, `field`) VALUES('$uid', '".escapestring($_POST["af_".$field['field_name']])."', '".$field['field_id']."');");
151
+			}
152
+/* End dynamic fields */
153
+			dbquery("UPDATE "._AUTHORTABLE." SET realname='".descript(strip_tags(escapestring($_POST['realname'])), $allowed_tags)."', email='$email', bio='".descript(strip_tags(escapestring($_POST['bio']), $allowed_tags))."', image='".($imageupload && !empty($_POST['image']) ? escapestring($_POST['image']) : "")."' WHERE uid = '$uid'");
154
+			$output .= write_message(_ACTIONSUCCESSFUL."  ".(isset($_GET['uid']) ? _BACK2ADMIN : _BACK2ACCT));
155
+		}
156
+	}
157
+	else {
158
+		if($action != "register") {
159
+			$result = dbquery("SELECT * FROM "._AUTHORTABLE." WHERE "._UIDFIELD." = '$uid' LIMIT 1");
160
+			$user = dbassoc($result);
161
+			$result2 = dbquery("SELECT * FROM ".TABLEPREFIX."fanfiction_authorinfo WHERE uid = '$uid'");
162
+			while($field = dbassoc($result2)) {
163
+				$user["af_".$field['field']] = $field['info'];
164
+			}
165
+		}
166
+		if($action == "register") {
167
+			$query = dbquery("SELECT message_text FROM ".TABLEPREFIX."fanfiction_messages WHERE message_name = 'tos'");
168
+			list($tos) = dbrow($query);
169
+			$output .= "<div class='tblborder' style='width: 90%; margin: 1em auto;'>$tos</div>";
170
+		}
171
+		$output .= "<div id='settingsform'><form method=\"POST\" enctype=\"multipart/form-data\" style='margin: 0 auto;' action=\"user.php?action=$action".($uid != USERUID ? "&uid=".$uid : "")."\">
172
+		<div><label for='newpenname'>"._PENNAME.":</label>";
173
+		if((isADMIN && uLEVEL == 1) || $action == "register")
174
+			$output .= "<INPUT name=\"newpenname\" type=\"text\" class=\"textbox\" maxlength=\"200\" value=\"".(isset($user) ? $user['penname'] : "")."\"><INPUT name=\"oldpenname\" type=\"hidden\" value=\"".(isset($user) ? $user['penname'] : "")."\"><font color=\"red\">*</font> ";
175
+		else if(isset($user)) $output .= " ".$user['penname'];
176
+		$output .= "</div>
177
+	 	<div><label for='realname'>"._REALNAME.": </label><INPUT type=\"text\" class=\"textbox=\" name=\"realname\" maxlength=\"200\" value=\"".(isset($user) ? $user['realname'] : "")."\"></div>
178
+	 	<div><label for='email'>"._EMAIL.":</label><INPUT  type=\"text\" class=\"textbox=\" name=\"email\" value=\"".(isset($user) ? $user['email'] : "")."\" maxlength=\"200\" size=\"35\"><font color=\"red\">*</font></div>
179
+	 	<div><label for='bio'>"._BIO.":</label></div>
180
+		<div style='width: 450px; margin: 0 auto;'><textarea class=\"textbox\" name=\"bio\" cols=\"50\" rows=\"6\">".(isset($user) ? stripslashes($user['bio']) : "")."</TEXTAREA></div>";
181
+/* The section adds fields to the form from the authorfields table to the authorinfo table allowing dynamic additions to the bio/registration page */
182
+		$authorfields = dbquery("SELECT * FROM ".TABLEPREFIX."fanfiction_authorfields WHERE field_on = '1'");
183
+		while($field = dbassoc($authorfields)) {
184
+			if($field['field_type'] == 1 || $field['field_type'] == 4 || $field['field_type'] == 6) 
185
+				$output .= "<div><label for='".$field['field_name']."'>".$field['field_title'].":</label>\n<input type='text' class='textbox' name='af_".$field['field_name']."'".(!empty($user["af_".$field['field_id']]) ? "value='".$user["af_".$field['field_id']]."'" : "").">\n</div>\n";
186
+			if($field['field_type'] == 2) {
187
+				$output .= "<div><label for='".$field['field_name']."'>".$field['field_title'].":</label>\n
188
+						<select class='textbox' name='af_".$field['field_name']."'>\n";
189
+				$opts = explode("|#|", $field['field_options']);
190
+				foreach($opts as $opt) {
191
+					$output .= "<option".(!empty($user["af_".$field['field_id']]) && $user["af_".$field['field_id']] == $opt ? " selected" : "").">$opt</option>\n";
192
+				}
193
+				$output .= "</select>\n</div>\n";
194
+			}
195
+			if($field['field_type'] == 5) eval(stripslashes($field['field_code_in']));
196
+			if($field['field_type'] == 3) {
197
+				$output .= "<div class='fieldset'><span class='label'>".$field['field_title'].":</span>\n";
198
+				$output .= "<input type='radio' name='af_".$field['field_name']."' id='af_".$field['field_name']._YES."' value='"._YES."'".(!empty($user["af_".$field['field_id']]) && $user["af_".$field['field_id']] == _YES ? "checked='checked'" : "")."> <label for='".$field['field_name']._YES."'>"._YES."</label>\n
199
+					<input type='radio' name='af_".$field['field_name']."' id='af_".$field['field_name']._NO."' value='"._NO."'".(!empty($user["af_".$field['field_id']]) && $user["af_".$field['field_id']] == _NO ? "checked='checked'" : "")."> <label for='".$field['field_name']._NO."'>"._NO."</label></div>\n";
200
+			}
201
+		}
202
+/* End dynamic fields */
203
+	 	if($imageupload == "1")
204
+	 		$output .= "<div><label for='image'>"._IMAGE.":</label> <INPUT  type=\"text\" class=\"textbox=\" name=\"image\" maxlength=\"200\" value=\"".(!empty($user['image']) ? $user['image'] : "")."\"></div>";
205
+		if($action != "register" || $pwdsetting)
206
+	 	$output .= "<div><label for='password'>"._PASSWORD.":</label>  <INPUT name=\"password\" class=\"textbox\" value=\"\" type=\"password\">".($action == "register" ? "<font color=\"red\">*</font>" : "")."</div>
207
+			<div><label for='password2'>"._PASSWORD2.":</label> <INPUT name=\"password2\" class=\"textbox=\" value=\"\" type=\"password\">".($action == "register" ? "<font color=\"red\">*</font>" : "")."</div>";
208
+		if(!empty($captcha) && $action == "register") $output .= "<div><label for='userdigit'>"._CAPTCHANOTE."</label><input MAXLENGTH=5 SIZE=5 name=\"userdigit\" type=\"text\" value=\"\"><div style='text-align: center;'><img width=120 height=30 src=\""._BASEDIR."includes/button.php\" style=\"border: 1px solid #111;\"></div></div>";
209
+	 	$output .= "<div style='text-align: center; margin: 1em;'><INPUT type=\"hidden\" name=\"uid\" value=\"".(isset($user) ? $user['uid'] : "")."\"><INPUT type=\"submit\" class=\"button\" name=\"submit\" value=\""._SUBMIT."\">";
210
+	 	if(!isADMIN)
211
+	 	{
212
+			 	$output .= " [<a href=\"admin.php?action=members&delete=$uid\">"._DELETE."</a>]";
213
+	 	}
214
+	 	$output .= "</div></form></div>".write_message("<font color=\"red\">*</font> "._REQUIREDFIELDS);
215
+	}
216
+?>
0 217
\ No newline at end of file
1 218
new file mode 100644
... ...
@@ -0,0 +1,19 @@
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", "");
6
+
7
+define ("_UIDFIELD", "author.uid");  // Do not change the aliasing (the "author." part)!
8
+define ("_PENNAMEFIELD", "author.penname");  // Do not change the aliasing (the "author." part)!
9
+define ("_EMAILFIELD", "author.email");  // Do not change the aliasing (the "author." part)!
10
+define ("_PASSWORDFIELD", "author.password"); //  Do not change the aliasing (the "author." part)!
11
+define ("_AUTHORTABLE", _AUTHORPREFIX."fanfiction_authors 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 count( stories.sid ) as stories, "._PENNAMEFIELD." as penname, "._UIDFIELD." as uid FROM "._AUTHORTABLE." LEFT JOIN ".TABLEPREFIX."fanfiction_authorprefs AS ap ON "._UIDFIELD." = ap.uid LEFT JOIN ".TABLEPREFIX."fanfiction_stories AS stories ON stories.validated > 0 AND (FIND_IN_SET("._UIDFIELD.", stories.coauthors) > 0 OR stories.uid = "._UIDFIELD.") ");
18
+define ("_MEMBERCOUNT", "SELECT COUNT(DISTINCT "._UIDFIELD.") FROM "._AUTHORTABLE." LEFT JOIN ".TABLEPREFIX."fanfiction_stories as stories ON stories.validated > 0 AND (FIND_IN_SET("._UIDFIELD.", stories.coauthors) > 0 OR stories.uid = "._UIDFIELD.")  LEFT JOIN ".TABLEPREFIX."fanfiction_authorprefs as ap ON "._UIDFIELD." = ap.uid");
19
+?>
0 20
\ No newline at end of file
1 21
new file mode 100644