Browse code

Initial uplad w/ php7 fixes

Rainer Volkrodt authored on 2016/03/12 15:54:02
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`) 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
+						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`) VALUES('".escapestring(sprintf(_NEWPEN, USERPENNAME, USERUID, $_POST[oldpenname], $uid, $penname))."', '".USERUID."', INET_ATON('".$_SERVER['REMOTE_ADDR']."'), 'EB')");
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