Mrb arkadaslar! benim phpforms scriptle yaptigim bi forum var, ama bu forumdan gelen bilgiler mail-e sadece text formatinda gonderiliyor, benim isteyim gelen bilgileri html formatinda almak.. scripte bi goz attigmda iki koddan subhelendim.. ama tam olarak sonuca ulasamadim.. simdi bu kodlari sizlere gonderiyorum, lutfen bi goz atin..
<?php
//----------------------------------------------------//
// Safe input/output () //
//----------------------------------------------------//
Function TxtSafeInput( $sVal )
{
$aHtml = array('textarea', 'script', 'table', 'select', 'optgroup');
$sVal = preg_replace ( "/<(br)>/ies" , "<\\1>", $sVal );
foreach ($aHtml as $sTag)
{
$sVal = preg_replace( "/<(\s*{$sTag})/is", "<\\1", $sVal );
}
$sVal = str_replace ( '/' , "/" , $sVal );
$sVal = str_replace ( "\n" , "<br>" , $sVal );
return $sVal;
}
Function TxtSafeOutput( $sVal )
{
$sVal = str_replace ( "<br>" , "\n" , $sVal );
// $sVal = str_replace ( "&" , "&" , $sVal );
$sVal = str_replace ( "<" , "<" , $sVal );
$sVal = str_replace ( ">" , ">" , $sVal );
$sVal = str_replace ( "\"" , """ , $sVal );
return $sVal;
}
// to write into html-code textarea
Function TxtGenOutput( $sVal )
{
$sVal = str_replace ( "<" , "<" , $sVal );
$sVal = str_replace ( ">" , ">" , $sVal );
$sVal = str_replace ( "\"" , """ , $sVal );
return $sVal;
}
Function TxtUnSafeOutput( $sVal )
{
$sVal = str_replace ( "<br>" , "\n" , $sVal );
//---
$sVal = str_replace ( ">" , ">" , $sVal );
$sVal = str_replace ( "<" , "<" , $sVal );
$sVal = str_replace ( "!" , "!" , $sVal );
$sVal = str_replace ( "|" , "|" , $sVal );
$sVal = str_replace ( "'" , "'" , $sVal );
$sVal = str_replace ( """ , "\"" , $sVal );
$sVal = str_replace ( "-->" , "-->" , $sVal );
$sVal = str_replace ( "<!--" , "<!--" , $sVal );
$sVal = str_replace ( "&" , "&" , $sVal );
$sVal = str_replace ( "/" , '/' , $sVal );
$sVal = str_replace ( "<" , '<' , $sVal );
return $sVal;
}
// TO-DO: remove in more stable version
// TEMP: A little patch for
// \', \" and \\ problem
//
function _FixEmailMsgBug( $sText )
{
$sText = str_replace( '\\'', "'", $sText );
$sText = str_replace( '\\"', '"', $sText );
$sText = str_replace( '|', '|', $sText );
$sText = str_replace( '\\\\', '\\', $sText );
$sText = str_replace( '&', '&', $sText );
return $sText;
}
//----------------------------------------------------//
// Decodes and encodes special chars in given string //
//----------------------------------------------------//
Function DecodeString($sStr)
{
$sStr = preg_replace("/!/","!",$sStr);
$sStr = preg_replace("/'/","'",$sStr);
$sStr = preg_replace('/"/',""",$sStr);
$sStr = preg_replace("/</","<",$sStr);
$sStr = preg_replace("/>/",">",$sStr);
return $sStr;
}
Function EncodeString($sStr)
{
$sStr = preg_replace("/!/","!",$sStr);
$sStr = preg_replace("/'/","'",$sStr);
$sStr = preg_replace("/"/",'"',$sStr);
$sStr = preg_replace("/</","<",$sStr);
$sStr = preg_replace("/>/",">",$sStr);
return $sStr;
}
//----------------------------------------------------//
// Validate email format //
//----------------------------------------------------//
Function CleanEmail($sEmail = "")
{
static $_mReturn;
$sEmail = preg_replace( "#[\n\r\*\'\"<>&\%\!\(\)\{\}\[\]\?\\/]#",
"",
$sEmail
);
if ( preg_match( "/^.+\@(\[?)[a-zA-Z0-9\-\.]+\.([a-zA-Z]{2,4}|[0-9]{1,4})(\]?)$/",
$sEmail)
)
{
$_mReturn = $sEmail;
}
else
{
$_mReturn = FALSE;
}
return $_mReturn;
}
?>
en cok subhelendigm bolum su
<?php
// E-mail format checking function
function isCorrectEmail( $sEmailString )
{
$bResult = 0;
$sPat = "/^[a-z0-9_\.\-]+@([a-z0-9][a-z0-9-]+\.)+[a-z]{2,4}$/i";
if ( preg_match( $sPat, $sEmailString ) ) $bResult = 1;
else $bResult = 0;
return $bResult;
}
// Replaces \n with \r\n
function doCorrectMtpl( $sMtpl )
{
$sResult = '';
$sResult = str_replace( "\n", "\r\n", $sMtpl );
return $sResult;
}
function xmail( $email_address, $email_cc, $email_bcc, $email_from,
$subject, $msg, $attach_filepath, $attach_types,
$want_attach, $attach_realname )
{
$b = 0;
$mail_attached = "";
$boundary = "000XMAIL000";
if (count($attach_filepath)>0 && $want_attach)
{
for ($a=0;$a<count($attach_filepath);$a++)
{
if ($fp=fopen($attach_filepath[$a],"rb"))
{
$file_name = basename( $attach_filepath[$a] );
$content[$b] = fread( $fp, filesize($attach_filepath[$a]) );
// $mail_attached.="--".$boundary."\n"."Content-Type: $attach_types[$a]; name=\"$file_name\"\n"."Content-Transfer-Encoding: base64\n"."Content-Disposition: inline; filename=\"$file_name\"\n\n".chunk_split(base64_encode($content[$b]))."\n";
$mail_attached .="--".$boundary."\n"."Content-Type: $attach_types[$a]; name=\"$file_name\"\n"."Content-Transfer-Encoding: base64\n"."Content-Disposition: inline; filename=\"$attach_realname[$a]\"\n\n".chunk_split(base64_encode($content[$b]))."\n";
$b++;
fclose($fp);
}
else
{
echo "Can't send an attachment.";
}
}
$mail_attached .= "\n";
// $mail_attached .= "--".$boundary."\n";
$add_header ="MIME-Version: 1.0\n"."Content-Type: multipart/mixed; boundary=\"$boundary\"; Message-ID: <".md5($email_from)."@domain.net>";
$mail_content="--".$boundary."\n"."Content-Type: text/html; charset=\"iso-8859-1\"\n"."Content-Transfer-Encoding: 8bit\n\n".$msg."\n\n".$mail_attached;
return mail( $email_address,$subject,$mail_content,"From: ".$email_from."\nCC: ".$email_cc."\nBCC: ".$email_bcc."\nErrors-To: ".$email_from."\n".$add_header );
}
else
{
return mail( $email_address,$subject,$msg,"From: ". $email_from. "\nErrors-To: ".$email_from );
}
}
?>