Jump to content

mattspriggs28

Members
  • Posts

    37
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

mattspriggs28's Achievements

Member

Member (2/5)

0

Reputation

  1. Managed to sort it. It was a case of simply swapping the message and attachment code blocks around, and all works fine!
  2. I tend to use single quotes, especially if I'm storing any html code in a variable as it means I don't have to escape every double quote. I'm not aware that one is any more secure than the other though, maybe someone else has an insight into this.
  3. Hi, I have a script that generates a password protected zip file, attaches to an email and sends. The email is sent successfully and received. However, the zip file is not attached. The weird thing is that the size of the email implies that there is an attachment. I've tried in a few different mail clients to see if it was my own that was blocking the zip attachment, but the others are exactly the same. I've also tried generating the zip file without a password and attaching, but again with no luck. Just to further explain, the file needs to be stored within a password protected zip as it will contain confidential information. Here's my code: // a random hash will be necessary to send mixed content $separator = md5(time()); // carriage return type (we use a PHP end of line constant) $eol = PHP_EOL; $subject = $myForm['surveyType'] . ' : ' . REFERRAL_SUBJ; // generate the zip file and attach $password = REFERRAL_PWD; $outfile = 'referral.zip'; // create file with body inside it $refFile = time().".html"; $fh = fopen($refFile, 'w') or die("can't open file"); $refData = $smarty->fetch(REFERRAL_BODY_TPL); fwrite($fh, $refData); fclose($fh); system("zip -P $password $outfile $refFile"); // Read ZIP file into string $zipDoc = file_get_contents($outfile); $attachment = chunk_split(base64_encode($zipDoc)); // main header (multipart mandatory) $headers = "From: " . REFERRAL_MAIL_FROM . $eol; $headers .= "Reply-To: " . REFERRAL_MAIL_REPLY . $eol; $headers .= "MIME-Version: 1.0" . $eol; $headers .= "Content-Type: multipart/mixed; boundary=\"" . $separator . "\"" . $eol . $eol; $headers .= "Content-Transfer-Encoding: 7bit" . $eol; $headers .= "This is a MIME encoded message." . $eol . $eol; // message $headers .= "--" . $separator . $eol; $headers .= "Content-Type: text/html; charset=\"iso-8859-1\"" . $eol; $headers .= "Content-Transfer-Encoding: 8bit" . $eol . $eol; $headers .= $body . $eol . $eol; $headers .= "--" . $separator . "--" . $eol . $eol; // attachment $headers .= "--" . $separator . $eol; $headers .= "Content-Type: application/zip; name=\"" . $outfile . "\"" . $eol; $headers .= "Content-Transfer-Encoding: base64" . $eol; $headers .= "Content-Disposition: attachment; filename=\"" . $outfile . "\"" . '\r\n\r\n'; $headers .= $attachment . '\r\n\r\n'; $headers .= "--" . $separator . "--"; // send message $res = mail(REFERRAL_EMAIL_ADDRESS, $subject, "", $headers); unlink('referral.zip'); unlink($refFile); Any help is much appreciated.
  4. Hi, I'm working on a project that requires some interaction from some input devices for processing orders coming through a warehouse. I've done some research into Barcode Scanners and it appears quite clear that you can purchase USB compatible barcode scanners, so this appears pretty straight forward for getting it to interact with a web-based PHP application. The other input device that needs consideration is weighing machines for weighing products as they are processed. In the same way as the barcode scanner, when something is weighed the value needs to be fed to the web application. Does anyone have any experience of this? And are there weighing machines that are USB plug and play compatible in the same way as a barcode scanner? I've done some research but the information is not very forthcoming. Thanks for your help.
  5. Hi all, I have an array of data. I am looping through this data to generate a CSV file. However, if there are commas in any of the elements then this will throw out the structure of the CSV file. My question is, how do I loop through the array before I use it to strip out any commas and replace with a space? Thanks for your help.
  6. <rss version="2.0" xmlns:g="http://base.google.com/ns/1.0">
  7. Hi, Im extracting my product data from the database to store in an XML file for the Google Product Listings. The problem I'm having is that there are a number of incompatible characters in some of the data that is causing the XML file, once generated to be invalid. There are a huge number of products in the database (60,000+) so it would take an age to go through each product and remove any rogue characters, so I am using preg_replace. I've managed to find the rogue characters that occur in the data and used the preg_replace function to strip out these characters. Below is a code sample: $narrLong = strip_tags(nl2br($productArr['narrLong'])); $narrLong = htmlentities(html_entity_decode(preg_replace("/\t/"," ",$narrLong)),ENT_QUOTES,UTF-; $narrLong = preg_replace("/£/","�",$narrLong); $narrLong = preg_replace("/Â/","",$narrLong); $narrLong = preg_replace("/ /"," ",$narrLong); $narrLong = html_entity_decode($narrLong); $narrLong = preg_replace("/ & /"," & ",$narrLong); $narrLong = preg_replace("/(\w)&(\w)/","$1&$2",$narrLong); $narrLong = preg_replace("/\"/",""",$narrLong); $narrLong = preg_replace("/'|`/","'",$narrLong); $narrLong = preg_replace("/</","<",$narrLong); $narrLong = preg_replace("/>/",">",$narrLong); $narrLong = preg_replace("/“/","'",$narrLong); $narrLong = preg_replace("/”/","'",$narrLong); $narrLong = preg_replace("/’/","'",$narrLong); $narrLong = preg_replace("/½/"," 1/2",$narrLong); $narrLong = preg_replace("/®/","",$narrLong); $narrLong = preg_replace("/£/","",$narrLong); $narrLong = preg_replace("/µ/", "u",$narrLong); $narrLong = preg_replace("/é/", "e",$narrLong); $narrLong = preg_replace("/è/", "e",$narrLong); $narrLong = preg_replace("/’/", "'",$narrLong); $narrLong = preg_replace("/…/", "...",$narrLong); $narrLong = preg_replace("/°/", "",$narrLong); $narrLong = preg_replace("/™/", "",$narrLong); $narrLong = preg_replace("/—/", "-",$narrLong); $narrLong = preg_replace("/Ã/", "",$narrLong); $narrLong = preg_replace("/ƒ/", "",$narrLong); $narrLong = preg_replace("/¨/", "",$narrLong); $narrLong = preg_replace("/©/","",$narrLong); $narrLong = preg_replace("/¤/", "",$narrLong); $narrLong = str_replace("·", "",$narrLong); $narrLong = preg_replace("/‰/", "",$narrLong); $narrLong = preg_replace("/¹/", "",$narrLong); I then plug my xml open and close tags onto either end etc... However, once the xml file is generated and saved, none of the characters that I've asked to replace have not been replaced and remain in the XML file. Is there something I'm doing wrong? Are some of the characters not being recognised in my script in the first place? Thanks for your help.
  8. I may be able to help you. I recently built a website that needed to display in Russian and therefore required UTF-8 encoding. What I did was opened up in Notepad++ the various scripts that weren't displaying the characters correctly and encoded them as UTF-8 WITHOUT BOM. I'm not sure whether this would work for you but worked a treat for me.
  9. I have converted xml into an array with no problems, however I'm having difficulty outputting the various attributes. Here is a sample: [0] => Array ( [@attributes] => Array ( [YourId] => 1082-1 [Name] => Woodwards Metals [Description] => ) ) The bit that is confusing me is the @attributes part. How would I output the 'Name' element for example?
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.