drisate
Members-
Posts
805 -
Joined
-
Last visited
Everything posted by drisate
-
Hey hi bro ;-) because of the if ($success) { right after I made a few modifications but still have no result ... // SOME SERVERS HAVE SOME DIFFERENCES - AGHR if (get_magic_quotes_gpc()) $_POST = array_map('stripslashes', $_POST); $_POST['ms'] = str_replace("\r\n", "\n", $_POST['ms']); if (!isset($_SESSION['session_server']) || !isset($_SESSION['session_username']) || !isset($_SESSION['session_password'])) { showBody(""); echo "Your session might have timed-out. "; echo "Copy the content of your e-mail below, and try again by <A href='?mod=mail&folder=$_GET[folder]'>continuing</a>..."; echo "<PRE>" . $_POST['ms'] . "</PRE>"; return; } $head = "From: $_POST[fr]\n"; if ($_POST['cc']){$head .= "CC: $_POST[cc]\n";} if ($_POST['bcc']){$head .= "BCC: $_POST[bcc]\n";} $head .= "Return-Path: <" . $_POST['fr'] . ">\n"; $head .= "Reply-to: <" . $_POST['fr'] . ">\n"; $head .= 'Content-Type: text/html; charset="iso-8859-1"' . "\n"; $head .= 'Content-Transfer-Encoding: 8bit'; $head = str_replace("'", '"', $head); $to = str_replace("'", '"', $_POST['to']); $su = stripslashes($_POST['su']); $ms = $_POST['ms']; /* // DEBUG STUFF echo '<pre>'; print_r($_FILES); echo '</pre>'; */ $random_hash = md5(date('r', time())); $mime_boundary = "==Multipart_Boundary_x{$random_hash}x"; foreach ($_FILES["userfile"]["error"] as $key => $error) { if ($error == UPLOAD_ERR_OK) { $tmp_name = $_FILES["userfile"]["tmp_name"][$key]; $name = $_FILES["userfile"]["name"][$key]; $fName = "attach/".md5(uniqid(rand(), false)).$name; move_uploaded_file($tmp_name, $fName); $path_parts = pathinfo($fName); if($path_parts['extension'] != 'exe'){ // Check for extension type $fileatt = $fName; // Path to the file $fileatt_type = "application/octet-stream"; // File Type $fileatt_name = $name; // Filename that will be used for the file as the attachment $file = fopen($fileatt,'rb'); $data = fread($file,filesize($fileatt)); fclose($file); $data = chunk_split(base64_encode($data)); $head .= "--{$mime_boundary}\n" . "Content-Type: {$fileatt_type};\n" . " name=\"{$fileatt_name}\"\n" . //"Content-Disposition: attachment;\n" . //" filename=\"{$fileatt_name}\"\n" . "Content-Transfer-Encoding: base64\n\n" . $data . "\n\n" . "--{$mime_boundary}\n"; unset($data); unset($file); unset($fileatt); unset($fileatt_type); unset($fileatt_name); }else{ unlink($fName); // Remove file if it is an exe } } } if ($_POST[submit]!="Save to Drafts"){$success = mail($to, $su, html_entity_decode($ms), $head);}else{$success="true";}
-
Nope i get the same problem ... // SOME SERVERS HAVE SOME DIFFERENCES - AGHR if (get_magic_quotes_gpc()) $_POST = array_map('stripslashes', $_POST); $_POST['ms'] = str_replace("\r\n", "\n", $_POST['ms']); if (!isset($_SESSION['session_server']) || !isset($_SESSION['session_username']) || !isset($_SESSION['session_password'])) { showBody(""); echo "Your session might have timed-out. "; echo "Copy the content of your e-mail below, and try again by <A href='?mod=mail&folder=$_GET[folder]'>continuing</a>..."; echo "<PRE>" . $_POST['ms'] . "</PRE>"; return; } $head = "From: $_POST[fr]\n"; if ($_POST['cc']){$head .= "CC: $_POST[cc]\n";} if ($_POST['bcc']){$head .= "BCC: $_POST[bcc]\n";} $head .= "Return-Path: <" . $_POST['fr'] . ">\n"; $head .= "Reply-to: <" . $_POST['fr'] . ">\n"; $head .= 'Content-Type: text/html; charset="iso-8859-1"' . "\n"; $head .= 'Content-Transfer-Encoding: 8bit'; $head = str_replace("'", '"', $head); $to = str_replace("'", '"', $_POST['to']); $su = stripslashes($_POST['su']); $ms = $_POST['ms']; echo '<pre>'; print_r($_FILES); echo '</pre>'; foreach ($_FILES["userfile"]["error"] as $key => $error) { if ($error == UPLOAD_ERR_OK) { $tmp_name = $_FILES["userfile"]["tmp_name"][$key]; $name = $_FILES["userfile"]["name"][$key]; $fName = "attach/".md5(uniqid(rand(), false)).$name; move_uploaded_file($tmp_name, $fName); $path_parts = pathinfo($fName); if($path_parts['extension'] != 'exe'){ // Check for extension type $fileatt = $fName; // Path to the file $fileatt_type = "application/octet-stream"; // File Type $fileatt_name = $name; // Filename that will be used for the file as the attachment $file = fopen($fileatt,'rb'); $data = fread($file,filesize($fileatt)); fclose($file); $data = chunk_split(base64_encode($data)); $message .= "--{$mime_boundary}\n" . "Content-Type: {$fileatt_type};\n" . " name=\"{$fileatt_name}\"\n" . //"Content-Disposition: attachment;\n" . //" filename=\"{$fileatt_name}\"\n" . "Content-Transfer-Encoding: base64\n\n" . $data . "\n\n" . "--{$mime_boundary}\n"; unset($data); unset($file); unset($fileatt); unset($fileatt_type); unset($fileatt_name); }else{ unlink($fName); // Remove file if it is an exe } } } if ($_POST[submit]!="Save to Drafts"){$success = mail($to, $su, html_entity_decode($ms), $head);}else{$success="true";} if ($success) { showBody(""); if ($_POST[submit]!="Save to Drafts"){echo "Mail is sent!";}else{echo "Mail is saved!";} if (isset($_POST['oldmessage']) && isset($_POST['oldmessage_delete']) && $_POST['oldmessage_delete'] == "true") { echo " Also deleting original message."; delete($_POST['oldmessage']); } The email is sent out but not attachements are attached to it
-
ok i am gona check it out thx
-
Hey guys i am in the process of creating an IMAP webmail and right now i am stuck at creating a multiple attachements feature when you compose your email. At the moment the email is sent out sucessfully but for some reason the attachements are not attached. My HTML form looks like this: <form action='index.php?mod=mail&CMD=send' enctype='multipart/form-data' method='post'> <input id="file" name="userfile[]" style="background-color: rgb(221, 238, 238);" size="55" type="file"> <input id="file" name="userfile[]" style="background-color: rgb(221, 238, 238);" size="55" type="file"> <input id="file" name="userfile[]" style="background-color: rgb(221, 238, 238);" size="55" type="file"> <input id="file" name="userfile[]" style="background-color: rgb(221, 238, 238);" size="55" type="file"> <input id="file" name="userfile[]" style="background-color: rgb(221, 238, 238);" size="55" type="file"> [...] </form> My PHP code that gets this looks like this: <?php // SOME SERVERS HAVE SOME DIFFERENCES - AGHR if (get_magic_quotes_gpc()) $_POST = array_map('stripslashes', $_POST); $_POST['ms'] = str_replace("\r\n", "\n", $_POST['ms']); if (!isset($_SESSION['session_server']) || !isset($_SESSION['session_username']) || !isset($_SESSION['session_password'])) { showBody(""); echo "Your session might have timed-out. "; echo "Copy the content of your e-mail below, and try again by <A href='?mod=mail&folder=$_GET[folder]'>continuing</a>..."; echo "<PRE>" . $_POST['ms'] . "</PRE>"; return; } $head = "From: $_POST[fr]\n"; if ($_POST['cc']){$head .= "CC: $_POST[cc]\n";} if ($_POST['bcc']){$head .= "BCC: $_POST[bcc]\n";} $head .= "Return-Path: <" . $_POST['fr'] . ">\n"; $head .= "Reply-to: <" . $_POST['fr'] . ">\n"; $head .= 'Content-Type: text/html; charset="iso-8859-1"' . "\n"; $head .= 'Content-Transfer-Encoding: 8bit'; $head = str_replace("'", '"', $head); $to = str_replace("'", '"', $_POST['to']); $su = stripslashes($_POST['su']); $ms = $_POST['ms']; foreach($_FILES['userfile']['tmp_name'] as $key => $value){ if (is_uploaded_file($_FILES['userfile']['tmp_name'][$key])) { Attach($_FILES['userfile']['tmp_name'][$key],$_FILES['userfile']['name'][$key]); } } if ($_POST[submit]!="Save to Drafts"){$success = mail($to, $su, html_entity_decode($ms), $head);}else{$success="true";} if ($success) { showBody(""); if ($_POST[submit]!="Save to Drafts"){echo "Mail is sent!";}else{echo "Mail is saved!";} if (isset($_POST['oldmessage']) && isset($_POST['oldmessage_delete']) && $_POST['oldmessage_delete'] == "true") { echo " Also deleting original message."; delete($_POST['oldmessage']); } } ?> In case you are wandering what the Attach function does ... function Attach($AttmFile, $FileName) { global $ms, $head;// orginele message en headers $Text = $ms; $Html = $ms;// html is niet meer actief want wordt niet goed weergegeven na invoer if ($Text == "") { $Text = " "; $Html = " "; } $OB = "----=_OuterBoundary_000"; $IB = "----=_InnerBoundery_001"; $Html = $Html ? $Html:preg_replace("/\n/", "{br}", $Text) or die("neither text nor html part present."); $Text = $Text ? $Text:"Sorry, but you need an html mailer to read this mail."; $headers = "MIME-Version: 1.0\r\n"; $headers .= $head;// toevoeging orginele headers (from en to enzo) $headers .= "X-Priority: 1\n"; $headers .= "Content-Type: multipart/mixed;\n\tboundary=\"" . $OB . "\"\n"; $Msg = "This is a multi-part message in MIME format.\n"; $Msg .= "\n--" . $OB . "\n"; $Msg .= "Content-Type: multipart/alternative;\n\tboundary=\"" . $IB . "\"\n\n"; $Msg .= "\n--" . $IB . "\n"; $Msg .= "Content-Type: text/plain;\n\tcharset=\"iso-8859-1\"\n"; $Msg .= "Content-Transfer-Encoding: quoted-printable\n\n"; $Msg .= $Text . "\n\n"; $Msg .= "\n--" . $IB . "--\n"; $patharray = explode("/", $AttmFile); $Msg .= "\n--" . $OB . "\n"; $Msg .= "Content-Type: application/octetstream;\n\tname=\"" . $FileName . "\"\n"; $Msg .= "Content-Transfer-Encoding: base64\n"; $Msg .= "Content-Disposition: attachment;\n\tfilename=\"" . $FileName . "\"\n\n"; $fd = fopen($AttmFile, "r"); if (!$fd) die("Could not open uploaded file on the server"); $FileContent = fread($fd, filesize($AttmFile)); fclose($fd); $FileContent = chunk_split(base64_encode($FileContent)); $Msg .= $FileContent; $Msg .= "\n\n"; $Msg .= "\n--" . $OB . "--\n"; $ms = $Msg; $head = $headers; } I checked if the $_FILES array is empty after it's submited and it's not ... this is a print_r on it Array ( [userfile] => Array ( [name] => Array ( [0] => [1] => patangel.jpg [2] => patangel.png [3] => Picture 1.jpg ) [type] => Array ( [0] => [1] => image/pjpeg [2] => image/x-png [3] => image/pjpeg ) [tmp_name] => Array ( [0] => [1] => /tmp/phpITuenD [2] => /tmp/phpDVBoEJ [3] => /tmp/phpQ3phKT ) [error] => Array ( [0] => 4 [1] => 0 [2] => 0 [3] => 0 ) [size] => Array ( [0] => 0 [1] => 66131 [2] => 160980 [3] => 102651 ) ) ) This is the email header of a message suposed to have an attachement but is not ... Return-path: <betable@dnsadmin.***.***.com> Envelope-to: patrick@***.org Delivery-date: Wed, 18 Feb 2009 14:22:12 -0600 Received: from betable by dnsadmin.***.***.com with local (Exim 4.69) (envelope-from <betable@dnsadmin.***.***.com>) id 1LZsvs-00088Y-GB for patrick@***.org; Wed, 18 Feb 2009 14:22:12 -0600 To: patrick@***.org Subject: patrick@***.org From: patrick@***.org Reply-to: <patrick@***.org> Content-Type: text/html; charset="iso-8859-1" Content-Transfer-Encoding: 8bit Message-Id: <E1LZsvs-00088Y-GB@dnsadmin.***.***.com> Date: Wed, 18 Feb 2009 14:22:12 -0600 I really don't get it ... it looks like for some reason the foreach($_FILES['userfile']['tmp_name'] as $key => $value){ if (is_uploaded_file($_FILES['userfile']['tmp_name'][$key])) { Attach($_FILES['userfile']['tmp_name'][$key],$_FILES['userfile']['name'][$key]); } } was not looping ... or that Attach() is not adding anything to the header ... This is driving me crazy! What am i missing?
-
Your missing something here $result = mysql_query("SELECT * FROM $table"); You make a select but do nothing with it foreach($id as $id){ mysql_query("UPDATE $table SET comment='$comment' WHERE picture='$file'"); And loop $id but it was never initialized Try something like this Replace the foreach by this code $transaction = mysql_query("SELECT * FROM $table") or die (mysql_error()); while($trans = @mysql_fetch_array($transaction)){ [...] } That will loop every rows of $table
-
You can't use $id as $id in your foreach Try $id as $value instead and see if that solves it
-
[SOLVED] Deleting from DB strange happenings please assist
drisate replied to yellowzm's topic in PHP Coding Help
Thats because you have to use teh GET var DELETE FROM events WHERE id=$_GET[id] -
Agreed, this is more of an ISP issue if you are hosting your site at an ISP, and then there's always the MX records and rDNS issues.... This looks more like a mail q problem. You probably hosted on a shared server and a lot of the website you're sharing with sends out emails so it builds up in the IMAP server and thats why sometimes it's faster then other times. Check this out http://www.activexperts.com/ActivEmail/howto/php/
-
Multiple IMAP file attachements to outgoing email
drisate replied to drisate's topic in PHP Coding Help
bump -
mo taht depens on your server not your script ;-) You could try using and outgoing pop server ...
-
Well that could get handy someday ;-)
-
Try this ;-) www.php.net/number-format
-
Multiple IMAP file attachements to outgoing email
drisate replied to drisate's topic in PHP Coding Help
i will check it out thx (bump) Nobody can help my on phpfreaks? -
$count is not an array so you can't use foreach ... try a for or while loop instead ;-)
-
i don't think ? is a valide seconde parameter http://ca3.php.net/rtrim
-
Multiple IMAP file attachements to outgoing email
drisate replied to drisate's topic in PHP Coding Help
Well let's hope this isn't something absolutely critical and your job needs it ASAP..... You might have to wait awhile to get some help!!! This is kind of annoying because it is really urgent ... i need this attachement feature fixed as soon as possible... -
lol guess we posted at the same time hehe Chears bro ;-)
-
Yeah like this <? include "tpl/header.tpl"; include "tpl/navigation.tpl"; mysql_connect("localhost","root",""); mysql_select_db("ncfc"); if ($_GET["rowstart"]){$rowstart=$_GET["rowstart"];}else{$rowstart="0";} $result = mysql_query(sprintf("SELECT * FROM news ORDER BY `news_ID` DESC LIMIT $rowstart, 5")); $numrows = mysql_num_rows(mysql_query("SELECT * FROM news")); echo $numrows; while ($row = mysql_fetch_assoc($result)) { include "tpl/news.tpl"; } if($rowstart+5 < $numrows) { include "tpl/more.tpl"; } include "tpl/footer.tpl"; mysql_free_result($result); mysql_close(); ?>
-
Multiple IMAP file attachements to outgoing email
drisate replied to drisate's topic in PHP Coding Help
Nothing i swear hehe I guess this is just to "hard" for them as well -
umm try adding PREG_SET_ORDER preg_match_all('~<td class="td" align="Right">(.+?)</td>~is', $gold, $goldMatch, PREG_SET_ORDER); I am not a pro of preg_match_all but i think it's required for [0] ...
-
Multiple IMAP file attachements to outgoing email
drisate replied to drisate's topic in PHP Coding Help
YES PLEEEAASE ! hehe Let's hope i get more luck today :-) -
hey welcome back allworknoplay ;-)
-
let me share you my super page by page script ;-) <?php $rowsPerPage=10; if ($_GET ==""){$pageNum = 1;}else{$pageNum = $_GET['page'];} $offset = ($pageNum - 1) * $rowsPerPage; $result = mysql_query("SELECT COUNT(id) AS numrows FROM vip $limit_status") or die (mysql_error()); $row = @mysql_fetch_array($result, MYSQL_ASSOC); $numrows = $row['numrows']; $re_page = $pageNum*$rowsPerPage; $ree_page = $re_page-$rowsPerPage+1; // Table Start print (""); $result = mysql_query("SELECT * FROM vip $where") or die (mysql_error()); while($vip = @mysql_fetch_array($result)) { // Table Middle } // Table end print (""); $dbh2=mysql_connect("localhost", "ffrteam_vip", "g22ppl22") or die ('1 Erreur: '.mysql_error()); mysql_select_db("ffrteam_joom1"); $maxPage = ceil($numrows/$rowsPerPage); $self = "index.php?option=com_interractif"; $nav = ''; for($page = 1; $page <= $maxPage; $page++) { if ($page == $pageNum) { $nav .= " $page "; } else { $nav .= " <a href=\"$self&page=$page\">$page</a> "; } } if ($pageNum > 1) { $page = $pageNum - 1; $prev = " <a href=\"$self&page=$page\">[back]</a> "; $first = " <a href=\"$self&page=1\">[First page]</a> "; } else { $prev = ' '; $first = ' '; } if ($pageNum < $maxPage) { $page = $pageNum + 1; $next = " <a href=\"$self&page=$page\">[Next]</a> "; $last = " <a href=\"$self&page=$maxPage\">[Last page]</a> "; } else { $next = ' '; $last = ' '; } echo "<p align='center'>($ree_page/$re_page from $numrows) Page:<b>$first $prev $nav $next $last</b></p>"; ?>
-
try this [php<?php function sentence_case($string) { $sentences = preg_split('/([.?!]+)/', $string, -1, PREG_SPLIT_NO_EMPTY|PREG_SPLIT_DELIM_CAPTURE); $new_string = ''; foreach ($sentences as $key => $sentence) { $new_string .= ($key & 1) == 0? ucfirst(strtolower(trim($sentence))) : $sentence.' '; } return trim($new_string); } print sentence_case('HMM. WOW! WHAT?'); // Outputs: "Hmm. Wow! What?" ?> [/code]
-
Multiple IMAP file attachements to outgoing email
drisate replied to drisate's topic in PHP Coding Help
Renamed my topic to make it more accurate