当前位置: 首页>>代码示例>>PHP>>正文


PHP link_exists函数代码示例

本文整理汇总了PHP中link_exists函数的典型用法代码示例。如果您正苦于以下问题:PHP link_exists函数的具体用法?PHP link_exists怎么用?PHP link_exists使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了link_exists函数的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: parseLinks

/**
 * @param $url
 * Функция для парсинга ссылок
 */
function parseLinks($url)
{
    global $domain;
    //имя домена
    global $recursiveDeep;
    // глубина рекурсии
    global $protocol;
    //протокол
    global $link_array;
    // массив с спарсенными ссылками
    if (strlen($url) <= 1) {
        return;
    }
    if ($recursiveDeep == 0) {
        //если глубина рекурсии равна 0
        $res = parse_url($url);
        if ($res != false) {
            $domain = $res['host'];
            $protocol = $res['scheme'];
        } else {
            return;
        }
    }
    $recursiveDeep++;
    // увеличиваем счетчик глубины рекурсии
    $doc = new DOMDocument();
    $doc->loadHTML(file_get_contents($url));
    $elements = $doc->getElementsByTagName('a');
    foreach ($elements as $element) {
        if (count($link_array) > 300) {
            return;
        }
        // устанавливаем лимит на кол-во ссылок
        $link = $element->getAttribute('href');
        if ($link[0] == '/' || $link[0] == '?') {
            $link = $protocol . "://" . $domain . $link;
        }
        $p_link = parse_url($link);
        if ($p_link == false) {
            continue;
        }
        if ($p_link["host"] != $domain) {
            continue;
        }
        // проверяем ведет ли эта ссылка на внешний сайт
        if (!link_exists($link) && strlen($link) > 1) {
            $link_array[] = $link;
            if ($recursiveDeep < 5) {
                // проверяем глубину рекурсии
                parseLinks($link);
            }
        }
    }
    $recursiveDeep--;
    // уменьшаем счетчик глубины рекурсии
}
开发者ID:vorobeyDjack,项目名称:php_parser,代码行数:60,代码来源:siteParser.php

示例2: nn_add_link

function nn_add_link($blog_id, $user_id, $domain, $path, $site_id, $meta)
{
    $blog_details = get_blog_details($blog_id);
    if (preg_match("/.*Test.*/i", $blog_details->blogname)) {
        /*
         * We don't create links to test sites
         */
        return;
    } elseif (link_exists($domain)) {
        return;
    } elseif (preg_match("/^Nerd Nite (.*)\$/", $blog_details->blogname, $matches)) {
        $city_name = strtolower($matches[1]);
        $term = get_term_by('slug', 'nerdnite', 'link_category');
        $linkdata = array('link_name' => $city_name, 'link_url' => $domain, 'link_category' => $term->term_id, 'link_rel' => 'friend');
        wp_insert_link($linkdata);
    }
    return;
}
开发者ID:nerd-nite,项目名称:nerd-nite-plugin,代码行数:18,代码来源:autolink.php

示例3: links2wp

 function links2wp($links = '')
 {
     // General Housekeeping
     global $wpdb;
     $count = 0;
     // Deal with the links
     if (is_array($links)) {
         echo '<p>' . __('Importing Links...') . '<br /><br /></p>';
         foreach ($links as $link) {
             $count++;
             extract($link);
             if ($title != "") {
                 if ($cinfo = is_term(csc($title), 'link_category')) {
                     $category = $cinfo['term_id'];
                 } else {
                     $category = wp_insert_term($wpdb->escape(csc($title)), 'link_category');
                     $category = $category['term_id'];
                 }
             } else {
                 $linkname = $wpdb->escape(csc($label));
                 $description = $wpdb->escape(csc($title));
                 if ($linfo = link_exists($linkname)) {
                     $ret_id = wp_insert_link(array('link_id' => $linfo, 'link_url' => $href, 'link_name' => $linkname, 'link_category' => $category, 'link_description' => $description));
                 } else {
                     $ret_id = wp_insert_link(array('link_url' => $url, 'link_name' => $linkname, 'link_category' => $category, 'link_description' => $description));
                 }
                 $dclinks2wplinks[$link_id] = $ret_id;
             }
         }
         add_option('dclinks2wplinks', $dclinks2wplinks);
         echo '<p>';
         printf(__('Done! <strong>%s</strong> links or link categories imported'), $count);
         echo '<br /><br /></p>';
         return true;
     }
     echo __('No Links to Import!');
     return false;
 }
开发者ID:helmonaut,项目名称:owb-mirror,代码行数:38,代码来源:dotclear.php

示例4: links2wp

 function links2wp($links = '')
 {
     // General Housekeeping
     global $wpdb;
     $count = 0;
     // Deal with the links
     if (is_array($links)) {
         echo '<p>' . __('Importing Links...') . '<br /><br /></p>';
         foreach ($links as $link) {
             $count++;
             extract($link);
             // Make nice vars
             $category = $wpdb->escape($category);
             $linkname = $wpdb->escape($linkname);
             $description = $wpdb->escape($description);
             if ($linfo = link_exists($linkname)) {
                 $ret_id = wp_insert_link(array('link_id' => $linfo, 'link_url' => $url, 'link_name' => $linkname, 'link_category' => $category, 'link_description' => $description, 'link_updated' => $date));
             } else {
                 $ret_id = wp_insert_link(array('link_url' => $url, 'link_name' => $linkname, 'link_category' => $category, 'link_description' => $description, 'link_updated' => $date));
             }
             $txplinks2wplinks[$link_id] = $ret_id;
         }
         add_option('txplinks2wplinks', $txplinks2wplinks);
         echo '<p>';
         printf(_n('Done! <strong>%s</strong> link imported', 'Done! <strong>%s</strong> links imported', $count), $count);
         echo '<br /><br /></p>';
         return true;
     }
     echo __('No Links to Import!');
     return false;
 }
开发者ID:schr,项目名称:wordpress,代码行数:31,代码来源:textpattern.php

示例5: links2wp

	function links2wp($links='')
	{
		// General Housekeeping
		global $wpdb;
		$count = 0;

		// Deal with the links
		if(is_array($links))
		{
			echo '<p>'.__('Importing Links (Friends)...').'<br /><br /></p>';
			foreach($links as $link)
			{
				$count++;
				extract($link);

				// Make nice vars
				$category = $wpdb->escape("Blogroll");
				$linkname = utf8_decode($wpdb->escape($friend));
				$description = "";

				if($linfo = link_exists($linkname))
				{
					$ret_id = wp_insert_link(array(
								'link_id'			=> $linfo,
								'link_url'			=> $url,
								'link_name'			=> $linkname,
								'link_category'		=> $category,
								'link_description'	=> $description,
								'link_updated'		=> time())
								);
				}
				else
				{
					$ret_id = wp_insert_link(array(
								'link_url'			=> $url,
								'link_name'			=> $linkname,
								'link_category'		=> $category,
								'link_description'	=> $description,
								'link_updated'		=> time())
								);
				}
				$jawslinks2wplinks[$id] = $ret_id;
			}
			add_option('jawslinks2wplinks',$jawslinks2wplinks);
			echo '<p>';
			printf(__('Done! <strong>%s</strong> Links (Friends) imported'), $count);
			echo '<br /><br /></p>';
			return true;
		}
		echo __('No Links to Import!');
		return false;
	}
开发者ID:vicm3,项目名称:vicm3-Public-Repository,代码行数:52,代码来源:jaws.php


注:本文中的link_exists函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。