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


PHP DokuHTTPClient::get方法代码示例

本文整理汇总了PHP中DokuHTTPClient::get方法的典型用法代码示例。如果您正苦于以下问题:PHP DokuHTTPClient::get方法的具体用法?PHP DokuHTTPClient::get怎么用?PHP DokuHTTPClient::get使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在DokuHTTPClient的用法示例。


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

示例1: substr

 /**
  * Process trackback request.
  */
 function _process()
 {
     // get ID
     global $ID;
     $ID = substr($_SERVER['PATH_INFO'], 1);
     $sourceUri = $_REQUEST['url'];
     if (is_null($this->tools) || !$this->tools->linkbackAllowed()) {
         $this->_printTrackbackError('Trackbacks disabled.');
         return;
     }
     // No POST request? Quit
     if ($_SERVER['REQUEST_METHOD'] != 'POST') {
         $this->_printTrackbackError('Trackback was not received via HTTP POST.');
         return;
     }
     // Given URL is not an url? Quit
     if (!preg_match("#^([a-z0-9\\-\\.+]+?)://.*#i", $sourceUri)) {
         $this->_printTrackbackError('Given trackback URL is not an URL.');
         return;
     }
     // Source does not exist? Quit
     $http = new DokuHTTPClient();
     $page = $http->get($sourceUri);
     if ($page === false) {
         $this->_printTrackbackError('Linked page cannot be reached');
         return;
     }
     if (!$this->tools->saveLinkback('trackback', strip_tags($_REQUEST['title']), $sourceUri, strip_tags($_REQUEST['excerpt']), $ID)) {
         $this->_printTrackbackError('Trackback already received.');
         return;
     }
     $this->_printTrackbackSuccess();
 }
开发者ID:stupid-beard,项目名称:plugin-blogtng,代码行数:36,代码来源:trackback.php

示例2: get_language_data

 private function get_language_data()
 {
     /* @var $cache door43Cache */
     $cache = $this->getCache();
     $cacheFile = 'langnames.json';
     $langs = $cache->getObject($cacheFile, true);
     // download from api.unfoldingWord.org if needed
     if (empty($langs)) {
         $http = new DokuHTTPClient();
         $raw = $http->get('https://td.unfoldingword.org/exports/langnames.json');
         $langs = json_decode($raw, true);
         $cache->saveString($cacheFile, $raw);
     }
     // if still empty, use the backup copy
     if (empty($langs)) {
         $langs = json_decode(file_get_contents(dirname(__FILE__) . '/lang/langnames.json'), true);
     }
     // $this->LN
     // $this->translations
     $ln = array();
     $translations = '';
     $langDir = array();
     foreach ($langs as $lang) {
         $ln[$lang['lc']] = $lang['ln'];
         $translations .= ' ' . $lang['lc'];
         $langDir[$lang['lc']] = $lang['ld'];
     }
     $cache->saveObject('helperLN.json', $ln);
     $cache->saveObject('languageDirection.json', $langDir);
     $sorted = array_unique(array_filter(explode(' ', $translations)));
     sort($sorted);
     $cache->saveObject('translations.json', $sorted);
 }
开发者ID:Jocai,项目名称:Door43,代码行数:33,代码来源:helper.php

示例3: checkUpdateMessages

/**
 * Check for new messages from upstream
 *
 * @author Andreas Gohr <andi@splitbrain.org>
 */
function checkUpdateMessages()
{
    global $conf;
    global $INFO;
    global $updateVersion;
    if (!$conf['updatecheck']) {
        return;
    }
    if ($conf['useacl'] && !$INFO['ismanager']) {
        return;
    }
    $cf = $conf['cachedir'] . '/messages.txt';
    $lm = @filemtime($cf);
    // check if new messages needs to be fetched
    if ($lm < time() - 60 * 60 * 24 || $lm < @filemtime(DOKU_INC . DOKU_SCRIPT)) {
        @touch($cf);
        dbglog("checkUpdatesMessages(): downloading messages.txt");
        $http = new DokuHTTPClient();
        $http->timeout = 12;
        $data = $http->get(DOKU_MESSAGEURL . $updateVersion);
        io_saveFile($cf, $data);
    } else {
        dbglog("checkUpdatesMessages(): messages.txt up to date");
        $data = io_readFile($cf);
    }
    // show messages through the usual message mechanism
    $msgs = explode("\n%\n", $data);
    foreach ($msgs as $msg) {
        if ($msg) {
            msg($msg, 2);
        }
    }
}
开发者ID:ngharaibeh,项目名称:Methodikos,代码行数:38,代码来源:infoutils.php

示例4: checkUpdateMessages

/**
 * Check for new messages from upstream
 *
 * @author Andreas Gohr <andi@splitbrain.org>
 */
function checkUpdateMessages()
{
    global $conf;
    global $INFO;
    if (!$conf['updatecheck']) {
        return;
    }
    if ($conf['useacl'] && $INFO['perm'] < AUTH_ADMIN) {
        return;
    }
    $cf = $conf['cachedir'] . '/messages.txt';
    $lm = @filemtime($cf);
    // check if new messages needs to be fetched
    if ($lm < time() - 60 * 60 * 24 || $lm < @filemtime(DOKU_CONF . 'msg')) {
        $num = @file(DOKU_CONF . 'msg');
        $num = is_array($num) ? (int) $num[0] : 0;
        $http = new DokuHTTPClient();
        $http->timeout = 8;
        $data = $http->get(DOKU_MESSAGEURL . $num);
        io_saveFile($cf, $data);
    } else {
        $data = io_readFile($cf);
    }
    // show messages through the usual message mechanism
    $msgs = explode("\n%\n", $data);
    foreach ($msgs as $msg) {
        if ($msg) {
            msg($msg, 2);
        }
    }
}
开发者ID:canneverbe,项目名称:flyspray,代码行数:36,代码来源:infoutils.php

示例5: ping

 /**
  * @param $sourceUri
  * @param $targetUri
  * @return IXR_Error
  */
 function ping($sourceUri, $targetUri)
 {
     global $ID;
     $ID = substr($_SERVER['PATH_INFO'], 1);
     if (is_null($this->tools) || !$this->tools->linkbackAllowed()) {
         return new IXR_Error(PINGBACK_ERROR_TARGETURI_CANNOT_BE_USED, '');
     }
     // Given URLs are no urls? Quit
     if (!preg_match("#^([a-z0-9\\-\\.+]+?)://.*#i", $sourceUri)) {
         return new IXR_Error(PINGBACK_ERROR_GENERIC, '');
     }
     if (!preg_match("#^([a-z0-9\\-\\.+]+?)://.*#i", $targetUri)) {
         return new IXR_Error(PINGBACK_ERROR_GENERIC, '');
     }
     // Source URL does not exist? Quit
     $http = new DokuHTTPClient();
     $page = $http->get($sourceUri);
     if ($page === false) {
         return new IXR_Error(PINGBACK_ERROR_SOURCEURI_DOES_NOT_EXIST, '');
     }
     // Target URL does not match with request? Quit
     if ($targetUri != wl($ID, '', true)) {
         return new IXR_Error(PINGBACK_ERROR_GENERIC, '');
     }
     // Retrieve data from source
     $linkback = $this->_getTrackbackData($sourceUri, $targetUri, $page);
     // Source URL does not contain link to target? Quit
     if (!$linkback) {
         return new IXR_Error(PINGBACK_ERROR_SOURCEURI_DOES_NOT_CONTAIN_LINK, '');
     }
     if (!$this->tools->saveLinkback('pingback', $linkback['title'], $sourceUri, $linkback['excerpt'], $ID)) {
         return new IXR_Error(PINGBACK_ERROR_PINGBACK_ALREADY_MADE, '');
     }
 }
开发者ID:stupid-beard,项目名称:plugin-blogtng,代码行数:39,代码来源:pingback.php

示例6: getInfoByHash

 public function getInfoByHash($repository_id, $commit_id)
 {
     $gitlabServer = $this->getConf('server');
     $apiToken = $this->getConf('api_token');
     $http = new DokuHTTPClient();
     $reqUrl = $gitlabServer . '/api/v3/projects/' . $repository_id . '/repository/commits/' . $commit_id . '/?private_token=' . $apiToken;
     $data = json_decode($http->get($reqUrl), true);
     return array($data['message'], $data['id']);
 }
开发者ID:MarcinKlejna,项目名称:dokuwiki-plugin-gitlab,代码行数:9,代码来源:syntax.php

示例7: _getRemoteData

 /**
  * Use DokuWiki's HTTP Clients for downloading
  *
  * @param string $url
  * @throws Exception
  * @return string
  */
 protected function _getRemoteData($url)
 {
     $http = new DokuHTTPClient($url);
     $file = $http->get($url);
     if (!$file) {
         throw new Exception('Your server can\'t connect to external resources. Please update the file manually.');
     }
     return $file;
 }
开发者ID:splitbrain,项目名称:dokuwiki-plugin-statistics,代码行数:16,代码来源:StatisticsBrowscap.class.php

示例8: execute_request

 public function execute_request()
 {
     global $INPUT;
     // if no contentType was passed, use application/json as the default
     $contentType = $INPUT->str('contentType');
     if (empty($contentType)) {
         $contentType = 'application/json';
     }
     header('Content-Type: ' . $contentType);
     $http = new DokuHTTPClient();
     // Get the list of source languages that are level 3.
     $url = $INPUT->str('requestUrl');
     echo $http->get($url);
 }
开发者ID:neutrinog,项目名称:Door43,代码行数:14,代码来源:CrossOriginRequest.php

示例9: _listhd

 private function _listhd()
 {
     require_once DOKU_INC . 'inc/HTTPClient.php';
     $url = 'https://xkcd.com/rss.xml';
     $ch = new DokuHTTPClient();
     $piece = $ch->get($url);
     $xml = simplexml_load_string($piece);
     $comicURL = $xml->channel->item->link;
     $description = (string) $xml->channel->item->description;
     $description = html_entity_decode($description, ENT_NOQUOTES);
     $feed_contents = $description;
     // Not used anymore because of new xml format
     //$dom = new DOMDocument();
     //$dom->loadXML($description);
     //$imgSrc = $dom->childNodes->item(0)->attributes->getNamedItem('src' )->value;
     //$imgTitle = $dom->childNodes->item(0)->attributes->getNamedItem('title' )->value;
     //$feed_contents = "<a href=\"$comicURL\"><img src=\"$imgSrc\" title=\"$imgTitle\" /></a>\n";
     return $feed_contents;
 }
开发者ID:jeffkayser,项目名称:dokuwiki_xkcd_plugin,代码行数:19,代码来源:syntax.php

示例10: checkUpdateMessages

/**
 * Check for new messages from upstream
 *
 * @author Andreas Gohr <andi@splitbrain.org>
 */
function checkUpdateMessages()
{
    global $conf;
    global $INFO;
    global $updateVersion;
    if (!$conf['updatecheck']) {
        return;
    }
    if ($conf['useacl'] && !$INFO['ismanager']) {
        return;
    }
    $cf = getCacheName($updateVersion, '.updmsg');
    $lm = @filemtime($cf);
    // check if new messages needs to be fetched
    if ($lm < time() - 60 * 60 * 24 || $lm < @filemtime(DOKU_INC . DOKU_SCRIPT)) {
        @touch($cf);
        dbglog("checkUpdateMessages(): downloading messages to " . $cf);
        $http = new DokuHTTPClient();
        $http->timeout = 12;
        $resp = $http->get(DOKU_MESSAGEURL . $updateVersion);
        if (is_string($resp) && ($resp == "" || substr(trim($resp), -1) == '%')) {
            // basic sanity check that this is either an empty string response (ie "no messages")
            // or it looks like one of our messages, not WiFi login or other interposed response
            io_saveFile($cf, $resp);
        } else {
            dbglog("checkUpdateMessages(): unexpected HTTP response received");
        }
    } else {
        dbglog("checkUpdateMessages(): messages up to date");
    }
    $data = io_readFile($cf);
    // show messages through the usual message mechanism
    $msgs = explode("\n%\n", $data);
    foreach ($msgs as $msg) {
        if ($msg) {
            msg($msg, 2);
        }
    }
}
开发者ID:esoule,项目名称:dokuwiki,代码行数:44,代码来源:infoutils.php

示例11: DokuHTTPClient

 * DokuWiki Bootstrap3 Template: User Menu
 *
 * @link     http://dokuwiki.org/template:bootstrap3
 * @author   Giuseppe Di Terlizzi <giuseppe.diterlizzi@gmail.com>
 * @license  GPL 2 (http://www.gnu.org/licenses/gpl.html)
 */
// must be run from within DokuWiki
if (!defined('DOKU_INC')) {
    die;
}
$gravatar_check = false;
if (bootstrap3_conf('useGravatar')) {
    $HTTP = new DokuHTTPClient();
    $gravatar_img_small = get_gravatar($INFO['userinfo']['mail'], 30);
    $gravatar_img = get_gravatar($INFO['userinfo']['mail'], 64);
    $gravatar_check = $HTTP->get($gravatar_img . '&d=404');
}
if (!empty($_SERVER['REMOTE_USER'])) {
    ?>
<ul class="nav navbar-nav" id="dw__user_menu">
  <li class="dropdown">

    <a href="#" class="dropdown-toggle" data-toggle="dropdown">
      <?php 
    if ($gravatar_check) {
        ?>
        <img src="<?php 
        echo $gravatar_img_small;
        ?>
" class="img-circle profile-image" />
      <?php 
开发者ID:stupid-beard,项目名称:bootstrap3-sb,代码行数:31,代码来源:tpl_user_menu.php

示例12: dbglog

 /**
  * Render the output remotely at plantuml.no-ip.org
  */
 function _remote($data, $in, $out)
 {
     if (!file_exists($in)) {
         dbglog($in, 'No such plantuml input file');
         return false;
     }
     dbglog("remote render image for {$in}");
     $http = new DokuHTTPClient();
     $http->timeout = 30;
     $remote_url = $this->getConf('remote_url');
     // strip trailing "/" if present
     $base_url = preg_replace('/(.+?)\\/$/', '$1', $remote_url);
     $uml = io_readFile($in);
     $uml = $this->encodep($uml);
     $url = "{$base_url}/img/{$uml}";
     dbglog("image url: {$url}");
     $img = $http->get($url);
     if (!$img) {
         dbglog("download image {$url} failed");
     }
     return $img ? io_saveFile($out, $img) : false;
 }
开发者ID:derron,项目名称:dokuwiki_plantuml,代码行数:25,代码来源:syntax.php

示例13: DokuHTTPClient

 /**
  * Get license under which the content is distributed
  */
 function _getWPlicense($wpUrl)
 {
     $url = $wpUrl . 'w/api.php?action=query&meta=siteinfo&siprop=rightsinfo&format=xml';
     // fetch license data from Wikipedia
     $http = new DokuHTTPClient();
     $http->agent .= ' (DokuWiki WikipediaSnippet Plugin)';
     $data = $http->get($url);
     if (!$data) {
         return false;
     }
     $xml = simplexml_load_string($data, 'SimpleXMLElement');
     if (!$xml) {
         return false;
     }
     $url = $xml->query->rightsinfo['url'];
     $text = $xml->query->rightsinfo['text'];
     return '<div class="wplicense"><a href="' . $url . '">' . $text . '</a></div>';
 }
开发者ID:selfthinker,项目名称:dokuwiki_plugin_wikipediasnippet,代码行数:21,代码来源:syntax.php

示例14: externalmedia

 /**
  * Render an external media file
  *
  * @param string $src        full media URL
  * @param string $title      descriptive text
  * @param string $align      left|center|right
  * @param int    $width      width of media in pixel
  * @param int    $height     height of media in pixel
  * @param string $cache      cache|recache|nocache
  * @param string $linking    linkonly|detail|nolink
  * @param bool   $returnonly whether to return odt or write to doc attribute
  */
 function externalmedia($src, $title = NULL, $align = NULL, $width = NULL, $height = NULL, $cache = NULL, $linking = NULL, $returnonly = false)
 {
     list($ext, $mime) = mimetype($src);
     if (substr($mime, 0, 5) == 'image') {
         $tmp_dir = $this->config->getParam('tmpdir') . "/odt";
         $tmp_name = $tmp_dir . "/" . md5($src) . '.' . $ext;
         $final_name = 'Pictures/' . md5($tmp_name) . '.' . $ext;
         if (!$this->docHandler->fileExists($final_name)) {
             $client = new DokuHTTPClient();
             $img = $client->get($src);
             if ($img === FALSE) {
                 $tmp_name = $src;
                 // fallback to a simple link
             } else {
                 if (!is_dir($tmp_dir)) {
                     io_mkdir_p($tmp_dir);
                 }
                 $tmp_img = fopen($tmp_name, "w") or die("Can't create temp file {$tmp_img}");
                 fwrite($tmp_img, $img);
                 fclose($tmp_img);
             }
         }
         if ($returnonly) {
             $ret = $this->_odtAddImage($tmp_name, $width, $height, $align, $title, true);
             if (file_exists($tmp_name)) {
                 unlink($tmp_name);
             }
             return $ret;
         } else {
             $this->_odtAddImage($tmp_name, $width, $height, $align, $title);
             if (file_exists($tmp_name)) {
                 unlink($tmp_name);
             }
         }
     } else {
         if ($returnonly) {
             return $this->externallink($src, $title, true);
         } else {
             $this->externallink($src, $title);
         }
     }
 }
开发者ID:phillip-hopper,项目名称:dokuwiki-plugin-odt,代码行数:54,代码来源:page.php

示例15: Parse

 function Parse($rss_url)
 {
     // Open and load RSS file
     $http = new DokuHTTPClient();
     if ($rss_content = $http->get($rss_url)) {
         // Parse document encoding
         $result['encoding'] = $this->my_preg_match("'encoding=[\\'\"](.*?)[\\'\"]'si", $rss_content);
         // if document codepage is specified, use it
         if ($result['encoding'] != '') {
             $this->rsscp = $result['encoding'];
         } else {
             $this->rsscp = $this->default_cp;
         }
         // This is used in my_preg_match()
         // Parse CHANNEL info
         preg_match("'<channel.*?>(.*?)</channel>'si", $rss_content, $out_channel);
         foreach ($this->channeltags as $channeltag) {
             $temp = $this->my_preg_match("'<{$channeltag}.*?>(.*?)</{$channeltag}>'si", $out_channel[1]);
             if ($temp != '') {
                 $result[$channeltag] = $temp;
             }
             // Set only if not empty
         }
         // If date_format is specified and lastBuildDate is valid
         if ($this->date_format != '' && ($timestamp = strtotime($result['lastBuildDate'])) !== -1) {
             // convert lastBuildDate to specified date format
             $result['lastBuildDate'] = strftime($this->date_format, $timestamp);
         }
         // Parse TEXTINPUT info
         preg_match("'<textinput(|[^>]*[^/])>(.*?)</textinput>'si", $rss_content, $out_textinfo);
         // This a little strange regexp means:
         // Look for tag <textinput> with or without any attributes, but skip truncated version <textinput /> (it's not beggining tag)
         if (isset($out_textinfo[2])) {
             foreach ($this->textinputtags as $textinputtag) {
                 $temp = $this->my_preg_match("'<{$textinputtag}.*?>(.*?)</{$textinputtag}>'si", $out_textinfo[2]);
                 if ($temp != '') {
                     $result['textinput_' . $textinputtag] = $temp;
                 }
                 // Set only if not empty
             }
         }
         // Parse IMAGE info
         preg_match("'<image.*?>(.*?)</image>'si", $rss_content, $out_imageinfo);
         if (isset($out_imageinfo[1])) {
             foreach ($this->imagetags as $imagetag) {
                 $temp = $this->my_preg_match("'<{$imagetag}.*?>(.*?)</{$imagetag}>'si", $out_imageinfo[1]);
                 if ($temp != '') {
                     $result['image_' . $imagetag] = $temp;
                 }
                 // Set only if not empty
             }
         }
         // Parse ITEMS
         preg_match_all("'<item(| .*?)>(.*?)</item>'si", $rss_content, $items);
         $rss_items = $items[2];
         $i = 0;
         $result['items'] = array();
         // create array even if there are no items
         foreach ($rss_items as $rss_item) {
             //check it is this UTF-8
             if ($this->check_utf8(utf8_decode($rss_item))) {
                 $rss_item = $rss_item;
             } else {
                 if ($this->check_utf8($rss_item)) {
                     $rss_item = utf8_decode($rss_item);
                 }
             }
             // If number of items is lower then limit: Parse one item
             if ($i < $this->items_limit || $this->items_limit == 0) {
                 foreach ($this->itemtags as $itemtag) {
                     $temp = $this->my_preg_match("'<{$itemtag}.*?>(.*?)</{$itemtag}>'si", $rss_item);
                     if ($temp != '') {
                         $result['items'][$i][$itemtag] = $temp;
                     }
                     // Set only if not empty
                 }
                 // Strip HTML tags and other bullshit from DESCRIPTION
                 if ($this->stripHTML && $result['items'][$i]['description']) {
                     $result['items'][$i]['description'] = strip_tags($this->unhtmlentities(strip_tags($result['items'][$i]['description'])));
                 }
                 // Strip HTML tags and other bullshit from TITLE
                 if ($this->stripHTML && $result['items'][$i]['title']) {
                     $result['items'][$i]['title'] = strip_tags($this->unhtmlentities(strip_tags($result['items'][$i]['title'])));
                 }
                 // If date_format is specified and pubDate is valid
                 if ($this->date_format != '' && ($timestamp = strtotime($result['items'][$i]['pubDate'])) !== -1) {
                     // convert pubDate to specified date format
                     $result['items'][$i]['pubDate'] = strftime($this->date_format, $timestamp);
                 }
                 // Item counter
                 $i++;
             }
         }
         $result['items_count'] = $i;
         return $result;
     } else {
         return False;
     }
 }
开发者ID:steinger,项目名称:dokuwiki-plugin-rssticker,代码行数:99,代码来源:lastRSS.php


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