function rsscache_update_normalize($d) { global $db; global $table_suffix; // HACK: fix garbage in the database if (strstr($d['rsstool_url'], 'www.google.com')) { // remove eventual google redirect $offset = strpos($d['rsstool_url'], '?q=') + 3; $len = strpos($d['rsstool_url'], '&source=') - $offset; $d['rsstool_url'] = substr($d['rsstool_url'], $offset, $len); // desc $offset = 0; $len = strrpos($d['rsstool_desc'], '<div '); if ($len) { $d['rsstool_desc'] = substr($d['rsstool_desc'], $offset, $len); } } else { if (strstr($d['rsstool_url'], 'news.google.com')) { // remove eventual google redirect $offset = strpos($d['rsstool_url'], '&url=') + 5; $len = strpos($d['rsstool_url'], '&usg=') - $offset; $d['rsstool_url'] = substr($d['rsstool_url'], $offset, $len); } else { if (strstr($d['rsstool_url'], 'www.youtube.com')) { $d['rsstool_url'] = str_replace('&feature=youtube_gdata', '', $d['rsstool_url']); } } } // fix category names // $d['rsscache_category'] = trim ($d['rsscache_category']); // $d['rsscache_moved'] = trim ($d['rsscache_moved']); // strip any tags from the desc $p = $d['rsstool_desc']; $p = str_replace('>', '> ', $p); $p = strip_tags2($p); $p = str_replace(array(' ', ' ', ' ', ' ', ' '), ' ', $p); $d['rsstool_desc'] = $p; $d['rsstool_desc'] = str_replace('youtube.com', '', $d['rsstool_desc']); // update $p = sprintf("%u", crc32($d['rsstool_url'])); $sql_query_s = 'UPDATE rsstool_table' . $table_suffix . ' SET' . ' rsstool_url = \'' . $d['rsstool_url'] . '\', ' . ' rsstool_url_crc32 = ' . $p . ', ' . ' rsstool_desc = \'' . $d['rsstool_desc'] . '\'' . ' WHERE rsstool_url_crc32 = ' . $d['rsstool_url_crc32'] . ' ;'; echo $sql_query_s . "\n"; $db->sql_write($sql_query_s, 0); // rename thumbnail if ($d['rsstool_url_crc32'] != $p) { if (rename('../htdocs/thumbnails/rsscache/' . $d['rsstool_url_crc32'] . '.jpg', '../htdocs/thumbnails/rsscache/' . $p . '.jpg')) { echo 'rename ' . $d['rsstool_url_crc32'] . '.jpg ' . $p . '.jpg' . "\n"; } } }
function misc_seo_description($html_body) { // generate meta tag from the body $p = strip_tags2($html_body); $p = str_replace(array(' ', '>', '<', "\n", ','), ' ', $p); $p = misc_get_keywords($p, 1); return '<meta name="Description" content="' . $p . '">' . '<meta name="keywords" content="' . $p . '">'; }
/** * Strip all tags, convert line break to space and trim string * @param string The string to clean * @return string The cleaned string */ public static function cleanString($str) { return trim(str_replace(array("\n", "\r"), ' ', strip_tags2($str))); }