function extract() { $txt =& $this->text; $len = strlen($txt); $length =& $this->length; $ngrams =& $this->ngrams; $buf = ''; $ultimo = ''; for ($i = 0; $i < $len; $i++) { if (strlen($buf) < $length) { if (!useful($txt[$i])) { continue; } if (is_space($txt[$i]) && is_space($ultimo)) { continue; } $buf .= is_space($txt[$i]) ? '_' : $txt[$i]; $ultimo = $txt[$i]; } else { $buf = strtolower(str_replace(" ", "_", $buf)); $ngrams[$buf] = isset($ngrams[$buf]) ? $ngrams[$buf] + 1 : 1; $ultimo = ''; $buf = ''; //The last caracter weren't accumulated, so decrement the counter and in the next itineration it will be hanled. $i--; } } }
function ext_search($field, $string) { $search = trim(stripslashes($string)); print "{$search}<br><br>"; $arr = preg_split('/(\\s|\\)|\\()/', $search, -1, PREG_SPLIT_DELIM_CAPTURE); print_r($arr); for ($i = 0; $i < count($arr); $i++) { $a = trim($arr[$i]); // spazio if (is_space($a)) { $newarr[] = $a; continue; } // connettivo logico if (is_logic($a)) { $newarr[] = " {$a} "; continue; } // parentesi if (is_par($a)) { $newarr[] = $a; continue; } $str = $a; $added = 0; // se le espressioni successive sono spazi o parole, uniscile a questa for ($j = $i + 1; $j < count($arr); $j++) { if (!is_par($arr[$j]) && !is_logic($arr[$j])) { $str .= $arr[$j]; $added++; } else { break; } } $i += $added; $newarr[] = " {$field} LIKE '%" . mysql_escape_string(trim($str)) . "%' "; } $final = "(" . implode('', $newarr) . ")"; return $final; }
function item_display($station, $itemId, $item, $lvl = 0) { global $Db, $hrwidth, $pos_fuels, $xpandall; $type = $Db->getTypeFromTypeId($item["typeID"]); $name = $type["typeName"]; /* New field - rawQuantity Items in the AssetList (and ContractItems) now include a rawQuantity attribute if the quantity in the DB is negative. Negative quantities are in fact codes, -1 indicates that the item is a singleton (non-stackable). If the item happens to be a Blueprint, -1 is an Original and -2 is a Blueprint Copy. For further information about negative quantities see this devblog http://www.eveonline.com/devblog.asp?a=blog&nbid=2324 */ if (strpos($name, " Blueprint") !== false && isset($item["rawQuantity"]) && (int) $item["rawQuantity"] == -2) { $name .= " (Copy)"; } $output = ""; if ($pos_fuels && !contains_pos_fuel($item)) { return; } if ($type == "") { $name = "<b><span style='font-size:80%;'>[UNKNOWN ITEM TYPE " . $item["typeID"] . "]</span></b>"; } else { type_check($type, $station); } $space = ""; for ($i = 0; $i < $lvl; $i++) { $space .= " "; } if (isset($item["contents"])) { $output .= "{$space}<a href=\"#\" onclick=\"return toggle_visibility('i" . $itemId . "');\">"; $output .= "{$name} [" . count($item["contents"]) . "]</a><br>\n"; $output .= "<div id=\"i" . $itemId . "\" style=\"" . ($xpandall && (!$pos_fuels || !is_space($item)) ? "display:block;" : "display:none;") . "\">\n<HR align=left>\n"; foreach ($item["contents"] as $itemIdC => $itemC) { $output .= item_display($station, $itemIdC, $itemC, $lvl + 1); } $output .= "<HR align=left></div>"; } else { if (!$pos_fuels || $pos_fuels && is_pos_fuel($type)) { $output .= $space . ($item["quantity"] == "1" ? "" : $item["quantity"] . " x ") . $name . "<br>\n"; } } return $output; }
function char_class($char) { $ret = is_cyr($char) ? '0001' : (is_space($char) ? '0010' : (is_dot($char) ? '0011' : (is_pmark($char) ? '0100' : (is_hyphen($char) ? '0101' : (is_number($char) ? '0110' : (is_latin($char) ? '0111' : (is_bracket1($char) ? '1000' : (is_bracket2($char) ? '1001' : (is_single_quote($char) ? '1010' : (is_slash($char) ? '1011' : (is_colon($char) ? '1100' : '0000'))))))))))); return str_split($ret); }