function parse_links($s, $cached = 1) { // turn plain text urls into links // return preg_replace ('/\\b(https?|ftp|file):\/\/[-A-Z0-9+&@#\/%?=~_|!:,.;]*[-A-Z0-9+&@#\/%=~_|]/i', "<a href=\"#\" onclick=\"open_url('\\0')\";return false;>\\0</a>", $s); // return ereg_replace("[[:alpha:]]+://[^<>[:space:]]+[[:alnum:]/]","<a href=\"\\0\">\\0</a>", $s); // $s = eregi_replace("((([ftp://])|(http(s?)://))((:alnum:|[-\%\.\?\=\#\_\:\&\/\~\+\@\,\;])*))","<a href = '\\0' target='_blank'>\\0</a>", $s); // $s = eregi_replace("(([^/])www\.|(^www\.))((:alnum:|[-\%\.\?\=\#\_\:\&\/\~\+\@\,\;])*)", "\\2<a href = 'http://www.\\4'>www.\\4</a>", $s); $a = explode(' ', strip_tags2($s)); $a = misc_array_unique_merge($a); // remove dupes // find eventual urls for ($i = 0; isset($a[$i]); $i++) { if (is_url($a[$i])) { $url = $a[$i]; // DEBUG //echo $url; if (!stristr($url, 'http://')) { $url = 'http://' . $url; } // cached: http://web.archive.org/web/*/http://ucon64.sourceforge.net $link = '<a href="' . $url . '">' . $url . '</a>'; if ($cached == 1) { $link = $link . '[<a href="http://web.archive.org/web/*/' . $url . '">Cached</a>]'; } $s = str_replace($a[$i], $link, $s); } } return $s; }
function rsscache_sql_keyword_func($any = NULL, $require = NULL, $exclude = NULL, $table_suffix = NULL) { $debug = 0; // DEBUG // if ($debug == 1) // echo 'any: '.$any.'<br>require: '.$require.'<br>exclude: '.$exclude.'<br>'; $rsstool_table = rsscache_tablename('rsstool', $table_suffix); $keyword_table = rsscache_tablename('keyword', $table_suffix); // HACK: merge any and require since result is sorted by number of matches $q = $any . ' ' . $require; $p = ''; $p .= ' (' . ' SELECT' . ' SQL_CACHE rsstool_url_crc32, COUNT(*) AS rsscache_rows' . ' FROM ' . $keyword_table . ' WHERE ' . $keyword_table . '.rsstool_keyword_crc16' . ' IN ( '; $s = misc_get_keywords($q, 0); // isalnum() $a = explode(' ', $s); $a = misc_array_unique_merge($a); $func = 'misc_crc16'; // 0xffff keywords // $func = 'misc_crc24'; // 0xffffff keywords // $func = 'crc32'; // 0xffffffff keywords $a = array_map($func, $a); $p .= implode(', ', $a); $p .= ' )' . ' GROUP BY rsstool_url_crc32' . ' ORDER BY rsscache_rows DESC' . ' LIMIT 256' . ' )' . ' AS temp' . ' JOIN ' . $rsstool_table . ' ON ' . $rsstool_table . '.rsstool_url_crc32 = temp.rsstool_url_crc32'; // DEBUG // echo $p; //exit; return $p; }