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


PHP SquidUpdate::expand方法代码示例

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


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

示例1: purge

 /**
  * Add array of URLs to the purger queue
  *
  * @param Array $urlArr list of URLs to purge
  * @throws WikiaException
  */
 static function purge($urlArr)
 {
     global $wgEnableScribeReport;
     wfProfileIn(__METHOD__);
     if (empty($wgEnableScribeReport)) {
         wfProfileOut(__METHOD__);
         return;
     }
     foreach ($urlArr as $url) {
         if (!is_string($url)) {
             throw new WikiaException('Bad purge URL');
         }
         $url = SquidUpdate::expand($url);
         $method = self::getPurgeCaller();
         wfDebug("Purging URL {$url} from {$method} via Scribe\n");
         wfDebug("Purging backtrace: " . wfGetAllCallers(false) . "\n");
         // add to the queue, will be sent by onRestInPeace method
         self::$urls[$url] = ['url' => $url, 'time' => time(), 'method' => $method];
         self::$urlsCount++;
     }
     wfProfileOut(__METHOD__);
 }
开发者ID:Tjorriemorrie,项目名称:app,代码行数:28,代码来源:ScribePurge.class.php

示例2: queuePurge

 /**
  * Queue a purge operation
  *
  * @param string $url
  */
 public function queuePurge($url)
 {
     global $wgSquidPurgeUseHostHeader;
     $url = SquidUpdate::expand(str_replace("\n", '', $url));
     $request = array();
     if ($wgSquidPurgeUseHostHeader) {
         $url = wfParseUrl($url);
         $host = $url['host'];
         if (isset($url['port']) && strlen($url['port']) > 0) {
             $host .= ":" . $url['port'];
         }
         $path = $url['path'];
         if (isset($url['query']) && is_string($url['query'])) {
             $path = wfAppendQuery($path, $url['query']);
         }
         $request[] = "PURGE {$path} HTTP/1.1";
         $request[] = "Host: {$host}";
     } else {
         $request[] = "PURGE {$url} HTTP/1.0";
     }
     $request[] = "Connection: Keep-Alive";
     $request[] = "Proxy-Connection: Keep-Alive";
     $request[] = "User-Agent: " . Http::userAgent() . ' ' . __CLASS__;
     // Two ''s to create \r\n\r\n
     $request[] = '';
     $request[] = '';
     $this->requests[] = implode("\r\n", $request);
     if ($this->currentRequestIndex === null) {
         $this->nextRequest();
     }
 }
开发者ID:eliagbayani,项目名称:LiteratureEditor,代码行数:36,代码来源:SquidPurgeClient.php

示例3: ScribePurge

 /**
  * wikia function
  * @
  * @access public
  * @static
  */
 static function ScribePurge($urlArr)
 {
     global $wgEnableScribeReport;
     wfProfileIn(__METHOD__);
     $key = 'varnish_purges';
     if (empty($wgEnableScribeReport)) {
         wfProfileOut(__METHOD__);
         return true;
     }
     try {
         foreach ($urlArr as $url) {
             if (!is_string($url)) {
                 throw new MWException('Bad purge URL');
             }
             $url = SquidUpdate::expand($url);
             wfDebug("Purging URL {$url} via Scribe\n");
             $data = json_encode(array('url' => $url, 'time' => time()));
             WScribeClient::singleton($key)->send($data);
         }
     } catch (TException $e) {
         Wikia::log(__METHOD__, 'scribeClient exception', $e->getMessage());
     }
     wfProfileOut(__METHOD__);
 }
开发者ID:schwarer2006,项目名称:wikia,代码行数:30,代码来源:SquidUpdate.php

示例4: HTCPPurge

 /**
  * @throws MWException
  * @param $urlArr array
  */
 static function HTCPPurge($urlArr)
 {
     global $wgHTCPMulticastRouting, $wgHTCPMulticastTTL;
     wfProfileIn(__METHOD__);
     $htcpOpCLR = 4;
     // HTCP CLR
     // @todo FIXME: PHP doesn't support these socket constants (include/linux/in.h)
     if (!defined("IPPROTO_IP")) {
         define("IPPROTO_IP", 0);
         define("IP_MULTICAST_LOOP", 34);
         define("IP_MULTICAST_TTL", 33);
     }
     // pfsockopen doesn't work because we need set_sock_opt
     $conn = socket_create(AF_INET, SOCK_DGRAM, SOL_UDP);
     if ($conn) {
         // Set socket options
         socket_set_option($conn, IPPROTO_IP, IP_MULTICAST_LOOP, 0);
         if ($wgHTCPMulticastTTL != 1) {
             socket_set_option($conn, IPPROTO_IP, IP_MULTICAST_TTL, $wgHTCPMulticastTTL);
         }
         $urlArr = array_unique($urlArr);
         // Remove duplicates
         foreach ($urlArr as $url) {
             if (!is_string($url)) {
                 wfProfileOut(__METHOD__);
                 throw new MWException('Bad purge URL');
             }
             $url = SquidUpdate::expand($url);
             $conf = self::getRuleForURL($url, $wgHTCPMulticastRouting);
             if (!$conf) {
                 wfDebug("No HTCP rule configured for URL {$url} , skipping\n");
                 continue;
             }
             if (!isset($conf['host']) || !isset($conf['port'])) {
                 wfProfileOut(__METHOD__);
                 throw new MWException("Invalid HTCP rule for URL {$url}\n");
             }
             // Construct a minimal HTCP request diagram
             // as per RFC 2756
             // Opcode 'CLR', no response desired, no auth
             $htcpTransID = rand();
             $htcpSpecifier = pack('na4na*na8n', 4, 'HEAD', strlen($url), $url, 8, 'HTTP/1.0', 0);
             $htcpDataLen = 8 + 2 + strlen($htcpSpecifier);
             $htcpLen = 4 + $htcpDataLen + 2;
             // Note! Squid gets the bit order of the first
             // word wrong, wrt the RFC. Apparently no other
             // implementation exists, so adapt to Squid
             $htcpPacket = pack('nxxnCxNxxa*n', $htcpLen, $htcpDataLen, $htcpOpCLR, $htcpTransID, $htcpSpecifier, 2);
             // Send out
             wfDebug("Purging URL {$url} via HTCP\n");
             socket_sendto($conn, $htcpPacket, $htcpLen, 0, $conf['host'], $conf['port']);
         }
     } else {
         $errstr = socket_strerror(socket_last_error());
         wfDebug(__METHOD__ . "(): Error opening UDP socket: {$errstr}\n");
     }
     wfProfileOut(__METHOD__);
 }
开发者ID:mangowi,项目名称:mediawiki,代码行数:62,代码来源:SquidUpdate.php

示例5: HTCPPurge

 static function HTCPPurge($urlArr)
 {
     global $wgHTCPMulticastAddress, $wgHTCPMulticastTTL, $wgHTCPPort;
     $fname = 'SquidUpdate::HTCPPurge';
     wfProfileIn($fname);
     $htcpOpCLR = 4;
     // HTCP CLR
     // FIXME PHP doesn't support these socket constants (include/linux/in.h)
     if (!defined("IPPROTO_IP")) {
         define("IPPROTO_IP", 0);
         define("IP_MULTICAST_LOOP", 34);
         define("IP_MULTICAST_TTL", 33);
     }
     // pfsockopen doesn't work because we need set_sock_opt
     $conn = socket_create(AF_INET, SOCK_DGRAM, SOL_UDP);
     if ($conn) {
         // Set socket options
         socket_set_option($conn, IPPROTO_IP, IP_MULTICAST_LOOP, 0);
         if ($wgHTCPMulticastTTL != 1) {
             socket_set_option($conn, IPPROTO_IP, IP_MULTICAST_TTL, $wgHTCPMulticastTTL);
         }
         foreach ($urlArr as $url) {
             if (!is_string($url)) {
                 wfDebugDieBacktrace('Bad purge URL');
             }
             $url = SquidUpdate::expand($url);
             // Construct a minimal HTCP request diagram
             // as per RFC 2756
             // Opcode 'CLR', no response desired, no auth
             $htcpTransID = rand();
             $htcpSpecifier = pack('na4na*na8n', 4, 'HEAD', strlen($url), $url, 8, 'HTTP/1.0', 0);
             $htcpDataLen = 8 + 2 + strlen($htcpSpecifier);
             $htcpLen = 4 + $htcpDataLen + 2;
             // Note! Squid gets the bit order of the first
             // word wrong, wrt the RFC. Apparently no other
             // implementation exists, so adapt to Squid
             $htcpPacket = pack('nxxnCxNxxa*n', $htcpLen, $htcpDataLen, $htcpOpCLR, $htcpTransID, $htcpSpecifier, 2);
             // Send out
             wfDebug("Purging URL {$url} via HTCP\n");
             socket_sendto($conn, $htcpPacket, $htcpLen, 0, $wgHTCPMulticastAddress, $wgHTCPPort);
         }
     } else {
         $errstr = socket_strerror(socket_last_error());
         wfDebug("SquidUpdate::HTCPPurge(): Error opening UDP socket: {$errstr}\n");
     }
     wfProfileOut($fname);
 }
开发者ID:BackupTheBerlios,项目名称:shoutwiki-svn,代码行数:47,代码来源:SquidUpdate.php

示例6: queuePurge

 /**
  * Queue a purge operation
  *
  * @param $url string
  */
 public function queuePurge($url)
 {
     $url = SquidUpdate::expand(str_replace("\n", '', $url));
     $this->requests[] = "PURGE {$url} HTTP/1.0\r\n" . "Connection: Keep-Alive\r\n" . "Proxy-Connection: Keep-Alive\r\n" . "User-Agent: " . Http::userAgent() . ' ' . __CLASS__ . "\r\n\r\n";
     if ($this->currentRequestIndex === null) {
         $this->nextRequest();
     }
 }
开发者ID:Tjorriemorrie,项目名称:app,代码行数:13,代码来源:SquidPurgeClient.php


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