Skip to content
View in the app

A better way to browse. Learn more.

Web Designer Forum

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Accept phone numbers only

Featured Replies

I have creating a form which is made with PHP Formmail Generator with a few modified changes.

 

I would like field_5 to accept numbers only, and if the user types in a text then display a msg box saying it is invalid. Hope someone can shed some light on this

 

form.php

<?php

# This block must be placed at the very top of page.
# --------------------------------------------------
require_once( dirname(__FILE__).'/form.lib.php' );
phpfmg_display_form();
# --------------------------------------------------



function phpfmg_form( $sErr = false ){
	$style=" class='form_text' ";

?>

<u><strong>Application for the Hire of a VANL Facility</u></p></strong>



<p>Thank you for your interest in hiring one of our meeting facilities. 


Please note: If you are viewing this page during office hours, you may wish to call us first to check availability of your preferred venue and date. Call 01236 748011 and ask to speak to Dianne Lawrie.</p> 

<p>Should you require any further information or have any questions about the completion of this form, please contact <a href="mailto:dianne.lawrie@xxx.xx.xx">dianne.lawrie@xxxx.xx.xx</a>.</p> 

<p>The <a href="#">Conditions of Let</a> must be read and agreed to by the person responsible for the hire and the rental charges. [i'll put up a page with these on which we can link to]</p>


<p>Thank you again for your enquiry and we look forward to being of service to you. </p>





<p><strong><font color="#FF0000">PUBLIC HOLIDAYS</strong>

Please note - premises are not available for hire on public holidays.</font>

<form name="frmFormMail" action='' method='post' enctype='multipart/form-data' onsubmit='return fmgHandler.onsubmit();'>
<input type='hidden' name='formmail_submit' value='Y'>
<div id='err_required' class="form_error" style='display:none;'>
   <label class='form_error_title'>Please check the required fields</label>
</div>


<ol class='phpfmg_form' >

<li class='field_block' id='field_0_div'><hr class='sectionbreak'>
VANL ROOM BOOKING DETAILS</li>
<li class='field_block' id='field_1_div'><div class='col_label'>
<label class='form_field'>Organisation Name</label> <label class='form_required' >*</label> </div>
<div class='col_field'>
<input type="text" name="field_1"  id="field_1" value="<?php  phpfmg_hsc("field_1"); ?>" class='text_box'>
<div id='field_1_tip' class='instruction'></div>
</div>
</li>

<li class='field_block' id='field_2_div'><div class='col_label'>
<label class='form_field'>Contact Name</label> <label class='form_required' >*</label> </div>
<div class='col_field'>
<input type="text" name="field_2"  id="field_2" value="<?php  phpfmg_hsc("field_2"); ?>" class='text_box'>
<div id='field_2_tip' class='instruction'></div>
</div>
</li>

<li class='field_block' id='field_3_div'><div class='col_label'>
<label class='form_field'>Contact Address</label> <label class='form_required' >*</label> </div>
<div class='col_field'>
<textarea name="field_3" id="field_3" rows=4 cols=25 class='text_area'><?php  phpfmg_hsc("field_3"); ?></textarea>

<div id='field_3_tip' class='instruction'></div>
</div>
</li>

<li class='field_block' id='field_4_div'><div class='col_label'>
<label class='form_field'>Post code</label> <label class='form_required' >*</label> </div>
<div class='col_field'>
<input type="text" name="field_4"  id="field_4" maxlength="8" value="<?php  phpfmg_hsc("field_4"); ?>" class='text_box'>
<div id='field_4_tip' class='instruction'></div>
</div>
</li>

<li class='field_block' id='field_5_div'><div class='col_label'>
<label class='form_field'>Tel No.</label> <label class='form_required' >*</label> </div>
<div class='col_field'>
<input type="ingt" name="field_5"  id="field_5" value="<?php  phpfmg_hsc("field_5"); ?>" class='text_box'>
       <div id='field_5_tip' class='instruction'></div>
</div>
</li>

<li class='field_block' id='field_6_div'><div class='col_label'>
<label class='form_field'>E-mail address</label> <label class='form_required' >*</label> </div>
<div class='col_field'>
<input type="text" name="field_6"  id="field_6" value="<?php  phpfmg_hsc("field_6"); ?>" class='text_box'>
<div id='field_6_tip' class='instruction'></div>
</div>
</li>

<li class='field_block' id='field_7_div'><hr class='sectionbreak'>
GROUP DETAILS</li>
<li class='field_block' id='field_8_div'><div class='col_label'>
<label class='form_field'>Is your group / organisation member a VANL?</label> <label class='form_required' >*</label> </div>
<div class='col_field'>
<?php phpfmg_radios( 'field_8', "Yes|No" );?>
<div id='field_8_tip' class='instruction'></div>
</div>
</li>

<li class='field_block' id='field_9_div'><div class='col_label'>
<label class='form_field'>Do work with children under 18 years old?</label> <label class='form_required' >*</label> </div>
<div class='col_field'>
<?php phpfmg_radios( 'field_9', "Yes|No" );?>
<div id='field_9_tip' class='instruction'></div>
</div>
</li>

<li class='field_block' id='field_10_div'><div class='col_label'>
<label class='form_field'>Will under 18's be present at this event?</label> <label class='form_required' >*</label> </div>
<div class='col_field'>
<?php phpfmg_radios( 'field_10', "Yes|No" );?>
<div id='field_10_tip' class='instruction'></div>
</div>
</li>

<li class='field_block' id='field_24_div'><div class='col_label'>
<label class='form_field'>How many people will be attending your event?</label> <label class='form_required' >*</label> </div>
<div class='col_field'>
<?php phpfmg_dropdown( 'field_24', "1|2|3|4|5|6|7|8|9|10|11|12|13|14|15|16|17|18|19|20|21|22|23|24|25|26|27|28|29|30|31|32|33|34|35|36|37|38|39|40|41|42|43|44|45|46|47|48|49|50|51|52|53|54|55|56|57|58|59|60", '' );?>
<div id='field_24_tip' class='instruction'></div>
</div>
</li>

<li class='field_block' id='field_11_div'><hr class='sectionbreak'>
EVENT DETAILS</li>
<li class='field_block' id='field_12_div'><div class='col_label'>
<label class='form_field'>Nature of Event</label> <label class='form_required' >*</label> </div>
<div class='col_field'>
<textarea name="field_12" id="field_12" rows=4 cols=25 class='text_area'><?php  phpfmg_hsc("field_12"); ?></textarea>

<div id='field_12_tip' class='instruction'>Committee Meeting; Conference; Youth Group etc.</div>
</div>
</li>

<li class='field_block' id='field_13_div'><div class='col_label'>
<label class='form_field'>Venue</label> <label class='form_required' >*</label><br>
<i>The Mavisbank Suite (Airdrie) has a capacity of 15 boardroom style, or 20 theatre style. 
<br> The Computer Suite (Wishaw) has space and IT equipment for 10. 
<br> The Small Church Hall (Wishaw) has a capacity of 40. 
<br>The Large Church Hall (Wishaw) has a capacity of 60.</i></div>
<div class='col_field'>
<?php phpfmg_dropdown( 'field_13', "-Select-|Mavisbank Suite (Airdrie)|Church: Computer Suite (Wishaw)|Church: Small Hall (Wishaw )|Church: Large Hall (Wishaw)", '' );?>
<div id='field_13_tip' class='instruction'></div>
</div>
</li>

<li class='field_block' id='field_14_div'><div class='col_label'>
<label class='form_field'>Please give details of how you would like the room set up</label> <label class='form_required' > </label> </div>
<div class='col_field'>
<textarea name="field_14" id="field_14" rows=4 cols=25 class='text_area'><?php  phpfmg_hsc("field_14"); ?></textarea>

<div id='field_14_tip' class='instruction'>e.g. theatre-style, boardroom style, flexible</div>
</div>
</li>

<li class='field_block' id='field_15_div'><hr class='sectionbreak'>
EQUIPMENT REQUIREMENTS</li>
<li class='field_block' id='field_16_div'><div class='col_label'>
<label class='form_field'>Please Select</label> <label class='form_required' > </label> </div>
<div class='col_field'>
<?php phpfmg_checkboxes( 'field_16', "Digital Projector (£15)|Laptop (£15)|Flipchart (£5)|OHP (£5)|Portable CD Player (£5)" );?>
<div id='field_16_tip' class='instruction'>Please select any equipment you wish to hire at the stated rates</div>
</div>
</li>

<li class='field_block' id='field_17_div'><div class='col_label'>
<label class='form_field'>Do you require tea/coffee?</label> <label class='form_required' >*</label> </div>
<div class='col_field'>
<?php phpfmg_radios( 'field_17', "Yes|No" );?>
<div id='field_17_tip' class='instruction'></div>
</div>
</li>

<li class='field_block' id='field_18_div'><div class='col_label'>
<label class='form_field'>Do you require catering?</label> <label class='form_required' >*</label> </div>
<div class='col_field'>
<?php phpfmg_radios( 'field_18', "Yes|No" );?>
<div id='field_18_tip' class='instruction'></div>
</div>
</li>

<li class='field_block' id='field_19_div'><hr class='sectionbreak'>
Section Break Text Goes Here</li>
<li class='field_block' id='field_20_div'><div class='col_label'>
<label class='form_field'>Date of Let</label> <label class='form_required' >*</label> </div>
<div class='col_field'>
<?php
selectList( "field_20_DD", $_POST["field_20_DD"], 1, 31, "DD", $style ) ; 
selectList( "field_20_MM", $_POST["field_20_MM"], 1, 12, "MM", $style ) ;
selectList( "field_20_YYYY", $_POST["field_20_YYYY"], date("Y")+0, date("Y")+10, "YYYY", $style ) ;
?>

<div id='field_20_tip' class='instruction'></div>
</div>
</li>

<li class='field_block' id='field_21_div'><div class='col_label'>
<label class='form_field'>Event Start time</label> <label class='form_required' >*</label> </div>
<div class='col_field'>
<?php 
selectList( "field_21_HH", $_POST["field_21_HH"], 0, 23, "HH", $style ) ;
selectList( "field_21_MM", $_POST["field_21_MM"], 0, 59, "MM", $style ) ;
?>

<div id='field_21_tip' class='instruction'></div>
</div>
</li>

<li class='field_block' id='field_22_div'><div class='col_label'>
<label class='form_field'>Event End Time</label> <label class='form_required' > </label> </div>
<div class='col_field'>
<?php 
selectList( "field_22_HH", $_POST["field_22_HH"], 0, 23, "HH", $style ) ;
selectList( "field_22_MM", $_POST["field_22_MM"], 0, 59, "MM", $style ) ;
?>

<div id='field_22_tip' class='instruction'></div>
</div>
</li>

<li class='field_block' id='field_23_div'><div class='col_label'>
<label class='form_field'>Additional Information (e.g. any special requirements)</label> <label class='form_required' > </label> </div>
<div class='col_field'>
<textarea name="field_23" id="field_23" rows=4 cols=25 class='text_area'><?php  phpfmg_hsc("field_23"); ?></textarea>

<div id='field_23_tip' class='instruction'></div>
</div>
</li>


<li class='field_block' id='phpfmg_captcha_div'>
<div class='col_label'><label class='form_field'>Security Code:</label> <label class='form_required' >*</label> </div><div class='col_field'>
<?php phpfmg_show_captcha(); ?>
</div>
</li>


           <li>
           <div class='col_label'> </div>
           <div class='form_submit_block col_field'>

               <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 alt='Processing...'> <label id='phpfmg_processing_dots'></label>
               </span>
           </div>
           </li>

</ol>




</form>




<?php

   phpfmg_javascript($sErr);

} 
# end of form




function phpfmg_form_css(){
?>
<style type='text/css'>

body{
   margin-left: 18px;
   margin-top: 18px;
}

body{
   font-family : Verdana, Arial, Helvetica, sans-serif;
   font-size : 13px;
   color : #474747;
   background-color: transparent;
}

select, option{
   font-size:13px;
}

ol.phpfmg_form{
   list-style-type:none;
   padding:0px;
   margin:0px;
}

ol.phpfmg_form li{
   margin-bottom:5px;
   clear:both;
   display:block;
   overflow:hidden;
width: 100%
}


.form_field, .form_required{
   font-weight : bold;
}

.form_required{
   color:red;
   margin-right:8px;
}

.field_block_over{
}

.form_submit_block{
   padding-top: 3px;
}

.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: 10px;
   margin-bottom: 10px;
}

.form_error_highlight{
   background-color: #F4F6E5;
   border-bottom: 1px dashed #ff0000;
}

div.instruction_error{
   color: red;
   font-weight:bold;
}

hr.sectionbreak{
   height:1px;
   color: #ccc;
}




<?php

   phpfmg_text_align();
   echo "</style>\n";

}
# end of css

# By: formmail-maker.com
?>

 

form-lib.php

<?php
# PHPFMG_ID:'20100624-572c'
# Date : 20100629 06:56:29
# 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' , 'xxxxxxxx-xxxx' );
define( 'PHPFMG_TO' , 'daniel.mcconnell@xxxx.xx.xx' );
define( 'PHPFMG_REDIRECT', 'http://www.voluntaryactionnorthlanarkshire.org.uk/thankyou.html' );

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' , '' );
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 Kilobytes
define( 'PHPFMG_FILE2LINK_SIZE' , '' );

define( 'PHPFMG_UPLOAD_CONTROL' , '' );
define( 'PHPFMG_HARMFUL_EXTS' , ".php, .html, .css, .js, .exe, .com, .bat, .vb, .vbs, scr, .inf, .reg, .lnk, .pif, .ade, .adp, .app, .bas, .chm, .cmd, .cpl, .crt, .csh, .fxp, .hlp, .hta, .ins, .isp, .jse, .ksh, .Lnk, .mda, .mdb, .mde, .mdt, .mdw, .mdz, .msc, .msi, .msp, .mst, .ops, .pcd, .prf, .prg, .pst, .scf, .scr, .sct, .shb, .shs, .url, .vbe, .wsc, .wsf, .wsh" );
define( 'PHPFMG_HARMFUL_EXTS_MSG' , 'File is potential harmful. Upload is not allowed.' );
define( 'PHPFMG_ALLOW_EXTS' , ".jpg, .gif, .png, .bmp" );
define( 'PHPFMG_ALLOW_EXTS_MSG' , "Upload is not allowed. Please check your file type." );

define( 'PHPFMG_CC' , '' );
define( 'PHPFMG_BCC', '' );
define( 'PHPFMG_SUBJECT' , "Room hire" );
define( 'PHPFMG_RETURN_SUBJECT' , "Confirmations of you room booking" ); // 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_TEXT_ALIGN' , 'top' ); // field label text alignment: top, right, left
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( '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_thankyou(){
   phpfmg_redirect_js();
?>

<!-- [Your confirmation message goes here] --------------------------------->
<br>

   <b>Thank you for your booking enquiry. A member of VANL staff will be in touch to confirm your booking within one working day.</b>
   <br><br>

<?php

} // end of function phpfmg_thankyou()



function phpfmg_auto_response_message(){
   ob_start();
?>
Dear %TitleOfSender% %NameOfSender%,

Thank you for your booking enquiry. A member of VANL staff will be in touch to confirm your booking within one working day.

Here is the copy of your booking:
%DataOfForm%


Regards,
VANL Webmaster

Date: %Date%
Time: %Time%
<?php
   $msg = ob_get_contents() ;
   ob_end_clean();
   return trim($msg);
}



function phpfmg_mail_template(){
   ob_start();
?>
You got mail from %TitleOfSender% %NameOfSender%.

Here is the form data:
%DataOfForm%

Cheers,
Web Administrator

Date: %Date%
Time: %Time%
<?php
   $msg = ob_get_contents() ;
   ob_end_clean();
   return trim($msg);
}




# --- Array of Form Elements ---
$form_mail['field_0'] = array( "name" => "field_0", "text" => "VANL ROOM BOOKING DETAILS",  "type" => "sectionbreak", "instruction" => "", "required" => "Not Required" ) ;
$form_mail['field_1'] = array( "name" => "field_1", "text" => "Organisation Name",  "type" => "text", "instruction" => "", "required" => "Required" ) ;
$form_mail['field_2'] = array( "name" => "field_2", "text" => "Contact Name",  "type" => "sender's name", "instruction" => "", "required" => "Required" ) ;
$form_mail['field_3'] = array( "name" => "field_3", "text" => "Contact Address",  "type" => "textarea", "instruction" => "", "required" => "Required" ) ;
$form_mail['field_4'] = array( "name" => "field_4", "text" => "Post code",  "type" => "text", "instruction" => "", "required" => "Required" ) ;
$form_mail['field_5'] = array( "name" => "field_5", "text" => "Tel No.",  "type" => "number", "instruction" => "", "required" => "Required" ) ;
$form_mail['field_6'] = array( "name" => "field_6", "text" => "E-mail address",  "type" => "sender's email", "instruction" => "", "required" => "Required" ) ;
$form_mail['field_7'] = array( "name" => "field_7", "text" => "GROUP DETAILS",  "type" => "sectionbreak", "instruction" => "", "required" => "Not Required" ) ;
$form_mail['field_8'] = array( "name" => "field_8", "text" => "Is your group / organisation member a VANL?",  "type" => "radio", "instruction" => "", "required" => "Required" ) ;
$form_mail['field_9'] = array( "name" => "field_9", "text" => "Do work with children under 18 years old?",  "type" => "radio", "instruction" => "", "required" => "Required" ) ;
$form_mail['field_10'] = array( "name" => "field_10", "text" => "Will under 18\'s be present at this event?",  "type" => "radio", "instruction" => "", "required" => "Required" ) ;
$form_mail['field_24'] = array( "name" => "field_24", "text" => "How many people will be attending your event?",  "type" => "select", "instruction" => "", "required" => "Required" ) ;
$form_mail['field_11'] = array( "name" => "field_11", "text" => "EVENT DETAILS",  "type" => "sectionbreak", "instruction" => "", "required" => "Not Required" ) ;
$form_mail['field_12'] = array( "name" => "field_12", "text" => "Nature of Event",  "type" => "textarea", "instruction" => "Committee Meeting; Conference; Youth Group etc.", "required" => "Required" ) ;
$form_mail['field_13'] = array( "name" => "field_13", "text" => "Venue",  "type" => "select", "instruction" => "The Mavisbank Suite (Airdrie) has a capacity of 15 boardroom style, or 20 theatre style, The Computer Suite (Wishaw) has space and IT equipment for 10, The Small Church Hall (Wishaw) has a capacity of 40, The Large Church Hall (Wishaw) has a capacity of 60", "required" => "Required" ) ;
$form_mail['field_14'] = array( "name" => "field_14", "text" => "Please give details of how you would like the room set up",  "type" => "textarea", "instruction" => "e.g. theatre-style, boardroom style, flexible", "required" => "" ) ;
$form_mail['field_15'] = array( "name" => "field_15", "text" => "EQUIPMENT REQUIREMENTS",  "type" => "sectionbreak", "instruction" => "", "required" => "Not Required" ) ;
$form_mail['field_16'] = array( "name" => "field_16", "text" => "Please Select",  "type" => "checkbox", "instruction" => "Please select any equipment you wish to hire at the stated rates", "required" => "" ) ;
$form_mail['field_17'] = array( "name" => "field_17", "text" => "Do you require tea/coffee?",  "type" => "radio", "instruction" => "", "required" => "Required" ) ;
$form_mail['field_18'] = array( "name" => "field_18", "text" => "Do you require catering?",  "type" => "radio", "instruction" => "", "required" => "Required" ) ;
$form_mail['field_19'] = array( "name" => "field_19", "text" => "Section Break Text Goes Here",  "type" => "sectionbreak", "instruction" => "", "required" => "Not Required" ) ;
$form_mail['field_20'] = array( "name" => "field_20", "text" => "Date of Let",  "type" => "date(dd-mm-yyyy)", "instruction" => "", "required" => "Required" ) ;
$form_mail['field_21'] = array( "name" => "field_21", "text" => "Event Start time",  "type" => "time(hh:mm)", "instruction" => "", "required" => "Required" ) ;
$form_mail['field_22'] = array( "name" => "field_22", "text" => "Event End Time",  "type" => "time(hh:mm)", "instruction" => "", "required" => "" ) ;
$form_mail['field_23'] = array( "name" => "field_23", "text" => "Additional Information (e.g. any special requirements)",  "type" => "textarea", "instruction" => "", "required" => "" ) ;


// -- Create new vars for checkPass() & sendFormMail() --
$field_16 = array();
$field_16[0]=$_POST[ "Checkbox01_field_16"];
$field_16[1]=$_POST[ "Checkbox02_field_16"];
$field_16[2]=$_POST[ "Checkbox03_field_16"];
$field_16[3]=$_POST[ "Checkbox04_field_16"];
$field_16[4]=$_POST[ "Checkbox05_field_16"];
$_POST[ "field_16" ] = join( PHPFMG_LNCR, $field_16);

$_POST[ "field_20" ] = ( $_POST[ "field_20_DD" ] && $_POST[ "field_20_MM" ] && $_POST[ "field_20_YYYY" ] ) 
                                                         ?  $_POST[ "field_20_DD" ] . "-" .  $_POST[ "field_20_MM" ]  . "-" .  $_POST[ "field_20_YYYY" ]
                                                         : "" ;
$_POST[ "field_21" ] = ( $_POST[ "field_21_HH" ] && $_POST[ "field_21_MM" ] ) 
                                                         ? $_POST[ "field_21_HH" ] . ":" .  $_POST[ "field_21_MM" ]
                                                         : "" ;
$_POST[ "field_22" ] = ( $_POST[ "field_22_HH" ] && $_POST[ "field_22_MM" ] ) 
                                                         ? $_POST[ "field_22_HH" ] . ":" .  $_POST[ "field_22_MM" ]
                                                         : "" ;



?>
<?php
/**
* Copyright (C) : http://www.formmail-maker.com
*/

function phpfmg_display_form(){
   global $form_mail;
   @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();

   return;
}


function phpfmg_sendmail( &$form_mail ) {
if( !isset($_POST["formmail_submit"]) ) return ;

$isHideForm = false ;
   $sErr = checkPass($form_mail);

   if( isset($_SESSION[phpFMG_ID.'fmgCaptchCode']) && strtoupper($_POST['fmgCaptchCode']) != strtoupper($_SESSION[phpFMG_ID.'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) ;

   // simply chop email address to avoid my website being abused
   if( false !== strpos( strtolower($_SERVER['HTTP_HOST']),'formmail-maker.com') ){
       $cc   = substr($cc, 0, 50);
       $bcc = substr($bcc,0, 50);
   };    


$subject   = PHPFMG_SUBJECT ; 
$from      = $to ;
$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("d-m-Y"),
       '%Time%'   => date("H:i:s"),
       '%AutoID%' => $RecordID,
   );
   $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 );
   };
   $subject = phpfmg_parse_mail_body( $subject, $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("d-m-Y 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 = phpfmg_rename_harmful(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) ;
               $isLarger = (filesize($tmp)/1024) > $size ;
               $link = $isHtml ? "<a href='{$url}'>$name</a>" : $name . " ( {$url} )";
               return $isLarger ? $link : $name ; // email download link when size is larger defined size, otherwise send as attachment 
       };// 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("d-m-Y 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("d-m-Y 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("d-m-Y 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 = "" , $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;  
   //$headers .= "Content-type: {$content_type}; charset={$charset}" .PHPFMG_LNCR ; 

   $plainHeaders = $headers ; // for no attachments header
   $plainHeaders .= 'MIME-Version: 1.0' . PHPFMG_LNCR;
   $plainHeaders .= "Content-type: {$content_type}; 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 = phpfmg_rename_harmful($aFile[ "name" ]) ; 
           if( is_uploaded_file( $sFileName ) ): 

               $isSkip = '' != $file2link_size && ( (filesize($sFileName)/1024) > $file2link_size );
               // save uploaded file
               if( $isWritable && $isSave ){
                   $tofile = PHPFMG_SAVE_ATTACHMENTS_DIR . phpfmg_getRecordID() . '-' . basename($sFileRealName);
                   if( @copy( $sFileName, $tofile) ) chmod($tofile,0777);
               };

               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  );
   $status = $ok ? "\n[Email sent]" : "\n[Failed to send mail]" ;
   phpfmg_log_mail( $to, $subject, ($ok ? 'Email sent' : 'Failed to send mail') . "\n" . ($nFound ? $headers  . $txtMsg : $headers . $message), '', $type . $status ); // 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);
   $subject = phpfmg_parse_mail_body( $subject, $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("d-m-Y 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>VANL - Room Booking Form</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 ;
   if( $isHtml ){
       $body = preg_match( "/<[^<>]+>/", $body ) ? $body : nl2br($body); 
   };
   return $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(DD-MM-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}'>". htmlspecialchars_decode($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;" alt="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_hsc($field){
   echo HtmlSpecialChars( $_POST[ $field ] );
}

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_dependent_dropdown( $field_name ){
   $field = phpfmg_dependent_dropdown_get_field( $field_name );
   $dd = new DependantDropdown(); 
   $dd->parseFmgField($field);
   $html = $dd->getHtml();
   echo $html;
}

function phpfmg_dependent_dropdown_dynamic_require( $field_name ){
   $field = phpfmg_dependent_dropdown_get_field( $field_name );
   $dd = new DependantDropdown();
   $dd->parseFmgField($field);
   $dd->dynamicRequired(); 
}

function phpfmg_dependent_dropdown_get_field( $field_name ){
   if( !isset($_SESSION[phpFMG_ID]) ){
       $_SESSION[phpFMG_ID] = array();
   };
   if( !isset($_SESSION[phpFMG_ID]['DD_DATA_' . $field_name]) ){
       $base64 = phpfmg_dependent_dropdown_data();
       $data = @unserialize( base64_decode($base64) );
       $_SESSION[phpFMG_ID]['DD_DATA_' . $field_name] = $data;
   }else{
       $data = $_SESSION[phpFMG_ID]['DD_DATA_' . $field_name]; 
   };

   if( !is_array($data) ){
       return ;
   };

   foreach( $data as $field ){
       if( $field['name'] == $field_name ){
           return $field;
       };
   };
}


# ------------------------------------------------------
class DependantDropdown
{
   var $data = '';
   var $sheet = array();
   var $fields = array();
   var $fieldInfo = array( 'label', 'instruction', 'required', 'prompt' ); // describe field information from the first N rows of data
   var $prefix = 'dd'; // in case there is no name for dropdown, it will name the dropdown like dd_0, dd_1, ... 

   var $fmgField = false;
   var $newliner = "<!--esh_newline-->" ; // replace \r\n with $newliner ;
var $newtaber = "<!--esh_newtaber-->" ; // replace \t with $newtaber ;

   function DependantDropdown(){
   }


   function lookupFieldColumn( $field, $column, $lookup, $contentType='text/plain', $charset='utf-8' ){
       $this->parseFmgField( $field );
       $this->nocache_headers( $contentType, $charset );
       return join( "\n", $this->getColumn( $column, $lookup ) );
   }

   function parseFmgField( $field ){
       if( !isset($_SESSION[phpFMG_ID]) ){
           $_SESSION[phpFMG_ID] = array();
       };
       $this->fmgField = $field;
       $value = $this->newline_back($field['value']);
       $this->data = explode("\r\n",$value);
       if( !isset($_SESSION[phpFMG_ID][ "DD_".$field['name'] ]) ){
           $this->parseData($field);
           $_SESSION[phpFMG_ID][ "DD_".$field['name'] ] = $this->fields;
       }else{
           $this->fields = $_SESSION[phpFMG_ID][ "DD_".$field['name'] ]; 
       };
       $this->makeupFieldsName();
   }

function	newline_back( $str = "" ){
	return str_replace( array($this->newtaber, $this->newliner),  array("\t","\r\n"), $str );
}

   function nocache_headers($contentType='text/plain', $charset='utf-8'){
       header("Expires: Mon, 01 Jan 1970 00:00:01 GMT");
       header("Cache-Control: max-age=0, no-store, no-cache, must-revalidate");
       header("Cache-Control: post-check=0, pre-check=0", false);
       header("Pragma: no-cache");
       header( "Content-Type: {$contentType}; charset={$charset}" );
   }


   function setData( $s ){
       $this->data = $s ;
   }

   function setPrefix( $s ){
       $this->prefix = $s;
   }

   function parseData(){
       $tab = chr(0x09);
       $nFieldInfoRows = count( $this->fieldInfo );
       for( $i = 0, $n = count($this->data); $i < $n; $i ++ ){
           $line = str_replace('"', '', $this->data[$i] );
           $cols = explode( $tab, $line );

           if( is_array($cols) && count($cols) > 1 ){

               if( $i < $nFieldInfoRows ){
                   $trims = array();
                   foreach( $cols as $col ){
                       $trims[] = trim($col);
                   };
                   $this->fields[ $this->fieldInfo[$i] ] = $trims;
               }
               else
                   $this->fields['data'][] = $cols;

           }; // if

           //if ( $i > 1000 ) break;
       }; // for

   }

   // $quickTest : to see whether a column contains data
   function getColumn( $n, $lookup = array(), $quickTest = false ){ 
       $count = count($lookup);
       if( $n > 0 && empty($count) ){
           return array(); // can not get column without search query  
       };

       $col        = array();
       $lastValue  = $lookup[ $count - 1 ];
       $flatLookup = join( '|', $lookup );

       foreach( $this->fields['data'] as $r ){

           if( !isset($r[$n]) )
               continue;

           $value = trim($r[$n]);
           if( $value == '' )
               continue;

           //$value = $r[$n];
           if( $n == 0 ){            
               $col[] = $value;
           }else{

               //if( trim($r[$n-1]) == $lastValue ){ // quick check to improve performance 
               if( $r[$n-1] == $lastValue ){ // quick check the last value to improve performance
                   $leftCols       = array_slice( $r, 0, $n );
                   $flatLeftValues = join( '|', $leftCols );
                   if( $flatLeftValues == $flatLookup ){ // show value only by lookuping by joining all its parents' values
                       $col[] = $value;
                   };
               }; // if

           }; // if $n == 0

           if( $quickTest && count($col) > 0 ) break;

       }; // foreach

       return array_unique($col);
   }

   function getColumnOptions( $n, $lookup = array(), $default = '' ){
       $opts = array();
       foreach( $this->getColumn($n, $lookup) as $v ){
           $selected = $default == $v ? 'selected' : '' ; 
           $opts[] = "<option {$selected} value=\"" . htmlspecialchars($v) . "\">{$v}</option>";
       };
       return join("\n",$opts);
   }

   function getHtml(){
       $html = array();

       $field_name = $this->fmgField['name'];
       $this->prefix = $field_name;
       $count = count($this->fields['label']);

       // prepare for getting column options after form submitted
       $lookup = array();
       $isPost = isset($_POST[ $this->fields['name'][0] ]);
       if( $isPost ){
           for( $i = 0; $i < $count; $i++  ){
               $label        = $this->fields['label'][$i];
               if( empty($label) )
                   continue;

               $lookup[] = $_POST[ $this->fields['name'][$i] ];  
           };
       };

       for( $i = 0; $i < $count; $i++  ){
           $label        = $this->fields['label'][$i];
           if( empty($label) )
               continue;

           $name         = $this->fields['name'][$i];
           $instruction  = $this->fields['instruction'][$i];
           $prompt       = $this->fields['prompt'][$i];
           $required     = $this->fields['required'][$i];
           $promptOption = empty($prompt) ? "" : "<option value=''>{$prompt}</option>";
           if( $isPost )
               $options = $this->getColumnOptions( $i, array_slice($lookup,0,$i), $_POST[$name] );
           else
               $options = $this->getColumnOptions( $i, array(), '' );

           $select = "<select id='{$name}' class='text_select' name='{$name}' onchange=\"dd_change({$i}, {$count}, '{$this->prefix}');\">{$promptOption}" . $options . "</select>";
           $sRequired = "<label class='form_required' >" . (strtolower($required) == 'required'? '*' : ' ') . "</label>" ;
$li = "
<li class='field_block' id='{$name}_div'>
   <div class='col_label'>
   <label class='form_field'>{$label}</label>{$sRequired} 
   </div>
<div class='col_field'>
   	{$select}
   	<div id='{$name}_tip' class='instruction'>{$instruction}</div>
</div>
</li>
";
           $html[] = $li;
       };

       echo join("\n\n",$html);

   }


   function dynamicRequired(){
       if( !isset($_POST) ){
           return ;
       };

       global $form_mail;
       $field_name = $this->fmgField['name'];
       $this->prefix = $field_name;
       $count = count($this->fields['label']);

       $lookup = array();
       $isPost = isset($_POST[ $this->fields['name'][0] ]);
       if( $isPost ){
           for( $i = 0; $i < $count; $i++  ){
               $label        = $this->fields['label'][$i];
               if( empty($label) )
                   continue;

               $lookup[] = $_POST[ $this->fields['name'][$i] ];  
           };
       };

       for( $i = 0; $i < $count; $i++  ){
           $label        = $this->fields['label'][$i];
           if( empty($label) )
               continue;

           $name = $this->fields['name'][$i];
           $required = $this->fields['required'][$i];
           if( strtolower($required) == 'required' ){
               $rows = $this->getColumn( $i, array_slice($lookup,0,$i), true );
               if( empty($rows) ) {
                   $form_mail[ $name ]['required'] = '' ; //
               };
           }else{
               $form_mail[ $name ]['required'] = '' ;
           };  
       };

   }


   function getFormMailArrayCode(){
       $code = array();
       for( $i = 0, $n = count($this->fields['label']); $i < $n; $i++  ){
           $label        = $this->fields['label'][$i];
           if( empty($label) )
               continue;
           $name         = $this->fields['name'][$i];
           $instruction  = $this->fields['instruction'][$i];
           $prompt       = $this->fields['prompt'][$i];
           $required     = $this->fields['required'][$i];
		$code[] = "\$form_mail['{$name}'] = array( \"name\" => \"$name\", \"text\" => \"" . addslashes( $label ) . "\",  \"type\" => \"select\", \"instruction\" => \"$instruction\", \"required\" => \"$required\" ) ;" ;
       };
       return join("\n",$code);
   }    

   function makeupFieldsName($default='field_99'){
       $field_name = isset($this->fmgField['name']) ? $this->fmgField['name'] : $default;
       $this->prefix = $field_name;
       for( $i = 0, $n = count($this->fields['label']); $i < $n; $i++  ){
           $this->fields['name'][$i] = $this->prefix . '_' . $i;
       };
   }

}



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 />";
           $labelLeft = ''; //0 == $i ? '' : "<div class='form_field'> </div><div class='choice'> </div>" ; // spacer for text algin left             
           $radios[] = "{$labelLeft}<input type='{$type}' name='{$newname}' id='{$id}'  value=\"{$o['value']}\"  {$checked} class='form_{$type}' ><label class='form_choice_text' for='{$id}'>{$o['text']}</label><br>";
           $i ++ ;
       };
   };
   $s = join("\t\n",$radios);
   //$s = "<div class='choices'>$s</div>";

   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_rename_harmful( $name ){
   if( defined('PHPFMG_BLOCK_HARMFUL') && 'Y' == PHPFMG_BLOCK_HARMFUL ){
	$ext = strrchr(strtolower($name), '.');
	if( $ext !== false ){
           $n = strpos( strtolower(PHPFMG_HARMFUL_EXTS), $ext );
           if( $n !== false ){
               return $name . '.bak' ;
           };
       };
   };

   return $name;
}


function phpfmg_redirect_js(){
   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>"; 
   };
}


if (!function_exists("htmlspecialchars_decode")) {
  function htmlspecialchars_decode($string, $quote_style = ENT_COMPAT) {
      return strtr($string, array_flip(get_html_translation_table(HTML_SPECIALCHARS, $quote_style)));
  }
}



function phpfmg_text_align(){
   $align = strtolower(defined('PHPFMG_TEXT_ALIGN') ? PHPFMG_TEXT_ALIGN : 'top');
   switch( $align ){
       case 'left' :
       case 'right' :

           $labelWidth = '158px';
           if( false !== strpos( strtolower($_SERVER['HTTP_USER_AGENT']), 'msie') ){
           # ----------- for IE -------
           $css = "
ol.phpfmg_form{
   width: 468px;
}

div.col_field, div.col_label{
   display:inline;
   float:left;
}

div.col_label{
   width:{$labelWidth};
   text-align: {$align};
}
";

           }else{

           # ----------- for Firefox -------
           $css = "
div.col_label{
   float:left;
   width:{$labelWidth};
   text-align: {$align};
}

div.col_field{ margin-left:{$labelWidth}; }
";
           }; // if
           break;

       case 'top' :
       default:
           $css = "";
           break;
   }; // switch

   echo $css;
}


function phpfmg_header(){
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
   <title>VANL - Room Booking Form</title>
   <meta http-equiv="content-type" content="text/html; charset=<?php echo defined('PHPFMG_CHARSET') ? PHPFMG_CHARSET : 'UTF-8'; ?>">
   <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">

<?php
phpfmg_form_css();
?>

</head>

<body>

<div class='form_description'>

</div>
<?php
}



function phpfmg_footer(){
?>

<div class='form_footer'>

</div>
<?php
   if( defined('PAYPAL_ID') && '' == PAYPAL_ID ){ 
?>


<br><br>

<div style="padding-left:10px; font-size:11px;color:#cccccc;text-decoration:none;">
	:: <title="VANL Booking Form" style="color:#cccccc;text-decoration:none;font-weight:bold;">Modified by VANL ::
</div>

<?php
};// if

?>
</body>
</html>
<?php
}



function phpfmg_javascript( $sErr = '' ){
?>
<script type="text/javascript">
function dd_change( n, max, prefix ){
   if( n >= max-1 )
       return; // the last dropdown, no need to query

   //var prefix = 'dd_' ;
   // reset all other dropdown options
   var next = n+1; 
   for( var i = next; i < max; i ++ ){
       var dd = document.getElementById(prefix +'_' + i );
       if( dd && dd.length >= 1 ) dd.length = 1 ; // keep the first one '- select -'
   };


   // request drop down data from server
   var me = this;
   var http;
   if(navigator.appName == "Microsoft Internet Explorer"){
       me.http = new ActiveXObject("Microsoft.XMLHTTP");
   }else{
       me.http = new XMLHttpRequest();
   };


   // build query string
   var lookup = [];
   for( var i = 0; i < next; i ++ ){
       lookup.push( "lookup[" + i + "]=" + document.getElementById(prefix +'_' +  i ).value )
   };
   lookup = lookup.join('&');

   var url = '<?php echo PHPFMG_ADMIN_URL . '?mod=dd&func=lookup&' ; ?>n='+next+ '&field_name=' + prefix + '&' + lookup;
   me.http.open('get', url);
   me.http.onreadystatechange = function(){

       if( me.http.readyState == 4 ){
           // rebuild the next dropdown options
           var eNext = document.getElementById(prefix +'_' + next );
           if( !eNext )
               return;

           var data = me.http.responseText;    
           var opts = String(data).split("\n");
           for( var j = 0, J = opts.length; j < J; j ++ ){
               eNext.options[ eNext.length ] = new Option( opts[j], opts[j], false, false );                
           }; // for
       }; //if

   }; 
   me.http.send(null);

}


function PHPFMG( formID ){
   var frmID = formID;
   var exts = {
       'upload_control' : '<?php echo PHPFMG_UPLOAD_CONTROL; ?>',
       'harmful_exts'  : '<?php echo PHPFMG_HARMFUL_EXTS; ?>',
       'harmful_errmsg': "<?php echo addslashes(PHPFMG_HARMFUL_EXTS_MSG); ?>",
       'allow_exts'  : '<?php echo PHPFMG_ALLOW_EXTS; ?>',
       'allow_errmsg': "<?php echo addslashes(PHPFMG_ALLOW_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'; 
           };
           var T = $( A[i] + '_tip' );
           if( T ){
               T.className += ' instruction_error'; 
           };
       };
       if( A.length > 0 ) $('err_required').style.display='';
   }

   this.choice_clicked = function( id ){
       $(id).checked = !$(id).checked ;
   }


   this.init = function(){
       //addLabelEvents();
       addFieldBlockEvents();
   }

   this.harmful = function(e){
       if( 'deny' != exts['upload_control'] ){
           return; 
       };

       var ext = file_ext(e.value);
       if( -1 != exts['harmful_exts'].toLowerCase().indexOf(ext) ){
           alert( exts['harmful_errmsg'] );
           e.value = '';
       };
   } 

   this.is_allow = function(e){
       if( 'allow' != exts['upload_control'] ){
           return; 
       };

       var ext = file_ext(e.value);
       if( -1 == exts['allow_exts'].toLowerCase().indexOf(ext) ){
           alert( exts['allow_errmsg'] );
           e.value = '';
       };
   } 

   this.check_upload = function(e){
       if( '' == exts['upload_control'] )
           return ;
       else
           return ( 'deny' == exts['upload_control'] ) 
                  ? this.harmful(e) 
                  : this.is_allow(e);
   }

   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();
fmgHandler.init();

<?php
if( isset($sErr['fields']) ){
   echo"
   location.href='#error'; 
   fmgHandler.highlight_fields('" . join(',',$sErr['fields']) ."');
   ";
};
?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FrCQkJCkRhdGUgb2YgTGV0CWZpZWxkXzIwCURhdGUoTU0tREQtWVlZWSkJTXIufE1ycy58TXMufE1pc3MJUmVxdWlyZWQJCkV2ZW50IFN0YXJ0IHRpbWUJZmllbGRfMjEJVGltZShISDpNTSkJTXIufE1ycy58TXMufE1pc3MJUmVxdWlyZWQJCkV2ZW50IEVuZCBUaW1lCWZpZWxkXzIyCVRpbWUoSEg6TU0pCU1yLnxNcnMufE1zLnxNaXNzCQkKVGltZUFkZGl0aW9uYWwgSW5mb3JtYXRpb24gKGUuZy4gYW55IHNwZWNpYWwgcmVxdWlyZW1lbnRzKQlmaWVsZF8yMwlUZXh0QXJlYQkJCQo=";
}

function phpfmg_dependent_dropdown_data(){
   return "YTowOnt9";
}
?>

Create an account or sign in to comment

Account

Navigation

Search

Search

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.