Ejemplo n.º 1
0
function readData($readFrom, $removeHeader)
{
    $str = "";
    $query = strstr($readFrom, "?");
    if (strlen($query) > 250) {
        $str = PostIt($readFrom);
    } else {
        $readUrl = encodeValues($readFrom);
        $fp = fopen($readUrl, "r");
        if ($fp) {
            while (!feof($fp)) {
                $buffer = fgets($fp, 8096);
                $str .= $buffer;
            }
            fclose($fp);
        }
    }
    $str = trim($str);
    if ($removeHeader) {
        // remove xml processing instruction
        if (strncasecmp($str, "<?xml", 5) == 0) {
            $pos = strpos($str, "?>");
            if ($pos > 0) {
                $str = substr_replace($str, "", 0, $pos + 2);
            }
        }
    }
    return $str;
}
Ejemplo n.º 2
0
function readData($readFrom, $removeHeader = true)
{
    $e = error_reporting();
    error_reporting($e & E_ALL - E_WARNING);
    if (eregi("swish", $readFrom)) {
        $swishStr = split("&", trim($readFrom));
        // indexa o vetor pelo valor que estiver antes do sinal de "="
        foreach ($swishStr as $i) {
            $i_split = split("=", $i);
            $swishArg[$i_split[0]] = $i_split[1];
        }
        $swishArgCount = $GLOBALS["browse-swish"] ? "-1" : $swishArg["count"];
        $swish = new swishe2XML($swishArg["path"], $swishArg["expression"], $swishArg["index"], "", "swish", $swishArgCount);
        $swish_result = $swish->search();
        // transforma as entidades html em caracteres para não gerar erro no XSL transformation
        $translateEntities = get_html_translation_table(HTML_ENTITIES);
        $translateEntities = array_flip($translateEntities);
        $translateEntities["&"] = "&amp;";
        $swish_result = strtr($swish_result, $translateEntities);
        return $swish_result;
    } else {
        $query = strstr($readFrom, "?");
        if (strlen($query) > 250) {
            $str = PostIt($readFrom);
        } else {
            $str = "";
            $buffer = "";
            $readUrl = encodeValues($readFrom);
            $fp = fopen($readUrl, "r");
            if ($fp) {
                while (!feof($fp)) {
                    $buffer = fgets($fp, 8096);
                    $str .= $buffer;
                }
                fclose($fp);
            }
        }
        if ($removeHeader) {
            /* remove xml processing instruction */
            if (strncasecmp($str, "<?xml", 5) == 0) {
                $pos = strpos($str, "?>");
                if ($pos > 0) {
                    $str = substr_replace($str, "", 0, $pos + 2);
                }
            }
        }
        return $str;
    }
}
Ejemplo n.º 3
0
 /**
  * Adds a hint box to the elemt.
  *
  * @param string|array|CTag     $text       hint content
  * @param string                $spanClass  wrap the content in a span element and assign a this class to the span
  * @param bool                  $byClick    if set to true, it will be possible to "freeze" the hint box via a mouse
  *                                          click
  *
  * @return bool
  */
 public function setHint($text, $spanClass = '', $byClick = true)
 {
     if (empty($text)) {
         return false;
     }
     encodeValues($text);
     $text = unpack_object($text);
     $this->addAction('onmouseover', 'hintBox.HintWraper(event, this, ' . zbx_jsvalue($text) . ', "' . $spanClass . '");');
     if ($byClick) {
         $this->addAction('onclick', 'hintBox.showStaticHint(event, this, ' . zbx_jsvalue($text) . ', "' . $spanClass . '");');
     }
     return true;
 }
Ejemplo n.º 4
0
function encodeValues(&$value, $encodeTwice = true)
{
    if (is_string($value)) {
        $value = htmlentities($value, ENT_COMPAT, 'UTF-8');
        if ($encodeTwice) {
            $value = htmlentities($value, ENT_COMPAT, 'UTF-8');
        }
    } elseif (is_array($value)) {
        foreach ($value as $key => $elem) {
            encodeValues($value[$key]);
        }
    } elseif (is_object($value)) {
        foreach ($value->items as $key => $item) {
            encodeValues($value->items[$key], false);
        }
    }
}
Ejemplo n.º 5
0
 /**
  * Adds a hint box to the element.
  *
  * @param string|array|CTag		$text				Hint content.
  * @param string				$span_class			Wrap the content in a span element and assign this class
  *													to the span.
  * @param bool					$freeze_on_click	If set to true, it will be possible to "freeze" the hint box
  *													via a mouse click.
  * @param string				$styles				Custom css styles.
  *													Syntax:
  *														property1: value1; property2: value2; property(n): value(n)
  *
  * @return bool
  */
 public function setHint($text, $span_class = '', $freeze_on_click = true, $styles = '')
 {
     if (empty($text)) {
         return $this;
     }
     encodeValues($text);
     $text = unpack_object($text);
     $this->onMouseover('hintBox.HintWraper(event, this, ' . zbx_jsvalue($text) . ', "' . $span_class . '", "' . $styles . '");');
     if ($freeze_on_click) {
         $this->onClick('hintBox.showStaticHint(event, this, ' . zbx_jsvalue($text) . ', "' . $span_class . '", false, "' . $styles . '");');
     }
     return $this;
 }