<?php
/*
  www.oscGold.com (C) Kamelia-Net Jacek Krysiak
  modul oscGold wer 4.0
*/
?>

<?php echo tep_draw_form('email_friend', tep_href_link(FILENAME_TELL_A_FRIEND, 'action=process&products_id=' . $HTTP_GET_VARS['products_id'])); ?>

<table border="0" width="100%" cellspacing="0" cellpadding="0">

 <!-- Naglowek BOF -->
 <tr>
  <td>
   <?php
   $info_box_contents = array();
   $info_box_contents[] = array('text' => osc_trunc_string(sprintf(HEADING_TITLE, $product_info['products_name']),60,1));
   new contentBoxHeading($info_box_contents);
   ?>
  </td>
 </tr>
 <tr>
  <td><?php echo tep_draw_separator('pixel_trans.gif', '100%', '1'); ?></td>
 </tr>
 <!-- Naglowek EOF -->

 <?php
 if ($messageStack->size('friend') > 0) {
 ?>
 <tr>
  <td><?php echo $messageStack->output('friend'); ?></td>
 </tr>
 <tr>
  <td><?php echo tep_draw_separator('pixel_trans.gif', '100%', '1'); ?></td>
 </tr>
 <?php
 }

 if (isset($HTTP_GET_VARS['action']) && ($HTTP_GET_VARS['action'] == 'success')) {
 ?>
 <tr>
  <td>
   <table border="0" width="100%" cellspacing="0" cellpadding="20" class="TableFrame">
       <tr>
        <td class="main" align="center"><?php echo TEXT_EMAIL_SUCCESSFUL_SENT; ?></td>
       </tr>
   </table>
  </td>
 </tr> 
 <tr>
  <td><?php echo tep_draw_separator('pixel_trans.gif', '100%', '2'); ?></td>
 </tr> 
 <tr>
  <td>
   <table border="0" width="100%" cellspacing="0" cellpadding="2"  class="TableFrame">
       <tr>
        <td width="10"><?php echo tep_draw_separator('pixel_trans.gif', '10', '1'); ?></td>
        <td align="right"><?php echo '<a href="' . FILENAME_PRODUCT_INFO, '?products_id=' . $tell_products_id . '">' . tep_image_button('button_continue.gif', IMAGE_BUTTON_CONTINUE) . '</a>'; ?></td>
        <td width="10"><?php echo tep_draw_separator('pixel_trans.gif', '10', '1'); ?></td>
       </tr>
   </table>
  </td>
 </tr>

 <?php
 } else {
 ?>
 <tr>
  <td>
   <table border="0" width="100%" cellspacing="0" cellpadding="0">
    <tr>
     <td colspan="2">
       <fieldset>
       <legend><?php echo FORM_TITLE_CUSTOMER_DETAILS; ?></legend>
         <table border="0" cellspacing="0" cellpadding="2">
          <tr>
           <td class="main"><?php echo FORM_FIELD_CUSTOMER_NAME; ?></td>
           <td class="main"><?php echo tep_draw_input_field('from_name', ( isset($from_name) ? $from_name : '' ), 'size="50"'); ?></td>
          </tr>
          <tr>
           <td class="main"><?php echo FORM_FIELD_CUSTOMER_EMAIL; ?></td>
           <td class="main"><?php echo tep_draw_input_field('from_email_address', ( isset($from_email_address) ? $from_email_address : '' ), 'size="30"'); ?></td>
          </tr>
         </table>
	   </fieldset>
     </td>
    </tr>

    <tr>
     <td colspan="2">
       <fieldset>
       <legend><?php echo FORM_TITLE_FRIEND_DETAILS; ?></legend>
         <table border="0" cellspacing="0" cellpadding="2">
          <tr>
           <td class="main"><?php echo FORM_FIELD_FRIEND_NAME; ?></td>
           <td class="main"><?php echo tep_draw_input_field('to_name') . '&nbsp;<span class="inputRequirement">' . ENTRY_FIRST_NAME_TEXT . '</span>'; ?></td>
          </tr>
          <tr>
           <td class="main"><?php echo FORM_FIELD_FRIEND_EMAIL; ?></td>
           <td class="main"><?php echo tep_draw_input_field('to_email_address') . '&nbsp;<span class="inputRequirement">' . ENTRY_EMAIL_ADDRESS_TEXT . '</span>'; ?></td>
          </tr>
          <tr><td class="inputRequirement" colspan="2"><br><?php echo POLA_OBOWIAZKOWE; ?></td></tr>
         </table>
        </fieldset>
     </td>
    </tr>

    <tr>
     <td colspan="2">
		   <fieldset>
		   <legend><?php echo FORM_TITLE_FRIEND_MESSAGE; ?></legend>
             <?php echo tep_draw_textarea_field('message', 'soft', 60, 8); ?>
		   </fieldset>
     </td>
    </tr>
    <tr>
     <td colspan="2"><?php echo tep_draw_separator('pixel_trans.gif', '100%', '1'); ?></td>
    </tr>

    <?php
    // BOF Anti Robot Registration v2.5
    if (ACCOUNT_VALIDATION == 'true' && strstr($PHP_SELF,'tell_a_friend') &&  TELL_FRIEND_VALIDATION == 'true') {
       ?>
       <tr>
        <td colspan="2">
            <fieldset>
            <legend><?php echo CATEGORY_ANTIROBOTREG; ?></legend>
                <table border="0" cellspacing="0" cellpadding="0" width="100%">
                    <?php
                    if ( strstr($PHP_SELF,'tell_a_friend') ) {
                        $sql = "DELETE FROM " . TABLE_ANTI_ROBOT_REGISTRATION . " WHERE timestamp < '" . (time() - 3600) . "' OR session_id = '" . tep_session_id() . "'";
                        if( !$result = tep_db_query($sql) ) { die('Could not delete validation key'); }
                        $reg_key = gen_reg_key();
                        $sql = "INSERT INTO ". TABLE_ANTI_ROBOT_REGISTRATION . " VALUES ('" . tep_session_id() . "', '" . $reg_key . "', '" . time() . "')";
                        if( !$result = tep_db_query($sql) ) { die('Could not check registration information'); }
                        ?>
                        <tr>
                            <td class="main">
                                <table border="0" width="100%" cellspacing="0" cellpadding="2">
                                    <tr>
                                        <td class="main">
                                            <table border="0" cellspacing="0" cellpadding="1" width="100%">
                                                <tr>
                                                    <td class="main"><?php echo ENTRY_ANTIROBOTREG; ?></td>
                                                    <td class="main">
                                                        <?php
                                                     $check_anti_robotreg_query = tep_db_query("select session_id, reg_key, timestamp from anti_robotreg where session_id = '" . tep_session_id() . "'");
                                                     $new_guery_anti_robotreg = tep_db_fetch_array($check_anti_robotreg_query);
                                                     $validation_images = '<img src="validation_png.php?rsid=' . $new_guery_anti_robotreg['session_id'] . '">';
                                                     if ( isset($entry_antirobotreg_error) && $entry_antirobotreg_error == true) {
                                                    ?>
                                                        <?php
                                                        echo $validation_images . '</td><td valign="middle">';
                                                        echo tep_draw_input_field('antirobotreg') . '';
                                                     } else {
                                                        ?>
                                                        <?php
                                                        echo $validation_images . '</td><td valign="middle">';
                                                        echo tep_draw_input_field('antirobotreg', '');
                                                    }
                                                    ?>
                                                    </td>
                                                </tr>
                                            </table>
                                        </td>
                                    </tr>
                                </table>
                            </td>
                        </tr>
                       <?php
                     }
                     ?>
                    </table>
            </fieldset>
        </td>
       </tr>
       <?php
       }
       // EOF Anti Robot Registration v2.5
       ?>
   </table>
  </td>
 </tr>


 <!-- Przyciski BOF -->
 <tr>
  <td><?php echo tep_draw_separator('pixel_trans.gif', '100%', '3'); ?></td>
 </tr>
 <tr>
  <td>
      <table border="0" width="100%" cellspacing="0" cellpadding="2">
       <tr>
        <td width="10"><?php echo tep_draw_separator('pixel_trans.gif', '10', '1'); ?></td>
        <td><?php echo '<a href="' . tep_href_link(FILENAME_PRODUCT_INFO, 'products_id=' . $HTTP_GET_VARS['products_id']) . '">' . tep_image_button('button_back.gif', IMAGE_BUTTON_BACK) . '</a>'; ?></td>
        <td align="right"><?php echo tep_image_submit('button_continue.gif', IMAGE_BUTTON_CONTINUE); ?></td>
        <td width="10"><?php echo tep_draw_separator('pixel_trans.gif', '10', '1'); ?></td>
       </tr>
      </table>
  </td>
 </tr>
 <!-- Przyciski EOF -->
 <?php
 }
 ?>

</table>
</form>