function pccf_filter($text)
{
    global $post;
    // get comma separated list of page ID's to exclude
    global $pccf_defaults;
    $tmp = get_option('pccf_options', $pccf_defaults);
    $exclude_id_list = $tmp['txt_exclude'];
    $exclude_id_array = explode(', ', $exclude_id_list);
    // if current page ID is in exclude list then don't filter
    if (isset($post) && in_array($post->ID, $exclude_id_array)) {
        return $text;
    }
    $wildcard_filter_type = $tmp['rdo_word'];
    $wildcard_char = $tmp['drp_filter_char'];
    if ($wildcard_char == 'star') {
        $wildcard = '*';
    } else {
        if ($wildcard_char == 'dollar') {
            $wildcard = '$';
        } else {
            if ($wildcard_char == 'question') {
                $wildcard = '?';
            } else {
                if ($wildcard_char == 'exclamation') {
                    $wildcard = '!';
                } else {
                    if ($wildcard_char == 'hyphen') {
                        $wildcard = '-';
                    } else {
                        if ($wildcard_char == 'hash') {
                            $wildcard = '#';
                        } else {
                            if ($wildcard_char == 'tilde') {
                                $wildcard = '~';
                            } else {
                                $wildcard = '';
                            }
                        }
                    }
                }
            }
        }
    }
    $filter_type = $tmp['rdo_case'];
    $db_search_string = $tmp['txtar_keywords'];
    $search = explode(",", $db_search_string);
    $search = array_unique($search);
    // get rid of duplicates in the keywords textbox
    if ($tmp['rdo_strict_filtering'] == 'strict_off') {
        // If strict filtering is OFF - use the standard str_ireplace, and str_ireplace functions
        foreach ($search as $sub_search) {
            $sub_search = trim($sub_search);
            // remove whitespace chars from start/end of string
            if (strlen($sub_search) > 2) {
                if ($wildcard_filter_type == 'first') {
                    $tmp_search = substr($sub_search, 0, 1) . str_repeat($wildcard, strlen(substr($sub_search, 1)));
                } else {
                    if ($wildcard_filter_type == 'all') {
                        $tmp_search = str_repeat($wildcard, strlen(substr($sub_search, 0)));
                    } else {
                        $tmp_search = substr($sub_search, 0, 1) . str_repeat($wildcard, strlen(substr($sub_search, 2))) . substr($sub_search, -1, 1);
                    }
                }
                if ($filter_type == "insen") {
                    $text = str_ireplace($sub_search, $tmp_search, $text);
                } else {
                    $text = str_replace($sub_search, $tmp_search, $text);
                }
            }
        }
    } else {
        // If strict filtering is ON - use regular expressions for more powerful seach and replace
        foreach ($search as $sub_search) {
            $sub_search = trim($sub_search);
            // remove whitespace chars from start/end of string
            if (strlen($sub_search) > 2) {
                if ($wildcard_filter_type == 'first') {
                    $tmp_search = substr($sub_search, 0, 1) . str_repeat($wildcard, strlen(substr($sub_search, 1)));
                } else {
                    if ($wildcard_filter_type == 'all') {
                        $tmp_search = str_repeat($wildcard, strlen(substr($sub_search, 0)));
                    } else {
                        $tmp_search = substr($sub_search, 0, 1) . str_repeat($wildcard, strlen(substr($sub_search, 2))) . substr($sub_search, -1, 1);
                    }
                }
                if ($filter_type == "insen") {
                    $text = str_replace_word_i($sub_search, $tmp_search, $text);
                } else {
                    $text = str_replace_word($sub_search, $tmp_search, $text);
                }
            }
        }
    }
    return $text;
}
Example #2
0
 function ParseFunctionDeclaration($rettypestr, $retpointertypestr, $funcname, $parastr, $isexternfunc, $deprecatedmods)
 {
     if ($deprecatedmods != "") {
         $deprecatedmods .= ";";
     }
     if ($this->IsKeywordReserved($funcname)) {
         $funcname .= "_";
     }
     $rettype = trim(str_replace_word("const", "", $rettypestr));
     $rettype = $this->ReplaceObjcType($rettype);
     $rettype = $this->EncodePointerModifiers($rettype, $retpointertypestr);
     $params = $this->ConvertCParamsPascal($parastr);
     if ($rettype == "void") {
         $result = "procedure ";
     } else {
         $result = "function ";
     }
     // if no name specified, the caller will add it
     if ($funcname != "") {
         if (!$isexternfunc) {
             $result = "{$funcname}: " . $result;
         } else {
             $result .= $funcname;
         }
     }
     if ($params != "") {
         $params = "(" . $params . ")";
     }
     if ($rettype == "void") {
         $result .= $params . "; cdecl;";
     } else {
         $result .= $params . ": " . $rettype . "; cdecl;";
     }
     if ($isexternfunc) {
         $result .= " external;{$deprecatedmods}";
     } else {
         $result .= "\n";
     }
     return $result;
 }