• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

PHP url_to_absolute函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: getURLFromHTML

function getURLFromHTML($originalURL, $htmlCode, $urlRegexList, &$urlList)
{
    // $mainURLObj = new Net_URL2($originalURL);
    foreach ($urlRegexList as $ur) {
        $matches = array();
        preg_match_all($ur, $htmlCode, $matches);
        if (isset($matches[1])) {
            // convert matched links to full url
            for ($i = 0; $i < count($matches[1]); $i++) {
                $link = urlencode($matches[1][$i]);
                $link = str_replace('%2F', '/', $link);
                $link = str_replace('%3F', '?', $link);
                // $urlObj = new Net_URL2($link);
                // relative url, add scheme, host and port into it
                $matches[1][$i] = urldecode(url_to_absolute($originalURL, $link));
                // if ($urlObj -> getScheme() == false) {
                // 	$urlObj -> setScheme($mainURLObj -> getScheme());
                // 	$urlObj -> setHost($mainURLObj -> getHost());
                // 	$urlObj -> setPort($mainURLObj -> getPort());
                // }
                // // query doesn't need to be encoded
                // $urlObj -> setQuery(urldecode($urlObj -> getQuery()));
                // $matches[1][$i] = (string)$urlObj;
            }
            $urlList = array_merge($urlList, $matches[1]);
        }
        $urlList = array_unique($urlList);
    }
}
开发者ID:lightbringer1991,项目名称:Projects,代码行数:29,代码来源:dataExtractor-dev.php


示例2: iitcMobileDownload

function iitcMobileDownload($apkfile)
{
    $version = getMobileVersion($apkfile);
    $apk_version = $version['apk_version'];
    $iitc_version = preg_replace('/^(\\d+\\.\\d+\\.\\d+)\\.(\\d{8}\\.\\d{1,6})/', '\\1<small class="text-muted">.\\2</small>', $version['iitc_version']);
    # we need an absolute link for the QR Code
    # get the URL of this page itself
    $pageurl = (isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] ? "https" : "http") . "://" . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'];
    $apkurl = url_to_absolute($pageurl, $apkfile);
    ?>


<div>

<img style="float: right; margin: 10px;" src="https://chart.googleapis.com/chart?cht=qr&chs=120x120&chld=L|2&chl=<?php 
    print urlencode($apkurl);
    ?>
" alt="QR Code for download">

<p>
IITC Mobile version <?php 
    print $apk_version;
    ?>
, with IITC version <?php 
    print $iitc_version;
    ?>
</p>

<p>
<a style="margin-right: 1em;" onclick="if(track){track('mobile','download','<?php 
    print $apkfile;
    ?>
');}" class="btn btn-large btn-primary" href="<?php 
    print $apkfile;
    ?>
">Download</a> or scan the QR Code
</p>

</div>
<div style="clear: both"></div>


<?php 
}
开发者ID:akorneev,项目名称:ingress-intel-total-conversion,代码行数:44,代码来源:mobile-download.php


示例3: check_d

 function check_d($path_arr, $dir = "", $i = 0)
 {
     global $docroot, $docroot_prefix, $url_fa;
     $handle = opendir(realpath($docroot . $dir));
     while ($f = readdir($handle)) {
         if ($f != "." && $f != "..") {
             $t[$f] = levenshtein($path_arr[$i], $f);
         }
     }
     closedir($handle);
     asort($t);
     while (list($rep, $val) = each($t)) {
         if ($val >= 0 && $val <= 1) {
             if ($i + 1 == count($path_arr)) {
                 $url_fa[] = url_to_absolute($docroot_prefix . $dir . $rep);
             } else {
                 if (is_dir($docroot . $dir . $rep)) {
                     $this->check_d($path_arr, $dir . $rep . "/", $i + 1);
                 }
             }
         }
     }
 }
开发者ID:BackupTheBerlios,项目名称:baifox-svn,代码行数:23,代码来源:mod_mispell.php


示例4: get_resource

function get_resource($url)
{
    $resource = '';
    if (!empty($url)) {
        $response = get_request($url);
        if (!function_exists('str_get_html')) {
            require_once dirname(__FILE__) . '/../vendor/simple-html-dom/simple-html-dom.php';
        }
        if (!function_exists('url_to_absolute')) {
            require_once dirname(__FILE__) . '/../vendor/url-to-absolute/url-to-absolute.php';
        }
        $url_parts = parse_url($url);
        //$body = wp_remote_retrieve_body($response);
        $body = $response;
        $html = str_get_html($body);
        foreach ($html->find('a, link') as $element) {
            if (isset($element->href) && $element->href[0] != "#") {
                $element->href = url_to_absolute($url, $element->href);
            }
        }
        foreach ($html->find('img, script') as $element) {
            if (isset($element->src)) {
                $element->src = url_to_absolute($url, $element->src);
            }
        }
        foreach ($html->find('form') as $element) {
            if (isset($element->action)) {
                $element->action = url_to_absolute($url, $element->action);
            } else {
                $element->action = $url;
            }
        }
        $resource = $html->save();
    }
    return $resource;
}
开发者ID:justinputney,项目名称:convertkit-landingpage-anywhere,代码行数:36,代码来源:landingpage.php


示例5: main


//.........这里部分代码省略.........
             if ($fbsort[1] == "desc") {
                 arsort($fsort);
                 arsort($dsort);
             } else {
                 asort($fsort);
                 asort($dsort);
             }
             if ($has_parent) {
                 $dsort = array_reverse($dsort);
                 $dsort[".."] = $has_parent;
                 $dsort = array_reverse($dsort);
             }
             // Do other processing
             if (@is_readable($wfn = $docroot . $http_uri . $conf[$vhost]["fbwelcomefile"][0])) {
                 $wfc = implode("<br>", file($wfn));
                 $welcome_formated = "<br><font size=\"1\" face=\"fixedsys\">" . $wfc . "</font><br><br>";
             } else {
                 $welcome_formated = "";
             }
             $fhdr = array();
             $fhdr["dir_name"] = "/" . $real_uri;
             $fhdr["welcome"] = $welcome_formated;
             $fhdr["total_files"] = $fb_tf;
             $fhdr["total_files_formated"] = number_format($fb_tf);
             $fhdr["total_size"] = $fb_ts;
             $fhdr["total_size_formated"] = number_format($fb_ts);
             $resp = nw_apply_template(NW_TMPL_FB_HEADER, $fhdr);
             $dfile = access_query("fbdescfile", 0);
             unset($fb_desc);
             if (@is_readable($dfcomp = realpath($accessdir . "/" . $dfile))) {
                 if ($descf = file($dfcomp)) {
                     foreach ($descf as $dfline) {
                         if (trim($dfline)) {
                             $didx = trim(substr($dfline, 0, strpos($dfline, " ")));
                             $desc = trim(substr($dfline, strpos($dfline, " ")));
                             $fb_desc[$didx] = $desc;
                         }
                     }
                 }
             }
             // Display each row
             foreach (array_keys($dsort) as $fidx) {
                 $fi = $fb_arr[$fidx];
                 $f = $fi["f"];
                 if ($f == "..") {
                     $dname = nw_apply_template(NW_TMPL_FB_PARENT, array());
                     $tmpdl = explode("/", trim($real_uri, "/"));
                     array_pop($tmpdl);
                     $dlink = url_to_absolute(implode("/", $tmpdl) . "/");
                 } else {
                     $dname = $f;
                     $dlink = url_to_absolute($real_uri . rawurlencode($f) . "/");
                 }
                 if ((substr($f, 0, 1) != "." || $f == ".." || $conf[$vhost]["fbshowdotfiles"][0]) && $f != "." && !($f == ".." && $http_uri == "/")) {
                     $d_row = array();
                     $d_row["icon"] = $icndir;
                     $d_row["link"] = $dlink;
                     $d_row["name"] = $dname;
                     $d_row["date"] = date($dfmt, $fi[9]);
                     $d_row["desc"] = $fb_desc[$f] ? $fb_desc[$f] : "-";
                     $resp .= nw_apply_template(NW_TMPL_FB_ROW_D, $d_row, true);
                 }
             }
             foreach (array_keys($fsort) as $fidx) {
                 $fi = $fb_arr[$fidx];
                 $f = $fi["f"];
                 $fp = pathinfo($f);
                 $t = $mime[strtolower($fp["extension"])];
                 $icnf = $icndef;
                 if ($icons) {
                     foreach ($icons as $key => $val) {
                         if (strpos($t, $key) === 0) {
                             $icnf = $val;
                             break;
                         }
                     }
                 }
                 if (($f[0] != "." || $f == ".." || $conf[$vhost]["fbshowdotfiles"][0]) && $f != "." && !($f == ".." && $http_uri == "/")) {
                     $f_row = array();
                     $f_row["icon"] = $icnf;
                     $f_row["link"] = url_to_absolute($real_uri . rawurlencode($f));
                     $f_row["name"] = $f;
                     $f_row["date"] = date($dfmt, $fi[9]);
                     $f_row["size"] = number_format($fi[7]);
                     $f_row["desc"] = $fb_desc[$f] ? $fb_desc[$f] : "-";
                     $resp .= nw_apply_template(NW_TMPL_FB_ROW_F, $f_row, true);
                 }
             }
             closedir($hnd);
             $resp .= nw_apply_template(NW_TMPL_FB_FOOTER, $fhdr);
         } else {
             $rq_err = 403;
         }
     } else {
         $rq_err = 404;
     }
     if ($resp) {
         $GLOBALS["lf"] =& new static_response($resp);
     }
 }
开发者ID:BackupTheBerlios,项目名称:baifox-svn,代码行数:101,代码来源:mod_fb.php


示例6: _pugpig_package_test_endpoints

function _pugpig_package_test_endpoints($endpoints, $timestamp, $tmp_root)
{
    pugpig_interface_output_header("Pugpig - Endpoint Checker");
    print_r("<h1>Checking Pugpig End Points</h1>");
    $tmp_root = str_replace(DIRECTORY_SEPARATOR, '/', $tmp_root);
    $tmp_path = $tmp_root . 'package-' . $timestamp . '/';
    $entries = array();
    $c = 0;
    foreach ($endpoints as $endpoint) {
        if ($endpoint != '') {
            $save_path = $tmp_path . 'opds/' . hash('md5', $endpoint) . '.xml';
            $entries[$endpoint] = $save_path;
        }
    }
    $debug = FALSE;
    $concurrent = 1;
    $entries = _pugpig_package_download_batch("OPDS Feeds", $entries, $debug, $concurrent);
    $format_failures = array();
    foreach (array_keys($entries) as $entry) {
        // print_r($entry . " ---> " . $entries[$entry] . "<br />");
        // Read the ATOM from the file
        $fhandle = fopen($entries[$entry], 'r');
        $opds_atom = fread($fhandle, filesize($entries[$entry]));
        fclose($fhandle);
        $msg = check_xml_is_valid($opds_atom);
        if ($msg != '') {
            $format_failures[$entry] = "OPDS XML Invalid: " . $msg;
            $opds_atom = '';
        }
        $opds_ret = _pugpig_package_parse_opds($opds_atom);
        $edition_roots = array();
        $package_roots = array();
        print_r("<h2>" . $entry . "(" . $opds_ret['title'] . ")</h2>");
        foreach ($opds_ret['editions'] as $edition) {
            $cover = url_to_absolute($entry, $edition['cover']);
            print_r("<img class='cover " . ($edition['free'] ? "free" : "paid") . "' height='60' title='" . $edition['title'] . ': ' . $edition['summary'] . "' src='" . $cover . "' />");
            $edition_root = url_to_absolute($entry, $edition['url']);
            $save_path = $tmp_path . $edition['type'] . '/' . hash('md5', $edition_root) . '.xml';
            $edition_roots[$edition_root] = $save_path;
            if ($edition['type'] == 'package') {
                $package_roots[] = $edition_root;
            }
        }
        $edition_roots = _pugpig_package_download_batch("Edition Roots", $edition_roots, $debug, $concurrent);
        $format_failures = array();
        foreach ($package_roots as $package_root) {
            $save_path = $edition_roots[$package_root];
            $fhandle = fopen($save_path, 'r');
            $package_xml_body = fread($fhandle, filesize($save_path));
            fclose($fhandle);
            $msg = check_xml_is_valid($package_xml_body);
            if ($msg != '') {
                $format_failures[$package_root] = "Package XML Invalid: " . $msg;
                $opds_atom = '';
            }
        }
        // Show package format errros
        _pugpig_package_show_failures($format_failures);
    }
    _pugpig_package_show_failures($format_failures);
}
开发者ID:johnedelatorre,项目名称:fusion,代码行数:61,代码来源:pugpig_packager.php


示例7: url_absolute

/**
 * Make an $url absolute according to $host, if it is not absolute yet.
 *
 * @param string URL
 * @param string Base (including protocol, e.g. 'http://example.com'); autodedected
 * @return string
 */
function url_absolute($url, $base = NULL)
{
    load_funcs('_ext/_url_rel2abs.php');
    if (is_absolute_url($url)) {
        // URL is already absolute
        return $url;
    }
    if (empty($base)) {
        // Detect current page base
        global $Blog, $ReqHost, $base_tag_set, $baseurl;
        if ($base_tag_set) {
            // <base> tag is set
            $base = $base_tag_set;
        } else {
            if (!empty($Blog)) {
                // Get original blog skin, not passed with 'tempskin' param
                $SkinCache =& get_SkinCache();
                if (($Skin = $SkinCache->get_by_ID($Blog->get_skin_ID(), false)) !== false) {
                    $base = $Blog->get_local_skins_url() . $Skin->folder . '/';
                } else {
                    // Skin not set:
                    $base = $Blog->gen_baseurl();
                }
            } else {
                // We are displaying a general page that is not specific to a blog:
                $base = $ReqHost;
            }
        }
    }
    if (($absurl = url_to_absolute($url, $base)) === false) {
        // Return relative URL in case of error
        $absurl = $url;
    }
    return $absurl;
}
开发者ID:Ariflaw,项目名称:b2evolution,代码行数:42,代码来源:_url.funcs.php


示例8: analyse_page

 public function analyse_page($baseurl, $content, &$list)
 {
     global $CFG, $OUTPUT;
     $urls = extract_html_urls($content);
     $images = $urls['img']['src'];
     $pattern = '#img(.+)src="?\'?([[:alnum:]:?=&@/._+-]+)"?\'?#i';
     if (!empty($images)) {
         foreach ($images as $url) {
             $list['list'][] = array('title' => $this->guess_filename($url, ''), 'source' => url_to_absolute($baseurl, $url), 'thumbnail' => url_to_absolute($baseurl, $url), 'thumbnail_height' => 84, 'thumbnail_width' => 84);
         }
     }
 }
开发者ID:ajv,项目名称:Offline-Caching,代码行数:12,代码来源:repository.class.php


示例9: list

list($successes, $failures) = array(0, 0);
foreach ($tests as $test) {
    if (($r = rel2abs($test['rel'], $base)) == $test['result']) {
        $successes++;
    } else {
        $failures++;
    }
}
$elapsed = microtime() - $start;
echo "rel2abs:         successes -> {$successes}, failures => {$failures}, elapsed time: {$elapsed}\n";
# url_to_absolute
$start = microtime();
$base = 'http://a/b/c/d;p?q';
list($successes, $failures) = array(0, 0);
foreach ($tests as $test) {
    if (($r = url_to_absolute($base, $test['rel'])) == $test['result']) {
        $successes++;
    } else {
        $failures++;
    }
}
$elapsed = microtime() - $start;
echo "url_to_absolute: successes -> {$successes}, failures => {$failures}, elapsed time: {$elapsed}\n";
# phpuri
$start = microtime();
$base = phpUri::parse('http://a/b/c/d;p?q');
list($successes, $failures) = array(0, 0);
foreach ($tests as $test) {
    if (($r = $base->join($test['rel'])) == $test['result']) {
        $successes++;
    } else {
开发者ID:dmitry-dimon-darkdim,项目名称:parser,代码行数:31,代码来源:test.php


示例10: absolute_url

function absolute_url($base_url, $relative_url)
{
    return url_to_absolute($base_url, $relative_url);
}
开发者ID:ronniebrito,项目名称:moodle_moviemasher,代码行数:4,代码来源:urlutils.php


示例11: getAllURLFromHTML

 public function getAllURLFromHTML()
 {
     $output = array();
     $dom = new DOMDocument();
     @$dom->loadHTML($this->htmlCode);
     $xpath = new DomXPath($dom);
     $hrefs = $xpath->evaluate("/html/body//a");
     for ($i = 0; $i < $hrefs->length; $i++) {
         $h = $this->encodeURL($hrefs->item($i)->getAttribute('href'));
         $h = url_to_absolute($this->url, $h);
         array_push($output, $h);
     }
     return array_unique($output);
 }
开发者ID:lightbringer1991,项目名称:Projects,代码行数:14,代码来源:Extractor.class.php


示例12: add_image_to_list

 protected function add_image_to_list($baseurl, $url, &$list)
 {
     if (empty($list['list'])) {
         $list['list'] = array();
     }
     $src = url_to_absolute($baseurl, htmlspecialchars_decode($url));
     foreach ($list['list'] as $image) {
         if ($image['source'] == $src) {
             return;
         }
     }
     $list['list'][] = array('title' => $this->guess_filename($url, ''), 'source' => $src, 'thumbnail' => $src, 'thumbnail_height' => 84, 'thumbnail_width' => 84);
 }
开发者ID:EmmanuelYupit,项目名称:educursos,代码行数:13,代码来源:lib.php


示例13: breadcrumbs

function breadcrumbs($forcedUrl='', $noBold=false){
	global $post;
	$menuItems = wp_get_nav_menu_items('glowne');
		
	$url = "http://".$_SERVER["HTTP_HOST"] . $_SERVER["REQUEST_URI"];
	
	//if (is_paged()){
	//	$url = preg_replace('#&paged=\d*#', '', $url);
	//}

	
	if (  is_single() || is_search()  ){
		$url=get_permalink();		
		
		$bold_suffix = false;
		if (!find_menu_item($menuItems, get_permalink())){
			$url=get_post_type_archive_link( get_post_type($post) );
			$suffix = get_the_title();
			$bold_suffix=true;
		}			
				
	}
	
	if (!empty($forcedUrl)){
		$url=$forcedUrl;
		$suffix='';
		$bold_suffix=false;		
	}

	
	
	$s='';
	$baseUrl = "http://".$_SERVER["HTTP_HOST"]."/";
	foreach($menuItems as $menuItem) {
		$absoluteUrl = url_to_absolute( $baseUrl, $menuItem->url); // bo w menu link moze byc zapisany jako samo "?post_type=xxx";
		if($absoluteUrl == $url ) {
			$id=$menuItem->ID;		
			
			for ($x=0; $x<50; $x++){
			

			
				if (empty($id))
					break;
				$item = get_menu_item($menuItems, $id);
				$parentId = $item->menu_item_parent;
				$title = $item->title;
				$title = htmlentities( $title, ENT_QUOTES ,"UTF-8" );
				
				//if (!empty_link($item->url)){
				//	$title='<a href="'.$item->url.'">'.$title.'</a>';
				//}
				$href=$item->url;
				
				if ( ($href=='') || ($href=='#') )
					//$href='?bread='.$item->ID;
					$href = "#";
				
				if ( ($x==0) && (!$bold_suffix) && (!$noBold)){
					$s = '<span>'.$title.'</span>'. $s;
					//$s = '<span class="breadcrumbs first">'.$title.'</span>'. $s;
				}else{
				
					if($x != 1){
						$separator = '<span> &gt; </span>';
						//$separator = '<span class="breadcrumbs sep"> &gt; </span>';
					}else{
						$separator = '';
					}
				
					$s = ' <a href="'.$href.'">'.$title.' </a>'.$separator. $s;
					//$s = ' <a href="'.$href.'" class="breadcrumbs">'.$title.' </a>'.$separator. $s;
				}
				
				
				$id = $parentId;
				

				
			}
			if (!$noBold)
				$s.= '<span>'.$suffix.'</span>'; //dokladamy tytul postu
				//$s.= '<span class="breadcrumbsBold last">'.$suffix.'</span>'; //dokladamy tytul postu
			//echo $s;			
			break;
		}
	}

if ( (empty($s)) && (empty($forcedUrl)) && (!$noBold) )
	$s='<span>'.get_the_title().'</span>';
	//$s='<span class="breadcrumbsBold single">'.get_the_title().'</span>';
echo $s;
	
}
开发者ID:skonina,项目名称:teatrbaza,代码行数:94,代码来源:breadcrumbs-functions.php


示例14: showEditionsAndCovers

function showEditionsAndCovers($user, $opds, $edition_file_root)
{
    $entries = array();
    $save_path = pugpig_get_local_save_path($edition_file_root, $opds);
    // Remove the query string
    $save_path = preg_replace('/\\/?\\?.*/', '', $save_path);
    $entries[$opds] = $save_path;
    $entries = _pugpig_package_download_batch("OPDS Feeds", $entries);
    $format_failures = array();
    foreach (array_keys($entries) as $entry) {
        // Read the ATOM from the file
        $fhandle = fopen($entries[$entry], 'r');
        $opds_body = fread($fhandle, filesize($entries[$entry]));
        fclose($fhandle);
        // Parse the OPDS file
        $opds_ret = _pugpig_package_parse_opds($opds_body);
        if (!empty($opds_ret['failure'])) {
            echo "<font color='red'>Not Valid OPDS: " . $opds_ret['failure'] . "</font>";
            return;
        }
        echo "<h1>Your Editions</h1>";
        $covers = array();
        echo "<table>";
        foreach ($opds_ret['editions'] as $edition) {
            echo "<tr>";
            $cover_url = url_to_absolute($opds, $edition['cover']);
            $atom_url = url_to_absolute($opds, $edition['url']);
            $cover_save_path = pugpig_get_local_save_path($edition_file_root, $cover_url);
            // $save_path = $edition_file_root . 'cover/' . hash('md5', $edition['cover']). '.jpg';
            if (count($covers) < 10) {
                $covers[$cover_url] = $cover_save_path;
                // showSingleEdition($user, $opds, $atom_url, $edition_file_root);
            }
            echo "<td><img height='80' src='" . $cover_url . "' /></td>";
            echo "<td>";
            echo "<b>" . $edition['title'] . "</b><br />";
            echo "<i>" . $edition['summary'] . "</i><br />";
            $updated_ts = strtotime($edition['updated']);
            echo _ago($updated_ts) . " ago) - (" . $edition['updated'] . ") ({$updated_ts})<br />";
            echo $edition['draft'] ? "<font color='orange'>DRAFT</font> " : "";
            echo ($edition['free'] ? "free" : "paid") . ($edition['samples'] ? " with samples" : "");
            echo "<br />";
            echo "</td>";
            echo "<td>";
            //echo count($edition['categories']) . " categories";
            foreach ($edition['categories'] as $schema => $term) {
                echo "<b>{$schema}</b>: {$term}<br />";
            }
            echo "</td>";
            echo "<td>";
            if ($edition['type'] == 'atom') {
                $q = http_build_query(array('opds' => $opds, 'atom' => $atom_url, 'user' => $user));
                echo "<a href='?{$q}'>TEST PAGES</a><br />\n";
            } else {
                echo "EPUB<br />";
            }
            echo "<a href='" . url_to_absolute($opds, $atom_url) . "' target='_blank'>FEED</a></br />";
            echo "FLATPLAN</br />";
            echo "PREVIEW IN WEB<br />";
            echo "</tr>";
        }
        echo "</table>";
        $entries = _pugpig_package_download_batch("Valdating Covers (only 10)", $covers);
    }
}
开发者ID:shortlist-digital,项目名称:agreable-pugpig-plugin,代码行数:65,代码来源:ppitc_index.php


示例15: GetImageUrl

 public function GetImageUrl($url)
 {
     $maxSize = -1;
     //         $curl = curl_init();
     // curl_setopt($curl, CURLOPT_URL, $url);
     // curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
     // curl_setopt($curl, CURLOPT_CONNECTTIMEOUT, 10);
     // $str = curl_exec($curl);
     // curl_close($curl);
     // $html= str_get_html($str);
     $html = file_get_html($url);
     if ($html === FALSE) {
         return 'No Image';
     }
     $temp = array();
     $visited = array();
     foreach ($html->find('img') as $e) {
         $src = $e->src;
         if ($src == '') {
             continue;
         }
         // it happens on your test url
         $imageurl = url_to_absolute($url, $src);
         //get image absolute url
         // ignore already seen images, add new images
         if (in_array($imageurl, $visited)) {
             continue;
         }
         $visited[] = $imageurl;
         // get image
         $image = @getimagesize($imageurl);
         // get the rest images width and height
         if ($image[0] * $image[1] > $maxSize) {
             $maxSize = $image[0] * $image[1];
             //compare sizes
             $biggest_img = $imageurl;
         }
     }
     return $biggest_img ? $biggest_img : 'No Image';
 }
开发者ID:Agroorama,项目名称:plugins,代码行数:40,代码来源:ReadArticle.php


示例16: findLinksOnPage

function findLinksOnPage($location)
{
    print "loading page " . $location . "\n";
    $html = scraperWiki::scrape($location);
    $dom = new simple_html_dom();
    $dom->load($html);
    foreach ($dom->find("a") as $anchor) {
        $href = $anchor->getAttribute('href');
        $href = preg_replace("/SID-[0-9a-fA-F]+\\-[0-9a-fA-F]+\\//i", "", $href);
        $type = "";
        if (preg_match("/(http|https|ftp):\\/\\/([\\w-\\d]+\\.)+[\\w-\\d]+/i", $href, $m)) {
            if ("bertelsmann-stiftung." == $m[2]) {
                $type = 'internal';
            } else {
                $type = 'external';
            }
        } else {
            if (preg_match("/(\\/[\\w~,;\\-\\.\\/?%&+#=]*)/i", $href)) {
                $type = 'internal';
                $href = url_to_absolute($location, $href);
            } else {
                $type = 'unknown';
            }
        }
        scraperwiki::save(array('href'), array('on_page' => $location, 'href' => $href, 'type' => $type, 'exported' => 0));
        // remember to follow an internal link, if not already done
        if ($type == 'internal') {
            if (!preg_match("/.*\\.mpeg\$/i", $href) && !preg_match("/.*\\.exe\$/i", $href) && !preg_match("/.*\\.pdf\$/i", $href) && !preg_match("/.*\\.mp3\$/i", $href) && !preg_match("/.*\\.jpg\$/i", $href) && !preg_match("/.*\\.zip\$/i", $href) && !preg_match("/.*\\.doc\$/i", $href) && !preg_match("/.*\\.ppt\$/i", $href)) {
                $count = scraperwiki::select("count(*) as c from pages where url like '" . $href . "'");
                $count = $count[0]['c'];
                if ($count > 0) {
                    //print "page already processed (or reserved): " . $href . "\n";
                } else {
                    scraperwiki::save_sqlite(array('url'), array('url' => $href, 'processed' => 0), "pages", 0);
                }
            }
        }
    }
}
开发者ID:flyeven,项目名称:scraperwiki-scraper-vault,代码行数:39,代码来源:links_4.php


示例17: entify_with_options

 /**
  * Entifies the tweet using the given entities element, using the provided
  * options.
  *
  * @param array $tweet the json converted to normalised array
  * @param array $options settings to be used when rendering the entities
  * @param array $replacements if specified, the entities and their replacements will be stored to this variable
  * @return the tweet text with entities replaced with hyperlinks
  */
 public static function entify_with_options($tweet, $options = array(), &$replacements = array())
 {
     $default_opts = array('encoding' => 'UTF-8', 'target' => '', 'link_preview' => false);
     $opts = array_merge($default_opts, $options);
     $encoding = mb_internal_encoding();
     mb_internal_encoding($opts['encoding']);
     $keys = array();
     $is_retweet = false;
     if (isset($tweet['retweeted_status'])) {
         $tweet = $tweet['retweeted_status'];
         $is_retweet = true;
     }
     if (!isset($tweet['entities'])) {
         return $tweet['text'];
     }
     $target = !empty($opts['target']) ? ' target="' . $opts['target'] . '"' : '';
     // prepare the entities
     foreach ($tweet['entities'] as $type => $things) {
         foreach ($things as $entity => $value) {
             $tweet_link = "<a href=\"https://twitter.com/{$tweet['user']['screen_name']}/statuses/{$tweet['id']}\"{$target}>{$tweet['created_at']}</a>";
             switch ($type) {
                 case 'hashtags':
                     $href = "<a href=\"https://twitter.com/search?q=%23{$value['text']}\"{$target}>#{$value['text']}</a>";
                     break;
                 case 'user_mentions':
                     $href = "@<a href=\"https://twitter.com/{$value['screen_name']}\" title=\"{$value['name']}\"{$target}>{$value['screen_name']}</a>";
                     break;
                 case 'urls':
                 case 'media':
                     $url = empty($value['expanded_url']) ? $value['url'] : $value['expanded_url'];
                     if ($opts['link_preview']) {
                         // Generate link previews rather than just a URL
                         $html = file_get_html($url);
                         $site_title = $html->find('title', 0);
                         $site_img = $html->find('img', 0);
                         $display = "<div>";
                         if (null != $site_img) {
                             // We have to convert the image from relative to absolute
                             $site_img = url_to_absolute($url, $site_img->src);
                             $display .= "<img style=\"width:30px;vertical-align:middle\" " . "src=\"{$site_img}\"/>";
                         }
                         if (null != $site_title) {
                             $site_title = trim($site_title->innertext);
                             $display .= "<span style=\"font-size: 2em;\">{$site_title}</span></span>";
                         } else {
                             // No title, fall back to normal behavior
                             $display = isset($value['display_url']) ? $value['display_url'] : str_replace('http://', '', $url);
                             // Not all pages are served in UTF-8 so you may need to do this ...
                             $display = "LAME" . urldecode(str_replace('%E2%80%A6', '&hellip;', urlencode($display)));
                         }
                         $display .= "</div>";
                     } else {
                         $display = isset($value['display_url']) ? $value['display_url'] : str_replace('http://', '', $url);
                         // Not all pages are served in UTF-8 so you may need to do this ...
                         $display = urldecode(str_replace('%E2%80%A6', '&hellip;', urlencode($display)));
                     }
                     $href = "<a href=\"{$value['url']}\"{$target}>{$display}</a>";
                     break;
             }
             $keys[$value['indices']['0']] = mb_substr($tweet['text'], $value['indices']['0'], $value['indices']['1'] - $value['indices']['0']);
             $replacements[$value['indices']['0']] = $href;
         }
     }
     ksort($replacements);
     $replacements = array_reverse($replacements, true);
     $entified_tweet = $tweet['text'];
     foreach ($replacements as $k => $v) {
         $entified_tweet = mb_substr($entified_tweet, 0, $k) . $v . mb_substr($entified_tweet, $k + strlen($keys[$k]));
     }
     $replacements = array('replacements' => $replacements, 'keys' => $keys);
     mb_internal_encoding($encoding);
     return $entified_tweet;
 }
开发者ID:hank,项目名称:tweetledee,代码行数:82,代码来源:tmhUtilities.php


示例18: clean_link

/**
 * Uniformly cleans a link to avoid duplicates
 *
 * 1. Changes relative links to absolute (/bar to http://www.foo.com/bar)
 * 2. Removes anchor tags (foo.html#bar to foo.html)
 * 3. Adds trailing slash if directory (foo.com/bar to foo.com/bar/)
 * 4. Adds www if there is not a subdomain (foo.com to www.foo.com but not bar.foo.com)
 *
 * @params string $link link to clean
 * @parmas string $dir directory of parent (linking) page
 * @return strin cleaned link
 */
function clean_link($link, $dir)
{
    $link = url_to_absolute($dir, $link);
    //make them absolute, not relative
    if (stripos($link, '#') != FALSE) {
        $link = substr($link, 0, stripos($link, '#'));
    }
    //remove anchors
    if (!preg_match('#(^http://(.*)/$)|http://(.*)/(.*)\\.([A-Za-z0-9]+)|http://(.*)/([^\\?\\#]*)(\\?|\\#)([^/]*)#i', $link)) {
        $link .= '/';
    }
    $link = preg_replace('#http://([^.]+).([a-zA-z]{3})/#i', 'http://www.$1.$2/', $link);
    return $link;
}
开发者ID:unetics,项目名称:Crawler,代码行数:26,代码来源:functions.php


示例19: GetImage

 function GetImage($document, $url)
 {
     $meta_og_img = '';
     foreach ($document->getElementsByTagName('meta') as $meta) {
         //If the property attribute of the meta tag is og:image
         if ($meta->getAttribute('property') == 'og:image') {
             //Assign the value from content attribute to $meta_og_img
             $meta_og_img = $meta->getAttribute('content');
             // trigger_error($meta_og_img);
             $images[$meta_og_img] = array('src' => $meta_og_img);
         }
     }
     foreach ($document->getElementsByTagName('img') as $img) {
         $image = array('src' => @url_to_absolute($url, $img->getAttribute('src')));
         if (!$image['src']) {
             continue;
         }
         if (!$this->endsWith($image['src'], "gif") && $meta_og_img != $image) {
             $images[$image['src']] = $image;
         }
     }
     if (isset($images)) {
         return $images;
     } else {
         return 0;
     }
 }
开发者ID:Agroorama,项目名称:plugins,代码行数:27,代码来源:ReadArticle.php


示例20: loadUserScriptHeader

                $response['mobile']['iitc_version'] = $header['@version'];
            }
        } else {
            $response['error'] = 'Failed to find .apk file ' . $apkfile;
        }
    } else {
        // desktop - .user.js scripts
        // load main script version
        $iitc_details = loadUserScriptHeader("{$dir}/total-conversion-build.user.js");
        $response['iitc'] = array('version' => $iitc_details['@version'], 'downloadUrl' => url_to_absolute($pageurl, "{$dir}/total-conversion-build.user.js"), 'pageUrl' => url_to_absolute($pageurl, $info['web']));
        // and now the plugins
        $response['plugins'] = array();
        foreach (glob("{$dir}/plugins/*.user.js") as $path) {
            $basename = basename($path, ".user.js");
            $details = loadUserScriptHeader($path);
            $response['plugins'][$basename] = array('version' => $details['@version'], 'downloadUrl' => url_to_absolute($pageurl, "{$dir}/plugins/{$basename}.user.js"), 'pageUrl' => url_to_absolute($pageurl, $info['web'] . "#plugin-{$basename}"));
        }
    }
} else {
    $response['error'] = 'Unsupported build for version check';
}
$data = json_encode($response);
# send the response - allow either jsonp (using a 'callback' parameter), or regular json
if (array_key_exists('callback', $_GET)) {
    header('Content-Type: text/javascript; charset=utf8');
    header('Access-Control-Allow-Origin: *');
    header('Access-Control-Max-Age: 3628800');
    header('Access-Control-Allow-Methods: GET, POST');
    $callback = $_GET['callback'];
    echo $callback . '(' . $data . ');';
} else {
开发者ID:akorneev,项目名称:ingress-intel-total-conversion,代码行数:31,代码来源:versioncheck.php



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
PHP url_to_postid函数代码示例发布时间:2022-05-23
下一篇:
PHP url_title函数代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap