| ... | ... |
@@ -1,224 +1,250 @@ |
| 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&uid=$uid\">"._DELETE."</a>]"; |
|
| 221 |
- } |
|
| 222 |
- $output .= "</div></form></div>".write_message("<font color=\"red\">*</font> "._REQUIREDFIELDS);
|
|
| 223 |
- } |
|
| 224 |
-?> |
|
| 225 | 1 |
\ No newline at end of file |
| 2 |
+<?php |
|
| 3 |
+// ---------------------------------------------------------------------- |
|
| 4 |
+// eFiction 3.2 |
|
| 5 |
+// Copyright (c) 2007 by Tammy Keefer |
|
| 6 |
+// Valid HTML 4.01 Transitional |
|
| 7 |
+// Based on eFiction 1.1 |
|
| 8 |
+// Copyright (C) 2003 by Rebecca Smallwood. |
|
| 9 |
+// http://efiction.sourceforge.net/ |
|
| 10 |
+// ---------------------------------------------------------------------- |
|
| 11 |
+// LICENSE |
|
| 12 |
+// |
|
| 13 |
+// This program is free software; you can redistribute it and/or |
|
| 14 |
+// modify it under the terms of the GNU General Public License (GPL) |
|
| 15 |
+// as published by the Free Software Foundation; either version 2 |
|
| 16 |
+// of the License, or (at your option) any later version. |
|
| 17 |
+// |
|
| 18 |
+// This program is distributed in the hope that it will be useful, |
|
| 19 |
+// but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
| 20 |
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
| 21 |
+// GNU General Public License for more details. |
|
| 22 |
+// |
|
| 23 |
+// To read the license please visit http://www.gnu.org/copyleft/gpl.html |
|
| 24 |
+// ---------------------------------------------------------------------- |
|
| 25 |
+ |
|
| 26 |
+if(!defined("_CHARSET")) exit( );
|
|
| 27 |
+if(!function_exists("random_char")) {
|
|
| 28 |
+ |
|
| 29 |
+function random_char($string) |
|
| 30 |
+{
|
|
| 31 |
+ $length = strlen($string); |
|
| 32 |
+ $position = mt_rand(0, $length - 1); |
|
| 33 |
+ $output = ($string[$position]); |
|
| 34 |
+ return $output; |
|
| 35 |
+} |
|
| 36 |
+ |
|
| 37 |
+function random_string ($charset_string, $length) |
|
| 38 |
+{
|
|
| 39 |
+ $return_string = random_char($charset_string); |
|
| 40 |
+ for ($x = 1; $x < $length; $x++) |
|
| 41 |
+ $return_string .= random_char($charset_string); |
|
| 42 |
+ return $return_string; |
|
| 43 |
+} |
|
| 44 |
+ |
|
| 45 |
+} |
|
| 46 |
+ |
|
| 47 |
+ $uid = isset($_REQUEST['uid']) ? $_REQUEST['uid'] : false; |
|
| 48 |
+ if(!$uid) $uid = USERUID; |
|
| 49 |
+ |
|
| 50 |
+ if((!isADMIN || uLEVEL > 2) && $uid != USERUID && $action == "editbio") $output .= write_error(_NOTAUTHORIZED); |
|
| 51 |
+ if(isMEMBER) $output .= "<div id=\"pagetitle\">"._EDITPERSONAL."</div>"; |
|
| 52 |
+ else $output .= "<div id=\"pagetitle\">"._NEWACCOUNT."</div>"; |
|
| 53 |
+ if(!empty($_POST['submit'])) {
|
|
| 54 |
+ $penname = isset($_POST['newpenname']) ? escapestring($_POST['newpenname']) : false; |
|
| 55 |
+ $email = escapestring($_POST['email']); |
|
| 56 |
+ if(!isset($email) && !isADMIN) $output .= "<div style='text-align: center;'>"._EMAILREQUIRED."</div>"; |
|
| 57 |
+ else if($penname && !preg_match("!^[a-z0-9-_ ]{3,30}$!i", $penname)) $output .= "<div style='text-align: center;'>"._BADUSERNAME."</div>";
|
|
| 58 |
+ else if(!validEmail($email)) $output .= "<div style='text-align: center;'>"._INVALIDEMAIL." "._TRYAGAIN."</div>"; |
|
| 59 |
+ else if($action == "register") {
|
|
| 60 |
+ if(!$penname || !preg_match("!^[a-z0-9-_ ]{3,30}$!i", $penname)) $output .= write_error(_PENEMAILREQUIRED);
|
|
| 61 |
+ else if($pwdsetting && empty($_POST['password'])) $output .= write_error(_PWDREQUIRED." "._TRYAGAIN); |
|
| 62 |
+ else {
|
|
| 63 |
+ $result = dbquery("SELECT "._PENNAMEFIELD." FROM "._AUTHORTABLE." WHERE "._PENNAMEFIELD." = '".escapestring($penname)."'");
|
|
| 64 |
+ $result2 = dbquery("SELECT "._EMAILFIELD." as email FROM "._AUTHORTABLE." WHERE "._EMAILFIELD." = '$email'");
|
|
| 65 |
+ if($captcha && !captcha_confirm()) $output .= write_error(_CAPTCHAFAIL); |
|
| 66 |
+ else if(dbnumrows($result) > 0) $output .= write_error(_PENNAMEINUSE." "._TRYAGAIN); |
|
| 67 |
+ else if(dbnumrows($result2) > 0) $output .= write_error(_EMAILINUSE." "._TRYAGAIN); |
|
| 68 |
+ else if(preg_match("!^[a-z0-9-_ ]{3,30}$!i", $penname)) {
|
|
| 69 |
+ if(!$pwdsetting) {
|
|
| 70 |
+ $charset = '23456789' . 'abcdefghijkmnpqrstuvwxyz' . 'ABCDEFGHJKLMNPQRSTUVWXYZ'; |
|
| 71 |
+ $pass = random_string($charset, 10); |
|
| 72 |
+ $encryppass = password_hash($pass, PASSWORD_BCRYPT, ['cost' => 12]); |
|
| 73 |
+ } |
|
| 74 |
+ else {
|
|
| 75 |
+ if($_POST['password'] != $_POST['password2']) {
|
|
| 76 |
+ $output .= write_error(_PASSWORDTWICE); |
|
| 77 |
+ $tpl->assign("output", $output);
|
|
| 78 |
+ $tpl->printToScreen( ); |
|
| 79 |
+ dbclose( ); |
|
| 80 |
+ exit( ); |
|
| 81 |
+ } |
|
| 82 |
+ $pass = $_POST['password2']; |
|
| 83 |
+ $encryppass = password_hash($pass, PASSWORD_BCRYPT, ['cost' => 12]); |
|
| 84 |
+ } |
|
| 85 |
+ 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')");
|
|
| 86 |
+ $useruid = dbinsertid(); |
|
| 87 |
+ 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() . ")");
|
|
| 88 |
+ if(empty($siteskin)) {
|
|
| 89 |
+ $skinquery = dbquery("SELECT skin FROM ".$settingsprefix."fanfiction_settings WHERE sitekey = '".SITEKEY."'");
|
|
| 90 |
+ list($skin) = dbrow($skinquery); |
|
| 91 |
+ } |
|
| 92 |
+ else $skin = $siteskin; |
|
| 93 |
+ |
|
| 94 |
+ |
|
| 95 |
+ |
|
| 96 |
+ dbquery("INSERT INTO ".TABLEPREFIX."fanfiction_authorprefs(uid, userskin, storyindex, sortby, tinyMCE) VALUES('".$useruid."', '$skin', '$displayindex', '$defaultsort', '$tinyMCE')");
|
|
| 97 |
+/* The section adds fields from the authorfields table to the authorinfo table allowing dynamic additions to the bio/registration page */ |
|
| 98 |
+ $fields = dbquery("SELECT * FROM ".TABLEPREFIX."fanfiction_authorfields WHERE field_on = '1'");
|
|
| 99 |
+ while($field = dbassoc($fields)) {
|
|
| 100 |
+ if(!$uid) continue; |
|
| 101 |
+ $oldfield = dbquery("SELECT * FROM ".TABLEPREFIX."fanfiction_authorinfo WHERE field='".$field['field_id']."' AND uid = '".$useruid."'");
|
|
| 102 |
+ if(dbnumrows($oldfield) > 0) {
|
|
| 103 |
+ $newinfo = isset($_POST["af_".$field['field_name']]) ? escapestring($_POST["af_".$field['field_name']]) : false; |
|
| 104 |
+ if(!empty($newinfo)) dbquery("UPDATE ".TABLEPREFIX."fanfiction_authorinfo SET info='$newinfo' WHERE uid = '$useruid' AND field = '".$field['field_id']."'");
|
|
| 105 |
+ else dbquery("DELETE FROM ".TABLEPREFIX."fanfiction_authorinfo WHERE uid = '$useruid' AND field = '".$field['field_id']."'");
|
|
| 106 |
+ } |
|
| 107 |
+ 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']."');");
|
|
| 108 |
+ } |
|
| 109 |
+/* End dynamic fields */ |
|
| 110 |
+ $subject = _SIGNUPSUBJECT; |
|
| 111 |
+ $mailtext = _SIGNUPMESSAGE._LOGIN.": $penname\n"._PASSWORD.": $pass \n\n"; |
|
| 112 |
+ if(!$pwdsetting) $mailtext .= _SIGNUPWARNING; |
|
| 113 |
+ include("includes/emailer.php");
|
|
| 114 |
+ sendemail($penname, $email, $sitename, $siteemail, $subject, $mailtext, "html"); |
|
| 115 |
+ |
|
| 116 |
+ /* registration notice */ |
|
| 117 |
+ if (isset($notifications)) |
|
| 118 |
+ {
|
|
| 119 |
+ $notifications = unserialize($notifications); |
|
| 120 |
+ } |
|
| 121 |
+ |
|
| 122 |
+ if(isset($notifications['registration_notify']) && $notifications['registration_notify']) {
|
|
| 123 |
+ if (isset($notifications['registration_toemail']) && $notifications['registration_toemail']) |
|
| 124 |
+ {
|
|
| 125 |
+ $RegSubject = "Registration Notice"; |
|
| 126 |
+ $RegIP = $_SERVER['REMOTE_ADDR']; |
|
| 127 |
+ $RegHost = gethostbyaddr($RegIP); |
|
| 128 |
+ $RegNoticeTo = $notifications['registration_toemail']; |
|
| 129 |
+ $RegMessage = "Username: $penname" . "\r\n" . "Email: $email" . "\r\n" . "IP: $RegIP" . "\r\n" . "Host: $RegHost"; |
|
| 130 |
+ $RegMessage .= " registered on your site"; |
|
| 131 |
+ $RegMessage .= "<br>Profile link: " . "<a href='" . $url . "/viewuser.php?uid=" . $useruid . "'>" . $penname . "</a>"; |
|
| 132 |
+ |
|
| 133 |
+ $RegNoticeTo_array=explode(',', $RegNoticeTo);
|
|
| 134 |
+ foreach ($RegNoticeTo_array AS $RegNoticeTo_email) {
|
|
| 135 |
+ if(validEmail($RegNoticeTo_email)) {
|
|
| 136 |
+ sendemail($sitename, $RegNoticeTo_email, $siteemail, $siteemail, $RegSubject, $RegMessage); |
|
| 137 |
+ } |
|
| 138 |
+ } |
|
| 139 |
+ |
|
| 140 |
+ } |
|
| 141 |
+ } |
|
| 142 |
+ /* registration notice end */ |
|
| 143 |
+ |
|
| 144 |
+ dbquery("UPDATE ".TABLEPREFIX."fanfiction_stats SET newestmember = '".$useruid."', members = members + 1");
|
|
| 145 |
+ if(defined("AUTHORPREFIX")) dbquery("UPDATE ".AUTHORPREFIX."fanfiction_stats SET newestmember = '".$useruid."', members = members + 1");
|
|
| 146 |
+ unset($_POST['submit']); |
|
| 147 |
+ $output = write_message(_ACTIONSUCCESSFUL); |
|
| 148 |
+ define("_LOGINCHECK", true);
|
|
| 149 |
+ include("user/login.php");
|
|
| 150 |
+ } |
|
| 151 |
+ else $output .= _BADUSERNAME; |
|
| 152 |
+ } |
|
| 153 |
+ } |
|
| 154 |
+ else{
|
|
| 155 |
+ if(($_POST['password']) && ($_POST['password2'])) {
|
|
| 156 |
+ if($_POST['password'] == $_POST['password2']) {
|
|
| 157 |
+ $encryppassword = password_hash($_POST['password'], PASSWORD_BCRYPT, ['cost' => 12]); |
|
| 158 |
+ dbquery("UPDATE "._AUTHORTABLE." SET password='$encryppassword' WHERE uid = '$uid'");
|
|
| 159 |
+ } |
|
| 160 |
+ else $output .= write_error(_PASSWORDTWICE); |
|
| 161 |
+ } |
|
| 162 |
+ if(isset($_POST['oldpenname']) && $penname != $_POST['oldpenname']) {
|
|
| 163 |
+ $checkresult = dbquery("SELECT * FROM "._AUTHORTABLE." WHERE penname = '".escapestring($penname)."'");
|
|
| 164 |
+ if(dbnumrows($checkresult)) {
|
|
| 165 |
+ $output .= write_message(_PENNAMEINUSE." "._TRYAGAIN); |
|
| 166 |
+ } |
|
| 167 |
+ else {
|
|
| 168 |
+ dbquery("UPDATE "._AUTHORTABLE." SET penname = '".escapestring($penname)."' WHERE uid = '$_POST[uid]'");
|
|
| 169 |
+ 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() . ")");
|
|
| 170 |
+ } |
|
| 171 |
+ } |
|
| 172 |
+/* The section adds fields from the authorfields table to the authorinfo table allowing dynamic additions to the bio/registration page */ |
|
| 173 |
+ $fields = dbquery("SELECT * FROM ".TABLEPREFIX."fanfiction_authorfields WHERE field_on = '1'");
|
|
| 174 |
+ while($field = dbassoc($fields)) {
|
|
| 175 |
+ $uid = isset($_POST['uid']) && isNumber($_POST['uid']) ? $_POST['uid'] : false; |
|
| 176 |
+ if(!$uid) continue; |
|
| 177 |
+ $oldfield = dbquery("SELECT * FROM ".TABLEPREFIX."fanfiction_authorinfo WHERE field='".$field['field_id']."' AND uid = '".$uid."'");
|
|
| 178 |
+ if(dbnumrows($oldfield) > 0) {
|
|
| 179 |
+ $newinfo = isset($_POST["af_".$field['field_name']]) ? escapestring(descript($_POST["af_".$field['field_name']])) : false; |
|
| 180 |
+ if(!empty($newinfo)) dbquery("UPDATE ".TABLEPREFIX."fanfiction_authorinfo SET info='".$newinfo."' WHERE uid = '$uid' AND field = '".descript($field['field_id'])."'");
|
|
| 181 |
+ else dbquery("DELETE FROM ".TABLEPREFIX."fanfiction_authorinfo WHERE uid = '$uid' AND field = '".$field['field_id']."'");
|
|
| 182 |
+ } |
|
| 183 |
+ 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']."');");
|
|
| 184 |
+ } |
|
| 185 |
+/* End dynamic fields */ |
|
| 186 |
+ 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'");
|
|
| 187 |
+ $output .= write_message(_ACTIONSUCCESSFUL." ".(isset($_GET['uid']) ? _BACK2ADMIN : _BACK2ACCT." "._LOGINAGAIN)); |
|
| 188 |
+ } |
|
| 189 |
+ } |
|
| 190 |
+ else {
|
|
| 191 |
+ if($action != "register") {
|
|
| 192 |
+ $result = dbquery("SELECT * FROM "._AUTHORTABLE." WHERE "._UIDFIELD." = '$uid' LIMIT 1");
|
|
| 193 |
+ $user = dbassoc($result); |
|
| 194 |
+ $result2 = dbquery("SELECT * FROM ".TABLEPREFIX."fanfiction_authorinfo WHERE uid = '$uid'");
|
|
| 195 |
+ while($field = dbassoc($result2)) {
|
|
| 196 |
+ $user["af_".$field['field']] = $field['info']; |
|
| 197 |
+ } |
|
| 198 |
+ } |
|
| 199 |
+ if($action == "register") {
|
|
| 200 |
+ $query = dbquery("SELECT message_text FROM ".TABLEPREFIX."fanfiction_messages WHERE message_name = 'tos'");
|
|
| 201 |
+ list($tos) = dbrow($query); |
|
| 202 |
+ $output .= "<div class='tblborder' style='width: 90%; margin: 1em auto;'>$tos</div>"; |
|
| 203 |
+ } |
|
| 204 |
+ $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 : "")."\"> |
|
| 205 |
+ <div><label for='newpenname'>"._PENNAME.":</label>"; |
|
| 206 |
+ if((isADMIN && uLEVEL == 1) || $action == "register") |
|
| 207 |
+ $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> "; |
|
| 208 |
+ else if(isset($user)) $output .= " ".$user['penname']; |
|
| 209 |
+ |
|
| 210 |
+ $output .= "</div> |
|
| 211 |
+ <div><label for='realname'>"._REALNAME.": </label><INPUT type=\"text\" class=\"textbox=\" name=\"realname\" maxlength=\"200\" value=\"".(isset($user) ? $user['realname'] : "")."\"></div> |
|
| 212 |
+ <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> |
|
| 213 |
+ <div><label for='bio'>"._BIO.":</label></div> |
|
| 214 |
+ <div style='width: 450px; margin: 0 auto;'> |
|
| 215 |
+ <textarea class=\"textbox\" name=\"bio\" cols=\"50\" rows=\"6\">".(isset($user['bio']) ? stripslashes($user['bio']) : "")."</TEXTAREA></div>"; |
|
| 216 |
+/* The section adds fields to the form from the authorfields table to the authorinfo table allowing dynamic additions to the bio/registration page */ |
|
| 217 |
+ $authorfields = dbquery("SELECT * FROM ".TABLEPREFIX."fanfiction_authorfields WHERE field_on = '1'");
|
|
| 218 |
+ while($field = dbassoc($authorfields)) {
|
|
| 219 |
+ if($field['field_type'] == 1 || $field['field_type'] == 4 || $field['field_type'] == 6) |
|
| 220 |
+ $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"; |
|
| 221 |
+ if($field['field_type'] == 2) {
|
|
| 222 |
+ $output .= "<div><label for='".$field['field_name']."'>".$field['field_title'].":</label>\n |
|
| 223 |
+ <select class='textbox' name='af_".$field['field_name']."'>\n"; |
|
| 224 |
+ $opts = explode("|#|", $field['field_options']);
|
|
| 225 |
+ foreach($opts as $opt) {
|
|
| 226 |
+ $output .= "<option".(!empty($user["af_".$field['field_id']]) && $user["af_".$field['field_id']] == $opt ? " selected" : "").">$opt</option>\n"; |
|
| 227 |
+ } |
|
| 228 |
+ $output .= "</select>\n</div>\n"; |
|
| 229 |
+ } |
|
| 230 |
+ if($field['field_type'] == 5) eval(stripslashes($field['field_code_in'])); |
|
| 231 |
+ if($field['field_type'] == 3) {
|
|
| 232 |
+ $output .= "<div class='fieldset'><span class='label'>".$field['field_title'].":</span>\n"; |
|
| 233 |
+ $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 |
|
| 234 |
+ <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"; |
|
| 235 |
+ } |
|
| 236 |
+ } |
|
| 237 |
+/* End dynamic fields */ |
|
| 238 |
+ if($imageupload == "1") |
|
| 239 |
+ $output .= "<div><label for='image'>"._IMAGE.":</label> <INPUT type=\"text\" class=\"textbox=\" name=\"image\" maxlength=\"200\" value=\"".(!empty($user['image']) ? $user['image'] : "")."\"></div>"; |
|
| 240 |
+ if($action != "register" || $pwdsetting) |
|
| 241 |
+ $output .= "<div><label for='password'>"._PASSWORD.":</label> <INPUT name=\"password\" class=\"textbox\" value=\"\" type=\"password\">".($action == "register" ? "<font color=\"red\">*</font>" : "")."</div> |
|
| 242 |
+ <div><label for='password2'>"._PASSWORD2.":</label> <INPUT name=\"password2\" class=\"textbox=\" value=\"\" type=\"password\">".($action == "register" ? "<font color=\"red\">*</font>" : "")."</div>"; |
|
| 243 |
+ 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>"; |
|
| 244 |
+ $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."\">"; |
|
| 245 |
+ if(!isADMIN && $action != "register") |
|
| 246 |
+ {
|
|
| 247 |
+ $output .= " [<a href=\"admin.php?action=members&delete=$uid\">"._DELETE."</a>]"; |
|
| 248 |
+ } |
|
| 249 |
+ $output .= "</div></form></div>".write_message("<font color=\"red\">*</font> "._REQUIREDFIELDS);
|
|
| 250 |
+ } |
|
| 251 |
+?> |
| 1 | 1 |
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&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 |