<?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="";  
$record = explode("<>", $dataarray[$viewcard-1]);
for ($x=0; $x<8; $x++)
{
$record[$x] = stripslashes($record[$x]);
// print '<br />$record['.$x.'] = '.$record[$x] ;
}
		if ($record[1]) { 
	  	$slected_message .= '<img src="graphics/'.$record[1].'">';
		}
		
		if ($record[2]) { 
		// Recipient's email address
		$slected_message .= 'To: <a href="mailto:'.$record[2].'">';
		$remail = $record[2];  // The recipient's email address
		}
		
		if ($record[3]) { 
		 // Recipient's Name
		$slected_message .= $record[3].'</a>';
		$recipient = $record[3];
		}
		
		if ($record[4]) { 
	 	// Sender's email address
		$slected_message .= 'From: <a href="mailto:'.$record[4].'">';
		$email = $record[4];
		}
		
		if ($record[5]) { 
		 // Sender's Name
		$slected_message .= $record[5].'</a>';
		$name = $record[5];
		}
		
	       if ($record[6]) {  
	        // Message
		$slected_message .= 'Message: '.$record[6];
		}
		
	       if ($record[7]) {    // Stored Random Number
		$eci_stored = $record[7];
		
		// print '<br />eci_stored: "'.$eci_stored.'"';
		// print '<br />eci: "'.$eci.'"';
		}


  // Security - Is The Random # the same as the Saved Random Number?
if (trim($eci_stored) == $eci)  {  // 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>";
}
else {  // 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>';

} 
?> 