English 中文(简体)
消除与空洞的内联网,与不允许列入名单的场所建立直接联系
原标题:remove links with empty insides, add a redirect link to sites that not in allowed list
<?php
$allowedURLHosts = array(
 youtube.com ,
 google.com 
);

$blockedURLHosts = array(
 yahoo.com ,
 208.71.34.142 
);


function getDomain($url)
{
    $pieces = parse_url($url);
    $domain = isset($pieces[ host ]) ? $pieces[ host ] :   ;
    if (preg_match( /(?P<domain>[a-z0-9][a-z0-9-]{1,63}.[a-z.]{2,6})$/i , $domain, $regs))
    {
        return $regs[ domain ];
    }
    return   ;
}

function filterLinks($str)
{
    $dom = new DOMDocument;
    @$dom->loadHTML($str);

    global $blockedURLHosts;
    global $allowedURLHosts;

    // Get all links in the document.
    $links = $dom->getElementsByTagName( a );
    $linksLength = $links->length;

    // Iterate over all links.
    while ($linksLength--)
    {
        $link = $links->item($linksLength);
        if ($link->hasAttribute( href ))
        {
            // Get the href attribute of the link.
            $src = $link->getAttribute( href );
            if ($link->nodeValue !=   )
            {
                if (in_array(getDomain($src), $blockedURLHosts))
                {
                    $link->parentNode->removeChild($link);
                }
                else if (!in_array(getDomain($src), $allowedURLHosts))
                {
                    $newlink = $dom->createElement( a );

                    if ($link->hasAttribute( title ))
                    {
                        $newlink->setAttribute( title , $link->getAttribute( title ));
                    }
                    $newlink->setAttribute( href ,  /redirect?link=  . urlencode($src));

                    $newlink->nodeValue = $link->nodeValue;

                    $link->parentNode->replaceChild($newlink,$link);
                }
            }
            else
            {
                $link->parentNode->removeChild($link);
            }
        }
    }
    $html =   ;
    foreach($dom->getElementsByTagName( body )->item(0)->childNodes as $node)
    {
        $html .= $dom->saveXML($node, LIBXML_NOEMPTYTAG);
    }
    return $html;
}

$text =  <div class="InfoText"><a href="http://www.getmyspacecomments.com/"><img src="http://ohiok.com/img/k75/laserxpc/a1/04.jpg" title="MySpace Comment Codes" alt="image" style="border: 0px;"></a><br><a href="http://www.getmyspacecomments.com/"><span style="font-size: large;">MySpace Comments</span></a><br></div>

<div style="text-align: center;"><a href="http://www.glitterbell.com/" title="MySpace Comments"></a><br><a href="http://www.glitterbell.com/">MySpace Comments at GlitterBell.com</a><br><a href="http://www.myspace.com/469121002">Add the Comment App</a></div> ;

echo filterLinks($text);
?>

与露天和近距离内的 im之间的联系没有显示。 由于某种原因,这些链接不会试图装上一页。 我仍没有完全使用这一文字,但至今没有工作。 我并不真心实实意地确定,迄今为止,哪怕错了。

<a href=”http://www.glitterbell.com/“it=“Myspace comments”></a>,因为案文内的案文空洞。

法典产出:

<div class="InfoText"><br></br><a href="/redirect?link=http%3A%2F%2Fwww.getmyspacecomments.com%2F">MySpace Comments</a><br></br></div> 

<div style="text-align: center;"><br></br><a href="/redirect?link=http%3A%2F%2Fwww.glitterbell.com%2F">MySpace Comments at GlitterBell.com</a><br></br><a href="/redirect?link=http%3A%2F%2Fwww.myspace.com%2F469121002">Add the Comment App</a></div>
问题回答

我要说的是<代码>img。 页: 1 价值财产,不序列上超文本,不应用于处理超文本。

如果你要分配确切相同的子女,则分配<儿童姓名/编码>财产。





相关问题
Brute-force/DoS prevention in PHP [closed]

I am trying to write a script to prevent brute-force login attempts in a website I m building. The logic goes something like this: User sends login information. Check if username and password is ...

please can anyone check this while loop and if condition

<?php $con=mysql_connect("localhost","mts","mts"); if(!con) { die( unable to connect . mysql_error()); } mysql_select_db("mts",$con); /* date_default_timezone_set ("Asia/Calcutta"); $date = ...

定值美元

如何确认来自正确来源的数字。

Generating a drop down list of timezones with PHP

Most sites need some way to show the dates on the site in the users preferred timezone. Below are two lists that I found and then one method using the built in PHP DateTime class in PHP 5. I need ...

Text as watermarking in PHP

I want to create text as a watermark for an image. the water mark should have the following properties front: Impact color: white opacity: 31% Font style: regular, bold Bevel and Emboss size: 30 ...

How does php cast boolean variables?

How does php cast boolean variables? I was trying to save a boolean value to an array: $result["Users"]["is_login"] = true; but when I use debug the is_login value is blank. and when I do ...

热门标签