public function format(Node $node, $em) { if ($value = $node->{$this->value}) { $result = html::em($em, array('host' => url::host($value)), html::cdata($value)); return $result; } }
/** * Проверяет, можно ли загрузить файл в S3. */ private static function canUploadToS3(FileNode $node) { if (empty($node->remoteurl)) { return true; } $host = url::host($node->remoteurl); if ('.s3.amazonaws.com' == substr($host, -17)) { return false; } return true; }
/** * Добавление скриптов к странице. * @mcms_message ru.molinos.cms.page.head */ public static function on_get_head(Context $ctx, array $pathinfo) { if ($query = $ctx->get('query') and $key = $ctx->config->get('modules/search/gas_key')) { $query = str_replace('"', "'", $query); $paths = array(os::path(MCMS_SITE_FOLDER, 'gas.js'), os::path('lib', 'modules', 'search', 'gas.js')); $output = ''; foreach ($paths as $path) { if (file_exists($path)) { $js = str_replace('QUERY', $query, file_get_contents($path)); $js = str_replace('HOSTNAME', url::host($_SERVER['HTTP_HOST']), $js); $output = '<script type="text/javascript" src="http://www.google.com/jsapi?key=' . $key . '"></script>' . '<script type="text/javascript">' . $js . '</script>'; return html::wrap('head', html::cdata($output), array('module' => 'search')); } } } }
public function set($value, &$node) { $result = array(); foreach (preg_split('/[\\r\\n]+/', $value) as $line) { if (count($parts = preg_split('/\\s+/', $line, 2, PREG_SPLIT_NO_EMPTY))) { $link = array(); if ($tmp = array_shift($parts)) { $link['href'] = $tmp; } if ($tmp = array_shift($parts)) { $link['name'] = $tmp; } if (!empty($link['href'])) { $link['host'] = url::host($link['href']); } try { $head = http::head($link['href']); if (200 == ($link['status'] = $head['_status'])) { if (!empty($head['Content-Type'])) { $link['type'] = $head['Content-Type']; } if (!empty($head['Content-Length'])) { $link['size'] = intval($head['Content-Length']); $link['sizefm'] = mcms::filesize($link['size']); } } } catch (Exception $e) { } $result[] = $link; } } if (empty($result)) { unset($node->{$this->value}); } else { $node->{$this->value} = $result; } }
<?php c::set('routes', array(array('pattern' => 'autologin', 'action' => function () { $username = '******'; $password = '******'; // Prevent access on the production system if (url::host() !== 'localhost') { return false; } $user = site()->user($username); if ($user and $user->login($password)) { go('panel'); // or use go(); to redirect to the frontpage } else { echo 'invalid username or password'; return false; } })));
<?php $kirby = kirby(); // Prevent panel breakage switch (url::host()) { case 'evanosky.local': $kirby->urls->index = 'http://evanosky.local'; default: $kirby->urls->index = 'http://' . url::host(); } // avatars folder $kirby->roots->avatars = $kirby->roots()->index() . DS . 'public' . DS . 'avatars'; $kirby->urls->avatars = $kirby->urls()->index() . '/public/avatars'; // thumbs folder $kirby->roots->thumbs = $kirby->roots()->index() . DS . 'public' . DS . 'thumbs'; $kirby->urls->thumbs = $kirby->urls()->index() . '/public/thumbs';
public static function domain() { $domain = url::protocol() . '://' . url::host(); return $domain; }
/** * Iterate through every route to find a matching route. * * @param string $path Optional path to match against * @param string $host Optional host to match against * @return Route */ public function run($path = null, $host = null) { $method = r::method(); $ajax = r::ajax(); $https = r::ssl(); $routes = a::get($this->routes, $method, array()); // detect path and host if not set manually if ($path === null) { $path = implode('/', (array) url::fragments(detect::path())); } if ($host === null) { $host = url::host(); } // empty urls should never happen if (empty($path)) { $path = '/'; } foreach ($routes as $route) { if ($route->host && $route->host !== $host) { continue; } if ($route->https && !$https) { continue; } if ($route->ajax && !$ajax) { continue; } // handle exact matches if ($route->pattern == $path) { $this->route = $route; break; } // We only need to check routes with regular expression since all others // would have been able to be matched by the search for literal matches // we just did before we started searching. if (strpos($route->pattern, '(') === false) { continue; } $preg = '#^' . $this->wildcards($route->pattern) . '$#u'; // If we get a match we'll return the route and slice off the first // parameter match, as preg_match sets the first array item to the // full-text match of the pattern. if (preg_match($preg, $path, $parameters)) { $this->route = $route; $this->route->arguments = array_slice($parameters, 1); break; } } if ($this->route && $this->filterer($this->route->filter, $this->route) !== false) { return $this->route; } else { return null; } }