예제 #1
0
 public function __construct($url = null)
 {
     if (empty($url)) {
         $this->formatGetArguments();
         $this->url = basename($_SERVER['SCRIPT_NAME']);
     } else {
         $this->url = $url;
         // parse reference
         $tmp_pos = zbx_strpos($this->url, '#');
         if ($tmp_pos !== false) {
             $this->reference = zbx_substring($this->url, $tmp_pos + 1);
             $this->url = zbx_substring($this->url, 0, $tmp_pos);
         }
         $tmp_pos = zbx_strpos($url, '?');
         // parse query
         if ($tmp_pos !== false) {
             $this->query = zbx_substring($url, $tmp_pos + 1);
             $this->url = $url = zbx_substring($url, 0, $tmp_pos);
         }
         $this->formatArguments();
     }
     if (isset($_COOKIE['zbx_sessionid'])) {
         $this->setArgument('sid', substr($_COOKIE['zbx_sessionid'], 16, 16));
     }
 }
예제 #2
0
function make_decoration($haystack, $needle, $class = null)
{
    $result = $haystack;
    $pos = zbx_stripos($haystack, $needle);
    if ($pos !== false) {
        $start = zbx_substring($haystack, 0, $pos);
        $end = zbx_substring($haystack, $pos + zbx_strlen($needle));
        $found = zbx_substring($haystack, $pos, $pos + zbx_strlen($needle));
        if (is_null($class)) {
            $result = array($start, bold($found), $end);
        } else {
            $result = array($start, new CSpan($found, $class), $end);
        }
    }
    return $result;
}
예제 #3
0
function make_decoration($haystack, $needle, $class = null)
{
    $result = $haystack;
    $pos = stripos($haystack, $needle);
    if ($pos !== FALSE) {
        $start = zbx_substring($haystack, 0, $pos);
        //			$middle = substr($haystack, $pos, zbx_strlen($needle));
        $middle = $needle;
        $end = substr($haystack, $pos + zbx_strlen($needle));
        if (is_null($class)) {
            $result = array($start, bold($middle), $end);
        } else {
            $result = array($start, new CSpan($middle, $class), $end);
        }
    }
    return $result;
}
예제 #4
0
 public function __construct($url = null)
 {
     $this->url = null;
     $this->port = null;
     $this->host = null;
     $this->protocol = null;
     $this->username = null;
     $this->password = null;
     $this->file = null;
     $this->reference = null;
     $this->path = null;
     $this->query = null;
     $this->arguments = array();
     if (empty($url)) {
         $this->formatArguments();
         $this->url = $url = 'http://' . $_SERVER['SERVER_NAME'] . $_SERVER['SCRIPT_NAME'] . '?' . $this->getQuery();
     } else {
         $this->url = urldecode($url);
         $tmp_pos = strpos($this->url, '?');
         $this->query = $tmp_pos !== false ? substr($this->url, $tmp_pos + 1) : '';
         $tmp_pos = strpos($this->query, '#');
         if ($tmp_pos !== false) {
             $this->query = zbx_substring($this->query, 0, $tmp_pos);
         }
         $this->formatArguments($this->query);
     }
     $protocolSepIndex = strpos($this->url, '://');
     if ($protocolSepIndex !== false) {
         $this->protocol = strtolower(zbx_substring($this->url, 0, $protocolSepIndex));
         $this->host = substr($this->url, $protocolSepIndex + 3);
         $tmp_pos = strpos($this->host, '/');
         if ($tmp_pos !== false) {
             $this->host = zbx_substring($this->host, 0, $tmp_pos);
         }
         $atIndex = strpos($this->host, '@');
         if ($atIndex !== false) {
             $credentials = zbx_substring($this->host, 0, $atIndex);
             $colonIndex = strpos(credentials, ':');
             if ($colonIndex !== false) {
                 $this->username = zbx_substring($credentials, 0, $colonIndex);
                 $this->password = substr($credentials, $colonIndex);
             } else {
                 $this->username = $credentials;
             }
             $this->host = substr($this->host, $atIndex + 1);
         }
         $host_ipv6 = strpos($this->host, ']');
         if ($host_ipv6 !== false) {
             if ($host_ipv6 < zbx_strlen($this->host) - 1) {
                 $host_ipv6++;
                 $host_less = substr($this->host, $host_ipv6);
                 $portColonIndex = strpos($host_less, ':');
                 if ($portColonIndex !== false) {
                     $this->host = zbx_substring($this->host, 0, $host_ipv6);
                     $this->port = substr($host_less, $portColonIndex + 1);
                 }
             }
         } else {
             $portColonIndex = strpos($this->host, ':');
             if ($portColonIndex !== false) {
                 $this->host = zbx_substring($this->host, 0, $portColonIndex);
                 $this->port = substr($this->host, $portColonIndex + 1);
             }
         }
         $this->file = substr($this->url, $protocolSepIndex + 3);
         $this->file = substr($this->file, strpos($this->file, '/'));
         if ($this->file == $this->host) {
             $this->file = '';
         }
     } else {
         $this->file = $this->url;
     }
     $tmp_pos = strpos($this->file, '?');
     if ($tmp_pos !== false) {
         $this->file = zbx_substring($this->file, 0, $tmp_pos);
     }
     $refSepIndex = strpos($url, '#');
     if ($refSepIndex !== false) {
         $this->file = zbx_substring($this->file, 0, $refSepIndex);
         $this->reference = substr($url, strpos($url, '#') + 1);
     }
     $this->path = $this->file;
     if (zbx_strlen($this->query) > 0) {
         $this->file .= '?' . $this->query;
     }
     if (zbx_strlen($this->reference) > 0) {
         $this->file .= '#' . $this->reference;
     }
     if (isset($_COOKIE['zbx_sessionid'])) {
         $this->setArgument('sid', substr($_COOKIE['zbx_sessionid'], 16, 16));
     }
 }