當前位置: 首頁>>代碼示例>>PHP>>正文


PHP utils::file_get_contents_curl方法代碼示例

本文整理匯總了PHP中utils::file_get_contents_curl方法的典型用法代碼示例。如果您正苦於以下問題:PHP utils::file_get_contents_curl方法的具體用法?PHP utils::file_get_contents_curl怎麽用?PHP utils::file_get_contents_curl使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在utils的用法示例。


在下文中一共展示了utils::file_get_contents_curl方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: getPublishedPatchs

 /**
  * Used to get the published patches of a given server and a given pushfeed
  * (and optionnaly a page title)
  * @param <string> $server url of the server
  * @param <string> $pushName pushfeed name
  * @param <string> $title article title
  * @return <array> array of patchIDs
  */
 static function getPublishedPatchs($server, $pushName, $title = null)
 {
     //global $wgScriptExtension;
     $published = array();
     $pushName = str_replace(' ', '_', $pushName);
     $title = str_replace(' ', '_', $title);
     if (isset($title)) {
         $patchXML = utils::file_get_contents_curl(utils::lcfirst($server) . "/api.php?action=query&meta=patchPushed&pppushName=" . $pushName . '&pppageName=' . $title . '&format=xml');
         /*test if it is a xml file. If not, the server is not reachable via the url
          * Then we try to reach it with the .php5 extension
          */
         if (strpos($patchXML, "<?xml version=\"1.0\"?>") === false) {
             $patchXML = utils::file_get_contents_curl(utils::lcfirst($server) . "/api.php5?action=query&meta=patchPushed&pppushName=" . $pushName . '&pppageName=' . $title . '&format=xml');
         }
         if (strpos($patchXML, "<?xml version=\"1.0\"?>") === false) {
             $patchXML = false;
         }
     } else {
         $patchXML = utils::file_get_contents_curl(utils::lcfirst($server) . "/api.php?action=query&meta=patchPushed&pppushName=" . $pushName . '&format=xml');
         /*test if it is a xml file. If not, the server is not reachable via the url
          * Then we try to reach it with the .php5 extension
          */
         if (strpos($patchXML, "<?xml version=\"1.0\"?>") === false) {
             $patchXML = utils::file_get_contents_curl(utils::lcfirst($server) . "/api.php5?action=query&meta=patchPushed&pppushName=" . $pushName . '&format=xml');
         }
         if (strpos($patchXML, "<?xml version=\"1.0\"?>") === false) {
             $patchXML = false;
         }
     }
     if ($patchXML === false) {
         return false;
     }
     $patchXML = trim($patchXML);
     $dom = new DOMDocument();
     $dom->loadXML($patchXML);
     $patchPublished = $dom->getElementsByTagName('patch');
     $published = array();
     foreach ($patchPublished as $p) {
         $published[] = $p->firstChild->nodeValue;
     }
     return $published;
 }
開發者ID:hala54,項目名稱:DSMW,代碼行數:50,代碼來源:utils.php

示例2: onUnknownAction


//.........這裏部分代碼省略.........
         }
         // $name = $name1[0];//with NS
         utils::writeAndFlush('<p><b>Start pull</b></p>');
         foreach ($name1 as $name) {
             // for each pullfeed name==> pull
             utils::writeAndFlush("<span style=\"margin-left:30px;\">begin pull: <A HREF=" . 'http://' . $wgServerName . $wgScriptPath . "/index.php?title={$name}>" . $name . "</a></span> <br/>");
             wfDebugLog('p2p', '      -> pull : ' . $name);
             // $previousCSID = getPreviousPulledCSID($name);
             // if($previousCSID==false) {
             //	$previousCSID = "none";
             // }
             $previousCSID = getHasPullHead($name);
             if ($previousCSID == false) {
                 $previousCSID = "none";
             }
             wfDebugLog('p2p', '      -> pullHead : ' . $previousCSID);
             $relatedPushServer = getPushURL($name);
             if (is_null($relatedPushServer)) {
                 throw new MWException(__METHOD__ . ': no relatedPushServer url');
             }
             $namePush = getPushName($name);
             $namePush = str_replace(' ', '_', $namePush);
             wfDebugLog('p2p', '      -> pushServer : ' . $relatedPushServer);
             wfDebugLog('p2p', '      -> pushName : ' . $namePush);
             if (is_null($namePush)) {
                 throw new MWException(__METHOD__ . ': no PushName');
             }
             // split NS and name
             preg_match("/^(.+?)_*:_*(.*)\$/S", $namePush, $m);
             $nameWithoutNS = $m[2];
             // $url = $relatedPushServer.'/api.php?action=query&meta=changeSet&cspushName='.$nameWithoutNS.'&cschangeSet='.$previousCSID.'&format=xml';
             // $url = $relatedPushServer."/api{$wgScriptExtension}?action=query&meta=changeSet&cspushName=".$nameWithoutNS.'&cschangeSet='.$previousCSID.'&format=xml';
             wfDebugLog('testlog', '      -> request ChangeSet : ' . $relatedPushServer . '/api.php?action=query&meta=changeSet&cspushName=' . $nameWithoutNS . '&cschangeSet=' . $previousCSID . '&format=xml');
             $cs = utils::file_get_contents_curl(utils::lcfirst($relatedPushServer) . "/api.php?action=query&meta=changeSet&cspushName=" . $nameWithoutNS . '&cschangeSet=' . $previousCSID . '&format=xml');
             /* test if it is a xml file. If not, the server is not reachable via the url
              * Then we try to reach it with the .php5 extension
              */
             if (strpos($cs, "<?xml version=\"1.0\"?>") === false) {
                 $cs = utils::file_get_contents_curl(utils::lcfirst($relatedPushServer) . "/api.php5?action=query&meta=changeSet&cspushName=" . $nameWithoutNS . '&cschangeSet=' . $previousCSID . '&format=xml');
             }
             if (strpos($cs, "<?xml version=\"1.0\"?>") === false) {
                 $cs = false;
             }
             if ($cs === false) {
                 throw new MWException(__METHOD__ . ': Cannot connect to Push Server (ChangeSet API)');
             }
             $cs = trim($cs);
             $dom = new DOMDocument();
             $dom->loadXML($cs);
             $changeSet = $dom->getElementsByTagName('changeSet');
             $CSID = null;
             foreach ($changeSet as $cs) {
                 if ($cs->hasAttribute("id")) {
                     $CSID = $cs->getAttribute('id');
                     $csName = $CSID;
                 }
             }
             wfDebugLog('p2p', '     -> changeSet found ' . $CSID);
             while ($CSID != null) {
                 // if(!utils::pageExist($CSID)) {
                 $listPatch = null;
                 $patchs = $dom->getElementsByTagName('patch');
                 foreach ($patchs as $p) {
                     wfDebugLog('p2p', '          -> patch ' . $p->firstChild->nodeValue);
                     $listPatch[] = $p->firstChild->nodeValue;
                 }
開發者ID:realsoc,項目名稱:mediawiki-extensions,代碼行數:67,代碼來源:DSMW.hooks.php

示例3: downloadFile

function downloadFile($url)
{
    global $wgServerName, $wgServer, $wgContLang, $wgAuth, $wgScriptPath, $wgScriptExtension, $wgMemc, $wgRequest;
    $apiUrl = $wgServer . $wgScriptPath . "/api" . $wgScriptExtension;
    $edittoken = $apiUrl . "?action=query&prop=info&intoken=edit&titles=Foo&format=xml";
    $edittoken = utils::file_get_contents_curl($edittoken);
    $dom = new DOMDocument();
    $dom->loadXML($edittoken);
    $edittoken = $dom->getElementsByTagName('page');
    foreach ($edittoken as $p) {
        if ($p->hasAttribute("edittoken")) {
            $token = $p->getAttribute('edittoken');
        }
    }
    $token = str_replace("+", "%2B", $token);
    //    $url = $patch->getUrl();
    $onPage = preg_split("/^.*\\//", $url);
    $onPage = $onPage[1];
    $onPage = str_replace(array(' '), array('_'), $onPage);
    $url = str_replace(array(':', 'Http', ' '), array('%3A', 'http', '_'), $url);
    $download = $apiUrl . "?action=upload&filename=" . $onPage . "&url=" . $url . "&token=" . $token . "&ignorewarnings=1";
    $resp = Http::post($download);
    libxml_use_internal_errors(true);
    $sxe = simplexml_load_string($resp);
}
開發者ID:hala54,項目名稱:DSMW,代碼行數:25,代碼來源:IntegrationFunctions.php


注:本文中的utils::file_get_contents_curl方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。