Browse code

3.5.8git notifications

Jimako authored on 2024/04/21 12:53:37
Showing 9 changed files
... ...
@@ -1,3 +1,9 @@
1
+# efiction v3.5.8
2
+
3
+- added notification module
4
+- changed files: user/editbio.php and user/lostpassword.php 
5
+
6
+
1 7
 # efiction v3.5.7
2 8
 
3 9
 minimum requirements:  MySQL 5.6.3  or MariaDB 10.5.0 
4 10
new file mode 100644
... ...
@@ -0,0 +1,80 @@
1
+<?php
2
+// ----------------------------------------------------------------------
3
+// Copyright (c) 2007 by Tammy Keefer
4
+// Valid HTML 4.01 Transitional
5
+// Based on eFiction 1.1
6
+// Copyright (C) 2003 by Rebecca Smallwood.
7
+// http://efiction.sourceforge.net/
8
+// ----------------------------------------------------------------------
9
+// LICENSE
10
+//
11
+// This program is free software; you can redistribute it and/or
12
+// modify it under the terms of the GNU General Public License (GPL)
13
+// as published by the Free Software Foundation; either version 2
14
+// of the License, or (at your option) any later version.
15
+//
16
+// This program is distributed in the hope that it will be useful,
17
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
18
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
19
+// GNU General Public License for more details.
20
+//
21
+// To read the license please visit http://www.gnu.org/copyleft/gpl.html
22
+// ----------------------------------------------------------------------
23
+$current = "notifications";
24
+if(isset($_GET['action']) && ($_GET['action'] == "add" || $_GET['action'] == "edit")) $displayform = 1;
25
+
26
+if(file_exists(_BASEDIR."languages/{$language}_admin.php")) include_once(_BASEDIR."languages/{$language}_admin.php");
27
+else include_once(_BASEDIR."languages/en_admin.php");
28
+if(file_exists(_BASEDIR."modules/notifications/languages/{$language}.php")) include_once(_BASEDIR."modules/notifications/languages/{$language}.php");
29
+else include_once(_BASEDIR."modules/notifications/languages/en.php");
30
+
31
+ 
32
+ 
33
+$output = "<div id='pagetitle'>"._NOTIFICATIONADMIN."</div>";
34
+if(!isADMIN) accessDenied( );
35
+ 
36
+if(isset($_POST['submit'])) {
37
+ 
38
+	$dbdata =  serialize($_POST['notifications']);
39
+	$dbdata = addslashes($dbdata); 
40
+	$result = dbquery("UPDATE ".$settingsprefix."fanfiction_settings SET notifications = '$dbdata' WHERE sitekey = '".SITEKEY."'");
41
+	if($result) $output .= write_message(_ACTIONSUCCESSFUL);
42
+	else $output .= write_error(_ERROR);
43
+}
44
+else {
45
+ 
46
+	$tmp =  unserialize($notifications);
47
+
48
+	$registration_notify = isset($tmp['registration_notify']) ? $tmp['registration_notify'] : "";
49
+	$lostpassword_notify = isset($tmp['lostpassword_notify']) ? $tmp['lostpassword_notify'] : "";
50
+	$registration_toemail = isset($tmp['registration_toemail']) ? $tmp['registration_toemail'] : "";
51
+ 
52
+	$output .= "<div  id=\"settingsform\" style=\"width: 99%\">
53
+	  <form method=\"POST\" style=\"margin: 1em auto;\" enctype=\"multipart/form-data\"
54
+	   action=\"admin.php?action=modules&amp;admin=true&amp;module=notifications\">";
55
+	$output .= "<div style='margin-bottom: 1em'>
56
+	        <label for=\"notifications[registration_notify]\">". _REGISTRATION_NOTIFY. ": </label> 
57
+			 <select name=\"notifications[registration_notify]\">
58
+				<option value=\"1\"".($registration_notify == "1" ? " selected" : "").">"._YES."</option>
59
+				<option value=\"0\"".($registration_notify == "0" ? " selected" : "").">"._NO. "</option>
60
+			</select></div>
61
+			<div style='margin-bottom: 1em'>
62
+	        <label for=\"notifications[lostpassword_notify]\">" . _LOST_PASWORD_NOTIFY . ": </label> 
63
+			 <select name=\"notifications[lostpassword_notify]\">
64
+				<option value=\"1\"" . ($lostpassword_notify == "1" ? " selected" : "") . ">" . _YES . "</option>
65
+				<option value=\"0\"" . ($lostpassword_notify == "0" ? " selected" : "") . ">" . _NO . "</option>
66
+			</select></div>
67
+			<div style='margin-bottom: 1em'>
68
+			<label for=\"notifications[registration_toemail]\">". _REGISTRATION_TOEMAIL.":</label> 
69
+				<input type=\"text\" class=\"textbox\" id=\"registration_toemail\" maxlength=\"250\"
70
+			 name=\"notifications[registration_toemail]\" size=\"80\"  value=\"" .  $registration_toemail  . "\"></div>
71
+			
72
+			</div>";
73
+	$output .= "<div id='submitdiv'>
74
+					<INPUT type=\"submit\" id=\"submit\" class=\"button\" name=\"submit\" value=\""._SUBMIT."\">
75
+				</div>
76
+				</form> 
77
+				</div>";
78
+	 
79
+}
80
+?>
0 81
new file mode 100644
... ...
@@ -0,0 +1,53 @@
1
+<?php
2
+// ----------------------------------------------------------------------
3
+// Copyright (c) 2007 by Tammy Keefer
4
+// Also Like Module developed for eFiction 3.0
5
+// // http://efiction.hugosnebula.com/
6
+// ----------------------------------------------------------------------
7
+// LICENSE
8
+//
9
+// This program is free software; you can redistribute it and/or
10
+// modify it under the terms of the GNU General Public License (GPL)
11
+// as published by the Free Software Foundation; either version 2
12
+// of the License, or (at your option) any later version.
13
+//
14
+// This program is distributed in the hope that it will be useful,
15
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
16
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17
+// GNU General Public License for more details.
18
+//
19
+// To read the license please visit http://www.gnu.org/copyleft/gpl.html
20
+// ----------------------------------------------------------------------
21
+$current = "adminarea";
22
+include ("../../header.php");
23
+                                     
24
+//make a new TemplatePower object
25
+if(file_exists( "$skindir/default.tpl")) $tpl = new TemplatePower("$skindir/default.tpl" );
26
+else $tpl = new TemplatePower(_BASEDIR."default_tpls/default.tpl");
27
+$tpl->assignInclude( "header", "$skindir/header.tpl" );
28
+$tpl->assignInclude( "footer", "$skindir/footer.tpl" );
29
+include(_BASEDIR."includes/pagesetup.php");
30
+include_once(_BASEDIR."languages/".$language."_admin.php");
31
+if(!isADMIN) accessDenied( );       
32
+$confirm = isset($_GET['confirm']) ? $_GET['confirm'] : false;
33
+if($confirm == "yes") {
34
+	list($installed) = dbrow(dbquery("SELECT COUNT(code_module) FROM ".TABLEPREFIX. "fanfiction_codeblocks WHERE code_module = 'notifications'"));
35
+	if(!$installed) {
36
+ 
37
+		$check= dbassoc(dbquery("SHOW COLUMNS FROM " . TABLEPREFIX . "fanfiction_settings LIKE 'notifications'"));
38
+		if (!$check) dbquery("ALTER TABLE `" . TABLEPREFIX . "fanfiction_settings` ADD `notifications` TEXT NOT NULL default ''");
39
+ 
40
+		include("version.php");
41
+		dbquery("INSERT INTO `".TABLEPREFIX."fanfiction_modules`(`version`, `name`) VALUES('$moduleVersion', '$moduleName')");
42
+ 	    }
43
+	$output = write_message(_ACTIONSUCCESSFUL);
44
+}
45
+else if($confirm == "no") {
46
+	$output = write_message(_ACTIONCANCELLED);
47
+}
48
+else {
49
+	$output = write_message(_CONFIRMINSTALL."<br /><a href='install.php?confirm=yes'>"._YES."</a> "._OR." <a href='install.php?confirm=no'>"._NO."</a>");
50
+}
51
+$tpl->assign("output", $output);
52
+$tpl->printToScreen( );
53
+?>
0 54
new file mode 100644
... ...
@@ -0,0 +1,33 @@
1
+<?php
2
+// ----------------------------------------------------------------------
3
+// Copyright (c) 2007 by Tammy Keefer
4
+// Also Like Module developed for eFiction 3.0
5
+// // http://efiction.hugosnebula.com/
6
+// ----------------------------------------------------------------------
7
+// LICENSE
8
+//
9
+// This program is free software; you can redistribute it and/or
10
+// modify it under the terms of the GNU General Public License (GPL)
11
+// as published by the Free Software Foundation; either version 2
12
+// of the License, or (at your option) any later version.
13
+//
14
+// This program is distributed in the hope that it will be useful,
15
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
16
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17
+// GNU General Public License for more details.
18
+//
19
+// To read the license please visit http://www.gnu.org/copyleft/gpl.html
20
+// ----------------------------------------------------------------------
21
+if(!defined("_CHARSET")) exit( );
22
+
23
+define("_NOTIFICATIONADMIN", "NOTIFICATIONs Administration");
24
+define("_REGISTRATION_NOTIFY", "Send email - new registration");
25
+define("_LOST_PASWORD_NOTIFY", "Send email - lost password");
26
+define("_REGISTRATION_TOEMAIL", "Email recipients"); 
27
+
28
+if(!defined("_UNINSTALLWARNING")) {
29
+    define("_UNINSTALLWARNING", "<strong>Warning!</strong> No data will be deleted from the database!");
30
+}
31
+
32
+
33
+ 
0 34
\ No newline at end of file
1 35
new file mode 100644
... ...
@@ -0,0 +1,55 @@
1
+<?php
2
+// ----------------------------------------------------------------------
3
+// Copyright (c) 2007 by Tammy Keefer
4
+// Also Like Module developed for eFiction 3.0
5
+// // http://efiction.hugosnebula.com/
6
+// ----------------------------------------------------------------------
7
+// LICENSE
8
+//
9
+// This program is free software; you can redistribute it and/or
10
+// modify it under the terms of the GNU General Public License (GPL)
11
+// as published by the Free Software Foundation; either version 2
12
+// of the License, or (at your option) any later version.
13
+//
14
+// This program is distributed in the hope that it will be useful,
15
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
16
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17
+// GNU General Public License for more details.
18
+//
19
+// To read the license please visit http://www.gnu.org/copyleft/gpl.html
20
+// ----------------------------------------------------------------------
21
+$current = "adminarea";
22
+include ("../../header.php");
23
+
24
+//make a new TemplatePower object
25
+if(file_exists( "$skindir/default.tpl")) $tpl = new TemplatePower("$skindir/default.tpl" );
26
+else $tpl = new TemplatePower(_BASEDIR."default_tpls/default.tpl");
27
+$tpl->assignInclude( "header", "$skindir/header.tpl" );
28
+$tpl->assignInclude( "footer", "$skindir/footer.tpl" );
29
+include(_BASEDIR."includes/pagesetup.php");
30
+include_once(_BASEDIR."languages/".$language."_admin.php");
31
+if(!isADMIN) accessDenied( );
32
+$confirm = isset($_GET['confirm']) ? $_GET['confirm'] : false;
33
+if($confirm == "yes") {
34
+	include("version.php");
35
+	dbquery("DELETE FROM `".TABLEPREFIX."fanfiction_modules` WHERE name = '$moduleName'");	
36
+	dbquery("DELETE FROM `".TABLEPREFIX."fanfiction_codeblocks` WHERE code_module = 'notifications'");	
37
+	$output = write_message(_ACTIONSUCCESSFUL);
38
+}
39
+else if($confirm == "no") {
40
+	$output = write_message(_ACTIONCANCELLED);
41
+}
42
+else {
43
+
44
+	$blockquery = dbquery("SELECT * FROM " . TABLEPREFIX . "fanfiction_modules WHERE name = 'notifications'");
45
+	$notquery = dbquery("SHOW COLUMNS FROM " . $settingsprefix . "fanfiction_settings LIKE 'notifications'");
46
+ 
47
+	$modquery = dbquery("SELECT * FROM ".TABLEPREFIX. "fanfiction_codeblocks WHERE code_module = 'notifications'");
48
+	if(dbnumrows($modquery) OR dbnumrows($notquery) or dbnumrows($blockquery) ) {
49
+		$output = write_message(_CONFIRMUNINSTALL."<a href='uninstall.php?confirm=yes'>"._YES."</a> "._OR." <a href='uninstall.php?confirm=no'>"._NO."</a>");		 
50
+	}
51
+	else $output .= write_message(_MODNOTINSTALLED);
52
+}
53
+$tpl->assign("output", $output);
54
+$tpl->printToScreen( );
55
+?>
0 56
new file mode 100644
... ...
@@ -0,0 +1,18 @@
1
+<?php
2
+/*
3
+This file will be called by admin/modules.php and update.php to determine if 
4
+the module version in the database is the current version of the module.  
5
+The version number in this file will be the current version.
6
+*/
7
+
8
+if(!defined("_CHARSET")) exit( );
9
+
10
+$moduleVersion = "1.0";
11
+$moduleName = "Notifications";
12
+
13
+$moduleDescription = "This tiny module adds notification settings for user registration. ";
14
+$moduleAuthor = "Jimako";
15
+$moduleAuthorEmail = "";
16
+$moduleWebsite = "";
17
+
18
+ 
0 19
\ No newline at end of file
... ...
@@ -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)) {
... ...
@@ -67,6 +67,28 @@ if(isMEMBER) accessDenied( );
67 67
 				else $output .=  write_message(_EMAILFAILED);
68 68
 				if($logging) 
69 69
 					dbquery("INSERT INTO ".TABLEPREFIX."fanfiction_log (`log_action`, `log_uid`, `log_ip`, `log_type`, `log_timestamp`) VALUES('".escapestring(sprintf(_LOG_LOST_PASSWORD, $penname, $uid, ($result ? _YES : _NO)))."', '$uid', INET6_ATON('".$_SERVER['REMOTE_ADDR']."'), 'LP', " . time() . ")");
70
+
71
+
72
+				/* lost password notice */
73
+				if (isset($notifications))
74
+				{
75
+					$notifications = unserialize($notifications);
76
+				}
77
+	 
78
+				if (isset($notifications['lostpassword_notify'])  && $notifications['lostpassword_notify'])
79
+				{
80
+				
81
+					if (isset($notifications['registration_toemail'])  && $notifications['registration_toemail'])
82
+					{
83
+						$RegSubject = "Lost Password Notice";
84
+						$RegIP = $_SERVER['REMOTE_ADDR'];
85
+						$RegHost = gethostbyaddr($RegIP);
86
+						$RegNoticeTo = $notifications['registration_toemail'];
87
+						$RegMessage = "Username: $penname" . "\r\n" . "Email: $email" . "\r\n" . "IP: $RegIP" . "\r\n" . "Host: $RegHost";
88
+						$RegMessage .= " Asked for new password";
89
+ 						sendemail($sitename, $RegNoticeTo, $siteemail, $siteemail, $RegSubject,  $RegMessage);
90
+					}
91
+				}	 
70 92
 			}
71 93
 
72 94
 		}
... ...
@@ -1,19 +1,3 @@
1 1
 <?php
2 2
 if(!defined("_CHARSET")) exit( );
3
-$version = "3.5.7";
4
-
5
-/* shortcut 
6
-$tmp = dbassoc(dbquery("SHOW COLUMNS FROM " . TABLEPREFIX . "fanfiction_stories LIKE 'date'"));
7
-if($tmp['Type'] == "datetime") {
8
-    dbquery("UPDATE " . TABLEPREFIX . "fanfiction_settings SET version = '3.5.5' WHERE sitekey = '" . SITEKEY . "'");
9
-}
10
-
11
-
12
-$tmp = dbassoc(dbquery("SHOW COLUMNS FROM " . TABLEPREFIX . "fanfiction_news LIKE 'time'"));
13
- 
14
-if ($tmp['Type'] == "datetime")
15
-{
16
-    dbquery("UPDATE " . TABLEPREFIX . "fanfiction_settings SET version = '3.5.5' WHERE sitekey = '" . SITEKEY . "'");
17
-}
18
-
19
-*/
3
+$version = "3.5.8";