{$start} ORDER BY message_id ASC LIMIT 5000", $handler); if (mysql_num_rows($rez) > 0) { while($row = mysql_fetch_assoc($rez)) { $message_id = intval($row['message_id']+0); $words = strtolower($row['message']); $words = preg_replace("/([^-_'a-z0-9]+)/", ' ', $words); $words = explode(' ', $words); $words = array_unique($words); sort($words); foreach($words as $word) { if (!preg_match('/^[a-z0-9]+.*[a-z0-9]+$/', $word)) { $word = preg_replace('/^([^a-z0-9]*)([a-z0-9]+.*[a-z0-9]+)([^a-z0-9]*)$/', '\2',$word); } if ( (strlen($word) >= 4) // Minimum word length && (strlen($word) <= 30) // Maximum word length && preg_match('/^[a-z0-9]+.*[a-z0-9]+$/', $word) && !preg_match('/.*[^a-z0-9]+[^a-z0-9]+.*/', $word) && !preg_match('/^[0-9]+$/', $word) && !preg_match('/^[a-z0-9]+[0-9]+[a-z]+[0-9]+[a-z]+[a-z0-9]+$/', $word) ) { //echo "{$word} "; $word_id = 0; $rez2 = mysql_query("SELECT word_id FROM uo_chat_biglog_words WHERE word='".mysql_escape_string($word)."'", $handler); if (mysql_num_rows($rez2) > 0) { $word_id = mysql_fetch_assoc($rez2); $word_id = intval($word_id['word_id']+0); } mysql_free_result($rez2); if (empty($word_id)) { mysql_query("INSERT INTO uo_chat_biglog_words (word) VALUES ('".mysql_escape_string($word)."')", $handler); $word_id = mysql_insert_id(); } if (!empty($word_id)) { mysql_query("INSERT INTO uo_chat_biglog_wordhits (word_id,message_id) VALUES ({$word_id},{$message_id})", $handler); } } } } } mysql_free_result($rez); ?>