Hi, ive recently been using php-nuke, and needed a little extra help with the webmail script so came to the place I know where I can get some good help.
The problem im having with the script is to add attachments to composed emails, this works by clicking a link in the compose file and this opens another window that you can browse and attach the file. The problem is after selcting the file and click attach, the file disapears but is not attached to the compose file or in the tmp directory. Ive checked the relevent tmp directory is CHMOD 777,
Can anyone suggest anything, the scripts are below
cheers in advance
Andy
There are two files that do this operation, the first is to compose file and the second the attach script this is below:
----compose----
<?php
***************************************************************/
if (!eregi("modules.php", $_SERVER['PHP_SELF'])) {
die ("You can't access this file directly...");
}
require_once("mainfile.php");
$module_name = basename(dirname(FILE));
get_lang($module_name);
if ($email_send == 1) {
if(!isset($user)) {
Header("Location: modules.php?name=Your_Account");
exit();
}
$user2 = base64_decode($user);
$userdata = explode(":", $user2);
$userid = $userdata[0];
$numrows = sql_num_rows(sql_query("select * from ".$prefix."_popsettings where uid='$userid'", $dbi), $dbi);
if ($numrows == 0 OR $numrows == "") {
Header("Location: modules.php?name=$module_name");
}
$pagetitle = "- "._COMPOSEEMAIL."";
include ("header.php");
include ("modules/$module_name/mailheader.php");
$body = stripslashes($body);
$to = stripslashes($to);
$subject = stripslashes($subject);
if(isset($op)) {
if($op == "reply") $subject = "Re: ".$subject;
else if($op == "forward") $subject = "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";
}
}
}
title(""._COMPOSEEMAIL."");
OpenTable();
if (ini_get(file_uploads) AND $attachments == 1) {
echo "<script language=\"javascript\">\n"
."function open_w(file) {\n"
." newwin = window.open(file,'Attachments','width=450, height=250, scrollbars=no, toolbar=no');\n"
."}\n"
."\n"
."function attachfiles(files,types) {\n"
." window.document.all.Atts.innerText = files;\n"
." document.emailform.attachment.value = files;\n"
." document.emailform.attchtype.value = types;\n"
."}\n"
."</script>\n";
}
echo "<b>".SENDANEMAIL."</b><br><br>"
."<form method=\"post\" action=\"modules.php?name=$module_name&file=nlmail\" name=\"emailform\">"
."<table align=\"center\" width=\"98%\">"
."<tr><td>".TO.":</td><td width=100%><input type=text name=\"to\" size=47 value='$to'></td></tr>"
."<tr><td> </td><td><font class=\"tiny\"><i>".SEPARATEEMAILS."</i></font></td></tr>"
."<tr><td>".SUBJECT.":</td><td><input type=text name=\"subject\" size=47 value='$subject'></td></tr>"
."<tr><td><i>Cc:</i></td><td><input type=text name=\"cc\" size=20> <i>Bcc:</i> <input type=text name=\"bcc\" size=19></td></tr>"
."<tr><td>".PRIORITY.":</td><td><select name=\"prior\">"
."<option value=\"1\">".HIGH."</option>"
."<option value=\"3\" selected>".NORMAL."</option>"
."<option value=\"4\">".LOW."</option>"
."</select>"
."</td>"
."</tr>"
."<tr><td><br>"._MESSAGE.":</td></tr>"
."<tr><td colspan=\"2\">"
."<textarea name=\"message\" rows=\"15\" cols=\"70\" wrap=\"virtual\">$content</textarea>"
."</td></tr>";
if (ini_get(file_uploads) AND $attachments == 1) {
echo "<tr><td colspan=2>";
OpenTable();
echo "".ATTACHMENTS.": <span style=\"background-color:#ffffcc\" id=\"Atts\">".NONE."</span> <br><br><a href=\"javascript: open_w('modules/$module_name/mailattach.php')\">"._CLICKTOATTACH."</a><br>";
CloseTable();
}
echo "<tr><td colspan=\"2\">"
."<input type=\"submit\" name=\"send\" value=\"".SENDMESSAGE."\"> <input type=\"reset\" value=\"".CLEARALL."\">"
."</td></tr>"
."</table>"
."</center>"
."<input type=hidden name=\"attachment\">"
."<input type=hidden name=\"attchtype\">"
."</form>";
Closetable();
include ("modules/$module_name/mailfooter.php");
} else {
Header("Location: modules.php?name=$module_name");
exit();
}
?>
----compose finish------
-----------------mailattach-------------
<?php
include("../../config.php");
if (isset($userfile) AND $userfile != "none" AND !ereg("/", $userfile) AND !ereg("..", $userfile) AND !ereg("%", $userfile)) {
if (ini_get(file_uploads) AND $attachments == 1) {
$updir = "tmp";
@copy($userfile, "$updir/$userfile_name");
@unlink($userfile);
}
}
echo "<html>\n"
."<title>$sitename: Attach Files</title>\n"
."<body text=\"#63627f\">\n"
."<form action=\"mailattach.php\" method=\"post\" ENCTYPE=\"multipart/form-data\" name=\"attchform\">\n"
."<center>\n"
."<b>Attach Files</b><br><br>\n"
."File: <input type=\"file\" name=\"userfile\"> <input type=\"submit\" value=\"Attach File\">\n"
."</center>\n"
."</form>\n"
."</body>\n"
."</html>";
?>