Beispiel #1
0
function event_connect($header, $data)
{
    $connect_info['protocol_name'] = decodeString($data);
    $offset = strlen($connect_info['protocol_name']) + 2;
    $connect_info['version'] = ord(substr($data, $offset, 1));
    $offset += 1;
    $byte = ord($data[$offset]);
    $connect_info['willRetain'] = $byte & 0x20 == 0x20;
    $connect_info['willQos'] = $byte & 0x18 >> 3;
    $connect_info['willFlag'] = $byte & 0x4 == 0x4;
    $connect_info['cleanStart'] = $byte & 0x2 == 0x2;
    $offset += 1;
    $connect_info['keepalive'] = decodeValue(substr($data, $offset, 2));
    $offset += 2;
    $connect_info['clientId'] = decodeString(substr($data, $offset));
    return $connect_info;
}
Beispiel #2
0
function stripTags($str, $tags)
{
    if (is_string($str)) {
        $whitelist = array('iframe');
        $tags = !is_array($tags) ? array($tags) : $tags;
        $str = decodeValue($str);
        foreach ($tags as $tag) {
            preg_match_all('/<' . $tag . '.*?(src=("|\')(.*?)\\2.*?)?\\/?>((.*?)<\\/' . $tag . '>)?/ism', $str, $m);
            if (isset($m[0]) && !empty($m[0])) {
                foreach ($m[0] as $k => $v) {
                    // 0 = complete
                    // 3 = src url if applicable
                    // 5 = innerHTML if applicable
                    $e_tag = $tag;
                    $keep = false;
                    if (in_array($tag, $whitelist)) {
                        // Figure URL
                        $url = $m[3][$k];
                        if (!empty($url)) {
                            $e_tag = $e_tag . ' with src of: ' . $url;
                            $keep = isHostApproved($url);
                        }
                    }
                    // If not a keeper, replace with HTML comment
                    if ($keep === false) {
                        $str = str_replace($m[0][$k], '<!-- tag (' . $e_tag . ') not allowed -->', $str);
                    }
                }
            }
        }
    }
    return $str;
}
Beispiel #3
0
 protected function clean()
 {
     $method = isset($_SERVER['REQUEST_METHOD']) && $_SERVER['REQUEST_METHOD'] == 'POST' ? $_POST : $_GET;
     $this->original = new stdClass();
     $this->clean = new stdClass();
     $this->db_clean = new stdClass();
     $this->html_clean = new stdClass();
     if (!empty($method)) {
         foreach ($method as $k => $v) {
             $this->original->{$k} = $v;
             $v = trim(decodeValue($v));
             $this->clean->{$k} = strip_tags($v);
             $this->db_clean->{$k} = $this->db->escape_str($this->clean->{$k});
             $this->html_clean->{$k} = $this->db->escape_str(purifyHTML($v));
         }
     }
 }