Commit ba58cdf9ff9a5268c0de49b8db0c5374c6653c4d
1 parent
534efd4a
Exists in
master
and in
7 other branches
Correcao nos includes
Showing
17 changed files
with
2340 additions
and
2325 deletions
Show diff stats
pacotes/.project
| ... | ... | @@ -6,6 +6,16 @@ |
| 6 | 6 | </projects> |
| 7 | 7 | <buildSpec> |
| 8 | 8 | <buildCommand> |
| 9 | + <name>org.eclipse.wst.validation.validationbuilder</name> | |
| 10 | + <arguments> | |
| 11 | + </arguments> | |
| 12 | + </buildCommand> | |
| 13 | + <buildCommand> | |
| 14 | + <name>org.eclipse.dltk.core.scriptbuilder</name> | |
| 15 | + <arguments> | |
| 16 | + </arguments> | |
| 17 | + </buildCommand> | |
| 18 | + <buildCommand> | |
| 9 | 19 | <name>org.eclipse.wst.jsdt.core.javascriptValidator</name> |
| 10 | 20 | <arguments> |
| 11 | 21 | </arguments> |
| ... | ... | @@ -13,5 +23,6 @@ |
| 13 | 23 | </buildSpec> |
| 14 | 24 | <natures> |
| 15 | 25 | <nature>org.eclipse.wst.jsdt.core.jsNature</nature> |
| 26 | + <nature>org.eclipse.php.core.PHPNature</nature> | |
| 16 | 27 | </natures> |
| 17 | 28 | </projectDescription> | ... | ... |
pacotes/arvorehiper/index.php
| 1 | 1 | <?php |
| 2 | -include("../../ms_configura.php"); | |
| 2 | +include(dirname(__FILE__)."/../../ms_configura.php"); | |
| 3 | 3 | $protocolo = explode("/",$_SERVER['SERVER_PROTOCOL']); |
| 4 | 4 | $url = $protocolo[0]."://".$_SERVER['HTTP_HOST']."/".basename($locaplic)."/admin/hiperbolica.php"; |
| 5 | 5 | $i3geo = $protocolo[0]."://".$_SERVER['HTTP_HOST']."/".basename($locaplic); |
| ... | ... | @@ -11,8 +11,8 @@ $i3geo = $protocolo[0]."://".$_SERVER['HTTP_HOST']."/".basename($locaplic); |
| 11 | 11 | </head> |
| 12 | 12 | <STYLE TYPE="text/css"> |
| 13 | 13 | table { |
| 14 | - width:100%; | |
| 15 | - text-align: left; | |
| 14 | + width:100%; | |
| 15 | + text-align: left; | |
| 16 | 16 | } |
| 17 | 17 | |
| 18 | 18 | body,ul,td { |
| ... | ... | @@ -51,30 +51,30 @@ border: 1px solid black; |
| 51 | 51 | </STYLE> |
| 52 | 52 | <body leftmargin="0" topmargin="0" class=" yui-skin-sam"> |
| 53 | 53 | <applet style=z-index:0;" code="tree.HTApplet.class" archive="tree4.jar" width="100%" height="100%" MAYSCRIPT="true"> |
| 54 | - <param name="htfile" value=""> | |
| 55 | - <param name="xmlfile" value="<?php echo $url;?>"> | |
| 56 | - <param name="xmltipo" value="verbete"> | |
| 57 | - <param name="htbackcoloredit" value="0xFF00FF"> | |
| 58 | - <param name="htbackcolor" value="0xFFFFFF"> | |
| 59 | - <param name="htlinkcolor" value="0x000000"> | |
| 60 | - <param name="htsearchcolor" value="0xFF0000"> | |
| 61 | - <param name="hthintcolor" value="0xFFFFD9"> | |
| 62 | - <param name="colornode" value="0xFFFACD"> | |
| 63 | - <param name="colortextnode" value="0x000000"> | |
| 64 | - <param name="colorrelationnode" value="0xE6E6FA"> | |
| 65 | - <param name="colortextrelationnode" value="0x00FF00"> | |
| 66 | - <param name="htbordertype" value="rounded"> | |
| 67 | - <param name="htfont" value="arial" > | |
| 68 | - <param name="htfontsize" value="11"> | |
| 69 | - <param name="htopenwindow" value="self"> | |
| 70 | - <param name="funcaoJS" value="SelecionaTema"> | |
| 71 | - </applet> | |
| 54 | + <param name="htfile" value=""> | |
| 55 | + <param name="xmlfile" value="<?php echo $url;?>"> | |
| 56 | + <param name="xmltipo" value="verbete"> | |
| 57 | + <param name="htbackcoloredit" value="0xFF00FF"> | |
| 58 | + <param name="htbackcolor" value="0xFFFFFF"> | |
| 59 | + <param name="htlinkcolor" value="0x000000"> | |
| 60 | + <param name="htsearchcolor" value="0xFF0000"> | |
| 61 | + <param name="hthintcolor" value="0xFFFFD9"> | |
| 62 | + <param name="colornode" value="0xFFFACD"> | |
| 63 | + <param name="colortextnode" value="0x000000"> | |
| 64 | + <param name="colorrelationnode" value="0xE6E6FA"> | |
| 65 | + <param name="colortextrelationnode" value="0x00FF00"> | |
| 66 | + <param name="htbordertype" value="rounded"> | |
| 67 | + <param name="htfont" value="arial" > | |
| 68 | + <param name="htfontsize" value="11"> | |
| 69 | + <param name="htopenwindow" value="self"> | |
| 70 | + <param name="funcaoJS" value="SelecionaTema"> | |
| 71 | + </applet> | |
| 72 | 72 | <script> |
| 73 | 73 | YAHOO.namespace("example.container"); |
| 74 | 74 | function SelecionaTema(id) { |
| 75 | - var myString = new String(id); | |
| 76 | - var myarray = myString.split(','); | |
| 77 | - | |
| 75 | + var myString = new String(id); | |
| 76 | + var myarray = myString.split(','); | |
| 77 | + | |
| 78 | 78 | if(myarray[0] == "tema") |
| 79 | 79 | { |
| 80 | 80 | core_montaEditor("","320px","500px") |
| ... | ... | @@ -88,7 +88,7 @@ function SelecionaTema(id) { |
| 88 | 88 | var fechar = function() |
| 89 | 89 | { |
| 90 | 90 | YAHOO.example.container.panelEditor.destroy(); |
| 91 | - YAHOO.example.container.panelEditor = null; | |
| 91 | + YAHOO.example.container.panelEditor = null; | |
| 92 | 92 | } |
| 93 | 93 | var i3geo = function() |
| 94 | 94 | { |
| ... | ... | @@ -121,7 +121,7 @@ function SelecionaTema(id) { |
| 121 | 121 | } |
| 122 | 122 | function listaTemasPorTag(dados) |
| 123 | 123 | { |
| 124 | - var ins = "Os seguintes temas contém o TAG clicado:<br><br>"; | |
| 124 | + var ins = "Os seguintes temas cont�m o TAG clicado:<br><br>"; | |
| 125 | 125 | ins += '<input type=button id=fechar value="Fechar" style="left:-5px;" /><br>' |
| 126 | 126 | |
| 127 | 127 | for (i=0;i < dados.length; i++) |
| ... | ... | @@ -141,7 +141,7 @@ function listaTemasPorTag(dados) |
| 141 | 141 | var fechar = function() |
| 142 | 142 | { |
| 143 | 143 | YAHOO.example.container.panelEditor.destroy(); |
| 144 | - YAHOO.example.container.panelEditor = null; | |
| 144 | + YAHOO.example.container.panelEditor = null; | |
| 145 | 145 | } |
| 146 | 146 | var adiciona = new YAHOO.widget.Button("fechar",{ onclick: { fn: fechar } }); |
| 147 | 147 | var temp = function(e) |
| ... | ... | @@ -150,17 +150,17 @@ function listaTemasPorTag(dados) |
| 150 | 150 | } |
| 151 | 151 | function removeAcentos(palavra) |
| 152 | 152 | { |
| 153 | - var re = /ã|á|à|â/gi; | |
| 153 | + var re = /�|�|�|�/gi; | |
| 154 | 154 | palavra = palavra.replace(re,"a"); |
| 155 | - var re = /é/gi; | |
| 155 | + var re = /�/gi; | |
| 156 | 156 | palavra = palavra.replace(re,"e"); |
| 157 | - var re = /í/gi; | |
| 157 | + var re = /�/gi; | |
| 158 | 158 | palavra = palavra.replace(re,"i"); |
| 159 | - var re = /ó|õ/gi; | |
| 159 | + var re = /�|�/gi; | |
| 160 | 160 | palavra = palavra.replace(re,"o"); |
| 161 | - var re = /ç/gi; | |
| 161 | + var re = /�/gi; | |
| 162 | 162 | palavra = palavra.replace(re,"c"); |
| 163 | - var re = /ú/gi; | |
| 163 | + var re = /�/gi; | |
| 164 | 164 | palavra = palavra.replace(re,"u"); |
| 165 | 165 | return(palavra); |
| 166 | 166 | } | ... | ... |
pacotes/cpaint/JSON/testsuite.php
| 1 | 1 | <?php |
| 2 | -/** | |
| 2 | +/** | |
| 3 | 3 | * The content of this file is (c) 2003-2005 digital media center GmbH |
| 4 | 4 | * All rights reserved |
| 5 | 5 | * |
| ... | ... | @@ -12,49 +12,49 @@ |
| 12 | 12 | */ |
| 13 | 13 | |
| 14 | 14 | //---- includes ---------------------------------------------------------------- |
| 15 | - /** | |
| 15 | + /** | |
| 16 | 16 | * @include JSON |
| 17 | 17 | */ |
| 18 | - require_once('../json.php'); | |
| 19 | - | |
| 18 | + require_once(dirname(__FILE__).'/../json.php'); | |
| 19 | + | |
| 20 | 20 | //---- class ------------------------------------------------------------------- |
| 21 | 21 | class MyObj { |
| 22 | 22 | var $id = ''; |
| 23 | 23 | var $name = ''; |
| 24 | 24 | var $attribs = array("first",'4'); |
| 25 | - | |
| 25 | + | |
| 26 | 26 | function setId($id) { |
| 27 | 27 | $this->id = $id; |
| 28 | 28 | } |
| 29 | - | |
| 29 | + | |
| 30 | 30 | function getId() { |
| 31 | 31 | return $this->id; |
| 32 | 32 | } |
| 33 | - | |
| 33 | + | |
| 34 | 34 | function setName($name) { |
| 35 | 35 | $this->name = $name; |
| 36 | 36 | } |
| 37 | - | |
| 37 | + | |
| 38 | 38 | function getName() { |
| 39 | 39 | return $this->name; |
| 40 | 40 | } |
| 41 | 41 | } |
| 42 | - | |
| 42 | + | |
| 43 | 43 | //---- variables --------------------------------------------------------------- |
| 44 | 44 | $JSON = new JSON(); |
| 45 | 45 | $myObj = new MyObj(); |
| 46 | - | |
| 46 | + | |
| 47 | 47 | //---- logic ------------------------------------------------------------------- |
| 48 | 48 | /* initialize object */ |
| 49 | - $myObj->setId('Äl' . chr(18) . "ie\nn"); | |
| 49 | + $myObj->setId('�l' . chr(18) . "ie\nn"); | |
| 50 | 50 | $myObj->setName('objectName'); |
| 51 | - array_push($myObj->attribs, 'øfirst'); | |
| 51 | + array_push($myObj->attribs, '�first'); | |
| 52 | 52 | array_push($myObj->attribs, 'second'); |
| 53 | 53 | array_push($myObj->attribs, 3); |
| 54 | 54 | |
| 55 | 55 | /* create JSON representation */ |
| 56 | 56 | $jsonStr = $JSON->stringify($myObj); |
| 57 | - | |
| 57 | + | |
| 58 | 58 | //---- clean-up ---------------------------------------------------------------- |
| 59 | 59 | //---- content ----------------------------------------------------------------- |
| 60 | 60 | |
| ... | ... | @@ -65,159 +65,159 @@ |
| 65 | 65 | <script type="text/javascript" src="json.js"></script> |
| 66 | 66 | <script type="text/javascript"> |
| 67 | 67 | JSON.arrayObj = new Array(); |
| 68 | -JSON.parse2 = function (text) | |
| 69 | -{ | |
| 68 | +JSON.parse2 = function (text) | |
| 69 | +{ | |
| 70 | 70 | var p = /^\s*(([,:{}\[\]])|"(\\.|[^\x00-\x1f"\\])*"|-?\d+(\.\d*)?([eE][+-]?\d+)?|true|false|null|\/\*Array\*\/)\s*/, |
| 71 | - token, | |
| 72 | - operator; | |
| 73 | - | |
| 74 | - function error(m, t) { | |
| 75 | - throw { | |
| 76 | - name: 'JSONError', | |
| 77 | - message: m, | |
| 78 | - text: t || operator || token | |
| 79 | - }; | |
| 80 | - } | |
| 81 | - | |
| 82 | - function next() { | |
| 83 | - if (text) { | |
| 84 | - var t = p.exec(text); | |
| 85 | - if (t) { | |
| 86 | - | |
| 87 | - if (t[2]) { | |
| 88 | - token = null; | |
| 89 | - operator = t[2]; | |
| 90 | - } else { | |
| 91 | - operator = null; | |
| 92 | - if(t[1].search (/^\/\*Array\*\/$/g) > -1) | |
| 93 | - { | |
| 94 | - token = function(){}; | |
| 95 | - } | |
| 96 | - else | |
| 97 | - { | |
| 98 | - try { | |
| 99 | - token = eval(t[1]); | |
| 100 | - } catch (e) { | |
| 101 | - error("Bad token", t[1]); | |
| 102 | - } | |
| 103 | - } | |
| 104 | - } | |
| 105 | - text = text.substring(t[0].length); | |
| 106 | - } else { | |
| 107 | - error("Unrecognized token", text); | |
| 108 | - } | |
| 109 | - } else { | |
| 110 | - token = operator = undefined; | |
| 111 | - } | |
| 112 | - } | |
| 113 | - | |
| 114 | - | |
| 115 | - function arr() { | |
| 116 | - var a = []; | |
| 117 | - | |
| 118 | - next(); | |
| 119 | - if (operator == ']') { | |
| 120 | - next(); | |
| 121 | - return a; | |
| 122 | - } | |
| 123 | - for (;;) { | |
| 124 | - a.push(val()); | |
| 125 | - switch (operator) { | |
| 126 | - case ']': | |
| 127 | - next(); | |
| 128 | - return a; | |
| 129 | - case ',': | |
| 130 | - next(); | |
| 131 | - break; | |
| 132 | - default: | |
| 133 | - error("Missing ']'"); | |
| 134 | - } | |
| 135 | - } | |
| 136 | - } | |
| 137 | - | |
| 138 | - function obj() { | |
| 139 | - var k, o = {}; | |
| 140 | - | |
| 141 | - next(); | |
| 142 | - if (operator == '}') { | |
| 143 | - next(); | |
| 144 | - return o; | |
| 145 | - } | |
| 146 | - if (typeof(token) == 'function') | |
| 147 | - { | |
| 148 | - o = []; | |
| 149 | - next(); | |
| 150 | - } | |
| 151 | - for (;;) | |
| 152 | - { | |
| 153 | - | |
| 154 | - | |
| 155 | - if (operator ||typeof token != 'string') { | |
| 156 | - error("Missing key"); | |
| 157 | - } | |
| 158 | - k = token; | |
| 159 | - next(); | |
| 160 | - | |
| 161 | - if (operator != ':') { | |
| 162 | - error("Missing ':'"); | |
| 163 | - } | |
| 164 | - | |
| 165 | - next(); | |
| 166 | - o[k] = val(); | |
| 167 | - | |
| 168 | - switch (operator) { | |
| 169 | - case '}': | |
| 170 | - next(); | |
| 171 | - return o; | |
| 172 | - case ',': | |
| 173 | - next(); | |
| 174 | - break; | |
| 175 | - case '#': | |
| 176 | - next(); | |
| 177 | - break; | |
| 178 | - default: | |
| 179 | - error("Missing '}'"); | |
| 180 | - } | |
| 181 | - } | |
| 182 | - } | |
| 183 | - | |
| 184 | - function val() { | |
| 185 | - switch (operator) { | |
| 186 | - case '{': | |
| 187 | - return obj(); | |
| 188 | - case '[': | |
| 189 | - return arr(); | |
| 190 | - default: | |
| 191 | - if (operator !== null) { | |
| 192 | - error("Missing value"); | |
| 193 | - } | |
| 194 | - var t = token; | |
| 195 | - next(); | |
| 196 | - return t; | |
| 197 | - } | |
| 198 | - } | |
| 199 | - next(); | |
| 200 | - return val(); | |
| 71 | + token, | |
| 72 | + operator; | |
| 73 | + | |
| 74 | + function error(m, t) { | |
| 75 | + throw { | |
| 76 | + name: 'JSONError', | |
| 77 | + message: m, | |
| 78 | + text: t || operator || token | |
| 79 | + }; | |
| 80 | + } | |
| 81 | + | |
| 82 | + function next() { | |
| 83 | + if (text) { | |
| 84 | + var t = p.exec(text); | |
| 85 | + if (t) { | |
| 86 | + | |
| 87 | + if (t[2]) { | |
| 88 | + token = null; | |
| 89 | + operator = t[2]; | |
| 90 | + } else { | |
| 91 | + operator = null; | |
| 92 | + if(t[1].search (/^\/\*Array\*\/$/g) > -1) | |
| 93 | + { | |
| 94 | + token = function(){}; | |
| 95 | + } | |
| 96 | + else | |
| 97 | + { | |
| 98 | + try { | |
| 99 | + token = eval(t[1]); | |
| 100 | + } catch (e) { | |
| 101 | + error("Bad token", t[1]); | |
| 102 | + } | |
| 103 | + } | |
| 104 | + } | |
| 105 | + text = text.substring(t[0].length); | |
| 106 | + } else { | |
| 107 | + error("Unrecognized token", text); | |
| 108 | + } | |
| 109 | + } else { | |
| 110 | + token = operator = undefined; | |
| 111 | + } | |
| 112 | + } | |
| 113 | + | |
| 114 | + | |
| 115 | + function arr() { | |
| 116 | + var a = []; | |
| 117 | + | |
| 118 | + next(); | |
| 119 | + if (operator == ']') { | |
| 120 | + next(); | |
| 121 | + return a; | |
| 122 | + } | |
| 123 | + for (;;) { | |
| 124 | + a.push(val()); | |
| 125 | + switch (operator) { | |
| 126 | + case ']': | |
| 127 | + next(); | |
| 128 | + return a; | |
| 129 | + case ',': | |
| 130 | + next(); | |
| 131 | + break; | |
| 132 | + default: | |
| 133 | + error("Missing ']'"); | |
| 134 | + } | |
| 135 | + } | |
| 136 | + } | |
| 137 | + | |
| 138 | + function obj() { | |
| 139 | + var k, o = {}; | |
| 140 | + | |
| 141 | + next(); | |
| 142 | + if (operator == '}') { | |
| 143 | + next(); | |
| 144 | + return o; | |
| 145 | + } | |
| 146 | + if (typeof(token) == 'function') | |
| 147 | + { | |
| 148 | + o = []; | |
| 149 | + next(); | |
| 150 | + } | |
| 151 | + for (;;) | |
| 152 | + { | |
| 153 | + | |
| 154 | + | |
| 155 | + if (operator ||typeof token != 'string') { | |
| 156 | + error("Missing key"); | |
| 157 | + } | |
| 158 | + k = token; | |
| 159 | + next(); | |
| 160 | + | |
| 161 | + if (operator != ':') { | |
| 162 | + error("Missing ':'"); | |
| 163 | + } | |
| 164 | + | |
| 165 | + next(); | |
| 166 | + o[k] = val(); | |
| 167 | + | |
| 168 | + switch (operator) { | |
| 169 | + case '}': | |
| 170 | + next(); | |
| 171 | + return o; | |
| 172 | + case ',': | |
| 173 | + next(); | |
| 174 | + break; | |
| 175 | + case '#': | |
| 176 | + next(); | |
| 177 | + break; | |
| 178 | + default: | |
| 179 | + error("Missing '}'"); | |
| 180 | + } | |
| 181 | + } | |
| 182 | + } | |
| 183 | + | |
| 184 | + function val() { | |
| 185 | + switch (operator) { | |
| 186 | + case '{': | |
| 187 | + return obj(); | |
| 188 | + case '[': | |
| 189 | + return arr(); | |
| 190 | + default: | |
| 191 | + if (operator !== null) { | |
| 192 | + error("Missing value"); | |
| 193 | + } | |
| 194 | + var t = token; | |
| 195 | + next(); | |
| 196 | + return t; | |
| 197 | + } | |
| 198 | + } | |
| 199 | + next(); | |
| 200 | + return val(); | |
| 201 | 201 | }; |
| 202 | 202 | |
| 203 | 203 | JSON.stringify2 = function(arg) |
| 204 | 204 | { |
| 205 | 205 | var jsonstring = []; |
| 206 | 206 | var b = this; |
| 207 | - function add(str) | |
| 207 | + function add(str) | |
| 208 | 208 | { |
| 209 | - jsonstring[jsonstring.length] = str; | |
| 210 | - } | |
| 211 | - function validObj(obj) | |
| 212 | - { | |
| 213 | - if (typeof(obj) != 'undefined' && typeof(obj) != 'function') | |
| 214 | - { | |
| 215 | - return true; | |
| 216 | - } | |
| 217 | - return false; | |
| 218 | - } | |
| 209 | + jsonstring[jsonstring.length] = str; | |
| 210 | + } | |
| 211 | + function validObj(obj) | |
| 212 | + { | |
| 213 | + if (typeof(obj) != 'undefined' && typeof(obj) != 'function') | |
| 214 | + { | |
| 215 | + return true; | |
| 216 | + } | |
| 217 | + return false; | |
| 218 | + } | |
| 219 | 219 | function recurse(obj, prefix) |
| 220 | - { | |
| 220 | + { | |
| 221 | 221 | switch (typeof(obj)) |
| 222 | 222 | { |
| 223 | 223 | case 'object': |
| ... | ... | @@ -248,7 +248,7 @@ JSON.stringify2 = function(arg) |
| 248 | 248 | } |
| 249 | 249 | } |
| 250 | 250 | return add ('}'); |
| 251 | - } | |
| 251 | + } | |
| 252 | 252 | return add('null'); |
| 253 | 253 | break; |
| 254 | 254 | case 'number': |
| ... | ... | @@ -256,42 +256,42 @@ JSON.stringify2 = function(arg) |
| 256 | 256 | break; |
| 257 | 257 | case 'string': |
| 258 | 258 | l = obj.length; |
| 259 | - add('"'); | |
| 260 | - for (i = 0; i < l; i += 1) { | |
| 261 | - c = obj.charAt(i); | |
| 262 | - if (c >= ' ') { | |
| 263 | - if (c == '\\' || c == '"') { | |
| 264 | - add('\\'); | |
| 265 | - } | |
| 266 | - add(c); | |
| 267 | - } else { | |
| 268 | - switch (c) { | |
| 269 | - case '\b': | |
| 270 | - add('\\b'); | |
| 271 | - break; | |
| 272 | - case '\f': | |
| 273 | - add('\\f'); | |
| 274 | - break; | |
| 275 | - case '\n': | |
| 276 | - add('\\n'); | |
| 277 | - break; | |
| 278 | - case '\r': | |
| 279 | - add('\\r'); | |
| 280 | - break; | |
| 281 | - case '\t': | |
| 282 | - add('\\t'); | |
| 283 | - break; | |
| 284 | - default: | |
| 285 | - c = c.charCodeAt(); | |
| 286 | - add('\\u00' + Math.floor(c / 16).toString(16) + (c % 16).toString(16)); | |
| 287 | - } | |
| 288 | - } | |
| 289 | - } | |
| 290 | - return add('"'); | |
| 259 | + add('"'); | |
| 260 | + for (i = 0; i < l; i += 1) { | |
| 261 | + c = obj.charAt(i); | |
| 262 | + if (c >= ' ') { | |
| 263 | + if (c == '\\' || c == '"') { | |
| 264 | + add('\\'); | |
| 265 | + } | |
| 266 | + add(c); | |
| 267 | + } else { | |
| 268 | + switch (c) { | |
| 269 | + case '\b': | |
| 270 | + add('\\b'); | |
| 271 | + break; | |
| 272 | + case '\f': | |
| 273 | + add('\\f'); | |
| 274 | + break; | |
| 275 | + case '\n': | |
| 276 | + add('\\n'); | |
| 277 | + break; | |
| 278 | + case '\r': | |
| 279 | + add('\\r'); | |
| 280 | + break; | |
| 281 | + case '\t': | |
| 282 | + add('\\t'); | |
| 283 | + break; | |
| 284 | + default: | |
| 285 | + c = c.charCodeAt(); | |
| 286 | + add('\\u00' + Math.floor(c / 16).toString(16) + (c % 16).toString(16)); | |
| 287 | + } | |
| 288 | + } | |
| 289 | + } | |
| 290 | + return add('"'); | |
| 291 | 291 | break; |
| 292 | 292 | case 'boolean': |
| 293 | 293 | return add(String(obj)); |
| 294 | - break; | |
| 294 | + break; | |
| 295 | 295 | default: |
| 296 | 296 | return add('null'); |
| 297 | 297 | break; |
| ... | ... | @@ -308,16 +308,16 @@ JSON.stringify2 = function(arg) |
| 308 | 308 | <!-- |
| 309 | 309 | /* print JSON representation */ |
| 310 | 310 | var jsonStr = '<?php echo addslashes($jsonStr); ?>'; |
| 311 | - | |
| 311 | + | |
| 312 | 312 | document.write('JavaScript JSONstr: ' + jsonStr); |
| 313 | 313 | |
| 314 | 314 | /* create another object from jsonStr */ |
| 315 | - try | |
| 315 | + try | |
| 316 | 316 | { |
| 317 | 317 | var myObj2 = JSON.parse(jsonStr); |
| 318 | - | |
| 319 | - var myObj3 = JSON.parse2(jsonStr); | |
| 320 | - | |
| 318 | + | |
| 319 | + var myObj3 = JSON.parse2(jsonStr); | |
| 320 | + | |
| 321 | 321 | |
| 322 | 322 | /* test the clone */ |
| 323 | 323 | document.write('<br /><br />Original JSON implementation'); |
| ... | ... | @@ -334,12 +334,12 @@ JSON.stringify2 = function(arg) |
| 334 | 334 | for (var i = 0; i < myObj3.attribs.length; i++) { |
| 335 | 335 | document.write('<br />attrib[' + i + ']: ' + myObj3.attribs[i]); |
| 336 | 336 | } |
| 337 | - | |
| 337 | + | |
| 338 | 338 | /* convert newline to JSON */ |
| 339 | 339 | var nl = "\n" + String.fromCharCode(18); |
| 340 | 340 | document.write('<br /><br /> Original JSON <br />newline as JSON: ' + JSON.stringify(nl)); |
| 341 | 341 | document.write('<br /><br /> New JSON <br />newline as JSON: ' + JSON.stringify2(nl)); |
| 342 | - | |
| 342 | + | |
| 343 | 343 | //--> |
| 344 | 344 | } |
| 345 | 345 | catch(e) | ... | ... |
pacotes/cpaint/JSON/testsuite2.php
| ... | ... | @@ -2,17 +2,17 @@ |
| 2 | 2 | |
| 3 | 3 | // New TestSuite |
| 4 | 4 | //---- includes ---------------------------------------------------------------- |
| 5 | - /** | |
| 5 | + /** | |
| 6 | 6 | * @include JSON |
| 7 | 7 | */ |
| 8 | - require_once('../json.php'); | |
| 8 | + require_once(dirname(__FILE__).'/../json.php'); | |
| 9 | 9 | require_once('json2.php'); |
| 10 | 10 | |
| 11 | 11 | // ----- PHP Test Objects |
| 12 | 12 | class object1 |
| 13 | 13 | { |
| 14 | 14 | var $firstattr = 'firstvalue'; |
| 15 | - var $foreignchars = "Äø\r\n"; | |
| 15 | + var $foreignchars = "��\r\n"; | |
| 16 | 16 | var $regarray = array("item1", "item2"); |
| 17 | 17 | var $assocarray = array("item1"=>"value1", "item2"=>"value2"); |
| 18 | 18 | var $boolean = true; |
| ... | ... | @@ -66,159 +66,159 @@ class object2 |
| 66 | 66 | <script type="text/javascript" src="json.js"></script> |
| 67 | 67 | <script type="text/javascript"> |
| 68 | 68 | JSON.arrayObj = new Array(); |
| 69 | -JSON.parse2 = function (text) | |
| 70 | -{ | |
| 69 | +JSON.parse2 = function (text) | |
| 70 | +{ | |
| 71 | 71 | var p = /^\s*(([,:{}\[\]])|"(\\.|[^\x00-\x1f"\\])*"|-?\d+(\.\d*)?([eE][+-]?\d+)?|true|false|null|\/\*Array\*\/)\s*/, |
| 72 | - token, | |
| 73 | - operator; | |
| 72 | + token, | |
| 73 | + operator; | |
| 74 | + | |
| 75 | + function error(m, t) { | |
| 76 | + throw { | |
| 77 | + name: 'JSONError', | |
| 78 | + message: m, | |
| 79 | + text: t || operator || token | |
| 80 | + }; | |
| 81 | + } | |
| 82 | + | |
| 83 | + function next() { | |
| 84 | + if (text) { | |
| 85 | + var t = p.exec(text); | |
| 86 | + if (t) { | |
| 74 | 87 | |
| 75 | - function error(m, t) { | |
| 76 | - throw { | |
| 77 | - name: 'JSONError', | |
| 78 | - message: m, | |
| 79 | - text: t || operator || token | |
| 80 | - }; | |
| 81 | - } | |
| 88 | + if (t[2]) { | |
| 89 | + token = null; | |
| 90 | + operator = t[2]; | |
| 91 | + } else { | |
| 92 | + operator = null; | |
| 93 | + if(t[1].search (/^\/\*Array\*\/$/g) > -1) | |
| 94 | + { | |
| 95 | + token = function(){}; | |
| 96 | + } | |
| 97 | + else | |
| 98 | + { | |
| 99 | + try { | |
| 100 | + token = eval(t[1]); | |
| 101 | + } catch (e) { | |
| 102 | + error("Bad token", t[1]); | |
| 103 | + } | |
| 104 | + } | |
| 105 | + } | |
| 106 | + text = text.substring(t[0].length); | |
| 107 | + } else { | |
| 108 | + error("Unrecognized token", text); | |
| 109 | + } | |
| 110 | + } else { | |
| 111 | + token = operator = undefined; | |
| 112 | + } | |
| 113 | + } | |
| 82 | 114 | |
| 83 | - function next() { | |
| 84 | - if (text) { | |
| 85 | - var t = p.exec(text); | |
| 86 | - if (t) { | |
| 87 | - | |
| 88 | - if (t[2]) { | |
| 89 | - token = null; | |
| 90 | - operator = t[2]; | |
| 91 | - } else { | |
| 92 | - operator = null; | |
| 93 | - if(t[1].search (/^\/\*Array\*\/$/g) > -1) | |
| 94 | - { | |
| 95 | - token = function(){}; | |
| 96 | - } | |
| 97 | - else | |
| 98 | - { | |
| 99 | - try { | |
| 100 | - token = eval(t[1]); | |
| 101 | - } catch (e) { | |
| 102 | - error("Bad token", t[1]); | |
| 103 | - } | |
| 104 | - } | |
| 105 | - } | |
| 106 | - text = text.substring(t[0].length); | |
| 107 | - } else { | |
| 108 | - error("Unrecognized token", text); | |
| 109 | - } | |
| 110 | - } else { | |
| 111 | - token = operator = undefined; | |
| 112 | - } | |
| 113 | - } | |
| 114 | 115 | |
| 116 | + function arr() { | |
| 117 | + var a = []; | |
| 115 | 118 | |
| 116 | - function arr() { | |
| 117 | - var a = []; | |
| 119 | + next(); | |
| 120 | + if (operator == ']') { | |
| 121 | + next(); | |
| 122 | + return a; | |
| 123 | + } | |
| 124 | + for (;;) { | |
| 125 | + a.push(val()); | |
| 126 | + switch (operator) { | |
| 127 | + case ']': | |
| 128 | + next(); | |
| 129 | + return a; | |
| 130 | + case ',': | |
| 131 | + next(); | |
| 132 | + break; | |
| 133 | + default: | |
| 134 | + error("Missing ']'"); | |
| 135 | + } | |
| 136 | + } | |
| 137 | + } | |
| 118 | 138 | |
| 119 | - next(); | |
| 120 | - if (operator == ']') { | |
| 121 | - next(); | |
| 122 | - return a; | |
| 123 | - } | |
| 124 | - for (;;) { | |
| 125 | - a.push(val()); | |
| 126 | - switch (operator) { | |
| 127 | - case ']': | |
| 128 | - next(); | |
| 129 | - return a; | |
| 130 | - case ',': | |
| 131 | - next(); | |
| 132 | - break; | |
| 133 | - default: | |
| 134 | - error("Missing ']'"); | |
| 135 | - } | |
| 136 | - } | |
| 137 | - } | |
| 139 | + function obj() { | |
| 140 | + var k, o = {}; | |
| 141 | + | |
| 142 | + next(); | |
| 143 | + if (operator == '}') { | |
| 144 | + next(); | |
| 145 | + return o; | |
| 146 | + } | |
| 147 | + if (typeof(token) == 'function') | |
| 148 | + { | |
| 149 | + o = []; | |
| 150 | + next(); | |
| 151 | + } | |
| 152 | + for (;;) | |
| 153 | + { | |
| 138 | 154 | |
| 139 | - function obj() { | |
| 140 | - var k, o = {}; | |
| 141 | - | |
| 142 | - next(); | |
| 143 | - if (operator == '}') { | |
| 144 | - next(); | |
| 145 | - return o; | |
| 146 | - } | |
| 147 | - if (typeof(token) == 'function') | |
| 148 | - { | |
| 149 | - o = []; | |
| 150 | - next(); | |
| 151 | - } | |
| 152 | - for (;;) | |
| 153 | - { | |
| 154 | - | |
| 155 | - | |
| 156 | - if (operator ||typeof token != 'string') { | |
| 157 | - error("Missing key"); | |
| 158 | - } | |
| 159 | - k = token; | |
| 160 | - next(); | |
| 161 | - | |
| 162 | - if (operator != ':') { | |
| 163 | - error("Missing ':'"); | |
| 164 | - } | |
| 165 | - | |
| 166 | - next(); | |
| 167 | - o[k] = val(); | |
| 168 | - | |
| 169 | - switch (operator) { | |
| 170 | - case '}': | |
| 171 | - next(); | |
| 172 | - return o; | |
| 173 | - case ',': | |
| 174 | - next(); | |
| 175 | - break; | |
| 176 | - case '#': | |
| 177 | - next(); | |
| 178 | - break; | |
| 179 | - default: | |
| 180 | - error("Missing '}'"); | |
| 181 | - } | |
| 182 | - } | |
| 183 | - } | |
| 184 | 155 | |
| 185 | - function val() { | |
| 186 | - switch (operator) { | |
| 187 | - case '{': | |
| 188 | - return obj(); | |
| 189 | - case '[': | |
| 190 | - return arr(); | |
| 191 | - default: | |
| 192 | - if (operator !== null) { | |
| 193 | - error("Missing value"); | |
| 194 | - } | |
| 195 | - var t = token; | |
| 196 | - next(); | |
| 197 | - return t; | |
| 198 | - } | |
| 199 | - } | |
| 200 | - next(); | |
| 201 | - return val(); | |
| 156 | + if (operator ||typeof token != 'string') { | |
| 157 | + error("Missing key"); | |
| 158 | + } | |
| 159 | + k = token; | |
| 160 | + next(); | |
| 161 | + | |
| 162 | + if (operator != ':') { | |
| 163 | + error("Missing ':'"); | |
| 164 | + } | |
| 165 | + | |
| 166 | + next(); | |
| 167 | + o[k] = val(); | |
| 168 | + | |
| 169 | + switch (operator) { | |
| 170 | + case '}': | |
| 171 | + next(); | |
| 172 | + return o; | |
| 173 | + case ',': | |
| 174 | + next(); | |
| 175 | + break; | |
| 176 | + case '#': | |
| 177 | + next(); | |
| 178 | + break; | |
| 179 | + default: | |
| 180 | + error("Missing '}'"); | |
| 181 | + } | |
| 182 | + } | |
| 183 | + } | |
| 184 | + | |
| 185 | + function val() { | |
| 186 | + switch (operator) { | |
| 187 | + case '{': | |
| 188 | + return obj(); | |
| 189 | + case '[': | |
| 190 | + return arr(); | |
| 191 | + default: | |
| 192 | + if (operator !== null) { | |
| 193 | + error("Missing value"); | |
| 194 | + } | |
| 195 | + var t = token; | |
| 196 | + next(); | |
| 197 | + return t; | |
| 198 | + } | |
| 199 | + } | |
| 200 | + next(); | |
| 201 | + return val(); | |
| 202 | 202 | }; |
| 203 | 203 | |
| 204 | 204 | JSON.stringify2 = function(arg) |
| 205 | 205 | { |
| 206 | 206 | var jsonstring = []; |
| 207 | 207 | var b = this; |
| 208 | - function add(str) | |
| 208 | + function add(str) | |
| 209 | 209 | { |
| 210 | - jsonstring[jsonstring.length] = str; | |
| 211 | - } | |
| 212 | - function validObj(obj) | |
| 213 | - { | |
| 214 | - if (typeof(obj) != 'undefined' && typeof(obj) != 'function') | |
| 215 | - { | |
| 216 | - return true; | |
| 217 | - } | |
| 218 | - return false; | |
| 219 | - } | |
| 210 | + jsonstring[jsonstring.length] = str; | |
| 211 | + } | |
| 212 | + function validObj(obj) | |
| 213 | + { | |
| 214 | + if (typeof(obj) != 'undefined' && typeof(obj) != 'function') | |
| 215 | + { | |
| 216 | + return true; | |
| 217 | + } | |
| 218 | + return false; | |
| 219 | + } | |
| 220 | 220 | function recurse(obj, prefix) |
| 221 | - { | |
| 221 | + { | |
| 222 | 222 | switch (typeof(obj)) |
| 223 | 223 | { |
| 224 | 224 | case 'object': |
| ... | ... | @@ -249,7 +249,7 @@ JSON.stringify2 = function(arg) |
| 249 | 249 | } |
| 250 | 250 | } |
| 251 | 251 | return add ('}'); |
| 252 | - } | |
| 252 | + } | |
| 253 | 253 | return add('null'); |
| 254 | 254 | break; |
| 255 | 255 | case 'number': |
| ... | ... | @@ -257,42 +257,42 @@ JSON.stringify2 = function(arg) |
| 257 | 257 | break; |
| 258 | 258 | case 'string': |
| 259 | 259 | l = obj.length; |
| 260 | - add('"'); | |
| 261 | - for (i = 0; i < l; i += 1) { | |
| 262 | - c = obj.charAt(i); | |
| 263 | - if (c >= ' ') { | |
| 264 | - if (c == '\\' || c == '"') { | |
| 265 | - add('\\'); | |
| 266 | - } | |
| 267 | - add(c); | |
| 268 | - } else { | |
| 269 | - switch (c) { | |
| 270 | - case '\b': | |
| 271 | - add('\\b'); | |
| 272 | - break; | |
| 273 | - case '\f': | |
| 274 | - add('\\f'); | |
| 275 | - break; | |
| 276 | - case '\n': | |
| 277 | - add('\\n'); | |
| 278 | - break; | |
| 279 | - case '\r': | |
| 280 | - add('\\r'); | |
| 281 | - break; | |
| 282 | - case '\t': | |
| 283 | - add('\\t'); | |
| 284 | - break; | |
| 285 | - default: | |
| 286 | - c = c.charCodeAt(); | |
| 287 | - add('\\u00' + Math.floor(c / 16).toString(16) + (c % 16).toString(16)); | |
| 288 | - } | |
| 289 | - } | |
| 290 | - } | |
| 291 | - return add('"'); | |
| 260 | + add('"'); | |
| 261 | + for (i = 0; i < l; i += 1) { | |
| 262 | + c = obj.charAt(i); | |
| 263 | + if (c >= ' ') { | |
| 264 | + if (c == '\\' || c == '"') { | |
| 265 | + add('\\'); | |
| 266 | + } | |
| 267 | + add(c); | |
| 268 | + } else { | |
| 269 | + switch (c) { | |
| 270 | + case '\b': | |
| 271 | + add('\\b'); | |
| 272 | + break; | |
| 273 | + case '\f': | |
| 274 | + add('\\f'); | |
| 275 | + break; | |
| 276 | + case '\n': | |
| 277 | + add('\\n'); | |
| 278 | + break; | |
| 279 | + case '\r': | |
| 280 | + add('\\r'); | |
| 281 | + break; | |
| 282 | + case '\t': | |
| 283 | + add('\\t'); | |
| 284 | + break; | |
| 285 | + default: | |
| 286 | + c = c.charCodeAt(); | |
| 287 | + add('\\u00' + Math.floor(c / 16).toString(16) + (c % 16).toString(16)); | |
| 288 | + } | |
| 289 | + } | |
| 290 | + } | |
| 291 | + return add('"'); | |
| 292 | 292 | break; |
| 293 | 293 | case 'boolean': |
| 294 | 294 | return add(String(obj)); |
| 295 | - break; | |
| 295 | + break; | |
| 296 | 296 | default: |
| 297 | 297 | return add('null'); |
| 298 | 298 | break; |
| ... | ... | @@ -311,7 +311,7 @@ JSON.stringify2 = function(arg) |
| 311 | 311 | <caption>Original JSON PHP/Javascript</caption> |
| 312 | 312 | <tr> |
| 313 | 313 | <td> |
| 314 | - Original PHP object (print_r) | |
| 314 | + Original PHP object (print_r) | |
| 315 | 315 | <textarea rows="5" cols="50"><?php echo print_r($object1); ?></textarea> |
| 316 | 316 | </td> |
| 317 | 317 | </tr> |
| ... | ... | @@ -321,7 +321,7 @@ JSON.stringify2 = function(arg) |
| 321 | 321 | <tr> |
| 322 | 322 | <td>Did it Convert to a Javascript Object origjsobj ?<br /> |
| 323 | 323 | <script> |
| 324 | - try | |
| 324 | + try | |
| 325 | 325 | { |
| 326 | 326 | var origjsobj = JSON.parse('<?php echo addslashes($origjsonstring); ?>'); |
| 327 | 327 | document.write('Successful'); |
| ... | ... | @@ -330,9 +330,9 @@ JSON.stringify2 = function(arg) |
| 330 | 330 | { |
| 331 | 331 | document.write('Failed'); |
| 332 | 332 | document.write(' Original Parse Failed with this error "' + e.message + '"'); |
| 333 | - } | |
| 333 | + } | |
| 334 | 334 | </script> |
| 335 | - <br /><button onclick="s=document.body.appendChild(document.createElement('script'));s.id='sst';s.language='javascript';void(s.src='http://snmp-dev.cableaz.com/beta/print_r_0_3.js');">Invoke Print_R</button> | |
| 335 | + <br /><button onclick="s=document.body.appendChild(document.createElement('script'));s.id='sst';s.language='javascript';void(s.src='http://snmp-dev.cableaz.com/beta/print_r_0_3.js');">Invoke Print_R</button> | |
| 336 | 336 | </td> |
| 337 | 337 | </tr> |
| 338 | 338 | <tr> |
| ... | ... | @@ -356,7 +356,7 @@ JSON.stringify2 = function(arg) |
| 356 | 356 | <caption>New JSON PHP/Javascript</caption> |
| 357 | 357 | <tr> |
| 358 | 358 | <td> |
| 359 | - Original PHP object (print_r) | |
| 359 | + Original PHP object (print_r) | |
| 360 | 360 | <textarea rows="5" cols="50"><?php echo print_r($object1); ?></textarea> |
| 361 | 361 | </td> |
| 362 | 362 | </tr> |
| ... | ... | @@ -366,7 +366,7 @@ JSON.stringify2 = function(arg) |
| 366 | 366 | <tr> |
| 367 | 367 | <td>Did it Convert to a Javascript Object newjsobj ?<br /> |
| 368 | 368 | <script> |
| 369 | - try | |
| 369 | + try | |
| 370 | 370 | { |
| 371 | 371 | var newjsobj = JSON.parse2('<?php echo addslashes($newjsonstring); ?>'); |
| 372 | 372 | document.write('Successful'); |
| ... | ... | @@ -375,9 +375,9 @@ JSON.stringify2 = function(arg) |
| 375 | 375 | { |
| 376 | 376 | document.write('Failed'); |
| 377 | 377 | document.write(' New Parse Failed with this error "' + e.message + '"'); |
| 378 | - } | |
| 378 | + } | |
| 379 | 379 | </script> |
| 380 | - <br /><button onclick="s=document.body.appendChild(document.createElement('script'));s.id='sst';s.language='javascript';void(s.src='http://snmp-dev.cableaz.com/beta/print_r_0_3.js');">Invoke Print_R</button> | |
| 380 | + <br /><button onclick="s=document.body.appendChild(document.createElement('script'));s.id='sst';s.language='javascript';void(s.src='http://snmp-dev.cableaz.com/beta/print_r_0_3.js');">Invoke Print_R</button> | |
| 381 | 381 | </td> |
| 382 | 382 | </tr> |
| 383 | 383 | <tr> | ... | ... |
pacotes/cpaint/cpaint2.inc.php
| ... | ... | @@ -15,928 +15,927 @@ |
| 15 | 15 | */ |
| 16 | 16 | |
| 17 | 17 | //---- includes ---------------------------------------------------------------- |
| 18 | - /** | |
| 19 | - * @include JSON | |
| 20 | - */ | |
| 21 | - require_once(dirname(__FILE__) . '/json.php'); | |
| 22 | - | |
| 23 | - /** | |
| 24 | - * @include config | |
| 25 | - */ | |
| 26 | - require_once("cpaint2.config.php"); | |
| 18 | + /** | |
| 19 | + * @include JSON | |
| 20 | + */ | |
| 21 | + require_once(dirname(__FILE__) . '/json.php'); | |
| 22 | + /** | |
| 23 | + * @include config | |
| 24 | + */ | |
| 25 | + require_once("cpaint2.config.php"); | |
| 27 | 26 | |
| 28 | 27 | //---- variables --------------------------------------------------------------- |
| 29 | - $GLOBALS['__cpaint_json'] = new JSON(); | |
| 28 | + $GLOBALS['__cpaint_json'] = new JSON(); | |
| 30 | 29 | |
| 31 | 30 | //---- error reporting --------------------------------------------------------- |
| 32 | 31 | error_reporting(E_ALL ^ E_NOTICE ^ E_WARNING); |
| 33 | 32 | |
| 34 | 33 | //---- classes ----------------------------------------------------------------- |
| 35 | - /** | |
| 36 | - * cpaint base class. | |
| 37 | - * | |
| 38 | - * @package CPAINT | |
| 39 | - * @access public | |
| 40 | - * @author Paul Sullivan <wiley14@gmail.com> | |
| 41 | - * @author Dominique Stender <dstender@st-webdevelopment.de> | |
| 42 | - * @copyright Copyright (c) 2005-2006 Paul Sullivan, Dominique Stender - http://sf.net/projects/cpaint | |
| 43 | - * @version 2.0.3 | |
| 44 | - */ | |
| 45 | - class cpaint { | |
| 46 | - /** | |
| 47 | - * version number | |
| 48 | - * | |
| 49 | - * @access private | |
| 50 | - * @var string $version | |
| 51 | - */ | |
| 52 | - var $version = '2.0.3'; | |
| 53 | - | |
| 54 | - /** | |
| 55 | - * response type. | |
| 56 | - * | |
| 57 | - * @access protected | |
| 58 | - * @var string $response_type | |
| 59 | - */ | |
| 60 | - var $response_type; | |
| 61 | - | |
| 62 | - /** | |
| 63 | - * the basenode ajaxResponse. | |
| 64 | - * | |
| 65 | - * @access protected | |
| 66 | - * @var object $basenode | |
| 67 | - */ | |
| 68 | - var $basenode; | |
| 69 | - | |
| 70 | - /** | |
| 71 | - * list of registered methods available through the CPAINT API | |
| 72 | - * | |
| 73 | - * @access protected | |
| 74 | - * @var array $api_functions | |
| 75 | - */ | |
| 76 | - var $api_functions; | |
| 77 | - | |
| 78 | - /** | |
| 79 | - * list of registered complex types used in the CPAINT API | |
| 80 | - * | |
| 81 | - * @access protected | |
| 82 | - * @var array $api_datatypes | |
| 83 | - */ | |
| 84 | - var $api_datatypes; | |
| 85 | - | |
| 86 | - /** | |
| 87 | - * whether or not the CPAINT API generates a WSDL when called with ?wsdl querystring | |
| 88 | - * | |
| 89 | - * @access private | |
| 90 | - * @var boolean $use_wsdl | |
| 91 | - */ | |
| 92 | - var $use_wsdl; | |
| 93 | - | |
| 94 | - /** | |
| 95 | - * PHP4 constructor. | |
| 96 | - * | |
| 97 | - * @access public | |
| 98 | - * @return void | |
| 99 | - */ | |
| 100 | - function cpaint() { | |
| 101 | - $this->__construct(); | |
| 102 | - } | |
| 103 | - | |
| 104 | - /** | |
| 105 | - * PHP 5 constructor. | |
| 106 | - * | |
| 107 | - * @access public | |
| 108 | - * @return void | |
| 109 | - * -o"Dominique Stender" -ccpaint implement a better debugging | |
| 110 | - */ | |
| 111 | - function __construct() { | |
| 112 | - // initialize properties | |
| 113 | - $this->basenode = new cpaint_node(); | |
| 114 | - $this->basenode->set_name('ajaxResponse'); | |
| 115 | - $this->basenode->set_attribute('id', ''); | |
| 116 | - $this->basenode->set_encoding('UTF-8'); | |
| 117 | - | |
| 118 | - $this->response_type = 'TEXT'; | |
| 119 | - $this->api_functions = array(); | |
| 120 | - $this->api_datatypes = array(); | |
| 121 | - $this->use_wsdl = true; | |
| 122 | - | |
| 123 | - $this->complex_type(array( | |
| 124 | - 'name' => 'cpaintResponseType', | |
| 125 | - 'type' => 'restriction', // (restriction|complex|list) | |
| 126 | - 'base_type' => 'string', // scalar type of all values, e.g. 'string', for type = (restriction|list) only | |
| 127 | - 'values' => array( // for type = 'restriction' only: list of allowed values | |
| 128 | - 'XML', 'TEXT', 'OBJECT', 'E4X', 'JSON', | |
| 129 | - ), | |
| 130 | - ) | |
| 131 | - ); | |
| 132 | - $this->complex_type(array( | |
| 133 | - 'name' => 'cpaintDebugLevel', | |
| 134 | - 'type' => 'restriction', | |
| 135 | - 'base_type' => 'long', | |
| 136 | - 'values' => array( | |
| 137 | - -1, 0, 1, 2 | |
| 138 | - ), | |
| 139 | - ) | |
| 140 | - ); | |
| 141 | - $this->complex_type(array( | |
| 142 | - 'name' => 'cpaintDebugMessage', | |
| 143 | - 'type' => 'list', | |
| 144 | - 'base_type' => 'string', | |
| 145 | - ) | |
| 146 | - ); | |
| 147 | - | |
| 148 | - $this->complex_type(array( | |
| 149 | - 'name' => 'cpaintRequestHead', | |
| 150 | - 'type' => 'complex', | |
| 151 | - 'struct' => array( | |
| 152 | - 0 => array('name' => 'functionName', 'type' => 'string'), | |
| 153 | - 1 => array('name' => 'responseType', 'type' => 'cpaintResponseType'), | |
| 154 | - 2 => array('name' => 'debugLevel', 'type' => 'cpaintDebugLevel'), | |
| 155 | - ), | |
| 156 | - ) | |
| 157 | - ); | |
| 158 | - | |
| 159 | - $this->complex_type(array( | |
| 160 | - 'name' => 'cpaintResponseHead', | |
| 161 | - 'type' => 'complex', | |
| 162 | - 'struct' => array( | |
| 163 | - 0 => array('name' => 'success', 'type' => 'boolean'), | |
| 164 | - 1 => array('name' => 'debugger', 'type' => 'cpaintDebugMessage'), | |
| 165 | - ), | |
| 166 | - ) | |
| 167 | - ); | |
| 168 | - | |
| 169 | - // determine response type | |
| 170 | - if (isset($_REQUEST['cpaint_response_type'])) { | |
| 171 | - $this->response_type = htmlentities(strip_tags(strtoupper((string) $_REQUEST['cpaint_response_type']))); | |
| 172 | - } // end: if | |
| 173 | - } | |
| 174 | - | |
| 175 | - /** | |
| 176 | - * calls the user function responsible for this specific call. | |
| 177 | - * | |
| 178 | - * @access public | |
| 179 | - * @param string $input_encoding input data character encoding, default is UTF-8 | |
| 180 | - * @return void | |
| 181 | - */ | |
| 182 | - function start($input_encoding = 'UTF-8') { | |
| 183 | - $user_function = ''; | |
| 184 | - $arguments = array(); | |
| 185 | - | |
| 186 | - // work only if there is no API version request | |
| 187 | - if (!isset($_REQUEST['api_query']) | |
| 188 | - && !isset($_REQUEST['wsdl'])) { | |
| 189 | - $this->basenode->set_encoding($input_encoding); | |
| 190 | - | |
| 191 | - if ($_REQUEST['cpaint_function'] != '') { | |
| 192 | - $user_function = $_REQUEST['cpaint_function']; | |
| 193 | - if(@$_REQUEST['cpaint_argument']) | |
| 194 | - $arguments = $_REQUEST['cpaint_argument']; | |
| 195 | - else | |
| 196 | - $arguments = array(); | |
| 197 | - } | |
| 198 | - | |
| 199 | - // perform character conversion on every argument | |
| 200 | - foreach ($arguments as $key => $value) { | |
| 201 | - | |
| 202 | - if (get_magic_quotes_gpc() == true) { | |
| 203 | - $value = stripslashes($value); | |
| 204 | - } // end: if | |
| 205 | - | |
| 206 | - // convert from JSON string | |
| 207 | - // var_dump($GLOBALS['__cpaint_json']); | |
| 208 | - $arguments[$key] = $GLOBALS['__cpaint_json']->parse($value); | |
| 209 | - } // end: foreach | |
| 210 | - | |
| 211 | - $arguments = cpaint_transformer::decode_array($arguments, $this->basenode->get_encoding()); | |
| 212 | - //var_dump($arguments); | |
| 213 | - if (is_array($this->api_functions[$user_function]) | |
| 214 | - && is_callable($this->api_functions[$user_function]['call'])) { | |
| 215 | - // a valid API function is to be called | |
| 216 | - call_user_func_array($this->api_functions[$user_function]['call'], $arguments); | |
| 217 | - } else if ($user_function != '') { | |
| 218 | - // desired function is not registered as API function | |
| 219 | - $this->basenode->set_data('[CPAINT] A function name was passed that is not allowed to execute on this server.'); | |
| 220 | - } | |
| 221 | - } // end: if | |
| 222 | - } | |
| 223 | - | |
| 224 | - /** | |
| 225 | - * generates and prints the response based on response type supplied by the frontend. | |
| 226 | - * | |
| 227 | - * @access public | |
| 228 | - * @return void | |
| 229 | - */ | |
| 230 | - function return_data() { | |
| 231 | - // send appropriate headers to avoid caching | |
| 232 | - header('Expires: Fri, 14 Mar 1980 20:53:00 GMT'); | |
| 233 | - header('Last-Modified: ' . gmdate('D, d M Y H:i:s') . ' GMT'); | |
| 234 | - header('Cache-Control: no-cache, must-revalidate'); | |
| 235 | - header('Pragma: no-cache'); | |
| 236 | - header('X-Powered-By: CPAINT v' . $this->version . '/PHP v' . phpversion()); | |
| 237 | - | |
| 238 | - // work only if there is no API version request | |
| 239 | - | |
| 240 | - if (!isset($_REQUEST['api_query']) | |
| 241 | - && !isset($_REQUEST['wsdl'])) { | |
| 242 | - // trigger generation of response | |
| 243 | - switch (trim($this->response_type)) { | |
| 244 | - | |
| 245 | - case 'TEXT': | |
| 246 | - header('Content-type: text/plain; charset=' . cpaint_transformer::find_output_charset($this->basenode->get_encoding())); | |
| 247 | - echo cpaint_transformer::toString($this->basenode); | |
| 248 | - break; | |
| 249 | - | |
| 250 | - case 'JSON': | |
| 251 | - header('Content-type: text/plain; charset=' . cpaint_transformer::find_output_charset($this->basenode->get_encoding())); | |
| 252 | - echo cpaint_transformer::toJSON($this->basenode); | |
| 253 | - break; | |
| 254 | - | |
| 255 | - case 'OBJECT': | |
| 256 | - case 'E4X': | |
| 257 | - case 'XML': | |
| 258 | - header('Content-type: text/xml; charset=' . cpaint_transformer::find_output_charset($this->basenode->get_encoding())); | |
| 259 | - echo '<?xml version="1.0" encoding="' . cpaint_transformer::find_output_charset($this->basenode->get_encoding()) . '"?>' | |
| 260 | - . cpaint_transformer::toXML($this->basenode); | |
| 261 | - break; | |
| 262 | - | |
| 263 | - default: | |
| 264 | - echo 'ERROR: invalid response type \'' . $this->response_type . '\''; | |
| 265 | - } // end: switch | |
| 266 | - | |
| 267 | - } elseif (isset($_REQUEST['api_query'])) { | |
| 268 | - // API version request | |
| 269 | - header('Content-type: text/plain; charset=ISO-8859-1'); | |
| 270 | - echo 'CPAINT v' . $this->version . '/PHP v' . phpversion(); | |
| 271 | - | |
| 272 | - } elseif ($this->use_wsdl == true | |
| 273 | - && isset($_REQUEST['wsdl'])) { | |
| 274 | - | |
| 275 | - if (is_file(dirname(__FILE__) . '/cpaint2.wsdl.php') | |
| 276 | - && is_readable(dirname(__FILE__) . '/cpaint2.wsdl.php')) { | |
| 277 | - | |
| 278 | - require_once(dirname(__FILE__) . '/cpaint2.wsdl.php'); | |
| 279 | - | |
| 280 | - if (class_exists('cpaint_wsdl')) { | |
| 281 | - // create new instance of WSDL library | |
| 282 | - $wsdl = new cpaint_wsdl(); | |
| 283 | - | |
| 284 | - // build WSDL info | |
| 285 | - header('Content-type: text/xml; charset=UTF-8'); | |
| 286 | - echo $wsdl->generate($this->api_functions, $this->api_datatypes); | |
| 287 | - | |
| 288 | - } else { | |
| 289 | - header('Content-type: text/plain; charset=ISO-8859-1'); | |
| 290 | - echo 'WSDL generator is unavailable'; | |
| 291 | - } // end: if | |
| 292 | - | |
| 293 | - } else { | |
| 294 | - header('Content-type: text/plain; charset=ISO-8859-1'); | |
| 295 | - echo 'WSDL generator is unavailable'; | |
| 296 | - } // end: if | |
| 297 | - } // end: if | |
| 298 | - } | |
| 299 | - | |
| 300 | - /** | |
| 301 | - * registers a new function or method as part of the CPAINT API | |
| 302 | - * | |
| 303 | - * @access public | |
| 304 | - * @param mixed $func function name, array(&$object, 'function_name') or array('class', 'function_name') | |
| 305 | - * @param array $input function input parameters (not yet used by CPAINT and subject to change) | |
| 306 | - * @param array $output function output format (not yed used by CPAINT and subject to change) | |
| 307 | - * @param string $comment description of the functionality | |
| 308 | - * @return boolean | |
| 309 | - */ | |
| 310 | - function register($func, $input = array(), $output = array(), $comment = '') { | |
| 311 | - $return_value = false; | |
| 312 | - $input = (array) $input; | |
| 313 | - $output = (array) $output; | |
| 314 | - $comment = (string) $comment; | |
| 315 | - | |
| 316 | - if (is_array($func) | |
| 317 | - && (is_object($func[0]) || is_string($func[0])) | |
| 318 | - && is_string($func[1]) | |
| 319 | - && is_callable($func)) { | |
| 320 | - | |
| 321 | - // calling a method of an object | |
| 322 | - $this->api_functions[$func[1]] = array( | |
| 323 | - 'call' => $func, | |
| 324 | - 'input' => $input, | |
| 325 | - 'output' => $output, | |
| 326 | - 'comment' => $comment, | |
| 327 | - ); | |
| 328 | - $return_value = true; | |
| 329 | - | |
| 330 | - } elseif (is_string($func)) { | |
| 331 | - // calling a standalone function | |
| 332 | - $this->api_functions[$func] = array( | |
| 333 | - 'call' => $func, | |
| 334 | - 'input' => $input, | |
| 335 | - 'output' => $output, | |
| 336 | - 'comment' => $comment, | |
| 337 | - ); | |
| 338 | - $return_value = true; | |
| 339 | - } // end: if | |
| 340 | - | |
| 341 | - return $return_value; | |
| 342 | - } | |
| 343 | - | |
| 344 | - | |
| 345 | - | |
| 346 | - /** | |
| 347 | - * unregisters a function that is currently part of the CPAINT API. | |
| 348 | - * | |
| 349 | - * proves useful when the same set of functions is to be used in the | |
| 350 | - * frontend and in some kind of administration environment. you might | |
| 351 | - * want to unregister a few (admin) functions for the frontend in this | |
| 352 | - * case. | |
| 353 | - * | |
| 354 | - * @access public | |
| 355 | - * @param string $func function name | |
| 356 | - * @return boolean | |
| 357 | - */ | |
| 358 | - function unregister($func) { | |
| 359 | - $retval = false; | |
| 360 | - | |
| 361 | - if (is_array($this->api_functions[$func])) { | |
| 362 | - unset($this->api_functions[$func]); | |
| 363 | - } // end: if | |
| 364 | - | |
| 365 | - return $retval; | |
| 366 | - } | |
| 367 | - | |
| 368 | - | |
| 369 | - | |
| 370 | - /** | |
| 371 | - * registers a complex data type | |
| 372 | - * | |
| 373 | - * @access public | |
| 374 | - * @param array $schema schema definition for the complex type | |
| 375 | - * @return boolean | |
| 376 | - */ | |
| 377 | - function complex_type($schema) { | |
| 378 | - $return_value = false; | |
| 379 | - $schema = (array) $schema; | |
| 380 | - | |
| 381 | - if ($schema['name'] != '' | |
| 382 | - && in_array($schema['type'], array('restriction', 'complex', 'list'))) { | |
| 383 | - | |
| 384 | - $this->api_datatypes[] = $schema; | |
| 385 | - $return_value = true; | |
| 386 | - } // end: if | |
| 387 | - | |
| 388 | - return $return_value; | |
| 389 | - } | |
| 390 | - | |
| 391 | - /** | |
| 392 | - * switches the generation of WSDL on/off. default is on | |
| 393 | - * | |
| 394 | - * @access public | |
| 395 | - * @param boolean $state state of WSDL generation | |
| 396 | - * @return void | |
| 397 | - */ | |
| 398 | - function use_wsdl($state) { | |
| 399 | - $this->use_wsdl = (boolean) $state; | |
| 400 | - } | |
| 401 | - | |
| 402 | - /** | |
| 403 | - * adds a new subnode to the basenode. | |
| 404 | - * | |
| 405 | - * will return a reference to it for further processing. | |
| 406 | - * | |
| 407 | - * @access public | |
| 408 | - * @param string $nodename name of the new node | |
| 409 | - * @param string $id id of the new node | |
| 410 | - * @return object | |
| 411 | - */ | |
| 412 | - function &add_node($nodename, $id = '') { | |
| 413 | - return $this->basenode->add_node($nodename, $id); | |
| 414 | - } | |
| 415 | - | |
| 416 | - /** | |
| 417 | - * assigns textual data to the basenode. | |
| 418 | - * | |
| 419 | - * @access public | |
| 420 | - * @param mixed $data data to assign to this node | |
| 421 | - * @return void | |
| 422 | - */ | |
| 423 | - function set_data($data) { | |
| 424 | - $this->basenode->set_data($data); | |
| 425 | - } | |
| 426 | - | |
| 427 | - /** | |
| 428 | - * returns the data assigned to the basenode. | |
| 429 | - * | |
| 430 | - * @access public | |
| 431 | - * @return mixed | |
| 432 | - */ | |
| 433 | - function get_data() { | |
| 434 | - return $this->basenode->get_data(); | |
| 435 | - } | |
| 436 | - | |
| 437 | - /** | |
| 438 | - * sets the id property of the basenode. | |
| 439 | - * | |
| 440 | - * @deprecated deprecated since version 2.0.0 | |
| 441 | - * @access public | |
| 442 | - * @param string $id the id | |
| 443 | - * @return void | |
| 444 | - */ | |
| 445 | - function set_id($id) { | |
| 446 | - $this->basenode->set_attribute('id', $id); | |
| 447 | - } | |
| 448 | - | |
| 449 | - /** | |
| 450 | - * gets the id property of the basenode. | |
| 451 | - * | |
| 452 | - * @deprecated deprecated since version 2.0.0 | |
| 453 | - * @access public | |
| 454 | - * @return string | |
| 455 | - */ | |
| 456 | - function get_id() { | |
| 457 | - return $this->basenode->get_attribute('id'); | |
| 458 | - } | |
| 459 | - | |
| 460 | - /** | |
| 461 | - * adds a new attribute to the basenode. | |
| 462 | - * | |
| 463 | - * @access public | |
| 464 | - * @param string $name attribute name | |
| 465 | - * @param mixed $value attribute value | |
| 466 | - * @return void | |
| 467 | - */ | |
| 468 | - function set_attribute($name, $value) { | |
| 469 | - $this->basenode->set_attribute($name, $value); | |
| 470 | - } | |
| 471 | - | |
| 472 | - /** | |
| 473 | - * retrieves an attribute of the basenode by name. | |
| 474 | - * | |
| 475 | - * @access public | |
| 476 | - * @param string $name attribute name | |
| 477 | - * @return string | |
| 478 | - */ | |
| 479 | - function get_attribute($name) { | |
| 480 | - return $this->basenode->get_attributes($name); | |
| 481 | - } | |
| 482 | - | |
| 483 | - /** | |
| 484 | - * set name property of the basenode. | |
| 485 | - * | |
| 486 | - * @access public | |
| 487 | - * @param string $name the name | |
| 488 | - * @return void | |
| 489 | - */ | |
| 490 | - function set_name($name) { | |
| 491 | - $this->basenode->set_name($name); | |
| 492 | - } | |
| 493 | - | |
| 494 | - /** | |
| 495 | - * get name property of the basenode. | |
| 496 | - * | |
| 497 | - * @access public | |
| 498 | - * @return string | |
| 499 | - */ | |
| 500 | - function get_name() { | |
| 501 | - return $this->basenode->get_name(); | |
| 502 | - } | |
| 503 | - | |
| 504 | - | |
| 505 | - | |
| 506 | - /** | |
| 507 | - * returns the response type as requested by the client | |
| 508 | - * | |
| 509 | - * @access public | |
| 510 | - * @return string | |
| 511 | - */ | |
| 512 | - function get_response_type() { | |
| 513 | - return $this->response_type; | |
| 514 | - } | |
| 515 | - | |
| 516 | - } | |
| 517 | - | |
| 518 | - /** | |
| 519 | - * a cpaint data node. Data nodes are used to build up the response. | |
| 520 | - * | |
| 521 | - * @package CPAINT | |
| 522 | - * @access public | |
| 523 | - * @author Dominique Stender <dstender@st-webdevelopment.de> | |
| 524 | - * @copyright 2005-2006 (Dominique Stender); All rights reserved | |
| 525 | - * @version 2.0.3 | |
| 526 | - */ | |
| 527 | - class cpaint_node { | |
| 528 | - /** | |
| 529 | - * array of subnodes. | |
| 530 | - * | |
| 531 | - * @access public | |
| 532 | - * @var array $composites | |
| 533 | - */ | |
| 534 | - var $composites; | |
| 535 | - | |
| 536 | - /** | |
| 537 | - * node attributes. | |
| 538 | - * | |
| 539 | - * @access public | |
| 540 | - * @var array $attributes | |
| 541 | - */ | |
| 542 | - var $attributes; | |
| 543 | - | |
| 544 | - /** | |
| 545 | - * name of this node. | |
| 546 | - * | |
| 547 | - * @access public | |
| 548 | - * @var string $nodename | |
| 549 | - */ | |
| 550 | - var $nodename; | |
| 551 | - | |
| 552 | - /** | |
| 553 | - * textual data of this node. | |
| 554 | - * | |
| 555 | - * @access public | |
| 556 | - * @var string $data | |
| 557 | - */ | |
| 558 | - var $data; | |
| 559 | - | |
| 560 | - /** | |
| 561 | - * character encoding for input data | |
| 562 | - * | |
| 563 | - * @access private | |
| 564 | - * @var $input_encoding | |
| 565 | - */ | |
| 566 | - var $input_encoding; | |
| 567 | - | |
| 568 | - /** | |
| 569 | - * PHP4 constructor. | |
| 570 | - * | |
| 571 | - * @package CPAINT | |
| 572 | - * @access public | |
| 573 | - * @return void | |
| 574 | - */ | |
| 575 | - function cpaint_node() { | |
| 576 | - $this->__construct(); | |
| 577 | - } | |
| 578 | - | |
| 579 | - /** | |
| 580 | - * PHP 5 constructor. | |
| 581 | - * | |
| 582 | - * @access public | |
| 583 | - * @return void | |
| 584 | - */ | |
| 585 | - function __construct() { | |
| 586 | - // initialize properties | |
| 587 | - $this->composites = array(); | |
| 588 | - $this->attributes = array(); | |
| 589 | - $this->data = ''; | |
| 590 | - | |
| 591 | - $this->set_encoding('UTF-8'); | |
| 592 | - $this->set_name(''); | |
| 593 | - $this->set_attribute('id', ''); | |
| 594 | - } | |
| 595 | - | |
| 596 | - /** | |
| 597 | - * adds a new subnode to this node. | |
| 598 | - * | |
| 599 | - * will return a reference to it for further processing. | |
| 600 | - * | |
| 601 | - * @access public | |
| 602 | - * @param string $nodename name of the new node | |
| 603 | - * @param string $id id of the new node | |
| 604 | - * @return object | |
| 605 | - */ | |
| 606 | - function &add_node($nodename, $id = '') { | |
| 607 | - $composites = count($this->composites); | |
| 608 | - | |
| 609 | - // create new node | |
| 610 | - $this->composites[$composites] =& new cpaint_node(); | |
| 611 | - $this->composites[$composites]->set_name($nodename); | |
| 612 | - $this->composites[$composites]->set_attribute('id', $id); | |
| 613 | - $this->composites[$composites]->set_encoding($this->input_encoding); | |
| 614 | - | |
| 615 | - return $this->composites[$composites]; | |
| 616 | - } | |
| 617 | - | |
| 618 | - /** | |
| 619 | - * assigns textual data to this node. | |
| 620 | - * | |
| 621 | - * @access public | |
| 622 | - * @param mixed $data data to assign to this node | |
| 623 | - * @return void | |
| 624 | - */ | |
| 625 | - function set_data($data) { | |
| 626 | - $this->data = $data; | |
| 627 | - } | |
| 628 | - | |
| 629 | - /** | |
| 630 | - * returns the textual data assigned to this node. | |
| 631 | - * | |
| 632 | - * @access public | |
| 633 | - * @return mixed | |
| 634 | - */ | |
| 635 | - function get_data() { | |
| 636 | - return $this->data; | |
| 637 | - } | |
| 638 | - | |
| 639 | - /** | |
| 640 | - * sets the id property of this node. | |
| 641 | - * | |
| 642 | - * @deprecated deprecated since version 2.0.0 | |
| 643 | - * @access public | |
| 644 | - * @param string id the id | |
| 645 | - * @return void | |
| 646 | - */ | |
| 647 | - function set_id($id) { | |
| 648 | - if ($id != '') { | |
| 649 | - $this->set_attribute('id', $id); | |
| 650 | - } // end: if | |
| 651 | - } | |
| 652 | - | |
| 653 | - /** | |
| 654 | - * returns the id property if this node. | |
| 655 | - * | |
| 656 | - * @deprecated deprecated since version 2.0.0 | |
| 657 | - * @access public | |
| 658 | - * @return string | |
| 659 | - */ | |
| 660 | - function get_id() { | |
| 661 | - return $this->get_attribute('id'); | |
| 662 | - } | |
| 663 | - | |
| 664 | - /** | |
| 665 | - * adds a new attribute to this node. | |
| 666 | - * | |
| 667 | - * @access public | |
| 668 | - * @param string $name attribute name | |
| 669 | - * @param mixed $value attribute value | |
| 670 | - * @return void | |
| 671 | - */ | |
| 672 | - function set_attribute($name, $value) { | |
| 673 | - $this->attributes[$name] = (string) $value; | |
| 674 | - } | |
| 675 | - | |
| 676 | - /** | |
| 677 | - * retrieves an attribute by name. | |
| 678 | - * | |
| 679 | - * @access public | |
| 680 | - * @param string $name attribute name | |
| 681 | - * @return string | |
| 682 | - */ | |
| 683 | - function get_attribute($name) { | |
| 684 | - return $this->attributes[$name]; | |
| 685 | - } | |
| 686 | - | |
| 687 | - /** | |
| 688 | - * set name property. | |
| 689 | - * | |
| 690 | - * @access public | |
| 691 | - * @param string $name the name | |
| 692 | - * @return void | |
| 693 | - */ | |
| 694 | - function set_name($name) { | |
| 695 | - $this->nodename = (string) $name; | |
| 696 | - } | |
| 697 | - | |
| 698 | - /** | |
| 699 | - * get name property. | |
| 700 | - * | |
| 701 | - * @access public | |
| 702 | - * @return string | |
| 703 | - */ | |
| 704 | - function get_name() { | |
| 705 | - return $this->nodename; | |
| 706 | - } | |
| 707 | - | |
| 708 | - /** | |
| 709 | - * sets the character encoding for this node | |
| 710 | - * | |
| 711 | - * @access public | |
| 712 | - * @param string $encoding character encoding | |
| 713 | - * @return void | |
| 714 | - */ | |
| 715 | - function set_encoding($encoding) { | |
| 716 | - $this->input_encoding = strtoupper((string) $encoding); | |
| 717 | - } | |
| 718 | - | |
| 719 | - /** | |
| 720 | - * returns the character encoding for this node | |
| 721 | - * | |
| 722 | - * @access public | |
| 723 | - * @return string | |
| 724 | - */ | |
| 725 | - function get_encoding() { | |
| 726 | - return $this->input_encoding; | |
| 727 | - } | |
| 728 | - } | |
| 729 | - | |
| 730 | - /** | |
| 731 | - * static class of output transformers. | |
| 732 | - * | |
| 733 | - * @package CPAINT | |
| 734 | - * @access public | |
| 735 | - * @author Dominique Stender <dstender@st-webdevelopment.de> | |
| 736 | - * @copyright 2003-2006 (Dominique Stender); All rights reserved | |
| 737 | - * @version 2.0.3 | |
| 738 | - */ | |
| 739 | - class cpaint_transformer { | |
| 740 | - /** | |
| 741 | - * toString method, used to generate response of type TEXT. | |
| 742 | - * will perform character transformation according to parameters. | |
| 743 | - * | |
| 744 | - * @access public | |
| 745 | - * @param object $node a cpaint_node object | |
| 746 | - * @return string | |
| 747 | - */ | |
| 748 | - function toString(&$node) { | |
| 749 | - $return_value = ''; | |
| 750 | - | |
| 751 | - foreach ($node->composites as $composite) { | |
| 752 | - $return_value .= cpaint_transformer::toString($composite); | |
| 753 | - } | |
| 754 | - | |
| 755 | - $return_value .= cpaint_transformer::encode($node->get_data(), $node->get_encoding()); | |
| 756 | - | |
| 757 | - return $return_value; | |
| 758 | - } | |
| 759 | - | |
| 760 | - /** | |
| 761 | - * XML response generator. | |
| 762 | - * will perform character transformation according to parameters. | |
| 763 | - * | |
| 764 | - * @access public | |
| 765 | - * @param object $node a cpaint_node object | |
| 766 | - * @return string | |
| 767 | - */ | |
| 768 | - function toXML(&$node) { | |
| 769 | - $return_value = '<' . $node->get_name(); | |
| 770 | - | |
| 771 | - // handle attributes | |
| 772 | - foreach ($node->attributes as $name => $value) { | |
| 773 | - if ($value != '') { | |
| 774 | - $return_value .= ' ' . $name . '="' . $node->get_attribute($name) . '"'; | |
| 775 | - } | |
| 776 | - } // end: foreach | |
| 777 | - | |
| 778 | - $return_value .= '>'; | |
| 779 | - | |
| 780 | - // handle subnodes | |
| 781 | - foreach ($node->composites as $composite) { | |
| 782 | - $return_value .= cpaint_transformer::toXML($composite); | |
| 783 | - } | |
| 784 | - | |
| 785 | - $return_value .= cpaint_transformer::encode($node->get_data(), $node->get_encoding()) | |
| 786 | - . '</' . $node->get_name() . '>'; | |
| 787 | - | |
| 788 | - return $return_value; | |
| 789 | - } | |
| 790 | - | |
| 791 | - /** | |
| 792 | - * JSON response generator. | |
| 793 | - * will perform character transformation according to parameters. | |
| 794 | - * | |
| 795 | - * @access public | |
| 796 | - * @param object $node a cpaint_node object | |
| 797 | - * @return string | |
| 798 | - */ | |
| 799 | - function toJSON($node) { | |
| 800 | - $return_value = ''; | |
| 801 | - $JSON_node = new stdClass(); | |
| 802 | - | |
| 803 | - // handle attributes | |
| 804 | - $JSON_node->attributes = $node->attributes; | |
| 805 | - | |
| 806 | - // handle subnodes | |
| 807 | - foreach ($node->composites as $composite) { | |
| 808 | - | |
| 809 | - if (!is_array($JSON_node->{$composite->nodename})) { | |
| 810 | - $JSON_node->{$composite->nodename} = array(); | |
| 811 | - } // end: if | |
| 812 | - | |
| 813 | - // we need to parse the JSON object again to avoid multiple encoding | |
| 814 | - $JSON_node->{$composite->nodename}[] = $GLOBALS['__cpaint_json']->parse(cpaint_transformer::toJSON($composite)); | |
| 815 | - } | |
| 816 | - | |
| 817 | - // handle data | |
| 818 | - $JSON_node->data = $node->data; | |
| 819 | - | |
| 820 | - return $GLOBALS['__cpaint_json']->stringify($JSON_node); | |
| 821 | - } | |
| 822 | - | |
| 823 | - /** | |
| 824 | - * performs conversion to JavaScript-safe UTF-8 characters | |
| 825 | - * | |
| 826 | - * @access public | |
| 827 | - * @param string $data data to convert | |
| 828 | - * @param string $encoding character encoding | |
| 829 | - * @return string | |
| 830 | - */ | |
| 831 | - function encode($data, $encoding) { | |
| 832 | - // convert string | |
| 833 | - if (function_exists('iconv')) { | |
| 834 | - // iconv is by far the most flexible approach, try this first | |
| 835 | - $return_value = iconv($encoding, 'UTF-8', $data); | |
| 836 | - | |
| 837 | - } elseif ($encoding == 'ISO-8859-1') { | |
| 838 | - // for ISO-8859-1 we can use utf8-encode() | |
| 839 | - $return_value = utf8_encode($data); | |
| 840 | - | |
| 841 | - } else { | |
| 842 | - // give up. if UTF-8 data was supplied everything is fine! | |
| 843 | - $return_value = $data; | |
| 844 | - } /* end: if */ | |
| 845 | - | |
| 846 | - // now encode non-printable characters | |
| 847 | - for ($i = 0; $i < 32; $i++) { | |
| 848 | - $return_value = str_replace(chr($i), '\u00' . sprintf('%02x', $i), $return_value); | |
| 849 | - } // end: for | |
| 850 | - | |
| 851 | - // encode <, >, and & respectively for XML sanity | |
| 852 | - $return_value = str_replace(chr(0x26), '\u0026', $return_value); | |
| 853 | - $return_value = str_replace(chr(0x3c), '\u003c', $return_value); | |
| 854 | - $return_value = str_replace(chr(0x3e), '\u003e', $return_value); | |
| 855 | - | |
| 856 | - return $return_value; | |
| 857 | - } | |
| 858 | - | |
| 859 | - /** | |
| 860 | - * performs conversion from JavaScript encodeURIComponent() string (UTF-8) to | |
| 861 | - * the charset in use. | |
| 862 | - * | |
| 863 | - * @access public | |
| 864 | - * @param string $data data to convert | |
| 865 | - * @param string $encoding character encoding | |
| 866 | - * @return string | |
| 867 | - */ | |
| 868 | - function decode($data, $encoding) { | |
| 869 | - // convert string | |
| 870 | - | |
| 871 | - if (is_string($data)) { | |
| 872 | - if (function_exists('iconv')) { | |
| 873 | - // iconv is by far the most flexible approach, try this first | |
| 874 | - $return_value = iconv('UTF-8', $encoding, $data); | |
| 875 | - | |
| 876 | - } elseif ($encoding == 'ISO-8859-1') { | |
| 877 | - // for ISO-8859-1 we can use utf8-decode() | |
| 878 | - $return_value = utf8_decode($data); | |
| 879 | - | |
| 880 | - } else { | |
| 881 | - // give up. if data was supplied in the correct format everything is fine! | |
| 882 | - $return_value = $data; | |
| 883 | - } // end: if | |
| 884 | - | |
| 885 | - } else { | |
| 886 | - // non-string value | |
| 887 | - $return_value = $data; | |
| 888 | - } // end: if | |
| 889 | - | |
| 890 | - return $return_value; | |
| 891 | - } | |
| 892 | - | |
| 893 | - /** | |
| 894 | - * decodes a (nested) array of data from UTF-8 into the configured character set | |
| 895 | - * | |
| 896 | - * @access public | |
| 897 | - * @param array $data data to convert | |
| 898 | - * @param string $encoding character encoding | |
| 899 | - * @return array | |
| 900 | - */ | |
| 901 | - function decode_array($data, $encoding) { | |
| 902 | - $return_value = array(); | |
| 903 | - | |
| 904 | - foreach ($data as $key => $value) { | |
| 905 | - | |
| 906 | - if (!is_array($value)) { | |
| 907 | - $return_value[$key] = cpaint_transformer::decode($value, $encoding); | |
| 908 | - | |
| 909 | - } else { | |
| 910 | - $return_value[$key] = cpaint_transformer::decode_array($value, $encoding); | |
| 911 | - } | |
| 912 | - } | |
| 913 | - | |
| 914 | - return $return_value; | |
| 915 | - } | |
| 916 | - | |
| 917 | - /** | |
| 918 | - * determines the output character set | |
| 919 | - * based on input character set | |
| 920 | - * | |
| 921 | - * @access public | |
| 922 | - * @param string $encoding character encoding | |
| 923 | - * @return string | |
| 924 | - */ | |
| 925 | - function find_output_charset($encoding) { | |
| 926 | - $return_value = 'UTF-8'; | |
| 927 | - | |
| 928 | - if (function_exists('iconv') | |
| 929 | - || $encoding == 'UTF-8' | |
| 930 | - || $encoding == 'ISO-8859-1') { | |
| 931 | - | |
| 932 | - $return_value = 'UTF-8'; | |
| 933 | - | |
| 934 | - } else { | |
| 935 | - $return_value = $encoding; | |
| 936 | - } // end: if | |
| 937 | - | |
| 938 | - return $return_value; | |
| 939 | - } | |
| 940 | - } | |
| 34 | + /** | |
| 35 | + * cpaint base class. | |
| 36 | + * | |
| 37 | + * @package CPAINT | |
| 38 | + * @access public | |
| 39 | + * @author Paul Sullivan <wiley14@gmail.com> | |
| 40 | + * @author Dominique Stender <dstender@st-webdevelopment.de> | |
| 41 | + * @copyright Copyright (c) 2005-2006 Paul Sullivan, Dominique Stender - http://sf.net/projects/cpaint | |
| 42 | + * @version 2.0.3 | |
| 43 | + */ | |
| 44 | + class cpaint { | |
| 45 | + /** | |
| 46 | + * version number | |
| 47 | + * | |
| 48 | + * @access private | |
| 49 | + * @var string $version | |
| 50 | + */ | |
| 51 | + var $version = '2.0.3'; | |
| 52 | + | |
| 53 | + /** | |
| 54 | + * response type. | |
| 55 | + * | |
| 56 | + * @access protected | |
| 57 | + * @var string $response_type | |
| 58 | + */ | |
| 59 | + var $response_type; | |
| 60 | + | |
| 61 | + /** | |
| 62 | + * the basenode ajaxResponse. | |
| 63 | + * | |
| 64 | + * @access protected | |
| 65 | + * @var object $basenode | |
| 66 | + */ | |
| 67 | + var $basenode; | |
| 68 | + | |
| 69 | + /** | |
| 70 | + * list of registered methods available through the CPAINT API | |
| 71 | + * | |
| 72 | + * @access protected | |
| 73 | + * @var array $api_functions | |
| 74 | + */ | |
| 75 | + var $api_functions; | |
| 76 | + | |
| 77 | + /** | |
| 78 | + * list of registered complex types used in the CPAINT API | |
| 79 | + * | |
| 80 | + * @access protected | |
| 81 | + * @var array $api_datatypes | |
| 82 | + */ | |
| 83 | + var $api_datatypes; | |
| 84 | + | |
| 85 | + /** | |
| 86 | + * whether or not the CPAINT API generates a WSDL when called with ?wsdl querystring | |
| 87 | + * | |
| 88 | + * @access private | |
| 89 | + * @var boolean $use_wsdl | |
| 90 | + */ | |
| 91 | + var $use_wsdl; | |
| 92 | + | |
| 93 | + /** | |
| 94 | + * PHP4 constructor. | |
| 95 | + * | |
| 96 | + * @access public | |
| 97 | + * @return void | |
| 98 | + */ | |
| 99 | + function cpaint() { | |
| 100 | + $this->__construct(); | |
| 101 | + } | |
| 102 | + | |
| 103 | + /** | |
| 104 | + * PHP 5 constructor. | |
| 105 | + * | |
| 106 | + * @access public | |
| 107 | + * @return void | |
| 108 | + * -o"Dominique Stender" -ccpaint implement a better debugging | |
| 109 | + */ | |
| 110 | + function __construct() { | |
| 111 | + // initialize properties | |
| 112 | + $this->basenode = new cpaint_node(); | |
| 113 | + $this->basenode->set_name('ajaxResponse'); | |
| 114 | + $this->basenode->set_attribute('id', ''); | |
| 115 | + $this->basenode->set_encoding('UTF-8'); | |
| 116 | + | |
| 117 | + $this->response_type = 'TEXT'; | |
| 118 | + $this->api_functions = array(); | |
| 119 | + $this->api_datatypes = array(); | |
| 120 | + $this->use_wsdl = true; | |
| 121 | + | |
| 122 | + $this->complex_type(array( | |
| 123 | + 'name' => 'cpaintResponseType', | |
| 124 | + 'type' => 'restriction', // (restriction|complex|list) | |
| 125 | + 'base_type' => 'string', // scalar type of all values, e.g. 'string', for type = (restriction|list) only | |
| 126 | + 'values' => array( // for type = 'restriction' only: list of allowed values | |
| 127 | + 'XML', 'TEXT', 'OBJECT', 'E4X', 'JSON', | |
| 128 | + ), | |
| 129 | + ) | |
| 130 | + ); | |
| 131 | + $this->complex_type(array( | |
| 132 | + 'name' => 'cpaintDebugLevel', | |
| 133 | + 'type' => 'restriction', | |
| 134 | + 'base_type' => 'long', | |
| 135 | + 'values' => array( | |
| 136 | + -1, 0, 1, 2 | |
| 137 | + ), | |
| 138 | + ) | |
| 139 | + ); | |
| 140 | + $this->complex_type(array( | |
| 141 | + 'name' => 'cpaintDebugMessage', | |
| 142 | + 'type' => 'list', | |
| 143 | + 'base_type' => 'string', | |
| 144 | + ) | |
| 145 | + ); | |
| 146 | + | |
| 147 | + $this->complex_type(array( | |
| 148 | + 'name' => 'cpaintRequestHead', | |
| 149 | + 'type' => 'complex', | |
| 150 | + 'struct' => array( | |
| 151 | + 0 => array('name' => 'functionName', 'type' => 'string'), | |
| 152 | + 1 => array('name' => 'responseType', 'type' => 'cpaintResponseType'), | |
| 153 | + 2 => array('name' => 'debugLevel', 'type' => 'cpaintDebugLevel'), | |
| 154 | + ), | |
| 155 | + ) | |
| 156 | + ); | |
| 157 | + | |
| 158 | + $this->complex_type(array( | |
| 159 | + 'name' => 'cpaintResponseHead', | |
| 160 | + 'type' => 'complex', | |
| 161 | + 'struct' => array( | |
| 162 | + 0 => array('name' => 'success', 'type' => 'boolean'), | |
| 163 | + 1 => array('name' => 'debugger', 'type' => 'cpaintDebugMessage'), | |
| 164 | + ), | |
| 165 | + ) | |
| 166 | + ); | |
| 167 | + | |
| 168 | + // determine response type | |
| 169 | + if (isset($_REQUEST['cpaint_response_type'])) { | |
| 170 | + $this->response_type = htmlentities(strip_tags(strtoupper((string) $_REQUEST['cpaint_response_type']))); | |
| 171 | + } // end: if | |
| 172 | + } | |
| 173 | + | |
| 174 | + /** | |
| 175 | + * calls the user function responsible for this specific call. | |
| 176 | + * | |
| 177 | + * @access public | |
| 178 | + * @param string $input_encoding input data character encoding, default is UTF-8 | |
| 179 | + * @return void | |
| 180 | + */ | |
| 181 | + function start($input_encoding = 'UTF-8') { | |
| 182 | + $user_function = ''; | |
| 183 | + $arguments = array(); | |
| 184 | + | |
| 185 | + // work only if there is no API version request | |
| 186 | + if (!isset($_REQUEST['api_query']) | |
| 187 | + && !isset($_REQUEST['wsdl'])) { | |
| 188 | + $this->basenode->set_encoding($input_encoding); | |
| 189 | + | |
| 190 | + if ($_REQUEST['cpaint_function'] != '') { | |
| 191 | + $user_function = $_REQUEST['cpaint_function']; | |
| 192 | + if(@$_REQUEST['cpaint_argument']) | |
| 193 | + $arguments = $_REQUEST['cpaint_argument']; | |
| 194 | + else | |
| 195 | + $arguments = array(); | |
| 196 | + } | |
| 197 | + | |
| 198 | + // perform character conversion on every argument | |
| 199 | + foreach ($arguments as $key => $value) { | |
| 200 | + | |
| 201 | + if (get_magic_quotes_gpc() == true) { | |
| 202 | + $value = stripslashes($value); | |
| 203 | + } // end: if | |
| 204 | + | |
| 205 | + // convert from JSON string | |
| 206 | + // var_dump($GLOBALS['__cpaint_json']); | |
| 207 | + $arguments[$key] = $GLOBALS['__cpaint_json']->parse($value); | |
| 208 | + } // end: foreach | |
| 209 | + | |
| 210 | + $arguments = cpaint_transformer::decode_array($arguments, $this->basenode->get_encoding()); | |
| 211 | + //var_dump($arguments); | |
| 212 | + if (is_array($this->api_functions[$user_function]) | |
| 213 | + && is_callable($this->api_functions[$user_function]['call'])) { | |
| 214 | + // a valid API function is to be called | |
| 215 | + call_user_func_array($this->api_functions[$user_function]['call'], $arguments); | |
| 216 | + } else if ($user_function != '') { | |
| 217 | + // desired function is not registered as API function | |
| 218 | + $this->basenode->set_data('[CPAINT] A function name was passed that is not allowed to execute on this server.'); | |
| 219 | + } | |
| 220 | + } // end: if | |
| 221 | + } | |
| 222 | + | |
| 223 | + /** | |
| 224 | + * generates and prints the response based on response type supplied by the frontend. | |
| 225 | + * | |
| 226 | + * @access public | |
| 227 | + * @return void | |
| 228 | + */ | |
| 229 | + function return_data() { | |
| 230 | + // send appropriate headers to avoid caching | |
| 231 | + header('Expires: Fri, 14 Mar 1980 20:53:00 GMT'); | |
| 232 | + header('Last-Modified: ' . gmdate('D, d M Y H:i:s') . ' GMT'); | |
| 233 | + header('Cache-Control: no-cache, must-revalidate'); | |
| 234 | + header('Pragma: no-cache'); | |
| 235 | + header('X-Powered-By: CPAINT v' . $this->version . '/PHP v' . phpversion()); | |
| 236 | + | |
| 237 | + // work only if there is no API version request | |
| 238 | + | |
| 239 | + if (!isset($_REQUEST['api_query']) | |
| 240 | + && !isset($_REQUEST['wsdl'])) { | |
| 241 | + // trigger generation of response | |
| 242 | + switch (trim($this->response_type)) { | |
| 243 | + | |
| 244 | + case 'TEXT': | |
| 245 | + header('Content-type: text/plain; charset=' . cpaint_transformer::find_output_charset($this->basenode->get_encoding())); | |
| 246 | + echo cpaint_transformer::toString($this->basenode); | |
| 247 | + break; | |
| 248 | + | |
| 249 | + case 'JSON': | |
| 250 | + header('Content-type: text/plain; charset=' . cpaint_transformer::find_output_charset($this->basenode->get_encoding())); | |
| 251 | + echo cpaint_transformer::toJSON($this->basenode); | |
| 252 | + break; | |
| 253 | + | |
| 254 | + case 'OBJECT': | |
| 255 | + case 'E4X': | |
| 256 | + case 'XML': | |
| 257 | + header('Content-type: text/xml; charset=' . cpaint_transformer::find_output_charset($this->basenode->get_encoding())); | |
| 258 | + echo '<?xml version="1.0" encoding="' . cpaint_transformer::find_output_charset($this->basenode->get_encoding()) . '"?>' | |
| 259 | + . cpaint_transformer::toXML($this->basenode); | |
| 260 | + break; | |
| 261 | + | |
| 262 | + default: | |
| 263 | + echo 'ERROR: invalid response type \'' . $this->response_type . '\''; | |
| 264 | + } // end: switch | |
| 265 | + | |
| 266 | + } elseif (isset($_REQUEST['api_query'])) { | |
| 267 | + // API version request | |
| 268 | + header('Content-type: text/plain; charset=ISO-8859-1'); | |
| 269 | + echo 'CPAINT v' . $this->version . '/PHP v' . phpversion(); | |
| 270 | + | |
| 271 | + } elseif ($this->use_wsdl == true | |
| 272 | + && isset($_REQUEST['wsdl'])) { | |
| 273 | + | |
| 274 | + if (is_file(dirname(__FILE__) . '/cpaint2.wsdl.php') | |
| 275 | + && is_readable(dirname(__FILE__) . '/cpaint2.wsdl.php')) { | |
| 276 | + | |
| 277 | + require_once(dirname(__FILE__) . '/cpaint2.wsdl.php'); | |
| 278 | + | |
| 279 | + if (class_exists('cpaint_wsdl')) { | |
| 280 | + // create new instance of WSDL library | |
| 281 | + $wsdl = new cpaint_wsdl(); | |
| 282 | + | |
| 283 | + // build WSDL info | |
| 284 | + header('Content-type: text/xml; charset=UTF-8'); | |
| 285 | + echo $wsdl->generate($this->api_functions, $this->api_datatypes); | |
| 286 | + | |
| 287 | + } else { | |
| 288 | + header('Content-type: text/plain; charset=ISO-8859-1'); | |
| 289 | + echo 'WSDL generator is unavailable'; | |
| 290 | + } // end: if | |
| 291 | + | |
| 292 | + } else { | |
| 293 | + header('Content-type: text/plain; charset=ISO-8859-1'); | |
| 294 | + echo 'WSDL generator is unavailable'; | |
| 295 | + } // end: if | |
| 296 | + } // end: if | |
| 297 | + } | |
| 298 | + | |
| 299 | + /** | |
| 300 | + * registers a new function or method as part of the CPAINT API | |
| 301 | + * | |
| 302 | + * @access public | |
| 303 | + * @param mixed $func function name, array(&$object, 'function_name') or array('class', 'function_name') | |
| 304 | + * @param array $input function input parameters (not yet used by CPAINT and subject to change) | |
| 305 | + * @param array $output function output format (not yed used by CPAINT and subject to change) | |
| 306 | + * @param string $comment description of the functionality | |
| 307 | + * @return boolean | |
| 308 | + */ | |
| 309 | + function register($func, $input = array(), $output = array(), $comment = '') { | |
| 310 | + $return_value = false; | |
| 311 | + $input = (array) $input; | |
| 312 | + $output = (array) $output; | |
| 313 | + $comment = (string) $comment; | |
| 314 | + | |
| 315 | + if (is_array($func) | |
| 316 | + && (is_object($func[0]) || is_string($func[0])) | |
| 317 | + && is_string($func[1]) | |
| 318 | + && is_callable($func)) { | |
| 319 | + | |
| 320 | + // calling a method of an object | |
| 321 | + $this->api_functions[$func[1]] = array( | |
| 322 | + 'call' => $func, | |
| 323 | + 'input' => $input, | |
| 324 | + 'output' => $output, | |
| 325 | + 'comment' => $comment, | |
| 326 | + ); | |
| 327 | + $return_value = true; | |
| 328 | + | |
| 329 | + } elseif (is_string($func)) { | |
| 330 | + // calling a standalone function | |
| 331 | + $this->api_functions[$func] = array( | |
| 332 | + 'call' => $func, | |
| 333 | + 'input' => $input, | |
| 334 | + 'output' => $output, | |
| 335 | + 'comment' => $comment, | |
| 336 | + ); | |
| 337 | + $return_value = true; | |
| 338 | + } // end: if | |
| 339 | + | |
| 340 | + return $return_value; | |
| 341 | + } | |
| 342 | + | |
| 343 | + | |
| 344 | + | |
| 345 | + /** | |
| 346 | + * unregisters a function that is currently part of the CPAINT API. | |
| 347 | + * | |
| 348 | + * proves useful when the same set of functions is to be used in the | |
| 349 | + * frontend and in some kind of administration environment. you might | |
| 350 | + * want to unregister a few (admin) functions for the frontend in this | |
| 351 | + * case. | |
| 352 | + * | |
| 353 | + * @access public | |
| 354 | + * @param string $func function name | |
| 355 | + * @return boolean | |
| 356 | + */ | |
| 357 | + function unregister($func) { | |
| 358 | + $retval = false; | |
| 359 | + | |
| 360 | + if (is_array($this->api_functions[$func])) { | |
| 361 | + unset($this->api_functions[$func]); | |
| 362 | + } // end: if | |
| 363 | + | |
| 364 | + return $retval; | |
| 365 | + } | |
| 366 | + | |
| 367 | + | |
| 368 | + | |
| 369 | + /** | |
| 370 | + * registers a complex data type | |
| 371 | + * | |
| 372 | + * @access public | |
| 373 | + * @param array $schema schema definition for the complex type | |
| 374 | + * @return boolean | |
| 375 | + */ | |
| 376 | + function complex_type($schema) { | |
| 377 | + $return_value = false; | |
| 378 | + $schema = (array) $schema; | |
| 379 | + | |
| 380 | + if ($schema['name'] != '' | |
| 381 | + && in_array($schema['type'], array('restriction', 'complex', 'list'))) { | |
| 382 | + | |
| 383 | + $this->api_datatypes[] = $schema; | |
| 384 | + $return_value = true; | |
| 385 | + } // end: if | |
| 386 | + | |
| 387 | + return $return_value; | |
| 388 | + } | |
| 389 | + | |
| 390 | + /** | |
| 391 | + * switches the generation of WSDL on/off. default is on | |
| 392 | + * | |
| 393 | + * @access public | |
| 394 | + * @param boolean $state state of WSDL generation | |
| 395 | + * @return void | |
| 396 | + */ | |
| 397 | + function use_wsdl($state) { | |
| 398 | + $this->use_wsdl = (boolean) $state; | |
| 399 | + } | |
| 400 | + | |
| 401 | + /** | |
| 402 | + * adds a new subnode to the basenode. | |
| 403 | + * | |
| 404 | + * will return a reference to it for further processing. | |
| 405 | + * | |
| 406 | + * @access public | |
| 407 | + * @param string $nodename name of the new node | |
| 408 | + * @param string $id id of the new node | |
| 409 | + * @return object | |
| 410 | + */ | |
| 411 | + function &add_node($nodename, $id = '') { | |
| 412 | + return $this->basenode->add_node($nodename, $id); | |
| 413 | + } | |
| 414 | + | |
| 415 | + /** | |
| 416 | + * assigns textual data to the basenode. | |
| 417 | + * | |
| 418 | + * @access public | |
| 419 | + * @param mixed $data data to assign to this node | |
| 420 | + * @return void | |
| 421 | + */ | |
| 422 | + function set_data($data) { | |
| 423 | + $this->basenode->set_data($data); | |
| 424 | + } | |
| 425 | + | |
| 426 | + /** | |
| 427 | + * returns the data assigned to the basenode. | |
| 428 | + * | |
| 429 | + * @access public | |
| 430 | + * @return mixed | |
| 431 | + */ | |
| 432 | + function get_data() { | |
| 433 | + return $this->basenode->get_data(); | |
| 434 | + } | |
| 435 | + | |
| 436 | + /** | |
| 437 | + * sets the id property of the basenode. | |
| 438 | + * | |
| 439 | + * @deprecated deprecated since version 2.0.0 | |
| 440 | + * @access public | |
| 441 | + * @param string $id the id | |
| 442 | + * @return void | |
| 443 | + */ | |
| 444 | + function set_id($id) { | |
| 445 | + $this->basenode->set_attribute('id', $id); | |
| 446 | + } | |
| 447 | + | |
| 448 | + /** | |
| 449 | + * gets the id property of the basenode. | |
| 450 | + * | |
| 451 | + * @deprecated deprecated since version 2.0.0 | |
| 452 | + * @access public | |
| 453 | + * @return string | |
| 454 | + */ | |
| 455 | + function get_id() { | |
| 456 | + return $this->basenode->get_attribute('id'); | |
| 457 | + } | |
| 458 | + | |
| 459 | + /** | |
| 460 | + * adds a new attribute to the basenode. | |
| 461 | + * | |
| 462 | + * @access public | |
| 463 | + * @param string $name attribute name | |
| 464 | + * @param mixed $value attribute value | |
| 465 | + * @return void | |
| 466 | + */ | |
| 467 | + function set_attribute($name, $value) { | |
| 468 | + $this->basenode->set_attribute($name, $value); | |
| 469 | + } | |
| 470 | + | |
| 471 | + /** | |
| 472 | + * retrieves an attribute of the basenode by name. | |
| 473 | + * | |
| 474 | + * @access public | |
| 475 | + * @param string $name attribute name | |
| 476 | + * @return string | |
| 477 | + */ | |
| 478 | + function get_attribute($name) { | |
| 479 | + return $this->basenode->get_attributes($name); | |
| 480 | + } | |
| 481 | + | |
| 482 | + /** | |
| 483 | + * set name property of the basenode. | |
| 484 | + * | |
| 485 | + * @access public | |
| 486 | + * @param string $name the name | |
| 487 | + * @return void | |
| 488 | + */ | |
| 489 | + function set_name($name) { | |
| 490 | + $this->basenode->set_name($name); | |
| 491 | + } | |
| 492 | + | |
| 493 | + /** | |
| 494 | + * get name property of the basenode. | |
| 495 | + * | |
| 496 | + * @access public | |
| 497 | + * @return string | |
| 498 | + */ | |
| 499 | + function get_name() { | |
| 500 | + return $this->basenode->get_name(); | |
| 501 | + } | |
| 502 | + | |
| 503 | + | |
| 504 | + | |
| 505 | + /** | |
| 506 | + * returns the response type as requested by the client | |
| 507 | + * | |
| 508 | + * @access public | |
| 509 | + * @return string | |
| 510 | + */ | |
| 511 | + function get_response_type() { | |
| 512 | + return $this->response_type; | |
| 513 | + } | |
| 514 | + | |
| 515 | + } | |
| 516 | + | |
| 517 | + /** | |
| 518 | + * a cpaint data node. Data nodes are used to build up the response. | |
| 519 | + * | |
| 520 | + * @package CPAINT | |
| 521 | + * @access public | |
| 522 | + * @author Dominique Stender <dstender@st-webdevelopment.de> | |
| 523 | + * @copyright 2005-2006 (Dominique Stender); All rights reserved | |
| 524 | + * @version 2.0.3 | |
| 525 | + */ | |
| 526 | + class cpaint_node { | |
| 527 | + /** | |
| 528 | + * array of subnodes. | |
| 529 | + * | |
| 530 | + * @access public | |
| 531 | + * @var array $composites | |
| 532 | + */ | |
| 533 | + var $composites; | |
| 534 | + | |
| 535 | + /** | |
| 536 | + * node attributes. | |
| 537 | + * | |
| 538 | + * @access public | |
| 539 | + * @var array $attributes | |
| 540 | + */ | |
| 541 | + var $attributes; | |
| 542 | + | |
| 543 | + /** | |
| 544 | + * name of this node. | |
| 545 | + * | |
| 546 | + * @access public | |
| 547 | + * @var string $nodename | |
| 548 | + */ | |
| 549 | + var $nodename; | |
| 550 | + | |
| 551 | + /** | |
| 552 | + * textual data of this node. | |
| 553 | + * | |
| 554 | + * @access public | |
| 555 | + * @var string $data | |
| 556 | + */ | |
| 557 | + var $data; | |
| 558 | + | |
| 559 | + /** | |
| 560 | + * character encoding for input data | |
| 561 | + * | |
| 562 | + * @access private | |
| 563 | + * @var $input_encoding | |
| 564 | + */ | |
| 565 | + var $input_encoding; | |
| 566 | + | |
| 567 | + /** | |
| 568 | + * PHP4 constructor. | |
| 569 | + * | |
| 570 | + * @package CPAINT | |
| 571 | + * @access public | |
| 572 | + * @return void | |
| 573 | + */ | |
| 574 | + function cpaint_node() { | |
| 575 | + $this->__construct(); | |
| 576 | + } | |
| 577 | + | |
| 578 | + /** | |
| 579 | + * PHP 5 constructor. | |
| 580 | + * | |
| 581 | + * @access public | |
| 582 | + * @return void | |
| 583 | + */ | |
| 584 | + function __construct() { | |
| 585 | + // initialize properties | |
| 586 | + $this->composites = array(); | |
| 587 | + $this->attributes = array(); | |
| 588 | + $this->data = ''; | |
| 589 | + | |
| 590 | + $this->set_encoding('UTF-8'); | |
| 591 | + $this->set_name(''); | |
| 592 | + $this->set_attribute('id', ''); | |
| 593 | + } | |
| 594 | + | |
| 595 | + /** | |
| 596 | + * adds a new subnode to this node. | |
| 597 | + * | |
| 598 | + * will return a reference to it for further processing. | |
| 599 | + * | |
| 600 | + * @access public | |
| 601 | + * @param string $nodename name of the new node | |
| 602 | + * @param string $id id of the new node | |
| 603 | + * @return object | |
| 604 | + */ | |
| 605 | + function &add_node($nodename, $id = '') { | |
| 606 | + $composites = count($this->composites); | |
| 607 | + | |
| 608 | + // create new node | |
| 609 | + $this->composites[$composites] =& new cpaint_node(); | |
| 610 | + $this->composites[$composites]->set_name($nodename); | |
| 611 | + $this->composites[$composites]->set_attribute('id', $id); | |
| 612 | + $this->composites[$composites]->set_encoding($this->input_encoding); | |
| 613 | + | |
| 614 | + return $this->composites[$composites]; | |
| 615 | + } | |
| 616 | + | |
| 617 | + /** | |
| 618 | + * assigns textual data to this node. | |
| 619 | + * | |
| 620 | + * @access public | |
| 621 | + * @param mixed $data data to assign to this node | |
| 622 | + * @return void | |
| 623 | + */ | |
| 624 | + function set_data($data) { | |
| 625 | + $this->data = $data; | |
| 626 | + } | |
| 627 | + | |
| 628 | + /** | |
| 629 | + * returns the textual data assigned to this node. | |
| 630 | + * | |
| 631 | + * @access public | |
| 632 | + * @return mixed | |
| 633 | + */ | |
| 634 | + function get_data() { | |
| 635 | + return $this->data; | |
| 636 | + } | |
| 637 | + | |
| 638 | + /** | |
| 639 | + * sets the id property of this node. | |
| 640 | + * | |
| 641 | + * @deprecated deprecated since version 2.0.0 | |
| 642 | + * @access public | |
| 643 | + * @param string id the id | |
| 644 | + * @return void | |
| 645 | + */ | |
| 646 | + function set_id($id) { | |
| 647 | + if ($id != '') { | |
| 648 | + $this->set_attribute('id', $id); | |
| 649 | + } // end: if | |
| 650 | + } | |
| 651 | + | |
| 652 | + /** | |
| 653 | + * returns the id property if this node. | |
| 654 | + * | |
| 655 | + * @deprecated deprecated since version 2.0.0 | |
| 656 | + * @access public | |
| 657 | + * @return string | |
| 658 | + */ | |
| 659 | + function get_id() { | |
| 660 | + return $this->get_attribute('id'); | |
| 661 | + } | |
| 662 | + | |
| 663 | + /** | |
| 664 | + * adds a new attribute to this node. | |
| 665 | + * | |
| 666 | + * @access public | |
| 667 | + * @param string $name attribute name | |
| 668 | + * @param mixed $value attribute value | |
| 669 | + * @return void | |
| 670 | + */ | |
| 671 | + function set_attribute($name, $value) { | |
| 672 | + $this->attributes[$name] = (string) $value; | |
| 673 | + } | |
| 674 | + | |
| 675 | + /** | |
| 676 | + * retrieves an attribute by name. | |
| 677 | + * | |
| 678 | + * @access public | |
| 679 | + * @param string $name attribute name | |
| 680 | + * @return string | |
| 681 | + */ | |
| 682 | + function get_attribute($name) { | |
| 683 | + return $this->attributes[$name]; | |
| 684 | + } | |
| 685 | + | |
| 686 | + /** | |
| 687 | + * set name property. | |
| 688 | + * | |
| 689 | + * @access public | |
| 690 | + * @param string $name the name | |
| 691 | + * @return void | |
| 692 | + */ | |
| 693 | + function set_name($name) { | |
| 694 | + $this->nodename = (string) $name; | |
| 695 | + } | |
| 696 | + | |
| 697 | + /** | |
| 698 | + * get name property. | |
| 699 | + * | |
| 700 | + * @access public | |
| 701 | + * @return string | |
| 702 | + */ | |
| 703 | + function get_name() { | |
| 704 | + return $this->nodename; | |
| 705 | + } | |
| 706 | + | |
| 707 | + /** | |
| 708 | + * sets the character encoding for this node | |
| 709 | + * | |
| 710 | + * @access public | |
| 711 | + * @param string $encoding character encoding | |
| 712 | + * @return void | |
| 713 | + */ | |
| 714 | + function set_encoding($encoding) { | |
| 715 | + $this->input_encoding = strtoupper((string) $encoding); | |
| 716 | + } | |
| 717 | + | |
| 718 | + /** | |
| 719 | + * returns the character encoding for this node | |
| 720 | + * | |
| 721 | + * @access public | |
| 722 | + * @return string | |
| 723 | + */ | |
| 724 | + function get_encoding() { | |
| 725 | + return $this->input_encoding; | |
| 726 | + } | |
| 727 | + } | |
| 728 | + | |
| 729 | + /** | |
| 730 | + * static class of output transformers. | |
| 731 | + * | |
| 732 | + * @package CPAINT | |
| 733 | + * @access public | |
| 734 | + * @author Dominique Stender <dstender@st-webdevelopment.de> | |
| 735 | + * @copyright 2003-2006 (Dominique Stender); All rights reserved | |
| 736 | + * @version 2.0.3 | |
| 737 | + */ | |
| 738 | + class cpaint_transformer { | |
| 739 | + /** | |
| 740 | + * toString method, used to generate response of type TEXT. | |
| 741 | + * will perform character transformation according to parameters. | |
| 742 | + * | |
| 743 | + * @access public | |
| 744 | + * @param object $node a cpaint_node object | |
| 745 | + * @return string | |
| 746 | + */ | |
| 747 | + function toString(&$node) { | |
| 748 | + $return_value = ''; | |
| 749 | + | |
| 750 | + foreach ($node->composites as $composite) { | |
| 751 | + $return_value .= cpaint_transformer::toString($composite); | |
| 752 | + } | |
| 753 | + | |
| 754 | + $return_value .= cpaint_transformer::encode($node->get_data(), $node->get_encoding()); | |
| 755 | + | |
| 756 | + return $return_value; | |
| 757 | + } | |
| 758 | + | |
| 759 | + /** | |
| 760 | + * XML response generator. | |
| 761 | + * will perform character transformation according to parameters. | |
| 762 | + * | |
| 763 | + * @access public | |
| 764 | + * @param object $node a cpaint_node object | |
| 765 | + * @return string | |
| 766 | + */ | |
| 767 | + function toXML(&$node) { | |
| 768 | + $return_value = '<' . $node->get_name(); | |
| 769 | + | |
| 770 | + // handle attributes | |
| 771 | + foreach ($node->attributes as $name => $value) { | |
| 772 | + if ($value != '') { | |
| 773 | + $return_value .= ' ' . $name . '="' . $node->get_attribute($name) . '"'; | |
| 774 | + } | |
| 775 | + } // end: foreach | |
| 776 | + | |
| 777 | + $return_value .= '>'; | |
| 778 | + | |
| 779 | + // handle subnodes | |
| 780 | + foreach ($node->composites as $composite) { | |
| 781 | + $return_value .= cpaint_transformer::toXML($composite); | |
| 782 | + } | |
| 783 | + | |
| 784 | + $return_value .= cpaint_transformer::encode($node->get_data(), $node->get_encoding()) | |
| 785 | + . '</' . $node->get_name() . '>'; | |
| 786 | + | |
| 787 | + return $return_value; | |
| 788 | + } | |
| 789 | + | |
| 790 | + /** | |
| 791 | + * JSON response generator. | |
| 792 | + * will perform character transformation according to parameters. | |
| 793 | + * | |
| 794 | + * @access public | |
| 795 | + * @param object $node a cpaint_node object | |
| 796 | + * @return string | |
| 797 | + */ | |
| 798 | + function toJSON($node) { | |
| 799 | + $return_value = ''; | |
| 800 | + $JSON_node = new stdClass(); | |
| 801 | + | |
| 802 | + // handle attributes | |
| 803 | + $JSON_node->attributes = $node->attributes; | |
| 804 | + | |
| 805 | + // handle subnodes | |
| 806 | + foreach ($node->composites as $composite) { | |
| 807 | + | |
| 808 | + if (!is_array($JSON_node->{$composite->nodename})) { | |
| 809 | + $JSON_node->{$composite->nodename} = array(); | |
| 810 | + } // end: if | |
| 811 | + | |
| 812 | + // we need to parse the JSON object again to avoid multiple encoding | |
| 813 | + $JSON_node->{$composite->nodename}[] = $GLOBALS['__cpaint_json']->parse(cpaint_transformer::toJSON($composite)); | |
| 814 | + } | |
| 815 | + | |
| 816 | + // handle data | |
| 817 | + $JSON_node->data = $node->data; | |
| 818 | + | |
| 819 | + return $GLOBALS['__cpaint_json']->stringify($JSON_node); | |
| 820 | + } | |
| 821 | + | |
| 822 | + /** | |
| 823 | + * performs conversion to JavaScript-safe UTF-8 characters | |
| 824 | + * | |
| 825 | + * @access public | |
| 826 | + * @param string $data data to convert | |
| 827 | + * @param string $encoding character encoding | |
| 828 | + * @return string | |
| 829 | + */ | |
| 830 | + function encode($data, $encoding) { | |
| 831 | + // convert string | |
| 832 | + if (function_exists('iconv')) { | |
| 833 | + // iconv is by far the most flexible approach, try this first | |
| 834 | + $return_value = iconv($encoding, 'UTF-8', $data); | |
| 835 | + | |
| 836 | + } elseif ($encoding == 'ISO-8859-1') { | |
| 837 | + // for ISO-8859-1 we can use utf8-encode() | |
| 838 | + $return_value = utf8_encode($data); | |
| 839 | + | |
| 840 | + } else { | |
| 841 | + // give up. if UTF-8 data was supplied everything is fine! | |
| 842 | + $return_value = $data; | |
| 843 | + } /* end: if */ | |
| 844 | + | |
| 845 | + // now encode non-printable characters | |
| 846 | + for ($i = 0; $i < 32; $i++) { | |
| 847 | + $return_value = str_replace(chr($i), '\u00' . sprintf('%02x', $i), $return_value); | |
| 848 | + } // end: for | |
| 849 | + | |
| 850 | + // encode <, >, and & respectively for XML sanity | |
| 851 | + $return_value = str_replace(chr(0x26), '\u0026', $return_value); | |
| 852 | + $return_value = str_replace(chr(0x3c), '\u003c', $return_value); | |
| 853 | + $return_value = str_replace(chr(0x3e), '\u003e', $return_value); | |
| 854 | + | |
| 855 | + return $return_value; | |
| 856 | + } | |
| 857 | + | |
| 858 | + /** | |
| 859 | + * performs conversion from JavaScript encodeURIComponent() string (UTF-8) to | |
| 860 | + * the charset in use. | |
| 861 | + * | |
| 862 | + * @access public | |
| 863 | + * @param string $data data to convert | |
| 864 | + * @param string $encoding character encoding | |
| 865 | + * @return string | |
| 866 | + */ | |
| 867 | + function decode($data, $encoding) { | |
| 868 | + // convert string | |
| 869 | + | |
| 870 | + if (is_string($data)) { | |
| 871 | + if (function_exists('iconv')) { | |
| 872 | + // iconv is by far the most flexible approach, try this first | |
| 873 | + $return_value = iconv('UTF-8', $encoding, $data); | |
| 874 | + | |
| 875 | + } elseif ($encoding == 'ISO-8859-1') { | |
| 876 | + // for ISO-8859-1 we can use utf8-decode() | |
| 877 | + $return_value = utf8_decode($data); | |
| 878 | + | |
| 879 | + } else { | |
| 880 | + // give up. if data was supplied in the correct format everything is fine! | |
| 881 | + $return_value = $data; | |
| 882 | + } // end: if | |
| 883 | + | |
| 884 | + } else { | |
| 885 | + // non-string value | |
| 886 | + $return_value = $data; | |
| 887 | + } // end: if | |
| 888 | + | |
| 889 | + return $return_value; | |
| 890 | + } | |
| 891 | + | |
| 892 | + /** | |
| 893 | + * decodes a (nested) array of data from UTF-8 into the configured character set | |
| 894 | + * | |
| 895 | + * @access public | |
| 896 | + * @param array $data data to convert | |
| 897 | + * @param string $encoding character encoding | |
| 898 | + * @return array | |
| 899 | + */ | |
| 900 | + function decode_array($data, $encoding) { | |
| 901 | + $return_value = array(); | |
| 902 | + | |
| 903 | + foreach ($data as $key => $value) { | |
| 904 | + | |
| 905 | + if (!is_array($value)) { | |
| 906 | + $return_value[$key] = cpaint_transformer::decode($value, $encoding); | |
| 907 | + | |
| 908 | + } else { | |
| 909 | + $return_value[$key] = cpaint_transformer::decode_array($value, $encoding); | |
| 910 | + } | |
| 911 | + } | |
| 912 | + | |
| 913 | + return $return_value; | |
| 914 | + } | |
| 915 | + | |
| 916 | + /** | |
| 917 | + * determines the output character set | |
| 918 | + * based on input character set | |
| 919 | + * | |
| 920 | + * @access public | |
| 921 | + * @param string $encoding character encoding | |
| 922 | + * @return string | |
| 923 | + */ | |
| 924 | + function find_output_charset($encoding) { | |
| 925 | + $return_value = 'UTF-8'; | |
| 926 | + | |
| 927 | + if (function_exists('iconv') | |
| 928 | + || $encoding == 'UTF-8' | |
| 929 | + || $encoding == 'ISO-8859-1') { | |
| 930 | + | |
| 931 | + $return_value = 'UTF-8'; | |
| 932 | + | |
| 933 | + } else { | |
| 934 | + $return_value = $encoding; | |
| 935 | + } // end: if | |
| 936 | + | |
| 937 | + return $return_value; | |
| 938 | + } | |
| 939 | + } | |
| 941 | 940 | |
| 942 | 941 | ?> |
| 943 | 942 | \ No newline at end of file | ... | ... |
pacotes/facebookoauth/config.php
pacotes/gvsig/gvsig2mapfile/upload.php
| 1 | 1 | <?php |
| 2 | -require_once("../../../classesphp/pega_variaveis.php"); | |
| 3 | -require_once("../../../classesphp/funcoes_gerais.php"); | |
| 2 | +require_once(dirname(__FILE__)."/../../../classesphp/pega_variaveis.php"); | |
| 3 | +require_once(dirname(__FILE__)."/../../../classesphp/funcoes_gerais.php"); | |
| 4 | 4 | $versao = versao(); |
| 5 | 5 | $versao = $versao["principal"]; |
| 6 | 6 | error_reporting(0); |
| 7 | 7 | if (isset($_FILES['i3GEOuploadfile']['name'])) |
| 8 | 8 | { |
| 9 | - require_once ("../../../ms_configura.php"); | |
| 9 | + require_once (dirname(__FILE__)."/../../../ms_configura.php"); | |
| 10 | 10 | include_once("class.gvsig2mapfile.php"); |
| 11 | 11 | if($base == "" or !isset($base)){ |
| 12 | 12 | $base = ""; |
| ... | ... | @@ -70,8 +70,8 @@ if (isset($_FILES['i3GEOuploadfile']['name'])) |
| 70 | 70 | $handle = fopen(str_replace(".gvp",".map",$Arquivon), "r"); |
| 71 | 71 | echo "<html>#mapfile: <br>"; |
| 72 | 72 | while (!feof($handle)) |
| 73 | - { | |
| 74 | - $linha = fgets($handle); | |
| 73 | + { | |
| 74 | + $linha = fgets($handle); | |
| 75 | 75 | echo $linha."<br>"; |
| 76 | 76 | } |
| 77 | 77 | fclose($handle); |
| ... | ... | @@ -88,7 +88,7 @@ function verificaNome($nome) |
| 88 | 88 | $extensao = $lista[count($lista) - 1]; |
| 89 | 89 | if($extensao != "gvp") |
| 90 | 90 | { |
| 91 | - echo "Nome de arquivo inválido"; | |
| 91 | + echo "Nome de arquivo inv�lido"; | |
| 92 | 92 | exit; |
| 93 | 93 | } |
| 94 | 94 | } | ... | ... |
pacotes/kmlmapserver/classes/layerserver.class.php
| ... | ... | @@ -22,19 +22,19 @@ |
| 22 | 22 | |
| 23 | 23 | This file is part of KMLMAPSERVER. |
| 24 | 24 | |
| 25 | - KMLMAPSERVER is free software; you can redistribute it and/or modify | |
| 26 | - it under the terms of the GNU Lesser General Public License as published by | |
| 27 | - the Free Software Foundation; either version 3 of the License, or | |
| 28 | - (at your option) any later version. | |
| 25 | + KMLMAPSERVER is free software; you can redistribute it and/or modify | |
| 26 | + it under the terms of the GNU Lesser General Public License as published by | |
| 27 | + the Free Software Foundation; either version 3 of the License, or | |
| 28 | + (at your option) any later version. | |
| 29 | 29 | |
| 30 | - KMLMAPSERVER is distributed in the hope that it will be useful, | |
| 31 | - but WITHOUT ANY WARRANTY; without even the implied warranty of | |
| 32 | - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
| 33 | - GNU Lesser General Public License for more details. | |
| 30 | + KMLMAPSERVER is distributed in the hope that it will be useful, | |
| 31 | + but WITHOUT ANY WARRANTY; without even the implied warranty of | |
| 32 | + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
| 33 | + GNU Lesser General Public License for more details. | |
| 34 | 34 | |
| 35 | - You should have received a copy of the GNU Lesser General Public License | |
| 36 | - along with KMLMAPSERVER; if not, write to the Free Software | |
| 37 | - Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | |
| 35 | + You should have received a copy of the GNU Lesser General Public License | |
| 36 | + along with KMLMAPSERVER; if not, write to the Free Software | |
| 37 | + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | |
| 38 | 38 | |
| 39 | 39 | */ |
| 40 | 40 | |
| ... | ... | @@ -57,232 +57,232 @@ if (!function_exists('ms_GetVersion')) |
| 57 | 57 | */ |
| 58 | 58 | class LayerServer { |
| 59 | 59 | |
| 60 | - /** map file path */ | |
| 61 | - var $map; | |
| 60 | + /** map file path */ | |
| 61 | + var $map; | |
| 62 | 62 | |
| 63 | - /** request */ | |
| 64 | - var $request; | |
| 63 | + /** request */ | |
| 64 | + var $request; | |
| 65 | 65 | |
| 66 | - /** map instance */ | |
| 67 | - var $map_object; | |
| 66 | + /** map instance */ | |
| 67 | + var $map_object; | |
| 68 | 68 | |
| 69 | - /** layer name(s) passed on the request */ | |
| 70 | - var $typename; | |
| 69 | + /** layer name(s) passed on the request */ | |
| 70 | + var $typename; | |
| 71 | 71 | |
| 72 | - /** array of requested layer objects (hash with layer name as key) */ | |
| 73 | - var $layers; | |
| 72 | + /** array of requested layer objects (hash with layer name as key) */ | |
| 73 | + var $layers; | |
| 74 | 74 | |
| 75 | - /** filters */ | |
| 76 | - var $filter; | |
| 75 | + /** filters */ | |
| 76 | + var $filter; | |
| 77 | 77 | |
| 78 | - /** bounding box */ | |
| 79 | - var $bbox; | |
| 78 | + /** bounding box */ | |
| 79 | + var $bbox; | |
| 80 | 80 | |
| 81 | - /** error messages */ | |
| 82 | - var $errors; | |
| 81 | + /** error messages */ | |
| 82 | + var $errors; | |
| 83 | 83 | |
| 84 | - /** send zipped data */ | |
| 85 | - var $_zipped = false; | |
| 84 | + /** send zipped data */ | |
| 85 | + var $_zipped = false; | |
| 86 | 86 | |
| 87 | - /** internal XML buffer */ | |
| 88 | - var $_xml; | |
| 87 | + /** internal XML buffer */ | |
| 88 | + var $_xml; | |
| 89 | 89 | |
| 90 | - /** input projection */ | |
| 91 | - var $in_proj; | |
| 90 | + /** input projection */ | |
| 91 | + var $in_proj; | |
| 92 | 92 | |
| 93 | - /** output projection */ | |
| 94 | - var $out_proj; | |
| 93 | + /** output projection */ | |
| 94 | + var $out_proj; | |
| 95 | 95 | |
| 96 | - /** debug flag */ | |
| 97 | - var $_debug = false; | |
| 96 | + /** debug flag */ | |
| 97 | + var $_debug = false; | |
| 98 | 98 | |
| 99 | - /** end point */ | |
| 100 | - var $endpoint; | |
| 99 | + /** end point */ | |
| 100 | + var $endpoint; | |
| 101 | 101 | |
| 102 | - /** custom style counter */ | |
| 103 | - var $style_counter = 0; | |
| 102 | + /** custom style counter */ | |
| 103 | + var $style_counter = 0; | |
| 104 | 104 | |
| 105 | - /** | |
| 106 | - * Mapfile and data encoding encoding | |
| 107 | - * XMl output must be UTF-8, attributes and METADATA based strings | |
| 108 | - * must be converted to UTF-8, encoding defaults to ISO-8859-1, if | |
| 109 | - * your encoding is different, you can set it through CGI style parameters | |
| 110 | - */ | |
| 111 | - var $encoding; | |
| 105 | + /** | |
| 106 | + * Mapfile and data encoding encoding | |
| 107 | + * XMl output must be UTF-8, attributes and METADATA based strings | |
| 108 | + * must be converted to UTF-8, encoding defaults to ISO-8859-1, if | |
| 109 | + * your encoding is different, you can set it through CGI style parameters | |
| 110 | + */ | |
| 111 | + var $encoding; | |
| 112 | 112 | |
| 113 | - /** | |
| 114 | - * send networklink | |
| 115 | - * wether folder should contain networklinks instead of real geometries | |
| 116 | - * it is automatically set when all layers are requested | |
| 117 | - */ | |
| 118 | - var $_networklink; | |
| 113 | + /** | |
| 114 | + * send networklink | |
| 115 | + * wether folder should contain networklinks instead of real geometries | |
| 116 | + * it is automatically set when all layers are requested | |
| 117 | + */ | |
| 118 | + var $_networklink; | |
| 119 | 119 | |
| 120 | 120 | |
| 121 | - /** | |
| 122 | - * Initialize | |
| 123 | - * | |
| 124 | - */ | |
| 125 | - function LayerServer(){ | |
| 126 | - $this->errors = array(); | |
| 127 | - // Load request parameters | |
| 128 | - $this->get_request(); | |
| 121 | + /** | |
| 122 | + * Initialize | |
| 123 | + * | |
| 124 | + */ | |
| 125 | + function LayerServer(){ | |
| 126 | + $this->errors = array(); | |
| 127 | + // Load request parameters | |
| 128 | + $this->get_request(); | |
| 129 | 129 | |
| 130 | - $this->style_counter = 0; | |
| 130 | + $this->style_counter = 0; | |
| 131 | 131 | |
| 132 | - // Load map | |
| 133 | - if(!$this->has_error()) { | |
| 134 | - $this->load_map(); | |
| 135 | - } | |
| 132 | + // Load map | |
| 133 | + if(!$this->has_error()) { | |
| 134 | + $this->load_map(); | |
| 135 | + } | |
| 136 | 136 | |
| 137 | - } | |
| 137 | + } | |
| 138 | 138 | |
| 139 | - /** | |
| 140 | - * Run the server and sends data | |
| 141 | - * @return string or void | |
| 142 | - */ | |
| 143 | - function run(){ | |
| 144 | - // Check cache | |
| 145 | - if(ENABLE_CACHE){ | |
| 146 | - $cache_file = $this->get_cache_file_name(); | |
| 147 | - if(file_exists($cache_file)){ | |
| 139 | + /** | |
| 140 | + * Run the server and sends data | |
| 141 | + * @return string or void | |
| 142 | + */ | |
| 143 | + function run(){ | |
| 144 | + // Check cache | |
| 145 | + if(ENABLE_CACHE){ | |
| 146 | + $cache_file = $this->get_cache_file_name(); | |
| 147 | + if(file_exists($cache_file)){ | |
| 148 | 148 | $this->send_header(); |
| 149 | 149 | readfile($cache_file); |
| 150 | 150 | exit; |
| 151 | - } | |
| 152 | - } | |
| 153 | - // If not layer are requested, send all as networklinks | |
| 154 | - if(!$this->typename){ | |
| 155 | - $this->_networklink = true; | |
| 156 | - $this->typename = $this->get_layer_list(); | |
| 157 | - } else { | |
| 158 | - $this->_networklink = false; | |
| 159 | - } | |
| 151 | + } | |
| 152 | + } | |
| 153 | + // If not layer are requested, send all as networklinks | |
| 154 | + if(!$this->typename){ | |
| 155 | + $this->_networklink = true; | |
| 156 | + $this->typename = $this->get_layer_list(); | |
| 157 | + } else { | |
| 158 | + $this->_networklink = false; | |
| 159 | + } | |
| 160 | 160 | |
| 161 | - $imageObj = $this->map_object->drawlegend(); | |
| 162 | - $url = $imageObj->saveWebImage(); | |
| 163 | - $protocolo = explode("/",$_SERVER['SERVER_PROTOCOL']); | |
| 164 | - $url = strtolower($protocolo[0]."://".$_SERVER['HTTP_HOST']).$url; | |
| 165 | - $legenda = " <ScreenOverlay>" . PHP_EOL | |
| 166 | - . " <name>Legenda</name>" . PHP_EOL | |
| 167 | - . " <Icon>" . PHP_EOL | |
| 168 | - . " <href>".$url."</href>" . PHP_EOL | |
| 169 | - . " </Icon>" . PHP_EOL | |
| 170 | - . " <overlayXY x='0.01' y='0.14' xunits='fraction' yunits='fraction'/>" . PHP_EOL | |
| 171 | - . " <screenXY x='0.01' y='0.14' xunits='fraction' yunits='fraction'/>" . PHP_EOL | |
| 172 | - . " <size x='-1' y='-1' xunits='pixels' yunits='pixels'/>" . PHP_EOL | |
| 173 | - . " </ScreenOverlay>" . PHP_EOL; | |
| 174 | - | |
| 175 | - $this->_xml = new SimpleXMLElement('<kml xmlns="http://earth.google.com/kml/2.0"><Document >'.$legenda.'</Document></kml>'); | |
| 176 | - // Prepare projection | |
| 177 | - $this->in_proj = ms_newProjectionObj($this->map_object->getProjection()); | |
| 178 | - // Set projection to GOOGLE earth's projection | |
| 179 | - $this->out_proj = ms_newProjectionObj("init=epsg:4326"); | |
| 180 | - // Set endpoint | |
| 181 | - //die($_SERVER['REQUEST_URI']); | |
| 161 | + $imageObj = $this->map_object->drawlegend(); | |
| 162 | + $url = $imageObj->saveWebImage(); | |
| 163 | + $protocolo = explode("/",$_SERVER['SERVER_PROTOCOL']); | |
| 164 | + $url = strtolower($protocolo[0]."://".$_SERVER['HTTP_HOST']).$url; | |
| 165 | + $legenda = " <ScreenOverlay>" . PHP_EOL | |
| 166 | + . " <name>Legenda</name>" . PHP_EOL | |
| 167 | + . " <Icon>" . PHP_EOL | |
| 168 | + . " <href>".$url."</href>" . PHP_EOL | |
| 169 | + . " </Icon>" . PHP_EOL | |
| 170 | + . " <overlayXY x='0.01' y='0.14' xunits='fraction' yunits='fraction'/>" . PHP_EOL | |
| 171 | + . " <screenXY x='0.01' y='0.14' xunits='fraction' yunits='fraction'/>" . PHP_EOL | |
| 172 | + . " <size x='-1' y='-1' xunits='pixels' yunits='pixels'/>" . PHP_EOL | |
| 173 | + . " </ScreenOverlay>" . PHP_EOL; | |
| 174 | + | |
| 175 | + $this->_xml = new SimpleXMLElement('<kml xmlns="http://earth.google.com/kml/2.0"><Document >'.$legenda.'</Document></kml>'); | |
| 176 | + // Prepare projection | |
| 177 | + $this->in_proj = ms_newProjectionObj($this->map_object->getProjection()); | |
| 178 | + // Set projection to GOOGLE earth's projection | |
| 179 | + $this->out_proj = ms_newProjectionObj("init=epsg:4326"); | |
| 180 | + // Set endpoint | |
| 181 | + //die($_SERVER['REQUEST_URI']); | |
| 182 | 182 | |
| 183 | 183 | $protocolo = explode("/",$_SERVER['SERVER_PROTOCOL']); |
| 184 | 184 | $protocolo = strtolower($protocolo[0]); |
| 185 | - $this->endpoint = $protocolo . '://'.$_SERVER['SERVER_NAME'] . ($_SERVER['SERVER_PORT'] ? ':'.$_SERVER['SERVER_PORT'] : '') . $_SERVER['PHP_SELF']; | |
| 186 | - | |
| 187 | - // Process request | |
| 188 | - if(!$this->has_error()) { | |
| 189 | - $this->process_request(); | |
| 190 | - } | |
| 191 | - if($this->has_error()){ | |
| 192 | - $this->add_errors(); | |
| 193 | - } | |
| 194 | - | |
| 195 | - return $this->send_stream($this->get_kml()); | |
| 196 | - | |
| 197 | - } | |
| 198 | - | |
| 199 | - /** | |
| 200 | - * Set debug flag | |
| 201 | - * @param boolean $value | |
| 202 | - */ | |
| 203 | - function set_debug($value){ | |
| 204 | - $this->_debug = $value; | |
| 205 | - } | |
| 206 | - | |
| 207 | - /** | |
| 208 | - * Get all request parameters | |
| 209 | - */ | |
| 210 | - function get_request(){ | |
| 211 | - $this->map = $this->load_parm('map'); | |
| 212 | - $this->bbox = $this->load_parm('bbox'); | |
| 213 | - $this->filter = $this->load_parm('filter'); | |
| 214 | - $this->typename = $this->load_parm('typename'); | |
| 215 | - $this->encoding = $this->load_parm('encoding', 'ISO-8859-1'); | |
| 216 | - $this->request = $this->load_parm('request', 'kml'); | |
| 217 | - if($this->request == 'kmz') { | |
| 218 | - $this->_zipped = true; | |
| 219 | - } | |
| 220 | - if(!$this->map){ | |
| 221 | - $this->set_error('No mapfile specified'); | |
| 222 | - } | |
| 223 | - } | |
| 224 | - | |
| 225 | - /** | |
| 226 | - * Apply filter | |
| 227 | - * @return array | |
| 228 | - */ | |
| 229 | - function apply_filter(&$layer, &$filter){ | |
| 230 | - if($layer->connectiontype == MS_POSTGIS){ | |
| 231 | - if($filter->PropertyIsEqualTo){ | |
| 232 | - $searchstring = '"'.$filter->PropertyIsEqualTo->PropertyName . ' = ' . '\''.addslashes($filter->PropertyIsEqualTo->Literal).'\''.'"'; | |
| 233 | - $searchfield = $filter->PropertyIsEqualTo->PropertyName; | |
| 234 | - } elseif($filter->PropertyIsLike){ | |
| 235 | - $searchfield = $filter->PropertyIsLike->PropertyName; | |
| 236 | - $searchstring ='"'.$filter->PropertyIsLike->PropertyName . ' LIKE \'%' . addslashes($filter->PropertyIsLike->Literal) . '%\''.'"'; | |
| 237 | - } | |
| 238 | - } elseif($layer->connectiontype == MS_SHAPEFILE || $layer->connectiontype == MS_OGR){ | |
| 239 | - if($filter->PropertyIsEqualTo){ | |
| 240 | - $searchstring = $filter->PropertyIsEqualTo->Literal; | |
| 241 | - $searchfield = $filter->PropertyIsEqualTo->PropertyName; | |
| 242 | - } elseif($filter->PropertyIsLike){ | |
| 243 | - $searchstring = $filter->PropertyIsLike->Literal; | |
| 244 | - $searchfield = $filter->PropertyIsLike->PropertyName; | |
| 245 | - } | |
| 246 | - } | |
| 247 | - return array($searchfield, $searchstring); | |
| 248 | - } | |
| 249 | - /** | |
| 250 | - * Process request | |
| 251 | - */ | |
| 252 | - function process_request(){ | |
| 253 | - // Get layer(s) | |
| 254 | - $layers = explode(',', $this->typename); | |
| 255 | - if($this->_networklink){ | |
| 256 | - foreach($layers as $layer){ | |
| 257 | - $this->add_networklink($layer); | |
| 258 | - } | |
| 259 | - } else { | |
| 260 | - foreach($layers as $layer){ | |
| 261 | - //echo "Oi";exit; | |
| 262 | - $this->process_layer_request($layer); | |
| 263 | - } | |
| 264 | - } | |
| 265 | - } | |
| 266 | - /** | |
| 267 | - * Add a networklink | |
| 268 | - */ | |
| 269 | - function add_networklink(&$layer_name){ | |
| 270 | - $nl =& $this->_xml->Document->addChild('NetworkLink'); | |
| 271 | - $layer = @$this->map_object->getLayerByName($layer_name); | |
| 185 | + $this->endpoint = $protocolo . '://'.$_SERVER['SERVER_NAME'] . ($_SERVER['SERVER_PORT'] ? ':'.$_SERVER['SERVER_PORT'] : '') . $_SERVER['PHP_SELF']; | |
| 186 | + | |
| 187 | + // Process request | |
| 188 | + if(!$this->has_error()) { | |
| 189 | + $this->process_request(); | |
| 190 | + } | |
| 191 | + if($this->has_error()){ | |
| 192 | + $this->add_errors(); | |
| 193 | + } | |
| 194 | + | |
| 195 | + return $this->send_stream($this->get_kml()); | |
| 196 | + | |
| 197 | + } | |
| 198 | + | |
| 199 | + /** | |
| 200 | + * Set debug flag | |
| 201 | + * @param boolean $value | |
| 202 | + */ | |
| 203 | + function set_debug($value){ | |
| 204 | + $this->_debug = $value; | |
| 205 | + } | |
| 206 | + | |
| 207 | + /** | |
| 208 | + * Get all request parameters | |
| 209 | + */ | |
| 210 | + function get_request(){ | |
| 211 | + $this->map = $this->load_parm('map'); | |
| 212 | + $this->bbox = $this->load_parm('bbox'); | |
| 213 | + $this->filter = $this->load_parm('filter'); | |
| 214 | + $this->typename = $this->load_parm('typename'); | |
| 215 | + $this->encoding = $this->load_parm('encoding', 'ISO-8859-1'); | |
| 216 | + $this->request = $this->load_parm('request', 'kml'); | |
| 217 | + if($this->request == 'kmz') { | |
| 218 | + $this->_zipped = true; | |
| 219 | + } | |
| 220 | + if(!$this->map){ | |
| 221 | + $this->set_error('No mapfile specified'); | |
| 222 | + } | |
| 223 | + } | |
| 224 | + | |
| 225 | + /** | |
| 226 | + * Apply filter | |
| 227 | + * @return array | |
| 228 | + */ | |
| 229 | + function apply_filter(&$layer, &$filter){ | |
| 230 | + if($layer->connectiontype == MS_POSTGIS){ | |
| 231 | + if($filter->PropertyIsEqualTo){ | |
| 232 | + $searchstring = '"'.$filter->PropertyIsEqualTo->PropertyName . ' = ' . '\''.addslashes($filter->PropertyIsEqualTo->Literal).'\''.'"'; | |
| 233 | + $searchfield = $filter->PropertyIsEqualTo->PropertyName; | |
| 234 | + } elseif($filter->PropertyIsLike){ | |
| 235 | + $searchfield = $filter->PropertyIsLike->PropertyName; | |
| 236 | + $searchstring ='"'.$filter->PropertyIsLike->PropertyName . ' LIKE \'%' . addslashes($filter->PropertyIsLike->Literal) . '%\''.'"'; | |
| 237 | + } | |
| 238 | + } elseif($layer->connectiontype == MS_SHAPEFILE || $layer->connectiontype == MS_OGR){ | |
| 239 | + if($filter->PropertyIsEqualTo){ | |
| 240 | + $searchstring = $filter->PropertyIsEqualTo->Literal; | |
| 241 | + $searchfield = $filter->PropertyIsEqualTo->PropertyName; | |
| 242 | + } elseif($filter->PropertyIsLike){ | |
| 243 | + $searchstring = $filter->PropertyIsLike->Literal; | |
| 244 | + $searchfield = $filter->PropertyIsLike->PropertyName; | |
| 245 | + } | |
| 246 | + } | |
| 247 | + return array($searchfield, $searchstring); | |
| 248 | + } | |
| 249 | + /** | |
| 250 | + * Process request | |
| 251 | + */ | |
| 252 | + function process_request(){ | |
| 253 | + // Get layer(s) | |
| 254 | + $layers = explode(',', $this->typename); | |
| 255 | + if($this->_networklink){ | |
| 256 | + foreach($layers as $layer){ | |
| 257 | + $this->add_networklink($layer); | |
| 258 | + } | |
| 259 | + } else { | |
| 260 | + foreach($layers as $layer){ | |
| 261 | + //echo "Oi";exit; | |
| 262 | + $this->process_layer_request($layer); | |
| 263 | + } | |
| 264 | + } | |
| 265 | + } | |
| 266 | + /** | |
| 267 | + * Add a networklink | |
| 268 | + */ | |
| 269 | + function add_networklink(&$layer_name){ | |
| 270 | + $nl =& $this->_xml->Document->addChild('NetworkLink'); | |
| 271 | + $layer = @$this->map_object->getLayerByName($layer_name); | |
| 272 | 272 | if(!$layer) |
| 273 | 273 | {$layer = $this->map_object->getlayer(0);} |
| 274 | - $nl->addChild('name', $this->get_layer_description($layer)); | |
| 275 | - $nl->addChild('visibility', 0); | |
| 276 | - $link =& $nl->addChild('Link'); | |
| 277 | - $link->addChild('href', $this->endpoint . '?map=' . $this->map . '&typename=' . urlencode($layer_name) . '&request=' . ($this->_zipped ? 'kmz' : 'kml')); | |
| 278 | - } | |
| 279 | - | |
| 280 | - | |
| 281 | - /** | |
| 282 | - * Process a single layer | |
| 283 | - * @return boolean false on error | |
| 284 | - */ | |
| 285 | - function process_layer_request(&$layer_name){ | |
| 274 | + $nl->addChild('name', $this->get_layer_description($layer)); | |
| 275 | + $nl->addChild('visibility', 0); | |
| 276 | + $link =& $nl->addChild('Link'); | |
| 277 | + $link->addChild('href', $this->endpoint . '?map=' . $this->map . '&typename=' . urlencode($layer_name) . '&request=' . ($this->_zipped ? 'kmz' : 'kml')); | |
| 278 | + } | |
| 279 | + | |
| 280 | + | |
| 281 | + /** | |
| 282 | + * Process a single layer | |
| 283 | + * @return boolean false on error | |
| 284 | + */ | |
| 285 | + function process_layer_request(&$layer_name){ | |
| 286 | 286 | error_reporting(0); |
| 287 | 287 | $v = "5.0.0"; |
| 288 | 288 | $vs = explode(" ",ms_GetVersion()); |
| ... | ... | @@ -294,116 +294,116 @@ class LayerServer { |
| 294 | 294 | $v = explode(".",$v); |
| 295 | 295 | $versao = $v[0]; |
| 296 | 296 | |
| 297 | - $layer = @$this->map_object->getLayerByName($layer_name); | |
| 297 | + $layer = @$this->map_object->getLayerByName($layer_name); | |
| 298 | 298 | if(!$layer) |
| 299 | 299 | {$layer = $this->map_object->getlayer(0);} |
| 300 | - if(!$layer){ | |
| 301 | - $this->set_error('Nenhum layer com esse nome foi encontrado no mapfile ' . $layer_name, $layer_name); | |
| 302 | - return false; | |
| 303 | - } | |
| 304 | - // Add to layer list | |
| 305 | - $this->layers[$layer_name] =& $layer; | |
| 306 | - // Get custom template if any | |
| 307 | - $description_template = $layer->getMetadata('DESCRIPTION_TEMPLATE'); | |
| 308 | - // Set on | |
| 309 | - $layer->set( 'status', MS_DEFAULT ); | |
| 310 | - // Set kml title from layer description (default to layer name) | |
| 311 | - $layer_desc = $this->get_layer_description($layer); | |
| 312 | - | |
| 313 | - // Now switch raster layers | |
| 314 | - //var_dump($layer->type == MS_LAYER_RASTER); | |
| 315 | - if($layer->type == MS_LAYER_RASTER){ | |
| 316 | - // Check if wms_onlineresource metadata is set | |
| 317 | - $wms_link = $this->map_object->getMetadata('wms_onlineresource'); | |
| 318 | - if(!$wms_link){ | |
| 319 | - $wms_link = $this->map_object->getMetadata('ows_onlineresource'); | |
| 320 | - } | |
| 321 | - if(!$wms_link){ | |
| 322 | - $this->set_error('No WMS server available for ' . $layer_name, $layer_name); | |
| 323 | - return false; | |
| 324 | - } | |
| 325 | - // Add parameters to OGC server call | |
| 326 | - // Fix & | |
| 327 | - $wms_link = preg_replace('/&/', '&', $wms_link); | |
| 328 | - $wms_link .= 'VERSION=1.1.1&REQUEST=GetMap&SRS=EPSG:4618&STYLES=&FORMAT=image/jpeg&TRANSPARENT=TRUE&'; | |
| 329 | - // Link ok, create folder | |
| 330 | - //$folder =& $this->_xml->Document->addChild('GroundOverlay'); | |
| 331 | - $folder =& $this->simplexml_addChild($this->_xml->Document,'GroundOverlay'); | |
| 332 | - //simplexml_addChild($parent, $name, $value='') | |
| 333 | - //$folder->addChild('description', $this->get_layer_description($layer)); | |
| 334 | - $this->simplexml_addChild($folder,'name',$layer_desc); | |
| 335 | - | |
| 336 | - //$folder->addChild('name', $layer_desc); | |
| 337 | - $this->add_wms_link($folder, $layer, $wms_link); | |
| 338 | - } else { | |
| 339 | - // Apply filter | |
| 340 | - if($this->filter){ | |
| 341 | - // Try loading as XML | |
| 342 | - try { | |
| 343 | - $filter = @new SimpleXMLElement($this->filter); | |
| 344 | - list($searchfield, $searchstring) = $this->apply_filter($layer, $filter); | |
| 345 | - if(! ($searchfield && $searchstring)){ | |
| 346 | - $this->set_error('Error parsing filter', $layer_name); | |
| 347 | - return false; | |
| 348 | - } | |
| 349 | - } catch (Exception $e) { | |
| 350 | - $this->set_error('Wrong XML filter', $layer_name); | |
| 351 | - $this->filter = null; | |
| 352 | - return false; | |
| 353 | - } | |
| 354 | - } | |
| 355 | - | |
| 356 | - // Get results | |
| 357 | - if(MS_SUCCESS == $layer->open()){ | |
| 358 | - // Search which column to use to identify the feature | |
| 359 | - $namecol = $layer->getMetadata("itens"); | |
| 360 | - if($namecol == ""){ | |
| 361 | - $cols = array_values($layer->getItems()); | |
| 362 | - $namecol = $cols[0]; | |
| 363 | - } | |
| 364 | - else | |
| 365 | - {$namecol = explode(",",$namecol);$namecol = $namecol[0];} | |
| 366 | - // Add classes | |
| 367 | - $folder =& $this->_xml->Document->addChild('Folder'); | |
| 368 | - | |
| 369 | - $class_list = $this->parse_classes($layer, $folder, $namecol, $title_field, $description_template); | |
| 370 | - | |
| 371 | - //die(print_r($class_list, true)); | |
| 372 | - $folder->addChild('description', $this->get_layer_description($layer)); | |
| 373 | - $folder->addChild('name', $layer_desc); | |
| 374 | - | |
| 375 | - //print("$searchfield && $searchstring"); | |
| 376 | - if(!isset($searchfield)){$searchfield = false;} | |
| 377 | - if(!isset($searchstring)){$searchstring = false;} | |
| 378 | - | |
| 379 | - if($searchfield && $searchstring){ | |
| 380 | - if(@$layer->queryByAttributes($searchfield, $searchstring, MS_MULTIPLE) == MS_SUCCESS){ | |
| 381 | - $layer->open(); | |
| 382 | - //var_dump($layer->getItems()); die(); | |
| 383 | - for ($j=0; $j < $layer->getNumResults(); $j++) | |
| 384 | - { | |
| 385 | - // get next shape row | |
| 300 | + if(!$layer){ | |
| 301 | + $this->set_error('Nenhum layer com esse nome foi encontrado no mapfile ' . $layer_name, $layer_name); | |
| 302 | + return false; | |
| 303 | + } | |
| 304 | + // Add to layer list | |
| 305 | + $this->layers[$layer_name] =& $layer; | |
| 306 | + // Get custom template if any | |
| 307 | + $description_template = $layer->getMetadata('DESCRIPTION_TEMPLATE'); | |
| 308 | + // Set on | |
| 309 | + $layer->set( 'status', MS_DEFAULT ); | |
| 310 | + // Set kml title from layer description (default to layer name) | |
| 311 | + $layer_desc = $this->get_layer_description($layer); | |
| 312 | + | |
| 313 | + // Now switch raster layers | |
| 314 | + //var_dump($layer->type == MS_LAYER_RASTER); | |
| 315 | + if($layer->type == MS_LAYER_RASTER){ | |
| 316 | + // Check if wms_onlineresource metadata is set | |
| 317 | + $wms_link = $this->map_object->getMetadata('wms_onlineresource'); | |
| 318 | + if(!$wms_link){ | |
| 319 | + $wms_link = $this->map_object->getMetadata('ows_onlineresource'); | |
| 320 | + } | |
| 321 | + if(!$wms_link){ | |
| 322 | + $this->set_error('No WMS server available for ' . $layer_name, $layer_name); | |
| 323 | + return false; | |
| 324 | + } | |
| 325 | + // Add parameters to OGC server call | |
| 326 | + // Fix & | |
| 327 | + $wms_link = preg_replace('/&/', '&', $wms_link); | |
| 328 | + $wms_link .= 'VERSION=1.1.1&REQUEST=GetMap&SRS=EPSG:4618&STYLES=&FORMAT=image/jpeg&TRANSPARENT=TRUE&'; | |
| 329 | + // Link ok, create folder | |
| 330 | + //$folder =& $this->_xml->Document->addChild('GroundOverlay'); | |
| 331 | + $folder =& $this->simplexml_addChild($this->_xml->Document,'GroundOverlay'); | |
| 332 | + //simplexml_addChild($parent, $name, $value='') | |
| 333 | + //$folder->addChild('description', $this->get_layer_description($layer)); | |
| 334 | + $this->simplexml_addChild($folder,'name',$layer_desc); | |
| 335 | + | |
| 336 | + //$folder->addChild('name', $layer_desc); | |
| 337 | + $this->add_wms_link($folder, $layer, $wms_link); | |
| 338 | + } else { | |
| 339 | + // Apply filter | |
| 340 | + if($this->filter){ | |
| 341 | + // Try loading as XML | |
| 342 | + try { | |
| 343 | + $filter = @new SimpleXMLElement($this->filter); | |
| 344 | + list($searchfield, $searchstring) = $this->apply_filter($layer, $filter); | |
| 345 | + if(! ($searchfield && $searchstring)){ | |
| 346 | + $this->set_error('Error parsing filter', $layer_name); | |
| 347 | + return false; | |
| 348 | + } | |
| 349 | + } catch (Exception $e) { | |
| 350 | + $this->set_error('Wrong XML filter', $layer_name); | |
| 351 | + $this->filter = null; | |
| 352 | + return false; | |
| 353 | + } | |
| 354 | + } | |
| 355 | + | |
| 356 | + // Get results | |
| 357 | + if(MS_SUCCESS == $layer->open()){ | |
| 358 | + // Search which column to use to identify the feature | |
| 359 | + $namecol = $layer->getMetadata("itens"); | |
| 360 | + if($namecol == ""){ | |
| 361 | + $cols = array_values($layer->getItems()); | |
| 362 | + $namecol = $cols[0]; | |
| 363 | + } | |
| 364 | + else | |
| 365 | + {$namecol = explode(",",$namecol);$namecol = $namecol[0];} | |
| 366 | + // Add classes | |
| 367 | + $folder =& $this->_xml->Document->addChild('Folder'); | |
| 368 | + | |
| 369 | + $class_list = $this->parse_classes($layer, $folder, $namecol, $title_field, $description_template); | |
| 370 | + | |
| 371 | + //die(print_r($class_list, true)); | |
| 372 | + $folder->addChild('description', $this->get_layer_description($layer)); | |
| 373 | + $folder->addChild('name', $layer_desc); | |
| 374 | + | |
| 375 | + //print("$searchfield && $searchstring"); | |
| 376 | + if(!isset($searchfield)){$searchfield = false;} | |
| 377 | + if(!isset($searchstring)){$searchstring = false;} | |
| 378 | + | |
| 379 | + if($searchfield && $searchstring){ | |
| 380 | + if(@$layer->queryByAttributes($searchfield, $searchstring, MS_MULTIPLE) == MS_SUCCESS){ | |
| 381 | + $layer->open(); | |
| 382 | + //var_dump($layer->getItems()); die(); | |
| 383 | + for ($j=0; $j < $layer->getNumResults(); $j++) | |
| 384 | + { | |
| 385 | + // get next shape row | |
| 386 | 386 | if($versao == 6) |
| 387 | 387 | {$shape = $layer->getShape($layer->getResult($j));} |
| 388 | 388 | else{ |
| 389 | 389 | $result = $layer->getResult($j); |
| 390 | 390 | $shape = $layer->getFeature($result->shapeindex,$result->tileindex); |
| 391 | 391 | } |
| 392 | - $this->process_shape($layer, $shape, $class_list, $folder, $namecol); | |
| 393 | - // end for loop | |
| 394 | - } | |
| 395 | - } else { | |
| 396 | - $this->set_error('Query returned no data', $layer_name); | |
| 397 | - return false; | |
| 398 | - } | |
| 399 | - } else { // Get all shapes | |
| 400 | - $layer->set("template","none.htm"); | |
| 401 | - $layer->queryByrect($this->map_object->extent); | |
| 402 | - $layer->open(); | |
| 403 | - $n = $layer->getNumResults(); | |
| 404 | - for ($j=0; $j < $n; $j++) | |
| 405 | - { | |
| 406 | - // get next shape row | |
| 392 | + $this->process_shape($layer, $shape, $class_list, $folder, $namecol); | |
| 393 | + // end for loop | |
| 394 | + } | |
| 395 | + } else { | |
| 396 | + $this->set_error('Query returned no data', $layer_name); | |
| 397 | + return false; | |
| 398 | + } | |
| 399 | + } else { // Get all shapes | |
| 400 | + $layer->set("template","none.htm"); | |
| 401 | + $layer->queryByrect($this->map_object->extent); | |
| 402 | + $layer->open(); | |
| 403 | + $n = $layer->getNumResults(); | |
| 404 | + for ($j=0; $j < $n; $j++) | |
| 405 | + { | |
| 406 | + // get next shape row | |
| 407 | 407 | if($versao == 6) |
| 408 | 408 | { |
| 409 | 409 | $result = $layer->getResult($j); |
| ... | ... | @@ -414,465 +414,465 @@ class LayerServer { |
| 414 | 414 | $shape = $layer->getFeature($result->shapeindex,$result->tileindex); |
| 415 | 415 | } |
| 416 | 416 | $shape->classindex = $result->classindex; |
| 417 | - $this->process_shape($layer, $shape, $class_list, $folder, $namecol); | |
| 418 | - } | |
| 419 | - if($n == 0) { | |
| 420 | - $this->set_error('QueryByRect returned no data', $layer_name); | |
| 421 | - return false; | |
| 422 | - } | |
| 423 | - } | |
| 424 | - $layer->close(); | |
| 425 | - } else { | |
| 426 | - $this->set_error('Layer cannot be opened', $layer_name); | |
| 427 | - return false; | |
| 428 | - } | |
| 429 | - } | |
| 430 | - return true; | |
| 431 | - } | |
| 432 | - | |
| 433 | - /** | |
| 434 | - * Process the shape | |
| 435 | - */ | |
| 436 | - function process_shape(&$layer, &$shape, &$class_list, &$folder, &$namecol){ | |
| 417 | + $this->process_shape($layer, $shape, $class_list, $folder, $namecol); | |
| 418 | + } | |
| 419 | + if($n == 0) { | |
| 420 | + $this->set_error('QueryByRect returned no data', $layer_name); | |
| 421 | + return false; | |
| 422 | + } | |
| 423 | + } | |
| 424 | + $layer->close(); | |
| 425 | + } else { | |
| 426 | + $this->set_error('Layer cannot be opened', $layer_name); | |
| 427 | + return false; | |
| 428 | + } | |
| 429 | + } | |
| 430 | + return true; | |
| 431 | + } | |
| 432 | + | |
| 433 | + /** | |
| 434 | + * Process the shape | |
| 435 | + */ | |
| 436 | + function process_shape(&$layer, &$shape, &$class_list, &$folder, &$namecol){ | |
| 437 | 437 | $permite = $layer->getmetadata("permitekmz"); |
| 438 | 438 | if($permite == "nao"){return;} |
| 439 | - $itens = $layer->getmetadata("itens"); | |
| 439 | + $itens = $layer->getmetadata("itens"); | |
| 440 | 440 | $itensdesc = $layer->getmetadata("itensdesc"); |
| 441 | - $shape->project($this->in_proj, $this->out_proj); | |
| 442 | - // Assign style | |
| 443 | - if($layer->classitem){ | |
| 444 | - //$style_id = $this->get_shape_class($layer->classitem, $shape->values, $class_list); | |
| 445 | - } | |
| 446 | - if(!isset($style_id)){ | |
| 447 | - // Get first class | |
| 448 | - $class_keys = array_keys($class_list); | |
| 441 | + $shape->project($this->in_proj, $this->out_proj); | |
| 442 | + // Assign style | |
| 443 | + if($layer->classitem){ | |
| 444 | + //$style_id = $this->get_shape_class($layer->classitem, $shape->values, $class_list); | |
| 445 | + } | |
| 446 | + if(!isset($style_id)){ | |
| 447 | + // Get first class | |
| 448 | + $class_keys = array_keys($class_list); | |
| 449 | 449 | $indice = $shape->classindex; |
| 450 | - $classe = $layer->getclass($indice); | |
| 451 | - $nome= $classe->name; | |
| 452 | - $style_id = preg_replace('/[^A-z0-9]/', '_', $layer->name . $nome); | |
| 453 | - } | |
| 454 | - // Add the feature | |
| 455 | - if(array_key_exists('folder', $class_list[$style_id])) { | |
| 456 | - $feature_folder =& $class_list[$style_id]['folder']; | |
| 457 | - } else { | |
| 458 | - //die('missing folder for ' . $style_id); | |
| 459 | - $feature_folder =& $folder; | |
| 460 | - } | |
| 461 | - if(!is_object($feature_folder)){ | |
| 462 | - $folder_name = $feature_folder; | |
| 463 | - $feature_folder =& $folder ->addChild('Folder'); | |
| 464 | - $feature_folder->addChild('name', $folder_name); | |
| 465 | - } | |
| 466 | - // Add style class | |
| 467 | - $style_url =& $this->add_style($layer, $feature_folder, $style_id, $class_list[$style_id], $namecol, $shape->values); | |
| 468 | - $wkt = $shape->toWkt(); | |
| 469 | - $description_template = $layer->getMetadata('DESCRIPTION_TEMPLATE');//false; | |
| 470 | - if($description_template == "") | |
| 471 | - {$description_template = false;} | |
| 472 | - $placemark =& $this->add_feature($feature_folder, $wkt, $shape->values[$namecol], $shape->values, $description_template, $class_list[$style_id],$itens,$itensdesc); | |
| 473 | - | |
| 474 | - $placemark->addChild('styleUrl', '#'. $style_url); | |
| 475 | - | |
| 476 | - } | |
| 477 | - /** | |
| 478 | - * Add the feature to the result set | |
| 479 | - * @return reference to placemark object | |
| 480 | - */ | |
| 481 | - function &add_feature(&$folder, &$wkt, $featurename, $attributes, $description_template, $style_data,$itens,$itensdesc){ | |
| 482 | - $pm = $folder->addChild('Placemark'); | |
| 483 | - $fname = mb_convert_encoding($featurename,"UTF-8",mb_detect_encoding($featurename,'UTF-8, UTF-7, ASCII, ISO-8859-1')); | |
| 484 | - $pm->addChild('name',$fname); | |
| 485 | - $pm->addChild('description', $this->get_feature_description($fname, $attributes, $description_template,$itens,$itensdesc)); | |
| 486 | - // Now parse the wkt | |
| 487 | - if(strpos($wkt, 'MULTILINESTRING') !== false){ | |
| 488 | - $this->add_multilinestring($wkt, $pm, $featurename, $style_data['icon']); | |
| 489 | - } elseif(strpos($wkt, 'LINESTRING') !== false){ | |
| 490 | - $this->add_linestring($wkt, $pm, $featurename, $style_data['icon']); | |
| 491 | - } elseif(strpos($wkt, 'POINT') !== false){ | |
| 492 | - $this->add_point($wkt, $pm, $featurename); | |
| 493 | - } elseif(strpos($wkt, 'MULTIPOLYGON') !== false){ | |
| 494 | - if(TREAT_POLY_AS_LINE){ | |
| 495 | - $ml = $pm->addChild('MultiGeometry'); | |
| 496 | - foreach(split('\), \(', $wkt) as $line){ | |
| 497 | - $this->add_multilinestring($line, $ml, $featurename ); | |
| 498 | - } | |
| 499 | - } else { | |
| 500 | - $this->add_multipolygon($wkt, $pm, $featurename); | |
| 501 | - } | |
| 502 | - } elseif(strpos($wkt, 'POLYGON') !== false){ | |
| 503 | - if(TREAT_POLY_AS_LINE){ | |
| 504 | - $this->add_multilinestring($wkt, $pm, $featurename); | |
| 505 | - } else { | |
| 506 | - $this->add_polygon($wkt, $pm, $featurename); | |
| 507 | - } | |
| 508 | - } else { | |
| 509 | - // Error? | |
| 510 | - } | |
| 511 | - return $pm; | |
| 512 | - } | |
| 513 | - | |
| 514 | - /** | |
| 515 | - * Add a linestring | |
| 516 | - */ | |
| 517 | - function add_linestring(&$wkt, &$element, $featurename, $add_points){ | |
| 518 | - preg_match('/(\d+[^\(\)]*\d)/', $wkt, $data); | |
| 519 | - $data = str_replace(', ', '#', $data[1]); | |
| 520 | - $data = str_replace(' ', ',', $data); | |
| 521 | - $data = str_replace('#', ' ', $data); | |
| 522 | - if($add_points){ | |
| 523 | - preg_match('/^(\d+\.\d+,\d+\.\d+).*(\d+\.\d+,\d+\.\d+)$/', $data, $points); | |
| 524 | - if(count($points) == 3){ | |
| 525 | - $mg = $element->addChild('MultiGeometry'); | |
| 526 | - $ls = $mg->addChild('LineString'); | |
| 527 | - $pt1 = $mg->addChild('Point'); | |
| 528 | - $pt1->addChild('coordinates', $points[1]); | |
| 529 | - $pt2 = $mg->addChild('Point'); | |
| 530 | - $pt2->addChild('coordinates', $points[2]); | |
| 531 | - } else { | |
| 532 | - die('errore'); | |
| 533 | - $ls = $element->addChild('LineString'); | |
| 534 | - } | |
| 535 | - //print_r($points);die(); | |
| 536 | - } else { | |
| 537 | - $ls = $element->addChild('LineString'); | |
| 538 | - } | |
| 539 | - $ls->addChild('coordinates', $data); | |
| 540 | - } | |
| 541 | - | |
| 542 | - /** | |
| 543 | - * Add a multilinestring | |
| 544 | - */ | |
| 545 | - function add_multilinestring(&$wkt, &$element, $featurename, $add_points){ | |
| 546 | - $ml = $element->addChild('MultiGeometry'); | |
| 547 | - foreach(split('\), \(', $wkt) as $line){ | |
| 548 | - $this->add_linestring($line, $ml, $featurename, $add_points ); | |
| 549 | - } | |
| 550 | - } | |
| 551 | - | |
| 552 | - /** | |
| 553 | - * Add a point | |
| 554 | - */ | |
| 555 | - function add_point(&$wkt, &$element, $featurename){ | |
| 556 | - $pt = $element->addChild('Point'); | |
| 557 | - /* | |
| 558 | - preg_match('/(\d\.?\d+\s\d+\.?\d+)/', $wkt, $data); | |
| 559 | - //var_dump($data);exit; | |
| 560 | - $data = str_replace(' ', ',', $data[1]); | |
| 561 | - */ | |
| 562 | - $data = str_replace("(","",$wkt); | |
| 563 | - $data = str_replace(")","",$data); | |
| 564 | - $data = str_replace("POINT","",$data); | |
| 565 | - $data = str_replace(" ",",",trim($data)); | |
| 566 | - //echo $data;exit; | |
| 567 | - $pt->addChild('coordinates', $data); | |
| 568 | - } | |
| 569 | - | |
| 570 | - | |
| 571 | - /** | |
| 572 | - * Add a polygon | |
| 573 | - */ | |
| 574 | - function add_polygon(&$wkt, &$element, $featurename){ | |
| 575 | - $ml = $element->addChild('Polygon'); | |
| 576 | - foreach(split('\), \(', $wkt) as $line){ | |
| 577 | - preg_match('/(\d+[^\(\)]*\d)/', $wkt, $data); | |
| 578 | - $data = str_replace(', ', '#', $data[1]); | |
| 579 | - $data = str_replace(' ', ',', $data); | |
| 580 | - // Add 1 meter height | |
| 581 | - $data = str_replace('#', ',1 ', $data) . ',1'; | |
| 582 | - $ml->addChild('tessellate', 1); | |
| 583 | - //$element->addChild('altitudeMode', 'relativeToGround'); | |
| 584 | - $element->addChild('altitudeMode', 'clampToGround'); | |
| 585 | - $ob = $ml->addChild('outerBoundaryIs'); | |
| 586 | - $ls = $ob->addChild('LinearRing'); | |
| 587 | - $ls->addChild('coordinates', $data); | |
| 588 | - } | |
| 589 | - } | |
| 590 | - | |
| 591 | - | |
| 592 | - /** | |
| 593 | - * Add a multipolygon | |
| 594 | - * fixme: untested, should take holes into account | |
| 595 | - */ | |
| 596 | - function add_multipolygon(&$wkt, &$element, $featurename){ | |
| 597 | - $ml = $element->addChild('MultiGeometry'); | |
| 598 | - foreach(split('\), \(', $wkt) as $line){ | |
| 599 | - $this->add_polygon($line, $ml, $featurename ); | |
| 600 | - } | |
| 601 | - } | |
| 602 | - | |
| 603 | - | |
| 604 | - /** | |
| 605 | - * Get the feature description | |
| 606 | - */ | |
| 607 | - function get_feature_description($featurename, $attributes, $description_template,$itens,$itensdesc){ | |
| 608 | - // Compute hyperlink | |
| 609 | - //var_dump($attributes);exit; | |
| 610 | - //if($description_template != ""){return $description_template;} | |
| 611 | - $n = ""; | |
| 612 | - if($description_template != "") | |
| 613 | - { | |
| 614 | - foreach($attributes as $k => $val) | |
| 615 | - {$description_template = str_replace("%".$k."%",$attributes[$k],$description_template);} | |
| 616 | - $n = $description_template; | |
| 617 | - } | |
| 450 | + $classe = $layer->getclass($indice); | |
| 451 | + $nome= $classe->name; | |
| 452 | + $style_id = preg_replace('/[^A-z0-9]/', '_', $layer->name . $nome); | |
| 453 | + } | |
| 454 | + // Add the feature | |
| 455 | + if(array_key_exists('folder', $class_list[$style_id])) { | |
| 456 | + $feature_folder =& $class_list[$style_id]['folder']; | |
| 457 | + } else { | |
| 458 | + //die('missing folder for ' . $style_id); | |
| 459 | + $feature_folder =& $folder; | |
| 460 | + } | |
| 461 | + if(!is_object($feature_folder)){ | |
| 462 | + $folder_name = $feature_folder; | |
| 463 | + $feature_folder =& $folder ->addChild('Folder'); | |
| 464 | + $feature_folder->addChild('name', $folder_name); | |
| 465 | + } | |
| 466 | + // Add style class | |
| 467 | + $style_url =& $this->add_style($layer, $feature_folder, $style_id, $class_list[$style_id], $namecol, $shape->values); | |
| 468 | + $wkt = $shape->toWkt(); | |
| 469 | + $description_template = $layer->getMetadata('DESCRIPTION_TEMPLATE');//false; | |
| 470 | + if($description_template == "") | |
| 471 | + {$description_template = false;} | |
| 472 | + $placemark =& $this->add_feature($feature_folder, $wkt, $shape->values[$namecol], $shape->values, $description_template, $class_list[$style_id],$itens,$itensdesc); | |
| 473 | + | |
| 474 | + $placemark->addChild('styleUrl', '#'. $style_url); | |
| 475 | + | |
| 476 | + } | |
| 477 | + /** | |
| 478 | + * Add the feature to the result set | |
| 479 | + * @return reference to placemark object | |
| 480 | + */ | |
| 481 | + function &add_feature(&$folder, &$wkt, $featurename, $attributes, $description_template, $style_data,$itens,$itensdesc){ | |
| 482 | + $pm = $folder->addChild('Placemark'); | |
| 483 | + $fname = mb_convert_encoding($featurename,"UTF-8",mb_detect_encoding($featurename,'UTF-8, UTF-7, ASCII, ISO-8859-1')); | |
| 484 | + $pm->addChild('name',$fname); | |
| 485 | + $pm->addChild('description', $this->get_feature_description($fname, $attributes, $description_template,$itens,$itensdesc)); | |
| 486 | + // Now parse the wkt | |
| 487 | + if(strpos($wkt, 'MULTILINESTRING') !== false){ | |
| 488 | + $this->add_multilinestring($wkt, $pm, $featurename, $style_data['icon']); | |
| 489 | + } elseif(strpos($wkt, 'LINESTRING') !== false){ | |
| 490 | + $this->add_linestring($wkt, $pm, $featurename, $style_data['icon']); | |
| 491 | + } elseif(strpos($wkt, 'POINT') !== false){ | |
| 492 | + $this->add_point($wkt, $pm, $featurename); | |
| 493 | + } elseif(strpos($wkt, 'MULTIPOLYGON') !== false){ | |
| 494 | + if(TREAT_POLY_AS_LINE){ | |
| 495 | + $ml = $pm->addChild('MultiGeometry'); | |
| 496 | + foreach(split('\), \(', $wkt) as $line){ | |
| 497 | + $this->add_multilinestring($line, $ml, $featurename ); | |
| 498 | + } | |
| 499 | + } else { | |
| 500 | + $this->add_multipolygon($wkt, $pm, $featurename); | |
| 501 | + } | |
| 502 | + } elseif(strpos($wkt, 'POLYGON') !== false){ | |
| 503 | + if(TREAT_POLY_AS_LINE){ | |
| 504 | + $this->add_multilinestring($wkt, $pm, $featurename); | |
| 505 | + } else { | |
| 506 | + $this->add_polygon($wkt, $pm, $featurename); | |
| 507 | + } | |
| 508 | + } else { | |
| 509 | + // Error? | |
| 510 | + } | |
| 511 | + return $pm; | |
| 512 | + } | |
| 513 | + | |
| 514 | + /** | |
| 515 | + * Add a linestring | |
| 516 | + */ | |
| 517 | + function add_linestring(&$wkt, &$element, $featurename, $add_points){ | |
| 518 | + preg_match('/(\d+[^\(\)]*\d)/', $wkt, $data); | |
| 519 | + $data = str_replace(', ', '#', $data[1]); | |
| 520 | + $data = str_replace(' ', ',', $data); | |
| 521 | + $data = str_replace('#', ' ', $data); | |
| 522 | + if($add_points){ | |
| 523 | + preg_match('/^(\d+\.\d+,\d+\.\d+).*(\d+\.\d+,\d+\.\d+)$/', $data, $points); | |
| 524 | + if(count($points) == 3){ | |
| 525 | + $mg = $element->addChild('MultiGeometry'); | |
| 526 | + $ls = $mg->addChild('LineString'); | |
| 527 | + $pt1 = $mg->addChild('Point'); | |
| 528 | + $pt1->addChild('coordinates', $points[1]); | |
| 529 | + $pt2 = $mg->addChild('Point'); | |
| 530 | + $pt2->addChild('coordinates', $points[2]); | |
| 531 | + } else { | |
| 532 | + die('errore'); | |
| 533 | + $ls = $element->addChild('LineString'); | |
| 534 | + } | |
| 535 | + //print_r($points);die(); | |
| 536 | + } else { | |
| 537 | + $ls = $element->addChild('LineString'); | |
| 538 | + } | |
| 539 | + $ls->addChild('coordinates', $data); | |
| 540 | + } | |
| 541 | + | |
| 542 | + /** | |
| 543 | + * Add a multilinestring | |
| 544 | + */ | |
| 545 | + function add_multilinestring(&$wkt, &$element, $featurename, $add_points){ | |
| 546 | + $ml = $element->addChild('MultiGeometry'); | |
| 547 | + foreach(split('\), \(', $wkt) as $line){ | |
| 548 | + $this->add_linestring($line, $ml, $featurename, $add_points ); | |
| 549 | + } | |
| 550 | + } | |
| 551 | + | |
| 552 | + /** | |
| 553 | + * Add a point | |
| 554 | + */ | |
| 555 | + function add_point(&$wkt, &$element, $featurename){ | |
| 556 | + $pt = $element->addChild('Point'); | |
| 557 | + /* | |
| 558 | + preg_match('/(\d\.?\d+\s\d+\.?\d+)/', $wkt, $data); | |
| 559 | + //var_dump($data);exit; | |
| 560 | + $data = str_replace(' ', ',', $data[1]); | |
| 561 | + */ | |
| 562 | + $data = str_replace("(","",$wkt); | |
| 563 | + $data = str_replace(")","",$data); | |
| 564 | + $data = str_replace("POINT","",$data); | |
| 565 | + $data = str_replace(" ",",",trim($data)); | |
| 566 | + //echo $data;exit; | |
| 567 | + $pt->addChild('coordinates', $data); | |
| 568 | + } | |
| 569 | + | |
| 570 | + | |
| 571 | + /** | |
| 572 | + * Add a polygon | |
| 573 | + */ | |
| 574 | + function add_polygon(&$wkt, &$element, $featurename){ | |
| 575 | + $ml = $element->addChild('Polygon'); | |
| 576 | + foreach(split('\), \(', $wkt) as $line){ | |
| 577 | + preg_match('/(\d+[^\(\)]*\d)/', $wkt, $data); | |
| 578 | + $data = str_replace(', ', '#', $data[1]); | |
| 579 | + $data = str_replace(' ', ',', $data); | |
| 580 | + // Add 1 meter height | |
| 581 | + $data = str_replace('#', ',1 ', $data) . ',1'; | |
| 582 | + $ml->addChild('tessellate', 1); | |
| 583 | + //$element->addChild('altitudeMode', 'relativeToGround'); | |
| 584 | + $element->addChild('altitudeMode', 'clampToGround'); | |
| 585 | + $ob = $ml->addChild('outerBoundaryIs'); | |
| 586 | + $ls = $ob->addChild('LinearRing'); | |
| 587 | + $ls->addChild('coordinates', $data); | |
| 588 | + } | |
| 589 | + } | |
| 590 | + | |
| 591 | + | |
| 592 | + /** | |
| 593 | + * Add a multipolygon | |
| 594 | + * fixme: untested, should take holes into account | |
| 595 | + */ | |
| 596 | + function add_multipolygon(&$wkt, &$element, $featurename){ | |
| 597 | + $ml = $element->addChild('MultiGeometry'); | |
| 598 | + foreach(split('\), \(', $wkt) as $line){ | |
| 599 | + $this->add_polygon($line, $ml, $featurename ); | |
| 600 | + } | |
| 601 | + } | |
| 602 | + | |
| 603 | + | |
| 604 | + /** | |
| 605 | + * Get the feature description | |
| 606 | + */ | |
| 607 | + function get_feature_description($featurename, $attributes, $description_template,$itens,$itensdesc){ | |
| 608 | + // Compute hyperlink | |
| 609 | + //var_dump($attributes);exit; | |
| 610 | + //if($description_template != ""){return $description_template;} | |
| 611 | + $n = ""; | |
| 612 | + if($description_template != "") | |
| 613 | + { | |
| 614 | + foreach($attributes as $k => $val) | |
| 615 | + {$description_template = str_replace("%".$k."%",$attributes[$k],$description_template);} | |
| 616 | + $n = $description_template; | |
| 617 | + } | |
| 618 | 618 | else |
| 619 | 619 | { |
| 620 | - if($itens == "") | |
| 621 | - { | |
| 622 | - foreach($attributes as $k => $val){ | |
| 623 | - $n .= $k." - ".$attributes[$k]."\n"; | |
| 624 | - } | |
| 625 | - } | |
| 626 | - else | |
| 627 | - { | |
| 628 | - $itens = explode(",",$itens); | |
| 629 | - $itensdesc = explode(",",$itensdesc); | |
| 630 | - for($i=0;$i<count($itens);$i++) | |
| 631 | - {$n .= $itensdesc[$i]." - ".$attributes[$itens[$i]]."\n";} | |
| 632 | - } | |
| 620 | + if($itens == "") | |
| 621 | + { | |
| 622 | + foreach($attributes as $k => $val){ | |
| 623 | + $n .= $k." - ".$attributes[$k]."\n"; | |
| 624 | + } | |
| 625 | + } | |
| 626 | + else | |
| 627 | + { | |
| 628 | + $itens = explode(",",$itens); | |
| 629 | + $itensdesc = explode(",",$itensdesc); | |
| 630 | + for($i=0;$i<count($itens);$i++) | |
| 631 | + {$n .= $itensdesc[$i]." - ".$attributes[$itens[$i]]."\n";} | |
| 632 | + } | |
| 633 | 633 | } |
| 634 | - $description = mb_convert_encoding($n,"UTF-8",mb_detect_encoding($n,"UTF-8,ISO-8859-1")); | |
| 634 | + $description = mb_convert_encoding($n,"UTF-8",mb_detect_encoding($n,"UTF-8,ISO-8859-1")); | |
| 635 | 635 | return $description; |
| 636 | - } | |
| 637 | - /** | |
| 638 | - * Parse classes | |
| 639 | - * @return array hash of 'style_id' => style_data) | |
| 640 | - */ | |
| 641 | - function parse_classes(&$layer, &$folder, &$namecol, &$title_field, &$description_template ){ | |
| 642 | - $style_ar = array(); | |
| 643 | - $numclasses = $layer->numclasses; | |
| 644 | - $versao = $this->versao(); | |
| 645 | - $vi = $versao["inteiro"]; | |
| 646 | - for($i = 0; $i < $numclasses; $i++){ | |
| 647 | - $class = $layer->getClass($i); | |
| 648 | - if($vi >= 60200){ | |
| 636 | + } | |
| 637 | + /** | |
| 638 | + * Parse classes | |
| 639 | + * @return array hash of 'style_id' => style_data) | |
| 640 | + */ | |
| 641 | + function parse_classes(&$layer, &$folder, &$namecol, &$title_field, &$description_template ){ | |
| 642 | + $style_ar = array(); | |
| 643 | + $numclasses = $layer->numclasses; | |
| 644 | + $versao = $this->versao(); | |
| 645 | + $vi = $versao["inteiro"]; | |
| 646 | + for($i = 0; $i < $numclasses; $i++){ | |
| 647 | + $class = $layer->getClass($i); | |
| 648 | + if($vi >= 60200){ | |
| 649 | 649 | if($class->numlabels > 0) |
| 650 | - $label = $class->getLabel(0); | |
| 651 | - } | |
| 652 | - else{ | |
| 653 | - $label = $class->label; | |
| 654 | - } | |
| 655 | - if($label){ | |
| 656 | - $style['label_color'] = $label->color; | |
| 657 | - $style['label_size'] = $label->size; | |
| 658 | - } | |
| 659 | - // Get styles | |
| 660 | - for($j = 0; $j < $class->numstyles; $j++){ | |
| 661 | - $_style = $class->getStyle($j); | |
| 662 | - $style['color'] = $_style->color; | |
| 663 | - $style['outlinecolor'] = $_style->outlinecolor; | |
| 664 | - $style['width'] = $_style->size; // Lines | |
| 665 | - $style['backgroundcolor'] = $_style->backgroundcolor; | |
| 666 | - if($layer->type == MS_LAYER_POINT) | |
| 667 | - $style['icon'] = $this->get_icon_url($layer, $class->name,$i); | |
| 668 | - $style['icon_width'] = $_style->size; // Points | |
| 669 | - } | |
| 670 | - $style['expression'] = $class->getExpressionString(); | |
| 671 | - // Set description_template if any | |
| 672 | - $style['description_template'] = $description_template; | |
| 673 | - // Get icon for lines if any | |
| 674 | - if($icon = $layer->getMetadata('KML_ADD_POINT')){ | |
| 675 | - $style['icon'] = $icon; | |
| 676 | - $style['icon_width'] = 32; | |
| 677 | - } | |
| 678 | - // Create style element | |
| 679 | - $style_id = preg_replace('/[^A-z0-9]/', '_', $layer->name . $class->name); | |
| 680 | - $this->add_style($layer, $folder, $style_id, $style, $namecol, $title_field ); | |
| 681 | - // create folder if more than one class | |
| 682 | - if($numclasses > 1){ | |
| 683 | - //$style['folder'] =& $class->name; | |
| 684 | - //$folder->addChild('Folder'); | |
| 685 | - //$style['folder']->addChild('name', $class->name); | |
| 686 | - } | |
| 687 | - $style_ar[$style_id] = $style; | |
| 688 | - } | |
| 689 | - return $style_ar; | |
| 690 | - } | |
| 691 | - | |
| 692 | - /** | |
| 693 | - * Return a CSV list of all layer names in the mapfile | |
| 694 | - * fixme: filter out ANNOTATIONS and other "strange" layers | |
| 695 | - */ | |
| 696 | - function get_layer_list(){ | |
| 697 | - $layer_list = array(); | |
| 698 | - for($i = 0; $i < $this->map_object->numlayers; $i++){ | |
| 699 | - $layer =& $this->map_object->getLayer($i); | |
| 700 | - $kml_skip = $layer->getMetadata('KML_SKIP'); | |
| 701 | - if(strtolower($kml_skip) !== 'true'){ | |
| 702 | - $layer_list[] = $layer->name; | |
| 703 | - } | |
| 704 | - } | |
| 705 | - return join(',', $layer_list); | |
| 706 | - } | |
| 707 | - | |
| 708 | - | |
| 709 | - /** | |
| 710 | - * Return the class for the shape, default to last class if not match | |
| 711 | - */ | |
| 712 | - function get_shape_class(&$classitem, &$values, &$class_list){ | |
| 713 | - //var_dump($class_list); die(); | |
| 714 | - foreach($class_list as $style_id => $style_data){ | |
| 715 | - if($style_data['expression'] && preg_match($style_data['expression'], $values[$classitem])){ | |
| 716 | - //print "get_shape_class($classitem) ".$values[$classitem]." matches<br>"; | |
| 717 | - return $style_id; | |
| 718 | - } | |
| 719 | - } | |
| 720 | - //print "get_shape_class($classitem) ".$values[$classitem]." no matches<br>"; | |
| 721 | - return $style_id; | |
| 722 | - } | |
| 723 | - | |
| 724 | - /** | |
| 725 | - * Add the style | |
| 726 | - * @return the style URL | |
| 727 | - */ | |
| 728 | - function add_style(&$layer, &$folder, $style_id, &$style_data){ | |
| 729 | - // Calculare style URL | |
| 730 | - | |
| 731 | - if($style_data['description_template']){ | |
| 732 | - $this->style_counter++; | |
| 733 | - $style_id .= '_'.$this->style_counter; | |
| 734 | - $balloon_data = $this->get_feature_description($attributes[$namecol], $attributes, $style_data['description_template']); | |
| 735 | - } | |
| 736 | - | |
| 737 | - // Check if the style already exists | |
| 738 | - $expr = '//*[@id=\''.$style_id.'\']'; | |
| 739 | - if($folder->xpath($expr)) { | |
| 740 | - return $style_id; | |
| 741 | - } | |
| 742 | - $new_style =& $folder->addChild('Style'); | |
| 743 | - $new_style['id'] = $style_id; | |
| 744 | - // Switch layer type | |
| 745 | - switch($layer->type){ | |
| 746 | - case MS_LAYER_POINT: | |
| 747 | - $this->add_style_point($new_style, $style_data); | |
| 748 | - break; | |
| 749 | - case MS_LAYER_POLYGON: | |
| 750 | - $this->add_style_polygon($new_style, $style_data); | |
| 751 | - break; | |
| 752 | - case MS_LAYER_LINE: | |
| 753 | - $this->add_style_line($new_style, $style_data); | |
| 754 | - // Add KML_ADD_POINT icon | |
| 755 | - if($style_data['icon']){ | |
| 756 | - $this->add_style_point($new_style, $style_data); | |
| 757 | - } | |
| 758 | - break; | |
| 759 | - } | |
| 760 | - return $style_id; | |
| 761 | - } | |
| 762 | - | |
| 763 | - /** | |
| 764 | - * Add style for lines | |
| 765 | - */ | |
| 766 | - function add_style_line(&$new_style, &$style_data){ | |
| 767 | - if($style_data['outlinecolor']->red != -1){ | |
| 768 | - $st =& $new_style->addChild('LineStyle'); | |
| 769 | - $st->addChild('color', sprintf('FF%02X%02X%02X', $style_data['outlinecolor']->blue, $style_data['outlinecolor']->green, $style_data['outlinecolor']->red)); | |
| 770 | - if($width) { | |
| 771 | - $st->addChild('width', $width); | |
| 772 | - } | |
| 773 | - } elseif($style_data['color']->red != -1){ | |
| 774 | - $st =& $new_style->addChild('LineStyle'); | |
| 775 | - $st->addChild('color', sprintf('FF%02X%02X%02X', $style_data['color']->blue, $style_data['color']->green, $style_data['color']->red)); | |
| 776 | - if($width) { | |
| 777 | - $st->addChild('width', $width); | |
| 778 | - } | |
| 779 | - } | |
| 780 | - } | |
| 781 | - | |
| 782 | - /** | |
| 783 | - * Add style for points | |
| 784 | - */ | |
| 785 | - function add_style_point(&$new_style, &$style_data){ | |
| 786 | - if($style_data['icon']){ | |
| 787 | - $st =& $new_style->addChild('IconStyle'); | |
| 650 | + $label = $class->getLabel(0); | |
| 651 | + } | |
| 652 | + else{ | |
| 653 | + $label = $class->label; | |
| 654 | + } | |
| 655 | + if($label){ | |
| 656 | + $style['label_color'] = $label->color; | |
| 657 | + $style['label_size'] = $label->size; | |
| 658 | + } | |
| 659 | + // Get styles | |
| 660 | + for($j = 0; $j < $class->numstyles; $j++){ | |
| 661 | + $_style = $class->getStyle($j); | |
| 662 | + $style['color'] = $_style->color; | |
| 663 | + $style['outlinecolor'] = $_style->outlinecolor; | |
| 664 | + $style['width'] = $_style->size; // Lines | |
| 665 | + $style['backgroundcolor'] = $_style->backgroundcolor; | |
| 666 | + if($layer->type == MS_LAYER_POINT) | |
| 667 | + $style['icon'] = $this->get_icon_url($layer, $class->name,$i); | |
| 668 | + $style['icon_width'] = $_style->size; // Points | |
| 669 | + } | |
| 670 | + $style['expression'] = $class->getExpressionString(); | |
| 671 | + // Set description_template if any | |
| 672 | + $style['description_template'] = $description_template; | |
| 673 | + // Get icon for lines if any | |
| 674 | + if($icon = $layer->getMetadata('KML_ADD_POINT')){ | |
| 675 | + $style['icon'] = $icon; | |
| 676 | + $style['icon_width'] = 32; | |
| 677 | + } | |
| 678 | + // Create style element | |
| 679 | + $style_id = preg_replace('/[^A-z0-9]/', '_', $layer->name . $class->name); | |
| 680 | + $this->add_style($layer, $folder, $style_id, $style, $namecol, $title_field ); | |
| 681 | + // create folder if more than one class | |
| 682 | + if($numclasses > 1){ | |
| 683 | + //$style['folder'] =& $class->name; | |
| 684 | + //$folder->addChild('Folder'); | |
| 685 | + //$style['folder']->addChild('name', $class->name); | |
| 686 | + } | |
| 687 | + $style_ar[$style_id] = $style; | |
| 688 | + } | |
| 689 | + return $style_ar; | |
| 690 | + } | |
| 691 | + | |
| 692 | + /** | |
| 693 | + * Return a CSV list of all layer names in the mapfile | |
| 694 | + * fixme: filter out ANNOTATIONS and other "strange" layers | |
| 695 | + */ | |
| 696 | + function get_layer_list(){ | |
| 697 | + $layer_list = array(); | |
| 698 | + for($i = 0; $i < $this->map_object->numlayers; $i++){ | |
| 699 | + $layer =& $this->map_object->getLayer($i); | |
| 700 | + $kml_skip = $layer->getMetadata('KML_SKIP'); | |
| 701 | + if(strtolower($kml_skip) !== 'true'){ | |
| 702 | + $layer_list[] = $layer->name; | |
| 703 | + } | |
| 704 | + } | |
| 705 | + return join(',', $layer_list); | |
| 706 | + } | |
| 707 | + | |
| 708 | + | |
| 709 | + /** | |
| 710 | + * Return the class for the shape, default to last class if not match | |
| 711 | + */ | |
| 712 | + function get_shape_class(&$classitem, &$values, &$class_list){ | |
| 713 | + //var_dump($class_list); die(); | |
| 714 | + foreach($class_list as $style_id => $style_data){ | |
| 715 | + if($style_data['expression'] && preg_match($style_data['expression'], $values[$classitem])){ | |
| 716 | + //print "get_shape_class($classitem) ".$values[$classitem]." matches<br>"; | |
| 717 | + return $style_id; | |
| 718 | + } | |
| 719 | + } | |
| 720 | + //print "get_shape_class($classitem) ".$values[$classitem]." no matches<br>"; | |
| 721 | + return $style_id; | |
| 722 | + } | |
| 723 | + | |
| 724 | + /** | |
| 725 | + * Add the style | |
| 726 | + * @return the style URL | |
| 727 | + */ | |
| 728 | + function add_style(&$layer, &$folder, $style_id, &$style_data){ | |
| 729 | + // Calculare style URL | |
| 730 | + | |
| 731 | + if($style_data['description_template']){ | |
| 732 | + $this->style_counter++; | |
| 733 | + $style_id .= '_'.$this->style_counter; | |
| 734 | + $balloon_data = $this->get_feature_description($attributes[$namecol], $attributes, $style_data['description_template']); | |
| 735 | + } | |
| 736 | + | |
| 737 | + // Check if the style already exists | |
| 738 | + $expr = '//*[@id=\''.$style_id.'\']'; | |
| 739 | + if($folder->xpath($expr)) { | |
| 740 | + return $style_id; | |
| 741 | + } | |
| 742 | + $new_style =& $folder->addChild('Style'); | |
| 743 | + $new_style['id'] = $style_id; | |
| 744 | + // Switch layer type | |
| 745 | + switch($layer->type){ | |
| 746 | + case MS_LAYER_POINT: | |
| 747 | + $this->add_style_point($new_style, $style_data); | |
| 748 | + break; | |
| 749 | + case MS_LAYER_POLYGON: | |
| 750 | + $this->add_style_polygon($new_style, $style_data); | |
| 751 | + break; | |
| 752 | + case MS_LAYER_LINE: | |
| 753 | + $this->add_style_line($new_style, $style_data); | |
| 754 | + // Add KML_ADD_POINT icon | |
| 755 | + if($style_data['icon']){ | |
| 756 | + $this->add_style_point($new_style, $style_data); | |
| 757 | + } | |
| 758 | + break; | |
| 759 | + } | |
| 760 | + return $style_id; | |
| 761 | + } | |
| 762 | + | |
| 763 | + /** | |
| 764 | + * Add style for lines | |
| 765 | + */ | |
| 766 | + function add_style_line(&$new_style, &$style_data){ | |
| 767 | + if($style_data['outlinecolor']->red != -1){ | |
| 768 | + $st =& $new_style->addChild('LineStyle'); | |
| 769 | + $st->addChild('color', sprintf('FF%02X%02X%02X', $style_data['outlinecolor']->blue, $style_data['outlinecolor']->green, $style_data['outlinecolor']->red)); | |
| 770 | + if($width) { | |
| 771 | + $st->addChild('width', $width); | |
| 772 | + } | |
| 773 | + } elseif($style_data['color']->red != -1){ | |
| 774 | + $st =& $new_style->addChild('LineStyle'); | |
| 775 | + $st->addChild('color', sprintf('FF%02X%02X%02X', $style_data['color']->blue, $style_data['color']->green, $style_data['color']->red)); | |
| 776 | + if($width) { | |
| 777 | + $st->addChild('width', $width); | |
| 778 | + } | |
| 779 | + } | |
| 780 | + } | |
| 781 | + | |
| 782 | + /** | |
| 783 | + * Add style for points | |
| 784 | + */ | |
| 785 | + function add_style_point(&$new_style, &$style_data){ | |
| 786 | + if($style_data['icon']){ | |
| 787 | + $st =& $new_style->addChild('IconStyle'); | |
| 788 | 788 | if($style_data['width'] && $style_data['icon_width'] != 32){ |
| 789 | 789 | /** |
| 790 | 790 | * |
| 791 | 791 | */ |
| 792 | 792 | //$st->addChild('scale', $style_data['icon_width'] / 32); |
| 793 | 793 | $st->addChild('scale', 1); |
| 794 | - } | |
| 794 | + } | |
| 795 | 795 | else |
| 796 | 796 | {$st->addChild('scale', 1);} |
| 797 | - $icon =& $st->addChild('Icon'); | |
| 798 | - $icon->addChild('href', htmlentities($style_data['icon'])); | |
| 799 | - | |
| 800 | - } | |
| 801 | - $ls =& $new_style->addChild('LabelStyle'); | |
| 802 | - $ls->addChild('scale', $style_data['label_size'] / 32); | |
| 803 | - // Add the balloon style if description_template is set | |
| 804 | - /* | |
| 805 | - if($style_data['description_template']){ | |
| 806 | - $this->add_balloon_style($new_style, $balloon_data); | |
| 807 | - } | |
| 808 | - */ | |
| 809 | - // Label size and color | |
| 810 | - /* | |
| 811 | - if($style_data['label_size'] || $style_data['label_color']){ | |
| 812 | - $ls =& $new_style->addChild('LabelStyle'); | |
| 813 | - if($style_data['label_size'] != -1 && $style_data['label_size'] != 32){ | |
| 814 | - $ls->addChild('scale', $style_data['label_size'] / 32); | |
| 815 | - } | |
| 816 | - if($style_data['label_color']->red != -1){ | |
| 817 | - $ls->addChild('color', sprintf('FF%02X%02X%02X', $style_data['label_color']->blue, $style_data['label_color']->green, $style_data['label_color']->red)); | |
| 818 | - } | |
| 819 | - } | |
| 820 | - */ | |
| 821 | - } | |
| 822 | - | |
| 823 | - /** | |
| 824 | - * Add style for polygons | |
| 825 | - */ | |
| 826 | - function add_style_polygon(&$new_style, &$style_data){ | |
| 827 | - // Get also outline styles | |
| 828 | - $this->add_style_line($new_style, $style_data); | |
| 829 | - $st =& $new_style->addChild('PolyStyle'); | |
| 830 | - //die(print_r($backgroundcolor, true)); | |
| 831 | - if($style_data['color']->red != -1){ | |
| 832 | - $st->addChild('color', sprintf('FF%02X%02X%02X', $style_data['color']->blue, $style_data['color']->green, $style_data['color']->red)); | |
| 833 | - $st->addChild('fill', 1); | |
| 834 | - } else { | |
| 835 | - $st->addChild('fill', 0); | |
| 836 | - } | |
| 837 | - $st->addChild('outline', 1); | |
| 838 | - } | |
| 839 | - | |
| 840 | - /** | |
| 841 | - * Add a WMS raster link | |
| 842 | - */ | |
| 843 | - function add_wms_link(&$folder, &$layer, &$link){ | |
| 844 | - // Build up the KML response document. | |
| 845 | - //$icon =& $folder->addChild('Icon'); | |
| 846 | - $icon =& $this->simplexml_addChild($folder,'Icon'); | |
| 847 | - //$icon->addChild('href', $link . 'layers=' . $layer->name); | |
| 848 | - $this->simplexml_addChild($icon,'href', $link . 'layers=' . $layer->name); | |
| 849 | - //$icon->addChild('viewRefreshMode', 'onStop'); | |
| 850 | - $this->simplexml_addChild($icon,'viewRefreshMode', 'onStop'); | |
| 851 | - //$llbox =& $folder->addChild('LatLonBox'); | |
| 852 | - $llbox =& $this->simplexml_addChild($folder,'LatLonBox'); | |
| 853 | - $ext = $this->map_object->extent; | |
| 854 | - $ext->project($this->in_proj, $this->out_proj); | |
| 855 | - //$llbox->north = $ext->maxy; | |
| 856 | - $this->simplexml_addChild($llbox,'north', $ext->maxy); | |
| 857 | - //$llbox->south = $ext->miny; | |
| 858 | - $this->simplexml_addChild($llbox,'south', $ext->miny); | |
| 859 | - //$llbox->east = $ext->maxx; | |
| 860 | - $this->simplexml_addChild($llbox,'east', $ext->maxx); | |
| 861 | - //$llbox->west = $ext->minx; | |
| 862 | - $this->simplexml_addChild($llbox,'west', $ext->minx); | |
| 863 | - // Reset original projection | |
| 864 | - $ext->project($this->out_proj, $this->in_proj); | |
| 865 | - } | |
| 866 | - | |
| 867 | - /** | |
| 868 | - * Get the url for a point icon | |
| 869 | - */ | |
| 870 | - function get_icon_url($layer, $classname, $classindex){ | |
| 871 | - $classe = $layer->getclass($classindex); | |
| 872 | - $estilo = $classe->getstyle(0); | |
| 873 | - $url = ""; | |
| 874 | - $imageObj = $classe->createLegendIcon(30,30); | |
| 875 | - if($imageObj) | |
| 797 | + $icon =& $st->addChild('Icon'); | |
| 798 | + $icon->addChild('href', htmlentities($style_data['icon'])); | |
| 799 | + | |
| 800 | + } | |
| 801 | + $ls =& $new_style->addChild('LabelStyle'); | |
| 802 | + $ls->addChild('scale', $style_data['label_size'] / 32); | |
| 803 | + // Add the balloon style if description_template is set | |
| 804 | + /* | |
| 805 | + if($style_data['description_template']){ | |
| 806 | + $this->add_balloon_style($new_style, $balloon_data); | |
| 807 | + } | |
| 808 | + */ | |
| 809 | + // Label size and color | |
| 810 | + /* | |
| 811 | + if($style_data['label_size'] || $style_data['label_color']){ | |
| 812 | + $ls =& $new_style->addChild('LabelStyle'); | |
| 813 | + if($style_data['label_size'] != -1 && $style_data['label_size'] != 32){ | |
| 814 | + $ls->addChild('scale', $style_data['label_size'] / 32); | |
| 815 | + } | |
| 816 | + if($style_data['label_color']->red != -1){ | |
| 817 | + $ls->addChild('color', sprintf('FF%02X%02X%02X', $style_data['label_color']->blue, $style_data['label_color']->green, $style_data['label_color']->red)); | |
| 818 | + } | |
| 819 | + } | |
| 820 | + */ | |
| 821 | + } | |
| 822 | + | |
| 823 | + /** | |
| 824 | + * Add style for polygons | |
| 825 | + */ | |
| 826 | + function add_style_polygon(&$new_style, &$style_data){ | |
| 827 | + // Get also outline styles | |
| 828 | + $this->add_style_line($new_style, $style_data); | |
| 829 | + $st =& $new_style->addChild('PolyStyle'); | |
| 830 | + //die(print_r($backgroundcolor, true)); | |
| 831 | + if($style_data['color']->red != -1){ | |
| 832 | + $st->addChild('color', sprintf('FF%02X%02X%02X', $style_data['color']->blue, $style_data['color']->green, $style_data['color']->red)); | |
| 833 | + $st->addChild('fill', 1); | |
| 834 | + } else { | |
| 835 | + $st->addChild('fill', 0); | |
| 836 | + } | |
| 837 | + $st->addChild('outline', 1); | |
| 838 | + } | |
| 839 | + | |
| 840 | + /** | |
| 841 | + * Add a WMS raster link | |
| 842 | + */ | |
| 843 | + function add_wms_link(&$folder, &$layer, &$link){ | |
| 844 | + // Build up the KML response document. | |
| 845 | + //$icon =& $folder->addChild('Icon'); | |
| 846 | + $icon =& $this->simplexml_addChild($folder,'Icon'); | |
| 847 | + //$icon->addChild('href', $link . 'layers=' . $layer->name); | |
| 848 | + $this->simplexml_addChild($icon,'href', $link . 'layers=' . $layer->name); | |
| 849 | + //$icon->addChild('viewRefreshMode', 'onStop'); | |
| 850 | + $this->simplexml_addChild($icon,'viewRefreshMode', 'onStop'); | |
| 851 | + //$llbox =& $folder->addChild('LatLonBox'); | |
| 852 | + $llbox =& $this->simplexml_addChild($folder,'LatLonBox'); | |
| 853 | + $ext = $this->map_object->extent; | |
| 854 | + $ext->project($this->in_proj, $this->out_proj); | |
| 855 | + //$llbox->north = $ext->maxy; | |
| 856 | + $this->simplexml_addChild($llbox,'north', $ext->maxy); | |
| 857 | + //$llbox->south = $ext->miny; | |
| 858 | + $this->simplexml_addChild($llbox,'south', $ext->miny); | |
| 859 | + //$llbox->east = $ext->maxx; | |
| 860 | + $this->simplexml_addChild($llbox,'east', $ext->maxx); | |
| 861 | + //$llbox->west = $ext->minx; | |
| 862 | + $this->simplexml_addChild($llbox,'west', $ext->minx); | |
| 863 | + // Reset original projection | |
| 864 | + $ext->project($this->out_proj, $this->in_proj); | |
| 865 | + } | |
| 866 | + | |
| 867 | + /** | |
| 868 | + * Get the url for a point icon | |
| 869 | + */ | |
| 870 | + function get_icon_url($layer, $classname, $classindex){ | |
| 871 | + $classe = $layer->getclass($classindex); | |
| 872 | + $estilo = $classe->getstyle(0); | |
| 873 | + $url = ""; | |
| 874 | + $imageObj = $classe->createLegendIcon(30,30); | |
| 875 | + if($imageObj) | |
| 876 | 876 | { |
| 877 | 877 | $url = $imageObj->saveWebImage(); |
| 878 | 878 | $protocolo = explode("/",$_SERVER['SERVER_PROTOCOL']); |
| ... | ... | @@ -884,77 +884,77 @@ class LayerServer { |
| 884 | 884 | imagecolortransparent($img, $index); |
| 885 | 885 | imagepng($img, $nome); |
| 886 | 886 | } |
| 887 | - return $url; //$this->endpoint . '?service=icon&map=' . $this->map . '&typename=' . urlencode($layer->name) . '&classname=' . urlencode($classname); | |
| 888 | - } | |
| 889 | - | |
| 890 | - /** | |
| 891 | - * Get the layer description | |
| 892 | - */ | |
| 893 | - function get_layer_description(&$layer){ | |
| 894 | - $description = $layer->getMetadata('DESCRIPTION'); | |
| 895 | - if(!$description){ | |
| 896 | - $description = $layer->getMetadata('OWS_TITLE'); | |
| 897 | - } | |
| 898 | - if(!$description){ | |
| 899 | - $description = $layer->getMetadata('WFS_TITLE'); | |
| 900 | - } | |
| 901 | - if(!$description){ | |
| 902 | - $description = $layer->getMetadata('WMS_TITLE'); | |
| 903 | - } | |
| 904 | - if(!$description){ | |
| 905 | - $description = $layer->getMetadata('TEMA'); | |
| 906 | - } | |
| 907 | - if(!$description){ | |
| 908 | - $description = $layer->name; | |
| 909 | - } | |
| 910 | - $description = mb_convert_encoding($description,"UTF-8",mb_detect_encoding($description,"UTF-8,ISO-8859-1")); | |
| 911 | - return $description; | |
| 912 | - } | |
| 913 | - | |
| 914 | - | |
| 915 | - | |
| 916 | - /** | |
| 917 | - * Add style for balloon | |
| 918 | - * @param string style XML id | |
| 919 | - * @param string column name for title | |
| 920 | - */ | |
| 921 | - function add_balloon_style(&$style, $balloon_data){ | |
| 922 | - $balloon =& $style->addChild('BalloonStyle'); | |
| 923 | - $balloon->addChild('text', htmlentities($balloon_data)); | |
| 924 | - } | |
| 925 | - | |
| 926 | - | |
| 927 | - /** | |
| 928 | - * Get a request parameter | |
| 929 | - * @param string $name | |
| 930 | - * @param string $default parameter optional | |
| 931 | - * @return string the parameter value or empty string if null | |
| 932 | - */ | |
| 933 | - function load_parm($name, $default = ''){ | |
| 934 | - if(!isset($_REQUEST[$name])) return $default; | |
| 935 | - $value = $_REQUEST[$name]; | |
| 936 | - if(get_magic_quotes_gpc() != 1) $value = addslashes($value); | |
| 937 | - //$value = escapeshellcmd($value); | |
| 938 | - return $value; | |
| 939 | - } | |
| 940 | - | |
| 941 | - /** | |
| 942 | - * Set error message | |
| 943 | - * @param string $message | |
| 944 | - * @param string $layer name | |
| 945 | - */ | |
| 946 | - function set_error($message, $layer = 'Error'){ | |
| 947 | - $this->errors[$layer][] = $message; | |
| 948 | - } | |
| 949 | - | |
| 950 | - | |
| 951 | - /** | |
| 952 | - * Load the map and create the map instance | |
| 953 | - */ | |
| 954 | - function load_map(){ | |
| 955 | - if(!file_exists($this->map) && is_readable($this->map)){ | |
| 956 | - $this->set_error('Cannot read mapfile '. $this->map); | |
| 957 | - } else { | |
| 887 | + return $url; //$this->endpoint . '?service=icon&map=' . $this->map . '&typename=' . urlencode($layer->name) . '&classname=' . urlencode($classname); | |
| 888 | + } | |
| 889 | + | |
| 890 | + /** | |
| 891 | + * Get the layer description | |
| 892 | + */ | |
| 893 | + function get_layer_description(&$layer){ | |
| 894 | + $description = $layer->getMetadata('DESCRIPTION'); | |
| 895 | + if(!$description){ | |
| 896 | + $description = $layer->getMetadata('OWS_TITLE'); | |
| 897 | + } | |
| 898 | + if(!$description){ | |
| 899 | + $description = $layer->getMetadata('WFS_TITLE'); | |
| 900 | + } | |
| 901 | + if(!$description){ | |
| 902 | + $description = $layer->getMetadata('WMS_TITLE'); | |
| 903 | + } | |
| 904 | + if(!$description){ | |
| 905 | + $description = $layer->getMetadata('TEMA'); | |
| 906 | + } | |
| 907 | + if(!$description){ | |
| 908 | + $description = $layer->name; | |
| 909 | + } | |
| 910 | + $description = mb_convert_encoding($description,"UTF-8",mb_detect_encoding($description,"UTF-8,ISO-8859-1")); | |
| 911 | + return $description; | |
| 912 | + } | |
| 913 | + | |
| 914 | + | |
| 915 | + | |
| 916 | + /** | |
| 917 | + * Add style for balloon | |
| 918 | + * @param string style XML id | |
| 919 | + * @param string column name for title | |
| 920 | + */ | |
| 921 | + function add_balloon_style(&$style, $balloon_data){ | |
| 922 | + $balloon =& $style->addChild('BalloonStyle'); | |
| 923 | + $balloon->addChild('text', htmlentities($balloon_data)); | |
| 924 | + } | |
| 925 | + | |
| 926 | + | |
| 927 | + /** | |
| 928 | + * Get a request parameter | |
| 929 | + * @param string $name | |
| 930 | + * @param string $default parameter optional | |
| 931 | + * @return string the parameter value or empty string if null | |
| 932 | + */ | |
| 933 | + function load_parm($name, $default = ''){ | |
| 934 | + if(!isset($_REQUEST[$name])) return $default; | |
| 935 | + $value = $_REQUEST[$name]; | |
| 936 | + if(get_magic_quotes_gpc() != 1) $value = addslashes($value); | |
| 937 | + //$value = escapeshellcmd($value); | |
| 938 | + return $value; | |
| 939 | + } | |
| 940 | + | |
| 941 | + /** | |
| 942 | + * Set error message | |
| 943 | + * @param string $message | |
| 944 | + * @param string $layer name | |
| 945 | + */ | |
| 946 | + function set_error($message, $layer = 'Error'){ | |
| 947 | + $this->errors[$layer][] = $message; | |
| 948 | + } | |
| 949 | + | |
| 950 | + | |
| 951 | + /** | |
| 952 | + * Load the map and create the map instance | |
| 953 | + */ | |
| 954 | + function load_map(){ | |
| 955 | + if(!file_exists($this->map) && is_readable($this->map)){ | |
| 956 | + $this->set_error('Cannot read mapfile '. $this->map); | |
| 957 | + } else { | |
| 958 | 958 | $protocolo = explode("/",$_SERVER['SERVER_PROTOCOL']); |
| 959 | 959 | $servidor = strtolower($protocolo[0])."://".$_SERVER['HTTP_HOST']; |
| 960 | 960 | $temp = $this->map; |
| ... | ... | @@ -962,7 +962,7 @@ class LayerServer { |
| 962 | 962 | include(dirname(__FILE__)."/ms_configura.php"); |
| 963 | 963 | } |
| 964 | 964 | else{ |
| 965 | - include("../../ms_configura.php"); | |
| 965 | + include(dirname(__FILE__)."/../../ms_configura.php"); | |
| 966 | 966 | } |
| 967 | 967 | if(!file_exists($this->map)){ |
| 968 | 968 | $maptemp = ms_newMapObj($locaplic."/temas/".$this->map.".map"); |
| ... | ... | @@ -994,13 +994,13 @@ class LayerServer { |
| 994 | 994 | } |
| 995 | 995 | $this->map = $base; |
| 996 | 996 | |
| 997 | - $this->map_object = ms_newMapObj($this->map); | |
| 998 | - if(!$this->_zipped){ | |
| 999 | - $this->map_object->setmetadata('wms_onlineresource',$servidor.":80/i3geo/ogc.php?tema=".$temp."&width=1500&height=1500&"); | |
| 1000 | - $this->map_object->setmetadata("ows_enable_request","*"); | |
| 1001 | - } | |
| 1002 | - $n = $this->map_object->numlayers; | |
| 1003 | - for ($i=0;$i < $n;$i++) | |
| 997 | + $this->map_object = ms_newMapObj($this->map); | |
| 998 | + if(!$this->_zipped){ | |
| 999 | + $this->map_object->setmetadata('wms_onlineresource',$servidor.":80/i3geo/ogc.php?tema=".$temp."&width=1500&height=1500&"); | |
| 1000 | + $this->map_object->setmetadata("ows_enable_request","*"); | |
| 1001 | + } | |
| 1002 | + $n = $this->map_object->numlayers; | |
| 1003 | + for ($i=0;$i < $n;$i++) | |
| 1004 | 1004 | { |
| 1005 | 1005 | $l = $this->map_object->getlayer($i); |
| 1006 | 1006 | $l->set("status",MS_DELETE); |
| ... | ... | @@ -1036,58 +1036,58 @@ class LayerServer { |
| 1036 | 1036 | //ms_newLayerObj($this->map_object, $l); |
| 1037 | 1037 | } |
| 1038 | 1038 | } |
| 1039 | - if(!$this->map_object){ | |
| 1040 | - $this->set_error('Cannot load mapfile '. $this->map); | |
| 1041 | - } | |
| 1042 | - } | |
| 1043 | - } | |
| 1044 | - | |
| 1045 | - /** | |
| 1046 | - * Test if has errors | |
| 1047 | - * @return boolean | |
| 1048 | - */ | |
| 1049 | - function has_error(){ | |
| 1050 | - return count($this->errors) > 0; | |
| 1051 | - } | |
| 1052 | - | |
| 1053 | - /** | |
| 1054 | - * Add error messages to folders TAGS | |
| 1055 | - */ | |
| 1056 | - function add_errors(){ | |
| 1057 | - foreach($this->errors as $layer => $errors){ | |
| 1058 | - $folder =& $this->_xml->Document->addChild('Folder'); | |
| 1059 | - $folder->addChild('name', $layer); | |
| 1060 | - $folder->addChild('description', '<p>' . join("</p>\n<p>", $errors) . "</p>"); | |
| 1061 | - } | |
| 1062 | - return $errorxml; | |
| 1063 | - } | |
| 1064 | - | |
| 1065 | - /** | |
| 1066 | - * Fetch XML and format it | |
| 1067 | - */ | |
| 1068 | - function get_kml(){ | |
| 1069 | - $doc = new DOMDocument('1.0'); | |
| 1070 | - $doc->formatOutput = true; | |
| 1071 | - $domnode = dom_import_simplexml($this->_xml); | |
| 1072 | - $domnode = $doc->importNode($domnode, true); | |
| 1073 | - $domnode = $doc->appendChild($domnode); | |
| 1074 | - return $doc->saveXML(); | |
| 1075 | - } | |
| 1076 | - | |
| 1077 | - /** | |
| 1078 | - * Send header | |
| 1079 | - */ | |
| 1080 | - function send_header(){ | |
| 1081 | - header('Content-Disposition: attachment; filename=kml.km'.($this->_zipped ? 'z' : 'l')); | |
| 1082 | - header('Content-type: application/vnd.google-earth.km'.($this->_zipped ? 'z' : 'l').'+XML'); | |
| 1083 | - } | |
| 1084 | - | |
| 1085 | - /** | |
| 1086 | - * Calculate cache file name | |
| 1087 | - */ | |
| 1088 | - function get_cache_file_name(){ | |
| 1089 | - //obtem o arquivo do metadata do layer se existir | |
| 1090 | - $layer = @$this->map_object->getlayerbyname($this->typename); | |
| 1039 | + if(!$this->map_object){ | |
| 1040 | + $this->set_error('Cannot load mapfile '. $this->map); | |
| 1041 | + } | |
| 1042 | + } | |
| 1043 | + } | |
| 1044 | + | |
| 1045 | + /** | |
| 1046 | + * Test if has errors | |
| 1047 | + * @return boolean | |
| 1048 | + */ | |
| 1049 | + function has_error(){ | |
| 1050 | + return count($this->errors) > 0; | |
| 1051 | + } | |
| 1052 | + | |
| 1053 | + /** | |
| 1054 | + * Add error messages to folders TAGS | |
| 1055 | + */ | |
| 1056 | + function add_errors(){ | |
| 1057 | + foreach($this->errors as $layer => $errors){ | |
| 1058 | + $folder =& $this->_xml->Document->addChild('Folder'); | |
| 1059 | + $folder->addChild('name', $layer); | |
| 1060 | + $folder->addChild('description', '<p>' . join("</p>\n<p>", $errors) . "</p>"); | |
| 1061 | + } | |
| 1062 | + return $errorxml; | |
| 1063 | + } | |
| 1064 | + | |
| 1065 | + /** | |
| 1066 | + * Fetch XML and format it | |
| 1067 | + */ | |
| 1068 | + function get_kml(){ | |
| 1069 | + $doc = new DOMDocument('1.0'); | |
| 1070 | + $doc->formatOutput = true; | |
| 1071 | + $domnode = dom_import_simplexml($this->_xml); | |
| 1072 | + $domnode = $doc->importNode($domnode, true); | |
| 1073 | + $domnode = $doc->appendChild($domnode); | |
| 1074 | + return $doc->saveXML(); | |
| 1075 | + } | |
| 1076 | + | |
| 1077 | + /** | |
| 1078 | + * Send header | |
| 1079 | + */ | |
| 1080 | + function send_header(){ | |
| 1081 | + header('Content-Disposition: attachment; filename=kml.km'.($this->_zipped ? 'z' : 'l')); | |
| 1082 | + header('Content-type: application/vnd.google-earth.km'.($this->_zipped ? 'z' : 'l').'+XML'); | |
| 1083 | + } | |
| 1084 | + | |
| 1085 | + /** | |
| 1086 | + * Calculate cache file name | |
| 1087 | + */ | |
| 1088 | + function get_cache_file_name(){ | |
| 1089 | + //obtem o arquivo do metadata do layer se existir | |
| 1090 | + $layer = @$this->map_object->getlayerbyname($this->typename); | |
| 1091 | 1091 | if(!$layer) |
| 1092 | 1092 | {$layer = $this->map_object->getlayer(0);} |
| 1093 | 1093 | $k = $layer->getmetadata("arquivokmz"); |
| ... | ... | @@ -1095,40 +1095,40 @@ class LayerServer { |
| 1095 | 1095 | return $k; |
| 1096 | 1096 | } |
| 1097 | 1097 | include(dirname(__FILE__)."/../../ms_configura.php"); |
| 1098 | - return $dir_tmp.'/'. md5($_SERVER['QUERY_STRING']) . ($this->_zipped ? '.kmz' : '.kml'); | |
| 1099 | - } | |
| 1098 | + return $dir_tmp.'/'. md5($_SERVER['QUERY_STRING']) . ($this->_zipped ? '.kmz' : '.kml'); | |
| 1099 | + } | |
| 1100 | 1100 | |
| 1101 | - /** | |
| 1102 | - * Send stream | |
| 1103 | - */ | |
| 1104 | - function send_stream($data){ | |
| 1101 | + /** | |
| 1102 | + * Send stream | |
| 1103 | + */ | |
| 1104 | + function send_stream($data){ | |
| 1105 | 1105 | $this->send_header(); |
| 1106 | - // Compress data | |
| 1107 | - | |
| 1108 | - if($this->_zipped){ | |
| 1109 | - include("zip.class.php"); | |
| 1110 | - $ziper = new zipfile(); | |
| 1111 | - $ziper->addFile($data, 'doc.kml'); | |
| 1112 | - $data = $ziper->file(); | |
| 1113 | - } | |
| 1114 | - | |
| 1115 | - // Create cache if needed | |
| 1116 | - if(ENABLE_CACHE && count($this->layers) == 1) { | |
| 1117 | - //error_log( 'creating cache ' . $this->get_cache_file_name() ); | |
| 1118 | - file_put_contents($this->get_cache_file_name(), $data); | |
| 1119 | - } | |
| 1120 | - print $data; | |
| 1121 | - exit(); | |
| 1122 | - } | |
| 1106 | + // Compress data | |
| 1107 | + | |
| 1108 | + if($this->_zipped){ | |
| 1109 | + include("zip.class.php"); | |
| 1110 | + $ziper = new zipfile(); | |
| 1111 | + $ziper->addFile($data, 'doc.kml'); | |
| 1112 | + $data = $ziper->file(); | |
| 1113 | + } | |
| 1114 | + | |
| 1115 | + // Create cache if needed | |
| 1116 | + if(ENABLE_CACHE && count($this->layers) == 1) { | |
| 1117 | + //error_log( 'creating cache ' . $this->get_cache_file_name() ); | |
| 1118 | + file_put_contents($this->get_cache_file_name(), $data); | |
| 1119 | + } | |
| 1120 | + print $data; | |
| 1121 | + exit(); | |
| 1122 | + } | |
| 1123 | 1123 | // phpversion <= 5.1.2 |
| 1124 | 1124 | |
| 1125 | 1125 | function simplexml_addChild($parent, $name, $value=''){ |
| 1126 | - $new_child = new SimpleXMLElement("<$name>$value</$name>"); | |
| 1127 | - $node1 = dom_import_simplexml($parent); | |
| 1128 | - $dom_sxe = dom_import_simplexml($new_child); | |
| 1129 | - $node2 = $node1->ownerDocument->importNode($dom_sxe, true); | |
| 1130 | - $node1->appendChild($node2); | |
| 1131 | - return simplexml_import_dom($node2); | |
| 1126 | + $new_child = new SimpleXMLElement("<$name>$value</$name>"); | |
| 1127 | + $node1 = dom_import_simplexml($parent); | |
| 1128 | + $dom_sxe = dom_import_simplexml($new_child); | |
| 1129 | + $node2 = $node1->ownerDocument->importNode($dom_sxe, true); | |
| 1130 | + $node1->appendChild($node2); | |
| 1131 | + return simplexml_import_dom($node2); | |
| 1132 | 1132 | } |
| 1133 | 1133 | function versao() |
| 1134 | 1134 | { | ... | ... |
pacotes/linkedinoauth/example/common.inc.php
pacotes/linkedinoauth/example/index.php
| 1 | 1 | <?php |
| 2 | 2 | require_once("common.inc.php"); |
| 3 | -include("../../../ms_configura.php"); | |
| 3 | +include(dirname(__FILE__)."/../../../ms_configura.php"); | |
| 4 | 4 | |
| 5 | 5 | $test_consumer = new OAuthConsumer($linkedinoauth["consumerkey"], $linkedinoauth["consumersecret"], NULL); |
| 6 | 6 | $req_token = new OAuthConsumer($linkedinoauth["consumerkey"], $linkedinoauth["consumersecret"], 1); |
| ... | ... | @@ -9,7 +9,7 @@ $acc_token = new OAuthConsumer($linkedinoauth["consumerkey"], $linkedinoauth["co |
| 9 | 9 | $sig_method = $hmac_method; |
| 10 | 10 | $user_sig_method = @$_GET['sig_method']; |
| 11 | 11 | if ($user_sig_method) { |
| 12 | - $sig_method = $sig_methods[$user_sig_method]; | |
| 12 | + $sig_method = $sig_methods[$user_sig_method]; | |
| 13 | 13 | } |
| 14 | 14 | |
| 15 | 15 | $req_req = OAuthRequest::from_consumer_and_token($test_consumer, NULL, "GET", $base_url . "/request_token.php"); |
| ... | ... | @@ -86,19 +86,19 @@ A successful request will echo the non-OAuth parameters sent to it, for example: |
| 86 | 86 | <?php |
| 87 | 87 | $sig_methods = $test_server->get_signature_methods(); |
| 88 | 88 | foreach ($sig_methods as $key => $method) { |
| 89 | - print "<li>$key"; | |
| 90 | - if ($key != $sig_method->get_name()) { | |
| 91 | - print "(<a href='?sig_method=$key'>switch</a>)"; | |
| 92 | - } | |
| 93 | - print "</li>\n"; | |
| 89 | + print "<li>$key"; | |
| 90 | + if ($key != $sig_method->get_name()) { | |
| 91 | + print "(<a href='?sig_method=$key'>switch</a>)"; | |
| 92 | + } | |
| 93 | + print "</li>\n"; | |
| 94 | 94 | } |
| 95 | 95 | ?> |
| 96 | 96 | </ul> |
| 97 | 97 | |
| 98 | -<?php | |
| 98 | +<?php | |
| 99 | 99 | if ("RSA-SHA1" == $sig_method->get_name()) { |
| 100 | - print "<pre>" . $sig_method->fetch_private_cert($req_req) . "</pre>\n"; | |
| 101 | - print "<pre>" . $sig_method->fetch_public_cert($req_req) . "</pre>\n"; | |
| 100 | + print "<pre>" . $sig_method->fetch_private_cert($req_req) . "</pre>\n"; | |
| 101 | + print "<pre>" . $sig_method->fetch_public_cert($req_req) . "</pre>\n"; | |
| 102 | 102 | } |
| 103 | 103 | ?> |
| 104 | 104 | ... | ... |
pacotes/linkedinoauth/testLinkedinOauth.php
pacotes/openid/login.php
| ... | ... | @@ -9,7 +9,7 @@ img |
| 9 | 9 | //http://localhost/i3geo/pacotes/openid/login.php?g_sid=dqpk71kh6ei121s4u5g1qb9vi1 |
| 10 | 10 | session_name("openid"); |
| 11 | 11 | session_start(); |
| 12 | -include("../../ms_configura.php"); | |
| 12 | +include(dirname(__FILE__)."/../../ms_configura.php"); | |
| 13 | 13 | if($_SESSION["openid"] == false) |
| 14 | 14 | { |
| 15 | 15 | $dadosurl = array_merge($_GET,$_POST); |
| ... | ... | @@ -17,15 +17,15 @@ if($_SESSION["openid"] == false) |
| 17 | 17 | echo "<span style=color:red >Ocorreu algum erro</span><br><br>"; |
| 18 | 18 | } |
| 19 | 19 | |
| 20 | -} | |
| 20 | +} | |
| 21 | 21 | require 'openid.php'; |
| 22 | 22 | try { |
| 23 | - $openid = new LightOpenID; | |
| 23 | + $openid = new LightOpenID; | |
| 24 | 24 | if(!$openid->mode && $_SESSION["openid"] == false) { |
| 25 | - if(isset($dadosurl['openid_identifier']) && empty($dadosurl["erro"])) { | |
| 25 | + if(isset($dadosurl['openid_identifier']) && empty($dadosurl["erro"])) { | |
| 26 | 26 | $openid->identity = $dadosurl['openid_identifier']; |
| 27 | - header('Location: ' . $openid->authUrl()); | |
| 28 | - } | |
| 27 | + header('Location: ' . $openid->authUrl()); | |
| 28 | + } | |
| 29 | 29 | ?> |
| 30 | 30 | |
| 31 | 31 | <body> |
| ... | ... | @@ -63,19 +63,19 @@ function submete(quem){ |
| 63 | 63 | } |
| 64 | 64 | if(quem == "google") |
| 65 | 65 | { |
| 66 | - var u = window.prompt("Usuário",""); | |
| 66 | + var u = window.prompt("Usu�rio",""); | |
| 67 | 67 | if(!u){return;} |
| 68 | 68 | var url = 'http://www.google.com/profiles/'+u; |
| 69 | 69 | } |
| 70 | 70 | if(quem == "myopenid") |
| 71 | 71 | { |
| 72 | - var u = window.prompt("Usuário",""); | |
| 72 | + var u = window.prompt("Usu�rio",""); | |
| 73 | 73 | if(!u){return;} |
| 74 | 74 | var url = "http://"+u+".myopenid.com/"; |
| 75 | - } | |
| 75 | + } | |
| 76 | 76 | if(quem == "myspace") |
| 77 | 77 | { |
| 78 | - var u = window.prompt("Usuário",""); | |
| 78 | + var u = window.prompt("Usu�rio",""); | |
| 79 | 79 | if(!u){return;} |
| 80 | 80 | var url = 'http://myspace.com/'+u; |
| 81 | 81 | } |
| ... | ... | @@ -85,13 +85,13 @@ function submete(quem){ |
| 85 | 85 | } |
| 86 | 86 | if(quem == "wordpress") |
| 87 | 87 | { |
| 88 | - var u = window.prompt("Usuário",""); | |
| 88 | + var u = window.prompt("Usu�rio",""); | |
| 89 | 89 | if(!u){return;} |
| 90 | 90 | var url = 'http://'+u+'wordpress.com'; |
| 91 | 91 | } |
| 92 | 92 | if(quem == "blogger") |
| 93 | 93 | { |
| 94 | - var u = window.prompt("Usuário",""); | |
| 94 | + var u = window.prompt("Usu�rio",""); | |
| 95 | 95 | if(!u){return;} |
| 96 | 96 | var url = 'http://'+u+'.blogspot.com'; |
| 97 | 97 | } |
| ... | ... | @@ -108,9 +108,9 @@ function submete(quem){ |
| 108 | 108 | } |
| 109 | 109 | </script> |
| 110 | 110 | <?php |
| 111 | - } elseif($openid->mode == 'cancel') { | |
| 112 | - echo 'User has canceled authentication!'; | |
| 113 | - } else { | |
| 111 | + } elseif($openid->mode == 'cancel') { | |
| 112 | + echo 'User has canceled authentication!'; | |
| 113 | + } else { | |
| 114 | 114 | if($_SESSION["openidservico"] != "twitter" && $_SESSION["openidservico"] != "facebook" && $_SESSION["openidservico"] != "linkedin"){ |
| 115 | 115 | $valido = $openid->validate(); |
| 116 | 116 | $_SESSION["openid"] = false; |
| ... | ... | @@ -133,9 +133,9 @@ function submete(quem){ |
| 133 | 133 | $url = "login.php?login&erro=ok"; |
| 134 | 134 | header('Location: ' . $url); |
| 135 | 135 | } |
| 136 | - } | |
| 136 | + } | |
| 137 | 137 | } catch(ErrorException $e) { |
| 138 | - echo $e->getMessage(); | |
| 138 | + echo $e->getMessage(); | |
| 139 | 139 | echo "<br>O nome de usuario pode estar errado."; |
| 140 | 140 | } |
| 141 | 141 | ?> |
| 142 | 142 | \ No newline at end of file | ... | ... |
pacotes/phpliteadmin/phpliteadmin.php
| ... | ... | @@ -28,7 +28,7 @@ |
| 28 | 28 | // |
| 29 | 29 | /////////////////////////////////////////////////////////////////////////// |
| 30 | 30 | //adicionado por edmar |
| 31 | -include_once ("../../ms_configura.php"); | |
| 31 | +include_once (dirname(__FILE__)."/../../ms_configura.php"); | |
| 32 | 32 | $editor = false; |
| 33 | 33 | if (strtolower($_SERVER['HTTP_HOST']) !== "localhost") |
| 34 | 34 | {echo "Acesso permitido apenas via localhost";exit;} |
| ... | ... | @@ -1790,7 +1790,7 @@ else //user is authorized - display the main application |
| 1790 | 1790 | echo "<table border='0' cellpadding='2' cellspacing='1' class='viewTable'>"; |
| 1791 | 1791 | echo "<tr>"; |
| 1792 | 1792 | $headings = array("Field", "Type", "Primary Key", "Autoincrement", "Not NULL", "Default Value"); |
| 1793 | - for($k=0; $k<count($headings); $k++) | |
| 1793 | + for($k=0; $k<count($headings); $k++) | |
| 1794 | 1794 | echo "<td class='tdheader'>" . $headings[$k] . "</td>"; |
| 1795 | 1795 | echo "</tr>"; |
| 1796 | 1796 | |
| ... | ... | @@ -2106,47 +2106,47 @@ else //user is authorized - display the main application |
| 2106 | 2106 | |
| 2107 | 2107 | for($i=0; $i<sizeof($result); $i++) |
| 2108 | 2108 | { |
| 2109 | - $field = $result[$i][1]; | |
| 2110 | - $type = $result[$i][2]; | |
| 2111 | - $tdWithClass = "<td class='td".($i%2 ? "1" : "2")."'>"; | |
| 2112 | - $tdWithClassLeft = "<td class='td".($i%2 ? "1" : "2")."' style='text-align:left;'>"; | |
| 2113 | - echo "<tr>"; | |
| 2114 | - echo $tdWithClassLeft; | |
| 2115 | - echo $field; | |
| 2116 | - echo "</td>"; | |
| 2117 | - echo $tdWithClassLeft; | |
| 2118 | - echo $type; | |
| 2119 | - echo "</td>"; | |
| 2120 | - echo $tdWithClassLeft; | |
| 2121 | - echo "<select name='".$field.":operator'>"; | |
| 2122 | - echo "<option value='='>=</option>"; | |
| 2123 | - if($type=="INTEGER" || $type=="REAL") | |
| 2124 | - { | |
| 2125 | - echo "<option value='>'>></option>"; | |
| 2126 | - echo "<option value='>='>>=</option>"; | |
| 2127 | - echo "<option value='<'><</option>"; | |
| 2128 | - echo "<option value='<='><=</option>"; | |
| 2129 | - } | |
| 2130 | - else if($type=="TEXT" || $type=="BLOB") | |
| 2131 | - { | |
| 2132 | - echo "<option value='= '''>= ''</option>"; | |
| 2133 | - echo "<option value='!= '''>!= ''</option>"; | |
| 2134 | - } | |
| 2135 | - echo "<option value='!='>!=</option>"; | |
| 2136 | - if($type=="TEXT" || $type=="BLOB") | |
| 2137 | - echo "<option value='LIKE' selected='selected'>LIKE</option>"; | |
| 2138 | - else | |
| 2139 | - echo "<option value='LIKE'>LIKE</option>"; | |
| 2140 | - echo "<option value='NOT LIKE'>NOT LIKE</option>"; | |
| 2141 | - echo "</select>"; | |
| 2142 | - echo "</td>"; | |
| 2143 | - echo $tdWithClassLeft; | |
| 2144 | - if($type=="INTEGER" || $type=="REAL" || $type=="NULL") | |
| 2145 | - echo "<input type='text' name='".$field."'/>"; | |
| 2146 | - else | |
| 2147 | - echo "<textarea name='".$field."' wrap='hard' rows='1' cols='60'></textarea>"; | |
| 2148 | - echo "</td>"; | |
| 2149 | - echo "</tr>"; | |
| 2109 | + $field = $result[$i][1]; | |
| 2110 | + $type = $result[$i][2]; | |
| 2111 | + $tdWithClass = "<td class='td".($i%2 ? "1" : "2")."'>"; | |
| 2112 | + $tdWithClassLeft = "<td class='td".($i%2 ? "1" : "2")."' style='text-align:left;'>"; | |
| 2113 | + echo "<tr>"; | |
| 2114 | + echo $tdWithClassLeft; | |
| 2115 | + echo $field; | |
| 2116 | + echo "</td>"; | |
| 2117 | + echo $tdWithClassLeft; | |
| 2118 | + echo $type; | |
| 2119 | + echo "</td>"; | |
| 2120 | + echo $tdWithClassLeft; | |
| 2121 | + echo "<select name='".$field.":operator'>"; | |
| 2122 | + echo "<option value='='>=</option>"; | |
| 2123 | + if($type=="INTEGER" || $type=="REAL") | |
| 2124 | + { | |
| 2125 | + echo "<option value='>'>></option>"; | |
| 2126 | + echo "<option value='>='>>=</option>"; | |
| 2127 | + echo "<option value='<'><</option>"; | |
| 2128 | + echo "<option value='<='><=</option>"; | |
| 2129 | + } | |
| 2130 | + else if($type=="TEXT" || $type=="BLOB") | |
| 2131 | + { | |
| 2132 | + echo "<option value='= '''>= ''</option>"; | |
| 2133 | + echo "<option value='!= '''>!= ''</option>"; | |
| 2134 | + } | |
| 2135 | + echo "<option value='!='>!=</option>"; | |
| 2136 | + if($type=="TEXT" || $type=="BLOB") | |
| 2137 | + echo "<option value='LIKE' selected='selected'>LIKE</option>"; | |
| 2138 | + else | |
| 2139 | + echo "<option value='LIKE'>LIKE</option>"; | |
| 2140 | + echo "<option value='NOT LIKE'>NOT LIKE</option>"; | |
| 2141 | + echo "</select>"; | |
| 2142 | + echo "</td>"; | |
| 2143 | + echo $tdWithClassLeft; | |
| 2144 | + if($type=="INTEGER" || $type=="REAL" || $type=="NULL") | |
| 2145 | + echo "<input type='text' name='".$field."'/>"; | |
| 2146 | + else | |
| 2147 | + echo "<textarea name='".$field."' wrap='hard' rows='1' cols='60'></textarea>"; | |
| 2148 | + echo "</td>"; | |
| 2149 | + echo "</tr>"; | |
| 2150 | 2150 | } |
| 2151 | 2151 | echo "<tr>"; |
| 2152 | 2152 | echo "<td class='tdheader' style='text-align:right;' colspan='4'>"; |
| ... | ... | @@ -2704,7 +2704,7 @@ else //user is authorized - display the main application |
| 2704 | 2704 | echo "<table border='0' cellpadding='2' cellspacing='1' class='viewTable'>"; |
| 2705 | 2705 | echo "<tr>"; |
| 2706 | 2706 | $headings = array("Field", "Type", "Primary Key", "Autoincrement", "Not NULL", "Default Value"); |
| 2707 | - for($k=0; $k<count($headings); $k++) | |
| 2707 | + for($k=0; $k<count($headings); $k++) | |
| 2708 | 2708 | echo "<td class='tdheader'>" . $headings[$k] . "</td>"; |
| 2709 | 2709 | echo "</tr>"; |
| 2710 | 2710 | ... | ... |
pacotes/qrcode/php/qr_html.php
| ... | ... | @@ -13,12 +13,12 @@ p |
| 13 | 13 | </style> |
| 14 | 14 | <body> |
| 15 | 15 | <?php |
| 16 | -include("../../../classesphp/carrega_ext.php"); | |
| 17 | -include("../../../classesphp/pega_variaveis.php"); | |
| 16 | +include(dirname(__FILE__)."/../../../classesphp/carrega_ext.php"); | |
| 17 | +include(dirname(__FILE__)."/../../../classesphp/pega_variaveis.php"); | |
| 18 | 18 | |
| 19 | 19 | echo "<p>O código de barras abaixo pode ser lido por dispositivos móveis, como os celulares ou pdas."; |
| 20 | 20 | echo "<p>Se o seu dispositivo possuir o software adequado, fotografe o código para abrir o navegador de internet ou clique no link."; |
| 21 | 21 | $d = $d."&temasa=".$temasa."&layers=".$layers; |
| 22 | -echo "<p><a href='$d' >$d</a><br>"; | |
| 22 | +echo "<p><a href='$d' >$d</a><br>"; | |
| 23 | 23 | echo "<img src='qr_img.php?d=$d' />"; |
| 24 | 24 | ?> |
| 25 | 25 | \ No newline at end of file | ... | ... |
pacotes/tme/TME_Engine.php
| ... | ... | @@ -171,7 +171,7 @@ class ThematicMap |
| 171 | 171 | exit("cannot open <$file>\n"); |
| 172 | 172 | } |
| 173 | 173 | */ |
| 174 | - include(__DIR__."/../kmlmapserver/classes/zip.class.php"); | |
| 174 | + include(dirname(__FILE__)."/../kmlmapserver/classes/zip.class.php"); | |
| 175 | 175 | $zip = new zipfile(); |
| 176 | 176 | // Add balloon logo to archieve (300 x 30 px) |
| 177 | 177 | $zip->addFile($this->logoline, 'files/balloonlogo.png'); | ... | ... |
pacotes/twitteroauth/config.php
| ... | ... | @@ -4,7 +4,7 @@ |
| 4 | 4 | * @file |
| 5 | 5 | * A single location to store configuration. |
| 6 | 6 | */ |
| 7 | -include("../../ms_configura.php"); | |
| 7 | +include(dirname(__FILE__)."/../../ms_configura.php"); | |
| 8 | 8 | define('CONSUMER_KEY', $twitteroauth["consumerkey"]); |
| 9 | 9 | define('CONSUMER_SECRET', $twitteroauth["consumersecret"]); |
| 10 | 10 | $protocolo = explode("/",$_SERVER['SERVER_PROTOCOL']); | ... | ... |