<?php
ini_set("include_path", '/home/httpd/html/fortotalrecall/download/lib/');
ini_set('error_reporting', E_ALL);
ini_set('log_errors', 0);
ini_set('error_log', '/home/httpd/html/fortotalrecall/logs/php_errors.log');
ini_set('display_errors', 1);
ini_set('html_errors', 1);
ini_set('ignore_repeated_errors ', 1);

require_once('PEAR.php');
require_once('HTML/QuickForm/Renderer/QuickHtml.php');
require_once('HTML/QuickForm.php');
require_once('Validate.php');
require_once('HTML/Template/Sigma.php');
//require_once('isset-class.php');

$s_content = '';
$i = 1;

$form =& new HTML_QuickForm('js1');
$defaultValues = array();
$form->setDefaults($defaultValues);

function _email_banned( $email )
{
    $s_banned_emails = '';
    $a_banned_emails = array();
    $b_banned = FALSE;
    
    $s_banned_emails = file_get_contents('/home/httpd/html/fortotalrecall/download/download_banned_list.txt');
    $a_banned_emails = explode("\n", $s_banned_emails);
    
    foreach( $a_banned_emails as $value )
    {
//        if( strpos( $email, $value ) !== false )
        if( strpos( $email, '@' . $value . '.' ) !== false )
       {
            $b_banned = TRUE;
        }
    }
    
    return $b_banned;
}

function _email_check($values)
{
    if($values['dl_email'] != '' && !Validate::Email($values['dl_email'],TRUE))
    {
        $errors['dl_email'] = 'Please enter a valid email address.';
	}
	else
	{
		if( _email_banned( $values['dl_email'] ) )
		{
			$errors['dl_email'] = 'Sorry, hotmail, gmail, yahoo and similar<br/>&nbsp&nbsp&nbsp&nbsp&nbsp email addresses are not accepted.<br/>&nbsp&nbsp&nbsp&nbsp&nbsp Please enter another email address.';
		}
	}
    return empty($errors)? true: $errors;
}

$form->addElement('text', 'dl_email' , 'Email address: ', array('size'=>'30', 'maxlength' => 45, 'tabindex'=>$i++, 'class' => 'textInput'));
$form->addElement('submit','submit','Submit', array( 'tabindex'=>$i++));
$form->addFormRule('_email_check');

if ( $form->validate() )
{
	$s_clientMessage = '                    C_wiz - for TOTAL recall
Low cost, high performance vessel monitoring for Microsoft Windows

Greetings,

This email was sent automatically by the C_wiz server in response
to your request for download instructions.

                           ooo000ooo

To download a copy of C_wiz, follow these steps:

1. Click on the following link:

http://www.fortotalrecall.com/download_ghtdkstu_portal.htm

If nothing happens when you click on the link, copy and paste the
link into the address bar of your web browser.

2. The link will take you to a C_wiz download page that presents
you with the download mechanism and installation instructions.

3. If you have any questions, we would appreciate it if you 
checked whether they have already been answered under the [FAQ]
hyperlink on the website. 

Otherwise, please do not hesitate to contact us via the [Contact
Us] hyperlink on the website or by replying to this email.

                           ooo000ooo

Thank you for downloading C_wiz, we hope you enjoy the experience.';

	include('Mail.php');
	$a_headers = array();
	$a_headers['From']    = 'C_wiz Download Manager <downloads2@fortotalrecall.com>';
	$a_headers['To']      = $form->exportvalue('dl_email') ;
	$a_headers['Subject'] = 'Request for C_wiz download instructions';
	
	$params['sendmail_path'] = '/usr/lib/sendmail';
	
	$o_mail = Mail::factory('sendmail',$params);
	$o_mail->send($form->exportvalue('dl_email'), $a_headers, $s_clientMessage);
	
	$s_adminMessage = 'C_wiz download request:

'. date("F j, Y, H:ia") .'
'. $form->exportValue('dl_email') .'
'. $_SERVER['REMOTE_ADDR'] .'

';

	$a_headers2 = array();
	$a_headers2['From']    = 'C_wiz Download Manager <downloads2@fortotalrecall.com>';
	$a_headers2['To']      = 'C_wiz Download Log <download_log2@fortotalrecall.com>';
	$a_headers2['Subject'] = 'C_wiz download instructions request';
	
	$o_mailAdmin = Mail::factory('sendmail',$params);
	$o_mailAdmin->send('C_wiz Download Log <download_log2@fortotalrecall.com>', $a_headers2, $s_adminMessage);
	
	header('Location: http://www.fortotalrecall.com/download_read_email.htm');
    exit();
}

// instantiate the renderer
$renderer =& new HTML_QuickForm_Renderer_Default();
$renderer->setFormTemplate("\n<form{attributes}>\n<table border=\"0\" id=\"formTable\">\n{content}\n</table>\n</form>");
$renderer->setHeaderTemplate("\n\t<tr>\n\t\t<td valign=\"top\" colspan=\"2\"><h2>{header}</h2></td>\n\t</tr>");
$renderer->setElementTemplate("\n\t<tr>\n\t\t<td width=\"150\" nowrap=\"nowrap\" valign=\"top\" align=\"right\"><!-- BEGIN required --><span  style=\"color:red;\">* </span><!-- END required -->{label}</td>\n\t\t<td class=\"tablePadding\"><!-- BEGIN error --><div style=\"background-color:yellow;color:Black;padding:3px 10px 3px 10px;min-height:15px;\"><img src=\"/images/error.gif\" alt=\"Error\" width=\"19\" height=\"19\" border=\"0\" align=\"absmiddle\" /> {error}</div><br /><!-- END error -->\t{element}<br /></td>\n\t</tr>");
$renderer->setRequiredNoteTemplate("\n\t<tr>\n\t\t<td></td>\n\t<td align=\"left\" valign=\"top\"><p>{requiredNote}</p></td>\n\t</tr>");

// process the form
$form->setRequiredNote('');
$form->accept($renderer);

$s_content = $renderer->toHtml();

// implement template
$tpl =& new HTML_Template_Sigma('/home/httpd/html/fortotalrecall/download/');
$tpl->loadTemplateFile('download_template.html');

$tpl->setVariable('cutInForm', $s_content);

$tpl->show();
?>

<!--webbot bot="SaveResults"
S-Email-Format="TEXT/PRE"
S-Email-Address="downloads2@fortotalrecall.com"
B-Email-Label-Fields="FALSE"
B-Email-ReplyTo-From-Field="TRUE"
S-Email-ReplyTo="email_address"
B-Email-Subject-From-Field="FALSE"
S-Email-Subject="Request for C_wiz download instructions"
S-Date-Format="%A, %d %B %Y" S-Time-Format="%I:%M:%S %p %Z"
S-Builtin-Fields="REMOTE_NAME Date Time"
S-Form-Fields="email_address "
U-Confirmation-Url="download_read_email.htm" startspan -->

