473,699 Members | 2,501 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

PHP file displays code

110 New Member
I have a PHP file that usually sends an email. Instead, it now simply displays the code beginning with line 14 (where #eol= begins). Can anybody help me with this?

Expand|Select|Wrap|Line Numbers
  1. <?php
  2.  
  3.   #Change only the information after the equals sign
  4.  
  5.   $to = $_REQUEST['ProducerEmail'];  
  6.   $body = "Your request to bind the submission on ".$_REQUEST['IName']." has been received by United Brokers. After it has been reviewed for content by an Underwriter and it has been determined that no essential information is missing it will be sent to Processing and will, typically, be on its way back to you within 48 hours.  Thank you for your business.";
  7.   $subject = "RE: ".$_REQUEST['IName']." - Submission Received";
  8.   $fromaddress = $_REQUEST['UWemail']; 
  9.   $fromname = $_REQUEST['Underwriter'];
  10.   $agent = $_REQUEST['Agent'];
  11.   $producer = $_REQUEST['Producer'];
  12.  
  13.   # DO NOT EDIT BELOW THIS
  14.   $eol="\r\n";
  15.   $attachments=false;
  16.   $mime_boundary=md5(time());
  17.  
  18.   # Common Headers
  19.   $headers .= "From: ".$fromname."<".$fromaddress.">".$eol;
  20.   $headers .= "Reply-To: ".$fromname."<".$fromaddress.">".$eol;
  21.   $headers .= "Return-Path: ".$fromname."<".$fromaddress.">".$eol;    // these two to set reply address
  22.   $headers .= "Message-ID: <".time()."-".$fromaddress.">".$eol;
  23.   $headers .= "X-Mailer: PHP v".phpversion().$eol;          // These two to help avoid spam-filters
  24.  
  25.   # Boundry for marking the split & Multitype Headers
  26.   $headers .= 'MIME-Version: 1.0'.$eol.$eol;
  27.   $headers .= "Content-Type: multipart/mixed; boundary=\"".$mime_boundary."\"".$eol.$eol;
  28.  
  29.   # Open the first part of the mail
  30.   $msg = "--".$mime_boundary.$eol;
  31.  
  32.   $htmlalt_mime_boundary = $mime_boundary."_htmlalt"; //we must define a different MIME boundary for this section
  33.   # Setup for text OR html -
  34.   $msg .= "Content-Type: multipart/alternative; boundary=\"".$htmlalt_mime_boundary."\"".$eol.$eol;
  35.  
  36.   # Text Version
  37.   $msg .= "--".$htmlalt_mime_boundary.$eol;
  38.   $msg .= "Content-Type: text/plain; charset=iso-8859-1".$eol;
  39.   $msg .= "Content-Transfer-Encoding: 8bit".$eol.$eol;
  40.   $msg .= strip_tags(str_replace("<br>", "\n", substr($body, (strpos($body, "<body>")+6)))).$eol.$eol;
  41.  
  42.   # HTML Version
  43.   $msg .= "--".$htmlalt_mime_boundary.$eol;
  44.   $msg .= "Content-Type: text/html; charset=iso-8859-1".$eol;
  45.   $msg .= "Content-Transfer-Encoding: 8bit".$eol.$eol;
  46.   $msg .= $body.$eol.$eol;
  47.  
  48.   //close the html/plain text alternate portion
  49.   $msg .= "--".$htmlalt_mime_boundary."--".$eol.$eol;
  50.  
  51.   if ($attachments !== false)
  52.   {
  53.     for($i=0; $i < count($attachments); $i++)
  54.     {
  55.       if (is_file($attachments[$i]["file"]))
  56.       {   
  57.         # File for Attachment
  58.         $file_name = substr($attachments[$i]["file"], (strrpos($attachments[$i]["file"], "/")+1));
  59.  
  60.         $handle=fopen($attachments[$i]["file"], 'rb');
  61.         $f_contents=fread($handle, filesize($attachments[$i]["file"]));
  62.         $f_contents=chunk_split(base64_encode($f_contents));    //Encode The Data For Transition using base64_encode();
  63.         $f_type=filetype($attachments[$i]["file"]);
  64.         fclose($handle);
  65.  
  66.         # Attachment
  67.         $msg .= "--".$mime_boundary.$eol;
  68.         $msg .= "Content-Type: ".$attachments[$i]["content_type"]."; name=\"".$file_name."\"".$eol;  // sometimes i have to send MS Word, use 'msword' instead of 'pdf'
  69.         $msg .= "Content-Transfer-Encoding: base64".$eol;
  70.         $msg .= "Content-Description: ".$file_name.$eol;
  71.         $msg .= "Content-Disposition: attachment; filename=\"".$file_name."\"".$eol.$eol; // !! This line needs TWO end of lines !! IMPORTANT !!
  72.         $msg .= $f_contents.$eol.$eol;
  73.       }
  74.     }
  75.   }
  76.  
  77.   # Finished
  78.   $msg .= "--".$mime_boundary."--".$eol.$eol;  // finish with two eol's for better security. see Injection.
  79.  
  80.   # SEND THE EMAIL
  81.   ini_set(sendmail_from,$fromaddress);  // the INI lines are to force the From Address to be used !
  82.   $mail_sent = mail($to, $subject, $msg, $headers);
  83.  
  84.   ini_restore(sendmail_from);
  85.  
  86.   return $mail_sent;
  87.  
  88. ?>
  89.  
Oct 9 '07 #1
3 1853
Atli
5,058 Recognized Expert Expert
Please use CODE tags when posting source code:

[CODE=php]
PHP code goes here.
[/CODE]

Moderator
Oct 9 '07 #2
code green
1,726 Recognized Expert Top Contributor
This is usually because of a missed closing php tag or including a file without php tags.
All code is then parsed as HTML by the browser.
Can't see anything in your code.
Although could be coming via the REQUEST global, because you have no input validation whatsoever.
Rather dangerous to allow this.
Can you double check your code for any of the above and echo out the REQUEST global to see what is in there?
Oct 9 '07 #3
Atli
5,058 Recognized Expert Expert
Hi.

I, like code green, see nothing wrong with that code.

Are you sure this is the code that you are running. Is there a chance you are running an old, out of date version on your server, rather than the one you are editing?

When I first read your post I thought it had something to do with the <?php tags, but there doesn't seem to be anything wrong with them.

My only concern is, like code green mentioned, that you are using $_REQUEST without any validation. I would advise using the $_POST, $_GET and $_COOKIE super-globals instead of the $_REQUEST super-global, for increased security, and that you make sure the values that are passed are those you are expecting.
Oct 9 '07 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

2
2324
by: mike | last post by:
ok here's the problem: I have a page that displays a form for user to select individual fields and to specify their own criteria which is used to query a database and then create an excel spreadsheet and download it to their PC. when the user clicks on the "create a custom query" link on the reports page the file customss.php displays the form that list the various fields and criteria to specify for the search. This part
2
5939
by: Eric Linders | last post by:
Hello, The code below is used to grab each row from a CSV file (except the first row) and insert it into a database, as long as it's not already in the DB. If I echo each row's data, it appears only once on the page. But, for some reason it inserts each row into the database 3 times. The code that echos the data, and the DB insertion code all appear within the same for loop.
1
2013
by: dmiller23462 | last post by:
Hi again guys.... This is my first source of help, by far the best ASP intellectual collective....Thanks in advance for any assistance...Anyway.... The forms I'm still working on (finishing touches) have one issue that I've found in my testing.... I have online submission forms that email to a party and then also append to a plain-text file. I have a link to an "archive" which is
1
3020
by: PeterB | last post by:
Hi! I'm using Pure ASP File Upload (http://www.asp101.com/articles/jacob/scriptupload.asp) to upload a file from a client to a server. I am testing both on a local IIS and a remote server. The welcome page has a browse button (for locating your local file), a textfield where the path is displayed, and a upload button. When clicking upload a VB ASP script is run, and the outcome is displayed on a new page. 1. On my local machine I got the...
10
1868
by: James_101 | last post by:
My training piece is in Authorware. The user logs in with last name and a four-digit number. Authorware sends this user identifier to an asp page called db_read.asp. This file sends a SQL SELECT command to a Microsoft Access database. The database returns either the record that was selected or a "no record" message. The db_read.asp file relays this information to Authorware. If a record was returned, Authorware displays it. If there...
16
637
by: ^_^ | last post by:
conversion from: a="a"; to a=0x????; If there are many unicode strings to convert, how can I do batch-conversion?
4
5727
by: Kenneth Keeley | last post by:
Hi, I have a page that uploads files to my server and I wish to display a "Please wait while uploading" page to the user while the file is uploading. I have been able to redirect the user once the file is finished uploading but am not sure how to do it while file is uploading. Some sample code would be welcomed with open arms. Thank You.
6
7375
by: john | last post by:
The standard method to transmit a file from an aspx page to a browser is to stream the file to the response then end the response. The HTML code generated by the aspx page is discarded, and the browser displays or offers to save the binary file instead. I would like to have the browser accept and display the revised HTML code as well as offering to open or save the attached file. This SHOULD be possible using a multipart MIME format -...
1
47462
KevinADC
by: KevinADC | last post by:
Note: You may skip to the end of the article if all you want is the perl code. Introduction Many websites have a form or a link you can use to download a file. You click a form button or click on a link and after a moment or two a file download dialog box pops-up in your web browser and prompts you for some instructions, such as “open” or “save“. I’m going to show you how to do that using a perl script. What You Need Any recent...
0
8685
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9172
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9032
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8908
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8880
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
5869
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4374
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
2
2344
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2008
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.