Welcome, Guest!!
follow us on... rss

Author Topic: Calling BotScout in a custom php Contact Form  (Read 5863 times)

J2Duncan

  • Newbie
  • *
  • Posts: 1
    • View Profile
Calling BotScout in a custom php Contact Form
« on: May 13, 2013, 12:54:06 PM »
I would like to include BotScout to my custom php contact form, but i'm not sure where to call the BotScout.php file. The form fields are populated from a database. The BotScout.php file set to check the email and ip. Do I use

// BotScout.com "BotBuster" check
 include('/path/to/my/directory/BotScout.php');

If yes, where can I include it to function?

Code: [Select]
<?php
if (!empty($_SERVER['HTTP_CLIENT_IP']))
    {
      
$ip=$_SERVER['HTTP_CLIENT_IP'];
    }
    elseif (!empty(
$_SERVER['HTTP_X_FORWARDED_FOR']))
    {
      
$ip=$_SERVER['HTTP_X_FORWARDED_FOR'];
    }
    else
    {
      
$ip=$_SERVER['REMOTE_ADDR'];
    }
?>


<div class="<?php echo $form_details['form_style'?>">
    <?php
    
//load page helpers and libraries
    
if (isset($form_details['form_helpers'])) {
        foreach (
explode(' '$form_details['form_helpers']) as $helper) {
            
$this->load->helper($helper);
        }
    }
    if (isset(
$form_details['form_libraries'])) {
        foreach (
explode(' '$form_details['form_libraries']) as $library) {
            
$this->load->helper($library);
        }
    }
    
?>

    <?php echo form_open($this->site->uri_string() . '#' $form_details['form_name']) ?>
    <?php echo form_hidden('form_id'$form_details['form_id']) ?>
    <?php echo form_hidden('form_name'$form_details['form_name']) ?>
    <?php echo form_hidden('request_ip'$ip?>
    <?php echo form_hidden('request_agent'$_SERVER['HTTP_USER_AGENT']) ?>
    <?php echo anchor(''' ', array('id' => $form_details['form_name'])) ?>
    <h2><?php echo $form_details['form_title'?></h2>
    <h3><?php echo $form_details['form_instructions'?></h3>
    <?php foreach ($form_details['fields'] as $field): ?>
        <?php if (isset($this->site->customer_info[$field['name']])): ?>
            <?php if ($this->site->customer_info[$field['name']]): ?>
                <?php $field_value $this->site->customer_info[$field['name']] ?>
            <?php else: ?>
                <?php $field_value $field['label'?>
            <?php endif; ?>
        <?php elseif (set_value() == TRUE): ?>
            <?php $field_value set_value($field['name']) ?>
        <?php else: ?>
            <?php $field_value $field['label'?>
        <?php endif; ?>
        <?php if ($field['type'] == 'input'): ?>
            <input class="<?php echo $field['style'?>" type="text" <?php if(!empty($field['max_length'])) :?>maxlength="<?php echo $field['max_size'?>"<?php endif; ?> name="<?php echo $field['name'?>" value="<?php
            
if (($this->input->post('name_first')) == '') {
                echo 
$field['label'];
            } else {
                echo 
set_value($field['name']);
            }
            
?>
" onfocus="if (this.value == '<?php echo $field['label'?>') this.value = ''" onblur="if (this.value == '') this.value = '<?php echo $field['label'?>'" />

        <?php elseif ($field['type'] == 'textarea'): ?>
            <textarea name= "<?php echo $field['name'?>" onfocus="if (this.value == '<?php echo $field['label'?>') this.value = ''" onblur="if (this.value == '') this.value = '<?php echo $field['label'?>'" class="<?php echo $field['style']; ?>"><?php echo $field_value ?></textarea>

        <?php elseif ($field['type'] == 'select') : ?>
            <?php echo form_dropdown($field['name'], states_dropdown_abbr(array('' => 'State')), set_value($field['name']), 'class="required_input state_input"'?>

        <?php elseif ($field['type'] == 'radio') : ?>
            <?php echo form_label(form_radio($field['name'], $field_valueFALSE) . $field['label']); ?>

        <?php elseif ($field['type'] == 'label') : ?>
            <?php echo $field['label']; ?>
        <?php elseif ($field['type'] == 'submit') : ?>
            <div class="clear"></div>
            <?php echo form_submit($field['name'], $field['label'], 'class="' $field['style'] . '"'?>

        <?php endif; ?>
<?php endforeach ?>

<?php echo form_close() ?>
    <div class="clear"></div>
</div>

Thank you for any help.

Mike

  • Administrator
  • Sr. Member
  • *****
  • Posts: 300
    • View Profile
Re: Calling BotScout in a custom php Contact Form
« Reply #1 on: May 13, 2013, 03:32:12 PM »
To work, the BotBuster code needs to be able to "see" the submitted form variables for the user's name, email address, and IP. In some cases you might need to build a little bit of code separate from the native code in order to expose these variables so the BotBuster code can make use of them.

In your form the code needs to placed such that it can determine if it's being submitted or not. The easiest way to do this might be to check to see if those vars were present or not.


Code: [Select]
if (!empty($_SERVER['HTTP_CLIENT_IP']))
    {
      $ip=$_SERVER['HTTP_CLIENT_IP'];
    }
    elseif (!empty($_SERVER['HTTP_X_FORWARDED_FOR']))
    {
      $ip=$_SERVER['HTTP_X_FORWARDED_FOR'];
    }
    else
    {
      $ip=$_SERVER['REMOTE_ADDR'];
    }

//////////////////////////////////////////

// are we viewing the form or submitting it?
if ( !empty($_POST['request_ip'])  &&  !empty($_POST['form_id']) &&  !empty($_POST['form_name']) ){

// submitting...
// at this point you'll need to alias the incoming vars to match the ones
// used in the botbuster code, or modify the the botbuster code directly.


      // BotScout.com "BotBuster" check
      include('/path/to/my/directory/BotScout.php');



}
//////////////////////////////////////////
Please don't PM me for assistance- post your questions in the forum where others can see them.