本文整理汇总了PHP中url_to_absolute函数的典型用法代码示例。如果您正苦于以下问题:PHP url_to_absolute函数的具体用法?PHP url_to_absolute怎么用?PHP url_to_absolute使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了url_to_absolute函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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);
}
}
示例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
}
示例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);
}
}
}
}
}
示例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;
}
示例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);
}
}
示例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);
}
示例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;
}
示例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);
}
}
}
示例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 {
示例10: absolute_url
function absolute_url($base_url, $relative_url)
{
return url_to_absolute($base_url, $relative_url);
}
示例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);
}
示例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);
}
示例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> > </span>';
//$separator = '<span class="breadcrumbs sep"> > </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;
}
示例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);
}
}
示例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';
}