Ejemplo n.º 1
0
 private function chunker(&$text, $style = "")
 {
     $errors = null;
     $text = collapse_spaces($text);
     $textarr = split_string($text);
     $chunksarr = split_on_spaces($textarr, $this->spaces);
     if ($style == "clean") {
         $chunksarr = remove_junk($chunksarr);
     }
     $chunkhashes = null;
     foreach ($chunksarr as $end => &$chunkarr) {
         $chunkhashes[$end] = count_words($chunkarr);
     }
     if (!$chunkhashes) {
         $errors[] = "Could not hash chunks. Huh.";
         trigger_error("Could not hash chunks. Huh.");
         return $errors;
     }
     // if cleaned style, remove all bad words and lc
     $max = array_pop(array_keys($textarr)) + 1;
     $maxlen = strlen("{$max}");
     $pad = "%0{$maxlen}s";
     foreach ($chunksarr as $end => $chunkarr) {
         $endpad = $end + 1;
         $endpad = sprintf($pad, $endpad);
         $out = $this->write_txt($chunkarr, $endpad, $style);
         $out2 = $this->write_csv($chunkhashes[$end], $endpad, $style);
         if ($out || $out2) {
             $errors = array_merge($out, $out2, $errors);
         }
     }
     if ($errors) {
         rrmdir($this->folder);
         trigger_error("Something in the chunking process went wrong.");
     }
     return $errors;
 }
Ejemplo n.º 2
0
function character_cleanup($str)
{
    # data validation
    data_validation($str, "|required|");
    return trim(collapse_spaces(eregi_replace("[^[:alnum:]!@#\$%&*()-_+=:;'\",.<>?/\\]", " ", $str)));
}