Jump to content

eregi()


Miss-Ruth

Recommended Posts

Ok... Now I've done this. Could someone tell me if this is coded correctly and will this prevent email injecting?

 

<?php
if(IsInjected($emailer) || IsInjected($name))
{
    echo "Hacking Attempt!";
    exit;
}else{
$to = "[email protected], [email protected],".$emailer;
$sender = "The Company";
$subject = "The Subject - $name"; 

$my_msg = "<HTML>
//goes the HTML part
</HTML>";
mail($to, $subject, "", $headers);  
}

function IsInjected($str)
{
  $injections = array('(\n+)',
              '(\r+)',
              '(\t+)',
              '(%0A+)',
              '(%0D+)',
              '(%08+)',
              '(%09+)'
              );
  $inject = join('|', $injections);
  $inject = "/$inject/i";
  if(preg_match($inject,$str))
    {
    return true;
  }  else    {
    return false;
  }
}
?>

Link to comment
https://forums.phpfreaks.com/topic/220903-eregi/#findComment-1144014
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.