2004-02-18 02:15:00 +00:00
|
|
|
<?php
|
2004-09-02 23:28:24 +00:00
|
|
|
/**
|
2012-05-08 12:51:21 +00:00
|
|
|
* Squid cache purging.
|
|
|
|
|
*
|
|
|
|
|
* This program is free software; you can redistribute it and/or modify
|
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
|
* the Free Software Foundation; either version 2 of the License, or
|
|
|
|
|
* (at your option) any later version.
|
|
|
|
|
*
|
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
|
*
|
|
|
|
|
* You should have received a copy of the GNU General Public License along
|
|
|
|
|
* with this program; if not, write to the Free Software Foundation, Inc.,
|
|
|
|
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
|
|
|
|
* http://www.gnu.org/copyleft/gpl.html
|
|
|
|
|
*
|
WARNING: HUGE COMMIT
Doxygen documentation update:
* Changed alls @addtogroup to @ingroup. @addtogroup adds the comment to the group description, but doesn't add the file, class, function, ... to the group like @ingroup does. See for example http://svn.wikimedia.org/doc/group__SpecialPage.html where it's impossible to see related files, classes, ... that should belong to that group.
* Added @file to file description, it seems that it should be explicitely decalred for file descriptions, otherwise doxygen will think that the comment document the first class, variabled, function, ... that is in that file.
* Removed some empty comments
* Removed some ?>
Added following groups:
* ExternalStorage
* JobQueue
* MaintenanceLanguage
One more thing: there are still a lot of warnings when generating the doc.
2008-05-20 17:13:28 +00:00
|
|
|
* @file
|
|
|
|
|
* @ingroup Cache
|
2004-09-02 23:28:24 +00:00
|
|
|
*/
|
2004-01-30 16:06:22 +00:00
|
|
|
|
2004-09-02 23:28:24 +00:00
|
|
|
/**
|
2008-10-06 15:31:03 +00:00
|
|
|
* Handles purging appropriate Squid URLs given a title (or titles)
|
WARNING: HUGE COMMIT
Doxygen documentation update:
* Changed alls @addtogroup to @ingroup. @addtogroup adds the comment to the group description, but doesn't add the file, class, function, ... to the group like @ingroup does. See for example http://svn.wikimedia.org/doc/group__SpecialPage.html where it's impossible to see related files, classes, ... that should belong to that group.
* Added @file to file description, it seems that it should be explicitely decalred for file descriptions, otherwise doxygen will think that the comment document the first class, variabled, function, ... that is in that file.
* Removed some empty comments
* Removed some ?>
Added following groups:
* ExternalStorage
* JobQueue
* MaintenanceLanguage
One more thing: there are still a lot of warnings when generating the doc.
2008-05-20 17:13:28 +00:00
|
|
|
* @ingroup Cache
|
2004-09-02 23:28:24 +00:00
|
|
|
*/
|
2004-01-30 16:06:22 +00:00
|
|
|
class SquidUpdate {
|
2012-07-04 15:31:01 +00:00
|
|
|
/**
|
2013-10-11 22:41:59 +00:00
|
|
|
* Collection of URLs to purge.
|
|
|
|
|
* @var array
|
2012-07-04 15:31:01 +00:00
|
|
|
*/
|
2013-10-11 22:41:59 +00:00
|
|
|
protected $urlArr;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @param array $urlArr Collection of URLs to purge
|
|
|
|
|
* @param bool|int $maxTitles Maximum number of unique URLs to purge
|
|
|
|
|
*/
|
|
|
|
|
public function __construct( $urlArr = array(), $maxTitles = false ) {
|
2004-06-30 03:39:48 +00:00
|
|
|
global $wgMaxSquidPurgeTitles;
|
|
|
|
|
if ( $maxTitles === false ) {
|
2013-10-11 22:41:59 +00:00
|
|
|
$maxTitles = $wgMaxSquidPurgeTitles;
|
2004-06-30 03:39:48 +00:00
|
|
|
}
|
2013-10-11 22:41:59 +00:00
|
|
|
|
|
|
|
|
// Remove duplicate URLs from list
|
|
|
|
|
$urlArr = array_unique( $urlArr );
|
|
|
|
|
if ( count( $urlArr ) > $maxTitles ) {
|
|
|
|
|
// Truncate to desired maximum URL count
|
|
|
|
|
$urlArr = array_slice( $urlArr, 0, $maxTitles );
|
2004-06-30 03:39:48 +00:00
|
|
|
}
|
2004-03-08 09:43:36 +00:00
|
|
|
$this->urlArr = $urlArr;
|
|
|
|
|
}
|
2004-01-30 16:06:22 +00:00
|
|
|
|
2011-04-25 22:41:54 +00:00
|
|
|
/**
|
2013-10-11 22:41:59 +00:00
|
|
|
* Create a SquidUpdate from the given Title object.
|
|
|
|
|
*
|
|
|
|
|
* The resulting SquidUpdate will purge the given Title's URLs as well as
|
|
|
|
|
* the pages that link to it. Capped at $wgMaxSquidPurgeTitles total URLs.
|
2011-07-12 19:59:35 +00:00
|
|
|
*
|
2013-10-11 22:41:59 +00:00
|
|
|
* @param Title $title
|
2011-04-25 22:41:54 +00:00
|
|
|
* @return SquidUpdate
|
|
|
|
|
*/
|
2013-10-11 22:41:59 +00:00
|
|
|
public static function newFromLinksTo( Title $title ) {
|
2010-07-26 20:51:33 +00:00
|
|
|
global $wgMaxSquidPurgeTitles;
|
2009-11-03 17:49:49 +00:00
|
|
|
wfProfileIn( __METHOD__ );
|
2004-07-18 08:48:43 +00:00
|
|
|
|
2004-03-20 15:03:26 +00:00
|
|
|
# Get a list of URLs linking to this page
|
2007-01-22 23:50:42 +00:00
|
|
|
$dbr = wfGetDB( DB_SLAVE );
|
2005-05-26 10:23:36 +00:00
|
|
|
$res = $dbr->select( array( 'links', 'page' ),
|
|
|
|
|
array( 'page_namespace', 'page_title' ),
|
|
|
|
|
array(
|
|
|
|
|
'pl_namespace' => $title->getNamespace(),
|
2013-03-07 16:50:43 +00:00
|
|
|
'pl_title' => $title->getDBkey(),
|
2005-05-26 10:23:36 +00:00
|
|
|
'pl_from=page_id' ),
|
2009-11-03 17:49:49 +00:00
|
|
|
__METHOD__ );
|
2004-03-20 15:03:26 +00:00
|
|
|
$blurlArr = $title->getSquidURLs();
|
2013-01-06 10:52:40 +00:00
|
|
|
if ( $res->numRows() <= $wgMaxSquidPurgeTitles ) {
|
2010-10-13 23:11:40 +00:00
|
|
|
foreach ( $res as $BL ) {
|
2013-02-09 21:44:24 +00:00
|
|
|
$tobj = Title::makeTitle( $BL->page_namespace, $BL->page_title );
|
2004-06-30 03:39:48 +00:00
|
|
|
$blurlArr[] = $tobj->getInternalURL();
|
|
|
|
|
}
|
2004-03-20 15:03:26 +00:00
|
|
|
}
|
2004-07-18 08:48:43 +00:00
|
|
|
|
2009-11-03 17:49:49 +00:00
|
|
|
wfProfileOut( __METHOD__ );
|
2013-11-20 17:20:36 +00:00
|
|
|
|
2004-03-20 15:03:26 +00:00
|
|
|
return new SquidUpdate( $blurlArr );
|
|
|
|
|
}
|
|
|
|
|
|
2009-02-16 14:26:34 +00:00
|
|
|
/**
|
|
|
|
|
* Create a SquidUpdate from an array of Title objects, or a TitleArray object
|
2011-04-25 22:41:54 +00:00
|
|
|
*
|
2013-10-11 22:41:59 +00:00
|
|
|
* @param array $titles
|
|
|
|
|
* @param array $urlArr
|
2011-04-25 22:41:54 +00:00
|
|
|
* @return SquidUpdate
|
2009-02-16 14:26:34 +00:00
|
|
|
*/
|
2013-10-11 22:41:59 +00:00
|
|
|
public static function newFromTitles( $titles, $urlArr = array() ) {
|
2006-06-18 12:42:16 +00:00
|
|
|
global $wgMaxSquidPurgeTitles;
|
2009-02-16 14:26:34 +00:00
|
|
|
$i = 0;
|
2013-11-20 18:43:39 +00:00
|
|
|
/** @var Title $title */
|
2005-04-17 08:30:15 +00:00
|
|
|
foreach ( $titles as $title ) {
|
|
|
|
|
$urlArr[] = $title->getInternalURL();
|
2009-02-16 14:26:34 +00:00
|
|
|
if ( $i++ > $wgMaxSquidPurgeTitles ) {
|
|
|
|
|
break;
|
|
|
|
|
}
|
2005-04-17 08:30:15 +00:00
|
|
|
}
|
2013-11-20 17:20:36 +00:00
|
|
|
|
2005-04-17 08:30:15 +00:00
|
|
|
return new SquidUpdate( $urlArr );
|
|
|
|
|
}
|
|
|
|
|
|
2011-04-25 22:41:54 +00:00
|
|
|
/**
|
2013-10-11 22:41:59 +00:00
|
|
|
* @param Title $title
|
2011-04-25 22:41:54 +00:00
|
|
|
* @return SquidUpdate
|
|
|
|
|
*/
|
2013-10-11 22:41:59 +00:00
|
|
|
public static function newSimplePurge( Title $title ) {
|
2004-03-20 15:03:26 +00:00
|
|
|
$urlArr = $title->getSquidURLs();
|
2013-11-20 17:20:36 +00:00
|
|
|
|
2005-11-07 04:10:02 +00:00
|
|
|
return new SquidUpdate( $urlArr );
|
2004-03-20 15:03:26 +00:00
|
|
|
}
|
2004-01-30 16:06:22 +00:00
|
|
|
|
2011-07-12 19:59:35 +00:00
|
|
|
/**
|
2013-10-11 22:41:59 +00:00
|
|
|
* Purges the list of URLs passed to the constructor.
|
2011-07-12 19:59:35 +00:00
|
|
|
*/
|
2013-10-11 22:41:59 +00:00
|
|
|
public function doUpdate() {
|
|
|
|
|
self::purge( $this->urlArr );
|
2004-03-20 15:03:26 +00:00
|
|
|
}
|
|
|
|
|
|
2011-04-25 22:41:54 +00:00
|
|
|
/**
|
|
|
|
|
* Purges a list of Squids defined in $wgSquidServers.
|
|
|
|
|
* $urlArr should contain the full URLs to purge as values
|
|
|
|
|
* (example: $urlArr[] = 'http://my.host/something')
|
|
|
|
|
* XXX report broken Squids per mail or log
|
|
|
|
|
*
|
2013-10-11 22:41:59 +00:00
|
|
|
* @param array $urlArr List of full URLs to purge
|
2011-04-25 22:41:54 +00:00
|
|
|
*/
|
2013-10-11 22:41:59 +00:00
|
|
|
public static function purge( $urlArr ) {
|
2013-07-02 10:50:48 +00:00
|
|
|
global $wgSquidServers, $wgHTCPRouting;
|
2004-03-20 15:03:26 +00:00
|
|
|
|
2013-04-20 17:18:13 +00:00
|
|
|
if ( !$urlArr ) {
|
2007-06-19 21:13:17 +00:00
|
|
|
return;
|
|
|
|
|
}
|
2004-03-20 15:03:26 +00:00
|
|
|
|
2014-02-04 21:16:13 +00:00
|
|
|
wfDebugLog( 'squid', __METHOD__ . ': ' . implode( ' ', $urlArr ) );
|
2012-10-17 00:00:07 +00:00
|
|
|
|
2013-07-02 10:50:48 +00:00
|
|
|
if ( $wgHTCPRouting ) {
|
2013-10-11 22:41:59 +00:00
|
|
|
self::HTCPPurge( $urlArr );
|
2007-06-19 21:13:17 +00:00
|
|
|
}
|
2005-04-06 17:14:43 +00:00
|
|
|
|
2009-11-03 17:49:49 +00:00
|
|
|
wfProfileIn( __METHOD__ );
|
2006-01-07 13:31:29 +00:00
|
|
|
|
2013-10-11 22:41:59 +00:00
|
|
|
// Remove duplicate URLs
|
|
|
|
|
$urlArr = array_unique( $urlArr );
|
|
|
|
|
// Maximum number of parallel connections per squid
|
|
|
|
|
$maxSocketsPerSquid = 8;
|
|
|
|
|
// Number of requests to send per socket
|
|
|
|
|
// 400 seems to be a good tradeoff, opening a socket takes a while
|
|
|
|
|
$urlsPerSocket = 400;
|
2010-02-05 03:36:04 +00:00
|
|
|
$socketsPerSquid = ceil( count( $urlArr ) / $urlsPerSocket );
|
|
|
|
|
if ( $socketsPerSquid > $maxSocketsPerSquid ) {
|
|
|
|
|
$socketsPerSquid = $maxSocketsPerSquid;
|
2004-03-20 15:03:26 +00:00
|
|
|
}
|
|
|
|
|
|
2010-02-05 03:36:04 +00:00
|
|
|
$pool = new SquidPurgeClientPool;
|
|
|
|
|
$chunks = array_chunk( $urlArr, ceil( count( $urlArr ) / $socketsPerSquid ) );
|
|
|
|
|
foreach ( $wgSquidServers as $server ) {
|
|
|
|
|
foreach ( $chunks as $chunk ) {
|
|
|
|
|
$client = new SquidPurgeClient( $server );
|
|
|
|
|
foreach ( $chunk as $url ) {
|
|
|
|
|
$client->queuePurge( $url );
|
2004-03-20 15:03:26 +00:00
|
|
|
}
|
2010-02-05 03:36:04 +00:00
|
|
|
$pool->addClient( $client );
|
2004-03-08 09:43:36 +00:00
|
|
|
}
|
|
|
|
|
}
|
2010-02-05 03:36:04 +00:00
|
|
|
$pool->run();
|
2004-01-30 16:06:22 +00:00
|
|
|
|
2009-11-03 17:49:49 +00:00
|
|
|
wfProfileOut( __METHOD__ );
|
2004-06-30 02:02:43 +00:00
|
|
|
}
|
|
|
|
|
|
2011-07-12 19:59:35 +00:00
|
|
|
/**
|
2013-10-11 22:41:59 +00:00
|
|
|
* Send Hyper Text Caching Protocol (HTCP) CLR requests.
|
|
|
|
|
*
|
2011-07-12 19:59:35 +00:00
|
|
|
* @throws MWException
|
2013-10-11 22:41:59 +00:00
|
|
|
* @param array $urlArr Collection of URLs to purge
|
2011-07-12 19:59:35 +00:00
|
|
|
*/
|
2013-10-11 22:41:59 +00:00
|
|
|
public static function HTCPPurge( $urlArr ) {
|
2013-07-02 10:50:48 +00:00
|
|
|
global $wgHTCPRouting, $wgHTCPMulticastTTL;
|
2009-11-03 17:49:49 +00:00
|
|
|
wfProfileIn( __METHOD__ );
|
2005-04-06 17:14:43 +00:00
|
|
|
|
2013-10-11 22:41:59 +00:00
|
|
|
// HTCP CLR operation
|
|
|
|
|
$htcpOpCLR = 4;
|
2005-04-06 17:14:43 +00:00
|
|
|
|
2011-05-17 22:03:20 +00:00
|
|
|
// @todo FIXME: PHP doesn't support these socket constants (include/linux/in.h)
|
2013-04-20 17:18:13 +00:00
|
|
|
if ( !defined( "IPPROTO_IP" ) ) {
|
2006-10-16 19:12:56 +00:00
|
|
|
define( "IPPROTO_IP", 0 );
|
|
|
|
|
define( "IP_MULTICAST_LOOP", 34 );
|
|
|
|
|
define( "IP_MULTICAST_TTL", 33 );
|
|
|
|
|
}
|
2005-04-06 17:14:43 +00:00
|
|
|
|
|
|
|
|
// pfsockopen doesn't work because we need set_sock_opt
|
2009-11-03 17:49:49 +00:00
|
|
|
$conn = socket_create( AF_INET, SOCK_DGRAM, SOL_UDP );
|
2013-11-20 17:20:36 +00:00
|
|
|
if ( !$conn ) {
|
2013-07-02 10:42:39 +00:00
|
|
|
$errstr = socket_strerror( socket_last_error() );
|
|
|
|
|
wfDebugLog( 'squid', __METHOD__ .
|
2014-02-04 21:16:13 +00:00
|
|
|
": Error opening UDP socket: $errstr" );
|
2013-07-02 10:42:39 +00:00
|
|
|
wfProfileOut( __METHOD__ );
|
2013-11-20 17:20:36 +00:00
|
|
|
|
2013-07-02 10:42:39 +00:00
|
|
|
return;
|
|
|
|
|
}
|
2005-04-06 17:14:43 +00:00
|
|
|
|
2013-07-02 10:42:39 +00:00
|
|
|
// Set socket options
|
|
|
|
|
socket_set_option( $conn, IPPROTO_IP, IP_MULTICAST_LOOP, 0 );
|
|
|
|
|
if ( $wgHTCPMulticastTTL != 1 ) {
|
2013-10-11 22:41:59 +00:00
|
|
|
// Set multicast time to live (hop count) option on socket
|
2013-07-02 10:42:39 +00:00
|
|
|
socket_set_option( $conn, IPPROTO_IP, IP_MULTICAST_TTL,
|
|
|
|
|
$wgHTCPMulticastTTL );
|
|
|
|
|
}
|
2008-04-14 07:45:50 +00:00
|
|
|
|
2013-10-11 22:41:59 +00:00
|
|
|
// Remove duplicate URLs from collection
|
|
|
|
|
$urlArr = array_unique( $urlArr );
|
2013-12-24 23:22:58 +00:00
|
|
|
// Get sequential trx IDs for packet loss counting
|
|
|
|
|
$ids = UIDGenerator::newSequentialPerNodeIDs(
|
|
|
|
|
'squidhtcppurge', 32, count( $urlArr ), UIDGenerator::QUICK_VOLATILE
|
|
|
|
|
);
|
|
|
|
|
|
2013-07-02 10:42:39 +00:00
|
|
|
foreach ( $urlArr as $url ) {
|
|
|
|
|
if ( !is_string( $url ) ) {
|
|
|
|
|
wfProfileOut( __METHOD__ );
|
|
|
|
|
throw new MWException( 'Bad purge URL' );
|
|
|
|
|
}
|
2013-10-11 22:41:59 +00:00
|
|
|
$url = self::expand( $url );
|
2013-07-02 10:50:48 +00:00
|
|
|
$conf = self::getRuleForURL( $url, $wgHTCPRouting );
|
2013-07-02 10:42:39 +00:00
|
|
|
if ( !$conf ) {
|
|
|
|
|
wfDebugLog( 'squid', __METHOD__ .
|
2014-02-04 21:16:13 +00:00
|
|
|
"No HTCP rule configured for URL {$url} , skipping" );
|
2013-07-02 10:42:39 +00:00
|
|
|
continue;
|
|
|
|
|
}
|
2013-07-02 10:50:48 +00:00
|
|
|
|
2013-08-24 15:06:25 +00:00
|
|
|
if ( isset( $conf['host'] ) && isset( $conf['port'] ) ) {
|
2013-07-02 10:50:48 +00:00
|
|
|
// Normalize single entries
|
|
|
|
|
$conf = array( $conf );
|
|
|
|
|
}
|
2013-08-24 15:06:25 +00:00
|
|
|
foreach ( $conf as $subconf ) {
|
2013-07-02 10:50:48 +00:00
|
|
|
if ( !isset( $subconf['host'] ) || !isset( $subconf['port'] ) ) {
|
|
|
|
|
wfProfileOut( __METHOD__ );
|
|
|
|
|
throw new MWException( "Invalid HTCP rule for URL $url\n" );
|
|
|
|
|
}
|
2013-07-02 10:42:39 +00:00
|
|
|
}
|
2005-04-06 17:14:43 +00:00
|
|
|
|
2013-07-02 10:42:39 +00:00
|
|
|
// Construct a minimal HTCP request diagram
|
|
|
|
|
// as per RFC 2756
|
|
|
|
|
// Opcode 'CLR', no response desired, no auth
|
2013-12-24 23:22:58 +00:00
|
|
|
$htcpTransID = current( $ids );
|
|
|
|
|
next( $ids );
|
2005-04-06 17:14:43 +00:00
|
|
|
|
2013-07-02 10:42:39 +00:00
|
|
|
$htcpSpecifier = pack( 'na4na*na8n',
|
|
|
|
|
4, 'HEAD', strlen( $url ), $url,
|
|
|
|
|
8, 'HTTP/1.0', 0 );
|
2005-04-06 17:14:43 +00:00
|
|
|
|
2013-07-02 10:42:39 +00:00
|
|
|
$htcpDataLen = 8 + 2 + strlen( $htcpSpecifier );
|
|
|
|
|
$htcpLen = 4 + $htcpDataLen + 2;
|
2005-04-06 17:14:43 +00:00
|
|
|
|
2013-07-02 10:42:39 +00:00
|
|
|
// 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 );
|
|
|
|
|
|
2013-07-01 13:16:43 +00:00
|
|
|
wfDebugLog( 'squid', __METHOD__ .
|
2014-02-04 21:16:13 +00:00
|
|
|
"Purging URL $url via HTCP" );
|
2013-08-24 15:06:25 +00:00
|
|
|
foreach ( $conf as $subconf ) {
|
2013-07-02 10:50:48 +00:00
|
|
|
socket_sendto( $conn, $htcpPacket, $htcpLen, 0,
|
|
|
|
|
$subconf['host'], $subconf['port'] );
|
|
|
|
|
}
|
2005-04-06 17:14:43 +00:00
|
|
|
}
|
2009-11-03 17:49:49 +00:00
|
|
|
wfProfileOut( __METHOD__ );
|
2005-04-06 17:14:43 +00:00
|
|
|
}
|
|
|
|
|
|
2006-05-24 21:57:25 +00:00
|
|
|
/**
|
|
|
|
|
* Expand local URLs to fully-qualified URLs using the internal protocol
|
|
|
|
|
* and host defined in $wgInternalServer. Input that's already fully-
|
|
|
|
|
* qualified will be passed through unchanged.
|
|
|
|
|
*
|
|
|
|
|
* This is used to generate purge URLs that may be either local to the
|
|
|
|
|
* main wiki or include a non-native host, such as images hosted on a
|
|
|
|
|
* second internal server.
|
|
|
|
|
*
|
|
|
|
|
* Client functions should not need to call this.
|
|
|
|
|
*
|
2013-10-11 22:41:59 +00:00
|
|
|
* @param string $url
|
2006-05-24 21:57:25 +00:00
|
|
|
* @return string
|
|
|
|
|
*/
|
2013-10-11 22:41:59 +00:00
|
|
|
public static function expand( $url ) {
|
2011-09-07 14:15:03 +00:00
|
|
|
return wfExpandUrl( $url, PROTO_INTERNAL );
|
2006-05-24 21:57:25 +00:00
|
|
|
}
|
2012-10-10 18:13:40 +00:00
|
|
|
|
2012-04-06 20:27:10 +00:00
|
|
|
/**
|
|
|
|
|
* Find the HTCP routing rule to use for a given URL.
|
2013-03-11 17:15:01 +00:00
|
|
|
* @param string $url URL to match
|
2013-07-02 10:50:48 +00:00
|
|
|
* @param array $rules Array of rules, see $wgHTCPRouting for format and behavior
|
2012-04-06 20:27:10 +00:00
|
|
|
* @return mixed Element of $rules that matched, or false if nothing matched
|
|
|
|
|
*/
|
2013-10-11 22:41:59 +00:00
|
|
|
private static function getRuleForURL( $url, $rules ) {
|
2012-04-06 20:27:10 +00:00
|
|
|
foreach ( $rules as $regex => $routing ) {
|
|
|
|
|
if ( $regex === '' || preg_match( $regex, $url ) ) {
|
|
|
|
|
return $routing;
|
|
|
|
|
}
|
|
|
|
|
}
|
2013-11-20 17:20:36 +00:00
|
|
|
|
2012-04-06 20:27:10 +00:00
|
|
|
return false;
|
|
|
|
|
}
|
2004-01-30 16:06:22 +00:00
|
|
|
}
|