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

PHP z_fetch_url函数代码示例

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

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



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

示例1: run

 public static function run($argc, $argv)
 {
     /**
      * Cron Weekly
      * 
      * Actions in the following block are executed once per day only on Sunday (once per week).
      *
      */
     call_hooks('cron_weekly', datetime_convert());
     z_check_cert();
     require_once 'include/hubloc.php';
     prune_hub_reinstalls();
     mark_orphan_hubsxchans();
     // get rid of really old poco records
     q("delete from xlink where xlink_updated < %s - INTERVAL %s and xlink_static = 0 ", db_utcnow(), db_quoteinterval('14 DAY'));
     $dirmode = intval(get_config('system', 'directory_mode'));
     if ($dirmode === DIRECTORY_MODE_SECONDARY || $dirmode === DIRECTORY_MODE_PRIMARY) {
         logger('regdir: ' . print_r(z_fetch_url(get_directory_primary() . '/regdir?f=&url=' . urlencode(z_root()) . '&realm=' . urlencode(get_directory_realm())), true));
     }
     // Check for dead sites
     Master::Summon(array('Checksites'));
     // update searchable doc indexes
     Master::Summon(array('Importdoc'));
     /**
      * End Cron Weekly
      */
 }
开发者ID:anmol26s,项目名称:hubzilla-yunohost,代码行数:27,代码来源:Cron_weekly.php


示例2: pubsites_content

function pubsites_content(&$a)
{
    require_once 'include/dir_fns.php';
    $dirmode = intval(get_config('system', 'directory_mode'));
    if ($dirmode == DIRECTORY_MODE_PRIMARY || $dirmode == DIRECTORY_MODE_STANDALONE) {
        $url = z_root() . '/dirsearch';
    }
    if (!$url) {
        $directory = find_upstream_directory($dirmode);
        $url = $directory['url'] . '/dirsearch';
    }
    $url .= '/sites';
    $o .= '<h1>' . t('Public Sites') . '</h1>';
    $o .= '<div class="descriptive-text">' . t('The listed sites allow public registration into the Red Matrix. All sites in the matrix are interlinked so membership on any of them conveys membership in the matrix as a whole. Some sites may require subscription or provide tiered service plans. The provider links <strong>may</strong> provide additional details.') . '</div>' . EOL;
    $ret = z_fetch_url($url);
    if ($ret['success']) {
        $j = json_decode($ret['body'], true);
        if ($j) {
            $rate_meta = local_channel() ? '<td>' . t('Rate this hub') . '</td>' : '';
            $o .= '<table border="1"><tr><td>' . t('Site URL') . '</td><td>' . t('Access Type') . '</td><td>' . t('Registration Policy') . '</td><td>' . t('Location') . '</td><td>' . t('View hub ratings') . '</td>' . $rate_meta . '</tr>';
            if ($j['sites']) {
                foreach ($j['sites'] as $jj) {
                    $host = strtolower(substr($jj['url'], strpos($jj['url'], '://') + 3));
                    $rate_links = local_channel() ? '<td><a href="rate?f=&target=' . $host . '" class="btn-btn-default"><i class="icon-check"></i> ' . t('Rate') . '</a></td>' : '';
                    $o .= '<tr><td>' . '<a href="' . ($jj['sellpage'] ? $jj['sellpage'] : $jj['url'] . '/register') . '" >' . $jj['url'] . '</a>' . '</td><td>' . $jj['access'] . '</td><td>' . $jj['register'] . '</td><td>' . $jj['location'] . '</td><td><a href="ratings/' . $host . '" class="btn-btn-default"><i class="icon-eye-open"></i> ' . t('View ratings') . '</a></td>' . $rate_links . '</tr>';
                }
            }
            $o .= '</table>';
        }
    }
    return $o;
}
开发者ID:redmatrix,项目名称:red,代码行数:32,代码来源:pubsites.php


示例3: oembed_fetch_url

function oembed_fetch_url($embedurl)
{
    $a = get_app();
    $txt = Cache::get($a->videowidth . $embedurl);
    if (strstr($txt, 'youtu')) {
        $txt = str_replace('http:', 'https:', $txt);
    }
    // These media files should now be caught in bbcode.php
    // left here as a fallback in case this is called from another source
    $noexts = array("mp3", "mp4", "ogg", "ogv", "oga", "ogm", "webm");
    $ext = pathinfo(strtolower($embedurl), PATHINFO_EXTENSION);
    if (is_null($txt)) {
        $txt = "";
        if (in_array($ext, $noexts)) {
            require_once 'include/hubloc.php';
            $zrl = is_matrix_url($embedurl);
            if ($zrl) {
                $embedurl = zid($embedurl);
            }
        } else {
            // try oembed autodiscovery
            $redirects = 0;
            $result = z_fetch_url($embedurl, false, $redirects, array('timeout' => 15, 'accept_content' => "text/*", 'novalidate' => true));
            if ($result['success']) {
                $html_text = $result['body'];
            }
            if ($html_text) {
                $dom = @DOMDocument::loadHTML($html_text);
                if ($dom) {
                    $xpath = new DOMXPath($dom);
                    $attr = "oembed";
                    $xattr = oe_build_xpath("class", "oembed");
                    $entries = $xpath->query("//link[@type='application/json+oembed']");
                    foreach ($entries as $e) {
                        $href = $e->getAttributeNode("href")->nodeValue;
                        $x = z_fetch_url($href . '&maxwidth=' . $a->videowidth);
                        $txt = $x['body'];
                        break;
                    }
                }
            }
        }
        if ($txt == false || $txt == "") {
            $x = array('url' => $embedurl, 'videowidth' => $a->videowidth);
            call_hooks('oembed_probe', $x);
            if (array_key_exists('embed', $x)) {
                $txt = $x['embed'];
            }
        }
        $txt = trim($txt);
        if ($txt[0] != "{") {
            $txt = '{"type":"error"}';
        }
        //save in cache
        Cache::set($a->videowidth . $embedurl, $txt);
    }
    $j = json_decode($txt);
    $j->embedurl = $embedurl;
    return $j;
}
开发者ID:Mauru,项目名称:red,代码行数:60,代码来源:oembed.php


示例4: get

 function get()
 {
     require_once 'include/dir_fns.php';
     $dirmode = intval(get_config('system', 'directory_mode'));
     if ($dirmode == DIRECTORY_MODE_PRIMARY || $dirmode == DIRECTORY_MODE_STANDALONE) {
         $url = z_root() . '/dirsearch';
     }
     if (!$url) {
         $directory = find_upstream_directory($dirmode);
         $url = $directory['url'] . '/dirsearch';
     }
     $url .= '/sites';
     $rating_enabled = get_config('system', 'rating_enabled');
     $o .= '<div class="generic-content-wrapper">';
     $o .= '<div class="section-title-wrapper"><h2>' . t('Public Hubs') . '</h2></div>';
     $o .= '<div class="section-content-tools-wrapper"><div class="descriptive-text">' . t('The listed hubs allow public registration for the $Projectname network. All hubs in the network are interlinked so membership on any of them conveys membership in the network as a whole. Some hubs may require subscription or provide tiered service plans. The hub itself <strong>may</strong> provide additional details.') . '</div>' . EOL;
     $ret = z_fetch_url($url);
     if ($ret['success']) {
         $j = json_decode($ret['body'], true);
         if ($j) {
             $o .= '<table class="table table-striped table-hover"><tr><td>' . t('Hub URL') . '</td><td>' . t('Access Type') . '</td><td>' . t('Registration Policy') . '</td><td>' . t('Stats') . '</td><td>' . t('Software') . '</td>';
             if ($rating_enabled) {
                 $o .= '<td colspan="2">' . t('Ratings') . '</td>';
             }
             $o .= '</tr>';
             if ($j['sites']) {
                 foreach ($j['sites'] as $jj) {
                     if (!$jj['project']) {
                         continue;
                     }
                     if (strpos($jj['version'], ' ')) {
                         $x = explode(' ', $jj['version']);
                         if ($x[1]) {
                             $jj['version'] = $x[1];
                         }
                     }
                     $m = parse_url($jj['url']);
                     $host = strtolower(substr($jj['url'], strpos($jj['url'], '://') + 3));
                     $rate_links = local_channel() ? '<td><a href="rate?f=&target=' . $host . '" class="btn-btn-default"><i class="fa fa-check-square-o"></i> ' . t('Rate') . '</a></td>' : '';
                     $location = '';
                     if (!empty($jj['location'])) {
                         $location = '<p title="' . t('Location') . '" style="margin: 5px 5px 0 0; text-align: right"><i class="fa fa-globe"></i> ' . $jj['location'] . '</p>';
                     } else {
                         $location = '<br />&nbsp;';
                     }
                     $urltext = str_replace(array('https://'), '', $jj['url']);
                     $o .= '<tr><td><a href="' . ($jj['sellpage'] ? $jj['sellpage'] : $jj['url'] . '/register') . '" ><i class="fa fa-link"></i> ' . $urltext . '</a>' . $location . '</td><td>' . $jj['access'] . '</td><td>' . $jj['register'] . '</td><td>' . '<a target="stats" href="https://hubchart-tarine.rhcloud.com/hub.jsp?hubFqdn=' . $m['host'] . '"><i class="fa fa-area-chart"></i></a></td><td>' . ucwords($jj['project']) . ($jj['version'] ? ' ' . $jj['version'] : '') . '</td>';
                     if ($rating_enabled) {
                         $o .= '<td><a href="ratings/' . $host . '" class="btn-btn-default"><i class="fa fa-eye"></i> ' . t('View') . '</a></td>' . $rate_links;
                     }
                     $o .= '</tr>';
                 }
             }
             $o .= '</table>';
             $o .= '</div></div>';
         }
     }
     return $o;
 }
开发者ID:phellmes,项目名称:hubzilla,代码行数:59,代码来源:Pubsites.php


示例5: init

 function init()
 {
     if (get_config('system', 'block_public') && !local_channel() && !remote_channel()) {
         return;
     }
     if (local_channel()) {
         load_contact_links(local_channel());
     }
     $dirmode = intval(get_config('system', 'directory_mode'));
     $x = find_upstream_directory($dirmode);
     if ($x) {
         $url = $x['url'];
     }
     $poco_rating = get_config('system', 'poco_rating_enable');
     // if unset default to enabled
     if ($poco_rating === false) {
         $poco_rating = true;
     }
     if (!$poco_rating) {
         return;
     }
     if (argc() > 1) {
         $hash = argv(1);
     }
     if (!$hash) {
         notice('Must supply a channel identififier.');
         return;
     }
     $results = false;
     $x = z_fetch_url($url . '/ratingsearch/' . urlencode($hash));
     if ($x['success']) {
         $results = json_decode($x['body'], true);
     }
     if (!$results || !$results['success']) {
         notice('No results.');
         return;
     }
     if (array_key_exists('xchan_hash', $results['target'])) {
         \App::$poi = $results['target'];
     }
     $friends = array();
     $others = array();
     if ($results['ratings']) {
         foreach ($results['ratings'] as $n) {
             if (is_array(\App::$contacts) && array_key_exists($n['xchan_hash'], \App::$contacts)) {
                 $friends[] = $n;
             } else {
                 $others[] = $n;
             }
         }
     }
     \App::$data = array('target' => $results['target'], 'results' => array_merge($friends, $others));
     if (!\App::$data['results']) {
         notice(t('No ratings') . EOL);
     }
     return;
 }
开发者ID:anmol26s,项目名称:hubzilla-yunohost,代码行数:57,代码来源:Ratings.php


示例6: embedly_oembed_probe

function embedly_oembed_probe($a, $b)
{
    // try oohembed service
    $ourl = "http://oohembed.com/oohembed/?url=" . $b['url'] . '&maxwidth=' . $b['videowidth'];
    $result = z_fetch_url($ourl);
    if ($result['success']) {
        $b['embed'] = $result['body'];
    }
}
开发者ID:git-marijus,项目名称:hubzilla-addons,代码行数:9,代码来源:embedly.php


示例7: noembed_oembed_probe

function noembed_oembed_probe(&$a, &$b)
{
    // try noembed service
    $ourl = 'https://noembed.com/embed?url=' . urlencode($b['url']);
    $result = z_fetch_url($ourl);
    if ($result['success']) {
        $b['embed'] = $result['body'];
    }
}
开发者ID:phellmes,项目名称:hubzilla-addons,代码行数:9,代码来源:noembed.php


示例8: ostatus_subscribe_content

function ostatus_subscribe_content(&$a)
{
    if (!local_user()) {
        notice(t('Permission denied.') . EOL);
        goaway($_SESSION['return_url']);
        // NOTREACHED
    }
    $o = "<h2>" . t("Subsribing to OStatus contacts") . "</h2>";
    $uid = local_user();
    $a = get_app();
    $counter = intval($_REQUEST['counter']);
    if (get_pconfig($uid, "ostatus", "legacy_friends") == "") {
        if ($_REQUEST["url"] == "") {
            return $o . t("No contact provided.");
        }
        $contact = probe_url($_REQUEST["url"]);
        if (!$contact) {
            return $o . t("Couldn't fetch information for contact.");
        }
        $api = $contact["baseurl"] . "/api/";
        // Fetching friends
        $data = z_fetch_url($api . "statuses/friends.json?screen_name=" . $contact["nick"]);
        if (!$data["success"]) {
            return $o . t("Couldn't fetch friends for contact.");
        }
        set_pconfig($uid, "ostatus", "legacy_friends", $data["body"]);
    }
    $friends = json_decode(get_pconfig($uid, "ostatus", "legacy_friends"));
    $total = sizeof($friends);
    if ($counter >= $total) {
        $a->page['htmlhead'] = '<meta http-equiv="refresh" content="0; URL=' . $a->get_baseurl() . '/settings/connectors">';
        del_pconfig($uid, "ostatus", "legacy_friends");
        del_pconfig($uid, "ostatus", "legacy_contact");
        $o .= t("Done");
        return $o;
    }
    $friend = $friends[$counter++];
    $url = $friend->statusnet_profile_url;
    $o .= "<p>" . $counter . "/" . $total . ": " . $url;
    $data = probe_url($url);
    if ($data["network"] == NETWORK_OSTATUS) {
        $result = new_contact($uid, $url, true);
        if ($result["success"]) {
            $o .= " - " . t("success");
        } else {
            $o .= " - " . t("failed");
        }
    } else {
        $o .= " - " . t("ignored");
    }
    $o .= "</p>";
    $o .= "<p>" . t("Keep this window open until done.") . "</p>";
    $a->page['htmlhead'] = '<meta http-equiv="refresh" content="0; URL=' . $a->get_baseurl() . '/ostatus_subscribe?counter=' . $counter . '">';
    return $o;
}
开发者ID:ZerGabriel,项目名称:friendica,代码行数:55,代码来源:ostatus_subscribe.php


示例9: fortunate_fetch

function fortunate_fetch(&$a, &$b)
{
    $fort_server = get_config('fortunate', 'server');
    if (!$fort_server) {
        return;
    }
    $a->page['htmlhead'] .= '<link rel="stylesheet" type="text/css" href="' . $a->get_baseurl() . '/addon/fortunate/fortunate.css' . '" media="all" />' . "\r\n";
    $s = z_fetch_url('http://' . $fort_server . '/cookie.php?numlines=4&equal=1&rand=' . mt_rand());
    if ($s['success']) {
        $b .= '<div class="fortunate">' . $s['body'] . '</div>';
    }
}
开发者ID:git-marijus,项目名称:hubzilla-addons,代码行数:12,代码来源:fortunate.php


示例10: oexchange_content

function oexchange_content(&$a)
{
    if (!local_channel()) {
        if (remote_channel()) {
            $observer = $a->get_observer();
            if ($observer && $observer['xchan_url']) {
                $parsed = @parse_url($observer['xchan_url']);
                if (!$parsed) {
                    notice(t('Unable to find your hub.') . EOL);
                    return;
                }
                $url = $parsed['scheme'] . '://' . $parsed['host'] . ($parsed['port'] ? ':' . $parsed['port'] : '');
                $url .= '/oexchange';
                $result = z_post_url($url, $_REQUEST);
                json_return_and_die($result);
            }
        }
        return login(false);
    }
    if (argc() > 1 && argv(1) === 'done') {
        info(t('Post successful.') . EOL);
        return;
    }
    $url = x($_REQUEST, 'url') && strlen($_REQUEST['url']) ? urlencode(notags(trim($_REQUEST['url']))) : '';
    $title = x($_REQUEST, 'title') && strlen($_REQUEST['title']) ? '&title=' . urlencode(notags(trim($_REQUEST['title']))) : '';
    $description = x($_REQUEST, 'description') && strlen($_REQUEST['description']) ? '&description=' . urlencode(notags(trim($_REQUEST['description']))) : '';
    $tags = x($_REQUEST, 'tags') && strlen($_REQUEST['tags']) ? '&tags=' . urlencode(notags(trim($_REQUEST['tags']))) : '';
    $ret = z_fetch_url($a->get_baseurl() . '/urlinfo?f=&url=' . $url . $title . $description . $tags);
    if ($ret['success']) {
        $s = $ret['body'];
    }
    if (!strlen($s)) {
        return;
    }
    $post = array();
    $post['profile_uid'] = local_channel();
    $post['return'] = '/oexchange/done';
    $post['body'] = $s;
    $post['type'] = 'wall';
    $_REQUEST = $post;
    require_once 'mod/item.php';
    item_post($a);
}
开发者ID:TamirAl,项目名称:hubzilla,代码行数:43,代码来源:oexchange.php


示例11: get

 function get()
 {
     $auth_success = false;
     $o .= '<h3>Magic-Auth Diagnostic</h3>';
     if (!local_channel()) {
         notice(t('Permission denied.') . EOL);
         return $o;
     }
     $o .= '<form action="authtest" method="get">';
     $o .= 'Target URL: <input type="text" style="width: 250px;" name="dest" value="' . $_GET['dest'] . '" />';
     $o .= '<input type="submit" name="submit" value="Submit" /></form>';
     $o .= '<br /><br />';
     if (x($_GET, 'dest')) {
         if (strpos($_GET['dest'], '@')) {
             $_GET['dest'] = $_REQUEST['dest'] = 'https://' . substr($_GET['dest'], strpos($_GET['dest'], '@') + 1) . '/channel/' . substr($_GET['dest'], 0, strpos($_GET['dest'], '@'));
         }
         $_REQUEST['test'] = 1;
         $mod = new Magic();
         $x = $mod->init($a);
         $o .= 'Local Setup returns: ' . print_r($x, true);
         if ($x['url']) {
             $z = z_fetch_url($x['url'] . '&test=1');
             if ($z['success']) {
                 $j = json_decode($z['body'], true);
                 if (!$j) {
                     $o .= 'json_decode failure from remote site. ' . print_r($z['body'], true);
                 }
                 $o .= 'Remote site responded: ' . print_r($j, true);
                 if ($j['success'] && strpos($j['message'], 'Authentication Success')) {
                     $auth_success = true;
                 }
             } else {
                 $o .= 'fetch url failure.' . print_r($z, true);
             }
         }
         if (!$auth_success) {
             $o .= 'Authentication Failed!' . EOL;
         }
     }
     return str_replace("\n", '<br />', $o);
 }
开发者ID:BlaBlaNet,项目名称:hubzilla,代码行数:41,代码来源:Authtest.php


示例12: sslify_init

function sslify_init(&$a)
{
    $x = z_fetch_url($_REQUEST['url']);
    if ($x['success']) {
        $h = explode("\n", $x['header']);
        foreach ($h as $l) {
            list($k, $v) = array_map("trim", explode(":", trim($l), 2));
            $hdrs[$k] = $v;
        }
        if (array_key_exists('Content-Type', $hdrs)) {
            $type = $hdrs['Content-Type'];
        }
        header('Content-Type: ' . $type);
        echo $x['body'];
        killme();
    }
    killme();
    // for some reason when this fallback is in place - it gets triggered
    // often, (creating mixed content exceptions) even though there is
    // nothing obvious missing on the page when we bypass it.
    goaway($_REQUEST['url']);
}
开发者ID:TamirAl,项目名称:hubzilla,代码行数:22,代码来源:sslify.php


示例13: diaspora_load

function diaspora_load()
{
    register_hook('notifier_hub', 'addon/diaspora/diaspora.php', 'diaspora_process_outbound');
    register_hook('notifier_process', 'addon/diaspora/diaspora.php', 'diaspora_notifier_process');
    register_hook('permissions_create', 'addon/diaspora/diaspora.php', 'diaspora_permissions_create');
    register_hook('permissions_update', 'addon/diaspora/diaspora.php', 'diaspora_permissions_update');
    register_hook('module_loaded', 'addon/diaspora/diaspora.php', 'diaspora_load_module');
    register_hook('follow_allow', 'addon/diaspora/diaspora.php', 'diaspora_follow_allow');
    register_hook('feature_settings_post', 'addon/diaspora/diaspora.php', 'diaspora_feature_settings_post');
    register_hook('feature_settings', 'addon/diaspora/diaspora.php', 'diaspora_feature_settings');
    register_hook('post_local', 'addon/diaspora/diaspora.php', 'diaspora_post_local');
    register_hook('well_known', 'addon/diaspora/diaspora.php', 'diaspora_well_known');
    if (!get_config('diaspora', 'relay_handle')) {
        $x = import_author_diaspora(array('address' => '[email protected]'));
        if ($x) {
            set_config('diaspora', 'relay_handle', $x);
            // Now register
            $url = "http://the-federation.info/register/" . App::get_hostname();
            $ret = z_fetch_url($url);
        }
    }
}
开发者ID:anmol26s,项目名称:hubzilla-yunohost,代码行数:22,代码来源:diaspora.php


示例14: import_account

 function import_account($account_id)
 {
     if (!$account_id) {
         logger("import_account: No account ID supplied");
         return;
     }
     $max_identities = account_service_class_fetch($account_id, 'total_identities');
     $max_friends = account_service_class_fetch($account_id, 'total_channels');
     $max_feeds = account_service_class_fetch($account_id, 'total_feeds');
     if ($max_identities !== false) {
         $r = q("select channel_id from channel where channel_account_id = %d", intval($account_id));
         if ($r && count($r) > $max_identities) {
             notice(sprintf(t('Your service plan only allows %d channels.'), $max_identities) . EOL);
             return;
         }
     }
     $data = null;
     $seize = x($_REQUEST, 'make_primary') ? intval($_REQUEST['make_primary']) : 0;
     $import_posts = x($_REQUEST, 'import_posts') ? intval($_REQUEST['import_posts']) : 0;
     $src = $_FILES['filename']['tmp_name'];
     $filename = basename($_FILES['filename']['name']);
     $filesize = intval($_FILES['filename']['size']);
     $filetype = $_FILES['filename']['type'];
     $completed = array_key_exists('import_step', $_SESSION) ? intval($_SESSION['import_step']) : 0;
     if ($completed) {
         logger('saved import step: ' . $_SESSION['import_step']);
     }
     if ($src) {
         // This is OS specific and could also fail if your tmpdir isn't very large
         // mostly used for Diaspora which exports gzipped files.
         if (strpos($filename, '.gz')) {
             @rename($src, $src . '.gz');
             @system('gunzip ' . escapeshellarg($src . '.gz'));
         }
         if ($filesize) {
             $data = @file_get_contents($src);
         }
         unlink($src);
     }
     if (!$src) {
         $old_address = x($_REQUEST, 'old_address') ? $_REQUEST['old_address'] : '';
         if (!$old_address) {
             logger('mod_import: nothing to import.');
             notice(t('Nothing to import.') . EOL);
             return;
         }
         $email = x($_REQUEST, 'email') ? $_REQUEST['email'] : '';
         $password = x($_REQUEST, 'password') ? $_REQUEST['password'] : '';
         $channelname = substr($old_address, 0, strpos($old_address, '@'));
         $servername = substr($old_address, strpos($old_address, '@') + 1);
         $scheme = 'https://';
         $api_path = '/api/red/channel/export/basic?f=&channel=' . $channelname;
         if ($import_posts) {
             $api_path .= '&posts=1';
         }
         $binary = false;
         $redirects = 0;
         $opts = array('http_auth' => $email . ':' . $password);
         $url = $scheme . $servername . $api_path;
         $ret = z_fetch_url($url, $binary, $redirects, $opts);
         if (!$ret['success']) {
             $ret = z_fetch_url('http://' . $servername . $api_path, $binary, $redirects, $opts);
         }
         if ($ret['success']) {
             $data = $ret['body'];
         } else {
             notice(t('Unable to download data from old server') . EOL);
         }
     }
     if (!$data) {
         logger('mod_import: empty file.');
         notice(t('Imported file is empty.') . EOL);
         return;
     }
     $data = json_decode($data, true);
     //	logger('import: data: ' . print_r($data,true));
     //	print_r($data);
     if (array_key_exists('user', $data) && array_key_exists('version', $data)) {
         require_once 'include/Import/import_diaspora.php';
         import_diaspora($data);
         return;
     }
     $moving = false;
     if (array_key_exists('compatibility', $data) && array_key_exists('database', $data['compatibility'])) {
         $v1 = substr($data['compatibility']['database'], -4);
         $v2 = substr(DB_UPDATE_VERSION, -4);
         if ($v2 > $v1) {
             $t = sprintf(t('Warning: Database versions differ by %1$d updates.'), $v2 - $v1);
             notice($t);
         }
         if (array_key_exists('server_role', $data['compatibility']) && $data['compatibility']['server_role'] == 'basic') {
             $moving = true;
         }
     }
     if ($moving) {
         $seize = 1;
     }
     // import channel
     $relocate = array_key_exists('relocate', $data) ? $data['relocate'] : null;
     if (array_key_exists('channel', $data)) {
//.........这里部分代码省略.........
开发者ID:phellmes,项目名称:hubzilla,代码行数:101,代码来源:Import.php


示例15: remote_online_status

function remote_online_status($webbie)
{
    $result = false;
    $r = q("select * from hubloc where hubloc_addr = '%s' limit 1", dbesc($webbie));
    if (!$r) {
        return $result;
    }
    $url = $r[0]['hubloc_url'] . '/online/' . substr($webbie, 0, strpos($webbie, '@'));
    $x = z_fetch_url($url);
    if ($x['success']) {
        $j = json_decode($x['body'], true);
        if ($j) {
            $result = $j['result'] ? $j['result'] : false;
        }
    }
    return $result;
}
开发者ID:23n,项目名称:hubzilla,代码行数:17,代码来源:identity.php


示例16: exec

 function exec()
 {
     $opts = $this->curlopts;
     $url = $this->url;
     if ($this->auth) {
         $opts['http_auth'] = $this->auth;
     }
     if ($this->magicauth) {
         $opts['cookiejar'] = 'store/[data]/cookie_' . $this->magicauth;
         $opts['cookiefile'] = 'store/[data]/cookie_' . $this->magicauth;
         $opts['cookie'] = 'PHPSESSID=' . trim(file_get_contents('store/[data]/cookien_' . $this->magicauth));
         $c = channelx_by_n($this->magicauth);
         if ($c) {
             $url = zid($this->url, channel_reddress($c));
         }
     }
     if ($this->custom) {
         $opts['custom'] = $this->custom;
     }
     if ($this->headers) {
         $opts['headers'] = $this->headers;
     }
     if ($this->upload) {
         $opts['upload'] = true;
         $opts['infile'] = $this->filehandle;
         $opts['infilesize'] = strlen($this->request_data);
         $opts['readfunc'] = [$this, 'curl_read'];
     }
     $recurse = 0;
     return z_fetch_url($this->url, true, $recurse, $opts ? $opts : null);
 }
开发者ID:phellmes,项目名称:hubzilla,代码行数:31,代码来源:SuperCurl.php


示例17: import_xchan_photo

function import_xchan_photo($photo, $xchan, $thing = false)
{
    $flags = $thing ? PHOTO_THING : PHOTO_XCHAN;
    $album = $thing ? 'Things' : 'Contact Photos';
    logger('import_xchan_photo: updating channel photo from ' . $photo . ' for ' . $xchan, LOGGER_DEBUG);
    if ($thing) {
        $hash = photo_new_resource();
    } else {
        $r = q("select resource_id from photo where xchan = '%s' and photo_usage = %d and imgscale = 4 limit 1", dbesc($xchan), intval(PHOTO_XCHAN));
        if ($r) {
            $hash = $r[0]['resource_id'];
        } else {
            $hash = photo_new_resource();
        }
    }
    $photo_failure = false;
    $img_str = '';
    if ($photo) {
        $filename = basename($photo);
        $result = z_fetch_url($photo, true);
        if ($result['success']) {
            $img_str = $result['body'];
            $type = guess_image_type($photo, $result['header']);
            $h = explode("\n", $result['header']);
            if ($h) {
                foreach ($h as $hl) {
                    if (stristr($hl, 'content-type:')) {
                        if (!stristr($hl, 'image/')) {
                            $photo_failure = true;
                        }
                    }
                }
            }
        }
    } else {
        $photo_failure = true;
    }
    if (!$photo_failure) {
        $img = photo_factory($img_str, $type);
        if ($img->is_valid()) {
            $width = $img->getWidth();
            $height = $img->getHeight();
            if ($width && $height) {
                if ($width / $height > 1.2) {
                    // crop out the sides
                    $margin = $width - $height;
                    $img->cropImage(300, $margin / 2, 0, $height, $height);
                } elseif ($height / $width > 1.2) {
                    // crop out the bottom
                    $margin = $height - $width;
                    $img->cropImage(300, 0, 0, $width, $width);
                } else {
                    $img->scaleImageSquare(300);
                }
            } else {
                $photo_failure = true;
            }
            $p = array('xchan' => $xchan, 'resource_id' => $hash, 'filename' => basename($photo), 'album' => $album, 'photo_usage' => $flags, 'imgscale' => 4);
            $r = $img->save($p);
            if ($r === false) {
                $photo_failure = true;
            }
            $img->scaleImage(80);
            $p['imgscale'] = 5;
            $r = $img->save($p);
            if ($r === false) {
                $photo_failure = true;
            }
            $img->scaleImage(48);
            $p['imgscale'] = 6;
            $r = $img->save($p);
            if ($r === false) {
                $photo_failure = true;
            }
            $photo = z_root() . '/photo/' . $hash . '-4';
            $thumb = z_root() . '/photo/' . $hash . '-5';
            $micro = z_root() . '/photo/' . $hash . '-6';
        } else {
            logger('import_xchan_photo: invalid image from ' . $photo);
            $photo_failure = true;
        }
    }
    if ($photo_failure) {
        $photo = z_root() . '/' . get_default_profile_photo();
        $thumb = z_root() . '/' . get_default_profile_photo(80);
        $micro = z_root() . '/' . get_default_profile_photo(48);
        $type = 'image/png';
    }
    return array($photo, $thumb, $micro, $type, $photo_failure);
}
开发者ID:phellmes,项目名称:hubzilla,代码行数:90,代码来源:photo_driver.php


示例18: random_profile

function random_profile()
{
    $randfunc = db_getfunc('rand');
    $checkrandom = get_config('randprofile', 'check');
    // False by default
    $retryrandom = intval(get_config('randprofile', 'retry'));
    if ($retryrandom == 0) {
        $retryrandom = 5;
    }
    for ($i = 0; $i < $retryrandom; $i++) {
        $r = q("select xchan_url from xchan left join hubloc on hubloc_hash = xchan_hash where hubloc_connected > %s - interval %s order by {$randfunc} limit 1", db_utcnow(), db_quoteinterval('30 day'));
        if (!$r) {
            return '';
        }
        // Couldn't get a random channel
        if ($checkrandom) {
            $x = z_fetch_url($r[0]['xchan_url']);
            if ($x['success']) {
                return $r[0]['xchan_url'];
            } else {
                logger('Random channel turned out to be bad.');
            }
        } else {
            return $r[0]['xchan_url'];
        }
    }
    return '';
}
开发者ID:anmol26s,项目名称:hubzilla-yunohost,代码行数:28,代码来源:Contact.php


示例19: diaspora_reshare

function diaspora_reshare($importer, $xml, $msg)
{
    logger('diaspora_reshare: init: ' . print_r($xml, true));
    $a = get_app();
    $guid = notags(unxmlify($xml->guid));
    $diaspora_handle = notags(unxmlify($xml->diaspora_handle));
    if ($diaspora_handle != $msg['author']) {
        logger('diaspora_post: Potential forgery. Message handle is not the same as envelope sender.');
        return 202;
    }
    $contact = diaspora_get_contact_by_handle($importer['channel_id'], $diaspora_handle);
    if (!$contact) {
        return;
    }
    if (!perm_is_allowed($importer['channel_id'], $contact['xchan_hash'], 'send_stream')) {
        logger('diaspora_reshare: Ignoring this author: ' . $diaspora_handle . ' ' . print_r($xml, true));
        return 202;
    }
    $search_guid = strlen($guid) == 64 ? $guid . '%' : $guid;
    $r = q("SELECT id FROM item WHERE uid = %d AND mid like '%s' LIMIT 1", intval($importer['channel_id']), dbesc($search_guid));
    if ($r) {
        logger('diaspora_reshare: message exists: ' . $guid);
        return;
    }
    $orig_author = notags(unxmlify($xml->root_diaspora_id));
    $orig_guid = notags(unxmlify($xml->root_guid));
    $source_url = 'https://' . substr($orig_author, strpos($orig_author, '@') + 1) . '/p/' . $orig_guid . '.xml';
    $orig_url = 'https://' . substr($orig_author, strpos($orig_author, '@') + 1) . '/posts/' . $orig_guid;
    $x = z_fetch_url($source_url);
    if (!$x['success']) {
        $x = z_fetch_url(str_replace('https://', 'http://', $source_url));
    }
    if (!$x['success']) {
        logger('diaspora_reshare: unable to fetch source url ' . $source_url);
        return;
    }
    logger('diaspora_reshare: source: ' . $x['body']);
    $source_xml = parse_xml_string($x['body'], false);
    if ($source_xml->post->status_message) {
        $body = diaspora2bb($source_xml->post->status_message->raw_message);
        // Checking for embedded pictures
        if ($source_xml->post->status_message->photo->remote_photo_path && $source_xml->post->status_message->photo->remote_photo_name) {
            $remote_photo_path = notags(unxmlify($source_xml->post->status_message->photo->remote_photo_path));
            $remote_photo_name = notags(unxmlify($source_xml->post->status_message->photo->remote_photo_name));
            $body = '[img]' . $remote_photo_path . $remote_photo_name . '[/img]' . "\n" . $body;
            logger('diaspora_reshare: embedded picture link found: ' . $body, LOGGER_DEBUG);
        }
        $body = scale_external_images($body);
        // Add OEmbed and other information to the body
        //		$body = add_page_info_to_body($body, false, true);
    } else {
        // Maybe it is a reshare of a photo that will be delivered at a later time (testing)
        logger('diaspora_reshare: no reshare content found: ' . print_r($source_xml, true));
        $body = "";
        //return;
    }
    //if(! $body) {
    //	logger('diaspora_reshare: empty body: source= ' . $x);
    //	return;
    //}
    $person = find_diaspora_person_by_handle($orig_author);
    if ($person) {
        $orig_author_name = $person['xchan_name'];
        $orig_author_link = $person['xchan_url'];
        $orig_author_photo = $person['xchan_photo_m'];
    }
    $newbody = "[share author='" . urlencode($orig_author_name) . "' profile='" . $orig_author_link . "' avatar='" . $orig_author_photo . "' link='" . $orig_url . "' posted='" . datetime_convert('UTC', 'UTC', unxmlify($sourcexml->post->status_message->created_at)) . "' message_id='" . unxmlify($source_xml->post->status_message->guid) . "]" . $body . "[/share]";
    $created = unxmlify($xml->created_at);
    $private = unxmlify($xml->public) == 'false' ? 1 : 0;
    $datarray = array();
    $str_tags = '';
    $tags = get_tags($newbody);
    if (count($tags)) {
        $datarray['term'] = array();
        foreach ($tags as $tag) {
            if (strpos($tag, '#') === 0) {
                if (strpos($tag, '[url=')) {
                    continue;
                }
                // don't link tags that are already embedded in links
                if (preg_match('/\\[(.*?)' . preg_quote($tag, '/') . '(.*?)\\]/', $newbody)) {
                    continue;
                }
                if (preg_match('/\\[(.*?)\\]\\((.*?)' . preg_quote($tag, '/') . '(.*?)\\)/', $newbody)) {
                    continue;
                }
                $basetag = str_replace('_', ' ', substr($tag, 1));
                $newbody = str_replace($tag, '#[url=' . $a->get_baseurl() . '/search?tag=' . rawurlencode($basetag) . ']' . $basetag . '[/url]', $newbody);
                $datarray['term'][] = array('uid' => $importer['channel_id'], 'type' => TERM_HASHTAG, 'otype' => TERM_OBJ_POST, 'term' => $basetag, 'url' => z_root() . '/search?tag=' . rawurlencode($basetag));
            }
        }
    }
    $cnt = preg_match_all('/@\\[url=(.*?)\\](.*?)\\[\\/url\\]/ism', $newbody, $matches, PREG_SET_ORDER);
    if ($cnt) {
        foreach ($matches as $mtch) {
            $datarray['term'][] = array('uid' => $importer['channel_id'], 'type' => TERM_MENTION, 'otype' => TERM_OBJ_POST, 'term' => $mtch[2], 'url' => $mtch[1]);
        }
    }
    // This won't work
    $plink = 'https://' . substr($diaspora_handle, strpos($diaspora_handle, '@') + 1) . '/posts/' . $guid;
//.........这里部分代码省略.........
开发者ID:Mauru,项目名称:red,代码行数:101,代码来源:diaspora.php


示例20: get

该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
PHP z_path函数代码示例发布时间:2022-05-23
下一篇:
PHP z_exit函数代码示例发布时间: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