TalkPHP
 
 
Account Login
Latest Articles
» The basic usage of PHPTAL, a XML/XHTML template library for PHP
» Vulnerable methods and the areas they are commonly trusted in.
» Simple way to protect a form from bot
» The Basics On: How Session Stealing Works
» How to keep your forms from double posting data
IRC Channel
IRC Speech Bubble Join the friendly bunch on IRC...
(#TalkPHP on Freenode)

...Also available via a web interface.

See this thread for information on the TalkPHP Free Hugs Initiative™. Subject to availability.
Associates
Associates
CSS Tutorials
 
 
LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
Old 09-17-2011, 09:51 AM   #1 (permalink)
The Visitor
 
Join Date: Sep 2011
Posts: 1
Thanks: 0
Avarus is on a distinguished road
Default ob_get_clean() doesn't work properly

Hi guys! For a newletter project I'm using ob_start() and ob_get_clean() for recording some HTML/CSS/PHP code, but the output is quite weird. When I buffer the following:

Code:
<html>
<head>
<title><?php echo $list->title; ?></title>
<style type="text/css">

#text h1{
    font: bold 16px Verdana, Geneva, sans-serif;
    margin: 0px;
    text-align: center;
}

#text a{
    color: #4c79ac;
    text-decoration: none;
}
</style>
</head>
<body>
{some content here}
</body>
</html>
i get as output:

Code:
#text h1{
    font: bold 16px Verdana, Geneva, sans-serif;
    margin: 0px;
    text-align: center;
    color: #4c79ac;
    text-decoration: none;
}
</style>
</head>
<body>
{some content here}
</body>
</html>
        </u></body></html>
As you can see, it's not quite what it should be. The first few lines are not buffered, the CSS gets messed up and some tags are added at the end. Could any of you help me with this? I've tried removing all PHP and CSS, but that didn't make any difference...

EDIT: ok, just after posting I found out there was an issue in the mail headers, so I partially fixed it. The problem now is: when the buffer output is being mailed, everything before the <body> tag is wiped. But only when it is mailed, when I view the output online, it's all good. Here is the script I use to send the mail:

Code:
public function send($id) {
		$date = date("Y-m-d");
		$query = mysql_query("SELECT * FROM aquanieuws WHERE id = '".$id."'", $this->database);
		$list = mysql_fetch_object($query);
		$file = unserialize(urldecode($list->file));
		$hash = md5(date("r", time()));
		$to = "**************";
		$subj = $list->title;
		$msg = modules::build($id);
		$headers = 'From: Aquamail <*******>' . "\r\n";
		$headers .= 'Reply-To: ************' . "\r\n";
		$headers .= 'X-Mailer: PHP/' . phpversion();
		$headers .= 'MIME-Version: 1.0' . "\r\n";
		$headers .= 'Content-Type: multipart/mixed; boundary="'.$hash.'"' . "\r\n";
		$headers .= 'This is a multi-part message in MIME format.' . "\r\n";
		$headers .= '--'.$hash.'' . "\r\n";
		$headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
		$headers .= 'Content-Transfer-Encoding: 7bit' . "\r\n";
		$headers .= $msg . "\r\n";
		if(!empty($file["name"])) {
			$file_path = "../upload/".$id."/".$file["name"]."";
			$attachment = chunk_split(base64_encode(file_get_contents($file_path)));
			$headers .= '--'.$hash.'' . "\r\n";
			$headers .= 'Content-Type: '.$file["type"].'; name="'.$file["name"].'"' . "\r\n";
			$headers .= 'Content-Transfer-Encoding: base64' . "\r\n";
			$headers .= 'Content-Disposition: attachment; filename="'.$file["name"].'"' . "\r\n";
			$headers .= ''.$attachment.'\r\n';
		}
						
		if(mail($to, $subj, "", $headers)) {
			return(1);
		}
		return(0);
		mysql_query("UPDATE aquanieuws SET date = '".$date."', sent = '1' WHERE id = '".$id."'", $this->database);
	}

Last edited by Avarus : 09-17-2011 at 10:14 AM.
Avarus is offline  
Reply With Quote
 



Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Similar Threads
Thread Thread Starter Forum Replies Last Post
Can't get PHP 5. to work? Newbie windows PHP guy DotNetTim Absolute Beginners 11 02-01-2013 11:02 AM
Defining your World: All About Constants Wildhoney General 15 01-29-2013 12:32 PM
Looking For Long Term Work riscphree The Lounge 0 03-14-2010 05:55 PM
Duble the work on pages Face_Of_Boe Absolute Beginners 3 01-06-2009 04:16 PM
Functions dont work from included files. Orc Javascript, AJAX, E4X 2 07-25-2008 11:22 AM


All times are GMT. The time now is 09:04 AM.

 
     

Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.1.0
Inactive Reminders By Icora Web Design