<?php

if ( ! @include_once( './mainfile.php' ) ) { exit( '!! INCLUDE ERROR. ACCESS DENIED !!' ); }
error_reporting( _E_VALUE );


/* vim: set expandtab tabstop=4 shiftwidth=4: */
// +----------------------------------------------------------------------+
// | myPHPNuke Version 188_8 RC2                                          |
// +----------------------------------------------------------------------+
// | License: GNU/GPL - http://www.gnu.org/copyleft/gpl.html              |
// +----------------------------------------------------------------------+
// | Support: http://myphpnuke.com/                                       |
// +----------------------------------------------------------------------+
// | Author: myPHPNuke Dev Team                                           |
// +----------------------------------------------------------------------+
// | Copyright: © 2001-2004 myPHPNuke Dev Team                            |
// +----------------------------------------------------------------------+
// $Id: compose.php,v 1.15.2.3 2004/08/01 17:04:16 kirilt Exp $



/*************************************************************************/
 #  Mailbox 0.9.2a   by Sivaprasad R.L (http://netlogger.net)              #
 #                                                                        #
 #          --  A pop3 client addon for phpnuked websites --              #
 #                                                                        #
 # 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.                           #
 #                                                                        #
 # You should have received a copy of the GNU General Public License      #
 # along with this program; if not, write to the Free Software            #
 # Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.              #
 #                                                                        #
 #             Copyright (C) by Sivaprasad R.L                            #
 #                                                                        #
/*************************************************************************/

    if ( ! _MPN_USER )
    {
        goBack( translate( 'You Are Not Logged In' ) );
        exit;
    }

    $tmp = cookiedecode();
    $uid = $tmp[0];
    unset( $tmp );

    $index = 2;

    include "./header.php";
    include "./mailheader.php";

    global $to, $subject, $body, $op, $bgcolor2;

    $body = stripslashes($body);
    $to = stripslashes($to);
    $subject = stripslashes($subject);

    $content = null;

    if(isset($op)) {
        if($op == "reply") $subject = translate("Re: ") . $subject;
        else if($op == "forward") $subject = translate("Fwd: ") . $subject;
        if(eregi($body, "<br>", $out)) {
            $bodytext = explode("<br>", $body);
            foreach($bodytext as $bt) {
                $content .= "> ".$bt;
            }
        } else {
            $bodytext = explode("\n",$body);
            foreach($bodytext as $bt) {
                $content .= "> ".$bt."\n";
            }
        }
    }

    if ( empty( $content ) ) { $content = ''; }

    $win_page = 'mail_attach.php';
    $win_name = 'Upload';
    $win_para = 'width=350, height=400, toolbar=0, location=1, directories=0, status=0, scrollbars=1, resizable=1, copyhistory=0';
    $text = translate( 'Click To Upload Your Attachments' );

    $link = "<a class='subtitle1' href=\"javascript: popWindow( '{$win_page}', '{$win_name}', '{$win_para}' );\" title='$text'>$text</a>\n";

OpenTable();

echo "<div class='tabletitles'>\n";

    echo translate( 'Sending Email Restrictions And Requirements' );

echo "</div>\n";

echo "<ul>\n";

    echo "<li>\n";

        echo translate( 'Separate Multiple Addresses With A Comma' );
    echo "</li><li>\n";

        echo translate( 'You May Send Mail To A Maximum Of Ten Addresses' );

    echo "</li><li>\n";

        echo translate( 'If Attachments Are Required, Please Upload First' ) . '<br />&nbsp;&nbsp;&nbsp;' . translate( 'Or You Will Lose Your Mail Message' );

    echo "</li><li>\n";

        echo translate( '<b>Allowed Attachments:</b> jpg, gif, html, htm, txt' );

    echo "</li><li>\n";

        echo translate( 'All Attachments Are Subject To Sanitizing' );

    echo "</li><li>\n";

        echo translate( 'All Non-Image Attachments Will Be Sent As A Text File' );

    echo "</li><li>\n";

        echo translate( 'You May Attach A Maximum Of Five Files' );

    echo "</li><br />\n";

echo "</ul>\n";

CloseTable();

echo "<br /><br />\n";

echo "<div class='center'>\n";

    echo $link;

echo "</div>\n";

echo "<br /><br />\n";

?>

<FORM METHOD="POST" ACTION="nlmail.php" name=emailform>

<TABLE align=center width=100% border=0>
<TR><TD class="label"> <?php echo translate("To") ?> :<br /><input type=text name="to" size=47  maxlength="250" value='<?php echo $to ?>'></TD></TR>
<TR><TD class="label"> <?php echo translate("Subject") ?> :<br /><input type=text name="subject" size=47 value='<?php echo $subject ?>'></TD></TR>
<TR><TD class="label"><i><?php echo translate("cc") ?></i>:&nbsp;&nbsp;&nbsp;<input type=text name="cc" size=20 maxlength="250"><br /><br />
<i class="label"><?php echo translate("bcc") ?></i>: <input type=text name="bcc" size=20 maxlength="250"></TD></TR>

<TD class="label"><?php echo translate("Priority") ?> : <select name="prior">
<option value="1"> <?php echo translate("High") ?> </option>
<option value="3" selected>  <?php echo translate("Normal") ?> </option>
<option value="4"> <?php echo translate("Low") ?> </option>
</select>
</TD>
</TR><TR><TD class="label"> <?php echo translate("Message") ?> :<br />

<TEXTAREA NAME="message" ROWS=20 COLS=70 WRAP=virtual><?php echo $content ?></TEXTAREA>
</TD></TR>
<tr><td colspan=2><hr></td></tr>

<?php

$allowed_files = array( 'jpg', 'gif', 'txt', 'htm', 'html' );
$attachment = array();
$dir_content = array();

$dir_content = $_SERVER['F_LIB'] -> dirContents( _DP_MAIL_ATTACH, $allowed_files );

echo "<tr><td colspan='2'>\n";
echo "<b>" . translate( 'You Have Attached The Following Files' ) . ":</b>\n";

echo "<br /><br />\n";

if ( is_array( $dir_content ) && sizeof( $dir_content ) > 0 )
{
    foreach( $dir_content AS $key => $v )
    {
        if ( (bool)FALSE !== strpos( $v, $uid ) )
        {
            $filename = NULL;

            if ( $key <= 4 )
            {
                $name_start = strpos( $v , '_' ) + 1;
                $name_end   = strrpos( $v , '_' );
                $filename   = substr( $v,  $name_start, ( $name_end - $name_start ) );
            }
            else
            {
                @unlink( _DP_MAIL_ATTACH . $v );
            }

            if ( ! empty( $filename ) )
            {
                echo "<input type='checkbox' name='$filename' value='$key' checked='checked'/>\n";
                echo "&nbsp;\n";
                echo "<span class='label'>$filename</span>\n";

                echo "<br /><br />\n";

                echo "<span class='font4'>\n";

                    echo "<em class='look'>&#042;&nbsp;</em>\n";
                    echo translate( 'To remove a file from this mail, uncheck the checkbox' );

                echo "</span>\n";
            }
        }
    }
}
else
{

    echo '<b>' . translate( 'No Attached Files' ) . '</b>';
    echo "<br />\n";
}


echo "<br /><hr /></td></tr>\n";

?>
<tr><td colspan=2></td></tr>
<TD><INPUT class='button' TYPE="submit" name="send" VALUE="<?php echo translate("Send Message") ?>">
</TD><TD>

<?php

    echo "<input type='hidden' name='stripit_form' value='to|subject|cc|bcc|prior|message' />\n";
    echo "<input type='hidden' name='mpn_sectype' value='1' />\n";
?>

<INPUT class='button' TYPE="reset" VALUE="<?php echo translate("Clear All") ?>"></TD></TR>
</TABLE>
</center>

</FORM>

<?php

include "mailfooter.php";

?>
