<?php
		  // PHPCards v0.2, Allows people to set up simple online greeting cards. 
                  // Copyright (C) 2000, Mike Gifford www.openconcept.on.ca 
                  // 
                  // This script is free software; you can redistribute it and/or 
                  // modify it under the terms of the GNU General Public License 
                  // as published by the Free Software Foundation; either version 2 
                  // of the License, or (at your option) any later version. 
                  // 
                  // This program is distributed in the hope that it will be useful, 
                  // but WITHOUT ANY WARRANTY; without even the implied warranty of 
                  // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the 
                  // GNU General Public License http://www.gnu.org/copyleft/ for more details. 
                  // 
                  // If you distribute this code, please maintain this header. 
                  // 
                  // This script allows users to select an image and write a personalized message. 
                  // It then sends a notice to the user specified email address and saves that 
                  // information to a text file. The receipient then can go and access both 
                  // the saved message and image from the website at a specified URL. 
                  // 
                  // Includes: send.phtml, send.php3, receive.phtml, receive.php3 


include("$DOCUMENT_ROOT/ireru/ecardsconfig.php3");

  // Load Cardfile into array and view specified file.
$dataarray=file("$cardfile");
$httpcounter=0;  
$slected_message="";  
$tok = strtok($dataarray[$viewcard-1],":");
while($tok){

	if ($httpcounter == 0) {} 
	elseif($httpcounter == 1){   // Chosen graphic
	  	$var1 = "<img src=\"graphics/$tok\">";
		$var1 = stripslashes($var1);
		$slected_message .= $var1;
		
	} elseif ($httpcounter == 2) {  // Recipient's email address
		 $var2 = "To: <a href=\"mailto:$tok\">";
		$var2 = stripslashes($var2);
		$slected_message .= $var2;
		$remail = $tok;  // The recipient's email address

	} elseif ($httpcounter == 3) {  // Recipient's Name
		 $var3 = "$tok</a>";
		$var3 = str_replace(chr(0),":",$var3);
		$var3 = stripslashes($var3);
		$slected_message .= $var3;
		$recipient = $tok;

	} elseif ($httpcounter == 4) { // Sender's email address
		 $var4 = "From: <a href=\"mailto:$tok\">";
		$var4 = stripslashes($var4);
		$slected_message .= $var4;
		$email = $tok;  // The name's email address

	} elseif ($httpcounter == 5) { // Sender's Name
		 $var5 = "$tok</a>";
		$var5 = str_replace(chr(0),":",$var5);
		$var5 = stripslashes($var5);
		$slected_message .= $var5;
		$name = $tok;

	} elseif ($httpcounter == 6) {  // Message
		$var6 = "Message: $tok";
		$var6 = str_replace(chr(0),":",$var6);
		$var6 = stripslashes($var6);
		$slected_message .= $var6;
		// echo $var6;
		
	} elseif ($httpcounter == 7) {  // Stored Random Number
		$eci_stored = $tok;
			
	}else { }
	$tok = strtok(":");
	$httpcounter++;
}

  // Security - Is The Random # the same as the Saved Random Number?
if ($eci_stored != $eci) {  // Incorrect Combination, Try Again?
echo 'You have entered an incorrect card/eci number combination, please try again:<br />';
echo '<form method="GET" action="receive.php3">
Card Number: <input type="text" size="5" name="viewcard"><br/>
Confirmation Number: <input type="submit" value="View Card!">
</form>';

} else {  // Successful Combination, Message Returned!
echo $slected_message;

  // Reply to Sender
// echo "<p>Click here to send an e-card back Would you like to send an e-Card in reply?<p>\n";
// echo "<form method=\"GET\" action=\"index.php3\">";
// echo "<input type=\"radio\" value=\"yes\" NAME=\"epost\">Yes, please!";
// echo "<input type=\"radio\" value=\"no\" NAME=\"epost\">No, thank you.";
// echo "<input type=hidden name=\"remail\" value=\"$email\">";
// echo "<input type=hidden name=\"recipient\" value=\"$name\">";
// echo "<input type=hidden name=\"email\" value=\"$remail\">";
// echo "<input type=hidden name=\"name\" value=\"$recipient\">";
// echo "<input type=\"submit\" value=\"Submit\"></form><br>";
}

?> 