function simple_meta_keywords()
{
    global $posts, $default_keywords;
    $keywords = explode(',', $default_keywords);
    if (is_single()) {
        // pull the tags for the post
        $tags = get_the_tags($posts[0]->ID);
        if (!empty($tags)) {
            foreach ($tags as $tag) {
                $keywords[] = clean_tag($tag->name);
            }
            // remove dupes
            $keywords = array_unique($keywords);
        }
    }
    echo "<meta name=\"keywords\" content=\"" . implode(', ', $keywords) . "\" />\n";
}
示例#2
0
function clean_html($html)
{
    $clean = "";
    $pre = 0;
    $html = clean_unicode($html);
    for ($i = 0; $i < mb_strlen($html); $i++) {
        //$c = substr($html, $i, 1);
        $c = mb_substr($html, $i, 1);
        if ($c == "<") {
            $s = "";
            for ($i = $i + 1; $i < mb_strlen($html); $i++) {
                //$c = substr($html, $i, 1);
                $c = mb_substr($html, $i, 1);
                if ($c == ">") {
                    break;
                }
                $s .= $c;
            }
            $tag = clean_tag($s);
            if ($tag == "<pre>") {
                $pre++;
            } else {
                if ($tag == "</pre>") {
                    $pre--;
                }
            }
            $clean .= $tag;
        } else {
            //if ($pre > 0 && $c == "\n") {
            //	$clean .= "<br/>";
            //} else {
            $clean .= $c;
            //}
        }
    }
    $clean = str_replace("\t", " ", $clean);
    $clean = str_replace("\n", " ", $clean);
    $clean = str_replace("\r", " ", $clean);
    while (string_has($clean, "  ")) {
        $clean = str_replace("  ", " ", $clean);
    }
    $clean = str_replace("> ", ">", $clean);
    $clean = str_replace(" <", "<", $clean);
    $clean = str_replace("FORCEWHITESPACE", " ", $clean);
    $clean = trim($clean);
    $clean = str_replace_all("  ", " ", $clean);
    $clean = str_replace_all("<br/><br/><br/>", "<br/><br/>", $clean);
    //	print "clean [$clean]";
    //	$clean = str_replace("<pre><br/>", "<pre>", $clean);
    //	$clean = str_replace("<br/></pre>", "</pre>", $clean);
    //	$clean = str_replace("<li><br/>", "<li>", $clean);
    //	$clean = str_replace("<br/></li>", "</li>", $clean);
    //	$clean = str_replace("<ul><br/>", "<ul>", $clean);
    //	$clean = str_replace("<br/></ul>", "</ul>", $clean);
    //	$clean = str_replace("<ol><br/>", "<ol>", $clean);
    //	$clean = str_replace("<br/></ol>", "</ol>", $clean);
    //	print "clean2 [$clean]";
    $clean = clean_newlines("pre", $clean);
    $clean = clean_newlines("ol", $clean);
    $clean = clean_newlines("ul", $clean);
    $clean = clean_newlines("li", $clean);
    $clean = clean_newlines("blockquote", $clean);
    $clean = clean_entities($clean);
    $clean = make_clickable($clean);
    return $clean;
}
     $body = $_POST['body'];
     if ($_POST['js_enabled'] === "false") {
         $body = nl2br($body, false);
     }
     $body = mysql_real_escape_string(str_replace("javascript:", "", strip_tags_attributes($body, "<a><b><i><u><span><div><p><br><hr><font><ul><li><ol><dt><dd><h1><h2><h3><h4><h5><h6><h7><del><map><area><strong><em><big><small><sub><sup><ins><pre><blockquote><cite><q><center><marquee><table><tr><td><th>", "href,src,alt,class,style,align,valign,color,face,size,width,height,shape,coords,target,border,cellpadding,cellspacing,colspan,rowspan")));
     $title = mysql_real_escape_string($_POST['title']);
     $language = mysql_real_escape_string($_POST['language']);
     $query = "INSERT INTO press (`Name`, `Body`, `CommentCount`, `Deleted`, `Approved`, `Attachment`, `Upvotes`, `Mod`, `ExternalAttachment`, `Language`, `Posted`)\n\t\t\t\t\t\t\tVALUES ('{$title}', '{$body}', '0', '0', '0', '{$upload_url}', '0', '', '1', '{$language}', CURRENT_TIMESTAMP)";
     if (mysql_query($query)) {
         $insert_id = mysql_insert_id();
         if (!empty($_POST['tags'])) {
             // tags were entered.
             $tags = $_POST['tags'];
             $tags_list = explode(",", $tags);
             foreach ($tags_list as $tag) {
                 $tag = mysql_real_escape_string(trim(clean_tag($tag)));
                 if (!empty($tag)) {
                     $query = "INSERT INTO tags (`Table`, `ItemId`, `TagName`) VALUES ('press', '{$insert_id}', '{$tag}')";
                     mysql_query($query);
                 }
             }
         }
         echo "<p><strong>Your press release was successfully submitted.</strong> It will have to be approved before it appears on the front page.</p>\n\t\t\t\t\t\t\t\t<p><a href=\"/\" class=\"page-button\">&lt;&lt; back to front page</a></p>";
     } else {
         echo mysql_error();
         $var_code = ANONNEWS_ERROR_DATABASE_ERROR;
         // Generic upload error
         require "module.error.php";
     }
 } else {
     $var_code = ANONNEWS_ERROR_EMPTY_BODY;