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?
  10. Hi, I have the following regular expression check to check for a valid URL: preg_match('|^http(s)?://[a-z0-9-]+(.[a-z0-9-]+)*(:[0-9]+)?(/.*)?$|i', $_prodLink) This works great, except when a URL contains rounded brackets. Does anyone know how I can amend the above to allow the rounded brackets ( ) in the URL?
  11. Sorry if this is posted in the wrong forum. I'm looking to build a pre-pay based e-commerce website, where users can add money to their 'account' using PayPal or something similar. When they then purchase something on the website, this deducts an amount from their pre-paid account. There are reasons for doing it this way which I will not go in to, but has anyone had any experience with anything similar, and if so, are there any security/ functionality issues to consider or did you encounter anything unexpected that is different from regular e-commerce?
  12. Not quite, I have the strpos of the string 'http://www.mysite.com/images/' which may be 42, so I want to start from strpos() + length (which in the example URL I guess would be 71) of my substring up to when the next double quote appears to get the remainder of the image URL. So basically I want to get from strpos 71 up to (but not including) the next occurence of a double quote to give me the remainder of the URL.
  13. Hi, I have an html page with multiple image tags inside it. I'm wanting to get the full URL of a specific image within that file. The specific image I'm looking for must start with 'http://www.mysite.com/images/' in the src part of the tag to make sure I'm getting the correct image. To find the occurence, I'm using strpos() to find the character position of the string match. What I then need to do is complete the rest of the URL to get the image name and then output this. So basically I need to get the string that comes after 'http://www.mysite.com/images/' and end when the speech mark occurs to close the src part of the image tag. This will then give me the full URL of my image. How do I do this? Or is there a better way to do this? Thanks.
  14. OK, so I've now worked out how to extract the HTML from an external website. Now what I want to do is find a specific string or part of the URL in the page: 1. I want to find a string in the code that contains 'http://www.mysite.com/products/images/' 2. My code has found <img src="http://www.mysite.com/products/images/123.jpg" alt=""> So now what I want to do is grab the whole URL of the image, so everything after 'src="' and before '" alt="">'. Can someone please advise the easiest way to do this? Thanks.
  15. That was going to be my next question, but I guess I could look for a specific string pattern in the img src to ensure I'm grabbing the correct image?
×
×
  • 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.