XC_Escape module

name = "XC Escape"
description = "Escape user input form"
core = "6.x"
package = "eXtensible Catalog (XC) System"


Setup:
1. Modify the code below("Code: Modification for xc_search.module") in the /sites/all/xc/xc_search/xc_search.module.
2. Copy xc_escape forder into "./site/all/module/xc".
3. Enable XC_Escape module on the administration (Site building >> modules).
    /admin/build/modules
4. Setup the following preferences (eXtensible Catalog(XC) >> Seach Interface Setup >> Search Query Exceptions)
    /admin/xc/search/escape_char

===========================================
Code: Modification for xc_search.module (around 2322 line)

1) Add the following codes into "function xc_search_form_search_validate"

  if(module_exists('xc_escape')) {
    $xc_remove_strings = xc_search_get_remove_strings();
    foreach($xc_remove_strings as $xc_remove_string){
      $values['keys'] = str_replace($xc_remove_string, '', $values['keys']);
    }
    $xc_escape_strings = xc_search_get_escape_strings();
    $values['keys'] = stripslashes($values['keys']);
    $flag_backslash = 0;
    $xc_escape_strings = str_replace('\\','',$xc_escape_strings,$flag_backslash);
    if($flag_backslash>0){
      $values['keys'] = str_replace('\\', '\\\\', $values['keys']);
    }
    foreach($xc_escape_strings as $xc_escape_string){
      $values['keys'] = str_replace($xc_escape_string, '\\'.$xc_escape_string, $values['keys']);
    }
  }


2) Add "xc_search_get_escape_strings()" function
/**
 * Get escape strings from xc_escape_admin_settings
 *
 * @param none
 * @return array
 *   escape strings
 */

function xc_search_get_escape_strings() {
  $strings = array();
  if (module_exists('xc_escape')) {
    if(variable_get('xc_escape_select_type', null) == 0){
      $strings = str_split(variable_get('xc_escape_strings', ''));
    }
  }
  return $strings;
}

/**
 * Get remove strings from xc_escape_admin_settings
 *
 * @param none
 * @return array
 *   remove strings
 */
 
function xc_search_get_remove_strings() {
  $strings = array();
  if (module_exists('xc_escape')) {
    if(variable_get('xc_escape_remove_select_type', null) == 0){
      $strings = str_split(variable_get('xc_escape_remove_strings', ''));
    }
  }
  return $strings;
}
===========================================