. */ include "inc.php"; ?> <?=$appname; ?> - Upload Results ERROR 1006: An error has occurred. Please contact the Help Desk for assistance.'; error_log('File upload filed, email addresses were incorrect.'); } else { if (isset($dirname)) { $dnldpass = addslashes($dirname); $filesrc = $fullfile; $filename = utf8_encode(addslashes($File1)); $method = 'ftp'; } else { // Generate a download code $dnldpass = addslashes(substr(md5(uniqid(rand(),1)),0,8)); $filesrc = $_FILES['File1']['tmp_name']; $filename = utf8_encode(addslashes(basename($_FILES['File1']['name']))); $filesize = $_FILES['File1']['size']; $method = 'http'; } // Test for failed HTTP upload; if (!isset($dirname) && $_FILES['File1']['error'] != 0) error_log(stripslashes($dnldpass) . ": Upload error (" . $UPLOADERRORS[$_FILES['File1']['error']] . ")"); // If transferred via HTTP or if the file is less than 2GB (2000000000 bytes), move the file; $ok=0; if ($method == 'http' || $filesize < 1900000000) { $uploadfile = $fpath . '/' . stripslashes($dnldpass) . '/' . $filename; $tmp = mkdir("$fpath/$dnldpass"); error_log($dnldpass . ": Moving $filesrc to $uploadfile"); if ($method == 'http' && move_uploaded_file($filesrc, $uploadfile)) $ok=1; elseif ($method == 'ftp' && rename($filesrc,$uploadfile)) { // Move file and remove ftp directory; $ok=1; rmdir($ftppath . stripslashes($dnldpass)); } else { $dismsg = 'An error occurred with your file upload. Please try again.'; if ($method == 'http') $dismsg .= '

Upload error: (' . $UPLOADERRORS[$_FILES['File1']['error']] . ')'; $ok = 0; } $method = 'http'; // Force this to HTTP before database insert so the download URL is correct; } elseif ($method == 'ftp') { // What to do if method was ftp and file larger than 2gb; // Leave file where it is; $ok = 1; } // Generate the modification code; $modpass = addslashes(substr(md5(uniqid(rand(),1)),0,8)); if ($ok == 1) { error_log(stripslashes($dnldpass) . ": Successfully uploaded file:" . $filename); // insert data into sql database; $query = 'insert into Sessions (indate, outdate, avail, srcemail, destemail, dnldcode, modcode) values ("' . $mydate . '", "' . ${'date' . $AvailabilityPeriod} . '", "' . $AvailabilityPeriod . '", "' . $YourEmail . '", "' . $DestinationEmail . '", "' . $dnldpass . '", "' . $modpass . '")'; $res = mysql_query($query,$dbh) or die('

A fatal database error occured.\n
Query: ' . $query . '
\nError: (' . mysql_errno() . ') ' . mysql_error()); // get the session id the sql database just created; $sessid = mysql_insert_id(); $query2 = 'insert into Files (name, description, method, sessionid, size) values ("' . $filename. '", "' . utf8_encode(addslashes($File1Description)) . '","' . $method . '", ' . $sessid . ', ' . $filesize . ');'; $res2 = mysql_query($query2,$dbh) or die('

A fatal database error occured.\n
Query: ' . $query2 . '
\nError: (' . mysql_errno() . ') ' . mysql_error()); // get the availability period (nice looking one); $query3="select * from Availability where short=\"$AvailabilityPeriod\""; $res3 = mysql_query($query3,$dbh) or die('

A fatal database error occured.\n
Query: ' . $query3 . '
\nError: (' . mysql_errno() . ') ' . mysql_error()); $row3 = mysql_fetch_row($res3); $availability = $row3[2]; // get the file id the sql database just created; $fileid = mysql_insert_id(); if ($savehistory) { // record file upload into History table; insert_history_entry('upload', $fileid, $sessid); } $dstheader = $utf8mailhdr . 'From: ' . stripslashes($YourEmail) . "\r\n"; $dstheader .= 'Reply-To: ' . stripslashes($YourEmail); $dstmsg = 'A file has been made available for you to download.

'; $dstmsg .= 'Filename: ' . utf8_encode($filename) . '
'; $dstmsg .= 'Size: ' . round($filesize / 1024 / 1024, 2) . ' MB
'; $dstmsg .= 'Availability: ' . $availability . '
'; $dstmsg .= 'Description: ' . utf8_encode($File1Description) . '
'; $dstmsg .= 'Download Code: ' . stripslashes($dnldpass) . '

'; $dstmsg .= 'Click here to download the file

'; $dstmsg .= 'If the download link above doesn\'t work for you, use the download code above on the ' . $appname . ' download page.'; mail(stripslashes($DestinationEmail), utf8_encode($filename) . ' ready for download at ' . $companyname, $dstmsg, $dstheader) or die("Could not send receiver email."); $srcheader = $utf8mailhdr . 'From: ' . $ehmailaddr . "\r\n"; $srcheader .= 'Reply-To: ' . $ehmailaddr; $srcmsg = 'The file you uploaded is ready for download.

'; $srcmsg .= 'Filename: ' . utf8_encode($filename) . '
'; $srcmsg .= 'Size: ' . round($filesize / 1024 / 1024, 2) . ' MB
'; $srcmsg .= 'Availability: ' . $availability . '
'; $srcmsg .= 'Description: ' . utf8_encode($File1Description) . '
'; $srcmsg .= 'Download Code: ' . stripslashes($dnldpass) . '
'; $srcmsg .= 'Modification Code: ' . stripslashes($modpass) . '

'; $srcmsg .= 'Download: Click here to download the file
'; $srcmsg .= 'Delete: Click here to DELETE the file
'; $srcmsg .= 'To modify the file description, availability period or delete the file, use the modification code above and go to: ' . $proto . '://' . $servername . '/download.php?mod=1'; mail(stripslashes($YourEmail), utf8_encode($filename) . ' uploaded at ' . $companyname, $srcmsg, $srcheader) or die("Could not send sender email."); $dismsg = 'Your file was uploaded successfully.'; } else { error_log(stripslashes($dnldpass) . ": File upload failed for:" . $filename); } } ?>