Jump to content

I've gotta be blind...


thesoggycow

Recommended Posts

Okay here is my code

 

<?
//soggy cows mailer version 1.0p 
//to do's... Test of course - add cookie uid check (set via javascript on form and pass uid onto script to check add to xml file) - add sendmail function - fix cost javascript in ie... use switch / case - also fix css fixed on cost page ie fucking it up
$toemail = "[email protected]";
$subject = "Information Request - Noodledude.com";
function getloc($value, $check) {
$n=count($value);
$i=0;
while($i<$n){
	if ($value[$i]==$check) { return $i; break; }
	else { return "moo"; }
$i++;
}
}
function write($data) {
$myFile = "mail.xml";
$fh = fopen($myFile, 'w') or die("can't open file");
fwrite($fh, $data);
fclose($fh);
}
$name = $_POST['name'];
$name = urldecode($name);
if (eregi("(\r|\n)", $name)) {
die("Spam Blocked!");
}
$email = $_POST['email'];
if ( eregi ('^[a-zA-Z0-9._-]+@[a-zA-Z0-9-]+\.[a-zA-Z.]{2,5}$', $email) ) {}
else { die("$email is not a valid email address... Please try again"); }
$phone = $_POST['phone'];
$refer = $_POST['refer'];
$com = $_POST['com'];
$date = date(n."-".j);
$ip = $_SERVER['REMOTE_ADDR']; 
$headers = "From:" . $email . "\r\n" . "Reply-To:" . $email . "\r\n" . "X-Mailer: The Soggy Mailer Version 1.0p ";
$message = "Date: ".$date."\r\n"."Name: ".$name."\r\n"."Phone: ".$phone."\r\n"."Email: ".$email."\r\n"."Reffered By: ".$refer."\r\n"."Sent From IP: ".$ip."\r\n"."\r\n"."$com";
$eray = array();
$dray = array();
$iray = array();
$cray = array();
// check ip
$xmlstr=file_get_contents("mail.xml");
$xml=new SimpleXMLElement($xmlstr);
foreach ($xml->id as $id) {
   array_push($eray,$id->email);
   array_push($dray,$id->day);
   array_push($iray,$id->ip);
   array_push($cray,$id->counter);
   $i++;
}
$eloc = getloc($eray, $email);
$iloc = getloc($iray, $ip);
echo "$eloc $iloc ";
#should be working - prerecorded email
if ($iloc == "moo") {
if ($eloc != "moo") {
	if ($dray[$eloc] == $date) {
		if ($cray[$eloc] == 2) {
			//date and count is wrong  
			die ("You have exceeded the sending limits, you may only send 2 emails every day");
		}
		else {
			echo "two";
			//date is wrong count is right
			$counternum = $cray[$eloc]+1;
			$xml->id[$eloc]->ip = $ip;
			$xml->id[$eloc]->email = $email;
			$xml->id[$eloc]->day = $date;
			$xml->id[$eloc]->counter = $counternum;
			write($xml->asXML());
			//sendmail
			#mail($toemail,$subject,$message,$headers);
		}
	}
	else {
		echo "two";
		//reset count and date
		$counternum = 0;
		$xml->id[$eloc]->ip = $ip;
		$xml->id[$eloc]->email = $email;
		$xml->id[$eloc]->day = $date;
		$xml->id[$eloc]->counter = $counternum;
		write($xml->asXML());
		//sendmail
		#mail($toemail,$subject,$message,$headers);
	}
}
}
#should also be working - prerecorded ip
if ($eloc == "moo") {
if ($iloc != "moo") {
	if ($dray[$iloc] == $date) {
		if ($cray[$iloc] == 2){
			//date and count is wrong  
			die ("You have exceeded the sending limits, you may only send 2 emails every day");
		}
		else {
			echo "three";
			//date is wrong count is right
			$counternum = $cray[$iloc]+1;
			$xml->id[$iloc]->ip = $ip;
			$xml->id[$iloc]->email = $email;
			$xml->id[$iloc]->day = $date;
			$xml->id[$iloc]->counter = $counternum;
			write($xml->asXML());
			//sendmail
			#mail($toemail,$subject,$message,$headers);
		}
	}
	else {
		echo "three";
		//reset count and date
		$counternum = 0;
		$xml->id[$iloc]->ip = $ip;
		$xml->id[$iloc]->email = $email;
		$xml->id[$iloc]->day = $date;
		$xml->id[$iloc]->counter = $counternum;
		write($xml->asXML());
		//sendmail
		mail($toemail,$subject,$message,$headers);
	}
}
}
#not working - not yet recorded
if ($eloc == "moo") {
if ($iloc == "moo") {
	/*//an unknown sender
	$idr = $xml->sent->addchild(id);
	$idr->addChild(ip,$ip);
	$idr->addChild(email,$email);
	$idr->addChild(day,$date);
	$idr->addChild(counter, 0);
	write($xml->asXML());
	//sendmail
	mail($toemail,$subject,$message,$headers);
	echo "unknown sender";*/
}
}
#working - prerecorded sender and ip
if ($eloc == $iloc) {
if ($dray[$eloc] == $date) {
	if ($cray[$eloc] == 2) {
		//date and count is wrong  
		die ("You have exceeded the sending limits, you may only send 2 emails every day");
	}
	else {
		echo "one";
		//date is wrong count is right
		$counternum = $cray[$eloc]+1;
		$xml->id[$eloc]->ip = $ip;
		$xml->id[$eloc]->email = $email;
		$xml->id[$eloc]->day = $date;
		$xml->id[$eloc]->counter = $counternum;
		write($xml->asXML());
		//sendmail
		#mail($toemail,$subject,$message,$headers);
	}
}
else {
	echo "one laaa";
	//reset count and date
	$counternum = 0;
	$xml->id[$eloc]->ip = $ip;
	$xml->id[$eloc]->email = $email;
	$xml->id[$eloc]->day = $date;
	$xml->id[$eloc]->counter = $counternum;
	write($xml->asXML());
	//sendmail
	#mail($toemail,$subject,$message,$headers);
}
}
else {
die ("Some Error Occured!");
}
?>

 

Basically its a code to check IP's and Emails against an XML file and send or not send and email accordingly. I know my mail functions are commented off thats not my problem. I also know that my addChild stuff is wrong but thats okay.

 

I can't figure it out but for some reason no matter what the XML file says my script always executes the section that echo's "one laa". What am I doing wrong! I'm really confused my conditional statements seem all right... Maybe I'm just blind. HELP!

Link to comment
https://forums.phpfreaks.com/topic/105174-ive-gotta-be-blind/
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.