//Libraries used for text posting//
include_once "libraries/lib_utilities.php";
include_once "libraries/lib_forms-generators.php";
include_once "libraries/lib_addstory.php";
include_once "libraries/lib_addupdatechap.php";
include_once "libraries/lib_removestory.php";
?>
//=============== AuthorAlertDisplay ==================
function addAuthorAlert_disp() {
@readfile("../data/templates/userconsole/addauthoralert.html");
}//end addAuthorAlert_disp()
//=============== Delete AuthorAlert Display ==========
function deleteAuthorAlert_disp() {
$query="SELECT * FROM AuthorAlerts INNER JOIN UserInfo ON AuthorAlerts.AuthorID=UserInfo.UserID WHERE AuthorAlerts.UserID=$_SESSION[id]";
$result=myquery($query) or errormsg("$query");
while ($ReaderInfo=mysql_fetch_array($result, MYSQL_ASSOC))
$selections.="\n\r";
if (str_clean($selections) == "")
$selections=""; //No author alerts currently available for deletion
fileparser("../data/templates/userconsole/deleteauthoralert.html", "//", $selections);
}//end deleteAuthorAlert_disp()
//=============== addAuthorAlert ======================
function addAuthorAlert($postdata)
{
if (!is_numeric($postdata["wid"])) {
if (!$errors)
errormsg_internal("Author ID #", "The author ID # you entered is not currently valid. Please enter a different ID #");
$errors=true;
}//if the author id they entered isn't a number
if (!$errors) {
$query="SELECT COUNT(UserID) AS UserNumber FROM UserInfo WHERE UserID=".str_clean($postdata["wid"]);
$result=myquery($query) or errormsg("$query");
$ainfo=mysql_fetch_array($result, MYSQL_ASSOC);
//See if the user's email is currently up to date
$query="SELECT COUNT(AuthorID) AS UserNumber FROM AuthorAlerts WHERE AuthorID=".str_clean($postdata["wid"])." AND UserID=$_SESSION[id]";
$result=myquery($query) or errormsg("$query");
$alrtinfo=mysql_fetch_array($result, MYSQL_ASSOC);
}//don't perform these queries if its not a numeric entry
if ($ainfo["UserNumber"]==0)
{
if (!$errors)
errormsg_internal("Author ID #", "The author ID # you entered is not currently valid. Please enter a different ID #");
$errors=true;
}//if the author doesn't exist under that ID #
if ($alrtinfo["UserNumber"] >=1)
{
if (!$errors)
errormsg_internal("Author Alert", "You already have an Author Alert for this Author. Please enter the UserID of a different Author.");
$errors=true;
}//if they already have an alert for this author
if ($postdata["wid"] == $_SESSION["id"])
{
if (!$errors)
errormsg_internal("Author Alert", "You CANNOT add an author alert for YOURSELF.");
$errors=true;
}//if they are trying to add themselves
if ($errors)
addAuthorAlert_disp();
else
{
$Aaquery="INSERT INTO AuthorAlerts (UserID, AuthorID) VALUES ($_SESSION[id], $postdata[wid])";
myquery($Aaquery) or errormsg("$Aaquery");
finishpage("Congratulations, the Author Alert has been successfully Added!");
}//if there's no errors
}//end addAuthorAlert
//=============== deleteAuthorAlert ====================
function deleteAuthorAlert($postdata)
{
//Check for User Mistakes/errors/stupidity
if ($postdata["wid"] == array() || $postdata["wid"] == "")
{
errormsg_internal("Author Alert", "You Need to Select an Author Alert to Remove");
deleteAuthorAlert_disp();
return;
}//If the user didn't select anything
if (!is_numeric($postdata["wid"][0]))
{
errormsg_internal("Author Alert", "You Need to Select an Author Alert to Remove");
deleteAuthorAlert_disp();
return;
}//If the user didn't select anything
//If there was correct usage, go and remove the author alerts
foreach($postdata["wid"] as $UserID) {
$query="DELETE FROM AuthorAlerts WHERE UserID=$_SESSION[id] AND AuthorID=$UserID";
myquery($query) or errormsg("$query");
}//remove each entry
finishpage("Congratulations, the Author Alert(s) have been successfully deleted.");
}//end delete authoralert
// =================================== END OF USER CONTROL FUNCTIONS ========================
//Send alert sends alert messages for the readers
function sendAuthorAlert($AlertEntry, $is_fanfic, $info=array())
{
$alertbody=""; //Initialize the string.
//If there's no Readers to Alert, drop out
//====== Get my Email address =============
if (is_array($AlertEntry))
foreach($AlertEntry as $Alert)
$alertbody.="\r".generateAlertMessage($Alert, $is_fanfic, array_shift($info)); //if its multiple alerts, to save on email traffic.
else
$alertbody=generateAlertMessage($AlertEntry, $is_fanfic, $info); //if its only a single.
if (trim($alertbody) == null || trim($alertbody) == "")
return;
//$_SESSION["username"]
$message="
Dear Reader(s),
Your Author, ".$_SESSION["username"].",
has posted/update the following pieces:
$alertbody
";
$query="SELECT UserID FROM AuthorAlerts WHERE AuthorAlerts.AuthorID=$_SESSION[id]";
$result=myquery($query) or errormsg("$query");
$query="INSERT INTO PrivateMessages (MailSenderID, MailRecipientID, MailSubject, MailBody, DateSent)
VALUES ";
while ($UserInfo=mysql_fetch_array($result, MYSQL_ASSOC))
$query.="($_SESSION[id], $UserInfo[UserID], '".addslashes($_SESSION["username"]." has Posted New Material!")."', '".addslashes($message)."',
'".addslashes(date("M d, Y G:i:sA"))."'),\n";
$query=substr($query, 0, -2);
if (mysql_num_rows($result) > 0)
myquery($query) OR errormsg($query);
}//end send author alerts
function generateAlertMessage($storyID, $is_fanfic, $info=array())
{
global $HTTPHOST;
if (isset($storyID) && is_numeric($storyID) && $info != array())
{
$AlertMsg="
Title: ".$info["StoryTitle"]."
Rated: ".$info["Rating"]."
Genre: ".$info["Genre"]."
Description: \n\n\r\r".$info["Description"]."\r\n";
if ($info["DatePosted"] == $info["DateUpdated"])
$AlertMsg .= "\r\nPosted: ".date("m/d/Y h:i:sa",$info["DatePosted"]);
else
$AlertMsg .= "\r\nUpdated: ".date("m/d/Y h:i:sa",$info["DateUpdated"]);
if ($is_fanfic)
$AlertMsg .="\n\rThis story can be viewed at the following URL:\n\rhttp://$HTTPHOST/view.php?storyid=$storyID";
else
$AlertMsg .="\n\rThis story can be viewed at the following URL:\n\rhttp://$HTTPHOST/view.php?pictureid=$storyID";
}//if its working properly
else
return null;
return $AlertMsg;
}//end line generator
?>
//=============== AuthorAlertDisplay ==================
function addViewer_disp() {
@readfile("../data/templates/userconsole/addviewer.html");
}//end addAuthorAlert_disp()
//=============== Delete AuthorAlert Display ==========
function deleteViewer_disp() {
$query="SELECT * FROM PrivateViewers INNER JOIN UserInfo ON PrivateViewers.ViewerID=UserInfo.UserID WHERE PrivateViewers.UserID=$_SESSION[id]";
$result=myquery($query) or errormsg("$query");
while ($ReaderInfo=mysql_fetch_array($result, MYSQL_ASSOC))
$selections.="\n\r";
if (str_clean($selections) == "")
$selections=""; //No author alerts currently available for deletion
fileparser("../data/templates/userconsole/deleteviewer.html", "//", $selections);
}//end deleteViewer_disp()
//=============== addAuthorAlert ======================
function addViewer($postdata)
{
$query="SELECT COUNT(UserID) AS UserNumber FROM UserInfo WHERE UserID=".str_clean($postdata["wid"]);
$result=myquery($query) or errormsg("$query");
$ainfo=mysql_fetch_array($result, MYSQL_ASSOC);
//See if the user's email is currently up to date
$query="SELECT COUNT(ViewerID) AS UserNumber FROM PrivateViewers WHERE ViewerID=".str_clean($postdata["wid"])." AND UserID=$_SESSION[id]";
$result=myquery($query) or errormsg("$query");
$alrtinfo=mysql_fetch_array($result, MYSQL_ASSOC);
$errors=false;
if ($ainfo["UserNumber"]==0)
{
if (!$errors)
errormsg_internal("Viewer ID #", "The viewer ID # you entered is not currently valid. Please enter a different ID #");
$errors=true;
}//if the author doesn't exist under that ID #
if ($alrtinfo["UserNumber"] >=1)
{
if (!$errors)
errormsg_internal("Authorized Viewer", "You already have authorized this viewer. Please enter the UserID of a different user.");
$errors=true;
}//if they already have an alert for this author
if ($postdata["wid"] == $_SESSION["id"])
{
if (!$errors)
errormsg_internal("Authorized Viewer", "You CANNOT add YOURSELF.");
$errors=true;
}//if they are trying to add themselves
if ($errors)
addViewer_disp();
else
{
$Aaquery="INSERT INTO PrivateViewers (UserID, ViewerID) VALUES ($_SESSION[id], $postdata[wid])";
myquery($Aaquery) or errormsg("$Aaquery");
finishpage("Congratulations, the Reader has been successfully Authorized!");
}//if there's no errors
}//end addAuthorAlert
//=============== deleteAuthorAlert ====================
function deleteViewer($postdata)
{
//Check for User Mistakes/errors/stupidity
if ($postdata["wid"] == array() || $postdata["wid"] == "")
{
errormsg_internal("Authorized Viewer", "You Need to Select an Viewer to Remove");
deleteViewer_disp();
return;
}//If the user didn't select anything
if (!is_numeric($postdata["wid"][0]))
{
errormsg_internal("Authorized Viewer", "You Need to Select an Viewer to Remove");
deleteAuthorAlert_disp();
return;
}//If the user didn't select anything
//If there was correct usage, go and remove the author alerts
foreach($postdata["wid"] as $UserID) {
$query="DELETE FROM PrivateViewers WHERE UserID=$_SESSION[id] AND ViewerID=$UserID";
myquery($query) or errormsg("$query");
}//remove each entry
finishpage("Congratulations, the Viewer(s) have been successfully removed from the list.");
}//end delete authoralert
// =================================== END OF USER CONTROL FUNCTIONS ========================
?>
//=============== Delete Favorites Display ==========
function del_favorites_disp() {
$stories="";
$authors="";
$query="
(SELECT Favorites.FavoriteID, UserInfo.UserName AS Title, UserInfo.UserEmail AS PartOfStoryID, Favorites.ReviewType FROM Favorites INNER JOIN UserInfo ON Favorites.ReviewItem=UserInfo.UserID WHERE Favorites.UserID=$_SESSION[id] AND Favorites.ReviewType='AUTHOR')
UNION
(SELECT Favorites.FavoriteID, FanFics.StoryTitle AS Title, FanFics.PartOfStoryID, Favorites.ReviewType FROM Favorites INNER JOIN FanFics ON Favorites.ReviewItem=FanFics.StoryID WHERE Favorites.UserID=$_SESSION[id] AND Favorites.ReviewType='STORY')
";
$result=myquery($query) or errormsg("$query");
while ($FavoriteInfo=mysql_fetch_array($result, MYSQL_ASSOC))
if ($FavoriteInfo["ReviewType"]=="STORY")
if ($FavoriteInfo["PartOfStoryID"] != NULL) {
$secquery="SELECT StoryTitle FROM FanFics WHERE StoryID=$FavoriteInfo[PartOfStoryID]";
$xtrainfo=mysql_fetch_array(myquery($secquery), MYSQL_ASSOC);
$stories.="\n\r";
}
else
$stories.="\n\r";
else
$authors.="\n\r";
if (str_clean($stories) == "")
$stories=""; //No favorite stories currently available for deletion
if (str_clean($authors) == "")
$authors=""; //No favorite authors currently available for deletion
fileparser("../data/templates/userconsole/deletefavorites.html", array("//", "//"), array($authors, $stories));
}//end del_favorites_disp()
//=============== deleteAuthorAlert ====================
function del_favorites($postdata)
{
if (!is_array($postdata["wid1"]) && !is_array($postdata["wid2"]))
$wid=array();
if (!is_array($postdata["wid1"]) && is_array($postdata["wid2"]))
$wid=$postdata["wid2"];
if (!is_array($postdata["wid2"]) && is_array($postdata["wid1"]))
$wid=$postdata["wid1"];
if (is_array($postdata["wid1"]) && is_array($postdata["wid2"]))
$wid=array_unique(array_merge($postdata["wid1"], $postdata["wid2"]));
/*
DebugLog("favoritescode.log",
"
\$postdata[wid1]
".print_r($postdata["wid1"], true)."
\$postdata[wid2]
".print_r($postdata["wid2"], true)."
\$wid
".print_r($wid), true);
*/
//Check for User Mistakes/errors/stupidity
if ($wid == array() || $wid == "")
{
errormsg_internal("Favorite(s)", "You Need to Select Favorite(s) to Remove");
del_favorites_disp();
return;
}//If the user didn't select anything
if ($wid[0]==0)
{
errormsg_internal("Favorite(s)", "You Need to Select Favorite(s) to Remove");
del_favorites_disp();
return;
}//If the user didn't select anything
//If there was correct usage, go and remove the author alerts
foreach($wid as $FavoriteID)
if ($FavoriteID != 0) {
$query="DELETE FROM Favorites WHERE UserID=$_SESSION[id] AND FavoriteID=$FavoriteID";
myquery($query) or errormsg("$query");
}//remove each entry
finishpage("Congratulations, the Favorites(s) have been successfully deleted.");
}//end delete favorites
//--------------- LoadJpeg ------------------------------------
function LoadJpeg($imgname)
{
$im = @imagecreatefromjpeg($imgname); /* Attempt to open */
if (!$im) { /* See if it failed */
$im = imagecreate(150, 30); /* Create a blank image */
$bgc = imagecolorallocate($im, 255, 255, 255);
$tc = imagecolorallocate($im, 0, 0, 0);
imagefilledrectangle($im, 0, 0, 150, 30, $bgc);
/* Output an errmsg */
imagestring($im, 1, 5, 5, "Error loading $imgname", $tc);
}
return $im;
}
function LoadGif ($imgname)
{
$im = @imagecreatefromgif ($imgname); /* Attempt to open */
if (!$im) { /* See if it failed */
$im = imagecreate (150, 30); /* Create a blank image */
$bgc = imagecolorallocate ($im, 255, 255, 255);
$tc = imagecolorallocate ($im, 0, 0, 0);
imagefilledrectangle ($im, 0, 0, 150, 30, $bgc);
/* Output an errmsg */
imagestring ($im, 1, 5, 5, "Error loading $imgname", $tc);
}
return $im;
}
//------------------- SaveImage -----------------------------
function SaveImage ($sourcefile, $dir, $filename)
{
GLOBAL $ARTFOLDER;
$width_max=700;
$thumb_x=80;
$thumb_y=80;
$quality=70;
if (baseext($sourcefile)=="jpg" || baseext($sourcefile)=="jpeg")
$image = LoadJpeg($sourcefile);
else
$image = LoadGif($sourcefile);
// Get new dimensions
$width=imagesx($image);
$height=imagesy($image);
if ($width > $width_max)
$percent=$width_max/$width;
else
$percent=1;
$new_width = $width * $percent;
$new_height = $height * $percent;
// Resample
$image_p = imagecreatetruecolor($new_width, $new_height);
@imagecopyresampled($image_p, $image, 0, 0, 0, 0, $new_width, $new_height, $width, $height);
$image_q = imagecreatetruecolor($thumb_x, $thumb_y);
@imagecopyresampled($image_q, $image, 0, 0, 0, 0, $thumb_x, $thumb_y, $width, $height);
// Output
if ($mimetype=="image/jpeg" || $mimetype=="image/pjpeg") {
@imagejpeg($image_q, "../$ARTFOLDER/_thumbs/TN$filename", $quality);
@imagejpeg($image_p, "../$ARTFOLDER/$dir/$filename", $quality);
}//if its a Jpeg
else {
@imagegif($image_q, "../$ARTFOLDER/_thumbs/TN$filename", $quality);
@imagegif($image_p, "../$ARTFOLDER/$dir/$filename", $quality);
}//if its a Gif
imagedestroy($image_p);
imagedestroy($image_q);
imagedestroy($image);
}//end SaveImage
//-- End the Library File
?>
Warning: Cannot modify header information - headers already sent by (output started at /var/www/fanworks-org/users/headers/authoralert.php:1) in /var/www/fanworks-org/users/user.php on line 23
Warning: session_start(): Cannot start session when headers already sent in /var/www/fanworks-org/users/user.php on line 55
TOS | Privacy Policy | Questions/Comments? | Found a bug? | Report violations of the TOS
Powered by E-FanWorks v3.9.9b © Null Referrence Software 2003-2006 The PDX Senpais 2020
![]()