protocol-class

Gesponsorde koppelingen

PHP script bestanden

  1. protocol-class

« Lees de omschrijving en reacties

Code (php)
PHP script in nieuw venster Selecteer het PHP script
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
<?php

/**
 * @author Nico Kaag
 * @copyright 2009
 */

error_reporting(E_ALL);

class protocol
{
    private $protocolExpression;
    
    public function __construct($acceptable)
    {

        $this->protocolExpression = "/<#(";
        $this->protocolExpression .= $acceptable;
        $this->protocolExpression .= ")>(.*?)<#\/(";
        $this->protocolExpression .= $acceptable;
        $this->protocolExpression .= ")>(.*?)/si";
    }

    
    /**
     * @function createFromArray
     * @description Create a new valid protocol message to send over the net
     * @param protocol
     * @paramDescription The protocol to return
     * @param Array
     * @paramDescription The array from wich to create an protocol
     */

    public function createFromArray($Array, $protocol = "")
    {

        foreach ($Array as $action => $value) {
            $protocol .= "<#" . $action . ">";
            $protocol .= $value;
            $protocol .= "<#/" . $action . ">";
        }

        return $protocol;
    }



    /**
     * @function stripAndReturn
     * @description Strips the protocol into an array, with the tag as array name, and the value as the value of the array
     * @param protocol
     * @paramDescription The protocol to strip
     * @param Array
     * @paramDescription The output array that will be filled
     */

    
    public function stripAndReturn($protocol, $Array = array())
    {

        if (!empty($protocol)) {
            preg_match($this->protocolExpression, $protocol, $matches);
            if (!empty($matches))
            {

                $sub_protocol = substr($protocol, strlen($matches[0]), (strlen($protocol) -
                    strlen($matches[0])));
                $Array[$matches[1]] = $matches[2];
                return $this->stripAndReturn($sub_protocol, $Array);
            }

            else {
                return false;
            }            
        }
else {
            return $Array;
        }
    }
}

?>

 
 

Om de gebruiksvriendelijkheid van onze website en diensten te optimaliseren maken wij gebruik van cookies. Deze cookies gebruiken wij voor functionaliteiten, analytische gegevens en marketing doeleinden. U vindt meer informatie in onze privacy statement.