6 public static function rewriteUrl($url)
8 if (!isset($GLOBALS['phinde']['urlRewrites'])
9 || count($GLOBALS['phinde']['urlRewrites']) == 0
14 foreach ($GLOBALS['phinde']['urlRewrites'] as $pattern => $replacement) {
15 $url = preg_replace('#' . $pattern . '#', $replacement, $url);
20 public static function isUrlAllowed($url)
22 $urlDomain = parse_url($url, PHP_URL_HOST);
23 if (!in_array($urlDomain, $GLOBALS['phinde']['domains'])) {
29 public static function noSchema($url)
32 array('http://', 'https://'),
38 public static function addSchema($url)
40 if (substr($url, 0, 7) == 'http://'
41 || substr($url, 0, 8) == 'https://'
45 return 'http://' . $url;
48 public static function removeAnchor($url)
50 $parts = explode('#', $url, 2);
54 public static function sanitizeTitle($str)
58 array("\r", "\n", ' ', ' '),
59 array('', ' ', ' ', ' '),
66 * Create a full URL with protocol and host name
68 * @param string $path Path to the file, with leading /
70 * @return string Full URL
72 public static function fullUrl($path = '/')
74 if (isset($_SERVER['HTTPS']) && $_SERVER['HTTPS']) {
79 return $prot . '://' . $_SERVER['HTTP_HOST'] . $path;
84 public static function start($timer = 'timer')
86 static::$timer[$timer] = microtime(true);
89 public static function stop($timer = 'timer')
91 $diff = microtime(true) - static::$timer[$timer];
92 echo '+timer: ' . number_format($diff, 3) . 'ms ' . $timer . "\n";
95 public static function baseDoc($url)
97 $esDoc = new \stdClass();
98 $esDoc->status = new \stdClass();
100 $esDoc->schemalessUrl = Helper::noSchema($url);