Exemplo n.º 1
0
    $test = '/' . $not_anchor . $not_http . $domain . $subdir . '/i';
    $ret = preg_replace($test, "<a href='http://\$0' title='http://\$0'>\$0</a>", $ret);
    return $ret;
}
function tagExtLinks2($str, $activ = null, $repl = "(*)")
{
    if ($activ == null) {
        $test = "/(<a href=)" . "(\"|\\')" . "(http|https|ftp)" . "(:\\/\\/)" . "(?!" . $_SERVER['HTTP_HOST'] . ")" . "(.*)" . "(<\\/a>)/isU";
        // 7: Match the closing anchor tag
        return preg_replace($test, " \${0}" . $repl, $str);
    } else {
        $test = "/(<a href=)" . "(\"|\\')" . "(http|https|ftp)" . "(:\\/\\/)" . "(?!" . $_SERVER['HTTP_HOST'] . ")" . "(.*)" . "(\"|\\')" . "(.*)" . "<\\/a>/isU";
        // 9: Match the closing anchor
        //return preg_replace($test, " \${0} xxxxxxxx" . $repl."</a>", $str);
        return preg_replace($test, " \${0}<a href=\"\${3}\${4}\${5}\" target=\"_BLANK\">" . $repl . "</a>", $str);
    }
}
function removeLinks($str)
{
    $test = "/(<a\\s+href=)" . "([\"\\'])" . "(.*[\"'])" . "(.*>)" . "(.+)" . "(<\\/a>)" . "/isU";
    //Make it case insensitive (i), treat across newlines (s)
    //and make it Ungreedy (U)
    return preg_replace($test, "\$5", $str);
}
//if ($matches[1][0] == "http://localhost" || "localhost" || "http://127.0.0.1") { do something } if ($matches[1][0] !== "http://localhost" || "localhost" || "http://127.0.0.1") { Do something else }
$str = "Hello there everyone. I hope you are having a good day. \n Please come to http://dog.cat/ for more information or visit\n <a href=\"http://www.google.com\">google</a> now which you ca find\n at www.google.com. On the other\n hand, <a href=\"http://sdasdas/fish.html\" class=\"someclass\">asdas</a>.\n This is test of <a href=\"http://test/\">this thing</a> but it does not \n tag <a href=\"http://localhost/something.php\">localhost</a>.";
echo activateLinks($str) . "<br /><br />";
echo tagExtLinks2(activateLinks($str), True) . "<br /><br />";
echo removeLinks(tagExtLinks2(activateLinks($str), True)) . "<br /><br />";
//echo "<br/>http://www.google.com " . isValidFormedUrl("http://www.google.com")."<br />";
//echo "<br/>htp://www.google.com " . isValidFormedUrl("htp://www.google.com")."<br />";
Exemplo n.º 2
0
function prev_next_link($prevnext, $option)
{
    $database =& JFactory::getDBO();
    $jdate = JFactory::getDate();
    $act = JRequest::getCmd('act', '', 'post');
    $link_id = JRequest::getInt('link_id', '', 'post');
    $post = JRequest::get('post');
    $database->setQuery('SELECT link_id FROM #__mt_links WHERE link_approved <= 0 ORDER BY link_created ASC, link_modified DESC');
    $links = $database->loadResultArray();
    if (array_key_exists(array_search($link_id, $links) + 1, $links)) {
        $next_link_id = $links[array_search($link_id, $links) + 1];
    } else {
        $next_link_id = 0;
    }
    if (array_key_exists(array_search($link_id, $links) - 1, $links)) {
        $prev_link_id = $links[array_search($link_id, $links) - 1];
    } else {
        $prev_link_id = 0;
    }
    if ($prevnext == "next") {
        if ($next_link_id > 0) {
            $post['returntask'] = "editlink&link_id=" . $next_link_id;
        } else {
            $post['returntask'] = "listpending_links";
        }
    } elseif ($prevnext == "prev") {
        if ($prev_link_id > 0) {
            $post['returntask'] = "editlink&link_id=" . $prev_link_id;
        } else {
            $post['returntask'] = "listpending_links";
        }
    }
    switch ($act) {
        case "ignore":
            savelink($option, $post);
            break;
        case "discard":
            removeLinks(array($link_id), $option, $post);
            break;
        case "approve":
            $post['publishing']['link_approved'] = 1;
            $post['publishing']['link_published'] = 1;
            $post['publishing']['link_created'] = $jdate->toMySQL();
            savelink($option, $post);
            break;
    }
}
Exemplo n.º 3
0
$tag = getTag($_GET["tag"]);
// if a tag is an equation we remove its number
function isNotLineWithLabel($line)
{
    return strncmp($line, "\\label", 6);
}
if ($tag["type"] == "equation") {
    $tag["value"] = implode("\n", array_filter(explode("\n", $tag["value"]), "isNotLineWithLabel"));
}
if (isset($_GET["format"]) and $_GET["format"]) {
    switch ($type) {
        case "full":
            print removeLinks($tag["value"]);
            break;
        case "statement":
            print removeLinks(removeProofs($tag["value"]));
            break;
    }
} else {
    $output = "";
    switch ($type) {
        case "full":
            $output .= convertLaTeX($_GET["tag"], $tag["file"], $tag["value"]);
            break;
        case "statement":
            $output .= convertLaTeX($_GET["tag"], $tag["file"], removeProofs($tag["value"]));
            break;
    }
    // handle footnotes
    global $footnotes;
    if (sizeof($footnotes) > 0) {