3.5.8git notifications
--- a/README.md
+++ b/README.md
@@ -1,3 +1,9 @@
+# efiction v3.5.8
+
+- added notification module
+- changed files: user/editbio.php and user/lostpassword.php
+
+
# efiction v3.5.7
minimum requirements: MySQL 5.6.3 or MariaDB 10.5.0
--- /dev/null
+++ b/modules/notifications/admin.php
@@ -1,1 +1,81 @@
+<?php
+// ----------------------------------------------------------------------
+// Copyright (c) 2007 by Tammy Keefer
+// Valid HTML 4.01 Transitional
+// Based on eFiction 1.1
+// Copyright (C) 2003 by Rebecca Smallwood.
+// http://efiction.sourceforge.net/
+// ----------------------------------------------------------------------
+// LICENSE
+//
+// This program is free software; you can redistribute it and/or
+// modify it under the terms of the GNU General Public License (GPL)
+// as published by the Free Software Foundation; either version 2
+// of the License, or (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// To read the license please visit http://www.gnu.org/copyleft/gpl.html
+// ----------------------------------------------------------------------
+$current = "notifications";
+if(isset($_GET['action']) && ($_GET['action'] == "add" || $_GET['action'] == "edit")) $displayform = 1;
+if(file_exists(_BASEDIR."languages/{$language}_admin.php")) include_once(_BASEDIR."languages/{$language}_admin.php");
+else include_once(_BASEDIR."languages/en_admin.php");
+if(file_exists(_BASEDIR."modules/notifications/languages/{$language}.php")) include_once(_BASEDIR."modules/notifications/languages/{$language}.php");
+else include_once(_BASEDIR."modules/notifications/languages/en.php");
+
+
+
+$output = "<div id='pagetitle'>"._NOTIFICATIONADMIN."</div>";
+if(!isADMIN) accessDenied( );
+
+if(isset($_POST['submit'])) {
+
+ $dbdata = serialize($_POST['notifications']);
+ $dbdata = addslashes($dbdata);
+ $result = dbquery("UPDATE ".$settingsprefix."fanfiction_settings SET notifications = '$dbdata' WHERE sitekey = '".SITEKEY."'");
+ if($result) $output .= write_message(_ACTIONSUCCESSFUL);
+ else $output .= write_error(_ERROR);
+}
+else {
+
+ $tmp = unserialize($notifications);
+
+ $registration_notify = isset($tmp['registration_notify']) ? $tmp['registration_notify'] : "";
+ $lostpassword_notify = isset($tmp['lostpassword_notify']) ? $tmp['lostpassword_notify'] : "";
+ $registration_toemail = isset($tmp['registration_toemail']) ? $tmp['registration_toemail'] : "";
+
+ $output .= "<div id=\"settingsform\" style=\"width: 99%\">
+ <form method=\"POST\" style=\"margin: 1em auto;\" enctype=\"multipart/form-data\"
+ action=\"admin.php?action=modules&admin=true&module=notifications\">";
+ $output .= "<div style='margin-bottom: 1em'>
+ <label for=\"notifications[registration_notify]\">". _REGISTRATION_NOTIFY. ": </label>
+ <select name=\"notifications[registration_notify]\">
+ <option value=\"1\"".($registration_notify == "1" ? " selected" : "").">"._YES."</option>
+ <option value=\"0\"".($registration_notify == "0" ? " selected" : "").">"._NO. "</option>
+ </select></div>
+ <div style='margin-bottom: 1em'>
+ <label for=\"notifications[lostpassword_notify]\">" . _LOST_PASWORD_NOTIFY . ": </label>
+ <select name=\"notifications[lostpassword_notify]\">
+ <option value=\"1\"" . ($lostpassword_notify == "1" ? " selected" : "") . ">" . _YES . "</option>
+ <option value=\"0\"" . ($lostpassword_notify == "0" ? " selected" : "") . ">" . _NO . "</option>
+ </select></div>
+ <div style='margin-bottom: 1em'>
+ <label for=\"notifications[registration_toemail]\">". _REGISTRATION_TOEMAIL.":</label>
+ <input type=\"text\" class=\"textbox\" id=\"registration_toemail\" maxlength=\"250\"
+ name=\"notifications[registration_toemail]\" size=\"80\" value=\"" . $registration_toemail . "\"></div>
+
+ </div>";
+ $output .= "<div id='submitdiv'>
+ <INPUT type=\"submit\" id=\"submit\" class=\"button\" name=\"submit\" value=\""._SUBMIT."\">
+ </div>
+ </form>
+ </div>";
+
+}
+?>
+
--- /dev/null
+++ b/modules/notifications/install.php
@@ -1,1 +1,54 @@
+<?php
+// ----------------------------------------------------------------------
+// Copyright (c) 2007 by Tammy Keefer
+// Also Like Module developed for eFiction 3.0
+// // http://efiction.hugosnebula.com/
+// ----------------------------------------------------------------------
+// LICENSE
+//
+// This program is free software; you can redistribute it and/or
+// modify it under the terms of the GNU General Public License (GPL)
+// as published by the Free Software Foundation; either version 2
+// of the License, or (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// To read the license please visit http://www.gnu.org/copyleft/gpl.html
+// ----------------------------------------------------------------------
+$current = "adminarea";
+include ("../../header.php");
+
+//make a new TemplatePower object
+if(file_exists( "$skindir/default.tpl")) $tpl = new TemplatePower("$skindir/default.tpl" );
+else $tpl = new TemplatePower(_BASEDIR."default_tpls/default.tpl");
+$tpl->assignInclude( "header", "$skindir/header.tpl" );
+$tpl->assignInclude( "footer", "$skindir/footer.tpl" );
+include(_BASEDIR."includes/pagesetup.php");
+include_once(_BASEDIR."languages/".$language."_admin.php");
+if(!isADMIN) accessDenied( );
+$confirm = isset($_GET['confirm']) ? $_GET['confirm'] : false;
+if($confirm == "yes") {
+ list($installed) = dbrow(dbquery("SELECT COUNT(code_module) FROM ".TABLEPREFIX. "fanfiction_codeblocks WHERE code_module = 'notifications'"));
+ if(!$installed) {
+
+ $check= dbassoc(dbquery("SHOW COLUMNS FROM " . TABLEPREFIX . "fanfiction_settings LIKE 'notifications'"));
+ if (!$check) dbquery("ALTER TABLE `" . TABLEPREFIX . "fanfiction_settings` ADD `notifications` TEXT NOT NULL default ''");
+
+ include("version.php");
+ dbquery("INSERT INTO `".TABLEPREFIX."fanfiction_modules`(`version`, `name`) VALUES('$moduleVersion', '$moduleName')");
+ }
+ $output = write_message(_ACTIONSUCCESSFUL);
+}
+else if($confirm == "no") {
+ $output = write_message(_ACTIONCANCELLED);
+}
+else {
+ $output = write_message(_CONFIRMINSTALL."<br /><a href='install.php?confirm=yes'>"._YES."</a> "._OR." <a href='install.php?confirm=no'>"._NO."</a>");
+}
+$tpl->assign("output", $output);
+$tpl->printToScreen( );
+?>
--- /dev/null
+++ b/modules/notifications/languages/en.php
@@ -1,1 +1,33 @@
+<?php
+// ----------------------------------------------------------------------
+// Copyright (c) 2007 by Tammy Keefer
+// Also Like Module developed for eFiction 3.0
+// // http://efiction.hugosnebula.com/
+// ----------------------------------------------------------------------
+// LICENSE
+//
+// This program is free software; you can redistribute it and/or
+// modify it under the terms of the GNU General Public License (GPL)
+// as published by the Free Software Foundation; either version 2
+// of the License, or (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// To read the license please visit http://www.gnu.org/copyleft/gpl.html
+// ----------------------------------------------------------------------
+if(!defined("_CHARSET")) exit( );
+define("_NOTIFICATIONADMIN", "NOTIFICATIONs Administration");
+define("_REGISTRATION_NOTIFY", "Send email - new registration");
+define("_LOST_PASWORD_NOTIFY", "Send email - lost password");
+define("_REGISTRATION_TOEMAIL", "Email recipients");
+
+if(!defined("_UNINSTALLWARNING")) {
+ define("_UNINSTALLWARNING", "<strong>Warning!</strong> No data will be deleted from the database!");
+}
+
+
+
--- /dev/null
+++ b/modules/notifications/uninstall.php
@@ -1,1 +1,56 @@
+<?php
+// ----------------------------------------------------------------------
+// Copyright (c) 2007 by Tammy Keefer
+// Also Like Module developed for eFiction 3.0
+// // http://efiction.hugosnebula.com/
+// ----------------------------------------------------------------------
+// LICENSE
+//
+// This program is free software; you can redistribute it and/or
+// modify it under the terms of the GNU General Public License (GPL)
+// as published by the Free Software Foundation; either version 2
+// of the License, or (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// To read the license please visit http://www.gnu.org/copyleft/gpl.html
+// ----------------------------------------------------------------------
+$current = "adminarea";
+include ("../../header.php");
+//make a new TemplatePower object
+if(file_exists( "$skindir/default.tpl")) $tpl = new TemplatePower("$skindir/default.tpl" );
+else $tpl = new TemplatePower(_BASEDIR."default_tpls/default.tpl");
+$tpl->assignInclude( "header", "$skindir/header.tpl" );
+$tpl->assignInclude( "footer", "$skindir/footer.tpl" );
+include(_BASEDIR."includes/pagesetup.php");
+include_once(_BASEDIR."languages/".$language."_admin.php");
+if(!isADMIN) accessDenied( );
+$confirm = isset($_GET['confirm']) ? $_GET['confirm'] : false;
+if($confirm == "yes") {
+ include("version.php");
+ dbquery("DELETE FROM `".TABLEPREFIX."fanfiction_modules` WHERE name = '$moduleName'");
+ dbquery("DELETE FROM `".TABLEPREFIX."fanfiction_codeblocks` WHERE code_module = 'notifications'");
+ $output = write_message(_ACTIONSUCCESSFUL);
+}
+else if($confirm == "no") {
+ $output = write_message(_ACTIONCANCELLED);
+}
+else {
+
+ $blockquery = dbquery("SELECT * FROM " . TABLEPREFIX . "fanfiction_modules WHERE name = 'notifications'");
+ $notquery = dbquery("SHOW COLUMNS FROM " . $settingsprefix . "fanfiction_settings LIKE 'notifications'");
+
+ $modquery = dbquery("SELECT * FROM ".TABLEPREFIX. "fanfiction_codeblocks WHERE code_module = 'notifications'");
+ if(dbnumrows($modquery) OR dbnumrows($notquery) or dbnumrows($blockquery) ) {
+ $output = write_message(_CONFIRMUNINSTALL."<a href='uninstall.php?confirm=yes'>"._YES."</a> "._OR." <a href='uninstall.php?confirm=no'>"._NO."</a>");
+ }
+ else $output .= write_message(_MODNOTINSTALLED);
+}
+$tpl->assign("output", $output);
+$tpl->printToScreen( );
+?>
+
--- /dev/null
+++ b/modules/notifications/version.php
@@ -1,1 +1,18 @@
+<?php
+/*
+This file will be called by admin/modules.php and update.php to determine if
+the module version in the database is the current version of the module.
+The version number in this file will be the current version.
+*/
+if(!defined("_CHARSET")) exit( );
+
+$moduleVersion = "1.0";
+$moduleName = "Notifications";
+
+$moduleDescription = "This tiny module adds notification settings for user registration. ";
+$moduleAuthor = "Jimako";
+$moduleAuthorEmail = "";
+$moduleWebsite = "";
+
+
--- a/user/editbio.php
+++ b/user/editbio.php
@@ -42,6 +42,7 @@
}
}
+
$uid = isset($_REQUEST['uid']) ? $_REQUEST['uid'] : false;
if(!$uid) $uid = USERUID;
@@ -88,6 +89,9 @@
list($skin) = dbrow($skinquery);
}
else $skin = $siteskin;
+
+
+
dbquery("INSERT INTO ".TABLEPREFIX."fanfiction_authorprefs(uid, userskin, storyindex, sortby, tinyMCE) VALUES('".$useruid."', '$skin', '$displayindex', '$defaultsort', '$tinyMCE')");
/* The section adds fields from the authorfields table to the authorinfo table allowing dynamic additions to the bio/registration page */
$fields = dbquery("SELECT * FROM ".TABLEPREFIX."fanfiction_authorfields WHERE field_on = '1'");
@@ -107,6 +111,27 @@
if(!$pwdsetting) $mailtext .= _SIGNUPWARNING;
include("includes/emailer.php");
sendemail($penname, $email, $sitename, $siteemail, $subject, $mailtext, "html");
+
+ /* registration notice */
+ if (isset($notifications))
+ {
+ $notifications = unserialize($notifications);
+ }
+
+ if(isset($notifications['registration_notify']) && $notifications['registration_notify']) {
+ if (isset($notifications['registration_toemail']) && $notifications['registration_toemail'])
+ {
+ $RegSubject = "Registration Notice";
+ $RegIP = $_SERVER['REMOTE_ADDR'];
+ $RegHost = gethostbyaddr($RegIP);
+ $RegNoticeTo = $notifications['registration_toemail'];
+ $RegMessage = "Username: $penname" . "\r\n" . "Email: $email" . "\r\n" . "IP: $RegIP" . "\r\n" . "Host: $RegHost";
+ $RegMessage .= " registered on your site";
+ sendemail($sitename, $RegNoticeTo, $siteemail, $siteemail, $RegSubject, $RegMessage);
+ }
+ }
+ /* registration notice end */
+
dbquery("UPDATE ".TABLEPREFIX."fanfiction_stats SET newestmember = '".$useruid."', members = members + 1");
if(defined("AUTHORPREFIX")) dbquery("UPDATE ".AUTHORPREFIX."fanfiction_stats SET newestmember = '".$useruid."', members = members + 1");
unset($_POST['submit']);
@@ -172,11 +197,13 @@
if((isADMIN && uLEVEL == 1) || $action == "register")
$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> ";
else if(isset($user)) $output .= " ".$user['penname'];
+
$output .= "</div>
<div><label for='realname'>"._REALNAME.": </label><INPUT type=\"text\" class=\"textbox=\" name=\"realname\" maxlength=\"200\" value=\"".(isset($user) ? $user['realname'] : "")."\"></div>
<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>
<div><label for='bio'>"._BIO.":</label></div>
- <div style='width: 450px; margin: 0 auto;'><textarea class=\"textbox\" name=\"bio\" cols=\"50\" rows=\"6\">".(isset($user) ? stripslashes($user['bio']) : "")."</TEXTAREA></div>";
+ <div style='width: 450px; margin: 0 auto;'>
+ <textarea class=\"textbox\" name=\"bio\" cols=\"50\" rows=\"6\">".(isset($user['bio']) ? stripslashes($user['bio']) : "")."</TEXTAREA></div>";
/* The section adds fields to the form from the authorfields table to the authorinfo table allowing dynamic additions to the bio/registration page */
$authorfields = dbquery("SELECT * FROM ".TABLEPREFIX."fanfiction_authorfields WHERE field_on = '1'");
while($field = dbassoc($authorfields)) {
--- a/user/lostpassword.php
+++ b/user/lostpassword.php
@@ -67,6 +67,28 @@
else $output .= write_message(_EMAILFAILED);
if($logging)
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() . ")");
+
+
+ /* lost password notice */
+ if (isset($notifications))
+ {
+ $notifications = unserialize($notifications);
+ }
+
+ if (isset($notifications['lostpassword_notify']) && $notifications['lostpassword_notify'])
+ {
+
+ if (isset($notifications['registration_toemail']) && $notifications['registration_toemail'])
+ {
+ $RegSubject = "Lost Password Notice";
+ $RegIP = $_SERVER['REMOTE_ADDR'];
+ $RegHost = gethostbyaddr($RegIP);
+ $RegNoticeTo = $notifications['registration_toemail'];
+ $RegMessage = "Username: $penname" . "\r\n" . "Email: $email" . "\r\n" . "IP: $RegIP" . "\r\n" . "Host: $RegHost";
+ $RegMessage .= " Asked for new password";
+ sendemail($sitename, $RegNoticeTo, $siteemail, $siteemail, $RegSubject, $RegMessage);
+ }
+ }
}
}
--- a/version.php
+++ b/version.php
@@ -1,20 +1,4 @@
<?php
if(!defined("_CHARSET")) exit( );
-$version = "3.5.7";
+$version = "3.5.8";
-/* shortcut
-$tmp = dbassoc(dbquery("SHOW COLUMNS FROM " . TABLEPREFIX . "fanfiction_stories LIKE 'date'"));
-if($tmp['Type'] == "datetime") {
- dbquery("UPDATE " . TABLEPREFIX . "fanfiction_settings SET version = '3.5.5' WHERE sitekey = '" . SITEKEY . "'");
-}
-
-
-$tmp = dbassoc(dbquery("SHOW COLUMNS FROM " . TABLEPREFIX . "fanfiction_news LIKE 'time'"));
-
-if ($tmp['Type'] == "datetime")
-{
- dbquery("UPDATE " . TABLEPREFIX . "fanfiction_settings SET version = '3.5.5' WHERE sitekey = '" . SITEKEY . "'");
-}
-
-*/
-