<?
# Slashster: Open Source Friend of a Friend Software
# Copyright 2004 Mark El-Wakil
# Contact: hide@address.com
# http://seventhcycle.net
#
# This file is part of Slashster.
#
# Slashster is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# Slashster 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.
#
# You should have received a copy of the GNU General Public License
# along with Slashster; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
import_request_variables("gPc");
require("PageClass.php");
$mpage = new PageClass("authonly");
$mpage->MembersOnly();
$mpage->VerifiedOnly();
$mpage->Initialize("authremainder");
if ($submit)
{
$level = $mpage->UserDistance($id);
if ($level == -1)
{
echo "This person is not in your network of friends";
$mpage->ClosePage();
}
$subject = (!trim($subject)) ? "(Untitled Message)" : trim($subject);
$txt = trim($txt);
$_POST[preview] = 1;
$preview = 1;
if (!strlen($txt))
{
echo "<font color=red><b>Your message is empty.</b><P>";
}
else
{
$txt = stripslashes($txt);
$mpage->MailSchedule($mpage->IdNum, $id, stripslashes($subject), $txt, 0, 0, 1, "encrypt");
$body = stripslashes($txt);
$body = $mpage->bbc($body);
$body = addslashes($body);
$subject = stripslashes($subject);
$subject = strip_tags($subject);
$subject = addslashes($subject);
$encrypt = ($encrypt) ? 1 : 0;
$encrypt = ($mpage->sys[SSL]) ? $encrypt : 0;
if ($encrypt)
{
$ke = $mpage->user[PublicKey];
$body = stripslashes($body);
openssl_public_encrypt($body, $body, $ke);
$body = base64_encode($body);
}
$sql = "insert into PrivateMessage set Start=$mpage->IdNum, End=$id,
Owner=$mpage->IdNum, Folder=".$mpage->user[DefMailOutg].",
New=0, Subject=\"$subject\", Body=\"$body\", DateSent=NOW(), Expires=0,
Notify=0, Encrypted=\"$encrypt\"
";
$mpage->DoQuery($sql);
if ($repid)
{
$sql = "update PrivateMessage set Answered=1 where Owner=$mpage->IdNum
AND Id = \"$repid\" ";
$mpage->DoQuery($sql);
}
?>
<BR><table width=600 align=center><tr><td>
<p class="title1">Mail Sent!<P>
<P><a href="messages.php">Go Back to your messages</a>
</td></tr></table><BR><BR>
<?
$mpage->ClosePage();
}
}
?>
<table width=100% height=500 border=1 cellspacing=0 cellpadding=0>
<tr>
<td width=560>
<div style="height:500px; width=100%; overflow:auto;">
<?
if ($preview)
{
PreviewText();
Form();
}
else
{
Form();
}
?>
</div>
</td>
<td width=200>
<div style="height:500px; width=100%; overflow:auto;">
<?
if ($preview)
{
PreviewWarning();
}
else
{
Rules();
}
?>
</div>
</td>
</tr>
</table>
<?
$mpage->ClosePage();
function PreviewText()
{
global $mpage, $id;
$sql = "select * from UserTable where Id = '$id' ";
$r = $mpage->DoQuery($sql,1);
$r = $r[0];
$to = $r[Fname] . " " . substr($r[Lname],0,1);
$txt2 = stripslashes($_POST[txt]);
$txt2 = $mpage->bbc($txt2);
?>
<BR>
<table width=95% class="stdtable" align=center>
<tr><td colspan=2 style="font: bold 14px;">Message Preview
<BR><BR>
</td></tr>
<tr><td width=75>Date:</td>
<td><?= date("F d, Y h:i:a") ?></td>
</tr>
<tr><td width=75>
To:
</td>
<td><a target=_blank class="stdtxt" href="user.php?id=<?= $id ?>"><?= $to
?></a></td>
</tr>
<tr><td width=75>Subject:</td>
<td><?= htmlentities($_POST[subject]) ?></td>
</tr>
</table>
<BR>
<table width=95% align=center><tr><td class="stdaltfilling">
<?
$txt2 = stripslashes($_POST[txt]);
$txt2 = $mpage->bbc($txt2);
echo $txt2;
?>
</td></tr></table>
<BR>
<hr color=black width=95%>
<? }
function Form()
{
global $mpage, $id;
if (($_POST[subject] == "") && ($_GET[subj])) $_POST[subject] = $_GET[subj];
$replyid = $_POST[replyid];
if ($_POST[reply])
{
$sql = "select PrivateMessage.*, UserTable.Fname, UserTable.Lname, UNIX_TIMESTAMP(DateSent) as UT
from PrivateMessage
left join UserTable on PrivateMessage.Start = UserTable.Id
where Owner = '$mpage->IdNum' AND PrivateMessage.Id = '$replyid' ";
$r = $mpage->DoQuery($sql,1);
if (sizeof($r))
{
$r = $r[0];
$txt2 = stripslashes($r[Body]);
$txt2 = $mpage->bbc($txt2);
$txt2 = trim(strip_tags($txt2));
if (!$r[Encrypted])
{
$msg .= "\n\n\n";
$msg .= "On ".date("D, d M Y h:i:s:a",$r[UT]).", ".$r[Fname] . " " . substr($r[Lname], 0,1)." wrote:";
$msg .= "\n----------------------------------\n\n";
$ng = split("\n", $txt2);
$msg .= "> " . join("> ", $ng);
$_POST[txt] = $msg;
}
$_POST[subject] = "Re: " . $r[Subject];
$_POST[to] = $r[Login];
$_POST[repid] = $r[Id];
$id = $r[Start];
}
}
$level = $mpage->UserDistance($id);
if ($level == -1)
{
echo "This person is not in your network of friends";
$mpage->ClosePage();
}
$sql = "select * from UserTable where Id = $id";
$rg = $mpage->DoQuery($sql,1);
$rg = $rg[0];
?>
<form name="newthread" method="post" action="composemessage.php">
<input name="id" value="<?= $id ?>" type="hidden">
<center>
<? if ($_POST[preview]) { ?>
<input class=submit name = "preview" type = "submit" value = "Preview Post">
<input class=submit name="submit" type = "submit" value = "Submit Post">
<? } ?>
<? if ($_POST[repid]) { ?>
<input name="repid" value="<?= $_POST[repid] ?>" type=hidden>
<? } ?>
<table cellspacing=0 cellpadding=0 border=1><tr><td>
<BR><BR>
<table width=95% cellspacing=0 align=center>
<tr><td width=75 class="stdtable">Date:</td>
<td class="stdtable"><?= date("F d,Y h:i:a") ?></td>
<td class="stdtable" rowspan=3 width=90>
<img src="userpics/<?= $mpage->PicPr($rg[PicDefault], $rg[Id]) ?>-b.jpg">
</td>
</tr>
<tr><td width=75 class="stdtable">
To:
</td><td class="stdtable"><a
class="stdtxt" href="user.php?id=<?= $rg[Id] ?>">
<B><?= $rg[Fname] ?> <?= substr($rg[Lname], 0,1) ?></b></a>
<input type=hidden name = "to" style = "width:530px" maxlength=50 value="<?= $rg[Id] ?>">
</td>
</tr>
<tr><td class="stdtable" width=75>Subject:</td>
<td class="stdtable">
<input name = "subject" style = "width:200px" maxlength=50 value="<?=
htmlentities(stripslashes($_POST[subject])) ?>">
</td>
</tr>
<? if ($rg[AES] && ($mpage->sys[SSL]) ) { ?>
<tr><td width=75 class="stdtable" align=center>
<img src="images/padlock.gif">
</td>
<td class="stdtable" colspan=2><input name="encrypt" value=1 type="checkbox"
<?= ($_POST[encrypt]) ? "checked" : "" ?>>
Encrypt Message
</td>
</tr>
<? } ?>
</table>
<center>
<BR>
<a href = "bbcodeinfo.php"
target="_blank">How to submit images and hyperlinks using BBcode</a>
<textarea name = "txt" rows=20 style = "width:500px">
<?= htmlentities(stripslashes($_POST[txt])) ?>
</textarea>
<BR><BR>
<input class=submit name = "preview" type = "submit" value = "Preview Post">
<? if ($_POST[preview]) { ?>
<input class=submit name="submit" type = "submit" value = "Submit Post">
<? } ?>
</center>
</td></tr></table>
</center>
</form>
<? }
function Rules()
{ ?>
<BR>
<table border=1 width=100% cellspacing=0 cellpadding=0>
<form method=get>
<tr><td align=center class=stdtable>
<B>Compose a message</b>
</td></tr>
<tr><td align=left class="stdaltfilling">
<BR>
Just a couple notes when sending mail:
<ul>
<li> Be courteous!
<li> Be friendly!
<li> If you are going to ask a question, check to see that it already hasn't been answered.
</ul>
Have fun!
</td></tr>
</table>
<? }
function PreviewWarning()
{ ?>
<BR>
<table border=1 width=100% cellspacing=0 cellpadding=0>
<form method=get>
<tr><td align=center class="stdtable">
<B>Preview Page</b>
</td></tr>
<tr><td align=left class="stdaltfilling">
<BR>
Here is what your post will appear to the recipient.
You can now check your post for:
<ul>
<li>Spelling errors.
<li>Grammar.
<li>Anything you'd like to add to it.
</ul>
When your post is complete, hit submit. You will be taken to the spot where it is posted.
</td></tr>
</table>
<? }
?>