Scan data steam using all enabled antiviruses, throws exception in case of infected data.

@param string $data The varaible containing the data to scan.
@throws \core\antivirus\scanner_exception If data is infected.
@return void
194397
public static function scan_data($data) {
        $antiviruses = self::get_enabled();
        foreach ($antiviruses as $antivirus) {
            $result = $antivirus->scan_data($data);
            if ($result === $antivirus::SCAN_RESULT_FOUND) {
                throw new \core\antivirus\scanner_exception('virusfound', '', array('item' => get_string('datastream', 'antivirus')));
            }
        }
    }
773594
protected function loadData(array $data = [])
    {
        foreach ($data as $key => $value) {
            if (property_exists($this, $key)) {
                $this->$key = $value;
            }
        }
    }
130207
public function setData($data)
    {
        foreach($this->data as $args)
        {
            Event::off(...$args);
        }
        $this->data = $data;
        foreach($this->data as $args)
        {
            Event::on(...$args);
        }
    }
381467
protected function write(string $data):void{
		$len = \strlen($data);

		for($i = 0; $i + 1 < $len; $i += 2){
			$c = ((0xff & \ord($data[$i])) << 8) | (0xff & \ord($data[$i + 1]));

			if(0x8140 <= $c && $c <= 0x9FFC){
				$c -= 0x8140;
			}
			elseif(0xE040 <= $c && $c <= 0xEBBF){
				$c -= 0xC140;
			}
			else{
				throw new QRCodeDataException('illegal char at '.($i + 1).' ['.$c.']');
			}

			$this->bitBuffer->put((($c >> 8) & 0xff) * 0xC0 + ($c & 0xff), 13);

		}

		if($i < $len){
			throw new QRCodeDataException('illegal char at '.($i + 1));
		}

	}
863450
public function set_data( $data ) {

		$this->instance = 0;
		foreach ( (array) $data[ $this->slug ] as $instance => $instance_data ) {
			foreach ( $this->child as $child ) {
				if ( method_exists( $child, 'set_data' ) ) {
					$child->set_data( $instance_data );
				}
			}
			$this->instance ++;
		}
		$this->instances = $this->instance;
		$this->instance  = 0;

	}
557802
public function load(string $data)
    {
        // we silence error(s) so we can catch them and throw a proper exception after
        $data = @parse_ini_string($data, true);

        // fail if there was an error while processing the specified ini file
        if ($data === false) {
            $error = error_get_last();
            throw new ProcessorException(__CLASS__.' fail to parse data: '.$error['message']);
        }

        // reset the result array
        $this->content = [];

        // loop through each section
        foreach ($data as $section => $contents) {
            $this->processSection($section, $contents);
        }
    }
1098950
protected function unpackData($data)
	{
		$this->values = $data['values'];
		$this->isInvalid = $data['isInvalid'];
		$this->messages = $data['messages'];
	}
293457
public static function setDebugData($data)
    {
        $matches = null;

        preg_match_all("/<p class=\"message warning\">\n(.*?)<\/p>/s", $data, $matches);

        if (!empty($matches[1])) {
            self::$debug = $matches[1];
        }
    }
500946
public function setResponseData($data) {
		$this->responseData = $data;
		if (isset($data['report'])) {
			$this->report = EETReport::fromArray($data['report']);
		}
		$this->cancels = array();
		if (isset($data['cancel'])) {
			foreach ($data['cancel'] as $cancel) {
				$this->cancels[] = EETReport::fromArray($cancel);
			}
		}
	}
71140
private function encryptPrivate($data)
    {
        if (!openssl_private_encrypt($data, $encrypted, $this->key, $this->cryptParams['padding'])) {
            throw new Exception('Failure encrypting Data (openssl private) - ' . openssl_error_string());
        }
        return $encrypted;
    }
837896
public function write(string $data) : void
    {
        $this->buffer .= $data;

        if (strlen($this->buffer) >= $this->size) {
            $this->flush();
        }
    }
1308607
private function scan($data,$level) {
		if (!isset($data[0])){
			$data = array($data);
		}
		foreach($data as $key => $record){
			 $this->extract($record,$level);	
		}
	}
179418
public function savePermission($data = [])
    {
        if (!empty($data)) {
            $this->data($data);
        }
        $validate = new \gmars\rbac\validate\Permission();
        if (!$validate->check($this)) {
            throw new Exception($validate->getError());
        }
        $data = $this->getData();
        if (isset($data['id']) && !empty($data['id'])) {
            $this->isUpdate(true);
        }
        $this->save();
        return $this;
    }
695961
protected function execute(array $data) {
        // Auto-connect:
        if ($this->isConnected() === false) {
            $this->connect();
        }

        $this->lastRequestContent = $data;

        $dataAsString = json_encode($data);

        $options = $this->options;

        $options[CURLOPT_POSTFIELDS] = $dataAsString;

        if (isset($this->session)) {
            $options[CURLOPT_HTTPHEADER][] = 'X-RPC-Auth-Session: ' . $this->session;
        } elseif (array_key_exists(self::USERNAME, $this->config) &&
            is_string($this->config[self::USERNAME]) &&
            !empty($this->config[self::USERNAME]) &&
            array_key_exists(self::PASSWORD, $this->config) &&
            is_string($this->config[self::PASSWORD]) &&
            !empty($this->config[self::PASSWORD])) {
            $options[CURLOPT_HTTPHEADER][] = 'X-RPC-Auth-Username: ' . $this->config[self::USERNAME];
            $options[CURLOPT_HTTPHEADER][] = 'X-RPC-Auth-Password: ' . $this->config[self::PASSWORD];
        }

        curl_setopt_array($this->resource, $options);

        $responseString = curl_exec($this->resource);

        $this->lastInfo = curl_getinfo($this->resource);

        if ($responseString === false) {
            switch ($this->lastInfo['http_code']) {
                case 0:
                    $message = curl_error($this->resource);

                    if (strlen($message) === 0) {
                        $message = 'Connection to Web server failed';
                    }

                    throw new RuntimeException($message);
                default:
                    throw new RuntimeException(sprintf(
                        'Web server responded with HTTP status code "%s"',
                        $this->lastInfo['http_code']
                    ));
            }
        } elseif (!is_string($responseString)) {
            throw new RuntimeException('No content from Web server');
        }

        $headerLength = curl_getinfo($this->resource, CURLINFO_HEADER_SIZE);
        $this->lastResponseHeaders = substr($responseString, 0, $headerLength);

        $body = substr($responseString, $headerLength);

        $lastResponse = json_decode(trim($body), true);

        if (!is_array($lastResponse)) {
            if (is_string($body) && strlen($body) > 0) {
                throw new RuntimeException(sprintf(
                    'i-doit responded with an unknown message: %s',
                    $body
                ));
            } else {
                throw new RuntimeException('i-doit responded with an invalid JSON string.');
            }
        }

        $this->lastResponse = $lastResponse;

        return $this->lastResponse;
    }
427723
public function initialize(array $data = array())
    {
        if($this->exe->flash->has('form_data'))
            $this->set($this->exe->flash->get('form_data'));

        parent::initialize($data);
    }
945032
public function onData($data)
    {
        //if we're in encryption stage decrypt it first
        if($this->secret !== null) {
            mcrypt_generic_init($this->encryptor, $this->secret, $this->secret);
            $data = mdecrypt_generic($this->encryptor, $data);
            mcrypt_generic_deinit($this->encryptor);
        }

        //attempt to parse the data as a packet
        try {

            //add the data to the current buffer
            $this->packetBuffer .= $data;

            //for as long as we have data left in the buffer
            do {

                //read the packet length from the stream
                $packetLengthVarInt = VarInt::readUnsignedVarInt($this->packetBuffer);

                //not enough data to read the packet length, wait for more data
                if($packetLengthVarInt === false) {
                    return;
                }

                //total length of the packet is the length of the varint + it's value
                $totalLength = $packetLengthVarInt->getDataLength() + $packetLengthVarInt->getValue();

                //if we don't have enough data to read the entire packet wait for more data to enter
                $bufferLength = strlen($this->packetBuffer);
                if ($bufferLength < $totalLength) {
                    return;
                }

                //remove the packet length varint from the buffer
                $this->packetBuffer = substr($this->packetBuffer, $packetLengthVarInt->getDataLength());

                //read the packet ID from the buffer
                $packetDataWithPacketID = substr($this->packetBuffer, 0, $packetLengthVarInt->getValue());

                //remove the rest of the packet from the buffer
                $this->packetBuffer = substr($this->packetBuffer, $packetLengthVarInt->getValue());

                //read the packet ID
                $packetID = VarInt::readUnsignedVarInt($packetDataWithPacketID);

                //get the raw packet data
                $packetData = substr($packetDataWithPacketID, $packetID->getDataLength());

                $this->lastPacket = $this->currentTime();

                //trigger packet processing
                $this->processPacket($packetID->getValue(), $packetData);

                //if we have buffer left run again
            } while (strlen($this->packetBuffer) > 0);

            //if any exceptions are thrown (error parsing the packets e.t.c.) send a disconnect packet
        } catch (Exception $ex) {
            echo "EXCEPTION IN PACKET PARSING {$ex->getMessage()}\n";
            echo $ex->getTraceAsString();
            $dis = new DisconnectPacket();
            $dis->setReason('Internal Server Error: '.$ex->getMessage());
            $this->end($dis->encodePacket());
        }
    }
88207
public function unserialize($data): void
    {
        $data = unserialize($data, ['allowed_classes' => [FlexObject::class]]);

        $this->doUnserialize($data);
    }