本文整理汇总了PHP中fnmatch函数的典型用法代码示例。如果您正苦于以下问题:PHP fnmatch函数的具体用法?PHP fnmatch怎么用?PHP fnmatch使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了fnmatch函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。
示例1: testFnmatchExtended
/**
* test fnmatch
*/
public function testFnmatchExtended()
{
// Valid
$this->assertTrue(fnmatch('/foo/bar/zoo', '/foo/bar/zoo'));
$this->assertTrue(fnmatch('/foo/?ar/zoo', '/foo/bar/zoo'));
$this->assertTrue(fnmatch('/foo/*/zoo', '/foo/bar/zoo'));
$this->assertTrue(fnmatch('/foo/b*/zoo', '/foo/bar/zoo'));
$this->assertTrue(fnmatch('/foo/bar*/zoo', '/foo/bar/zoo'));
$this->assertTrue(fnmatch('/foo/bar/#', '/foo/bar/22'));
$this->assertTrue(fnmatch('/foo/bar/?#', '/foo/bar/a22'));
$this->assertTrue(fnmatch('/foo/**', '/foo/bar/zoo'));
$this->assertTrue(fnmatch('/foo/**', '/foo/'));
$this->assertTrue(fnmatch('/foo/**', '/foo'));
$this->assertTrue(fnmatch('/foo/{bar,baz}/zoo', '/foo/bar/zoo'));
$this->assertTrue(fnmatch('/foo/{12,89}/zoo', '/foo/12/zoo'));
$this->assertTrue(fnmatch('/foo/[bc]ar/zoo', '/foo/bar/zoo'));
$this->assertTrue(fnmatch('/foo/[a-c]ar/zoo', '/foo/bar/zoo'));
// Invalid
$this->assertFalse(fnmatch('/foo/qux/zoo', '/foo/bar/zoo'));
$this->assertFalse(fnmatch('/foo/?a/zoo', '/foo/bar/zoo'));
$this->assertFalse(fnmatch('/foo/*/zoo', '/foo/zoo'));
$this->assertFalse(fnmatch('/foo/bar/#', '/foo/bar/n00'));
$this->assertFalse(fnmatch('/foo/bar/?#', '/foo/bar/2'));
$this->assertFalse(fnmatch('/foo/**', '/foobar/zoo'));
$this->assertFalse(fnmatch('/foo/{bar,baz}/zoo', '/foo/{bar,baz}/zoo'));
$this->assertFalse(fnmatch('/foo/{12,89}/zoo', '/foo/1289/zoo'));
$this->assertFalse(fnmatch('/foo/[bc]ar/zoo', '/foo/dar/zoo'));
$this->assertFalse(fnmatch('/foo/[d-q]ar/zoo', '/foo/bar/zoo'));
}
开发者ID:sachsy,项目名称:php-functions,代码行数:32,代码来源:FileFunctionsTest.php
示例2: run
public function run()
{
if (fnmatch('*cli*', php_sapi_name())) {
$dir = Config::get('dir.schedules', APPLICATION_PATH . DS . 'schedules');
if (is_dir($dir)) {
Timer::start();
Cli::show("Start of execution", 'COMMENT');
$files = glob($dir . DS . '*.php');
foreach ($files as $file) {
require_once $file;
$object = str_replace('.php', '', Arrays::last(explode(DS, $file)));
$class = 'Thin\\' . ucfirst(Inflector::camelize($object . '_schedule'));
$instance = lib('app')->make($class);
$methods = get_class_methods($instance);
Cli::show("Start schedule '{$object}'", 'COMMENT');
foreach ($methods as $method) {
$when = $this->getWhen($instance, $method);
$isDue = $this->isDue($object, $method, $when);
if (true === $isDue) {
Cli::show("Execution of {$object}->{$method}", 'INFO');
$instance->{$method}();
} else {
Cli::show("No need to execute {$object}->{$method}", 'QUESTION');
}
}
}
Cli::show("Time of execution [" . Timer::get() . " s.]", 'SUCCESS');
Cli::show("end of execution", 'COMMENT');
}
}
}
开发者ID:schpill,项目名称:standalone,代码行数:31,代码来源:schedule.php
示例3: processFiles
protected function processFiles($path)
{
$files = glob($path . "/{,.}*", GLOB_BRACE);
foreach ($files as $file) {
$is_ok = true;
if (preg_match('#/\\.\\.?$#', $file)) {
$is_ok = false;
} else {
$short = preg_replace("#^{$this->root}/#", '', $file);
}
if ($is_ok) {
foreach ($this->excludes as $exclude) {
if (fnmatch("{$this->root}/{$exclude}", $file)) {
$this->log("Ignore " . (is_dir($file) ? 'dir ' : 'file') . " {$short} \t\t[{$exclude}]");
$is_ok = false;
break;
}
}
}
// for files that need to avoid exclude patterns -- only one so far
if (!$is_ok) {
if (preg_match('#/.htaccess$#', $file)) {
$this->log("Butnot " . (is_dir($file) ? 'dir ' : 'file') . " {$short}");
$is_ok = true;
}
}
if ($is_ok) {
if (++$this->count % $this->reopen_interval == $this->reopen_interval - 1) {
$this->reopen();
// to stop annoying file handle exhaustion bug
}
$is_dist = preg_match('#\\.dist$#', $file) == 1;
if ($is_dist) {
$short = preg_replace('#\\.dist$#', '', $short);
}
if (is_dir($file)) {
$this->log("Adding dir {$short}");
// double space makes it line up
if ($is_dist) {
throw new sfException("Cannot use .dist suffixed directories yet");
}
$this->zip->addEmptyDir($short);
$this->processFiles($file);
} else {
$this->log("Adding file {$short}" . ($is_dist ? " from {$short}.dist" : ''));
$entry_exists = $this->zip->locateName($short) !== FALSE;
if ($entry_exists) {
if ($is_dist) {
$this->log("{$short} already exists -- replaced with {$short}.dist.", true);
} else {
throw new sfException("{$short} already exists in archive!");
}
}
if ($this->zip->addFile($file, $short) == FALSE) {
throw new sfException("Couldn't add -- probably too many open files");
}
}
}
}
}
开发者ID:WIZARDISHUNGRY,项目名称:sflimetracker,代码行数:60,代码来源:limetrackerZipTask.class.php
示例4: w3_rmdir
/**
* Recursive remove dir
*
* @param string $path
* @param array $exclude
* @param bool $remove
* @return void
*/
function w3_rmdir($path, $exclude = array(), $remove = true)
{
$dir = @opendir($path);
if ($dir) {
while (($entry = @readdir($dir)) !== false) {
if ($entry == '.' || $entry == '..') {
continue;
}
foreach ($exclude as $mask) {
if (fnmatch($mask, basename($entry))) {
continue 2;
}
}
$full_path = $path . DIRECTORY_SEPARATOR . $entry;
if (@is_dir($full_path)) {
w3_rmdir($full_path, $exclude);
} else {
@unlink($full_path);
}
}
@closedir($dir);
if ($remove) {
@rmdir($path);
}
}
}
开发者ID:novichkovv,项目名称:candoweightloss,代码行数:34,代码来源:file.php
示例5: ls
public function ls()
{
$pattern = null;
$dir = null;
$args = func_get_args();
$lst = array();
switch (count($args)) {
case 0:
$dir = getcwd();
case 1:
$dir = $this->app->path($args[0]);
break;
case 2:
$pattern = $args[0];
$dir = $this->app->path($args[1]);
break;
default:
return $lst;
}
if (!$dir || !file_exists($dir)) {
return $lst;
}
foreach (new \DirectoryIterator($dir) as $file) {
if ($file->isDot()) {
continue;
}
if ($pattern && !fnmatch($pattern, $file->getBasename())) {
continue;
}
$lst[] = new \SplFileObject($file->getRealPath());
}
return $lst;
}
开发者ID:amdad,项目名称:BirdsLab,代码行数:33,代码来源:Filesystem.php
示例6: myglob
function myglob($glob, $recursive = false)
{
$pattern = basename($glob);
$path = dirname($glob);
if ($path == DIRECTORY_SEPARATOR) {
return array(".");
}
if (!is_readable($path)) {
return array();
}
$handle = opendir($path);
if ($handle === false) {
return array();
}
$list = array();
while (false !== ($file = readdir($handle))) {
if ($file == ".") {
continue;
}
if ($file == "..") {
continue;
}
if (is_file(dirname($glob) . DIRECTORY_SEPARATOR . $file) && fnmatch($pattern, $file)) {
$list[] = $path . DIRECTORY_SEPARATOR . $file;
}
if (is_dir(dirname($glob) . DIRECTORY_SEPARATOR . $file) && $recursive) {
$res = myglob(dirname($glob) . DIRECTORY_SEPARATOR . $file . DIRECTORY_SEPARATOR . basename($glob), $recursive);
$list = array_merge($list, $res);
}
}
closedir($handle);
natsort($list);
return $list;
}
开发者ID:jehon,项目名称:database_patch,代码行数:34,代码来源:database.php
示例7: formatErrors
public function formatErrors(Validator $validator)
{
$repeatedAttendee = false;
$emptyNames = false;
$errors = $validator->errors()->all();
foreach ($errors as $index => $error) {
if (fnmatch('The selected user id.* is invalid.', $error)) {
// Removes from array; can still iterate through array with foreach
unset($errors[$index]);
$repeatedAttendee = true;
} else {
if (fnmatch('The name.* field is required.', $error)) {
unset($errors[$index]);
$emptyNames = true;
}
}
}
// Pushes more descriptive error message onto array
if ($repeatedAttendee) {
array_push($errors, 'The same attendee has been entered in the attendance list more than once.');
}
if ($emptyNames) {
array_push($errors, 'One of the names of the listed attendees has not been provided.');
}
return $errors;
}
开发者ID:natalieduong,项目名称:konnection,代码行数:26,代码来源:CreateActivityRequest.php
示例8: handleRequest
/**
* Handles request in order to authenticate.
*
* @param \AppserverIo\Psr\Servlet\Http\HttpServletRequestInterface $servletRequest The request instance
* @param \AppserverIo\Psr\Servlet\Http\HttpServletResponseInterface $servletResponse The response instance
*
* @return boolean TRUE if the authentication has been successful, else FALSE
*
* @throws \Exception
*/
public function handleRequest(HttpServletRequestInterface $servletRequest, HttpServletResponseInterface $servletResponse)
{
// iterate over all servlets and return the matching one
/**
* @var string $urlPattern
* @var \AppserverIo\Http\Authentication\AuthenticationInterface $authenticationAdapter
*/
foreach ($this->authenticationAdapters as $urlPattern => $authenticationAdapter) {
// we'll match our URI against the URL pattern
if (fnmatch($urlPattern, $servletRequest->getServletPath() . $servletRequest->getPathInfo())) {
// the URI pattern matches, init the adapter and try to authenticate
// check if auth header is not set in coming request headers
if (!$servletRequest->hasHeader(Protocol::HEADER_AUTHORIZATION)) {
// send header for challenge authentication against client
$servletResponse->addHeader(HttpProtocol::HEADER_WWW_AUTHENTICATE, $authenticationAdapter->getAuthenticateHeader());
}
// initialize the adapter with the current request
$authenticationAdapter->init($servletRequest->getHeader(HttpProtocol::HEADER_AUTHORIZATION), $servletRequest->getMethod());
// try to authenticate the request
$authenticated = $authenticationAdapter->authenticate();
if (!$authenticated) {
// send header for challenge authentication against client
$servletResponse->addHeader(HttpProtocol::HEADER_WWW_AUTHENTICATE, $authenticationAdapter->getAuthenticateHeader());
}
return $authenticated;
}
}
// we did not find an adapter for that URI pattern, no authentication required then
return true;
}
开发者ID:jinchunguang,项目名称:appserver,代码行数:40,代码来源:StandardAuthenticationManager.php
示例9: onRoute
public function onRoute(MvcEvent $e)
{
$serviceManager = $e->getApplication()->getServiceManager();
$routeMatchName = $e->getRouteMatch()->getMatchedRouteName();
if (strpos($routeMatchName, '.rest.') !== false || strpos($routeMatchName, '.rpc.') !== false) {
return;
}
$config = $serviceManager->get('Config');
$identityGuards = $config['zource_guard']['identity'];
$needsIdentity = null;
foreach ($identityGuards as $guard => $needed) {
if (fnmatch($guard, $routeMatchName)) {
$needsIdentity = $needed;
break;
}
}
if ($needsIdentity === null) {
throw new RuntimeException(sprintf('The identity guard "%s" has not been configured.', $routeMatchName));
}
if (!$needsIdentity) {
return;
}
$authenticationService = $serviceManager->get('Zend\\Authentication\\AuthenticationService');
if ($authenticationService->hasIdentity()) {
return;
}
$returnUrl = $e->getRouter()->assemble([], ['name' => $routeMatchName, 'force_canonical' => true, 'query' => $e->getRequest()->getUri()->getQuery()]);
$url = $e->getRouter()->assemble([], ['name' => 'login', 'query' => ['redir' => $returnUrl]]);
$response = new Response();
$response->setStatusCode(Response::STATUS_CODE_302);
$response->getHeaders()->addHeaderLine('Location: ' . $url);
return $response;
}
开发者ID:zource,项目名称:zource,代码行数:33,代码来源:IdentityGuard.php
示例10: passes
public static function passes(\Modules\Models\Modules $module, $route = null, $options = array())
{
// if this ruleset is ignored, return null
if (!in_array($module->{'assignment.routes.method'}, array('include', 'exclude'))) {
return null;
}
if (is_null($route) || $route == '*') {
return true;
}
$match = false;
// get the list of urls to match $route against
// if any of them match, return true
$patterns = (array) $module->{'assignment.routes.list'};
if (empty($patterns)) {
$match = true;
}
foreach ($patterns as $pattern) {
if (fnmatch($pattern, $route)) {
$match = true;
}
}
switch ($module->{'assignment.routes.method'}) {
case "exclude":
$passes = $match ? false : true;
break;
default:
$passes = $match;
break;
}
return $passes;
}
开发者ID:dioscouri,项目名称:f3-modules,代码行数:31,代码来源:Routes.php
示例11: safe_glob
/**
* A safe empowered glob().
*
* Function glob() is prohibited on some server (probably in safe mode)
* (Message "Warning: glob() has been disabled for security reasons in
* (script) on line (line)") for security reasons as stated on:
* http://seclists.org/fulldisclosure/2005/Sep/0001.html
*
* safe_glob() intends to replace glob() using readdir() & fnmatch() instead.
* Supported flags: GLOB_MARK, GLOB_NOSORT, GLOB_ONLYDIR
* Additional flags: GLOB_NODIR, GLOB_PATH, GLOB_NODOTS, GLOB_RECURSE
* (not original glob() flags)
*
* @author BigueNique AT yahoo DOT ca
* @updates
* - 080324 Added support for additional flags: GLOB_NODIR, GLOB_PATH,
* GLOB_NODOTS, GLOB_RECURSE
*/
function safe_glob($pattern, $flags = 0)
{
$split = explode('/', str_replace('\\', '/', $pattern));
$mask = array_pop($split);
$path = implode('/', $split);
if (($dir = @opendir($path)) !== false) {
$glob = array();
while (($file = readdir($dir)) !== false) {
// Recurse subdirectories (GLOB_RECURSE); speedup: no need to sort the intermediate results
if ($flags & GLOB_RECURSE && is_dir($file) && !in_array($file, array('.', '..'))) {
$glob = array_merge($glob, array_prepend(safe_glob($path . '/' . $file . '/' . $mask, $flags | GLOB_NOSORT), $flags & GLOB_PATH ? '' : $file . '/'));
}
// Match file mask
if (fnmatch($mask, $file)) {
if ((!($flags & GLOB_ONLYDIR) || is_dir($path . '/' . $file)) && (!($flags & GLOB_NODIR) || !is_dir($path . '/' . $file)) && (!($flags & GLOB_NODOTS) || !in_array($file, array('.', '..')))) {
$glob[] = ($flags & GLOB_PATH ? $path . '/' : '') . $file . ($flags & GLOB_MARK && is_dir($path . '/' . $file) ? '/' : '');
}
}
}
closedir($dir);
if (!($flags & GLOB_NOSORT)) {
sort($glob);
}
return $glob;
} else {
return false;
}
}
开发者ID:GerHobbelt,项目名称:CompactCMS,代码行数:46,代码来源:Tooling.php
示例12: uniquify
public static function uniquify($filePath)
{
//$filePath = '/www/sites/vladsch/database/migrations/2015_10_17_030224_*_create_license_agent_versions_table.php';
$base_path = dirname($filePath);
$filename = substr($filePath, strlen($base_path) + 1);
$pos = strpos($filename, '*');
$name = substr($filename, 0, $pos + 1);
assert($pos !== false, "pattern '*' must exist in {$filePath}");
$maxMatch = 0;
if ($handle = opendir($base_path)) {
while (false !== ($entry = readdir($handle))) {
if (fnmatch($name, $entry, FNM_PERIOD)) {
// this one matches, lets extract the stuff matched by *
if (preg_match('/(\\d+)/', substr($entry, $pos + 1), $matches)) {
$found = $matches[1];
//print("Found $entry : value $found\n");
if ($maxMatch < $found) {
$maxMatch = intval($found);
}
}
}
}
closedir($handle);
}
$maxMatch = sprintf("%02d", $maxMatch + 1);
return str_replace('*', $maxMatch, $filePath);
}
开发者ID:vsch,项目名称:generators,代码行数:27,代码来源:GeneratorsServiceProvider.php
示例13: __construct
public function __construct($configFiles, $env = '@')
{
$this->config = new \stdClass();
if (!is_array($configFiles)) {
$configFiles = [$configFiles];
}
foreach ($configFiles as $configFile) {
if (!file_exists($configFile)) {
throw new ConfigException('Configuration file not found: ' . $configFile);
}
$config = parse_ini_file($configFile, true);
if (!$config || !is_array($config['@'])) {
throw new ConfigException('Configuration file failed to parse: ' . $configFile);
}
$this->addValues($config['@']);
if (isset($config[$env])) {
$config = [$env => $config[$env]];
}
foreach ($config as $key => $value) {
if (fnmatch($key, $env)) {
$this->addValues($value);
}
}
}
$this->config = $this->recursiveArrayToObject($this->config);
}
开发者ID:etu,项目名称:php-tools,代码行数:26,代码来源:IniConfig.php
示例14: loadClient
/**
* Load a client configuration as a service in the container. A client can use multiple servers
*
* @param ContainerInterface $container The container
* @param string $alias Alias of the client
* @param array $config Base config of the client
* @param array $servers List of available servers as describe in the config file
* @param boolean $baseEvents Register base events
*
* @throws InvalidConfigurationException
* @return string the service name
*/
protected function loadClient($container, $alias, array $config, array $servers, $baseEvents)
{
$usedServers = [];
$events = $config['events'];
$matchedServers = [];
if ($config['servers'][0] == 'all') {
// Use all servers
$matchedServers = array_keys($servers);
} else {
// Use only declared servers
foreach ($config['servers'] as $serverAlias) {
// Named server
if (array_key_exists($serverAlias, $servers)) {
$matchedServers[] = $serverAlias;
continue;
}
// Search matchning server config name
$found = false;
foreach (array_keys($servers) as $key) {
if (fnmatch($serverAlias, $key)) {
$matchedServers[] = $key;
$found = true;
}
}
// No server found
if (!$found) {
throw new InvalidConfigurationException(sprintf('M6WebStatsd client %s used server %s which is not defined in the servers section', $alias, $serverAlias));
}
}
}
// Matched server congurations
foreach ($matchedServers as $serverAlias) {
$usedServers[] = ['address' => $servers[$serverAlias]['address'], 'port' => $servers[$serverAlias]['port']];
}
// Add the statsd client configured
$serviceId = $alias == 'default' ? 'm6_statsd' : 'm6_statsd.' . $alias;
$definition = new Definition('M6Web\\Bundle\\StatsdBundle\\Client\\Client');
$definition->setScope(ContainerInterface::SCOPE_CONTAINER);
$definition->addArgument($usedServers);
if (isset($config['to_send_limit'])) {
$definition->addMethodCall('setToSendLimit', array($config['to_send_limit']));
}
foreach ($events as $eventName => $eventConfig) {
$definition->addTag('kernel.event_listener', ['event' => $eventName, 'method' => 'handleEvent']);
$definition->addMethodCall('addEventToListen', [$eventName, $eventConfig]);
}
$container->setDefinition($serviceId, $definition);
// Add the statsd client listener
$serviceListenerId = $serviceId . '.listener';
$definition = new Definition('M6Web\\Bundle\\StatsdBundle\\Statsd\\Listener');
$definition->addArgument(new Reference($serviceId));
$definition->addArgument(new Reference('event_dispatcher'));
$definition->addTag('kernel.event_listener', ['event' => 'kernel.terminate', 'method' => 'onKernelTerminate', 'priority' => -100]);
if ($baseEvents) {
$definition->addTag('kernel.event_listener', ['event' => 'kernel.terminate', 'method' => 'onKernelTerminateEvents', 'priority' => 0]);
$definition->addTag('kernel.event_listener', ['event' => 'kernel.exception', 'method' => 'onKernelException', 'priority' => 0]);
}
$container->setDefinition($serviceListenerId, $definition);
return $serviceId;
}
开发者ID:VoidAndAny,项目名称:StatsdBundle,代码行数:72,代码来源:M6WebStatsdExtension.php
示例15: _clean
function _clean($path, $remove = false)
{
$dir = @opendir($path);
if ($dir) {
while (($entry = @readdir($dir)) !== false) {
if ($entry == '.' || $entry == '..') {
continue;
}
if (substr($entry, -4) === '.old') {
continue;
}
foreach ($this->_exclude as $mask) {
if (fnmatch($mask, basename($entry))) {
continue 2;
}
}
$full_path = $path . DIRECTORY_SEPARATOR . $entry;
if (@is_dir($full_path)) {
$this->_clean($full_path);
} elseif (!$this->is_valid($full_path)) {
$old_entry_path = $full_path . '.old';
$this->processed_count++;
if (!@rename($full_path, $old_entry_path)) {
// if we can delete old entry - do second attempt to store in old-entry file
if (@unlink($old_entry_path)) {
@rename($full_path, $old_entry_path);
}
}
}
}
@closedir($dir);
}
}
开发者ID:marqui678,项目名称:finalchance.Panopta,代码行数:33,代码来源:Generic.php
示例16: write_hook
/**
* listen to write event.
*/
public static function write_hook($params)
{
if (\OCP\App::isEnabled('files_versions')) {
$path = $params[\OC\Files\Filesystem::signal_param_path];
$user = \OCP\User::getUser();
$excluded = false;
$excludes = \OCP\Config::getSystemValue('files_versions_excludes', NULL);
if (isset($excludes) && array_key_exists($user, $excludes)) {
$user_excludes = $excludes[$user];
foreach ($user_excludes as &$pat) {
if (fnmatch($pat, $path)) {
// TODO: Not certain if logging of the files names and patters is allowed.
\OCP\Util::writeLog('files_versions', "write_hook: user='" . $user . "', path='" . $path . "' matched to '" . $pat . "', excluding!", \OCP\Util::INFO);
$excluded = true;
break;
}
}
unset($pat);
}
if ($excluded) {
return;
}
if ($path != '') {
Storage::store($path);
}
}
}
开发者ID:mnefedov,项目名称:core,代码行数:30,代码来源:hooks.php
示例17: generate_table
private function generate_table($tbl)
{
$conf = $this->tblconf[$tbl];
$key = $conf['key'];
unset($conf['key']);
$indices = array();
if (isset($conf['index'])) {
$indices = explode(' ', $conf['index']);
unset($conf['index']);
}
$k = $this->get_key_field($tbl);
$sql = "CREATE TABLE `{$tbl}` ( `{$k}` " . $this->generate_type($key, true) . ', ';
foreach ($conf as $key => $type) {
if (fnmatch($key, 'field.*')) {
$key = substr($key, 6);
$sql .= "`{$key}` " . $this->generate_type($type, false) . ", ";
}
}
$sql = substr($sql, 0, -2);
$sql .= ' )';
$this->conn->query($sql);
foreach ($indices as $index) {
$sql = "CREATE UNIQUE INDEX `{$tbl}" . "_{$index}` ON `{$tbl}`(`{$index}`)";
$this->conn->query($sql);
}
}
开发者ID:prophile,项目名称:manila,代码行数:26,代码来源:mysql.php
示例18: buckets
/**
* @param \Kbrw\RiakBundle\Model\Cluster\Cluster $cluster
* @return array<string>
*/
public function buckets($cluster, $ignore = "_rsid_*")
{
$bucketNames = array();
$request = $this->getClient($cluster->getGuzzleClientProviderService(), $this->getConfig($cluster, "true"))->get();
$this->logger->debug("[GET] '" . $request->getUrl() . "'");
try {
$response = $request->send();
$extra = array("method" => "GET");
if ($response->getStatusCode() === 200) {
$ts = microtime(true);
$content = json_decode($response->getBody(true));
$extra["deserialization_time"] = microtime(true) - $ts;
if (isset($content)) {
foreach ($content->{"buckets"} as $bucketName) {
if (!fnmatch($ignore, $bucketName)) {
$bucketNames[] = $bucketName;
}
}
}
}
$this->logResponse($response, $extra);
} catch (CurlException $e) {
$this->logger->err("Riak is unavailable" . $e->getMessage());
throw new RiakUnavailableException();
} catch (\Exception $e) {
$this->logger->err("Error while getting buckets" . $e->getMessage());
}
return $bucketNames;
}
开发者ID:shopping-adventure,项目名称:RiakBundle,代码行数:33,代码来源:RiakClusterServiceClient.php
示例19: trigger
/**
* @param string $event
* @param array $params
* @param string $context
*/
public function trigger($event, $params = [], $context = '')
{
if (empty($this->events[$event])) {
return;
}
$queue = new \SplPriorityQueue();
foreach ($this->events[$event] as $index => $action) {
$queue->insert($index, $action['prio']);
}
$queue->top();
while ($queue->valid()) {
$index = $queue->current();
if (!empty($context)) {
$contexts = explode(',', $this->events[$event][$index]['contexts']);
$current_context = false;
foreach ($contexts as $route) {
if (fnmatch(trim($route), $context)) {
$current_context = true;
break;
}
}
} else {
$current_context = true;
}
if ($current_context && is_callable($this->events[$event][$index]['fn'])) {
if (call_user_func_array($this->events[$event][$index]['fn'], $params) === false) {
break;
}
}
$queue->next();
}
}
开发者ID:sydes,项目名称:sydes,代码行数:37,代码来源:Event.php
示例20: sendFile
public function sendFile($file)
{
$lastmod = filemtime($file);
if (isset($_SERVER['HTTP_IF_MODIFIED_SINCE'])) {
$ifmod = strtotime($_SERVER['HTTP_IF_MODIFIED_SINCE']);
if ($ifmod >= $lastmod) {
header('Not Modified', true, 304);
return;
}
}
$ct = null;
// Apply content type
foreach (['*.css' => 'text/css', '*.js' => 'text/javascript'] as $ptn => $ct) {
if (fnmatch($ptn, $file)) {
$ctype = $ct;
}
}
// If no match, try to determine
if (empty($ctype)) {
$ctype = mime_content_type($file);
}
// Set headers
header('Content-Type: ' . $ctype);
header('Content-Length: ' . filesize($file));
header('Last-Modified: ' . gmdate('D, d M Y H:i:s \\G\\M\\T', $lastmod));
$this->contentlength = filesize($file);
readfile($file);
return;
}
开发者ID:noccy80,项目名称:cherryphp,代码行数:29,代码来源:response.php
注:本文中的fnmatch函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论