Initial import from svn sydic-dev
authorEbersold Andre <andre.ebersold@free.fr>
Thu, 30 Dec 2021 13:08:37 +0000 (14:08 +0100)
committerEbersold Andre <andre.ebersold@free.fr>
Thu, 30 Dec 2021 13:08:37 +0000 (14:08 +0100)
27 files changed:
IXR_Library.inc [new file with mode: 0644]
class.ActionResults.php [new file with mode: 0644]
class.chiffre_lettre.php [new file with mode: 0644]
class.controler.php [new file with mode: 0644]
class.crontab.php [new file with mode: 0644]
class.db.php [new file with mode: 0644]
class.feed.php [new file with mode: 0644]
class.form.php [new file with mode: 0644]
class.fpdfdb.php [new file with mode: 0644]
class.http.Request.php [new file with mode: 0644]
class.images.php [new file with mode: 0644]
class.json-rpc.php [new file with mode: 0644]
class.logging.php [new file with mode: 0644]
class.menu.php [new file with mode: 0644]
class.nntp.php [new file with mode: 0644]
class.notebook.php [new file with mode: 0644]
class.ofx.php [new file with mode: 0644]
class.page.php [new file with mode: 0644]
class.router.php [new file with mode: 0644]
class.session.php [new file with mode: 0644]
class.sitemap.php [new file with mode: 0644]
class.smtp.php [new file with mode: 0644]
class.validator.php [new file with mode: 0644]
iface.ActionResult.php [new file with mode: 0644]
iface.Request.php [new file with mode: 0644]
monofont.ttf [new file with mode: 0644]
utils.php [new file with mode: 0644]

diff --git a/IXR_Library.inc b/IXR_Library.inc
new file mode 100644 (file)
index 0000000..99f685e
--- /dev/null
@@ -0,0 +1,818 @@
+<?php
+
+/* 
+   IXR - The Inutio XML-RPC Library - (c) Incutio Ltd 2002
+   Version 1.61 - Simon Willison, 11th July 2003 (htmlentities -> htmlspecialchars)
+   Site:   http://scripts.incutio.com/xmlrpc/
+   Manual: http://scripts.incutio.com/xmlrpc/manual.php
+   Made available under the Artistic License: http://www.opensource.org/licenses/artistic-license.php
+*/
+
+
+class IXR_Value {
+    var $data;
+    var $type;
+    function IXR_Value ($data, $type = false) {
+        $this->data = $data;
+        if (!$type) {
+            $type = $this->calculateType();
+        }
+        $this->type = $type;
+        if ($type == 'struct') {
+            /* Turn all the values in the array in to new IXR_Value objects */
+            foreach ($this->data as $key => $value) {
+                $this->data[$key] = new IXR_Value($value);
+            }
+        }
+        if ($type == 'array') {
+            for ($i = 0, $j = count($this->data); $i < $j; $i++) {
+                $this->data[$i] = new IXR_Value($this->data[$i]);
+            }
+        }
+    }
+    function calculateType() {
+        if ($this->data === true || $this->data === false) {
+            return 'boolean';
+        }
+        if (is_integer($this->data)) {
+            return 'int';
+        }
+        if (is_double($this->data)) {
+            return 'double';
+        }
+        // Deal with IXR object types base64 and date
+        if (is_object($this->data) && is_a($this->data, 'IXR_Date')) {
+            return 'date';
+        }
+        if (is_object($this->data) && is_a($this->data, 'IXR_Base64')) {
+            return 'base64';
+        }
+        // If it is a normal PHP object convert it in to a struct
+        if (is_object($this->data)) {
+            
+            $this->data = get_object_vars($this->data);
+            return 'struct';
+        }
+        if (!is_array($this->data)) {
+            return 'string';
+        }
+        /* We have an array - is it an array or a struct ? */
+        if ($this->isStruct($this->data)) {
+            return 'struct';
+        } else {
+            return 'array';
+        }
+    }
+    function getXml() {
+        /* Return XML for this value */
+        switch ($this->type) {
+            case 'boolean':
+                return '<boolean>'.(($this->data) ? '1' : '0').'</boolean>';
+                break;
+            case 'int':
+                return '<int>'.$this->data.'</int>';
+                break;
+            case 'double':
+                return '<double>'.$this->data.'</double>';
+                break;
+            case 'string':
+                return '<string>'.htmlspecialchars($this->data).'</string>';
+                break;
+            case 'array':
+                $return = '<array><data>'."\n";
+                foreach ($this->data as $item) {
+                    $return .= '  <value>'.$item->getXml()."</value>\n";
+                }
+                $return .= '</data></array>';
+                return $return;
+                break;
+            case 'struct':
+                $return = '<struct>'."\n";
+                foreach ($this->data as $name => $value) {
+                    $return .= "  <member><name>$name</name><value>";
+                    $return .= $value->getXml()."</value></member>\n";
+                }
+                $return .= '</struct>';
+                return $return;
+                break;
+            case 'date':
+            case 'base64':
+                return $this->data->getXml();
+                break;
+        }
+        return false;
+    }
+    function isStruct($array) {
+        /* Nasty function to check if an array is a struct or not */
+        $expected = 0;
+        foreach ($array as $key => $value) {
+            if ((string)$key != (string)$expected) {
+                return true;
+            }
+            $expected++;
+        }
+        return false;
+    }
+}
+
+
+class IXR_Message {
+    var $message;
+    var $messageType;  // methodCall / methodResponse / fault
+    var $faultCode;
+    var $faultString;
+    var $methodName;
+    var $params;
+    // Current variable stacks
+    var $_arraystructs = array();   // The stack used to keep track of the current array/struct
+    var $_arraystructstypes = array(); // Stack keeping track of if things are structs or array
+    var $_currentStructName = array();  // A stack as well
+    var $_param;
+    var $_value;
+    var $_currentTag;
+    var $_currentTagContents;
+    // The XML parser
+    var $_parser;
+    function IXR_Message ($message) {
+        $this->message = $message;
+    }
+    function parse() {
+        // first remove the XML declaration
+        $this->message = preg_replace('/<\?xml(.*)?\?'.'>/', '', $this->message);
+        if (trim($this->message) == '') {
+            return false;
+        }
+        $this->_parser = xml_parser_create();
+        // Set XML parser to take the case of tags in to account
+        xml_parser_set_option($this->_parser, XML_OPTION_CASE_FOLDING, false);
+        // Set XML parser callback functions
+        xml_set_object($this->_parser, $this);
+        xml_set_element_handler($this->_parser, 'tag_open', 'tag_close');
+        xml_set_character_data_handler($this->_parser, 'cdata');
+        if (!xml_parse($this->_parser, $this->message)) {
+            /* die(sprintf('XML error: %s at line %d',
+                xml_error_string(xml_get_error_code($this->_parser)),
+                xml_get_current_line_number($this->_parser))); */
+            return false;
+        }
+        xml_parser_free($this->_parser);
+        // Grab the error messages, if any
+        if ($this->messageType == 'fault') {
+            $this->faultCode = $this->params[0]['faultCode'];
+            $this->faultString = $this->params[0]['faultString'];
+        }
+        return true;
+    }
+    function tag_open($parser, $tag, $attr) {
+        $this->currentTag = $tag;
+        switch($tag) {
+            case 'methodCall':
+            case 'methodResponse':
+            case 'fault':
+                $this->messageType = $tag;
+                break;
+            /* Deal with stacks of arrays and structs */
+            case 'data':    // data is to all intents and puposes more interesting than array
+                $this->_arraystructstypes[] = 'array';
+                $this->_arraystructs[] = array();
+                break;
+            case 'struct':
+                $this->_arraystructstypes[] = 'struct';
+                $this->_arraystructs[] = array();
+                break;
+        }
+    }
+    function cdata($parser, $cdata) {
+        $this->_currentTagContents .= $cdata;
+    }
+    function tag_close($parser, $tag) {
+        $valueFlag = false;
+        switch($tag) {
+            case 'int':
+            case 'i4':
+                $value = (int)trim($this->_currentTagContents);
+                $this->_currentTagContents = '';
+                $valueFlag = true;
+                break;
+            case 'double':
+                $value = (double)trim($this->_currentTagContents);
+                $this->_currentTagContents = '';
+                $valueFlag = true;
+                break;
+            case 'string':
+                $value = (string)trim($this->_currentTagContents);
+                $this->_currentTagContents = '';
+                $valueFlag = true;
+                break;
+            case 'dateTime.iso8601':
+                $value = new IXR_Date(trim($this->_currentTagContents));
+                // $value = $iso->getTimestamp();
+                $this->_currentTagContents = '';
+                $valueFlag = true;
+                break;
+            case 'value':
+                // "If no type is indicated, the type is string."
+                if (trim($this->_currentTagContents) != '') {
+                    $value = (string)$this->_currentTagContents;
+                    $this->_currentTagContents = '';
+                    $valueFlag = true;
+                }
+                break;
+            case 'boolean':
+                $value = (boolean)trim($this->_currentTagContents);
+                $this->_currentTagContents = '';
+                $valueFlag = true;
+                break;
+            case 'base64':
+                $value = base64_decode($this->_currentTagContents);
+                $this->_currentTagContents = '';
+                $valueFlag = true;
+                break;
+            /* Deal with stacks of arrays and structs */
+            case 'data':
+            case 'struct':
+                $value = array_pop($this->_arraystructs);
+                array_pop($this->_arraystructstypes);
+                $valueFlag = true;
+                break;
+            case 'member':
+                array_pop($this->_currentStructName);
+                break;
+            case 'name':
+                $this->_currentStructName[] = trim($this->_currentTagContents);
+                $this->_currentTagContents = '';
+                break;
+            case 'methodName':
+                $this->methodName = trim($this->_currentTagContents);
+                $this->_currentTagContents = '';
+                break;
+        }
+        if ($valueFlag) {
+            /*
+            if (!is_array($value) && !is_object($value)) {
+                $value = trim($value);
+            }
+            */
+            if (count($this->_arraystructs) > 0) {
+                // Add value to struct or array
+                if ($this->_arraystructstypes[count($this->_arraystructstypes)-1] == 'struct') {
+                    // Add to struct
+                    $this->_arraystructs[count($this->_arraystructs)-1][$this->_currentStructName[count($this->_currentStructName)-1]] = $value;
+                } else {
+                    // Add to array
+                    $this->_arraystructs[count($this->_arraystructs)-1][] = $value;
+                }
+            } else {
+                // Just add as a paramater
+                $this->params[] = $value;
+            }
+        }
+    }       
+}
+
+
+class IXR_Server {
+    var $data;
+    var $callbacks = array();
+    var $message;
+    var $capabilities;
+    function IXR_Server($callbacks = false, $data = false) {
+        $this->setCapabilities();
+        if ($callbacks) {
+            $this->callbacks = $callbacks;
+        }
+        $this->setCallbacks();
+        $this->serve($data);
+    }
+    function serve($data = false) {
+        if (!$data) {
+            global $HTTP_RAW_POST_DATA;
+            if (!$HTTP_RAW_POST_DATA) {
+               die('XML-RPC server accepts POST requests only.');
+            }
+            $data = $HTTP_RAW_POST_DATA;
+        }
+        $this->message = new IXR_Message($data);
+        if (!$this->message->parse()) {
+            $this->error(-32700, 'parse error. not well formed');
+        }
+        if ($this->message->messageType != 'methodCall') {
+            $this->error(-32600, 'server error. invalid xml-rpc. not conforming to spec. Request must be a methodCall');
+        }
+        $result = $this->call($this->message->methodName, $this->message->params);
+        // Is the result an error?
+        if (is_a($result, 'IXR_Error')) {
+            $this->error($result);
+        }
+        // Encode the result
+        $r = new IXR_Value($result);
+        $resultxml = $r->getXml();
+        // Create the XML
+        $xml = <<<EOD
+<methodResponse>
+  <params>
+    <param>
+      <value>
+        $resultxml
+      </value>
+    </param>
+  </params>
+</methodResponse>
+
+EOD;
+        // Send it
+        $this->output($xml);
+    }
+    function call($methodname, $args) {
+        if (!$this->hasMethod($methodname)) {
+            return new IXR_Error(-32601, 'server error. requested method '.$methodname.' does not exist.');
+        }
+        $method = $this->callbacks[$methodname];
+        // Perform the callback and send the response
+        if (count($args) == 1) {
+            // If only one paramater just send that instead of the whole array
+            $args = $args[0];
+        }
+        // Are we dealing with a function or a method?
+        if (substr($method, 0, 5) == 'this:') {
+            // It's a class method - check it exists
+            $method = substr($method, 5);
+            if (!method_exists($this, $method)) {
+                return new IXR_Error(-32601, 'server error. requested class method "'.$method.'" does not exist.');
+            }
+            // Call the method
+            $result = $this->$method($args);
+        } else {
+            // It's a function - does it exist?
+            if (!function_exists($method)) {
+                return new IXR_Error(-32601, 'server error. requested function "'.$method.'" does not exist.');
+            }
+            // Call the function
+            $result = $method($args);
+        }
+        return $result;
+    }
+
+    function error($error, $message = false) {
+        // Accepts either an error object or an error code and message
+        if ($message && !is_object($error)) {
+            $error = new IXR_Error($error, $message);
+        }
+        $this->output($error->getXml());
+    }
+    function output($xml) {
+        $xml = '<?xml version="1.0"?>'."\n".$xml;
+        $length = strlen($xml);
+        header('Connection: close');
+        header('Content-Length: '.$length);
+        header('Content-Type: text/xml');
+        header('Date: '.date('r'));
+        echo $xml;
+        exit;
+    }
+    function hasMethod($method) {
+        return in_array($method, array_keys($this->callbacks));
+    }
+    function setCapabilities() {
+        // Initialises capabilities array
+        $this->capabilities = array(
+            'xmlrpc' => array(
+                'specUrl' => 'http://www.xmlrpc.com/spec',
+                'specVersion' => 1
+            ),
+            'faults_interop' => array(
+                'specUrl' => 'http://xmlrpc-epi.sourceforge.net/specs/rfc.fault_codes.php',
+                'specVersion' => 20010516
+            ),
+            'system.multicall' => array(
+                'specUrl' => 'http://www.xmlrpc.com/discuss/msgReader$1208',
+                'specVersion' => 1
+            ),
+        );   
+    }
+    function getCapabilities($args) {
+        return $this->capabilities;
+    }
+    function setCallbacks() {
+        $this->callbacks['system.getCapabilities'] = 'this:getCapabilities';
+        $this->callbacks['system.listMethods'] = 'this:listMethods';
+        $this->callbacks['system.multicall'] = 'this:multiCall';
+    }
+    function listMethods($args) {
+        // Returns a list of methods - uses array_reverse to ensure user defined
+        // methods are listed before server defined methods
+        return array_reverse(array_keys($this->callbacks));
+    }
+    function multiCall($methodcalls) {
+        // See http://www.xmlrpc.com/discuss/msgReader$1208
+        $return = array();
+        foreach ($methodcalls as $call) {
+            $method = $call['methodName'];
+            $params = $call['params'];
+            if ($method == 'system.multicall') {
+                $result = new IXR_Error(-32600, 'Recursive calls to system.multicall are forbidden');
+            } else {
+                $result = $this->call($method, $params);
+            }
+            if (is_a($result, 'IXR_Error')) {
+                $return[] = array(
+                    'faultCode' => $result->code,
+                    'faultString' => $result->message
+                );
+            } else {
+                $return[] = array($result);
+            }
+        }
+        return $return;
+    }
+}
+
+class IXR_Request {
+    var $method;
+    var $args;
+    var $xml;
+    function IXR_Request($method, $args) {
+        $this->method = $method;
+        $this->args = $args;
+        $this->xml = <<<EOD
+<?xml version="1.0"?>
+<methodCall>
+<methodName>{$this->method}</methodName>
+<params>
+
+EOD;
+        foreach ($this->args as $arg) {
+            $this->xml .= '<param><value>';
+            $v = new IXR_Value($arg);
+            $this->xml .= $v->getXml();
+            $this->xml .= "</value></param>\n";
+        }
+        $this->xml .= '</params></methodCall>';
+    }
+    function getLength() {
+        return strlen($this->xml);
+    }
+    function getXml() {
+        return $this->xml;
+    }
+}
+
+
+class IXR_Client {
+    var $server;
+    var $port;
+    var $path;
+    var $useragent;
+    var $response;
+    var $message = false;
+    var $debug = false;
+    // Storage place for an error message
+    var $error = false;
+    function IXR_Client($server, $path = false, $port = 80) {
+        if (!$path) {
+            // Assume we have been given a URL instead
+            $bits = parse_url($server);
+            $this->server = $bits['host'];
+            $this->port = isset($bits['port']) ? $bits['port'] : 80;
+            $this->path = isset($bits['path']) ? $bits['path'] : '/';
+            // Make absolutely sure we have a path
+            if (!$this->path) {
+                $this->path = '/';
+            }
+        } else {
+            $this->server = $server;
+            $this->path = $path;
+            $this->port = $port;
+        }
+        $this->useragent = 'The Incutio XML-RPC PHP Library';
+    }
+    function query() {
+        $args = func_get_args();
+        $method = array_shift($args);
+        $request = new IXR_Request($method, $args);
+        $length = $request->getLength();
+        $xml = $request->getXml();
+        $r = "\r\n";
+        $request  = "POST {$this->path} HTTP/1.0$r";
+        $request .= "Host: {$this->server}$r";
+        $request .= "Content-Type: text/xml$r";
+        $request .= "User-Agent: {$this->useragent}$r";
+        $request .= "Content-length: {$length}$r$r";
+        $request .= $xml;
+        // Now send the request
+        if ($this->debug) {
+            echo '<pre>'.htmlspecialchars($request)."\n</pre>\n\n";
+        }
+        $fp = @fsockopen($this->server, $this->port);
+        if (!$fp) {
+            $this->error = new IXR_Error(-32300, 'transport error - could not open socket');
+            return false;
+        }
+        fputs($fp, $request);
+        $contents = '';
+        $gotFirstLine = false;
+        $gettingHeaders = true;
+        while (!feof($fp)) {
+            $line = fgets($fp, 4096);
+            if (!$gotFirstLine) {
+                // Check line for '200'
+                if (strstr($line, '200') === false) {
+                    $this->error = new IXR_Error(-32300, 'transport error - HTTP status code was not 200');
+                    return false;
+                }
+                $gotFirstLine = true;
+            }
+            if (trim($line) == '') {
+                $gettingHeaders = false;
+            }
+            if (!$gettingHeaders) {
+                $contents .= trim($line)."\n";
+            }
+        }
+        if ($this->debug) {
+            echo '<pre>'.htmlspecialchars($contents)."\n</pre>\n\n";
+        }
+        // Now parse what we've got back
+        $this->message = new IXR_Message($contents);
+        if (!$this->message->parse()) {
+            // XML error
+            $this->error = new IXR_Error(-32700, 'parse error. not well formed');
+            return false;
+        }
+        // Is the message a fault?
+        if ($this->message->messageType == 'fault') {
+            $this->error = new IXR_Error($this->message->faultCode, $this->message->faultString);
+            return false;
+        }
+        // Message must be OK
+        return true;
+    }
+    function getResponse() {
+        // methodResponses can only have one param - return that
+        return $this->message->params[0];
+    }
+    function isError() {
+        return (is_object($this->error));
+    }
+    function getErrorCode() {
+        return $this->error->code;
+    }
+    function getErrorMessage() {
+        return $this->error->message;
+    }
+}
+
+
+class IXR_Error {
+    var $code;
+    var $message;
+    function IXR_Error($code, $message) {
+        $this->code = $code;
+        $this->message = $message;
+    }
+    function getXml() {
+        $xml = <<<EOD
+<methodResponse>
+  <fault>
+    <value>
+      <struct>
+        <member>
+          <name>faultCode</name>
+          <value><int>{$this->code}</int></value>
+        </member>
+        <member>
+          <name>faultString</name>
+          <value><string>{$this->message}</string></value>
+        </member>
+      </struct>
+    </value>
+  </fault>
+</methodResponse> 
+
+EOD;
+        return $xml;
+    }
+}
+
+
+class IXR_Date {
+    var $year;
+    var $month;
+    var $day;
+    var $hour;
+    var $minute;
+    var $second;
+    function IXR_Date($time) {
+        // $time can be a PHP timestamp or an ISO one
+        if (is_numeric($time)) {
+            $this->parseTimestamp($time);
+        } else {
+            $this->parseIso($time);
+        }
+    }
+    function parseTimestamp($timestamp) {
+        $this->year = date('Y', $timestamp);
+        $this->month = date('Y', $timestamp);
+        $this->day = date('Y', $timestamp);
+        $this->hour = date('H', $timestamp);
+        $this->minute = date('i', $timestamp);
+        $this->second = date('s', $timestamp);
+    }
+    function parseIso($iso) {
+        $this->year = substr($iso, 0, 4);
+        $this->month = substr($iso, 4, 2); 
+        $this->day = substr($iso, 6, 2);
+        $this->hour = substr($iso, 9, 2);
+        $this->minute = substr($iso, 12, 2);
+        $this->second = substr($iso, 15, 2);
+    }
+    function getIso() {
+        return $this->year.$this->month.$this->day.'T'.$this->hour.':'.$this->minute.':'.$this->second;
+    }
+    function getXml() {
+        return '<dateTime.iso8601>'.$this->getIso().'</dateTime.iso8601>';
+    }
+    function getTimestamp() {
+        return mktime($this->hour, $this->minute, $this->second, $this->month, $this->day, $this->year);
+    }
+}
+
+
+class IXR_Base64 {
+    var $data;
+    function IXR_Base64($data) {
+        $this->data = $data;
+    }
+    function getXml() {
+        return '<base64>'.base64_encode($this->data).'</base64>';
+    }
+}
+
+
+class IXR_IntrospectionServer extends IXR_Server {
+    var $signatures;
+    var $help;
+    function IXR_IntrospectionServer() {
+        $this->setCallbacks();
+        $this->setCapabilities();
+        $this->capabilities['introspection'] = array(
+            'specUrl' => 'http://xmlrpc.usefulinc.com/doc/reserved.html',
+            'specVersion' => 1
+        );
+        $this->addCallback(
+            'system.methodSignature', 
+            'this:methodSignature', 
+            array('array', 'string'), 
+            'Returns an array describing the return type and required parameters of a method'
+        );
+        $this->addCallback(
+            'system.getCapabilities', 
+            'this:getCapabilities', 
+            array('struct'), 
+            'Returns a struct describing the XML-RPC specifications supported by this server'
+        );
+        $this->addCallback(
+            'system.listMethods', 
+            'this:listMethods', 
+            array('array'), 
+            'Returns an array of available methods on this server'
+        );
+        $this->addCallback(
+            'system.methodHelp', 
+            'this:methodHelp', 
+            array('string', 'string'), 
+            'Returns a documentation string for the specified method'
+        );
+    }
+    function addCallback($method, $callback, $args, $help) {
+        $this->callbacks[$method] = $callback;
+        $this->signatures[$method] = $args;
+        $this->help[$method] = $help;
+    }
+    function call($methodname, $args) {
+        // Make sure it's in an array
+        if ($args && !is_array($args)) {
+            $args = array($args);
+        }
+        // Over-rides default call method, adds signature check
+        if (!$this->hasMethod($methodname)) {
+            return new IXR_Error(-32601, 'server error. requested method "'.$this->message->methodName.'" not specified.');
+        }
+        $method = $this->callbacks[$methodname];
+        $signature = $this->signatures[$methodname];
+        $returnType = array_shift($signature);
+        // Check the number of arguments
+        if (count($args) != count($signature)) {
+            // print 'Num of args: '.count($args).' Num in signature: '.count($signature);
+            return new IXR_Error(-32602, 'server error. wrong number of method parameters');
+        }
+        // Check the argument types
+        $ok = true;
+        $argsbackup = $args;
+        for ($i = 0, $j = count($args); $i < $j; $i++) {
+            $arg = array_shift($args);
+            $type = array_shift($signature);
+            switch ($type) {
+                case 'int':
+                case 'i4':
+                    if (is_array($arg) || !is_int($arg)) {
+                        $ok = false;
+                    }
+                    break;
+                case 'base64':
+                case 'string':
+                    if (!is_string($arg)) {
+                        $ok = false;
+                    }
+                    break;
+                case 'boolean':
+                    if ($arg !== false && $arg !== true) {
+                        $ok = false;
+                    }
+                    break;
+                case 'float':
+                case 'double':
+                    if (!is_float($arg)) {
+                        $ok = false;
+                    }
+                    break;
+                case 'date':
+                case 'dateTime.iso8601':
+                    if (!is_a($arg, 'IXR_Date')) {
+                        $ok = false;
+                    }
+                    break;
+            }
+            if (!$ok) {
+                return new IXR_Error(-32602, 'server error. invalid method parameters');
+            }
+        }
+        // It passed the test - run the "real" method call
+        return parent::call($methodname, $argsbackup);
+    }
+    function methodSignature($method) {
+        if (!$this->hasMethod($method)) {
+            return new IXR_Error(-32601, 'server error. requested method "'.$method.'" not specified.');
+        }
+        // We should be returning an array of types
+        $types = $this->signatures[$method];
+        $return = array();
+        foreach ($types as $type) {
+            switch ($type) {
+                case 'string':
+                    $return[] = 'string';
+                    break;
+                case 'int':
+                case 'i4':
+                    $return[] = 42;
+                    break;
+                case 'double':
+                    $return[] = 3.1415;
+                    break;
+                case 'dateTime.iso8601':
+                    $return[] = new IXR_Date(time());
+                    break;
+                case 'boolean':
+                    $return[] = true;
+                    break;
+                case 'base64':
+                    $return[] = new IXR_Base64('base64');
+                    break;
+                case 'array':
+                    $return[] = array('array');
+                    break;
+                case 'struct':
+                    $return[] = array('struct' => 'struct');
+                    break;
+            }
+        }
+        return $return;
+    }
+    function methodHelp($method) {
+        return $this->help[$method];
+    }
+}
+
+
+class IXR_ClientMulticall extends IXR_Client {
+    var $calls = array();
+    function IXR_ClientMulticall($server, $path = false, $port = 80) {
+        parent::IXR_Client($server, $path, $port);
+        $this->useragent = 'The Incutio XML-RPC PHP Library (multicall client)';
+    }
+    function addCall() {
+        $args = func_get_args();
+        $methodName = array_shift($args);
+        $struct = array(
+            'methodName' => $methodName,
+            'params' => $args
+        );
+        $this->calls[] = $struct;
+    }
+    function query() {
+        // Prepare multicall, then call the parent::query() method
+        return parent::query('system.multicall', $this->calls);
+    }
+}
+
+?>
\ No newline at end of file
diff --git a/class.ActionResults.php b/class.ActionResults.php
new file mode 100644 (file)
index 0000000..6c91246
--- /dev/null
@@ -0,0 +1,31 @@
+<?php
+
+require_once(dirname(__FILE__)."/iface.ActionResult.php");
+
+class Ok implements IActionResult
+{
+    public function __construct($code)
+    {
+    }
+
+    public function render()
+    {
+       
+    }
+}
+
+class HtmlResult implements IActionResult
+{
+    private $text;
+    public function __construct($_text)
+    {
+       $this->text = $_text;
+    }
+
+    public function render()
+    {
+       echo $this->text;
+    }
+}
+
+?>
diff --git a/class.chiffre_lettre.php b/class.chiffre_lettre.php
new file mode 100644 (file)
index 0000000..37553ca
--- /dev/null
@@ -0,0 +1,204 @@
+<?php
+/**
+ * Description of chiffreEnLettre
+ * source : http://www.javascriptfr.com/codes/CONVERSION-CHIFFRE-MONETAIRE-LETTRE_30141.aspx
+ * @author PHP : adrien (http://blog.toolix.net/convertir-un-chiffre-en-lettres-classe-php-pour-facture-ou-cheque.html)
+ * Conversion limitée à 999 999 999 999 999 ou 9 999 999 999 999,99
+ * si le nombre contient plus de 2 décimales, il est arrondit à 2 décimales
+ */
+class chiffreEnLettre {
+    /**
+    * fonction permettant de transformer une valeur numérique en valeur en lettre
+    * @param int $Nombre le nombre a convertir
+    * @param int $Devise (0 = aucune, 1 = Euro €, 2 = Dollar $)
+    * @param int $Langue (0 = Français, 1 = Belgique, 2 = Suisse)
+    * @return string la chaine
+    */
+    public function ConvNumberLetter($Nombre, $Devise, $Langue) {
+        $dblEnt=''; $byDec='';
+        $bNegatif='';
+        $strDev = '';
+            $strCentimes = '';
+
+        if( $Nombre < 0 ) {
+            $bNegatif = true;
+            $Nombre = abs($Nombre);
+
+        }
+        $dblEnt = intval($Nombre) ;
+            $byDec = round(($Nombre - $dblEnt) * 100) ;
+        if( $byDec == 0 ) {
+            if ($dblEnt > 999999999999999) {
+                return "#TropGrand" ;
+            }
+            }
+        else {
+            if ($dblEnt > 9999999999999.99) {
+                return "#TropGrand" ;
+            }
+            }
+            switch($Devise) {
+            case 0 :
+                if ($byDec > 0) $strDev = " virgule" ;
+                            break;
+            case 1 :
+                $strDev = " Euro" ;
+                if ($byDec > 0) $strCentimes = $strCentimes . " Cents" ;
+                            break;
+            case 2 :
+                $strDev = " Dollar" ;
+                if ($byDec > 0) $strCentimes = $strCentimes . " Cent" ;
+                            break;
+            }
+        if (($dblEnt > 1) && ($Devise != 0)) $strDev = $strDev . "s" ;
+
+            $NumberLetter = $this->ConvNumEnt(floatval($dblEnt), $Langue) . $strDev . " " . $this->ConvNumDizaine($byDec, $Langue) . $strCentimes ;
+            return $NumberLetter;
+    }
+
+    private function ConvNumEnt($Nombre, $Langue) {
+       $byNum=$iTmp=$dblReste='' ;
+       $StrTmp = '';
+       $NumEnt='' ;
+        $iTmp = $Nombre - (intval($Nombre / 1000) * 1000) ;
+        $NumEnt = $this->ConvNumCent(intval($iTmp), $Langue) ;
+        $dblReste = intval($Nombre / 1000) ;
+        $iTmp = $dblReste - (intval($dblReste / 1000) * 1000) ;
+        $StrTmp = $this->ConvNumCent(intval($iTmp), $Langue) ;
+        switch($iTmp) {
+            case 0 :
+                            break;
+            case 1 :
+                $StrTmp = "mille " ;
+                            break;
+            default :
+                $StrTmp = $StrTmp . " mille " ;
+        }
+        $NumEnt = $StrTmp . $NumEnt ;
+        $dblReste = intval($dblReste / 1000) ;
+        $iTmp = $dblReste - (intval($dblReste / 1000) * 1000) ;
+        $StrTmp = $this->ConvNumCent(intval($iTmp), $Langue) ;
+        switch($iTmp) {
+            case 0 :
+                            break;
+            case 1 :
+                $StrTmp = $StrTmp . " million " ;
+                            break;
+            default :
+                $StrTmp = $StrTmp . " millions " ;
+        }
+        $NumEnt = $StrTmp . $NumEnt ;
+        $dblReste = intval($dblReste / 1000) ;
+        $iTmp = $dblReste - (intval($dblReste / 1000) * 1000) ;
+        $StrTmp = $this->ConvNumCent(intval($iTmp), $Langue) ;
+            switch($iTmp) {
+            case 0 :
+                            break;
+            case 1 :
+                $StrTmp = $StrTmp . " milliard " ;
+                            break;
+            default :
+                $StrTmp = $StrTmp . " milliards " ;
+        }
+        $NumEnt = $StrTmp . $NumEnt ;
+        $dblReste = intval($dblReste / 1000) ;
+        $iTmp = $dblReste - (intval($dblReste / 1000) * 1000) ;
+        $StrTmp = $this->ConvNumCent(intval($iTmp), $Langue) ;
+            switch($iTmp) {
+            case 0 :
+                            break;
+            case 1 :
+                $StrTmp = $StrTmp . " billion " ;
+                            break;
+            default :
+                $StrTmp = $StrTmp . " billions " ;
+        }
+        $NumEnt = $StrTmp . $NumEnt ;
+        return $NumEnt;
+    }
+
+    private function ConvNumDizaine($Nombre, $Langue) {
+        $TabUnit=$TabDiz='';
+        $byUnit=$byDiz='' ;
+        $strLiaison = '' ;
+
+        $TabUnit = array("", "un", "deux", "trois", "quatre", "cinq", "six", "sept",
+            "huit", "neuf", "dix", "onze", "douze", "treize", "quatorze", "quinze",
+            "seize", "dix-sept", "dix-huit", "dix-neuf") ;
+        $TabDiz = array("", "", "vingt", "trente", "quarante", "cinquante",
+            "soixante", "soixante", "quatre-vingt", "quatre-vingt") ;
+        if ($Langue == 1) {
+            $TabDiz[7] = "septante" ;
+            $TabDiz[9] = "nonante" ;
+            }
+        else if ($Langue == 2) {
+            $TabDiz[7] = "septante" ;
+            $TabDiz[8] = "huitante" ;
+            $TabDiz[9] = "nonante" ;
+        }
+        $byDiz = intval($Nombre / 10) ;
+        $byUnit = $Nombre - ($byDiz * 10) ;
+        $strLiaison = "-" ;
+        if ($byUnit == 1) $strLiaison = " et " ;
+        switch($byDiz) {
+            case 0 :
+                $strLiaison = "" ;
+                            break;
+            case 1 :
+                $byUnit = $byUnit + 10 ;
+                $strLiaison = "" ;
+                            break;
+            case 7 :
+                if ($Langue == 0) $byUnit = $byUnit + 10 ;
+                            break;
+            case 8 :
+                if ($Langue != 2) $strLiaison = "-" ;
+                            break;
+            case 9 :
+                if ($Langue == 0) {
+                    $byUnit = $byUnit + 10 ;
+                    $strLiaison = "-" ;
+                }
+                            break;
+        }
+        $NumDizaine = $TabDiz[$byDiz] ;
+        if ($byDiz == 8 && $Langue != 2 && $byUnit == 0) $NumDizaine = $NumDizaine . "s" ;
+        if ($TabUnit[$byUnit] != "") {
+            $NumDizaine = $NumDizaine . $strLiaison . $TabUnit[$byUnit] ;
+            }
+        else {
+            $NumDizaine = $NumDizaine ;
+        }
+        return $NumDizaine;
+    }
+
+    private function ConvNumCent($Nombre, $Langue) {
+        $TabUnit='' ;
+        $byCent=$byReste='' ;
+        $strReste = '' ;
+        $NumCent='';
+        $TabUnit = array("", "un", "deux", "trois", "quatre", "cinq", "six", "sept","huit", "neuf", "dix") ;
+
+        $byCent = intval($Nombre / 100) ;
+        $byReste = $Nombre - ($byCent * 100) ;
+        $strReste = $this->ConvNumDizaine($byReste, $Langue);
+        switch($byCent) {
+            case 0 :
+                $NumCent = $strReste ;
+                            break;
+            case 1 :
+                if ($byReste == 0)
+                    $NumCent = "cent" ;
+                else
+                    $NumCent = "cent " . $strReste ;
+                break;
+            default :
+                if ($byReste == 0)
+                    $NumCent = $TabUnit[$byCent] . " cents" ;
+                else
+                    $NumCent = $TabUnit[$byCent] . " cent " . $strReste ;
+            }
+            return $NumCent;
+    }
+}
+?>
diff --git a/class.controler.php b/class.controler.php
new file mode 100644 (file)
index 0000000..2349564
--- /dev/null
@@ -0,0 +1,20 @@
+<?php
+
+
+/**
+ * @brief MVC pattern, Controler Base class.
+ * Implements the common operation for all controlers
+ *
+ *  
+ *
+ */
+class ControlerBase {
+
+    public __construct()
+    {
+    }
+
+
+}
+
+?>
diff --git a/class.crontab.php b/class.crontab.php
new file mode 100644 (file)
index 0000000..c0369cd
--- /dev/null
@@ -0,0 +1,31 @@
+<?php
+
+class Crontab {
+  var $filename ="/tmp/compta_cron.txt";
+  var $php     = "/usr/bin/php -q ";
+  var $data    = "";
+  function __construct() {
+  }
+
+  function doMonthly($job) {
+   $data = '30 7 15 * * '.$this->php." ".$job." 2>&1 >>NULL";
+   file_put_content($this->filename,$data,FILE_APPEND);
+  }
+  function doQuarterly($job) {
+   $data = '30 7 15 2,5,8,11 * '.$this->php." ".$job." 2>&1 >>NULL";
+    file_put_content($this->filename,$data,FILE_APPEND);
+
+  }
+  function doJob($job) {
+    file_put_content($this->filename,$this->data,FILE_APPEND);
+  }
+  function commit() {
+    exec("crontab ".$filename,$output,$result);
+    if ($result === 0) {
+    } else {
+      log_error("Failed commit cron jobs");
+    }
+  }
+}
+>
diff --git a/class.db.php b/class.db.php
new file mode 100644 (file)
index 0000000..5669200
--- /dev/null
@@ -0,0 +1,160 @@
+<?php
+
+
+/**
+ * @brief authentication will be checked against
+ * 
+ * Register a user 
+ * register statistics
+ * auth user
+ * upgrade profile
+ * upgrade services
+ * get groupes
+ * get users
+ *
+ */
+class Db {
+    protected $_r = Array( 'total_matches' => 0 
+        , 'records' => array ()
+        , 'result'  => ""
+    );
+        /* Request results */
+    /*
+     * @brief Database interface
+     */
+    function __construct($host,$user,$password,$dbname) {
+       /* Record version ... select VERSION();*/
+       $this->mysqli = new mysqli($host,$user,$password,$dbname);
+       if (! $this->mysqli->connect_errno) {
+           $this->mysqli->set_charset('utf8');
+       }
+    }
+
+    function __destructor() {
+        $this->mysqli->close();
+    }
+    function insert_id() {
+      return $this->mysqli->insert_id;
+    }
+    /**
+     * @brief Some sanetizing
+     */
+    function escape($values) {
+      if(is_array($values)) {
+        $values = array_map(array(&$this, 'escape'), $values);
+      } else {
+        /* Quote if not integer */
+        if ( !is_numeric($values) || $values{0} == '0' ) {
+              $values = "\"" .filter_var($values,FILTER_SANITIZE_STRING) . "\"";
+        }
+      }
+      return $values;    
+    } 
+
+    /**
+     * @brief seems to be used by church web site. I think 
+     * this function should be deprecated
+     *
+     */
+    function validateUser($user,$pwd ="") {
+      $u = $this->escape($user);
+      $p = $this->escape($pwd);
+      
+      $query="select * from annuaire_2004_pasteurs where mail = $u ;"; 
+      $result =$this->mysqli->query($query);
+      if (!$result) {
+        //echo "Query failed: $query\n".mysql_error();;
+        echo "Query failed: $query\n".$this->mysqli->error;
+        return false;
+      }
+
+      $result->close();
+      return false;
+    }
+    
+    /**
+     * @brief simple query into json result. 
+     * TODO: use mysqli driver instead of mysql
+     *
+     */
+    function doQuery($sql,$count = "") {
+        $ident = Array('total_matches' => 0 
+                          , 'records' => array ()
+                          , 'result' => ""
+                  );
+        if ($this->checkError("doQuery")) {
+            return $this->_r;
+        }  
+        $result = $this->mysqli->query($sql);
+        if ( ! ($result === false)  ) {
+          $i = 0;
+         while ($ident["records"][$i++] = $result->fetch_array(MYSQLI_ASSOC)) ;
+
+         $result->close();
+
+          // Stating version 5 of mysql the queries can be more
+          // sofiticated
+          if ($count != "" ) {
+              $result = $this->query($count);
+              $row    =  $result->fetch_array();
+              $ident["total_matches"] = (int)$row[0];
+              $result->close();
+          }
+        }
+        return $ident;
+    }
+    /**
+     */
+    function doQueryI($sql,$count = "") {
+        $ident = Array('total_matches' => 0 , 'records' => array (),'result' => "");
+        if ($this->checkError("doQueryI")) {
+            return $this->_r;
+        }  
+        $qr = $this->mysqli->multi_query($sql);
+        $i = 0;
+       if (! ($qr === false ))
+               {
+          do {       
+              if ($result = $this->mysqli->store_result()) {
+                  while ($row = $result->fetch_row()) {
+                      $ident["records"][$i++] = $row;
+                  }
+                  $result->free();
+              } 
+
+              // Stating version 5 of mysql the queries can be more
+              // sofiticated
+          } while($this->mysqli->next_result());
+          $ident['total_matches'] = $i;
+        } else {
+          error_log("doQuery ".$sql." Failed:".$this->mysqli->error,0);
+          $ident['result']="Failed :".$this->mysqli->error;
+        }
+        return $ident;
+    }
+    /**
+     * @brief Simple helper function to check Db status before any request.
+     * Always return the appropriate error message.
+     */
+    function checkError($fct) {
+        if ($this->mysqli->connect_errno) {
+            $this->_r['result']="Failed :".$this->mysqli->error;
+            error_log("Db::".$fct." ".$this->mysqli->error);
+            return true;
+        }
+        return false;
+    }
+    /**
+     * @brief call this function after each request to check if an error
+     * happened or not. It's safer that checking the number of returned
+     * values.
+     */
+    function checkQueryError() {
+    }
+
+    function cleanDb() {
+    }
+}
+
+?>
diff --git a/class.feed.php b/class.feed.php
new file mode 100644 (file)
index 0000000..bf851be
--- /dev/null
@@ -0,0 +1,369 @@
+<?php
+
+
+/**
+ *
+ *
+ */
+class FeedItem {
+    var $title,$description,$link;
+    /* Optional attributes */
+    var $author,$authorEmail,$image,$category,$comments,$source,$guid;
+    var $date;
+    /**
+     * For multimedia purpose, add enclosure
+     */
+    var $enclosure;
+    function FeedItem {
+    }
+
+}
+
+/**
+ *
+ */
+class FeedEnclosure {
+  var $url,$length,$type;
+}
+
+
+/**
+ *
+ */
+class FeedImage {
+    /**
+     * Mandatory attributes of an image.
+     */
+    var $title, $url, $link;
+
+    /**
+     * Optional attributes of an image.
+     */
+    var $width, $height, $description;
+}
+
+/**
+ * FeedDate is an internal class that stores a date for a feed or feed item.
+ * Usually, you won't need to use this.
+ */
+class FeedDate {
+    var $unix;
+
+    /**
+     * Creates a new instance of FeedDate representing a given date.
+     * Accepts RFC 822, ISO 8601 date formats as well as unix time stamps.
+     * @param mixed $dateString optional the date this FeedDate will represent. If not specified, the current date and time is used.
+     */
+    function FeedDate($dateString="") {
+        if ($dateString=="") $dateString = date("r");
+
+        if (is_numeric($dateString)) {
+            $this->unix = $dateString;
+            return;
+        }
+        if (preg_match("~(?:(?:Mon|Tue|Wed|Thu|Fri|Sat|Sun),\\s+)?(\\d{1,2})\\s+([a-zA-Z]{3})\\s+(\\d{4})\\s+(\\d{2}):(\\d{2}):(\\d{2})\\s+(.*)~",$dateString,$matches)) {
+            $months = Array("Jan"=>1,"Feb"=>2,"Mar"=>3,"Apr"=>4,"May"=>5,"Jun"=>6,"Jul"=>7,"Aug"=>8,"Sep"=>9,"Oct"=>10,"Nov"=>11,"Dec"=>12);
+            $this->unix = mktime($matches[4],$matches[5],$matches[6],$months[$matches[2]],$matches[1],$matches[3]);
+            if (substr($matches[7],0,1)=='+' OR substr($matches[7],0,1)=='-') {
+                $tzOffset = (substr($matches[7],0,3) * 60 + substr($matches[7],-2)) * 60;
+            } else {
+                if (strlen($matches[7])==1) {
+                    $oneHour = 3600;
+                    $ord = ord($matches[7]);
+                    if ($ord < ord("M")) {
+                        $tzOffset = (ord("A") - $ord - 1) * $oneHour;
+                    } elseif ($ord >= ord("M") AND $matches[7]!="Z") {
+                        $tzOffset = ($ord - ord("M")) * $oneHour;
+                    } elseif ($matches[7]=="Z") {
+                        $tzOffset = 0;
+                    }
+                }
+                switch ($matches[7]) {
+                    case "UT":
+                    case "GMT": $tzOffset = 0;
+                }
+            }
+            $this->unix += $tzOffset;
+            return;
+        }
+        if (preg_match("~(\\d{4})-(\\d{2})-(\\d{2})T(\\d{2}):(\\d{2}):(\\d{2})(.*)~",$dateString,$matches)) {
+            $this->unix = mktime($matches[4],$matches[5],$matches[6],$matches[2],$matches[3],$matches[1]);
+            if (substr($matches[7],0,1)=='+' OR substr($matches[7],0,1)=='-') {
+                $tzOffset = (substr($matches[7],0,3) * 60 + substr($matches[7],-2)) * 60;
+            } else {
+                if ($matches[7]=="Z") {
+                    $tzOffset = 0;
+                }
+            }
+            $this->unix += $tzOffset;
+            return;
+        }
+        $this->unix = 0;
+    }
+
+    /**
+     * Gets the date stored in this FeedDate as an RFC 822 date.
+     *
+     * @return a date in RFC 822 format
+     */
+    function rfc822() {
+        //return gmdate("r",$this->unix);
+        $date = gmdate("D, d M Y H:i:s", $this->unix);
+        if (TIME_ZONE!="") $date .= " ".str_replace(":","",TIME_ZONE);
+        return $date;
+    }
+
+    /**
+     * Gets the date stored in this FeedDate as an ISO 8601 date.
+     *
+     * @return a date in ISO 8601 (RFC 3339) format
+     */
+    function iso8601() {
+        $date = gmdate("Y-m-d\TH:i:sO",$this->unix);
+        if (TIME_ZONE!="") $date = str_replace("+0000",TIME_ZONE,$date);
+        $date = substr($date,0,22) . ':' . substr($date,-2);
+        return $date;
+    }
+
+
+    /**
+     * Gets the date stored in this FeedDate as unix time stamp.
+     *
+     * @return a date as a unix time stamp
+     */
+    function unix() {
+        return $this->unix;
+    }
+}
+
+
+/**
+ * \brief Feed Creator classs
+ *
+ */
+class FeedCreator {
+    var $title,$description,$link;
+    var $contentType    = "application/xml";
+    var $encoding       = "utf-8";
+    /**
+     * Should not be accessed 
+     */
+    var $items = Array();
+
+    /**
+     * \brief adds FeedItem to the feed;
+     * 
+     * \param $item the FeedItem to be acced
+     */
+    function addItem($item) {
+        $this->items[] = $item;
+    }
+
+    /**
+     * \brief createFeed 
+     */
+    function createFeed() {
+    }
+
+    /**
+     *
+     */
+    function _redirect($filename) {
+        header("Content-Type:".$this->contentType."; charset=".$this->encoding."; filename=".basename($filename));
+        header("Content-Disposition: inline; filename=".basename($filename));
+        readfile($filename,"r";
+        die();
+    }
+
+    /**
+     *
+     */
+    function output() {
+        echo $this->createFeed();
+    }
+}
+
+/**
+ * RSSCreator091 is a FeedCreator that implements RSS 0.91 Spec, revision 3.
+ *
+ * @see http://my.netscape.com/publish/formats/rss-spec-0.91.html
+ * @since 1.3
+ * @author Kai Blankenhorn <kaib@bitfolge.de>
+ */
+class RSSCreator091 extends FeedCreator {
+
+    /**
+     * Stores this RSS feed's version number.
+     * @access private
+     */
+    var $RSSVersion;
+
+    function RSSCreator091() {
+        $this->_setRSSVersion("0.91");
+        $this->contentType = "application/rss+xml";
+    }
+
+    /**
+     * Sets this RSS feed's version number.
+     * @access private
+     */
+    function _setRSSVersion($version) {
+        $this->RSSVersion = $version;
+    }
+
+    /**
+     * Builds the RSS feed's text. The feed will be compliant to RDF Site Summary (RSS) 1.0.
+     * The feed will contain all items previously added in the same order.
+     * @return    string    the feed's complete text
+     */
+    function createFeed() {
+        $feed = "<?xml version=\"1.0\" encoding=\"".$this->encoding."\"?>\n";
+        $feed.= $this->_createGeneratorComment();
+        $feed.= $this->_createStylesheetReferences();
+        $feed.= "<rss version=\"".$this->RSSVersion."\">\n";
+        $feed.= "    <channel>\n";
+        $feed.= "        <title>".FeedCreator::iTrunc(htmlspecialchars($this->title),100)."</title>\n";
+        $this->descriptionTruncSize = 500;
+        $feed.= "        <description>".$this->getDescription()."</description>\n";
+        $feed.= "        <link>".$this->link."</link>\n";
+        $now = new FeedDate();
+        $feed.= "        <lastBuildDate>".htmlspecialchars($now->rfc822())."</lastBuildDate>\n";
+        $feed.= "        <generator>".FEEDCREATOR_VERSION."</generator>\n";
+
+        if ($this->image!=null) {
+            $feed.= "        <image>\n";
+            $feed.= "            <url>".$this->image->url."</url>\n";
+            $feed.= "            <title>".FeedCreator::iTrunc(htmlspecialchars($this->image->title),100)."</title>\n";
+            $feed.= "            <link>".$this->image->link."</link>\n";
+            if ($this->image->width!="") {
+                $feed.= "            <width>".$this->image->width."</width>\n";
+            }
+            if ($this->image->height!="") {
+                $feed.= "            <height>".$this->image->height."</height>\n";
+            }
+            if ($this->image->description!="") {
+                $feed.= "            <description>".$this->image->getDescription()."</description>\n";
+            }
+            $feed.= "        </image>\n";
+        }
+        if ($this->language!="") {
+            $feed.= "        <language>".$this->language."</language>\n";
+        }
+        if ($this->copyright!="") {
+            $feed.= "        <copyright>".FeedCreator::iTrunc(htmlspecialchars($this->copyright),100)."</copyright>\n";
+        }
+        if ($this->editor!="") {
+            $feed.= "        <managingEditor>".FeedCreator::iTrunc(htmlspecialchars($this->editor),100)."</managingEditor>\n";
+        }
+        if ($this->webmaster!="") {
+            $feed.= "        <webMaster>".FeedCreator::iTrunc(htmlspecialchars($this->webmaster),100)."</webMaster>\n";
+        }
+        if ($this->pubDate!="") {
+            $pubDate = new FeedDate($this->pubDate);
+            $feed.= "        <pubDate>".htmlspecialchars($pubDate->rfc822())."</pubDate>\n";
+        }
+        if ($this->category!="") {
+            // Changed for DokuWiki: multiple categories are possible
+            if(is_array($this->category)) foreach($this->category as $cat){
+                $feed.= "        <category>".htmlspecialchars($cat)."</category>\n";
+            }else{
+                $feed.= "        <category>".htmlspecialchars($this->category)."</category>\n";
+            }
+        }
+        if ($this->docs!="") {
+            $feed.= "        <docs>".FeedCreator::iTrunc(htmlspecialchars($this->docs),500)."</docs>\n";
+        }
+        if ($this->ttl!="") {
+            $feed.= "        <ttl>".htmlspecialchars($this->ttl)."</ttl>\n";
+        }
+        if ($this->rating!="") {
+            $feed.= "        <rating>".FeedCreator::iTrunc(htmlspecialchars($this->rating),500)."</rating>\n";
+        }
+        if ($this->skipHours!="") {
+            $feed.= "        <skipHours>".htmlspecialchars($this->skipHours)."</skipHours>\n";
+        }
+        if ($this->skipDays!="") {
+            $feed.= "        <skipDays>".htmlspecialchars($this->skipDays)."</skipDays>\n";
+        }
+        $feed.= $this->_createAdditionalElements($this->additionalElements, "    ");
+
+        for ($i=0;$i<count($this->items);$i++) {
+            $feed.= "        <item>\n";
+            $feed.= "            <title>".FeedCreator::iTrunc(htmlspecialchars(strip_tags($this->items[$i]->title)),100)."</title>\n";
+            $feed.= "            <link>".htmlspecialchars($this->items[$i]->link)."</link>\n";
+            $feed.= "            <description>".$this->items[$i]->getDescription()."</description>\n";
+
+            if ($this->items[$i]->author!="") {
+                $feed.= "            <author>".htmlspecialchars($this->items[$i]->author)."</author>\n";
+            }
+            /*
+            // on hold
+            if ($this->items[$i]->source!="") {
+                    $feed.= "            <source>".htmlspecialchars($this->items[$i]->source)."</source>\n";
+            }
+            */
+            if ($this->items[$i]->category!="") {
+                // Changed for DokuWiki: multiple categories are possible
+                if(is_array($this->items[$i]->category)) foreach($this->items[$i]->category as $cat){
+                    $feed.= "        <category>".htmlspecialchars($cat)."</category>\n";
+                }else{
+                    $feed.= "        <category>".htmlspecialchars($this->items[$i]->category)."</category>\n";
+                }
+            }
+
+            if ($this->items[$i]->comments!="") {
+                $feed.= "            <comments>".htmlspecialchars($this->items[$i]->comments)."</comments>\n";
+            }
+            if ($this->items[$i]->date!="") {
+            $itemDate = new FeedDate($this->items[$i]->date);
+                $feed.= "            <pubDate>".htmlspecialchars($itemDate->rfc822())."</pubDate>\n";
+            }
+            if ($this->items[$i]->guid!="") {
+                $feed.= "            <guid>".htmlspecialchars($this->items[$i]->guid)."</guid>\n";
+            }
+            $feed.= $this->_createAdditionalElements($this->items[$i]->additionalElements, "        ");
+
+            if ($this->RSSVersion == "2.0" && $this->items[$i]->enclosure != NULL)
+                {
+                                $feed.= "            <enclosure url=\"";
+                                $feed.= $this->items[$i]->enclosure->url;
+                                $feed.= "\" length=\"";
+                                $feed.= $this->items[$i]->enclosure->length;
+                                $feed.= "\" type=\"";
+                                $feed.= $this->items[$i]->enclosure->type;
+                                $feed.= "\"/>\n";
+                        }
+
+
+
+            $feed.= "        </item>\n";
+        }
+
+        $feed.= "    </channel>\n";
+        $feed.= "</rss>\n";
+        return $feed;
+    }
+}
+
+
+
+/**
+ * RSSCreator20 is a FeedCreator that implements RDF Site Summary (RSS) 2.0.
+ *
+ * @see http://backend.userland.com/rss
+ * @since 1.3
+ * @author Kai Blankenhorn <kaib@bitfolge.de>
+ */
+class RSSCreator20 extends RSSCreator091 {
+
+    function RSSCreator20() {
+        parent::_setRSSVersion("2.0");
+    }
+
+}
+
+
+/**
+    vim:et:ts=4:sw=4:enc=utf-8:
+ */
+?>
diff --git a/class.form.php b/class.form.php
new file mode 100644 (file)
index 0000000..9a9aa5d
--- /dev/null
@@ -0,0 +1,261 @@
+<?php
+
+/**
+ * @brief  a hidden and generic input field
+ *
+ *
+ */
+class FormInput {
+    var $name;
+    var $id;
+    var $value;
+    var $class = "";
+    var $type = "hidden";
+    var $lWidth = 0;
+    var $iWidth = 0;
+    var $iSize  =30;
+    var $imaxLength;
+    var $placeholder = "";
+    var $icon        = "";
+    var $onClick ="";
+    function FormInput($name="",$value="",$label="",$id="") {
+            $this->name = $name;
+            $this->id   = $id;
+            $this->value= $value;
+            $this->label= $label;
+            $this->icon = "";
+    }
+    function showLabel() {
+        if ($this->type == "hidden")
+            return;
+        if ($this->label != "") {
+            echo "<label for='".$this->name."' ";
+            if ($this->lWidth > 0) {
+            echo "size='".$this->lWidth."'";
+            }
+            echo ">".$this->label."</label>";
+        }
+    }
+
+    function show()
+    {
+        $this->showLabel();
+        if ( ! empty ($this->icon) ) {
+          echo "<span class=\"input-icon\">\n";
+        }
+        echo "<input type='".$this->type."' size='".$this->iSize."'";
+        if ($this->onClick != "") {
+          echo " onclick='".$this->onClick."' ";
+        }
+        if ($this->placeholder != "") {
+          echo " placeholder='".$this->placeholder."' ";
+        }
+        if ($this->class != "") {
+          echo " class='".$this->class."' ";
+        }
+        echo " name='".$this->name."' value='".$this->value."' id='".$this->name."'>\n";
+        if ( !empty($this->icon)) {
+          echo "<i class=\"fa ".$this->icon."\"></i></span>\n";
+        }
+    }
+    function setIcon($_i="") {$this->icon = $_i;}
+    function setClass($class= "") { $this->class = $class;}
+    function setWidth($l,$i) {$this->lWidth=$l;$this->iWith=$i;}
+    function setSize($s,$ml=0) {$this->iSize = $s;}
+} 
+
+/**
+ * @brief 
+ *
+ *
+ */
+class FormInputText extends FormInput{
+    function FormInputText($name,$value,$label="",$id="") {
+       parent::FormInput($name,$value,$label,$id);
+        $this->type="text";
+    }
+}
+
+/**
+ * @brief 
+ *
+ *
+ */
+class FormInputPassword extends FormInput{
+    function FormInputPassword($name,$value,$label="",$id="") {
+        parent::FormInput($name,$value,$label,$id);
+        $this->type="password";
+    }
+}
+
+/**
+ * @brief
+ *
+ */
+class FormInputTextArea extends FormInput{
+    var $rows = 5;
+    var $columns = 20;    
+    function FormInputTextArea($name,$v="",$l="",$i="") {
+        parent::FormInput($name,$v,$l,$i);
+    }
+    function setSize($rows,$c = 0) {
+        $this->rows = $rows;
+        $this->columns = $c;
+    }
+
+    function show() {
+        $this->showLabel();
+        echo "<textarea name='".$this->name."' rows='".$this->rows."' cols='".$this->columns."'>".$this->value."</textarea>";
+    }
+}
+
+
+/**
+ *
+ *
+ */
+class FormInputCheckbox extends FormInput {
+    var $checked = 0;
+    function FormInputCheckbox($n,$v=0,$l="",$i="") {
+        parent::FormInput($n,$v,$l,$i);
+        $this->type='checkbox';
+        $this->checked=$v;
+    }
+    function show()
+    {
+        $this->showLabel();
+        echo "<input type='".$this->type."' size='".$this->iSize."' name='".$this->name."' value='".$this->value."' id='".$this->name."' ";
+        if ($this->checked) {
+            echo "checked";
+        }
+        echo ">\n";
+    }
+}
+/**
+ *
+ *
+ *
+ */
+class FormInputButton extends FormInput {
+    function FormInputButton($n,$v,$l,$i) {
+       parent::FormInput($n,$v,$l,$i);
+        $this->type='button';
+    }
+}
+
+class FormInputSubmit extends FormInput {
+    function FormInputSubmit($n,$v="",$l="",$i="") {
+        parent::FormInput($n,$v,$l,$i);
+        $this->type='submit';
+    }
+}
+
+class FormInputFile extends FormInput {
+    function __construct($n,$v="",$l="",$i="") {
+        parent::FormInput($n,$v,$l,$i);
+        $this->type='file';
+    }
+}
+/**
+ * \brief This class defines an option for the select input.
+ * \author EBERSOLD Andre
+ * \date   29/08/08
+ */
+class FormSelectOption {
+    var $selected,$value,$label;
+    /**
+     *
+     */
+    function __construct($label,$value,$selected=false) {
+        $this->label=$label;$this->value=$value;$this->selected=$selected;
+    }
+    /**
+     *  \brief default show function 
+     *
+     */
+    function show() {
+        echo "<option ";
+        echo ($this->selected)?"SELECTED value=":"value='".$this->value."'>".$this->label."</option>";
+    }
+}
+
+/**
+ * @brief  The Select field 
+ */
+class FormSelect {
+    var $options,$selection,$size;
+    var $tabindex,$disabled,$name;
+    /**
+     * Default constructor 
+     * an option is 'selected' and has a 'value'
+     */
+    function __construct($name,$options=Array()) {
+        $this->tabindex  = 0;
+        $this->selection = false;
+        $this->size      = 10;
+        $this->name      = $name;
+        $this->options   = $options;
+    }
+
+    /**
+     * @brief Show function that echo's the selection field
+     *
+     */
+    function show() {
+        echo "<select name='".$this->name."' ";
+        echo ($this->selection == true)?"MULTIPLE>":">";
+        foreach ($this->options as $option) {
+            $option->show();
+        }
+        echo "</select>";
+    }
+}
+
+/**
+ * @brief a formulare 
+ *
+ */
+class Form {
+    var $method ="POST";
+    var $action = "";
+    var $inputs = Array();
+    var $count = 0;
+    var $class = "";
+    var $id ="";
+    var $encode = "multipart/form-data";
+    var $onSubmit ="";
+
+    function Form($action = "",$method = "POST") {
+        if ($action != "") {
+            $this->action=$action;
+        }
+        $this->method = $method;
+    }
+    
+    function setClass($class= "") { $this->class = $class;}
+
+    function addInput($input) {
+        $this->inputs[$this->count++] = $input;
+    }
+
+    function show() {
+        if ( $this->id == "") {
+          echo "<form  action='".$this->action."' method='".$this->method."' enctype='".$this->encode."'>\n";
+        } else {
+          echo "<form id='",$this->id,"' action='".$this->action."' method='".$this->method."' enctype='".$this->encode."'>\n";
+        }
+        
+        echo "<fieldset class='".$this->class."'>";
+        echo "<span class='group1 tr'><span class='group1 tc'> <span class='tl'></span></span></span><span class='group1 cn'>";
+        foreach ($this->inputs as $input) {
+          $input->show();
+        }
+        echo "</span><span class='group1 br'><span class='group1 bc'> <span class='bl'></span></span></span>";
+        echo "</fieldset>";
+        echo "</form>\n";
+    }
+}
+/*
+  vim:syntax on:et:list:sw=4:ts=4
+ */
+?>
diff --git a/class.fpdfdb.php b/class.fpdfdb.php
new file mode 100644 (file)
index 0000000..0e0a3c0
--- /dev/null
@@ -0,0 +1,165 @@
+<?php
+
+require_once(dirname(__FILE__)."/fpdf/fpdf.php");
+
+class fpdfDb extends FPDF {
+
+    var $_dbname   = "";
+    var $_host     = "";
+    var $_password = "";
+    var $_user     = "";
+    var $conn     = null;
+    function __construct($host,$user,$password,$dbname) {
+       //$this->conn = mysql_connect($host,$user,$password,false,65536);
+       //if (! $this->conn) {
+       //  echo "Could not connect to $host as $user\n";
+       //}
+       $this->_dbname   = $dbname;
+       $this->_host     = $host;
+       $this->_password = $password;
+       $this->_user     = $user;
+       
+       //mysql_select_db($dbname,$this->conn);
+       //mysql_query("SET NAMES 'utf8'");
+       /* Record version ... select VERSION();*/
+       if (version_compare(PHP_VERSION,'5.4.0','>')) {
+         ini_set('magic_quotes_runtime',0);
+       }
+       parent::FPDF();
+
+       $this->mysqli = new mysqli($host,$user,$password,$dbname);
+       $this->mysqli->set_charset('utf-8');
+    }
+    
+    function __destruct () {
+        if ($this->conn != null) {
+            $this->cleanDb();
+        }
+        //if (defined($this->mysqli)) {
+            $this->mysqli->close();
+        //}
+    }
+
+    /**
+     *
+     *
+     *
+     */
+    function doQuery($sql,$count = "") {
+        $ident = Array('total_matches' => 0 , 'records' => array ());
+        //$result = mysql_query($sql,$this->conn);
+        $result = $this->mysqli->query($sql);
+        if ($result ) {
+          $i = 0;
+          //while ($ident["records"][$i++] = mysql_fetch_array($result,MYSQL_ASSOC)) ;
+          //mysql_free_result($result);
+          while ($ident["records"][$i++] = $result->fetch_array(MYSQLI_ASSOC)) ;
+          $result->close() ;
+          $ident['total_matches'] = $i;
+          // Stating version 5 of mysql the queries can be more
+          // sofiticated
+          if ($count != "" ) {
+            //$result = mysql_query($count,$this->conn);
+            //$row=  mysql_fetch_row($result);
+            $result = $this->mysqli->query($count);
+            $row    =  $result->fetch_array();
+            $ident["total_matches"] = (int)$row[0];
+            //mysql_free_result($result);
+            $result->close();
+          }
+        } else {
+          error_log("doQuery ".$sql." Failed:".mysql_error(),0);
+          $ident['result']="Failed";
+        }
+        return $ident;
+    }
+
+    function doQueryImpr($sql,$count = "") {
+        $ident = Array('total_matches' => 0 , 'records' => array ());
+        $qr = $this->mysqli->multi_query($sql);
+        $i = 0;
+        if ($qr ) {
+          do {       
+            if ($result = $this->mysqli->store_result()) {
+                while ($row = $result->fetch_row()) {
+                    $ident["records"][$i++] = $row;
+                }
+                $result->free();
+            } 
+
+          $ident['total_matches'] = $i;
+          // Stating version 5 of mysql the queries can be more
+          // sofiticated
+          } while($this->mysqli->next_result());
+        } else {
+          error_log("doQuery ".$sql." Failed:".$this->mysqli->error,0);
+          $ident['result']="Failed";
+        }
+        return $ident;
+    }
+
+    function cleanDb() {
+        mysql_close($this->conn);
+        unset($this->conn);
+    }
+
+  function RoundedRect($x, $y, $w, $h, $r, $corners = '1234', $style = '')
+    {
+        $k = $this->k;
+        $hp = $this->h;
+        if($style=='F')
+            $op='f';
+        elseif($style=='FD' || $style=='DF')
+            $op='B';
+        else
+            $op='S';
+        $MyArc = 4/3 * (sqrt(2) - 1);
+        $this->_out(sprintf('%.2F %.2F m',($x+$r)*$k,($hp-$y)*$k ));
+
+        $xc = $x+$w-$r;
+        $yc = $y+$r;
+        $this->_out(sprintf('%.2F %.2F l', $xc*$k,($hp-$y)*$k ));
+        if (strpos($corners, '2')===false)
+            $this->_out(sprintf('%.2F %.2F l', ($x+$w)*$k,($hp-$y)*$k ));
+        else
+            $this->_Arc($xc + $r*$MyArc, $yc - $r, $xc + $r, $yc - $r*$MyArc, $xc + $r, $yc);
+
+        $xc = $x+$w-$r;
+        $yc = $y+$h-$r;
+        $this->_out(sprintf('%.2F %.2F l',($x+$w)*$k,($hp-$yc)*$k));
+        if (strpos($corners, '3')===false)
+            $this->_out(sprintf('%.2F %.2F l',($x+$w)*$k,($hp-($y+$h))*$k));
+        else
+            $this->_Arc($xc + $r, $yc + $r*$MyArc, $xc + $r*$MyArc, $yc + $r, $xc, $yc + $r);
+
+        $xc = $x+$r;
+        $yc = $y+$h-$r;
+        $this->_out(sprintf('%.2F %.2F l',$xc*$k,($hp-($y+$h))*$k));
+        if (strpos($corners, '4')===false)
+            $this->_out(sprintf('%.2F %.2F l',($x)*$k,($hp-($y+$h))*$k));
+        else
+            $this->_Arc($xc - $r*$MyArc, $yc + $r, $xc - $r, $yc + $r*$MyArc, $xc - $r, $yc);
+
+        $xc = $x+$r ;
+        $yc = $y+$r;
+        $this->_out(sprintf('%.2F %.2F l',($x)*$k,($hp-$yc)*$k ));
+        if (strpos($corners, '1')===false)
+        {
+            $this->_out(sprintf('%.2F %.2F l',($x)*$k,($hp-$y)*$k ));
+            $this->_out(sprintf('%.2F %.2F l',($x+$r)*$k,($hp-$y)*$k ));
+        }
+        else
+            $this->_Arc($xc - $r, $yc - $r*$MyArc, $xc - $r*$MyArc, $yc - $r, $xc, $yc - $r);
+        $this->_out($op);
+    }
+
+    function _Arc($x1, $y1, $x2, $y2, $x3, $y3)
+    {
+        $h = $this->h;
+        $this->_out(sprintf('%.2F %.2F %.2F %.2F %.2F %.2F c ', $x1*$this->k, ($h-$y1)*$this->k,
+            $x2*$this->k, ($h-$y2)*$this->k, $x3*$this->k, ($h-$y3)*$this->k));
+    }
+
+}
+
+?>
diff --git a/class.http.Request.php b/class.http.Request.php
new file mode 100644 (file)
index 0000000..4d993db
--- /dev/null
@@ -0,0 +1,169 @@
+<?php
+
+require_once(dirname(__FILE__)."/iface.Request.php");
+
+/**
+ * @brief Implements methods to facilitate 
+ * Http request processing on server side.
+ *
+ */
+class Request implements ArrayAccess,IRequest 
+{
+    private $data = [];
+
+    private $allowedKeys = Array('post','urlParams','get');
+    /**
+     *
+     */
+    function __construct(array $vars = [])
+    {
+        foreach($this->allowedKeys as $k)
+        {
+            $this->data = isset($vars[$k])?\array_merge($this->data,$vars[$k]):$this->data;
+        }
+    }
+
+    /**
+     * implement ArrayAccess method
+     *
+     */
+    public function offsetSet($offset,$value)
+    {
+        if (is_null($offset))
+        {
+            $this->data[] = $value;
+        } else
+        {
+            $this->data[$offset] = $value;
+        }
+    }
+
+    /**
+     * implement ArrayAccess method
+     *
+     */
+    public function offsetExists($offet)
+    {
+        return isset($this->data[$offset]);
+    }
+
+    /**
+     * implement ArrayAccess method
+     *
+     */
+    public function offsetUnset($offset)
+    {
+        unset($this->data[$offset]);
+    }
+
+    /**
+     * implement ArrayAccess method
+     *
+     */
+    public function offsetGet($offset)
+    {
+        return isset($this->data[$offset]) ? $this->data[$offset] : null;
+    }
+
+
+    /**
+     * implement IRequest method
+     *
+     */
+    public function getHeader($name)
+    {
+    }
+
+    /**
+     * Lets you access post and get parameters by the index
+     * In case of json requests the encoded json body is accessed
+     *
+     * @param string $key the key which you want to access in the URL Parameter
+     *                     placeholder, $_POST or $_GET array.
+     *                     The priority how they're returned is the following:
+     *                     1. URL parameters
+     *                     2. POST parameters
+     *                     3. GET parameters
+     * @param mixed $default If the key is not found, this value will be returned
+     * @return mixed the content of the array
+     * @since 6.0.0
+     */
+    public function getParam($key, $default = null)
+    {
+        if ( isset($_GET[$key]) )
+        {
+             return $_GET[$key] ;
+        } 
+        elseif ( isset($_POST[$key]) )
+        {
+            return $_POST[$key] ;
+        } 
+        else
+        {
+            return $default;
+        }
+
+    }
+
+    /**
+     *
+     * @return string the server host
+     */
+    public function getServerHost()
+    {
+        $host = "localhost";
+        if (isset($_SERVER['HTTP_X_FORWARDED_HOST']))
+        {
+        } else
+        {
+            if (isset($_SERVER['HTTP_HOST'])) 
+            {
+                $host = $_SERVER['HTTP_HOST'];
+            } elseif (isset($_SERVER['SERVER_NAME'])) {
+                $host = $_SERVER['SERVER_NAME'];
+            }
+        }
+        return $host;
+
+    }
+    /**
+     * @brief return Client IP address even if server is behind a proxy
+     */
+    function remoteAddr() {
+      if (isset($_SERVER['HTTP_X_FORWARDED_FOR'] ))
+      { 
+        return $_SERVER['HTTP_X_FORWARDED_FOR'];
+      } else if (isset($_SERVER['REMOTE_ADDR'] )) {
+        return $_SERVER['REMOTE_ADDR'];
+      } else
+      {
+        return "0";
+      }
+    }
+    /**
+     *
+     */
+    public function getScheme()
+    {
+        $protocol = "http://";
+       if (isset($_SERVER['HTTPS']) &&
+           ($_SERVER['HTTPS'] == 'on' || $_SERVER['HTTPS'] == 1) ||
+           isset($_SERVER['HTTP_X_FORWARDED_PROTO']) &&
+           $_SERVER['HTTP_X_FORWARDED_PROTO'] == 'https') {
+         $protocol = 'https://';
+       }
+      return $protocol;   
+    }
+    
+    public function getMethod()
+    {
+        return $_SERVER['REQUEST_METHOD'];
+    }
+
+    public function getPathInfo()
+    {
+        return $_SERVER['PATH_INFO'];
+    }
+}
+
+?>
diff --git a/class.images.php b/class.images.php
new file mode 100644 (file)
index 0000000..de118aa
--- /dev/null
@@ -0,0 +1,124 @@
+<?php
+/* 
+ * vim:et:sw=2:ts=2 
+ */
+
+/**
+ *
+ *
+ */
+class Thumbnails {
+  var $src_folder = ".";
+  var $dst_folder = "./thumbs";
+  var $width  = 100;
+  var $height = 100;
+  /**
+   *
+   */
+  function __constructor($src_dir = ".",$dst_dir = "./thumbs" ,$width = 100,$height = 100)
+  {
+    $this->src_folder = $src_dir;
+    $this->dst_folder = $dst_dir;
+    $this->width      = $width;
+    $this->height     = $height;
+  }
+  /**
+   *
+   */
+  function do_batch()
+  {
+    $pics = $this->directory($this->src_folder,"jpg,JPG,JPEG,jpeg,mng,PNG");
+    $pics = $this->ditchtn($pics,"tn_"); /* remove thumbs from list */
+
+    foreach ($pics as $p) 
+    {
+      $this->createthumb($p,$dst_folder."/tn_".$p,$this->width,$this->height);
+    }
+  }
+
+  /**
+   *
+   */
+  function ditchtn($arr,$thumbname)
+  {
+    foreach ($arr as $item)
+    {
+      if (!preg_match("/^".$thumbname."/",$item)){$tmparr[]=$item;}
+    }
+    return $tmparr;
+  }
+
+  /*
+    Function createthumb($name,$filename,$new_w,$new_h)
+    creates a resized image
+    variables:
+    $name     Original filename
+    $filename Filename of the resized image
+    $new_w    width of resized image
+    $new_h    height of resized image
+  */
+  function createthumb($name,$filename,$new_w,$new_h)
+  {
+    $system=explode(".",$name);
+    if (preg_match("/jpg|jpeg/",$system[1])){$src_img=imagecreatefromjpeg($name);}
+    if (preg_match("/png/",$system[1])){$src_img=imagecreatefrompng($name);}
+    $old_x=imageSX($src_img);
+    $old_y=imageSY($src_img);
+    if ($old_x > $old_y) 
+    {
+      $thumb_w=$new_w;
+      $thumb_h=$old_y*($new_h/$old_x);
+    }
+    if ($old_x < $old_y) 
+    {
+      $thumb_w=$old_x*($new_w/$old_y);
+      $thumb_h=$new_h;
+    }
+    if ($old_x == $old_y) 
+    {
+      $thumb_w=$new_w;
+      $thumb_h=$new_h;
+    }
+    $dst_img=ImageCreateTrueColor($thumb_w,$thumb_h);
+    imagecopyresampled($dst_img,$src_img,0,0,0,0,$thumb_w,$thumb_h,$old_x,$old_y); 
+    if (preg_match("/png/",$system[1]))
+    {
+      imagepng($dst_img,$filename); 
+    } else {
+      imagejpeg($dst_img,$filename); 
+    }
+    imagedestroy($dst_img); 
+    imagedestroy($src_img); 
+  }
+
+  /*
+          Function directory($directory,$filters)
+          reads the content of $directory, takes the files that apply to $filter 
+      and returns an array of the filenames.
+          You can specify which files to read, for example
+          $files = directory(".","jpg,gif");
+                  gets all jpg and gif files in this directory.
+          $files = directory(".","all");
+                  gets all files.
+  */
+  function directory($dir,$filters)
+  {
+    $handle=opendir($dir);
+    $files=array();
+    if ($filters == "all"){while(($file = readdir($handle))!==false){$files[] = $file;}}
+    if ($filters != "all")
+    {
+      $filters=explode(",",$filters);
+      while (($file = readdir($handle))!==false)
+      {
+        for ($f=0;$f<sizeof($filters);$f++):
+          $system=explode(".",$file);
+          if ($system[1] == $filters[$f]){$files[] = $file;}
+        endfor;
+      }
+    }
+    closedir($handle);
+    return $files;
+} 
+}
+?>
diff --git a/class.json-rpc.php b/class.json-rpc.php
new file mode 100644 (file)
index 0000000..7a889ea
--- /dev/null
@@ -0,0 +1,147 @@
+<?php
+/* vim:expandtab:sw=2:ts=2: 
+ */
+
+/**
+ * Do a Json-RPC request on another server
+ *
+ */
+class JsonRPCClient {
+  private $url;
+  private $id;
+  /**
+   *
+   */
+  public function __construct($url,$proxy = "") {
+    $this->url  = $url;
+    $this->proxy= $proxy;
+    $this->id   = 1;
+  }
+
+  /**
+   *
+   */
+  public function __call($method,$params) {
+    // pre cond
+    if ( !is_scalar($method)) {
+      throw new Exception('Method name issue');
+    }
+    if ( !is_array($params)) {
+      throw new Exception('Params issue should ne an array');
+    }
+    // request
+    $request = array('method' => $method,
+                     'params' => $params,
+                     'id'     => $this->id);
+    $request = json_encode($request);
+    // do http request
+    $opts = array('http' => array(
+      'method'  => 'POST',
+      'header'  => 'Content-type: application/json',
+      'content' => $request
+    ));
+
+    $context = stream_context_create($opts);
+    if ($data = file_get_contents($this->url,false,$context)) {
+      $response = json_decode($data,true);
+    }
+
+    if (!is_null($response['error'])) {
+      throw new Exception('Request error:'.$response['error']);
+    }
+    return $response['result'];
+  }
+};
+
+/**
+ * Starting from a object encode and decode json-rpc
+ *
+ */
+class JsonRPCServer {
+  
+  public function __construct() {
+  }
+  /**
+   *
+   */
+  public static function is_json_rpc() {
+    if ( $_SERVER['REQUEST_METHOD'] != 'POST' ||
+        empty($_SERVER['CONTENT_TYPE']) ||
+        $_SERVER['CONTENT_TYPE'] != 'application/json; charset=UTF-8') {
+      return false; 
+    } else return true;
+  }
+  function getContent() {
+    $request = json_decode(file_get_contents('php://input'),true);
+    return $request;
+  }
+
+  static function handle($object,$request) {
+    if (!JsonRPCServer::is_json_rpc()) {
+      return false;
+    }
+      // reads the input data
+    //$request = json_decode(file_get_contents('php://input'),true);
+    
+    // executes the task on local object
+    try {
+      if ($result = @call_user_func_array(array($object,$request['method']),$request['params'])) {
+        $response = array (
+                  'id' => $request['id'],
+                  'result' => $result,
+                  'error' => NULL
+                  );
+      } else {
+        $response = array (
+                  'id' => $request['id'],
+                  'result' => 0,
+                  'error' => NULL
+        );
+        if (is_array($result)) {
+          error_log("json-rpc: unknow method ".$request['method']." or incorrect parameters (...) res=".$result[0]);
+        } else
+          error_log("json-rpc: unknow method ".$request['method']." or incorrect parameters (...) res=".$result);
+      }
+    } catch (Exception $e) {
+      $response = array (
+                'id' => $request['id'],
+                'result' => NULL,
+                'error' => $e->getMessage()
+                );
+    }
+    if (!empty($request['id'])) {
+      //$ur = iconv('UTF-8','UTF-8//IGNORE',$response);
+      //header('content-type: application/json; charset=utf-8');
+      header('content-type: application/json; charset=iso-8859-1');
+      header('X-JSON: '.json_encode($response));
+      $json = json_encode($response);
+      switch (json_last_error())
+      {
+         case JSON_ERROR_NONE:
+             echo $json;
+         break;
+         case JSON_ERROR_DEPTH:
+             error_log("json-rpc json-encode error: Depth");
+         break;
+         case JSON_ERROR_STATE_MISMATCH:
+             error_log("json-rpc json-encode error: state mismatch");
+         break;
+         case JSON_ERROR_CTRL_CHAR:
+             error_log("json-rpc json-encode error: control char");
+         break;
+         case JSON_ERROR_SYNTAX:
+             error_log("json-rpc json-encode error: syntax");
+         break;
+         case JSON_ERROR_UTF8:
+             error_log("json-rpc json-encode error: utf8");
+         break;
+         default:
+             error_log("json-rpc json-encode error: inconnue");
+         break;
+
+      }
+    }
+    return true;
+  }
+};
+?>
diff --git a/class.logging.php b/class.logging.php
new file mode 100644 (file)
index 0000000..5fe5f38
--- /dev/null
@@ -0,0 +1,68 @@
+<?php
+/**
+ *
+ */
+
+class Logging {
+  private $log_file,$fp;
+   
+  function __construct($path = "") {
+    if ($path != "") {
+      $log_file        = $path;
+      $this->lopen();
+    }
+  }
+  function __destruct() {
+    if (  is_resource($this->fp) {
+      $this->lclose();
+    }
+  }
+  
+  public function logError($message) {
+    // Log an error somewhere else then apache log file
+    if ( ! is_resource($this->fp) {
+      $this->lopen();
+    }
+    $script_name       = pathinfo($_SERVER['PHP_SELF'],PATHINFO_FILENAME);
+    $time              = @date('[d/M/Y:H:i:s]');
+    fwrite($this->fp,"".$time." (".$script_name.") ".$message.PHP_EOL);
+  }
+  public function logInfo($message) {
+    // Log information
+    if ( ! is_resource($this->fp) {
+      $this->lopen();
+    }
+    $script_name       = pathinfo($_SERVER['PHP_SELF'],PATHINFO_FILENAME);
+    $time              = @date('[d/M/Y:H:i:s]');
+    fwrite($this->fp,"".$time." (".$script_name.") ".$message.PHP_EOL);
+  }
+
+  public function logTransaction($message) {
+    // Log financial transaction
+    if ( ! is_resource($this->fp) {
+      $this->lopen();
+    }
+
+    $script_name       = pathinfo($_SERVER['PHP_SELF'],PATHINFO_FILENAME);
+    $time              = @date('[d/M/Y:H:i:s]');
+    fwrite($this->fp,"".$time." (".$script_name.") ".$message.PHP_EOL);
+  }
+
+  private function lopen() {
+    if (strtoupper(substr(PHP_OS,0,3)) === 'WIN') {
+    } else {
+      $log_file_default = '/tmp/aebwww.log';
+    }
+    $lfile = $this->log_file ? $this->log_file : $log_file_default;
+   
+    $this->fp  = fopen($lfile,'a') or error_log("Logging can't open file : ".$log_file);
+  
+  }
+
+  public function lclose() {
+    fclose($this->fp);
+  }
+
+}
+?>
diff --git a/class.menu.php b/class.menu.php
new file mode 100644 (file)
index 0000000..7b198fd
--- /dev/null
@@ -0,0 +1,169 @@
+<?php 
+
+/**
+ * @brief MenuItem of classes
+ *
+ */
+class MenuItem {
+   var $name;
+   var $link;
+   var $sub;
+   function MenuItem($name,$link,$sub = null) {
+       $this->name = $name;
+       $this->link = $link;
+       if ( $sub != null ) {
+           $this->sub = $sub;
+       }
+   }
+   function isSubMenu() {return isset($this->sub);}
+   
+   function showHorizontal($parent,$pos,$level=0) {
+       $res = "<li id='".$parent.$pos."'>";
+       if ($this->isSubMenu()) {
+         $res .= "<a class='horizontalMenu' href='".$this->link."'>".$this->name."</a>";
+          $res .= $this->sub->showSubMenu($parent,$pos);
+       } else {
+          $res .="<a ";
+          if ($level == 0) {$res.="class='horizontalMenu'"; }
+         $res.=" href='".$this->link."'>".$this->name."</a></li>\n";
+       }
+       return $res;
+   }
+   /**
+    *
+    *
+    */
+   function show($parent,$pos,$level=0) {
+       $result = "";
+       if ($this->isSubMenu()) {
+               $result.="<li id=\"".$parent."_i".$pos."\" class=\"menu_item\" onmouseover=\"changeMenu(event,'".$parent."_".$pos."', '";
+               $result.=$parent."_i".$pos."','#AAFFAA',".$level.")\">";
+               $result.="<a href=\"".$this->link."\">".$this->name."</a>\n<ul class='menucontent' style='display:none;position:absolute; "; 
+               $result.="z-index:100;top:0px;left:0px;' onmouseout='hideMenu(event,\"".$parent."_".$pos."\",0)' ";
+               $result.=" onmouseover='stopHideMenu(0)' id='".$parent."_".$pos."'>\n";
+                $result.=$this->sub->showSubMenu($parent,$pos);
+               $result.="</ul></li>\n";
+
+       } else {
+               $result.="<li id=\"".$parent."_i".$pos."\" class=\"menu_item\" onmouseover=\"changeMenu(event,null, '";
+               $result.=$parent."_i".$pos."','#AAFFAA',".$level.")\">";
+               $result.="<a href=\"".$this->link."\">".$this->name."</a> </li>\n";
+       }
+          return $result;
+   }
+}
+
+/**
+ * @brief Class used to build Menus
+ *
+ *
+ */
+class Menu {
+       var $parent = "";
+       var $parent_item = 0;
+       var $title;
+       var $id;
+       var $items;
+       var $type='vertical';
+
+    /**
+     *
+     */        
+    function Menu($id="Menu",$title="home",$type='vertical')
+    {
+        $this->title = $title;
+       $this->id = $id;
+       $this->type = $type;
+        $this->items = array();
+    }
+
+    function addMenuItem($name,$link) {
+        $this->items[$name] = new MenuItem($name,$link);
+    }
+    function addSubMenu($name,$link,$sub) {
+        $this->items[$name] = new MenuItem($name,$link,$sub);
+    }
+
+    /**
+     * @brief Show Vertical Menu
+     *
+     *
+     */
+    function showVertical($parent="")
+    {
+       if ($parent == "") {
+        // Display Menu title
+     $result="<span class=\"corner-top-center\" id=\"";
+
+     $result.="".$this->id;
+     $result.="\"><span class=\"corner-top\"><span class=\"corner-left\"></span></span></span><span class=\"menu-title\" id=\"".$this->id."\">";
+     $result.=$this->title."</span>";
+     $result.="<ul class=\"menucontent\" id=\"";
+     $result.="".$this->id."\" onmouseout=\"hideMenu(event,'".$this->id."',0)\" onmouseover=\"stopHideMenu(0)\">\n";
+     echo "$result";
+     $i = 1;
+     $result="";
+        foreach ($this->items as $item) {
+           $result.=$item->show($this->id,$i);
+           $i+= 1;
+        }
+    
+     $result.="</ul>\n";
+       }
+     echo $result;
+    }
+
+    /**
+     * @brief Show Horizontal Menu
+     *
+     */
+    function showHorizontal($parent="") {
+       $result="<ul class='horizontalMenu'>\n";
+       $res = "";
+       $i = 1;
+       foreach ($this->items as $item) {
+           $res.=$item->showHorizontal($this->id,$i);
+           $i+= 1;
+       }
+       $icon = "<li class='h-icon'><a href='javascript:void(0)' class='' onclick='htoggle()'><i class='fa fa-bars'></i></a></li>";
+       $result.=$res."".$icon."</ul>\n";
+       echo $result;
+    }
+    /**
+     * @brief
+     *
+     */
+    function showSubMenu($parent,$pos) {
+           $i = 1;
+           $result = "";
+           if ($this->type == "horizontal" ){
+               $result.="<ul class='horizontalSubMenu' id='s".$parent."_".$pos."'>\n";
+           }
+           foreach ($this->items as $item) {
+               if ($this->type =='vertical' ) {
+                       $result.=$item->show($parent."_".$pos,$i,1);
+               } else {
+                       $result.=$item->showHorizontal($parent.$pos."_",$i,1);
+               }
+               $i+= 1;
+           }
+           if ($this->type == "horizontal" ){
+               $result.="</ul>\n";
+           }
+       return $result;
+    }
+
+    /**
+     * @brief main entry to show a menu
+     *
+     */
+    function show($parent = "") {
+       if ($this->type == 'vertical') {
+           $this->showVertical($parent);
+       } else {
+           $this->showHorizontal($parent);
+       }
+
+    }
+}
+?>
diff --git a/class.nntp.php b/class.nntp.php
new file mode 100644 (file)
index 0000000..834c904
--- /dev/null
@@ -0,0 +1,9 @@
+<?php
+
+
+class NNTP {
+
+
+}
+
+?>
diff --git a/class.notebook.php b/class.notebook.php
new file mode 100644 (file)
index 0000000..5cf1eb8
--- /dev/null
@@ -0,0 +1,73 @@
+<?php
+
+/**
+ *
+ */
+class NotebookPage {
+    var $title;
+    var $class;
+
+
+    function __construct($title) {
+    }
+
+    function title() {return $this->title;}
+    
+    function show_title($obj) {
+        echo "<li class='notbooktitle' id='win".$this->title."'><div id='left'></div>";
+        echo "<a href=\"javascript:Note_win.openBoite('".$this->title."');\" id=\"center\">";
+        echo $this->title."</a><div id='right'></div></li>";
+    }
+    /**
+     * \brief this function might be reimplemented for 
+     * each new page
+     */
+    function content() {
+    }
+    /**
+     * \brief This page display the decoration
+     */
+    function show() {
+        echo "<div class='page' id='".$this->title."'>";
+        $this->content();
+        echo "</div>";
+    }
+}
+
+/**
+ * \brief This class will be used to create and
+ * display a note book
+ * \author EBERSOLD ANDRE
+ * \date   01/09/08
+ *
+ */
+class Notebook {
+    var $pages=Array();
+    var $title;
+    var $obj="NoteWin";
+
+    function __construct() {
+    }
+
+    fucntion addPage($page) {
+        $pages[] = $page;
+    }
+
+    function show() {
+        echo "<div class='notebook'><div id='nbleft'></div><ul>";
+        echo "</ul><div class='nbright'></div>";
+        foreach ($pages as $page) {
+            $page->show_title($this->obj);
+        }
+        foreach ($pages as $page) {
+            $page->show($this->obj);
+        }
+        echo "<script type='text/javascript'>var ".$this->obj."=new AEBW.control.notebook(";
+        echo "'win','".$this->pages[0]->title."');".$this->obj."('".$this->pages[0]->title."');";
+        echo "</script></div>";
+    }
+}
+/*
+ vim:et:sw=4:ts=4:enc=utf-8
+ */
+?>
diff --git a/class.ofx.php b/class.ofx.php
new file mode 100644 (file)
index 0000000..f9a523d
--- /dev/null
@@ -0,0 +1,108 @@
+<?php
+
+
+class Ofx {
+
+  var $texte ;
+  var $para;
+
+  function __construct() {
+
+  }
+
+  function __destruct() {
+
+  }
+
+  private function paragraphe($code) { 
+    //global $texte, $paragraphe ; 
+    $debut = strpos($this->texte, '<'.$code.'>') ; 
+    if (! ($debut === false) ) { 
+        $fin = strpos($this->texte, '</'.$code.'>')+strlen($code)+3 ; 
+        $this->para = substr($this->texte, $debut, $fin-$debut) ; 
+        $this->texte = substr($this->texte, $fin) ; 
+    } else 
+    {
+      error_log("no more paragraph ".$code." début=".$debut." text:".substr($this->texte,0,20));
+      $this->para = '' ;
+    } 
+  } 
+
+   private function valeur($parametre) { 
+    //global $paragraphe ; 
+    $debut = strpos($this->para, '<'.$parametre.'>') ; 
+    if ($debut>0) { 
+        $debut = $debut+strlen($parametre)+2 ; 
+        $fin = strpos($this->para, '<',$debut+1) ; 
+        return trim(substr($this->para, $debut, $fin-$debut)) ; 
+    } else return '' ; 
+  } 
+
+  public function onAccount($codeBanque,$codeGuichet,$codeCompte)
+  {
+    //mysql_select_db($database_locations, $locations); 
+    //$query_rs_compte = "SELECT id, libelle FROM tbl_compte WHERE code_banque='$code_banque' AND code_guichet='$code_guichet' AND no_compte='$no_compte'"; 
+    //$rs_compte = mysql_query($query_rs_compte, $locations) or die(mysql_error()); 
+    //$row_rs_compte = mysql_fetch_assoc($rs_compte); 
+    //$compte_id = $row_rs_compte['id'] ;
+  }
+  
+  public function onMouvement($type,$date,$montant,$reste,$libelle,$info)
+  {
+  }
+
+public function parse($fichier)
+{
+    $ofx_msg = ""; 
+    //if($_size_ > 3200000) $ofx_msg = "Erreur: le fichier est trop lourd (max 3M)"; 
+    if(empty($errStr))
+    { 
+        if (file_exists($fichier)) { 
+            $file = fopen($fichier, "r") ; 
+            $this->texte = ''; 
+            while (!feof($file)) $this->texte .= fread($file, 8192); 
+            fclose($file);     
+            $this->paragraphe('BANKACCTFROM') ; 
+            if (strlen($this->para) > 0) { 
+                $code_banque = $this->valeur('BANKID') ; 
+                $code_guichet = $this->valeur('BRANCHID') ; 
+                $no_compte = $this->valeur('ACCTID') ; 
+                $this->onAccount($code_banque,$code_guichet,$no_compte);
+                $compte_id   = 512000; 
+                //$totalRows_rs_compte = mysql_num_rows($rs_compte);     
+                $totalRows_rs_compte = 1;     
+                if ($totalRows_rs_compte == 1) { 
+                    $values = '' ; 
+                    $a_supprimer = array("'", ".") ; 
+                    $this->paragraphe('STMTTRN') ; 
+                    $i = 0 ; 
+                    while (strlen($this->para)>0) { 
+                        $i += 1 ; 
+                        $type = $this->valeur('TRNTYPE') ; 
+                        $date = $this->valeur('DTPOSTED') ; 
+                        $montant = $this->valeur ('TRNAMT') ; 
+                        $reste = $montant ; 
+                        $banque_mouvement_id = $compte_id.' - '.$this->valeur('FITID') ; 
+                        $libelle = ucwords(strtolower(str_replace($a_supprimer, ' ', $this->valeur('NAME')))) ; 
+                        $info = ucwords(strtolower(str_replace($a_supprimer, ' ', $this->valeur ('MEMO')))) ; 
+                        //$values .= "(".$compte_id.",'".$type."',".$date.",".$montant.",".$reste. 
+                        //    ",'".$banque_mouvement_id."','".$libelle."','".$info."'), " ; 
+                        $this->paragraphe('STMTTRN') ;
+                        $this->onMouvement($type,$date,$montant,$reste,$libelle,$info);
+                    } 
+                    //$values = substr($values, 0, strlen($values)-2) ;
+                    //mysql_select_db($database_locations, $locations); 
+                    //$query_insert = "INSERT IGNORE INTO tbl_mouvement (compte_id, type, `date`, montant, reste, banque_mouvement_id, libelle, info) VALUES $values"; 
+                    //if (mysql_query($query_insert, $locations) == 1) 
+                    //    $ofx_msg = "Importation réussie de $i mouvements dans le compte ".$row_rs_compte['libelle'].'<br />'.mysql_info($locations) ; 
+                    //else $ofx_msg = "Erreur dans l'insertion des mouvements" ;
+
+                } else $ofx_msg = "Erreur: le compte bancaire $code_banque / $code_guichet / $no_compte n'existe pas" ; 
+            } else $ofx_msg = "Erreur: le fichier ne semble pas être un fichier OFX valide" ; 
+        } else $ofx_msg = "Erreur: échec lors de l'ouverture du fichier $fichier" ; 
+    } else $ofx_msg = "Erreur: le fichier n'a pas été téléchargé" ; 
+    error_log("Parsing end ".$i." : ".$ofx_msg);
+ }
+}
+
+?>
diff --git a/class.page.php b/class.page.php
new file mode 100644 (file)
index 0000000..e7053e4
--- /dev/null
@@ -0,0 +1,246 @@
+<?php  
+
+require_once(dirname(__FILE__)."/class.menu.php");
+
+
+/**
+ *  Generic class that can be specialized for all pages served by the application
+ */
+class Page
+{
+    protected $charset="utf-8";
+    var $state;
+    var $alias;
+    var $vmenu;
+    var $class = "";
+    var $keywords="";
+    var $title = "";
+    var $_withHeader = 1;
+    var $_withMenuH  = 1;
+    var $_withMenuV  = 0;
+    var $_body_class     = "";
+    var $_layout_class   = "";
+    var $_width_class    = "";
+    function style()
+    {
+    }
+
+    function description()
+    {
+        return "";
+    }
+
+    function setTitle($t)
+    {
+         $this->title = $t;
+    }
+    function title()
+    {
+        return $this->title;
+    }
+    function redirectLocal($url) {
+        $_scheme = $this->request->getScheme();
+        if (empty($this->alias)) {
+          header("Location: ".$_scheme."".$this->request->getServerHost()."/".$url);
+        } else
+          header("Location: ".$_scheme."".$this->request->getServerHost()."/".$this->alias."/".$url);
+        die();
+    }
+    /**
+     * @brief  This function computes the scheme of the current request.
+       pretty usefull to complete the link area and so on.
+     */
+    function siteScheme()
+    {
+        $protocol = "http://";
+        if (isset($_SERVER['HTTPS']) &&
+            ($_SERVER['HTTPS'] == 'on' || $_SERVER['HTTPS'] == 1) ||
+            isset($_SERVER['HTTP_X_FORWARDED_PROTO']) &&
+            $_SERVER['HTTP_X_FORWARDED_PROTO'] == 'https') {
+          $protocol = 'https://';
+        }
+        return $protocol;   
+    }
+    /**
+     * @brief return Client IP address even if server is behind a proxy
+     */
+    function remoteAddr() {
+        $addr = "0";
+        $host = "";
+        if (isset($_SERVER['HTTP_X_FORWARDED_FOR'] ))
+        {
+            $host = $_SERVER['HTTP_X_FORWARDED_FOR'];
+        } else if (isset($_SERVER['REMOTE_ADDR'] )) {
+            $host = $_SERVER['REMOTE_ADDR'];
+        }
+        $addr = gethostbyname($host);
+        //error_log("remoteAddr:".$host." <".$addr.">");
+        return $addr;
+
+    }
+    #################################################################################################
+    ## INCLUSION JAVASCRIPT GENERIQUE
+    #################################################################################################
+    function generate_top() {
+        header("Content-Type: text/html; charset=".$this->charset."");
+        echo "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.0//EN\" \"http://www.w3.or/TR/REC-html40/strict.dtd\">\n";
+        echo "<html lang='fr'>";
+        echo "<head>\n";
+        echo "    <meta charset=\"".$this->charset."\">\n";
+        echo "    <title>".$this->title."</title>\n";
+        //echo "    <meta http-equiv=\"Content-Type\" content=\"text/html; charset='".$this->charset."'\">\n";
+        echo "    <meta http-equiv=\"Content-Type\" content=\"text/html;\">\n";
+        /* May be can be disabled in production */
+        echo "    <meta http-equiv=\"Cache-Control\" content=\"no-cache, no-store, must-revalidate\">\n";
+        echo "    <meta http-equiv=\"Pragma\" content=\"no-cache\">\n";
+        echo "    <meta http-equiv=\"Expires\" content=\"0\">\n";
+        echo "    <meta name=\"keywords\" content=\"".$this->keywords."\">\n";
+        echo "    <meta name=\"description\" content=\"".$this->description()."\">\n";
+        echo "    <meta name=\"viewport\" content=\"width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0\">\n";
+    }
+       
+    function generate_links() {
+
+        #echo "<link REL=\"alternate stylesheet\" TYPE=\"text/css\" href=\"/css/trinity/default.css\" title='trinity'/>\n";
+        echo "<link rel=\"stylesheet\" TYPE=\"text/css\" href=\"/css/feeb/default.css\" title=\"feebf\"/>\n";
+       echo <<<FIN
+    <!--[if IE]>
+    <link REL="alternate stylesheet" TYPE="text/css" href="/css/feeb/ie_ahp.css" title="feebf"/>
+    <![endif]-->
+<script language="javascript" type="text/javascript">
+       function changeLocation(loc) { 
+           var frm = document.getElementById("myFrame");
+               frm.src = loc;
+               frm.location.reload(true);
+           return "#";
+       }
+
+</script>
+FIN;
+
+        echo "<script type='text/javascript' src='/js/mydate.js' ></script>\n";
+        echo "<script type='text/javascript' src='/js/mymenu.js' ></script>\n";
+        echo "<script type='text/javascript' src='/js/styleswitcher.js' ></script>\n";
+        echo "<script type='text/javascript' src='/js/xgui/aebw.js' ></script>\n";
+        #
+        # Was necessary for IE !!! 
+        #
+        echo "<script type='text/javascript'>setActiveStyleSheet(\"feebf\");</script>\n";
+    }
+
+    
+     
+        #
+        # xgui links
+        #
+    function generate_xgui() {
+        echo "<link rel=\"stylesheet\" TYPE=\"text/css\" href=\"/css/xgui/default.css\"/>";
+        echo "<script type='text/javascript' src='/js/xgui/xgui.js' />\n";
+        echo "<script type='text/javascript' src='/js/xgui/xgui_tab.js' />\n";
+        echo "<script type='text/javascript' src='/js/xgui/xgui_table.js' />\n";
+        echo "<script type='text/javascript' src='/js/xgui/xgui_calendar.js' />\n";
+        echo "<script type='text/javascript' src='/js/xgui/xgui_corba.js' />\n";
+        echo "<script type='text/javascript' src='/css/jscook/JSCookTree.js' />\n";
+        echo "<link REL=\"stylesheet\" TYPE=\"text/css\" href=\"/css/jscook/theme.css\"/>\n";
+        echo "<script type='text/javascript' src='/css/jscook/theme.js' />\n";
+    }
+    
+    function  __construct() {
+      $state = "dede";      
+    }
+    function __destruct() {
+    }
+
+    function _HtmlHeader () {
+       $this->generate_top();
+       $this->generate_links();
+       echo "<script type='text/javascript'>var alias='".$this->alias."';</script>\n";
+       echo "</head>\n";
+       
+    }
+    
+    function top () {
+    }
+    function bottom () {
+    }
+    function news() {
+       "<div id='news'></div>";
+    }
+    
+    function hMenu () {
+       echo "<ul class='horizontalMenu'>\n";
+       echo "<li id='mh1'> <a class=\"horizontalMenu\" href=\"/fr/accueil.html\">home</a></li>\n";
+       echo "<li id='mh2'> <a class=\"horizontalMenu\" href=\"/fr/accueil.html\">Test</a></li>\n";
+       echo "<li id='mh3'> <a class=\"horizontalMenu\" href=\"/fr/accueil.html\">Test</a></li>\n";
+       echo "<li id='mh4'> <a class=\"horizontalMenu\" href=\"/fr/profile.html');\">Index</a></li>\n";
+       echo "<li id='mh5'> <a class=\"horizontalMenu\" href='\"/fr/accueil.html\");'>Index</a></li>\n";
+       echo "</ul><br>\n";
+       #echo "<script> var my_menubar = new AEBW.control.menubar(\"menuh\",\"horizontal\"); </script>";
+    }
+    
+    function vMenu () {
+        if (!defined($this->vmenu)) {
+            $this->vmenu = new Menu("Menu1");
+            $this->vmenu->addMenuItem("accueil","/app/index.php");
+            $this->vmenu->addMenuItem("register","/app/registration/register.php");
+         }
+       $this->vmenu->show();
+    }
+    
+    
+    function main() {
+       echo "<h1 class=\"h1page\">Main entry</h1>";
+    }
+    function _login() {
+    }
+    
+    function showTitle($title) {
+        echo "<h1 class='h1page'>$title</h1>\n";
+    }
+    function _content() {
+       echo "\n<div class='content '>\n<div class='container-border'></div>\n";
+        $this->main();
+        echo "</div>\n"; /* end content */        
+    }
+    function show () {
+        $this->_HtmlHeader();
+        echo "<body><div id='conteneur' class='container clearfix'>\n";
+        echo "<div class='row'>";
+        if ($this->_layout_class != "")
+          echo "<div class='".$this->_layout_class."'>\n"; /* end  layout */
+        if ($this->_withHeader) 
+        {
+          echo "<div id='head' class='".$this->_width_class."'>\n",
+          $this->top();
+          echo "</div>\n";
+        }
+        if ($this->_withMenuH) 
+        {
+          echo "<div id='menuh' class='".$this->_width_class."'>\n",
+          $this->hMenu();
+          echo "</div>\n";
+        }
+        echo "<iframe title=\"menu\" id=\"iframe_menu1\" src=\"javascript:false;\" style=\"display:none; position:absolute; width:0px;height:0px;border:0px;\" width=\"0px\" height=\"0px\"></iframe>\n";
+        if ($this->_withMenuV )
+        {
+          echo "<div id='menuv'>\n",
+          $this->vMenu();
+          echo "</div>\n";
+        }
+        echo "<div id='main' class='".$this->class." clearfix'>";
+        $this->news();
+        $this->_content();
+        echo "</div>\n"; /* end main */
+        echo "<div id='bottom' class='bottom ".$this->_width_class."' valing='left'>";
+        $this->bottom();
+        echo "</div>\n"; /* end bottom    */
+        if ($this->_layout_class != "")
+          echo "</div>\n"; /* end  layout */
+        echo "</div>\n";   /* end row       */
+        echo "</div>\n";   /* end container */
+        $this->_login();
+        echo "</body>\n</html>\n";
+       return true; 
+    }
+}
+?>
diff --git a/class.router.php b/class.router.php
new file mode 100644 (file)
index 0000000..cd7a54f
--- /dev/null
@@ -0,0 +1,154 @@
+<?php
+/* vim: set expandtab sw=4 ts=4 sts=4 list: */
+/**
+ * This file contains the class for API of general ledger system.
+ *
+ * @author Andre Ebersold <andre.ebersold@free.fr>
+ * @version 1.0
+ * @package phplib
+ */
+
+require_once(dirname(__FILE__)."/iface.Request.php");
+require_once(dirname(__FILE__)."/iface.ActionResult.php");
+require_once(dirname(__FILE__)."/class.ActionResults.php");
+
+class Route
+{
+    private $path;
+    private $callable;
+    private $matches = [];
+    private $params  = [];
+
+    private $root    =".";
+
+    public function __construct($path,$callable)
+    {
+        $this->path = trim($path,'/'); // Remove unecessairy /
+        $this->callable = $callable;
+    }
+
+    public function setRoot($_r)
+    {
+        $this->root = $_r;
+        return $this;
+    }
+
+    public function with($param,$regex)
+    {
+        $this->params[$param] = str_replace('(','(?:',regex);
+        return $this;
+    }
+
+    public function match($url)
+    {
+        $url   = trim($url,'/');
+        //$path  = preg_replace('#:([\w]+)#',[$this,'paramMatch'],$this->path);
+        $path  = preg_replace_callback('#:([\w]+)#',[$this,'paramMatch'],$this->path);
+        $regex = "#^$path$#i";
+        if (!preg_match($regex,$url,$matches))
+        {
+            return false;
+        }
+        array_shift($matches);
+        $this->matches = $matches;
+        return true;
+    }
+
+    public function call()
+    {
+        if (is_string($this->callable) ) 
+        {
+            $params     = explode('#',$this->callable);
+           $file       = "".$params[0].".php";
+           $controler  = "compta\\controlers\\" . $params[0];
+
+           if ( file_exists($this->root.$file) )
+           {
+               require_once($this->root.$file);
+               $_c = new $controler ();
+               return call_user_func_array([$_c,$params[1]],$this->matches);
+           }
+           return new \HtmlResult("<h1>router failed</h1>");
+        }
+        return call_user_func_array($this->callable,$this->matches);
+    }
+
+    private function paramMatch($match)
+    {
+        if (isset($this->params[$match[1]]))
+        {
+            return '('. $this->params[$match[1]] . ')';
+        }
+        return '([^/]+)';
+    }
+}
+
+/**
+ *
+ *
+ */
+class Router
+{
+    private $routes         = [];
+    private $namesRoutes    = [];
+    private $request       = null;
+
+    public function __construct(IRequest $_r)
+    {
+        $this->request = $_r;
+    }
+
+    public function get($path,$callable,$name = null)
+    {
+        return $this->add($path,$callable,$name,'GET');
+    }
+
+    public function post($path,$callable,$name = null)
+    {
+        return $this->add($path,$callable,$name,'POST');
+    }
+
+    public function add($path,$callable,$name,$method)
+    {
+        $route = new Route($path,$callable);
+        $this->routes[$method][] = $route;
+        if ( is_string($callable) && $name === null)
+        {
+            $name = $callable;
+        }
+        if ($name)
+        {
+            $this->namedRoutes[$name] = $route;
+        }
+        return $route; // On retourne la route pour "enchainer" les méthodes
+    }
+
+    public function run()
+    {
+        if (! isset($this->routes[$this->request->getMethod()]) )
+        {
+            // Error should do something
+        }
+        foreach($this->routes[$this->request->getMethod()] as $route)
+        {
+            if ($route->match($this->request->getPathInfo())) 
+            {
+                return $route->call();
+            }
+       }
+       echo "No route";
+        // Again no route found
+    }
+}
+
+/**
+ * Examples
+ require_once(dirname(__FILE__)."/class.http.Request.php");
+ $req = new Request();
+ $r = new Router($req);
+ $r->get('/',function($id) {echo "Main page"});
+ $r->get('/posts/:id',function($id) { echo "$Got id $id" ;} );
+ $r->run();
+ */
+
+?>
diff --git a/class.session.php b/class.session.php
new file mode 100644 (file)
index 0000000..319ad19
--- /dev/null
@@ -0,0 +1,182 @@
+<?php
+
+/**
+ * @brief this object handles all session aspects.
+ * a new feature is the storage of all information
+ * in the database rather than in the SESSION global
+ * variable. Only the token will serve as point
+ * of reference.
+ */
+class Session {
+    /**
+     *
+     */
+    function __construct($_opaqueDb = null) {
+        if ($_opaqueDb != null) {
+            $this->opaqueDb = $_opaqueDb;
+        }
+        $this->timeout    = 1800;
+        $this->user_id    = (array_key_exists('user_id',$_SESSION))?$_SESSION['user_id']:"";
+        $this->user_name  = (isset($_SESSION['user_name']))?$_SESSION['user_name']:"" ;
+        $this->user_prenom= (isset($_SESSION['user_prenom']))?$_SESSION['user_prenom']:"" ;
+        $this->user_email = (isset($_SESSION['user_email']))?$_SESSION['user_email']:"" ;
+        $this->user_token = (isset($_SESSION['token']))?$_SESSION['token']:"" ;
+        $this->user_groupe= (isset($_SESSION['user_groupe']))?$_SESSION['user_groupe']:"" ;
+        $this->updateTimeout();
+    }
+    /**
+     * @brief Generate a random string to handle session tokens
+     */
+    function generateRandomString($length = 40) {
+        $characters = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ';
+        $charactersLength = strlen($characters);
+        $randomString = '';
+        for ($i = 0; $i < $length; $i++) {
+          $randomString .= $characters[rand(0, $charactersLength - 1)];
+        }
+        return $randomString;
+    }
+
+    function updateTimeout() {
+      $timeout = time();
+      if (isset($_SESSION['LAST_ACTIVITY']) && $timeout - $_SESSION['LAST_ACTIVITY'] > $this->timeout) {
+        session_unset();   // unser $_SESSION variables
+        session_destroy(); // Destroy session storage
+      }
+      $_SESSION['LAST_ACTIVITY'] = time();
+    }
+    /**
+     * @brief
+     */
+    function createToken() {
+        $this->user_token = $this->generateRandomString(36);
+        if ($this->opaqueDb) {
+            $result = @call_user_func_array(array($this->opaqueDb,"create")
+                      ,array($this->user_token,0)) ;
+        }
+        $_SESSION['token'] = $this->user_token;
+        return $this->user_token;
+    }
+    function is_logged_in() { 
+        return ( isset($_SESSION['login'])) && ($_SESSION['login'] != '');}
+    
+    function id() { return $this->user_id; }
+
+    function name() {return $this->user_name; }
+    
+    function first_name() {return $this->user_prenom; }
+
+    function groupe() {return $this->user_groupe; }
+    /**
+     * @note $_SESSION['user_groupe_name'] is set 
+     * in member/class.json_db_user.php  
+     */
+    function in_groupe($name) {
+        return in_array($name,$_SESSION['user_groupe_name']);}
+
+    function last_name() { return $this->user_name;}
+
+    function set_email($email)     {  $this->user_email = $email; $_SESSION['user_email']=$email;}
+
+    function email()     { return $this->user_email;}
+
+    function logout() {
+        if ($this->opaqueDb) {
+            $result = @call_user_func_array(array($this->opaqueDb,"destroy")
+                      ,array($this->user_token,0)) ;
+        }
+        if (isset($_SESSION['token'])) { unset($_SESSION['token']); }
+        if (isset($_SESSION['login'] )) {
+            unset($_SESSION['login']);
+            unset($login);
+        }
+        if (isset($_SESSION['user_groupe']) ) {
+            unset($_SESSION['user_groupe']);
+        }
+        session_destroy();
+    }
+    /*
+     * @brief Store the requested uri before redirection.
+     * retrived it back once authenticated
+     */
+    function set_uri($uri) { $_SESSION['req_uri'] = $uri; }
+    function get_uri()     { return $_SESSION['req_uri']; }
+    function isset_uri()   { return isset($_SESSION['req_uri']); }
+    function unset_uri()   { if (isset($_SESSION['req_uri'] )) { unset($_SESSION['req_uri']);} }
+    /**
+     * @brief User is authorized.
+     * if database is available, update and reload
+     */
+    function login($id,$nom,$prenom,$groupe) {
+        $_SESSION['user_id'] = $id;
+        $_SESSION['user_name'] = $nom;
+        $_SESSION['user_prenom'] = $prenom;
+        $_SESSION['user_groupe'] = $groupe;
+        if ($this->opaqueDb) {
+            $result = @call_user_func_array(array($this->opaqueDb,"updateState")
+                      ,array($this->user_token,"Authenticated")) ;
+        }
+    }
+    /**
+     * @brief Refresh session info based on database state 
+     * time
+     */
+    function refresh() {
+    
+        $this->from_token($_SESSION['token']);
+    }
+
+    /**
+     * @brief From token, get session formation from token
+     * user, first_name state and email1
+     *  
+     */
+    function from_token($token)
+    {
+        $_ret = false;
+        if ($this->opaqueDb) {
+            $result = @call_user_func_array(array($this->opaqueDb,"getAll")
+                      ,array($token)) ;
+            if (sizeof($result) > 0 ) {
+                $_SESSION['state'] = $result[3];
+                $_SESSION['token'] = $token;
+                $this->user_token  = $token; 
+                $this->user_email  = $result[2]; 
+                $this->user_name   = $result[0]; 
+                $this->user_id     = $result[5]; 
+                $ret = true;    
+            }
+        }
+
+        return $_ret;
+    }
+
+    /**
+     * @brief return the session state. I'm not sur If I should extract
+     * it from the global Session or from the Data base
+     */
+    function get_state()
+    {
+        return $_SESSION['state'];
+    }
+    /**
+     *
+     */
+    function set_state($token,$state)
+    {
+        if ($this->user_token == $token) 
+        {
+            $_SESSION['state'] = $state;
+            if ($this->opaqueDb) {
+                $result = @call_user_func_array(array($this->opaqueDb,"updateState")
+                      ,array($this->user_token,$state)) ;
+            }
+       } else {
+            error_log("Session::set_state Failed token miss matche");
+       }
+    }
+}
+/**
+ vim:et:sw=4:ts=4:enc=utf-8
+ */
+?>
diff --git a/class.sitemap.php b/class.sitemap.php
new file mode 100644 (file)
index 0000000..57d0569
--- /dev/null
@@ -0,0 +1,59 @@
+<?php
+
+class SitemapItem {
+    var $url;
+    var $priority;
+    var $lastupdate ="2013-01-01";
+    var $changefreq;
+    function __construct($u,$p=0.8)
+    {
+        $this->url = $u;
+
+        $this->changefreq ="monthly";
+        $this->priority =$p;
+    }
+
+    function createItem() {
+        $item="<url>";
+        $item.="<loc>".$this->url."</loc>";
+        $item.="<lastmod>".$this->lastupdate."</lastmod>";
+        $item.="<changefreq>".$this->changefreq."</changefreq>";
+        $item.="<priority>".$this->priority."</priority>";
+        $item.="</url>";
+        return $item;
+    }
+};
+
+class SitemapCreator {
+    var $contentType    = "application/xml";
+    var $encoding       = "utf-8";
+    var $items = array();
+    function __construct()
+    {
+        header("Content-Type:".$this->contentType."; charset=".$this->encoding."; filename=sitemap.xml");
+    }
+
+    function addItem($i) {
+      $this->items[] = $i;
+    }
+
+    function createSitemap() {
+        $sitemap ="<?xml version='1.0' encoding='UTF-8'?> <urlset xmlns='http://www.sitemaps.org/schemas/sitemap/0.9'>";
+        foreach ($this->items as $item) {
+          $sitemap.=$item->createItem();
+        }
+        $sitemap .="</urlset>";
+        return $sitemap;
+    }
+
+    function output() {
+      echo $this->createSitemap();
+    }
+
+}
+
+
+/*
+ :vim:enciding=utf-8:fileencoding=utf-8:et:sw=2:ts-2
+ */
+?>
diff --git a/class.smtp.php b/class.smtp.php
new file mode 100644 (file)
index 0000000..2f4f933
--- /dev/null
@@ -0,0 +1,671 @@
+<?php
+/*******************************************************************************
+ *
+ * Nom de la source :
+ * Class SMTP
+ * Nom du fichier par défaut :
+ * Class.SMTP.php
+ * Auteur :
+ * Nuel Guillaume alias Immortal-PC
+ * Site Web :
+ * http://immortal-pc.info/
+ *
+ *******************************************************************************/
+
+ class SMTP {
+ // Nom du domaine ou nom du serveur
+ var $NomDuDomaine = '';
+
+ // De Qui
+ var $From = 'root@localhost';// Adresse de l' expéditeur
+ var $FromName = 'Root';// Nom de l' expéditeur
+ var $ReplyTo = 'root@localhost';// Adresse de retour
+ var $org = 'Localhost'; // Organisation
+
+ // A Qui
+ var $To = '';
+ // Utilisation : $Bcc = 'mail1,mail2,....';
+ var $Bcc = '';// Blind Carbon Copy, c'est à dire que les adresses qui sont contenue ici seront invisibles pour tout le monde
+ var $Cc = '';
+
+ // Priorité
+ var $Priority = 3;// Priorité accordée au mail (valeur allant de 1 pour Urgent à 3 pour normal et 6 pour bas)
+
+ // Encodage
+ var $ContentType = 'html';//Contenu du mail (texte, html...) (txt , html, txt/html)
+ var $Encoding = '8bit'; // Ancienne valeur quoted-printable
+ var $ISO = 'iso-8859-15';
+ var $MIME = '1.0';// La version mime
+ var $Encode = false;// Encodage necessaire ou pas
+ var $CHARSET = '';
+
+ // Confirmation de reception
+ var $Confimation_reception = '';// Entrez l' adresse où sera renvoyé la confirmation
+
+ // Le mail
+ var $Sujet = '';
+ var $Body = '';
+ var $Body_txt = '';
+
+ // Fichier(s) joint(s)
+ var $File_joint = array();
+
+ // Nombre tour
+ var $Tour = 0;
+
+
+ //**************************************************************************
+ // Paramètre de connection SMTP
+ //**************************************************************************
+ var $Authentification_smtp = false;
+
+ var $serveur = '';// Serveur SMTP
+ var $port = 25;// Port SMTP
+ var $login_smtp = '';// Login pour le serveur SMTP
+ var $mdp_smtp = '';// Mot de passe pour le serveur SMTP
+ var $time_out = 10;// Durée de la connection avec le serveur SMTP
+ var $tls = false;// Activation de la connection sécurisée (anciennement ssl)
+
+
+ //**************************************************************************
+ // Variables temporaires
+ //**************************************************************************
+ var $smtp_connection = '';// Variable de connection
+ var $erreur = '';
+ var $debug = false;
+
+ //------------------------------------------------------------------------------
+
+ //**************************************************************************
+ // Fonction de déclaration de connection SMTP
+ //**************************************************************************
+ function SMTP($serveur='', $user='', $pass='', $port=25, $NomDuDomaine='', $debug=false){
+ if($serveur){
+ $this->serveur = $serveur;
+ }
+ if($user){
+ $this->Authentification_smtp = true;
+ $this->login_smtp = $user;
+ $this->mdp_smtp = $pass;
+ }
+ $this->port = $port;
+ if($NomDuDomaine){
+ $this->NomDuDomaine = $NomDuDomaine;
+ }
+ $this->debug = $debug;
+ }
+
+
+ //**************************************************************************
+ // Fonction de connection SMTP
+ //**************************************************************************
+ function Connect_SMTP(){
+ // Definition du charset
+ if(!$this->CHARSET){ $this->CHARSET = mb_internal_encoding(); }
+
+ // Connection au serveur SMTP
+ $this->smtp_connection = fsockopen($this->serveur, // Serveur
+ $this->port, // Port de connection
+ $num_erreur, // Numéros de l' erreur
+ $msg_erreur, // Message d' erreur
+ $this->time_out); // Durée de la connection en secs
+ if(!$this->smtp_connection){// Vérification de la connection
+ $this->erreur = 'Impossible de se connecter au serveur SMTP !!!<br />'."\r\n"
+ .'Numéro de l&#39; erreur: '.$num_erreur.'<br />'."\r\n"
+ .'Message renvoyé: '.$msg_erreur.'<br />'."\r\n";
+ return false;
+ }
+
+ // Suppression du message d' accueil
+ $reponce = $this->get_smtp_data();
+ // Debug
+ if($this->debug){
+ echo '<div style="color:#993300;">Connection</div>',"\r\n",str_replace("\r\n", '<br />', $reponce['msg']);
+ }
+
+ // On règle le timeout du serveur SMTP car parfois, le serveur SMTP peut être un peut lent à répondre
+ // Windows ne comprend pas la fonction socket_set_timeout donc on vérifi que l' on travail sous Linux
+ if(substr(PHP_OS, 0, 3) !== 'WIN'){
+ socket_set_timeout($this->smtp_connection, $this->time_out, 0);
+ }
+
+ //**********************************************************************
+ // Commande EHLO et HELO
+ if($this->NomDuDomaine === ''){// On vérifit si le nom de domaine à été renseigné
+ if($_SERVER['SERVER_NAME'] !== ''){
+ $this->NomDuDomaine = $_SERVER['SERVER_NAME'];
+ }else{
+ $this->NomDuDomaine = 'localhost.localdomain';
+ }
+ }
+
+ if(!$this->Commande('EHLO '.$this->NomDuDomaine, 250)){// Commande EHLO
+ // Deusième commande EHLO -> HELO
+ if(!$this->Commande('HELO '.$this->NomDuDomaine, 250, 'Le serveur refuse l&#39; authentification (EHLO et HELO) !!!')){// Commande HELO
+ return false;
+ }
+ }
+
+ if($this->tls && !$this->Commande('STARTTLS', 220, 'Le serveur refuse la connection sécurisée ( STARTTLS ) !!!')){// Commande STARTTLS
+ return false;
+ }
+
+ if($this->Authentification_smtp){// On vérifi si l' on a besoin de s' authentifier
+ //******************************************************************
+ // Authentification
+ //******************************************************************
+ if(!$this->Commande('AUTH LOGIN', 334, 'Le serveur refuse l&#39; authentification (AUTH LOGIN) !!!')){
+ return false;
+ }
+
+
+ //******************************************************************
+ // Authentification : Login
+ //******************************************************************
+ $tmp = $this->Commande(base64_encode($this->login_smtp), 334, 'Login ( Nom d&#39; utilisateur ) incorrect !!!', 0);
+ if(!$tmp['no_error']){
+ return false;
+ }
+ // Debug
+ if($this->debug){
+ echo '<div style="color:#993300;">Envoie du login.</div>',"\r\n",str_replace("\r\n", '<br />', $tmp['msg']);
+ }
+
+
+ //******************************************************************
+ // Authentification : Mot de passe
+ //******************************************************************
+ $tmp = $this->Commande(base64_encode($this->mdp_smtp), 235, 'Mot de passe incorrect !!!', 0);
+ if(!$tmp['no_error']){
+ return false;
+ }
+ // Debug
+ if($this->debug){
+ echo '<div style="color:#993300;">Envoie du mot de passe.</div>',"\r\n",str_replace("\r\n", '<br />', $tmp['msg']);
+ }
+
+ }
+
+ //**********************************************************************
+ // Connecté au serveur SMTP
+ //**********************************************************************
+ return true;
+ }
+
+
+ //**************************************************************************
+ // Fonctons de set
+ //**************************************************************************
+ function set_from($name, $email='', $org='Localhost'){
+ $this->FromName = $name;
+ if($this->Encode){
+ $this->FromName = $this->encode_mimeheader(mb_convert_encoding($this->FromName, $this->ISO, $this->CHARSET), $this->ISO);
+ }
+ if(!empty($email)){
+ $this->From = $email;
+ }
+ $this->org = $org;
+ unset($name, $email, $org);
+ }
+
+ function set_encode($ISO, $CHARSET=''){
+ $this->Encode = true;
+ $this->ISO = $ISO;
+ $this->CHARSET = $CHARSET;
+ unset($ISO, $CHARSET);
+ }
+
+
+ //**************************************************************************
+ // System d' encodage par Pierre CORBEL
+ //**************************************************************************
+ function encode_mimeheader($string){
+ $encoded = '';
+ $CHARSET = mb_internal_encoding();
+ // Each line must have length <= 75, including `=?'.$this->CHARSET.'?B?` and `?=`
+ $length = 75 - strlen('=?'.$this->CHARSET.'?B?') - 2;
+ $tmp = mb_strlen($string, $this->CHARSET);
+ // Average multi-byte ratio
+ $ratio = mb_strlen($string, $this->CHARSET) / strlen($string);
+ // Base64 has a 4:3 ratio
+ $magic = floor(3 * $length * $ratio / 4);
+ $avglength = $magic;
+
+ for($i=0; $i <= $tmp; $i+=$magic) {
+ $magic = $avglength;
+ $offset = 0;
+ // Recalculate magic for each line to be 100% sure
+ do{
+ $magic -= $offset;
+ $chunk = mb_substr($string, $i, $magic, $this->CHARSET);
+ $chunk = base64_encode($chunk);
+ $offset++;
+ }while(strlen($chunk) > $length);
+ if($chunk){
+ $encoded .= ' '.'=?'.$this->CHARSET.'?B?'.$chunk.'?='."\r\n";
+ }
+ }
+ // Chomp the first space and the last linefeed
+ return substr($encoded, 1, -2);
+ }
+
+
+ //**************************************************************************
+ // Foncton d' ajout de pièce jointe
+ //**************************************************************************
+ function add_file($url_file){
+ if(!$url_file){
+ $this->erreur = 'Champs manquant !!!<br />'."\r\n";
+ return false;
+ }
+ if(!($fp = @fopen($url_file, 'a'))){
+ $this->erreur = 'Fichier introuvable !!!<br />'."\r\n";
+ return false;
+ }
+ fclose($fp);
+
+ $file_name = explode('/', $url_file);
+ $file_name = $file_name[count($file_name)-1];
+ $mime = parse_ini_file('./mime.ini');
+ $ext = explode('.', $file_name);
+ $ext = $ext[count($ext)-1];
+
+ if(IsSet($this->File_joint[$file_name])){
+ $file_name = explode('_', str_replace('.'.$ext, '', $file_name));
+ if(is_numeric($file_name[count($file_name)-1])){
+ $file_name[count($file_name)-1]++;
+ $file_name = implode('_', $file_name);
+ }else{
+ $file_name = implode('_', $file_name);
+ $file_name .= '_1';
+ }
+ $file_name .= '.'.$ext;
+ }
+ $this->File_joint[$file_name] = array(
+ 'url' => $url_file,
+ 'mime' => $mime[$ext]
+ );
+ unset($file_name, $mime, $ext);
+ }
+
+
+ //**************************************************************************
+ // Entêtes (Headers)
+ //**************************************************************************
+ function headers(){
+ // Id unique
+ $Boundary1 = '------------Boundary-00=_'.substr(md5(uniqid(time())), 0, 7).'0000000000000';
+ $Boundary2 = '------------Boundary-00=_'.substr(md5(uniqid(time())), 0, 7).'0000000000000';
+ $Boundary3 = '------------Boundary-00=_'.substr(md5(uniqid(time())), 0, 7).'0000000000000';
+
+ $header = '';
+ $No_body = 0;
+
+ // Adresse de l'expéditeur (format : Nom <adresse_mail>)
+ if(!empty($this->From)){
+ $header .= 'X-Sender: '.$this->From."\n";// Adresse réelle de l'expéditeur
+ }
+ // La version mime
+ if(!empty($this->MIME)){
+ $header .= 'MIME-Version: '.$this->MIME."\n";
+ }
+ $header .= sprintf("Message-ID: <%s@%s>%s", md5(uniqid(time())), $this->NomDuDomaine, "\n")
+ .'Date: '.date('r')."\n"
+ .'Content-Type: Multipart/Mixed;'."\n"
+ .' boundary="'.$Boundary1.'"'."\n"
+ // Logiciel utilisé pour l' envoi des mails
+ .'X-Mailer: PHP '.phpversion()."\n";
+ // Adresse de l'expéditeur (format : Nom <adresse_mail>)
+ if(!empty($this->From)){
+ if(!empty($this->FromName)){
+ $header .= 'From: "'.$this->FromName.'"';
+ }else{
+ $header .= 'From: ';
+ }
+ $header .= '<'.$this->From.">\n";
+ }
+ $header .= 'X-FID: FLAVOR00-NONE-0000-0000-000000000000'."\n";
+
+ // Priorité accordée au mail (valeur allant de 1 pour Urgent à 3 pour normal et 6 pour bas)
+ if(!empty($this->Priority)){
+ $header .= 'X-Priority: '.$this->Priority."\n";
+ }
+ // To
+ if(!empty($this->To)){// A
+ $header .= 'To: '.$this->To."\n";
+ }else{
+ $No_body++;// Personne
+ }
+ // Cc
+ if(!empty($this->Cc)){// Copie du mail
+ $header .= 'Cc: '.$this->Cc."\n";
+ }else{
+ $No_body++;// Personne
+ }
+ // Bcc
+ if(empty($this->Bcc)){// Blind Carbon Copy, c' est à dire que les adresses qui sont contenue ici seront invisibles pour tout le monde
+ $No_body++;// Personne
+ }
+ // Sujet
+ if(!empty($this->Sujet)){
+ $header .= 'Subject: '.$this->Sujet."\n";
+ }
+ if(!empty($this->Confimation_reception)){// Adresse utilisée pour la réponse au mail
+ $header .= 'Disposition-Notification-To: <'.$this->Confimation_reception.'>'."\n";
+ }
+ // ReplyTo
+ if(!empty($this->ReplyTo) && $this->ReplyTo !== $this->From && $this->ReplyTo !== 'root@localhost'){// Adresse utilisée pour la réponse au mail
+ $header .= 'Reply-to: '.$this->ReplyTo."\n"
+ .'Return-Path: <'.$this->ReplyTo.">\n";
+ }
+ if(!IsSet($_SERVER['REMOTE_ADDR'])){$_SERVER['REMOTE_ADDR'] = '127.0.0.1';}
+ if(!IsSet($_SERVER['HTTP_X_FORWARDED_FOR'])){$_SERVER['HTTP_X_FORWARDED_FOR'] = '';}
+ if(!IsSet($_SERVER['HTTP_USER_AGENT'])){$_SERVER['HTTP_USER_AGENT'] = 'Internet Explorer';}
+ if(!IsSet($_SERVER['HTTP_ACCEPT_LANGUAGE'])){$_SERVER['HTTP_ACCEPT_LANGUAGE'] = 'Fr-fr';}
+ $host = 'localhost';
+ if(function_exists('gethostbyaddr') && $_SERVER['REMOTE_ADDR'] !== '127.0.0.1'){$host = gethostbyaddr($_SERVER['REMOTE_ADDR']);}
+ $header .= 'X-Client-IP: '.$_SERVER['REMOTE_ADDR']."\n"
+ .'X-Client-PROXY: '.$_SERVER['HTTP_X_FORWARDED_FOR']."\n"
+ .'X-Client-Agent: '.$_SERVER['HTTP_USER_AGENT']."\n"
+ .'X-Client-Host: '.$host."\n"
+ .'X-Client-Language: '.$_SERVER['HTTP_ACCEPT_LANGUAGE']."\n"
+ .'Organization: '.$this->org."\n"
+ ."\n\n\n"
+ .'--'.$Boundary1."\n"
+ .'Content-Type: Multipart/Alternative;'."\n"
+ .' boundary="'.$Boundary3.'"'."\n"
+ ."\n\n"
+ .'--'.$Boundary3."\n";
+ if($this->ContentType === 'txt' || $this->ContentType === 'txt/html'){
+ $header .= 'Content-Type: Text/Plain;'."\r\n"
+ .' charset="'.$this->ISO.'"'."\r\n"
+ .'Content-Transfer-Encoding: '.$this->Encoding."\r\n"
+ ."\r\n";
+ if($this->ContentType === 'txt'){
+ $header .= $this->Body."\r\n";
+ }else{
+ $header .= $this->Body_txt."\r\n";
+ }
+ }elseif($this->ContentType === 'html' || $this->ContentType === 'txt/html'){
+ if($this->ContentType === 'txt/html'){
+ $header .= '--'.$Boundary3."\r\n";
+ }
+ $header .= 'Content-Type: Text/HTML;'."\r\n"
+ .' charset="'.$this->ISO.'"'."\r\n"
+ .'Content-Transfer-Encoding: '.$this->Encoding."\r\n"
+ ."\r\n"
+ .'<html><head>'."\r\n"
+ .'<meta http-equiv="Content-LANGUAGE" content="French" />'."\r\n"
+ .'<meta http-equiv="Content-Type" content="text/html; charset='.$this->ISO.'" />'."\r\n"
+ .'</head>'."\r\n"
+ .'<body>'."\r\n"
+ .$this->Body."\r\n"
+ .'</body></html>'."\r\n"
+ .'--'.$Boundary3.'--'."\r\n";
+ }else{
+ $header .= 'Content-Type: '.$this->ContentType.';'."\r\n"
+ .' charset="'.$this->ISO.'"'."\r\n"
+ .'Content-Transfer-Encoding: '.$this->Encoding."\r\n"
+ ."\r\n"
+ .$this->Body."\r\n";
+ }
+ $header .= "\n";
+
+ // On joint le ou les fichiers
+ if($this->File_joint){
+ foreach($this->File_joint as $file_name => $file){
+ $header .= '--'.$Boundary1."\n"
+ .'Content-Type: '.$file['mime'].';'."\n"
+ .' name="'.$file_name.'"'."\n"
+ .'Content-Disposition: attachment'."\n"
+ .'Content-Transfer-Encoding: base64'."\n"
+ ."\n"
+ .chunk_split(base64_encode(file_get_contents($file['url'])))."\n"
+ ."\n\n";
+ }
+ }
+ $header .= '--'.$Boundary1.'--';
+
+ if($No_body === 3){
+ $this->erreur = 'Le mail n&#39; a pas de destinataire !!!';
+ return false;
+ }
+ return $header;
+ }
+
+
+ //**************************************************************************
+ // Envoie du mail avec le serveur SMTP
+ //**************************************************************************
+ function smtp_mail($to, $subject, $message, $header=''){
+ // Pas de déconnection automatique
+ $auto_disconnect = false;
+ // On vérifit si la connection existe
+ if(empty($this->smtp_connection)){
+ if(!$this->Connect_SMTP()){// Connection
+ $this->erreur .= 'Impossible d&#39; envoyer le mail !!!<br />'."\r\n";
+ return false;
+ }
+ $auto_disconnect = true;// Déconnection automatique activée
+ }
+
+ // On vérifit Que c' est le premier tour sinon on éfface les anciens paramètres
+ if($this->Tour){
+ if($this->Commande('RSET', 250, 'Envoie du mail impossible !!!')){
+ $this->Tour = 0;
+ }
+ }
+
+ //**********************************************************************
+ // Variables temporairement modifiées
+ if(!empty($to)){
+ $this->To = $to;
+ }
+ if(!empty($subject)){
+ if($this->Encode){
+ $this->Sujet = $this->encode_mimeheader(mb_convert_encoding($subject, $this->ISO, $this->CHARSET), $this->ISO);
+ }else{
+ $this->Sujet = mb_encode_mimeheader($subject, $this->ISO);
+ }
+ }
+
+ if(is_array($message)){
+ $this->Body = $message[0];
+ $this->Body_txt = $message[1];
+ if($this->Encode){
+ $this->Body = mb_convert_encoding($this->Body, $this->ISO, $this->CHARSET);
+ $this->Body_txt = mb_convert_encoding($this->Body_txt, $this->ISO, $this->CHARSET);
+ }
+ }else{
+ $this->Body = $message;
+ if($this->Encode){
+ $this->Body = mb_convert_encoding($this->Body, $this->ISO, $this->CHARSET);
+ }
+ }
+
+ //**********************************************************************
+ // Y a t' il un destinataire
+ if(empty($this->To) && empty($header) && empty($this->Bcc) && empty($this->Cc)){
+ $this->erreur = 'Veuillez entrer une adresse de destination !!!<br />'."\r\n";
+ return false;
+ }
+
+ //**********************************************************************
+ // Envoie des informations
+ //**********************************************************************
+
+ //**********************************************************************
+ // De Qui
+ if(!empty($this->From) && !$this->Tour){
+ if(!$this->Commande('MAIL FROM:<'.$this->From.'>', 250, 'Envoie du mail impossible car le serveur n&#39; accèpte pas la commande MAIL FROM !!!')){
+ return false;
+ }
+ $this->Tour = 1;
+ }
+
+ //**********************************************************************
+ // A Qui
+ $A = array();
+ if(!empty($this->To)){
+ $A[0] = $this->To;
+ }
+ if(!empty($this->Bcc)){
+ $A[1] = $this->Bcc;
+ }
+ if(!empty($this->Cc)){
+ $A[2] = $this->Cc;
+ }
+ foreach($A as $cle => $tmp_to){
+ if(substr_count($tmp_to, ',')){
+ $tmp_to = explode(',', $tmp_to);
+ foreach($tmp_to as $cle => $tmp_A){
+ if(!$this->Commande('RCPT TO:<'.$tmp_A.'>', array(250,251), 'Envoie du mail impossible car le serveur n&#39; accèpte pas la commande RCPT TO !!!')){
+ return false;
+ }
+ }
+ }else{
+ if(!$this->Commande('RCPT TO:<'.$tmp_to.'>', array(250,251), 'Envoie du mail impossible car le serveur n&#39; accèpte pas la commande RCPT TO !!!')){
+ return false;
+ }
+ }
+ }
+
+ //**********************************************************************
+ // On créer les entêtes ( headers ) si c' est pas fait
+ if(empty($header)){
+ if(!$header = $this->headers()){
+ $this->erreur .= 'Impossible d&#39; envoyer le mail !!!<br />'."\r\n";
+ return false;
+ }
+ }
+
+
+ //**********************************************************************
+ // On indique que l' on va envoyer des données
+ if(!$this->Commande('DATA', 354, 'Envoie du mail impossible car le serveur n&#39; accèpte pas la commande DATA!!!')){
+ return false;
+ }
+
+
+ //**********************************************************************
+ // Envoie de l' entête et du message
+ fputs($this->smtp_connection, $header);
+ fputs($this->smtp_connection, "\r\n.\r\n");
+
+ $reponce = $this->get_smtp_data();
+ // Debug
+ if($this->debug){
+ echo '<div style="color:#993300;">Entête et message :<br />',"\r\n",'<div style="padding-left:25px;">',str_replace(array("\r\n","\n"), '<br />', $header),'<br />',"\r\n",$message,'</div>',"\r\n",'</div>',"\r\n",str_replace("\r\n", '<br />', $reponce['msg']);
+ }
+ if($reponce['code'] !== 250 && $reponce['code'] !== 354){
+ $this->erreur = 'Envoie du mail impossible !!!<br />'."\r\n"
+ .'Numéro de l&#39; erreur: '.$reponce['code'].'<br />'."\r\n"
+ .'Message renvoyé: '.$reponce['msg'].'<br />'."\r\n";
+ return false;
+ }
+
+
+ //**********************************************************************
+ // Variables temporairement modifiées
+ if($to === $this->To){
+ $this->To = '';
+ }
+ if($subject === $this->Sujet){
+ $this->Sujet = '';
+ }
+
+ //**********************************************************************
+ // Déconnection automatique
+ //**********************************************************************
+ if($auto_disconnect){// Auto déconnection ?
+ $this->Deconnection_SMTP();// Déconnection
+ }
+
+ //**********************************************************************
+ // Mail envoyé
+ //**********************************************************************
+ return true;
+ }
+
+
+ //**************************************************************************
+ // Lecture des données renvoyées par le serveur SMTP
+ //**************************************************************************
+ function get_smtp_data(){
+ $data = '';
+ while($donnees = fgets($this->smtp_connection, 515)){// On parcour les données renvoyées
+ $data .= $donnees;
+
+ if(substr($donnees,3,1) == ' ' && !empty($data)){break;}// On vérifi si on a toutes les données
+ }
+ // Renvoie des données : array(Code, message complet)
+ return array('code'=>(int)substr($data, 0, 3), 'msg'=>$data);
+ }
+
+
+ //**************************************************************************
+ // Execution des commandes SMTP
+ //**************************************************************************
+ function Commande($commande, $bad_error, $msg_error='', $debug=1){
+ if(!empty($this->smtp_connection)){
+ fputs($this->smtp_connection, $commande."\n");
+ $reponce = $this->get_smtp_data();
+ // Debug
+ if($this->debug && $debug){
+ echo '<div style="color:#993300;">',htmlentities($commande),'</div>',"\r\n",str_replace("\r\n", '<br />', $reponce['msg']);
+ }
+
+ // Tableau de code valide
+ if((is_array($bad_error) && !in_array($reponce['code'], $bad_error)) || (!is_array($bad_error) && $reponce['code'] !== $bad_error)){
+ if($msg_error){
+ $this->erreur = $msg_error.'<br />'."\r\n"
+ .'Numéro de l&#39; erreur: '.$reponce['code'].'<br />'."\r\n"
+ .'Message renvoyé: '.$reponce['msg'].'<br />'."\r\n";
+ }
+ if(!$debug){
+ return array('no_error'=>false, 'msg'=>$reponce['msg']);
+ }else{
+ return false;
+ }
+ }
+
+ if(!$debug){
+ return array('no_error'=>true, 'msg'=>$reponce['msg']);
+ }else{
+ return true;
+ }
+ }else{
+ $this->erreur = 'Impossible d&#39; éxecuter la commande <span style="font-weight:bolder;">'.$commande.'</span> car il n&#39; y a pas de connection !!!<br />'."\r\n";
+ if(!$debug){
+ return array('no_error'=>false, 'msg'=>'');
+ }else{
+ return false;
+ }
+ }
+ }
+
+
+ //**************************************************************************
+ // Fonction de déconnection SMTP
+ //**************************************************************************
+ function Deconnection_SMTP(){
+ if(!empty($this->smtp_connection)){
+ if(!$this->Commande('QUIT', 221, 'Impossible de se déconnecter !!!')){
+ return false;
+ }
+
+ @sleep(5);// On laisse 5 seconde au serveur pour terminer toutes les instructions
+ if(!fclose($this->smtp_connection)){
+ $this->erreur = 'Impossible de se déconnecter !!!<br />'."\r\n";
+ return false;
+ }
+ $this->smtp_connection = 0;
+ return true;
+ }
+ $this->erreur = 'Impossible de se déconnecter car il n&#39; y a pas de connection !!!<br />'."\r\n";
+ return false;
+ }
+ }
+ ?>
+
+
diff --git a/class.validator.php b/class.validator.php
new file mode 100644 (file)
index 0000000..4629005
--- /dev/null
@@ -0,0 +1,73 @@
+<?php
+/**
+ * @brief provide the necessary validation 
+ * features. It's somehow an interface to 
+ * the native validate filter ... 
+ */
+class Validator {
+    /**
+     * Throw an exception if a field in not valide
+     */
+    protected function validate($var,$filter,$msg="",$reg="/[A-Za-z0-9\-].*/") {
+      if ($filter == FILTER_VALIDATE_EMAIL) {
+        if (!filter_var($var,$filter)) {
+                throw new Exception(_("Field validation failed ").$msg);
+        }
+      }
+      if ($filter == FILTER_VALIDATE_REGEXP) {
+        $opts=array("options" => array("regexp" => $reg));
+        if (!filter_var($var,$filter,$opts)) {
+                throw new Exception(_("Field validation does not match ").$msg);
+        }
+      }
+      if ($filter == FILTER_VALIDATE_INT) {
+       // Fix code code validate 0 as integer (add filter_var === 0)
+        if (! (filter_var($var,$filter) === 0 || filter_var($var,$filter) )) {
+                throw new Exception(_("Field validation not an int ").$msg);
+        }
+      }
+      if ($filter == FILTER_VALIDATE_FLOAT) {
+        if (!filter_var($var,$filter)) {
+                throw new Exception(_("Field validation not a float ").$msg);
+       }
+      }
+    }
+
+    /**
+     *
+     */
+    function email($var,$msg) {
+      $this->validate($var,FILTER_VALIDATE_EMAIL,$msg);
+    }
+
+    function str_date($var,$msg) {
+      $date = date_parse($var);
+      if ($date['error_count'] == 0 && checkdate($date['month'],$date['day'],$date['year']))
+      {
+        return ;
+      }
+      throw new Exception(_("Invalide date ").$msg);
+    }
+
+    /**
+     *
+     */
+    function str($var,$msg,$reg="/[A-Za-z0-9\-].*/") {
+      $this->validate($var,FILTER_VALIDATE_REGEXP,$msg,$reg);
+    }
+    /**
+     *
+     */
+    function num_int($var,$msg) {
+      $this->validate($var,FILTER_VALIDATE_INT,$msg);
+    }
+
+    /**
+     *
+     */
+    function num_float($var,$msg) {
+      $this->validate($var,FILTER_VALIDATE_FLOAT,$msg);
+    }
+}
+
+?>
diff --git a/iface.ActionResult.php b/iface.ActionResult.php
new file mode 100644 (file)
index 0000000..540b0f0
--- /dev/null
@@ -0,0 +1,12 @@
+<?php
+
+
+interface IActionResult 
+{
+    /**
+     * @brief render action result
+     *
+     */
+    public function render();
+}
+?>
diff --git a/iface.Request.php b/iface.Request.php
new file mode 100644 (file)
index 0000000..18e0fe6
--- /dev/null
@@ -0,0 +1,45 @@
+<?php
+
+
+interface IRequest 
+{
+    /**
+     *
+     *
+     */
+    public function getHeader($name);
+    /**
+     * Lets you access post and get parameters by the index
+     * In case of json requests the encoded json body is accessed
+     *
+     * @param string $key the key which you want to access in the URL Parameter
+     *                     placeholder, $_POST or $_GET array.
+     *                     The priority how they're returned is the following:
+     *                     1. URL parameters
+     *                     2. POST parameters
+     *                     3. GET parameters
+     * @param mixed $default If the key is not found, this value will be returned
+     * @return mixed the content of the array
+     * @since 6.0.0
+     */
+    public function getParam($key, $default = null);
+
+    /**
+     *
+     */
+    public function getServerHost();
+
+    /**
+     * return http request remote address even if behind a proxy
+     */
+    public function remoteAddr() ;
+    /**
+     *
+     */
+    public function getScheme();
+
+    public function getMethod();
+    
+    public function getPathInfo();
+}
+?>
diff --git a/monofont.ttf b/monofont.ttf
new file mode 100644 (file)
index 0000000..ec6c51b
Binary files /dev/null and b/monofont.ttf differ
diff --git a/utils.php b/utils.php
new file mode 100644 (file)
index 0000000..5110f13
--- /dev/null
+++ b/utils.php
@@ -0,0 +1,18 @@
+<?php
+
+function check_email_address($email) {
+    return filter_var($email,FILTER_VALIDATE_EMAIL);
+}
+
+/*Each $_POST variable will be checked by the function*/
+function test_input($data) {
+     $data = trim($data);
+     $data = stripslashes($data);
+     $data = htmlspecialchars($data);
+     return $data;
+}
+
+/**
+       vim:et:ts=4:sw=4:enc=utf-8
+ */
+?>