Je fais appel à vous pour un problème au niveau d'un formulaire que je n'arrive pas à résoudre.
J'ai créé un formulaire en PHP à l'aide d'un générateur, jusqu'ici tout va bien, pour une débutante comme moi rien de plus simple.
J'ai donc obtenu 2 fichiers, un fichier form.php qui accueille mon formulaire, un fichier form.lib.php pour la configuration avancée.
J'ai réussi à personnaliser mon formulaire pour l'intégrer dans ma page web, mais j'ai un souci.
En effet, le formulaire d'origine est configuré pour que lorsq'un champs est manquant, la ligne contenant le champs se colore en gris. Dans mon fichier de config, cela donne ça :
.form_error_highlight{
background-color: #F4F6E5;
border-bottom: 1px dashed #ff0000;
}
Or, ceci est valable pour un formulaire qui n'est pas intégré dans un tableau. Or le mien, pour des raisons esthétiques, je l'ai intégré dans un tableau de 3 colonnes et 15 lignes, pour aligner les champs. Mais une fois le tableau créé et les champs mis dedans, une erreur de saisie ou un champs manquant ne génère plus la coloration en gris de la ligne concernée, ce qui à mon humble avis de débutant, provient du fait que le code n'est pas prévu pour fonctionner dans un tableau, seulement voilà, je ne suis pas assez experte pour modifier le code en question pour qu'il colore à nouveau le champs manquant ou qui contient une erreur.
Quelqu'un pourrait-il me dire comment faire, sachant je le répête que je n'ai jamais vraiment fait de PHP, et que je fonctionne davantage par logique et déduction !
Je vous donne mon code, en espérant que cela suffira
Code du fichier form.php de base non personnalisé :
<?php
# Generated by : http://phpfmg.sourceforge.net
# This block must be placed at the very top of page.
# -----------------------------------------------------------------------------
require_once( 'form.lib.php' );
header( 'Content-Type: text/html; charset=' . PHPFMG_CHARSET );
$phpfmg_send = phpfmg_sendmail( $form_mail ) ;
$isHideForm = isset($phpfmg_send['isHideForm']) ? $phpfmg_send['isHideForm'] : false;
$sErr = isset($phpfmg_send['error']) ? $phpfmg_send['error'] : '';
# -----------------------------------------------------------------------------
# FormMail main()
# -----------------------------------------------------------------------------
phpfmg_header();
if( !$isHideForm ){
phpfmg_form($sErr);
}else{
phpfmg_thankyou();
};
phpfmg_footer();
# -----------------------------------------------------------------------------
function phpfmg_form( $sErr = false ){
?>
<div class='phpfmg_form' summary='Mail form generated by php formmail generator at http://phpfmg.sourceforge.net.' >
<form name="frmFormMail" action='' method='post' enctype='multipart/form-data' onsubmit='return fmgHandler.onsubmit();'>
<input type='hidden' name='formmail_submit' value='Y'>
<?php
if( $sErr ) print "<br><a name='error'></a><div class='form_error' >" . ERR_MISSING . "</div><br>";
$starColor = $sErr ? "#ff0000" : "#000000";
$style=" class='form_text' ";
?>
<div class='field_block' id='field_0_div'>
<label class='form_field'>Nom</label> <label class='form_required' >*</label> <br>
<input type="text" name="field_0" id="field_0" value="<?php print HtmlSpecialChars( $_POST[ "field_0" ] ); ?>" class='text_box'>
<? phpfmg_field_instruction('field_0'); ?>
</div>
<div class='field_block' id='field_1_div'>
<label class='form_field'>Prenom</label> <label class='form_required' >*</label> <br>
<input type="text" name="field_1" id="field_1" value="<?php print HtmlSpecialChars( $_POST[ "field_1" ] ); ?>" class='text_box'>
<? phpfmg_field_instruction('field_1'); ?>
</div>
<div class='field_block' id='field_2_div'>
<label class='form_field'>Adresse</label> <label class='form_required' >*</label> <br>
<input type="text" name="field_2" id="field_2" value="<?php print HtmlSpecialChars( $_POST[ "field_2" ] ); ?>" class='text_box'>
<? phpfmg_field_instruction('field_2'); ?>
</div>
<div class='field_block' id='field_3_div'>
<label class='form_field'>Code Postal</label> <label class='form_required' >*</label> <br>
<input type="text" name="field_3" id="field_3" value="<?php print HtmlSpecialChars( $_POST[ "field_3" ] ); ?>" class='text_box'>
<? phpfmg_field_instruction('field_3'); ?>
</div>
<div class='field_block' id='field_4_div'>
<label class='form_field'>Ville</label> <label class='form_required' >*</label> <br>
<input type="text" name="field_4" id="field_4" value="<?php print HtmlSpecialChars( $_POST[ "field_4" ] ); ?>" class='text_box'>
<? phpfmg_field_instruction('field_4'); ?>
</div>
<div class='field_block' id='field_5_div'>
<label class='form_field'>Email</label> <label class='form_required' >*</label> <br>
<input type="text" name="field_5" id="field_5" value="<?php print HtmlSpecialChars( $_POST[ "field_5" ] ); ?>" class='text_box'>
<? phpfmg_field_instruction('field_5'); ?>
</div>
<div class='field_block' id='field_6_div'>
<label class='form_field'>Nom/Marque</label> <label class='form_required' >*</label> <br>
<input type="text" name="field_6" id="field_6" value="<?php print HtmlSpecialChars( $_POST[ "field_6" ] ); ?>" class='text_box'>
<? phpfmg_field_instruction('field_6'); ?>
</div>
<div class='field_block' id='field_7_div'>
<label class='form_field'>Description de votre activité</label> <label class='form_required' >*</label> <br>
<textarea name="field_7" id="field_7" rows=4 cols=25 class='text_area'><?php print HtmlSpecialChars( $_POST[ "field_7" ] ); ?></textarea>
<? phpfmg_field_instruction('field_7'); ?>
</div>
<div class='field_block' id='field_8_div'>
<label class='form_field'>Couleurs</label> <label class='form_required' >*</label> <br>
<?php phpfmg_dropdown( 'field_8', "Sélectionnez|Vives|Pastels|Noir&Blanc", '' );?>
<? phpfmg_field_instruction('field_8'); ?>
</div>
<div class='field_block' id='field_9_div'>
<label class='form_field'>Pièce jointe</label><br>
<input type="file" name="field_9" id="field_9" value="" class='text_box' onchange="fmgHandler.harmful(this);">
<? phpfmg_field_instruction('field_9'); ?>
</div>
<div class='field_block' id='field_10_div'>
<label class='form_field'>CGV</label> <label class='form_required' >*</label> <br>
<?php phpfmg_checkboxes( 'field_10', "En cochant cette case, j'accepte les conditions générales de vente" );?>
<? phpfmg_field_instruction('field_10'); ?>
</div>
<div class='field_block' id='phpfmg_captcha_div'>
<label class='form_field'>Security Code:</label> <label class='form_required' >*</label> <br><?php phpfmg_show_captcha(); ?>
</div>
<div class='form_submit_block'>
<input type='submit' value='Submit' class='form_button'>
<span id='phpfmg_processing' style='display:none;'>
<img id='phpfmg_processing_gif' src='<?php echo PHPFMG_ADMIN_URL . '?mod=image&func=processing' ;?>' border=0> <label id='phpfmg_processing_dots'></label>
</span>
</div>
<script type='text/javascript'>
fmgHandler.init();
</script>
</form>
</div>
<?php
if( $sErr ) {
print "<script language='javascript' type='text/javascript'>location.href='#error'; fmgHandler.highlight_fields('" . join(',',$sErr['fields']) ."'); </script>" ;
};
} // end of function phpfmg_form()
function phpfmg_thankyou(){
if( defined('PHPFMG_REDIRECT') && '' != PHPFMG_REDIRECT ){
echo "<script type='text/javascript'>
function phpfmg_redirect(){
var redirect = '" . addslashes(PHPFMG_REDIRECT) . "';
try{
if( parent ) parent.location.href = redirect;
}catch(e){
location.href = redirect;
};
}
phpfmg_redirect();
</script>";
};
?>
<!-- [Your confirmation message goes here] --------------------------------->
<br>
<b></b>
<br><br>
<?php
} // end of function phpfmg_thankyou()
?>
Code du fichier form.lib.php de base non modifié :<?php
# PHPFMG_ID:'20091019-2501'
# Date : 20091024 04:11:56
# Generated By Free PHP Formmail Generator : http://phpfmg.sourceforge.net
# -----------------------------------------------------------------------------
define( 'PAYPAL_ID' , '' ); // Put donation ID here to disable the copyright link
define( 'PHPFMG_ID' , '20091019-2501' );
define( 'PHPFMG_TO' , '[email protected]' );
define( 'PHPFMG_REDIRECT', 'http://www.blablabla.com/paylogo.htm' );
define( 'PHPFMG_ROOT_DIR' , dirname(__FILE__) );
define( 'PHPFMG_SAVE_FILE' , PHPFMG_ROOT_DIR . '/form-data-log.php' ); // save submitted data to this file
define( 'PHPFMG_EMAILS_LOGFILE' , PHPFMG_ROOT_DIR . '/email-traffics-log.php' ); // log email traffics to this file
define( 'PHPFMG_ADMIN_URL' , 'admin.php' );
define( 'PHPFMG_SAVE_ATTACHMENTS' , 'Y' );
define( 'PHPFMG_SAVE_ATTACHMENTS_DIR' , PHPFMG_ROOT_DIR . '/uploaded/' );
// three options : empty - always mail file as attachment, 0 - always mail file as link, N - mail file as link if filesize larger than N Megabytes
define( 'PHPFMG_FILE2LINK_SIZE' , '3072' );
define( 'PHPFMG_BLOCK_HARMFUL' , 'Y' );
define( 'PHPFMG_HARMFUL_EXTS' , '.exe, .com, .bat, .js, .vb, .vbs, scr, .inf, .reg, .lnk, .pif, .ade, .adp, .app, .bas, .bat, .chm, .cmd, .cpl, .crt, .csh, .exe, .fxp, .hlp, .hta, .inf, .ins, .isp, .js, .jse, .ksh, .Lnk, .mda, .mdb, .mde, .mdt, .mdt, .mdw, .mdz, .msc, .msi, .msp, .mst, .ops, .pcd, .pif, .prf, .prg, .pst, .reg, .scf, .scr, .sct, .shb, .shs, .url, .vb, .vbe, .vbs, .wsc, .wsf, .wsh' );
define( 'PHPFMG_HARMFUL_EXTS_MSG' , 'File is potential harmful. Upload is not allowed.' );
define( 'PHPFMG_CC' , '' );
define( 'PHPFMG_BCC', '' );
define( 'PHPFMG_SUBJECT' , "commande logo" );
define( 'PHPFMG_RETURN_SUBJECT' , "Votre commande sur blablabla" ); // auto response mail subject
define( 'PHPFMG_CHARSET' , 'UTF-8' );
define( 'PHPFMG_MAIL_TYPE' , 'html' ); // send mail in html format or plain text.
define( 'PHPFMG_ACTION' , 'mailandfile' ); // delivery method
define( 'PHPFMG_NO_FROM_HEADER' , '' ); // don't make up From: header.
define( 'PHPFMG_SENDMAIL_FROM' , '' ); // force sender's email
define( 'PHPFMG_SMTP' , '' ); // send email via this SMTP server
define( 'HOST_NAME',getEnv( 'SERVER_NAME' ) );
define( 'PHP_SELF', getEnv( 'SCRIPT_NAME' ) );
define( 'PHPFMG_LNCR', "\x0d\x0a" );
define( 'ERR_MISSING', '<div class="form_error_title">Please check the required fields</div>' );
define( 'ERR_EMAIL', ' (not a valid e-mail address)' );
define( 'ERR_CREDIT_CARD_NUMBER', 'Please check the credit card number : ' );
define( 'ERR_CREDIT_CARD_EXPIRED', 'Please check the credit card expiry date : ' );
define( 'ERR_SELECT_UPLOAD', 'Please select upload file : ' );
define( 'ERR_CAPTCHA', 'Security Code' );
define( 'PHPFMG_ANTI_HOTLINKING' , '' );
define( 'PHPFMG_REFERERS_ALLOW', "" ); // Referers - domains/ips that you will allow forms to reside on.
define( 'PHPFMG_REFERERS_DENIED_MSG', "You are coming from an <b>unauthorized domain.</b>" );
# -----------------------------------------------------------------------------
set_magic_quotes_runtime(0);
error_reporting( E_ERROR );
session_start();
phpfmg_check_referers();
# -----------------------------------------------------------------------------
function phpfmg_auto_response_message(){
ob_start();
?>
Votre commande a bien été enregistrée et nous vous en remercions.
Elle sera traitée dans les meilleurs délais.
A bientôt sur http://www.blablabla.com !
<?php
$msg = ob_get_contents() ;
ob_end_clean();
return trim($msg);
}
function phpfmg_mail_template(){
ob_start();
?>
<?php
$msg = ob_get_contents() ;
ob_end_clean();
return trim($msg);
}
# --- Array of Form Elements ---
$form_mail['field_0'] = array( "name" => "field_0", "text" => "Nom", "type" => "sender's name", "instruction" => "", "required" => "Required" ) ;
$form_mail['field_1'] = array( "name" => "field_1", "text" => "Prenom", "type" => "text", "instruction" => "", "required" => "Required" ) ;
$form_mail['field_2'] = array( "name" => "field_2", "text" => "Adresse", "type" => "text", "instruction" => "", "required" => "Required" ) ;
$form_mail['field_3'] = array( "name" => "field_3", "text" => "Code Postal", "type" => "text", "instruction" => "", "required" => "Required" ) ;
$form_mail['field_4'] = array( "name" => "field_4", "text" => "Ville", "type" => "text", "instruction" => "", "required" => "Required" ) ;
$form_mail['field_5'] = array( "name" => "field_5", "text" => "Email", "type" => "sender's email", "instruction" => "", "required" => "Required" ) ;
$form_mail['field_6'] = array( "name" => "field_6", "text" => "Nom/Marque", "type" => "text", "instruction" => "", "required" => "Required" ) ;
$form_mail['field_7'] = array( "name" => "field_7", "text" => "Description de votre activité", "type" => "textarea", "instruction" => "", "required" => "Required" ) ;
$form_mail['field_8'] = array( "name" => "field_8", "text" => "Couleurs", "type" => "select", "instruction" => "", "required" => "Required" ) ;
$form_mail['field_9'] = array( "name" => "field_9", "text" => "Pièce jointe", "type" => "attachment", "instruction" => "", "required" => "" ) ;
$form_mail['field_10'] = array( "name" => "field_10", "text" => "CGV", "type" => "checkbox", "instruction" => "", "required" => "Required" ) ;
// -- Create new vars for checkPass() & sendFormMail() --
$field_10 = array();
$field_10[0]=$_POST[ "Checkbox01_field_10"];
$_POST[ "field_10" ] = join( PHPFMG_LNCR, $field_10);
?>
<?php
/**
* Copyright (C) : http://www.formmail-maker.com
*/
function phpfmg_sendmail( &$form_mail ) {
if( !isset($_POST["formmail_submit"]) ) return ;
$isHideForm = false ;
$sErr = checkPass($form_mail);
if( isset($_SESSION['fmgCaptchCode']) && strtoupper($_POST['fmgCaptchCode']) != strtoupper($_SESSION['fmgCaptchCode']) ){
$sErr['fields'][] = 'phpfmg_captcha';
$sErr['errors'][] = ERR_CAPTCHA;
};
if( empty($sErr['fields']) ){
if( defined('PHPFMG_SENDMAIL_FROM') && '' != PHPFMG_SENDMAIL_FROM ){
ini_set("sendmail_from", PHPFMG_SENDMAIL_FROM);
};
if( defined('PHPFMG_SMTP') && '' != PHPFMG_SMTP ){
ini_set("SMTP", PHPFMG_SMTP);
};
sendFormMail( $form_mail, PHPFMG_SAVE_FILE ) ;
$isHideForm = true;
// move the redirect to phpfmg_thankyou() to get around the redirection within an iframe problem
/*
$redirect = PHPFMG_REDIRECT;
if( strlen(trim($redirect)) ):
header( "Location: $redirect" );
exit;
endif;
*/
};
return array(
'isHideForm' => $isHideForm,
'error' => $sErr ,
);
}
function sendFormMail( $form_mail, $sFileName = "" )
{
$to = filterEmail(PHPFMG_TO) ;
$cc = filterEmail(PHPFMG_CC) ;
$bcc = filterEmail(PHPFMG_BCC) ;
$subject = PHPFMG_SUBJECT ;
$from = "phpfmg@" . HOST_NAME ;
$fromName = "";
$titleOfSender = '';
$strip = get_magic_quotes_gpc() ;
$content = '' ;
$style = 'font-family:Verdana, Arial, Helvetica, sans-serif; font-size : 13px; color:#474747;padding:6px;border-bottom:1px solid #cccccc;' ;
$tr = array() ; // html table
$csvValues = array();
$cols = array();
$replace = array();
$RecordID = phpfmg_getRecordID();
$isWritable = is_writable( dirname(PHPFMG_SAVE_ATTACHMENTS_DIR) );
foreach( $form_mail as $field ){
$field_type = strtolower($field[ "type" ]);
if( 'sectionbreak' == $field_type ){
continue;
};
$value = trim( $_POST[ $field[ "name" ] ] );
$value = $strip ? stripslashes($value) : $value ;
if( 'attachment' == $field_type ){
$value = $isWritable ? phpfmg_file2value( $RecordID, $_FILES[ $field[ "name" ] ] ) : $_FILES[ $field[ "name" ] ]['name'];
//$value = $_FILES[ $field[ "name" ] ]['name'];
};
$content .= $field[ "text" ] . " \t : " . $value .PHPFMG_LNCR;
$tr[] = "<tr> <td valign=top style='{$style};width:300px;border-right:1px solid #cccccc;'>" . $field[ "text" ] . " </td> <td valign=top style='{$style};'>" . nl2br($value) . " </td></tr>" ;
$csvValues[] = csvfield( $value );
$cols[] = csvfield( $field[ "text" ] );
$replace["%".$field[ "name" ]."%"] = $value;
switch( $field_type ){
case "sender's email" :
$from = filterEmail($value) ;
break;
case "sender's name" :
$fromName = filterEmail($value) ;
break;
case "titleofsender" :
$titleOfSender = $value ;
break;
default :
// nothing
};
}; // for
$isHtml = 'html' == PHPFMG_MAIL_TYPE ;
if( $isHtml ) {
$content = "<table cellspacing=0 cellpadding=0 border=0 >" . PHPFMG_LNCR . join( PHPFMG_LNCR, $tr ) . PHPFMG_LNCR . "</table>" ;
};
$fromHeader = filterEmail( ('' != $fromName ? "\"$fromName\"" : '' ) . " <{$from}>",array(",", ";")) ; // no multiple emails are allowed.
$_fields = array(
'%NameOfSender%' => $fromName,
'%TitleOfSender%' => $titleOfSender,
'%DataOfForm%' => $content,
'%IP%' => $_SERVER['REMOTE_ADDR'],
'%Date%' => date("Y-m-d"),
'%Time%' => date("H:i:s"),
);
$fields = array_merge( $_fields, $replace );
$esh_mail_template = trim(phpfmg_mail_template());
if( !empty($esh_mail_template) ){
$esh_mail_template = phpfmg_adjust_template($esh_mail_template);
$content = phpfmg_parse_mail_body( $esh_mail_template, $fields );
};
if( $isHtml ) {
$content = phpfmg_getHtmlContent( $content );
};
$oldMask = umask(0);
//$sep = ','; //chr(0x09);
$sep = chr(0x09);
$recordCols = phpfmg_data2record( csvfield('RecordID') . $sep . csvfield('Date') . $sep . csvfield('IP') . $sep . join($sep,$cols) );
$record = phpfmg_data2record( csvfield($RecordID) . $sep . csvfield(date("Y-m-d H:i:s")) . $sep . csvfield($_SERVER['REMOTE_ADDR']) .$sep . join($sep,$csvValues) );
switch( strtolower(PHPFMG_ACTION) ){
case 'fileonly' :
appendToFile( $sFileName, $record, $recordCols );
break;
case 'mailonly' :
mailAttachments( $to , $subject , $content, $fromHeader, $cc , $bcc, PHPFMG_CHARSET ) ;
break;
case 'mailandfile' :
default:
mailAttachments( $to , $subject , $content, $fromHeader, $cc , $bcc, PHPFMG_CHARSET ) ;
appendToFile( $sFileName, $record, $recordCols );
}; // switch
//mailReport( $content, $sFileName );
mailAutoResponse( $from, $to, $fields ) ;
umask($oldMask);
}
function phpfmg_file2value( $recordID, $file ){
$tmp = $file[ "tmp_name" ] ;
$name = trim($file[ "name" ]) ;
if( !defined('PHPFMG_FILE2LINK_SIZE') ){
return $name;
};
if( is_uploaded_file( $tmp ) ) {
$size = trim(PHPFMG_FILE2LINK_SIZE) ;
switch( $size ){
case '' :
return $name;
default:
$isHtml = 'html' == PHPFMG_MAIL_TYPE;
$filelink= base64_encode( serialize(array('recordID'=>$recordID, 'filename'=>$name)) );
$url = phpfmg_admin_url() . "?mod=filman&func=download&filelink=" . urlencode($filelink) ;
return $isHtml ? "<a href='{$url}'>$name</a>" : $name . " ( {$url} )";
};// switch
}; // if
return $name;
}
function phpfmg_dir2unix( $dir ){
return str_replace( array("\\", '//'), '/', $dir );
}
function phpfmg_request_uri(){
$uri = getEnv('REQUEST_URI'); // apache has this
if( false !== $uri && strlen($uri) > 0 ){
return $uri ;
} else {
$uri = ($uri = getEnv('SCRIPT_NAME')) !== false
? $uri
: getEnv('PATH_INFO') ;
$qs = getEnv('QUERY_STRING'); // IIS and Apache has this
return $uri . ( empty($qs) ? '' : '?' . $qs );
};
return "" ;
}
// parse full admin url to view large size uploaded file online
function phpfmg_admin_url(){
$http_host = "http://{$_SERVER['HTTP_HOST']}";
switch( true ){
case (0 === strpos(PHPFMG_ADMIN_URL, 'http://' )) :
$url = PHPFMG_ADMIN_URL;
break;
case ( '/' == substr(PHPFMG_ADMIN_URL,0,1) ) :
$url = $http_host . PHPFMG_ADMIN_URL ;
break;
default:
$uri = phpfmg_request_uri();
$pos = strrpos( $uri, '/' );
$vdir = substr( $uri, 0, $pos );
$url = $http_host . $vdir . '/' . PHPFMG_ADMIN_URL ;
};
return $url;
}
function phpfmg_ispost(){
return 'POST' == strtoupper($_SERVER["REQUEST_METHOD"]) || 'POST' == strtoupper(getEnv('REQUEST_METHOD')) ;
}
// don't allow hotlink form to my website. To avoid people create phishing form.
function phpfmg_hotlinking_mysite(){
$yes = false !== strpos( strtolower($_SERVER['HTTP_HOST']),'formmail-maker.com') // accessing form at mysite
&& ( empty($_SERVER['HTTP_REFERER']) || false === strpos( strtolower($_SERVER['HTTP_REFERER']),'formmail-maker.com') ) ; // doesn't have referer of mysite
if( $yes ){
die( "<b>Access Denied.</b>
<br /><br />
You are visiting a form hotlinkink from <a href='http://www.formmail-maker.com'>formmail-maker.com</a> which is not allowed.
Please read the <a href='http://www.formmail-maker.com/web-form-mail-faq.php'>FAQ</a>.
" );
};
}
function phpfmg_check_referers(){
phpfmg_hotlinking_mysite(); // anti phishing
$debugs = array();
$debugs[] = "Your IP: " . $_SERVER['REMOTE_ADDR'];
$debugs[] = "Referer link: " . $_SERVER['HTTP_REFERER'];
$debugs[] = "Host of referer: $referer";
$check = defined('PHPFMG_ANTI_HOTLINKING') && 'Y' == PHPFMG_ANTI_HOTLINKING;
if( !$check ) {
$debugs[] = "Referer is empty. No need to check hot linking.";
//echo "<pre>" . join("\n",$debugs) . "</pre>\n";
//appendToFile( PHPFMG_EMAILS_LOGFILE, date("Y-m-d H:i:s") . "\t" . $_SERVER['REMOTE_ADDR'] . " \n" . join("\n",$debugs) ) ;
return true;
};
// maybe post from local file
if( !isset($_SERVER['HTTP_REFERER']) && phpfmg_ispost() ){
appendToFile( PHPFMG_EMAILS_LOGFILE, date("Y-m-d H:i:s") . "\t" . $_SERVER['REMOTE_ADDR'] . " \n phpfmg_ispost " . join("\n",$debugs) ) ;
die( PHPFMG_REFERERS_DENIED_MSG );
};
$url = parse_url($_SERVER['HTTP_REFERER']);
$referer = str_replace( 'www.', '', strtolower($url['host']) );
if( empty($referer) ) {
return true;
};
$hosts = explode(',',PHPFMG_REFERERS_ALLOW);
$http_host = strtolower($_SERVER['HTTP_HOST']);
$referer = $http_host ;
$hosts[] = str_replace('www.', '', $http_host );
$debugs[] = "Hosts Allow: " . PHPFMG_REFERERS_ALLOW;
$allow = false ;
foreach( $hosts as $host ){
$host = strtolower(trim($host));
$debugs[] = "check host: $host " ;
if( false !== strpos($referer, $host) || false !== strpos($referer, 'www.'.$host) ){
$allow = true;
$debugs[] = " -> allow (quick exit)";
break;
}else{
$debugs[] = " -> deny";
};
};
//echo "<pre>" . join("\n",$debugs) . "</pre>\n";
//appendToFile( PHPFMG_EMAILS_LOGFILE, date("Y-m-d H:i:s") . "\t" . $_SERVER['REMOTE_ADDR'] . " \n" . join("\n",$debugs) ) ;
if( !$allow ){
die( PHPFMG_REFERERS_DENIED_MSG );
};
}
function phpfmg_getRecordID(){
if( !isset($GLOBALS['RecordID']) ){
$GLOBALS['RecordID'] = date("Ymd") . '-'. substr( md5(uniqid(rand(), true)), 0,4 );
};
return $GLOBALS['RecordID'];
}
function phpfmg_data2record( $s, $b=true ){
$from = array( "\r", "\n");
$to = array( "\\r", "\\n" );
return $b ? str_replace( $from, $to, $s ) : str_replace( $to, $from, $s ) ;
}
function csvfield( $str ){
$str = str_replace( '"', '""', $str );
return '"' . trim($str) . '"';
}
function mailAttachments( $to = "" , $subject = "" , $message = "" , $from = "[email protected]" , $cc = "" , $bcc = "", $charset = "UTF-8", $type = 'FormMail' ){
if( ! strlen( trim( $to ) ) ) return "Missing \"To\" Field." ;
$boundary = "====_My_PHP_Form_Generator_" . md5( uniqid( srand( time() ) ) ) . "====";
$content_type = 'html' == PHPFMG_MAIL_TYPE ? "text/html" : "text/plain" ;
// setup mail header infomation
$headers = 'Y' == PHPFMG_NO_FROM_HEADER ? '' : "From: $from" .PHPFMG_LNCR;
if ($cc) $headers .= "CC: $cc".PHPFMG_LNCR;
if ($bcc) $headers .= "BCC: $bcc".PHPFMG_LNCR;
$plainHeaders = $headers ; // for no attachments header
if( 'html' == PHPFMG_MAIL_TYPE ) {
$plainHeaders .= 'MIME-Version: 1.0' . PHPFMG_LNCR;
$plainHeaders .= "Content-type: text/html; charset={$charset}" ;
};
//create mulitipart attachments boundary
$sError = "" ;
$nFound = 0;
if( array_key_exists($GLOBALS['phpfmg_files_content']) && '' != $GLOBALS['phpfmg_files_content'] ){
// use previous encoded content
$sEncodeBody = $GLOBALS['phpfmg_files_content'] ;
$nFound = true ;
}else{
$file2link_size = trim(PHPFMG_FILE2LINK_SIZE) ;
$isSave = ('' != $file2link_size || defined('PHPFMG_SAVE_ATTACHMENTS') && 'Y' == PHPFMG_SAVE_ATTACHMENTS);
if( $isSave ){
if( defined('PHPFMG_SAVE_ATTACHMENTS_DIR') ){
if( !is_dir(PHPFMG_SAVE_ATTACHMENTS_DIR) ){
$ok = @mkdir( PHPFMG_SAVE_ATTACHMENTS_DIR, 0777 );
if( !$ok ) $isSave = false;
};
};
};
$isWritable = is_writable( dirname(PHPFMG_SAVE_ATTACHMENTS_DIR) );
// parse attachments content
foreach( $_FILES as $aFile ){
$sFileName = $aFile[ "tmp_name" ] ;
$sFileRealName = $aFile[ "name" ] ;
if( is_uploaded_file( $sFileName ) ):
// save uploaded file
if( $isWritable && $isSave ){
$tofile = PHPFMG_SAVE_ATTACHMENTS_DIR . phpfmg_getRecordID() . '-' . basename($sFileRealName);
if( @copy( $sFileName, $tofile) ) chmod($tofile,0777);
};
$isSkip = '' != $file2link_size && ( (filesize($sFileName)/1024) > $file2link_size );
if( $isSkip )
continue; // mail file as link
if( $fp = @fopen( $sFileName, "rb" ) ) :
$sContent = fread( $fp, filesize( $sFileName ) );
$sFName = basename( $sFileRealName ) ;
$sMIME = getMIMEType( $sFName ) ;
$bPlainText = ( $sMIME == "text/plain" ) ;
if( $bPlainText ) :
$encoding = "" ;
else:
$encoding = "Content-Transfer-Encoding: base64".PHPFMG_LNCR;
$sContent = chunk_split( base64_encode( $sContent ) );
endif;
$sEncodeBody .= PHPFMG_LNCR."--$boundary" .PHPFMG_LNCR.
"Content-Type: $sMIME;" . PHPFMG_LNCR.
"\tname=\"$sFName\"" . PHPFMG_LNCR.
$encoding .
"Content-Disposition: attachment;" . PHPFMG_LNCR.
"\tfilename=\"$sFName\"" . PHPFMG_LNCR. PHPFMG_LNCR.
$sContent . PHPFMG_LNCR ;
$nFound ++;
else:
$sError .= "<br>Failed to open file $sFileName.\n" ;
endif; // if( $fp = fopen( $sFileName, "rb" ) ) :
else:
$sError .= "<br>File $sFileName doesn't exist.\n" ;
endif; //if( file_exists( $sFileName ) ):
}; // end foreach
$sEncodeBody .= PHPFMG_LNCR.PHPFMG_LNCR."--$boundary--" ;
}; // if
$headers .= "MIME-Version: 1.0".PHPFMG_LNCR."Content-type: multipart/mixed;".PHPFMG_LNCR."\tboundary=\"$boundary\"";
$txtMsg = PHPFMG_LNCR."This is a multi-part message in MIME format." .PHPFMG_LNCR .
PHPFMG_LNCR."--$boundary" .PHPFMG_LNCR .
"Content-Type: {$content_type};".PHPFMG_LNCR.
"\tcharset=\"$charset\"" .PHPFMG_LNCR.PHPFMG_LNCR .
$message . PHPFMG_LNCR;
$body = $nFound ? $txtMsg . $sEncodeBody : $message ;
$headers = $nFound ? $headers : $plainHeaders ;
$ok = mail( $to, $subject, $body, $headers );
//echo ($ok ? 'Email sent' : 'Failed to send mail') . "\n<hr>To:\n\n$to\n\n<hr>Subject:\n\n$subject\n\n<hr>Message:\n\n$body\n\n<hr>Header:\n$headers\n\n";
phpfmg_log_mail( $to, $subject, ($nFound ? $headers . $txtMsg : $plainHeaders . $message), '', $type ); // no log for attachments
return $sError ;
}
function mailAutoResponse( $to, $from, $fields = false ){
if( !formIsEMail($to) ) return ERR_EMAIL ; // one more check for spam robot
$body = trim(phpfmg_auto_response_message());
if( empty($body) ){
return false ;
};
$subject = PHPFMG_RETURN_SUBJECT;
$isHtml = 'html' == PHPFMG_MAIL_TYPE ;
$body = phpfmg_adjust_template($body);
$body = phpfmg_parse_mail_body($body,$fields);
if( $isHtml ) {
$body = phpfmg_getHtmlContent( $body );
};
$body = str_replace( "0x0d", '', $body );
$body = str_replace( "0x0a", PHPFMG_LNCR, $body );
return mailAttachments( $to , $subject , $body, filterEmail($from), '' , '', PHPFMG_CHARSET, 'AutoResponseEmail' ) ;
}
function phpfmg_log_mail( $to='', $subject='', $body='', $headers = '', $type='' ){
$sep = str_repeat('----',20) . "\r\n" ;
appendToFile( PHPFMG_EMAILS_LOGFILE, date("Y-m-d H:i:s") . "\t" . $_SERVER['REMOTE_ADDR'] . "\t{$type}\r\n" . $sep . "To: {$to}\r\nSubject: {$subject}\r\n" . $headers . $body . "\r\n" . $sep ) ;
}
function phpfmg_getHtmlContent( $body ){
$html = "
<html>
<title>Your Form Mail Content | htttp://phpfmg.sourceforge.net</title>
<style type='text/css'>
body, td{
font-family : Verdana, Arial, Helvetica, sans-serif;
font-size : 13px;
}
</style>
<body>
"
. $body .
"
</body>
</html>
";
return $html ;
}
function phpfmg_adjust_template( $body ){
$isHtml = 'html' == PHPFMG_MAIL_TYPE ;
return $isHtml && preg_match( "/<[^<>]+>/", $body ) ? $body : nl2br($body);
}
function phpfmg_parse_mail_body( $body, $fields = false ){
if( !is_array($fields) )
return $body ;
$yes = function_exists( 'str_ireplace' );
foreach( $fields as $name => $value ){
$body = $yes ? str_ireplace( $name, $value ,$body )
: str_replace ( $name, $value ,$body );
};
return trim($body);
}
# filter line breaks to avoid emails injecting
function filterEmail($email, $chars = ''){
$email = trim(str_replace( array("\r","\n"), '', $email ));
if( is_array($chars) ) $email = str_replace( array("\r","\n"), '', $email );
return $email;
}
function mailReport( $content = "", $file = '' ){
$content = "
Dear Sir or Madam,
Your online form at " . HOST_NAME . PHP_SELF . " failed to save data to file. Please make sure the web user has permission to write to file \"{$file}\". If you don't know how to fix it, please forward this email to technical support team of your web hosting company or your Administrator.
PHPFMG
- PHP FormMail Generator
";
mail(PHPFMG_TO, "Error@" . HOST_NAME . PHP_SELF, $content );
}
function remove_newline( $str = "" ){
return str_replace( array("\r\n", "\r", "\n"), array('\r\n', '\r', '\n'), $str );
}
function checkPass( $form_mail = array() )
{
$names = array();
$labels = array();
foreach( $form_mail as $field ){
$type = strtolower( $field[ "type" ] );
$value = trim( $_POST[ $field[ "name" ] ] );
$required = $field[ "required" ] ;
$text = stripslashes( $field[ "text" ] );
// simple check the field has something keyed in.
if( !strlen($value) && ( $required == "Required" ) && $type != "attachment" ){
$names[] = $field[ "name" ];
$labels[] = $text;
//return ERR_MISSING . $text ;
continue;
};
// verify the special case
if(
( strlen($value) || $type == "attachment" )
&& $required == "Required"
):
switch( $type ){
case strtolower("Sender's Name") :
break;
case strtolower("Generic email"):
case strtolower("Sender's email"):
if( ! formIsEMail($value) ) {
$names[] = $field[ "name" ];
$labels[] = $text . ERR_EMAIL;
//return ERR_EMAIL . $text ;
};
break;
case "text" :
break;
case "textarea" :
break;
case "checkbox" :
case "radio" :
break;
case "select" :
break;
case "attachment" :
$upload_file = $_FILES[ $field["name"] ][ "tmp_name" ] ;
if( ! is_uploaded_file($upload_file) ){
$names[] = $field[ "name" ];
$labels[] = $text;
//return ERR_SELECT_UPLOAD . $text;
};
break;
case strtolower("Date(MM-DD-YYYY)"):
break;
case strtolower("Date(MM-YYYY)"):
break;
case strtolower("CreditCard(MM-YYYY)"):
if( $value < date("Y-m") ) {
$names[] = $field[ "name" ];
$labels[] = $text;
//return ERR_CREDIT_CARD_EXPIRED . $text;
};
break;
case strtolower("CreditCard#"):
if( !formIsCreditNumber( $value ) ) {
$names[] = $field[ "name" ];
$labels[] = $text;
//return ERR_CREDIT_CARD_NUMBER . $text ;
};
break;
case strtolower("Time(HH:MM:SS)"):
break;
case strtolower("Time(HH:MM)"):
break;
default :
//return $sErrRequired . $form_mail[ $i ][ "text" ];
}; // switch
endif;
}; // for
return array(
'fields' => $names,
'errors' => $labels,
);
}
function formSelected( $var, $val )
{
echo ( $var == $val ) ? "selected" : "";
}
function formChecked( $var, $val )
{
echo ( $var == $val ) ? "checked" : "";
}
function formIsEMail( $email ){
return ereg( "^(.+)@(.+)\\.(.+)$", $email );
}
function selectList( $name, $selectedValue, $start, $end, $prompt = "-Select-", $style = "" )
{
$tab = "\t" ;
print "<select name=\"$name\" $style>\n" ;
print $tab . "<option value=''>$prompt</option>\n" ;
$nLen = strlen( "$end" ) ;
$prefix_zero = str_repeat( "0", $nLen );
for( $i = $start; $i <= $end ; $i ++ ){
$stri = substr( $prefix_zero . $i, strlen($prefix_zero . $i)-$nLen, $nLen );
$selected = ( $stri == $selectedValue ) ? " selected " : "" ;
print $tab . "<option value=\"$stri\" $selected >$stri</option>\n" ;
}
print "</select>\n\n" ;
}
# something like CreditCard.pm in perl CPAN
function formIsCreditNumber( $number ) {
$tmp = $number;
$number = preg_replace( "/[^0-9]/", "", $tmp );
if ( preg_match( "/[^\d\s]/", $number ) ) return 0;
if ( strlen($number) < 13 && 0+$number ) return 0;
for ($i = 0; $i < strlen($number) - 1; $i++) {
$weight = substr($number, -1 * ($i + 2), 1) * (2 - ($i % 2));
$sum += (($weight < 10) ? $weight : ($weight - 9));
}
if ( substr($number, -1) == (10 - $sum % 10) % 10 ) return $number;
return $number;
}
/* ---------------------------------------------------------------------------------------------------
Parameters: $sFileName
Return :
1. "" : no extendsion name, or sFileName is empty
2. string: MIME Type name of array aMimeType's definition.
---------------------------------------------------------------------------------------------------*/
function getMIMEType( $sFileName = "" ) {
$sFileName = strtolower( trim( $sFileName ) );
if( ! strlen( $sFileName ) ) return "";
$aMimeType = array(
"txt" => "text/plain" ,
"pdf" => "application/pdf" ,
"zip" => "application/x-compressed" ,
"html" => "text/html" ,
"htm" => "text/html" ,
"avi" => "video/avi" ,
"mpg" => "video/mpeg " ,
"wav" => "audio/wav" ,
"jpg" => "image/jpeg " ,
"gif" => "image/gif" ,
"tif" => "image/tiff " ,
"png" => "image/x-png" ,
"bmp" => "image/bmp"
);
$aFile = split( "\.", basename( $sFileName ) ) ;
$nDiminson = count( $aFile ) ;
$sExt = $aFile[ $nDiminson - 1 ] ; // get last part: like ".tar.zip", return "zip"
return ( $nDiminson > 1 ) ? $aMimeType[ $sExt ] : "";
}
function appendToFile( $sFileName = "", $line = "", $dataColumnsLine = '' ){
if( !$sFileName || !$line ) return 0;
$isExists = file_exists( $sFileName );
$hFile = @fopen( "$sFileName", "a+w" );
$nBytes = 0;
if( $hFile ){
if( !$isExists && false !== strpos(strtolower(basename($sFileName)), '.php') ){
fputs( $hFile, "<?php exit(); /* For security reason. To avoid public user downloading below data! */?>\r\n");
if( !empty($dataColumnsLine) ){
fputs($hFile,$dataColumnsLine."\r\n");
};
};
$nBytes = fputs( $hFile , trim($line)."\r\n" );
fclose( $hFile );
};
return $nBytes ;
}
function phpfmg_get_csv_header($form_mail){
global $form_mail;
$csvValues = array();
foreach( $form_mail as $field ){
$csvValues[] = csvfield( $field[ "text" ] );
};
return join(chr(0x09),/*","*/$csvValues) ;
}
function phpfmg_field_instruction($name, $show = true ){
global $form_mail, $sErr;
$isError = in_array($name,$sErr['fields']);
$class = $isError ? 'instruction_error' : 'instruction' ;
if( $show || $isError ) echo "<div class='{$class}'>". $form_mail[ $name ]['instruction'] . "</div>";
}
function phpfmg_rand( $len = 4 ){
$md5 = md5( uniqid(rand()) );
return $len > 0 ? substr($md5,0,$len) : $md5 ;
}
function phpfmg_show_captcha(){
$url = PHPFMG_ADMIN_URL . '?mod=captcha&func=get&tid=' ;
?>
<img id="phpfmg_captcha_image" src="<?php echo $url . time();?>" onclick="this.src='<?php echo $url ;?>'+Math.random();" border=0 style="cursor:pointer;" title="Click the image to reload. PHP FormMail Generator at http://phpfmg.sourceforge.net">
<a href="http://phpfmg.sourceforge.net" onclick="document.getElementById('phpfmg_captcha_image').src='<?php echo $url ;?>'+Math.random();return false;" style="color:#474747;" title="Reload PHP FormMail Generator Security Image" >Reload Image</a><br>
<input type='text' name="fmgCaptchCode" value="" class="fmgCaptchCode" style="width:73px;" >
<?php
}
function phpfmg_dropdown( $name, $options, $extra = '', $isReturn = false ){
$dropdown = array();
$list = explode( '|', $options );
$dropdown[] = "<select name='{$name}' class='text_select' {$extra} >";
//$dropdown[] = "<option value='' >{$select}</option>";
if( is_array($list) ){
foreach( $list as $opt ){
$o = phpfmg_parse_option( $opt );
if( isset($_POST['formmail_submit']) ){
$selected = $o['value'] == $_POST[ $name ] ? 'selected' : '' ;
}else{
$selected = $o['default'] ? 'selected' : '' ;
};
$dropdown[] = "<option value=\"{$o['value']}\" {$selected}>{$o['text']}</option>";
};
};
$dropdown[] = "</select>\n";
$s = join("\t\n",$dropdown);
if( $isReturn )
return $s;
else
echo $s ;
}
function phpfmg_parse_option( $opt ){
$opt = $opt;
$a = array(
'text' => $opt,
'value' => $opt,
'default' => false,
);
$pos = strrpos( $opt, '=' );
if( false !== $pos ){
$a['text'] = substr($opt,0,$pos);
$part = substr($opt,$pos+1);
$nv = strrpos( $part, ',' );
if( false !== $nv ){
$a['value'] = substr($part,0,$nv);
$a['default'] = 'default' == strtolower(substr($part,$nv+1));
}else{
$a['value'] = $part;
};
};
$a['text'] = trim($a['text']);
$a['value'] = trim($a['value']);
return $a ;
}
function phpfmg_choice( $type, $name, $options, $isReturn = false ){
$radios = array();
$list = explode( '|', $options );
if( is_array($list) ){
$i = 0 ;
foreach( $list as $opt ){
//$value = HtmlSpecialChars( $opt );
$o = phpfmg_parse_option( $opt );
$id = "{$name}_{$i}";
$newname = 'checkbox' == $type ? "Checkbox" . substr("00".($i+1), strlen("00".($i+1))-2,2) . "_" . $name : $name;
if( isset($_POST['formmail_submit']) ){
$checked = $o['value'] == $_POST[ $newname ] ? 'checked' : '' ;
}else{
$checked = $o['default'] ? 'checked' : '' ;
};
//$radios[] = "<input type='{$type}' name='{$newname}' id='{$id}' value=\"{$o['value']}\" {$checked} class='form_{$type}' ><label class='form_{$type}_text' onclick=\"fmgHandler.choice_clicked('{$id}');\" onmouseover=\"this.className='form_{$type}_text form_choice_over';\" onmouseout=\"this.className='form_{$type}_text form_choice_out';\">{$o['text']}</label><br />";
$radios[] = "<input type='{$type}' name='{$newname}' id='{$id}' value=\"{$o['value']}\" {$checked} class='form_{$type}' ><label class='form_choice_text' oid='{$id}'>{$o['text']}</label><br />";
$i ++ ;
};
};
$s = join("\t\n",$radios);
if( $isReturn )
return $s;
else
echo $s ;
}
function phpfmg_radios( $name, $options, $isReturn = false ){
return phpfmg_choice( 'radio', $name, $options, $isReturn );
}
function phpfmg_checkboxes( $name, $options, $isReturn = false ){
return phpfmg_choice( 'checkbox', $name, $options, $isReturn );
}
function phpfmg_header(){
?>
<html>
<head>
<title>PHP FormMail Generator - A tool to create ready-to-use web forms in a flash </title>
<meta name="keywords" content="PHP FormMail Generator, Free Form, Form Builder, Form Creator, phpFormMailGen, Customized Web Forms, phpFormMailGenerator,formmail.php, formmail.pl, formMail Generator, ASP Formmail, ASP form, PHP Form, Generator, phpFormGen, phpFormGenerator, anti-spam, web hosting">
<meta name="description" content="PHP formMail Generator - A tool to ceate ready-to-use web forms in a flash">
<meta name="generator" content="PHP Mail Form Generator, phpfmg.sourceforge.net">
<style type='text/css'>
body, .form_field, .form_required, .form_description, .form_button{
font-family : Verdana, Arial, Helvetica, sans-serif;
font-size : 13px;
color : #474747;
}
body{
background-color: transparent;
};
.phpfmg_form, .form_description, .form_footer{
padding-left: 10px;
padding-bottom: 10px;
width: 418px;
}
.form_field, .form_required, .form_description, .form_button{
font-weight : bold;
}
.form_required{
color:red;
}
.field_block{
padding: 5px;
}
.field_block_over{
/*
padding: 4px;
border: 1px dashed #cccccc;
background-color: yellow;
*/
}
.form_submit_block{
padding-top: 10px;
}
.form_text{
}
.text_box, .text_area, .text_select {
width:300px;
}
.text_area{
height:80px;
}
.form_error_title{
font-weight: bold;
color: red;
}
.form_error{
background-color: #F4F6E5;
border: 1px dashed #ff0000;
padding: 16px;
color : black;
margin: 10px;
}
.form_error_highlight{
background-color: #F4F6E5;
border-bottom: 1px dashed #ff0000;
}
div.instruction_error{
color: red;
font-weight:bold;
}
div.instruction{
}
.form_button{
width: 80px;
height: 28px;
}
.form_choice_text{
}
.form_choice_over{
background-color: #dedede;
cursor: pointer;
}
</style>
<script type="text/javascript">
function PHPFMG( formID ){
var frmID = formID;
var exts = {
'block_harmful' : '<?php echo PHPFMG_BLOCK_HARMFUL; ?>',
'harmful_exts' : '<?php echo PHPFMG_HARMFUL_EXTS; ?>',
'harmful_errmsg': "<?php echo addslashes(PHPFMG_HARMFUL_EXTS_MSG); ?>"
};
function $( id ){
return document.getElementById(id);
}
function get_form( id ){
var frm = 'object' == typeof($(id)) ? $(id) : eval( 'document.' + id ) ;
return frm ? frm : document.forms[0];
}
function file_ext( f ){
var n = f.lastIndexOf(".");
return -1 == n ? '' : f.substr( n ).toLowerCase();
}
function addLabelEvents(){
var labels = document.body.getElementsByTagName('LABEL');
for( var i = 0, N = labels.length; i < N; i ++ ){
var e = labels[i];
if( -1 != String(e.className).indexOf('form_choice_text') ){
var oid = e.getAttribute('oid');
if( !oid ) continue;
e.onmouseout = function(){ this.className = 'form_choice_text'; };
e.onmouseover = function(){ this.className = 'form_choice_text form_choice_over'; };
e.onclick = function(){
try{
var oid = this.getAttribute('oid');
var O = document.getElementById(oid);
O.checked = !O.checked;
}
catch(E){};
};
}; // if
}; // for
}
function addFieldBlockEvents(){
var divs = document.body.getElementsByTagName('DIV');
for( var i = 0, N = divs.length; i < N; i ++ ){
var e = divs[i];
if( -1 != String(e.className).indexOf('field_block') ){
e.onmouseout = function(){ if( String(this.className).indexOf('form_error_highlight') == -1 ) this.className = 'field_block'; };
e.onmouseover = function(){ if( String(this.className).indexOf('form_error_highlight') == -1 ) this.className = 'field_block field_block_over'; };
}; // if
}; // for
}
function removeHighliht(){
var divs = document.body.getElementsByTagName('DIV');
for( var i = 0, N = divs.length; i < N; i ++ ){
var e = divs[i];
var cn = String(e.className);
if( -1 != cn.indexOf('form_error_highlight') ){
e.className = cn.replace('form_error_highlight','');
}; // if
}; // for
}
function showProcessing(){
try{
var E = $('phpfmg_processing');
if( !E ) return ;
if( -1 != navigator.userAgent.toLowerCase().indexOf('msie') ){
E.style.backgroundColor='#2960AF';
$('phpfmg_processing_gif').style.display = 'none';
setInterval( 'fmgHandler.dots()', 380 );
};
E.style.display = '' ;
}catch(e){};
}
this.highlight_fields = function( fields ){
var A = fields.split(',');
for( var i = 0, N = A.length; i < N; i ++ ){
var E = $( A[i] + '_div' );
if( E ){
E.className += ' form_error_highlight';
};
};
}
this.choice_clicked = function( id ){
$(id).checked = !$(id).checked ;
}
this.is_ext_allow = function(){
}
this.init = function(){
addLabelEvents();
addFieldBlockEvents();
}
this.harmful = function(e){
if( 'Y' != exts['block_harmful'] ){
return;
};
var ext = file_ext(e.value);
if( -1 != exts['harmful_exts'].toLowerCase().indexOf(ext) ){
e.value = '';
alert( exts['harmful_errmsg'] );
};
}
this.dots = function(){
$('phpfmg_processing_dots').innerHTML += '.';
if( $('phpfmg_processing_dots').innerHTML.length >= 38 ) {
$('phpfmg_processing_dots').innerHTML = '.';
};
}
this.onsubmit = function(){
showProcessing();
return true;
}
var Form = null;
var err_fields=null;
}
var fmgHandler = new PHPFMG();
</script>
</head>
<body marginheight="0" marginwidth="0" leftmargin="0" topmargin="0">
<div class='form_description'>
</div>
<?php
}
function phpfmg_footer(){
?>
<div class='form_footer'>
</div>
<?php
if( defined('PAYPAL_ID') && '' == PAYPAL_ID ){
?>
<!-- -------------------------------------- Copyright -------------------------------------- -->
<br><br>
<div style="padding-left:10px; font-size:11px;color:#cccccc;text-decoration:none;">
:: <a href="http://phpfmg.sourceforge.net" target="_blank" title="Free Mailform Maker: Create read-to-use Web Forms in a flash" style="color:#cccccc;text-decoration:none;font-weight:bold;">PHP FormMail Generator</a> ::
</div>
<br><br><br>
<?php
};// if
?>
</body>
</html>
<?php
}
?>
Je continue dans le message suivant car trop de caractères !