I have a email script which (on the sending of the email) writes into a file handle called $fcf (on a new line) with the senders ip address ($ipaddress) and the time on which they sent their email ($time) in this format: $ipaddress--$time on a new line in $fcf.
I am new to php and if someone could convert my normal language into PHP scripting I would be very grateful.
Expand|Select|Wrap|Line Numbers
- if ($fcf contains $_SERVER['REMOTE_ADDR'] with time() [giving a time offset anywhere between 0 and 500 seconds ago]) {
- [continue the script]
(This is the full code:
[PHP]<?php
$subject = $_POST['subject'];
$message = $_POST['message'];
$time = $_SERVER['REQUEST_TIME'];
$ipaddress = $_SERVER['REMOTE_ADDR'];
$fcfdata = "$ipaddress--$time\n";
include 'config.inc.php';
$fcf = fopen($floodcontrolfile, 'a+');
$fcfread = fread($fcf);
//if ($fcf contains $_SERVER['REMOTE_ADDR'] with time() [giving a time offset anywhere between 0 and 500 seconds ago]) {
if ($subject == "") {
echo '
<script language="Javascript">
<!--
alert ("The message contained no subject. Redirecting you to the homepage.")
//-->
</script>
';
echo ' <META HTTP-EQUIV="refresh" CONTENT="2;URL=';
echo $homepage;
echo ' ">';
echo ' <h1> Redirecting... ( Error! No Subject! ) </h1>';
exit();
}
elseif (mail($to, $subject, $message, $headers)) {
fwrite($fcf, $fcfdata);
echo '
<script language="Javascript">
<!--
alert ("Message sent. Redirecting you to the homepage.")
//-->
</script>
';
echo ' <META HTTP-EQUIV="refresh" CONTENT="2;URL=';
echo $homepage;
echo ' ">';
echo ' <h1> Redirecting... ( Sent! ) </h1>';
exit();
} else {
echo '
<script language="Javascript">
<!--
alert ("Error sending message. Redirecting you to the homepage.")
//-->
</script>
';
echo ' <META HTTP-EQUIV="refresh" CONTENT="3;URL=';
echo $homepage;
echo ' ">';
echo ' <h1> Redirecting ( Error Sending Message! Try Again! ) </h1>';
exit();
}[/PHP]