Browse code

add MD5 password check and warning in Edit Personal Information page

Clarissa Walker authored on 2026/09/16 16:51:10
Showing 1 changed files
... ...
@@ -49,6 +49,16 @@ function random_string ($charset_string, $length)
49 49
 	if((!isADMIN || uLEVEL > 2) && $uid != USERUID && $action == "editbio") $output .= write_error(_NOTAUTHORIZED);
50 50
 	if(isMEMBER) $output .= "<div id=\"pagetitle\">"._EDITPERSONAL."</div>";
51 51
 	else $output .= "<div id=\"pagetitle\">"._NEWACCOUNT."</div>";
52
+
53
+	// check for MD5 password hashes after a user logs in to edit their bio and warn them if their password is insecure
54
+	// all MD5 hashes are 32 exact characters long, hexadecimal, 0-9 and a-f random
55
+	// this set is a bit cursed... but it works
56
+	$pwdcharlengthquery = dbquery("SELECT CHAR_LENGTH(password) FROM ".TABLEPREFIX."fanfiction_authors WHERE uid = ".USERUID.";");
57
+	$pwdlengthfetch = mysqli_fetch_row($pwdcharlengthquery);
58
+	$pwdlengthstring = end($pwdlengthfetch);
59
+	$pwdcheck = (int) $pwdlengthstring;
60
+	if ($pwdcheck == 32) $output .= "<center>"._INSECUREPWD."</center><br>";
61
+
52 62
 	if(!empty($_POST['submit'])) {
53 63
 		$penname = isset($_POST['newpenname']) ? escapestring($_POST['newpenname']) : false;
54 64
 		$email = escapestring($_POST['email']);
Browse code

user page cleanup

Clarissa Walker authored on 2026/09/16 16:03:02
Showing 1 changed files
... ...
@@ -183,7 +183,7 @@ function random_string ($charset_string, $length)
183 183
 			}
184 184
 /* End dynamic fields */
185 185
 			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'");
186
-			$output .= write_message(_ACTIONSUCCESSFUL."  ".(isset($_GET['uid']) ? _BACK2ADMIN : _BACK2ACCT." "._LOGINAGAIN));
186
+			$output .= write_message(_ACTIONSUCCESSFUL."  ".(isset($_GET['uid']) ? _BACK2ADMIN : _BACK2ACCT."<br>"._LOGINAGAIN));
187 187
 		}
188 188
 	}
189 189
 	else {
Browse code

Resize GD captcha for today's resolutions - and add forgotten set font directory

Clarissa Walker authored on 2026/09/04 14:38:27
Showing 1 changed files
... ...
@@ -239,7 +239,7 @@ function random_string ($charset_string, $length)
239 239
 		if($action != "register" || $pwdsetting)
240 240
 	 	$output .= "<div><label for='password'>"._PASSWORD.":</label>  <INPUT name=\"password\" class=\"textbox\" value=\"\" type=\"password\">".($action == "register" ? "<font color=\"red\">*</font>" : "")."</div>
241 241
 			<div><label for='password2'>"._PASSWORD2.":</label> <INPUT name=\"password2\" class=\"textbox=\" value=\"\" type=\"password\">".($action == "register" ? "<font color=\"red\">*</font>" : "")."</div>";
242
-		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>";
242
+		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=240 height=60 src=\""._BASEDIR."includes/button.php\" style=\"border: 1px solid #111;\"></div></div>";
243 243
 	 	$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."\">";
244 244
 	 	if(!isADMIN && $action != "register")
245 245
 	 	{
Browse code

Editing user bio page is less jank - also previous commit: stories.php

Clarissa Walker authored on 2026/07/26 19:21:01
Showing 1 changed files
... ...
@@ -200,7 +200,7 @@ function random_string ($charset_string, $length)
200 200
 			list($tos) = dbrow($query);
201 201
 			$output .= "<div class='tblborder' style='width: 90%; margin: 1em auto;'>$tos</div>";
202 202
 		}
203
-		$output .= "<div id='settingsform'><form method=\"POST\" id=\"editbio\" name=\"editbio\" enctype=\"multipart/form-data\" style='margin: 0 auto;' action=\"user.php?action=$action".($uid != USERUID ? "&uid=".$uid : "")."\">
203
+		$output .= "<div id='settingsform'><form method=\"POST\" id=\"editbio\" name=\"editbio\" enctype=\"multipart/form-data\" style='width: 260%; margin: 0 auto;' action=\"user.php?action=$action".($uid != USERUID ? "&uid=".$uid : "")."\">
204 204
 		<div><label for='newpenname'>"._PENNAME.":</label>";
205 205
 		if((isADMIN && uLEVEL == 1) || $action == "register")
206 206
 			$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> ";
Browse code

Password conversion: MD5 -> bcrypt with a cost of 12. This change also causes the user to log off the site every time the password is changed.

Clarissa Walker authored on 2026/07/16 19:43:15
Showing 1 changed files
... ...
@@ -68,7 +68,7 @@ function random_string ($charset_string, $length)
68 68
 					if(!$pwdsetting) {
69 69
 						$charset = '23456789' . 'abcdefghijkmnpqrstuvwxyz' . 'ABCDEFGHJKLMNPQRSTUVWXYZ';
70 70
 						$pass = random_string($charset, 10);
71
-						$encryppass = md5($pass);
71
+						$encryppass = password_hash($pass, PASSWORD_BCRYPT, ['cost' => 12]);
72 72
 					}
73 73
 					else {
74 74
 						if($_POST['password'] != $_POST['password2']) {
... ...
@@ -79,7 +79,7 @@ function random_string ($charset_string, $length)
79 79
 							exit( );
80 80
 						}
81 81
 						$pass = $_POST['password2'];
82
-						$encryppass = md5($pass);
82
+						$encryppass = password_hash($pass, PASSWORD_BCRYPT, ['cost' => 12]);
83 83
 					}
84 84
 					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'," . time() . ", '$encryppass')");
85 85
 					$useruid = dbinsertid();
... ...
@@ -153,7 +153,7 @@ function random_string ($charset_string, $length)
153 153
 		else{
154 154
 			 if(($_POST['password']) && ($_POST['password2'])) {
155 155
 				if($_POST['password'] == $_POST['password2']) {
156
-					$encryppassword = md5($_POST['password']);
156
+					$encryppassword = password_hash($_POST['password'], PASSWORD_BCRYPT, ['cost' => 12]);
157 157
 					dbquery("UPDATE "._AUTHORTABLE." SET password='$encryppassword' WHERE uid = '$uid'");
158 158
 				}
159 159
 				else $output .=  write_error(_PASSWORDTWICE);
... ...
@@ -183,7 +183,7 @@ function random_string ($charset_string, $length)
183 183
 			}
184 184
 /* End dynamic fields */
185 185
 			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'");
186
-			$output .= write_message(_ACTIONSUCCESSFUL."  ".(isset($_GET['uid']) ? _BACK2ADMIN : _BACK2ACCT));
186
+			$output .= write_message(_ACTIONSUCCESSFUL."  ".(isset($_GET['uid']) ? _BACK2ADMIN : _BACK2ACCT." "._LOGINAGAIN));
187 187
 		}
188 188
 	}
189 189
 	else {
Browse code

#15 fix mistypo - only logs failed

Jimako authored on 2026/03/29 03:41:38
Showing 1 changed files
... ...
@@ -165,7 +165,7 @@ function random_string ($charset_string, $length)
165 165
 				}
166 166
 				else {
167 167
 					dbquery("UPDATE "._AUTHORTABLE." SET penname = '".escapestring($penname)."' WHERE uid = '$_POST[uid]'");
168
-					if($logging) dbquery("INSERT INTO ".TABLEPREFIX."fanfiction_log (`log_action`, `log_uid`, `log_ip`, `log_type`, `log_timestamp`) VALUES('".escapestring(sprintf(_NEWPEN, USERPENNAME, USERUID, $_POST[oldpenname], $uid, $penname))."', '".USERUID."', INET6_ATON('".$_SERVER['REMOTE_ADDR']."'), 'EB', " . time() . ")");
168
+					if($logging) dbquery("INSERT INTO ".TABLEPREFIX."fanfiction_log (`log_action`, `log_uid`, `log_ip`, `log_type`, `log_timestamp`) VALUES('".escapestring(sprintf(_NEWPEN, USERPENNAME, USERUID, $_POST['oldpenname'], $uid, $penname))."', '".USERUID."', INET6_ATON('".$_SERVER['REMOTE_ADDR']."'), 'EB', " . time() . ")");
169 169
 				}
170 170
 			}
171 171
 /* The section adds fields from the authorfields table to the authorinfo table allowing dynamic additions to the bio/registration page */
Browse code

multiple address support

Jimako authored on 2024/04/25 04:12:38
Showing 1 changed files
... ...
@@ -128,7 +128,14 @@ function random_string ($charset_string, $length)
128 128
 							$RegMessage = "Username: $penname" . "\r\n" . "Email: $email" . "\r\n" . "IP: $RegIP" . "\r\n" . "Host: $RegHost";
129 129
 							$RegMessage .= " registered on your site";
130 130
 							$RegMessage .= "<br>Profile link: " . "<a href='" . $url . "/viewuser.php?uid=" . $useruid . "'>" . $penname . "</a>";
131
-							sendemail($sitename, $RegNoticeTo, $siteemail, $siteemail, $RegSubject,  $RegMessage);
131
+
132
+							$RegNoticeTo_array=explode(',', $RegNoticeTo);
133
+							foreach ($RegNoticeTo_array AS $RegNoticeTo_email) {
134
+								if(validEmail($RegNoticeTo_email)) {
135
+									sendemail($sitename, $RegNoticeTo_email, $siteemail, $siteemail, $RegSubject,  $RegMessage);
136
+								}	
137
+							}
138
+
132 139
 						}
133 140
 					}
134 141
 					/* registration notice end */
Browse code

fix for time - user registration

Jimako authored on 2024/04/21 17:50:30
Showing 1 changed files
... ...
@@ -81,7 +81,7 @@ function random_string ($charset_string, $length)
81 81
 						$pass = $_POST['password2'];
82 82
 						$encryppass = md5($pass);
83 83
 					}
84
-					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
+					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'," . time() . ", '$encryppass')");
85 85
 					$useruid = dbinsertid();
86 86
 					if($logging) dbquery("INSERT INTO ".TABLEPREFIX."fanfiction_log (`log_action`, `log_uid`, `log_ip`, `log_type`, `log_timestamp`) VALUES('".escapestring(sprintf(_LOG_REGISTER, $penname, $useruid, $_SERVER['REMOTE_ADDR']))."', '".$useruid. "', INET6_ATON('".$_SERVER['REMOTE_ADDR']."'), 'RG', " . time() . ")");
87 87
 					if(empty($siteskin)) {
... ...
@@ -127,6 +127,7 @@ function random_string ($charset_string, $length)
127 127
 							$RegNoticeTo = $notifications['registration_toemail'];
128 128
 							$RegMessage = "Username: $penname" . "\r\n" . "Email: $email" . "\r\n" . "IP: $RegIP" . "\r\n" . "Host: $RegHost";
129 129
 							$RegMessage .= " registered on your site";
130
+							$RegMessage .= "<br>Profile link: " . "<a href='" . $url . "/viewuser.php?uid=" . $useruid . "'>" . $penname . "</a>";
130 131
 							sendemail($sitename, $RegNoticeTo, $siteemail, $siteemail, $RegSubject,  $RegMessage);
131 132
 						}
132 133
 					}
Browse code

3.5.8git notifications

Jimako authored on 2024/04/21 12:53:37
Showing 1 changed files
... ...
@@ -42,6 +42,7 @@ function random_string ($charset_string, $length)
42 42
 }
43 43
 
44 44
 }
45
+ 
45 46
 	$uid = isset($_REQUEST['uid']) ? $_REQUEST['uid'] : false;
46 47
 	if(!$uid) $uid = USERUID;
47 48
 
... ...
@@ -88,6 +89,9 @@ function random_string ($charset_string, $length)
88 89
 						list($skin) = dbrow($skinquery);
89 90
 					}
90 91
 					else $skin = $siteskin;
92
+
93
+
94
+
91 95
 					dbquery("INSERT INTO ".TABLEPREFIX."fanfiction_authorprefs(uid, userskin, storyindex, sortby, tinyMCE) VALUES('".$useruid."', '$skin', '$displayindex', '$defaultsort', '$tinyMCE')");
92 96
 /* The section adds fields from the authorfields table to the authorinfo table allowing dynamic additions to the bio/registration page */
93 97
 					$fields = dbquery("SELECT * FROM ".TABLEPREFIX."fanfiction_authorfields WHERE field_on = '1'");
... ...
@@ -107,6 +111,27 @@ function random_string ($charset_string, $length)
107 111
 					if(!$pwdsetting) $mailtext .= _SIGNUPWARNING;
108 112
 					include("includes/emailer.php");
109 113
 					sendemail($penname, $email, $sitename, $siteemail, $subject, $mailtext, "html");
114
+
115
+					/* registration notice */
116
+					if (isset($notifications))
117
+					{
118
+						$notifications = unserialize($notifications);
119
+					}
120
+
121
+					if(isset($notifications['registration_notify'])  && $notifications['registration_notify'])  {
122
+						if (isset($notifications['registration_toemail'])  && $notifications['registration_toemail'])
123
+						{
124
+							$RegSubject = "Registration Notice";
125
+							$RegIP = $_SERVER['REMOTE_ADDR'];
126
+							$RegHost = gethostbyaddr($RegIP);			
127
+							$RegNoticeTo = $notifications['registration_toemail'];
128
+							$RegMessage = "Username: $penname" . "\r\n" . "Email: $email" . "\r\n" . "IP: $RegIP" . "\r\n" . "Host: $RegHost";
129
+							$RegMessage .= " registered on your site";
130
+							sendemail($sitename, $RegNoticeTo, $siteemail, $siteemail, $RegSubject,  $RegMessage);
131
+						}
132
+					}
133
+					/* registration notice end */
134
+
110 135
 					dbquery("UPDATE ".TABLEPREFIX."fanfiction_stats SET newestmember = '".$useruid."', members = members + 1");
111 136
 					if(defined("AUTHORPREFIX")) dbquery("UPDATE ".AUTHORPREFIX."fanfiction_stats SET newestmember = '".$useruid."', members = members + 1");
112 137
 					unset($_POST['submit']);
... ...
@@ -172,11 +197,13 @@ function random_string ($charset_string, $length)
172 197
 		if((isADMIN && uLEVEL == 1) || $action == "register")
173 198
 			$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> ";
174 199
 		else if(isset($user)) $output .= " ".$user['penname'];
200
+		
175 201
 		$output .= "</div>
176 202
 	 	<div><label for='realname'>"._REALNAME.": </label><INPUT type=\"text\" class=\"textbox=\" name=\"realname\" maxlength=\"200\" value=\"".(isset($user) ? $user['realname'] : "")."\"></div>
177 203
 	 	<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>
178 204
 	 	<div><label for='bio'>"._BIO.":</label></div>
179
-		<div style='width: 450px; margin: 0 auto;'><textarea class=\"textbox\" name=\"bio\" cols=\"50\" rows=\"6\">".(isset($user) ? stripslashes($user['bio']) : "")."</TEXTAREA></div>";
205
+		<div style='width: 450px; margin: 0 auto;'>
206
+		  <textarea class=\"textbox\" name=\"bio\" cols=\"50\" rows=\"6\">".(isset($user['bio']) ? stripslashes($user['bio']) : "")."</TEXTAREA></div>";
180 207
 /* The section adds fields to the form from the authorfields table to the authorinfo table allowing dynamic additions to the bio/registration page */
181 208
 		$authorfields = dbquery("SELECT * FROM ".TABLEPREFIX."fanfiction_authorfields WHERE field_on = '1'");
182 209
 		while($field = dbassoc($authorfields)) {
Browse code

version 3.5.7

Jimako authored on 2024/04/08 12:21:57
Showing 1 changed files
... ...
@@ -82,7 +82,7 @@ function random_string ($charset_string, $length)
82 82
 					}
83 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 84
 					$useruid = dbinsertid();
85
-					if($logging) dbquery("INSERT INTO ".TABLEPREFIX."fanfiction_log (`log_action`, `log_uid`, `log_ip`, `log_type`, `log_timestamp`) VALUES('".escapestring(sprintf(_LOG_REGISTER, $penname, $useruid, $_SERVER['REMOTE_ADDR']))."', '".$useruid."', INET_ATON('".$_SERVER['REMOTE_ADDR']."'), 'RG', " . time() . ")");
85
+					if($logging) dbquery("INSERT INTO ".TABLEPREFIX."fanfiction_log (`log_action`, `log_uid`, `log_ip`, `log_type`, `log_timestamp`) VALUES('".escapestring(sprintf(_LOG_REGISTER, $penname, $useruid, $_SERVER['REMOTE_ADDR']))."', '".$useruid. "', INET6_ATON('".$_SERVER['REMOTE_ADDR']."'), 'RG', " . time() . ")");
86 86
 					if(empty($siteskin)) {
87 87
 						$skinquery = dbquery("SELECT skin FROM ".$settingsprefix."fanfiction_settings WHERE sitekey = '".SITEKEY."'");
88 88
 						list($skin) = dbrow($skinquery);
... ...
@@ -132,7 +132,7 @@ function random_string ($charset_string, $length)
132 132
 				}
133 133
 				else {
134 134
 					dbquery("UPDATE "._AUTHORTABLE." SET penname = '".escapestring($penname)."' WHERE uid = '$_POST[uid]'");
135
-					if($logging) dbquery("INSERT INTO ".TABLEPREFIX."fanfiction_log (`log_action`, `log_uid`, `log_ip`, `log_type`, `log_timestamp`) VALUES('".escapestring(sprintf(_NEWPEN, USERPENNAME, USERUID, $_POST[oldpenname], $uid, $penname))."', '".USERUID."', INET_ATON('".$_SERVER['REMOTE_ADDR']."'), 'EB', " . time() . ")");
135
+					if($logging) dbquery("INSERT INTO ".TABLEPREFIX."fanfiction_log (`log_action`, `log_uid`, `log_ip`, `log_type`, `log_timestamp`) VALUES('".escapestring(sprintf(_NEWPEN, USERPENNAME, USERUID, $_POST[oldpenname], $uid, $penname))."', '".USERUID."', INET6_ATON('".$_SERVER['REMOTE_ADDR']."'), 'EB', " . time() . ")");
136 136
 				}
137 137
 			}
138 138
 /* The section adds fields from the authorfields table to the authorinfo table allowing dynamic additions to the bio/registration page */
... ...
@@ -212,4 +212,4 @@ function random_string ($charset_string, $length)
212 212
 	 	}
213 213
 	 	$output .= "</div></form></div>".write_message("<font color=\"red\">*</font> "._REQUIREDFIELDS);
214 214
 	}
215
-?>
216 215
\ No newline at end of file
216
+?>
Browse code

3.5.6 efiction version

Jimako authored on 2024/03/09 16:09:42
Showing 1 changed files
1 1
new file mode 100644
... ...
@@ -0,0 +1,215 @@
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(!validEmail($email)) $output .= "<div style='text-align: center;'>"._INVALIDEMAIL." "._TRYAGAIN."</div>";
57
+		else if($action == "register") {
58
+			if(!$penname || !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`, `log_timestamp`) VALUES('".escapestring(sprintf(_LOG_REGISTER, $penname, $useruid, $_SERVER['REMOTE_ADDR']))."', '".$useruid."', INET_ATON('".$_SERVER['REMOTE_ADDR']."'), 'RG', " . time() . ")");
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
+						if(!$uid) continue;
96
+						$oldfield = dbquery("SELECT * FROM ".TABLEPREFIX."fanfiction_authorinfo WHERE field='".$field['field_id']."' AND uid = '".$useruid."'");
97
+						if(dbnumrows($oldfield) > 0) {
98
+							$newinfo = isset($_POST["af_".$field['field_name']]) ? escapestring($_POST["af_".$field['field_name']]) : false;
99
+							if(!empty($newinfo)) dbquery("UPDATE ".TABLEPREFIX."fanfiction_authorinfo SET info='$newinfo' WHERE uid = '$useruid' AND field = '".$field['field_id']."'");
100
+							else dbquery("DELETE FROM ".TABLEPREFIX."fanfiction_authorinfo WHERE uid = '$useruid' AND field = '".$field['field_id']."'");
101
+						}
102
+						else if(!empty($_POST["af_".$field['field_name']])) dbquery("INSERT INTO ".TABLEPREFIX."fanfiction_authorinfo(`uid`, `info`, `field`) VALUES('$useruid', '".escapestring($_POST["af_".$field['field_name']])."', '".$field['field_id']."');");
103
+					}
104
+/* End dynamic fields */
105
+					$subject = _SIGNUPSUBJECT;
106
+					$mailtext = _SIGNUPMESSAGE._LOGIN.": $penname\n"._PASSWORD.": $pass \n\n";
107
+					if(!$pwdsetting) $mailtext .= _SIGNUPWARNING;
108
+					include("includes/emailer.php");
109
+					sendemail($penname, $email, $sitename, $siteemail, $subject, $mailtext, "html");
110
+					dbquery("UPDATE ".TABLEPREFIX."fanfiction_stats SET newestmember = '".$useruid."', members = members + 1");
111
+					if(defined("AUTHORPREFIX")) dbquery("UPDATE ".AUTHORPREFIX."fanfiction_stats SET newestmember = '".$useruid."', members = members + 1");
112
+					unset($_POST['submit']);
113
+					$output = write_message(_ACTIONSUCCESSFUL);
114
+					define("_LOGINCHECK", true);
115
+					include("user/login.php");
116
+				}
117
+				else $output .= _BADUSERNAME;
118
+			}
119
+		}
120
+		else{
121
+			 if(($_POST['password']) && ($_POST['password2'])) {
122
+				if($_POST['password'] == $_POST['password2']) {
123
+					$encryppassword = md5($_POST['password']);
124
+					dbquery("UPDATE "._AUTHORTABLE." SET password='$encryppassword' WHERE uid = '$uid'");
125
+				}
126
+				else $output .=  write_error(_PASSWORDTWICE);
127
+			}
128
+			if(isset($_POST['oldpenname']) && $penname != $_POST['oldpenname']) {
129
+				$checkresult = dbquery("SELECT * FROM "._AUTHORTABLE." WHERE penname = '".escapestring($penname)."'");
130
+				if(dbnumrows($checkresult)) {
131
+					$output .= write_message(_PENNAMEINUSE."  "._TRYAGAIN);
132
+				}
133
+				else {
134
+					dbquery("UPDATE "._AUTHORTABLE." SET penname = '".escapestring($penname)."' WHERE uid = '$_POST[uid]'");
135
+					if($logging) dbquery("INSERT INTO ".TABLEPREFIX."fanfiction_log (`log_action`, `log_uid`, `log_ip`, `log_type`, `log_timestamp`) VALUES('".escapestring(sprintf(_NEWPEN, USERPENNAME, USERUID, $_POST[oldpenname], $uid, $penname))."', '".USERUID."', INET_ATON('".$_SERVER['REMOTE_ADDR']."'), 'EB', " . time() . ")");
136
+				}
137
+			}
138
+/* The section adds fields from the authorfields table to the authorinfo table allowing dynamic additions to the bio/registration page */
139
+			$fields = dbquery("SELECT * FROM ".TABLEPREFIX."fanfiction_authorfields WHERE field_on = '1'");
140
+			while($field = dbassoc($fields)) {
141
+				$uid = isset($_POST['uid']) && isNumber($_POST['uid']) ? $_POST['uid'] : false;
142
+				if(!$uid) continue;
143
+				$oldfield = dbquery("SELECT * FROM ".TABLEPREFIX."fanfiction_authorinfo WHERE field='".$field['field_id']."' AND uid = '".$uid."'");
144
+				if(dbnumrows($oldfield) > 0) {
145
+					$newinfo = isset($_POST["af_".$field['field_name']]) ? escapestring(descript($_POST["af_".$field['field_name']])) : false;
146
+					if(!empty($newinfo)) dbquery("UPDATE ".TABLEPREFIX."fanfiction_authorinfo SET info='".$newinfo."' WHERE uid = '$uid' AND field = '".descript($field['field_id'])."'");
147
+					else dbquery("DELETE FROM ".TABLEPREFIX."fanfiction_authorinfo WHERE uid = '$uid' AND field = '".$field['field_id']."'");
148
+				}
149
+				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']."');");
150
+			}
151
+/* End dynamic fields */
152
+			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'");
153
+			$output .= write_message(_ACTIONSUCCESSFUL."  ".(isset($_GET['uid']) ? _BACK2ADMIN : _BACK2ACCT));
154
+		}
155
+	}
156
+	else {
157
+		if($action != "register") {
158
+			$result = dbquery("SELECT * FROM "._AUTHORTABLE." WHERE "._UIDFIELD." = '$uid' LIMIT 1");
159
+			$user = dbassoc($result);
160
+			$result2 = dbquery("SELECT * FROM ".TABLEPREFIX."fanfiction_authorinfo WHERE uid = '$uid'");
161
+			while($field = dbassoc($result2)) {
162
+				$user["af_".$field['field']] = $field['info'];
163
+			}
164
+		}
165
+		if($action == "register") {
166
+			$query = dbquery("SELECT message_text FROM ".TABLEPREFIX."fanfiction_messages WHERE message_name = 'tos'");
167
+			list($tos) = dbrow($query);
168
+			$output .= "<div class='tblborder' style='width: 90%; margin: 1em auto;'>$tos</div>";
169
+		}
170
+		$output .= "<div id='settingsform'><form method=\"POST\" id=\"editbio\" name=\"editbio\" enctype=\"multipart/form-data\" style='margin: 0 auto;' action=\"user.php?action=$action".($uid != USERUID ? "&uid=".$uid : "")."\">
171
+		<div><label for='newpenname'>"._PENNAME.":</label>";
172
+		if((isADMIN && uLEVEL == 1) || $action == "register")
173
+			$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> ";
174
+		else if(isset($user)) $output .= " ".$user['penname'];
175
+		$output .= "</div>
176
+	 	<div><label for='realname'>"._REALNAME.": </label><INPUT type=\"text\" class=\"textbox=\" name=\"realname\" maxlength=\"200\" value=\"".(isset($user) ? $user['realname'] : "")."\"></div>
177
+	 	<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>
178
+	 	<div><label for='bio'>"._BIO.":</label></div>
179
+		<div style='width: 450px; margin: 0 auto;'><textarea class=\"textbox\" name=\"bio\" cols=\"50\" rows=\"6\">".(isset($user) ? stripslashes($user['bio']) : "")."</TEXTAREA></div>";
180
+/* The section adds fields to the form from the authorfields table to the authorinfo table allowing dynamic additions to the bio/registration page */
181
+		$authorfields = dbquery("SELECT * FROM ".TABLEPREFIX."fanfiction_authorfields WHERE field_on = '1'");
182
+		while($field = dbassoc($authorfields)) {
183
+			if($field['field_type'] == 1 || $field['field_type'] == 4 || $field['field_type'] == 6) 
184
+				$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";
185
+			if($field['field_type'] == 2) {
186
+				$output .= "<div><label for='".$field['field_name']."'>".$field['field_title'].":</label>\n
187
+						<select class='textbox' name='af_".$field['field_name']."'>\n";
188
+				$opts = explode("|#|", $field['field_options']);
189
+				foreach($opts as $opt) {
190
+					$output .= "<option".(!empty($user["af_".$field['field_id']]) && $user["af_".$field['field_id']] == $opt ? " selected" : "").">$opt</option>\n";
191
+				}
192
+				$output .= "</select>\n</div>\n";
193
+			}
194
+			if($field['field_type'] == 5) eval(stripslashes($field['field_code_in']));
195
+			if($field['field_type'] == 3) {
196
+				$output .= "<div class='fieldset'><span class='label'>".$field['field_title'].":</span>\n";
197
+				$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
198
+					<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";
199
+			}
200
+		}
201
+/* End dynamic fields */
202
+	 	if($imageupload == "1")
203
+	 		$output .= "<div><label for='image'>"._IMAGE.":</label> <INPUT  type=\"text\" class=\"textbox=\" name=\"image\" maxlength=\"200\" value=\"".(!empty($user['image']) ? $user['image'] : "")."\"></div>";
204
+		if($action != "register" || $pwdsetting)
205
+	 	$output .= "<div><label for='password'>"._PASSWORD.":</label>  <INPUT name=\"password\" class=\"textbox\" value=\"\" type=\"password\">".($action == "register" ? "<font color=\"red\">*</font>" : "")."</div>
206
+			<div><label for='password2'>"._PASSWORD2.":</label> <INPUT name=\"password2\" class=\"textbox=\" value=\"\" type=\"password\">".($action == "register" ? "<font color=\"red\">*</font>" : "")."</div>";
207
+		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>";
208
+	 	$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."\">";
209
+	 	if(!isADMIN && $action != "register")
210
+	 	{
211
+			 	$output .= " [<a href=\"admin.php?action=members&delete=$uid\">"._DELETE."</a>]";
212
+	 	}
213
+	 	$output .= "</div></form></div>".write_message("<font color=\"red\">*</font> "._REQUIREDFIELDS);
214
+	}
215
+?>
0 216
\ No newline at end of file