将查询字符串传递给表单选择选项


Passing query string to form select option

嗨,伙计们,我有这个代码检查链接:

$reciprocal_linkback = reciprocal_linkback("$contenturl","http://www.mydomain.com",1);
if ("$reciprocal_linkback"=="0") {

$contenturl是url,将检查我的网站(http://www.mydomain.com)

问题是我需要检查url和主页。我使用了以下代码:

$parse = parse_url($contenturl);

最后的结果是:

$parse = parse_url($contenturl);
$reciprocal_linkback = reciprocal_linkback("$contenturl, $parse","http://www.mydomain.com",1);
    if ("$reciprocal_linkback"=="0") {

我不知道如何使用像$contenturl, $parse这样的多个变量,所以我可以检查两个链接对我的域。

如果你能帮助我,我会很感激的。

Sicnerely .

编辑:这里是函数

function reciprocal_linkback($check_url, $link, $strict = "0") {
    global $global;
    global $field;
    $field['hostname'] = "";
    $field['hostname_port'] = "80";
    $field['result'] = "0";
    preg_match("/^(http:'/'/)?([^'/]+)/i",$check_url, $field['hostname']);
    $field['hostname_short'] = $field['hostname'][2];
    $field['hostname_end'] = str_replace($field['hostname'][0], "", $check_url); # We don't want http://, we want the domain
    $field['url_get'] = fsockopen($field['hostname_short'], $field['hostname_port']); # Connect to domain
    if ($field['url_get']) { # We're connected...
        if(trim($field['hostname_end'])=="") { # No filename, add a slash to end URL
            $field['hostname_page'] = "/";
        } else {
            $field['hostname_page'] = $field['hostname_end']; # Filename
        }
        fputs($field['url_get'], "GET ".$field['hostname_page']." HTTP/1.0'r'nHost: ".$field['hostname_short']."'r'n'r'n"); # Request page from domain
        $field['url_content'] = "";
        while(!feof($field['url_get'])) { # Get data by line and store
            $field['url_content'] .= fgets($field['url_get'], 10240);
        }
        if (eregi($link, $field['url_content'])) { # Can we find the URL in the page?
            if ("$strict"=="1") { # Check for nofollow
                $field['result'] = "1"; # Success, we have a link, now check for nofollow
                $field['link_position'] = strpos($field['url_content'], $link); # Find position of URL being checked
                $field['link_html_end'] = substr($field['url_content'],($field['link_position'] + strlen($link)),200); # Get HTML after URL
                $field['link_html_start'] = substr($field['url_content'],($field['link_position'] - strlen($link) - 100),200); # Get HTML before URL
                $field['link_html_end_explode'] = explode(">",$field['link_html_end']);
                $field['link_html_start_explode'] = explode("<",$field['link_html_start']);
                $link_html_start_count = count($field['link_html_start_explode']) - 1;
                $field['link_html_start_explode'] = explode("=",$field['link_html_start_explode'][$link_html_start_count]);
                $field['link_html_tag'] = $field['link_html_end_explode'][0].$field['link_html_start_explode'][0]; # Get link HTML, without URL and surrounding HTML
                if (eregi("nofollow", $field['link_html_tag'])) { # Can we find a nofollow tag in link HTML?
                    $field['result'] = "0"; # Nofollow tag found
                }
            } else {
                $field['result'] = "1"; # Success, we have a link, but nofollow not checked
            }
        }
        fclose($field['url_get']);
    } else {
        $field['result'] = "2"; # Cannot read page
    }
    return $field['result'];
}

和我上面提到的完整代码:

// Check to see if have backlink and nofollow atribute
$reciprocal_linkback = reciprocal_linkback("$contenturl","http://www.dumpvid.com",1);
if ("$reciprocal_linkback"=="0") {
$_SESSION['submitstatus'] = "<div class=error><b>Error:</b> Backlink was not found, or nofollow detected.</div> ";
header('Location: '.$frompage.'');
 exit; 
}

我需要让它检查url本身和来自同一url的域。

这就是为什么我使用$parse = parse_url($contenturl);转换域名中的url。只有顶级域名,但力工作。

你可以这样做:

$contenturl = "http://domain.com/video_content.html";
$parse = parse_url($contenturl);
$base_url = $parse["host"]; // domain.com

并调用两次:

$linkback1 = reciprocal_linkback($contenturl, "http://www.mydomain.com", 1);
$linkback2 = reciprocal_linkback($base_url, "http://www.mydomain.com", 1);