if ( hook_form_invalid() ) exit(); else if ( hook_is_form() ) { hook_create_session(); } /////////////////////////////////////////////////////////////////////////////////////////////////// function hook_form_invalid() { if ( hook_is_form_processing() ) { if ( !hook_is_valid_session() ) return true; if ( hook_is_blocked_ip() ) return true; if ( hook_has_html() ) return true; if ( hook_has_keywords() ) return true; } return false; } /////////////////////////////////////////////////////////////////////////////////////////////////// function hook_is_blocked_ip() { switch ( $_SERVER['REMOTE_ADDR'] ) { case '200.88.223.98': case '125.137.127.80': return true; } return false; } /////////////////////////////////////////////////////////////////////////////////////////////////// function hook_is_form() { return ( $_REQUEST['src'] == 'forms' && ($_REQUEST['id'] != '' || $_REQUEST['ref'] != '' ) ); } /////////////////////////////////////////////////////////////////////////////////////////////////// function hook_is_valid_session() { return ( $_SESSION['hook_freedom_form'] == session_id() ); } /////////////////////////////////////////////////////////////////////////////////////////////////// function hook_create_session() { $_SESSION['hook_freedom_form'] = session_id(); } /////////////////////////////////////////////////////////////////////////////////////////////////// function hook_has_html() { $field_list = hook_fields(); foreach ($field_list as $field) { if ( strip_tags( $_REQUEST[$field] ) != $_REQUEST[$field] ) return true; } return false; } /////////////////////////////////////////////////////////////////////////////////////////////////// function hook_fields() { return array( 'formField_Contact', 'formField_Information', 'formField_Name', 'formField_Comments', 'formField_First_Name', 'formField_ProgamNeeds' ); } /////////////////////////////////////////////////////////////////////////////////////////////////// function hook_keywords() { // use lower case words only return array( 'viagra', 'viagr', 'cialis', 'cailis', 'levitra', 'replica', 'ringtones', 'fuck', 'asshole', 'shit', 'paxil', '<', 'penis' ); } /////////////////////////////////////////////////////////////////////////////////////////////////// function hook_is_form_processing() { return ( $_REQUEST['src'] == 'forms' && $_REQUEST['srctype'] == 'process' ); } /////////////////////////////////////////////////////////////////////////////////////////////////// function hook_has_keywords() { $keyword_list = hook_keywords(); $field_list = hook_fields(); foreach ( $field_list as $field ) { $haystack = strtolower( $_REQUEST[$field] ); foreach ( $keyword_list as $needle ) { if ( strpos( $haystack, $needle ) !== false ) return true; } } return false; } /////////////////////////////////////////////////////////////////////////////////////////////////// ?>