Commit 1b0616f38f968cd4b9f53aaf0e54742bae260820
1 parent
1a4ac69d
Exists in
master
and in
7 other branches
Otimização do uso de funções reaproveitáveis
Showing
9 changed files
with
642 additions
and
663 deletions
Show diff stats
classesphp/classe_alteraclasse.php
... | ... | @@ -4,7 +4,6 @@ Title: classe_alteraclasse.php |
4 | 4 | |
5 | 5 | Manipulação de classes e estilos de um layer |
6 | 6 | |
7 | - | |
8 | 7 | Licenca: |
9 | 8 | |
10 | 9 | GPL2 |
... | ... | @@ -241,7 +240,7 @@ $ignorar - valor que será ignorado na listagem final |
241 | 240 | function intervalosiguais($item,$nclasses,$ignorar) |
242 | 241 | { |
243 | 242 | if(!$this->layer){return "erro";} |
244 | - $valores = pegaValores($this->mapa,$this->layer,$item,true,$ignorar); | |
243 | + $valores = $this->pegaValores($this->mapa,$this->layer,$item,true,$ignorar); | |
245 | 244 | if (count($valores) > 0) |
246 | 245 | { |
247 | 246 | //calcula o menor valor e o maior valor |
... | ... | @@ -306,7 +305,7 @@ Include: |
306 | 305 | { |
307 | 306 | if(!$this->layer){return "erro";} |
308 | 307 | |
309 | - $valores = pegaValores($this->mapa,$this->layer,$item,true,$ignorar); | |
308 | + $valores = $this->pegaValores($this->mapa,$this->layer,$item,true,$ignorar); | |
310 | 309 | if (count($valores) > 0) |
311 | 310 | { |
312 | 311 | if(file_exists($this->locaplic."/classe_estatistica.php")) |
... | ... | @@ -383,11 +382,11 @@ $itemNome - item que será usado para definir os nomes das classes (por de |
383 | 382 | if($itemNome == "" || $ignorar != "") |
384 | 383 | {$itemNome = $item;} |
385 | 384 | // pega valores |
386 | - $vs = pegaValores($this->mapa,$this->layer,$item,false,$ignorar); | |
385 | + $vs = $this->pegaValores($this->mapa,$this->layer,$item,false,$ignorar); | |
387 | 386 | if ($item == $itemNome) |
388 | 387 | {$ns = $vs;} |
389 | 388 | else |
390 | - {$ns = pegaValores($this->mapa,$this->layer,$itemNome,false,$ignorar);} | |
389 | + {$ns = $this->pegaValores($this->mapa,$this->layer,$itemNome,false,$ignorar);} | |
391 | 390 | $lista = array(); |
392 | 391 | for ($i = 0; $i < count($vs); ++$i){ |
393 | 392 | $temp[$vs[$i]] = $ns[$i]; |
... | ... | @@ -700,5 +699,89 @@ $classe - id da classe |
700 | 699 | $this->layer->setMetaData("cache",""); |
701 | 700 | return("ok"); |
702 | 701 | } |
702 | + /* | |
703 | + Function: pegaValores | |
704 | + | |
705 | + Pega os valores de um item de um tema. | |
706 | + | |
707 | + Parametros: | |
708 | + | |
709 | + $layer {objeto} - Layer que será processado. | |
710 | + | |
711 | + $item {string} - Item que será processado. | |
712 | + | |
713 | + $numerico {boleano} - O item e numerico (true ou false). | |
714 | + | |
715 | + $ignorar {string} - valor que será ignorado na listagem final | |
716 | + | |
717 | + Retorno: | |
718 | + | |
719 | + {array} | |
720 | + */ | |
721 | + function pegaValores($mapa,$layer,$item,$numerico=false,$ignorar="") | |
722 | + { | |
723 | + $layer->set("template","none.htm"); | |
724 | + $layer->setfilter(""); | |
725 | + $versao = versao(); | |
726 | + $versao = $versao["principal"]; | |
727 | + $ignorararray = explode(",",$ignorar); | |
728 | + if (@$layer->queryByrect($mapa->extent) == MS_SUCCESS) | |
729 | + { | |
730 | + $sopen = $layer->open(); | |
731 | + if($sopen == MS_FAILURE){ | |
732 | + return "erro"; | |
733 | + } | |
734 | + $res_count = $layer->getNumresults(); | |
735 | + $valitem = array(); | |
736 | + for ($i=0;$i<$res_count;++$i) | |
737 | + { | |
738 | + if($versao == 6) | |
739 | + { | |
740 | + $shape = $layer->getShape($layer->getResult($i)); | |
741 | + } | |
742 | + else{ | |
743 | + $result = $layer->getResult($i); | |
744 | + $shp_index = $result->shapeindex; | |
745 | + $shape = $layer->getfeature($shp_index,-1); | |
746 | + } | |
747 | + $v = trim($shape->values[$item]); | |
748 | + if ($numerico) | |
749 | + { | |
750 | + if (is_numeric($v)) | |
751 | + { | |
752 | + if ($ignorar == "") | |
753 | + { | |
754 | + $valitem[] = $v; | |
755 | + } | |
756 | + else | |
757 | + { | |
758 | + //if ($v != $ignorar) | |
759 | + if(!in_array($v,$ignorararray)) | |
760 | + { | |
761 | + $valitem[] = $v; | |
762 | + } | |
763 | + } | |
764 | + } | |
765 | + } | |
766 | + else | |
767 | + { | |
768 | + if ($ignorar == "") | |
769 | + { | |
770 | + $valitem[] = $v; | |
771 | + } | |
772 | + else | |
773 | + { | |
774 | + if(!in_array($v,$ignorararray)) | |
775 | + { | |
776 | + $valitem[] = $v; | |
777 | + } | |
778 | + } | |
779 | + } | |
780 | + } | |
781 | + $fechou = $layer->close(); | |
782 | + } | |
783 | + $layer->close(); | |
784 | + return ($valitem); | |
785 | + } | |
703 | 786 | } |
704 | 787 | ?> |
705 | 788 | \ No newline at end of file | ... | ... |
classesphp/classe_analise.php
... | ... | @@ -102,10 +102,7 @@ $ext - Extens&atilde;o geogr&aacute;fica do mapa |
102 | 102 | { |
103 | 103 | //error_reporting(E_ALL); |
104 | 104 | $this->qyfile = str_replace(".map",".qy",$map_file); |
105 | - if(file_exists($locaplic."/funcoes_gerais.php")) | |
106 | - include_once($locaplic."/funcoes_gerais.php"); | |
107 | - else | |
108 | - include_once("funcoes_gerais.php"); | |
105 | + include_once(__DIR__."/funcoes_gerais.php"); | |
109 | 106 | $this->v = versao(); |
110 | 107 | $this->v = $this->v["principal"]; |
111 | 108 | $this->dbaseExiste = false; |
... | ... | @@ -254,14 +251,14 @@ Include: |
254 | 251 | break; |
255 | 252 | } |
256 | 253 | //cria a imagem |
257 | - $minmax = criaImagemR($nomearq); | |
254 | + $minmax = $this->criaImagemR($nomearq); | |
258 | 255 | //cria as cores |
259 | 256 | include_once("class.palette.php"); |
260 | 257 | $cori = RGB2hex(explode(",",$cori)); |
261 | 258 | $corf = RGB2hex(explode(",",$corf)); |
262 | 259 | $myPalette=new palette(array($cori,$corf),($numclasses + 1)); |
263 | 260 | //cria os parametros das classes |
264 | - $cls = classesRasterI($minmax[0],$minmax[1],$numclasses,$myPalette->colorRGB); | |
261 | + $cls = $this->classesRasterI($minmax[0],$minmax[1],$numclasses,$myPalette->colorRGB); | |
265 | 262 | if (count($cls) != $numclasses){return("erro.");} |
266 | 263 | //adiciona o novo tema |
267 | 264 | if (file_exists($nomearq.".png")) |
... | ... | @@ -447,7 +444,7 @@ $locaplic - Onde fica o I3Geo. |
447 | 444 | $rcode[] = 'cat("<br><img src=contordensidade.png />\n", file = zz)'; |
448 | 445 | $rcode[] = 'sink()'; |
449 | 446 | $rcode[] = 'close(zz)'; |
450 | - $r = executaR($rcode,$dir_tmp,$R_path); | |
447 | + $r = $this->executaR($rcode,$dir_tmp,$R_path); | |
451 | 448 | } |
452 | 449 | /* |
453 | 450 | function: mapaCluster |
... | ... | @@ -500,7 +497,7 @@ $sigma - Bandwidth for kernel smoother in "smooth" option. |
500 | 497 | $rcode[] = 'library(spatclus)'; |
501 | 498 | $rcode[] = 'RES <- clus(d1,d2,limx='.$dimx.',limy='.$dimy.',eps=0.2)'; |
502 | 499 | //var_dump($rcode); |
503 | - $r = executaR($rcode,$dir_tmp,$R_path,$gfile_name); | |
500 | + $r = $this->executaR($rcode,$dir_tmp,$R_path,$gfile_name); | |
504 | 501 | return "ok"; |
505 | 502 | } |
506 | 503 | |
... | ... | @@ -561,7 +558,7 @@ $sigma - Bandwidth for kernel smoother in "smooth" option. |
561 | 558 | $rcode[] = 'cat(img$yrange,file="'.$arqpt.'h",append=TRUE,fill=TRUE)'; |
562 | 559 | $rcode[] = 'cat(img$dim,file="'.$arqpt.'h",append=TRUE,fill=TRUE)'; |
563 | 560 | //var_dump($rcode); |
564 | - $r = executaR($rcode,$dir_tmp,$R_path,$gfile_name); | |
561 | + $r = $this->executaR($rcode,$dir_tmp,$R_path,$gfile_name); | |
565 | 562 | return "ok"; |
566 | 563 | } |
567 | 564 | /* |
... | ... | @@ -614,7 +611,7 @@ $locaplic - Onde fica o I3Geo. |
614 | 611 | $rcode[] = 'cat(img$xrange,file="'.$arqpt.'h",append=TRUE,fill=TRUE)'; |
615 | 612 | $rcode[] = 'cat(img$yrange,file="'.$arqpt.'h",append=TRUE,fill=TRUE)'; |
616 | 613 | $rcode[] = 'cat(img$dim,file="'.$arqpt.'h",append=TRUE,fill=TRUE)'; |
617 | - $r = executaR($rcode,$dir_tmp,$R_path,$gfile_name); | |
614 | + $r = $this->executaR($rcode,$dir_tmp,$R_path,$gfile_name); | |
618 | 615 | return "ok"; |
619 | 616 | } |
620 | 617 | /* |
... | ... | @@ -668,7 +665,7 @@ $locaplic - Onde fica o I3Geo. |
668 | 665 | $rcode[] = 'cat(img$xrange,file="'.$arqpt.'h",append=TRUE,fill=TRUE)'; |
669 | 666 | $rcode[] = 'cat(img$yrange,file="'.$arqpt.'h",append=TRUE,fill=TRUE)'; |
670 | 667 | $rcode[] = 'cat(img$dim,file="'.$arqpt.'h",append=TRUE,fill=TRUE)'; |
671 | - $r = executaR($rcode,$dir_tmp,$R_path,$gfile_name); | |
668 | + $r = $this->executaR($rcode,$dir_tmp,$R_path,$gfile_name); | |
672 | 669 | return "ok"; |
673 | 670 | } |
674 | 671 | /* |
... | ... | @@ -713,7 +710,7 @@ $locaplic - Onde fica o I3Geo. |
713 | 710 | $rcode[] = 'pt <- deldir(dadosx, dadosy)'; |
714 | 711 | $rcode[] = 'write.csv(pt$delsgs,file="'.$arqpt.'delsgs")'; |
715 | 712 | $rcode[] = 'write.csv(pt$dirsgs,file="'.$arqpt.'dirsgs")'; |
716 | - $r = executaR($rcode,$dir_tmp,$R_path,$gfile_name); | |
713 | + $r = $this->executaR($rcode,$dir_tmp,$R_path,$gfile_name); | |
717 | 714 | return "ok"; |
718 | 715 | } |
719 | 716 | /* |
... | ... | @@ -2733,5 +2730,141 @@ $geos - array com os dados |
2733 | 2730 | fwrite($fp,$r); |
2734 | 2731 | fclose($fp); |
2735 | 2732 | } |
2733 | +/* | |
2734 | +Function: classesRasterI | |
2735 | + | |
2736 | +Gera parâmetros para classificação de imagens. | |
2737 | + | |
2738 | +Gera a expressão e as cores para uso em classes com intervalos iguais para representação de imagens raster. | |
2739 | + | |
2740 | +Parametros: | |
2741 | + | |
2742 | +$minvalor {numeric} - Menor valor existente na série | |
2743 | + | |
2744 | +$maxvalor {numeric} - Maior valor | |
2745 | + | |
2746 | +$nclasses {numeric} - Número de classes | |
2747 | + | |
2748 | +$cores {array} - Cores. Array de array de cores cores[0] = array(r,g,b) | |
2749 | + | |
2750 | +Retorno: | |
2751 | + | |
2752 | +(start code) | |
2753 | +array( | |
2754 | + array( | |
2755 | + "nomeclasse"=>, | |
2756 | + "expressao"=>, | |
2757 | + "cores"=> | |
2758 | + ) | |
2759 | +) | |
2760 | +(end) | |
2761 | +*/ | |
2762 | +//error_reporting(0); | |
2763 | + function classesRasterI($minvalor,$maxvalor,$nclasses,$cores) | |
2764 | + { | |
2765 | + $resultado = array(); | |
2766 | + $intervalo = intval(250 / $nclasses); | |
2767 | + $trans = 250 / ($maxvalor - $minvalor); | |
2768 | + $intervalo = (($maxvalor*$trans) - ($minvalor*$trans)) / $nclasses; | |
2769 | + $conta = 0; | |
2770 | + for ($i=0; $i < $nclasses; ++$i) | |
2771 | + { | |
2772 | + $expressao = "([pixel]>=".$conta." and [pixel]<".($conta+$intervalo).")"; | |
2773 | + $nomeclasse = ">= ".($conta/$trans)." e < que ".(($conta + $intervalo)/$trans); | |
2774 | + $resultado[] = array("nomeclasse"=>$nomeclasse,"expressao"=>$expressao,"cores"=>$cores[$i]); | |
2775 | + $conta = $conta + $intervalo; | |
2776 | + } | |
2777 | + return $resultado; | |
2778 | + } | |
2779 | + function executaR($rcode,$dir_tmp,$R_path,$gfile_name="") | |
2780 | + { | |
2781 | + $R_options = "--slave --no-save"; | |
2782 | + $r_name = nomeRandomico(20); | |
2783 | + $r_input = $dir_tmp."/".$r_name.".R"; | |
2784 | + $r_output = $dir_tmp."/".$r_name.".Rout"; | |
2785 | + gravaDados($rcode,$r_input); | |
2786 | + $command = $R_path." $R_options < $r_input > $r_output"; | |
2787 | + $result = ""; | |
2788 | + $error = ""; | |
2789 | + $exec_result = exec($command,$result,$error); | |
2790 | + //corta a imagem final | |
2791 | + //include_once("classe_imagem.php"); | |
2792 | + //$m = new Imagem($dir_tmp."/".$gfile_name.".png"); | |
2793 | + //$i = $m->cortaBorda(); | |
2794 | + //imagepng($i,$dir_tmp."/".$gfile_name.".png"); | |
2795 | + return($r_input); | |
2796 | + } | |
2797 | + /* | |
2798 | + Function: criaImagemR | |
2799 | + | |
2800 | + Cria uma imagem png a partir de dados armazenados em disco. | |
2801 | + | |
2802 | + Utilizado para gerar uma imagem com base nos resultados de comandos R. | |
2803 | + | |
2804 | + O nome da imagem criada será o mesmo nome de $nomearq, porém com extensão .png | |
2805 | + | |
2806 | + Parametros: | |
2807 | + | |
2808 | + $nomearq {string} - Nome do arquivo no servidor que será utilizado para gerar a imagem. | |
2809 | + | |
2810 | + Retorno: | |
2811 | + | |
2812 | + {array($minpixel,$maxpixel)} - tamanho da imagem gerada. | |
2813 | + */ | |
2814 | + function criaImagemR($nomearq) | |
2815 | + { | |
2816 | + if (!file_exists($nomearq."img")) | |
2817 | + {return "erro";} | |
2818 | + //pega os parametros | |
2819 | + $abre = fopen($nomearq."h", "r"); | |
2820 | + while (!feof($abre)) | |
2821 | + { | |
2822 | + $buffer = fgets($abre); | |
2823 | + $pararray[] = $buffer; | |
2824 | + } | |
2825 | + fclose($abre); | |
2826 | + $xsize = $pararray[0]; | |
2827 | + $ysize = $pararray[1]; | |
2828 | + $xdim = $pararray[2]; | |
2829 | + $ydim = $pararray[3]; | |
2830 | + $wh = explode(" ",$pararray[4]); | |
2831 | + // pega os valores dos pixels | |
2832 | + $abre = fopen($nomearq."img", "r"); | |
2833 | + $buffer = fgets($abre); | |
2834 | + fclose($abre); | |
2835 | + $pixelimg = explode(" ",$buffer); | |
2836 | + $minpixel = min($pixelimg); | |
2837 | + $maxpixel = max($pixelimg); | |
2838 | + $trans = 250 / ($maxpixel - $minpixel); | |
2839 | + $img = imagecreatetruecolor($wh[0],$wh[1]); | |
2840 | + $celula = 0; | |
2841 | + for ($x = 0; $x < $wh[0]; ++$x) | |
2842 | + { | |
2843 | + for ($y = ($wh[1] - 1); $y >= 0; $y--) | |
2844 | + { | |
2845 | + $cor = imagecolorresolve($img,$pixelimg[$celula] * $trans, $pixelimg[$celula] * $trans, $pixelimg[$celula] * $trans); | |
2846 | + imagesetpixel($img, $x, $y,$cor); | |
2847 | + $celula = $celula + 1; | |
2848 | + } | |
2849 | + } | |
2850 | + Imagepng($img,$nomearq.".png"); | |
2851 | + ImageDestroy($nomearq.".png"); | |
2852 | + $dadosw[] = trim($xsize); | |
2853 | + $dadosw[] = 0; | |
2854 | + $dadosw[] = 0; | |
2855 | + $dadosw[] = trim($ysize * -1); | |
2856 | + $temp = explode(" ",$xdim); | |
2857 | + $dadosw[] = trim($temp[0]); | |
2858 | + $temp = explode(" ",$ydim); | |
2859 | + $dadosw[] = trim($temp[1]); | |
2860 | + $fp = fopen($nomearq.".wld","w"); | |
2861 | + foreach ($dadosw as $dado) | |
2862 | + { | |
2863 | + fwrite($fp,$dado."\n"); | |
2864 | + } | |
2865 | + fclose($fp); | |
2866 | + $retorno = array($minpixel,$maxpixel); | |
2867 | + return $retorno; | |
2868 | + } | |
2736 | 2869 | } |
2737 | 2870 | ?> |
2738 | 2871 | \ No newline at end of file | ... | ... |
classesphp/classe_legenda.php
... | ... | @@ -710,7 +710,7 @@ $opacidade - Opacidade |
710 | 710 | if ($this->layer->getmetadata("sld") != "") |
711 | 711 | { |
712 | 712 | $sld = $this->layer->getmetadata("sld"); |
713 | - reSLD($this->arquivo,$this->nome,$sld); | |
713 | + $this->reSLD($this->arquivo,$this->nome,$sld); | |
714 | 714 | } |
715 | 715 | $this->layer->setMetaData("cache",""); |
716 | 716 | return "ok"; |
... | ... | @@ -832,5 +832,36 @@ $width |
832 | 832 | } |
833 | 833 | return("ok"); |
834 | 834 | } |
835 | + /* | |
836 | + Function: reSLD | |
837 | + | |
838 | + Gera o SLD de um tema WMS. | |
839 | + | |
840 | + Parametros: | |
841 | + | |
842 | + $map_file {string} - arquivo map_file | |
843 | + | |
844 | + $tema {string} - código do tema | |
845 | + | |
846 | + $sld {string} - arquivo onde o sld será gravado | |
847 | + */ | |
848 | + function reSLD($map_file,$tema,$sld) | |
849 | + { | |
850 | + $map = ms_newMapObj($map_file); | |
851 | + $layer = $map->getlayerbyname($tema); | |
852 | + $layer->set("name",$layer->getmetadata("nomeoriginal")); | |
853 | + $tiporep = $layer->getmetadata("tipooriginal"); | |
854 | + $layer->set("type",MS_LAYER_POLYGON); | |
855 | + if ($tiporep == "linear") | |
856 | + {$layer->set("type",MS_LAYER_LINE);} | |
857 | + if ($tiporep == "pontual") | |
858 | + {$layer->set("type",MS_LAYER_POINT);} | |
859 | + $sldf = $layer->generateSLD(); | |
860 | + if (file_exists($sld)) | |
861 | + {unlink($sld);} | |
862 | + $fp = fopen($sld, "a"); | |
863 | + fputs( $fp, $sldf ); | |
864 | + fclose($fp); | |
865 | + } | |
835 | 866 | } |
836 | 867 | ?> |
837 | 868 | \ No newline at end of file | ... | ... |
classesphp/funcoes_gerais.php
... | ... | @@ -32,207 +32,6 @@ Arquivo: |
32 | 32 | i3geo/classesphp/funcoes_gerais.php |
33 | 33 | */ |
34 | 34 | /* |
35 | -Section: Imagens | |
36 | -*/ | |
37 | -/* | |
38 | -Function: classesRasterI | |
39 | - | |
40 | -Gera parâmetros para classificação de imagens. | |
41 | - | |
42 | -Gera a expressão e as cores para uso em classes com intervalos iguais para representação de imagens raster. | |
43 | - | |
44 | -Parametros: | |
45 | - | |
46 | -$minvalor {numeric} - Menor valor existente na série | |
47 | - | |
48 | -$maxvalor {numeric} - Maior valor | |
49 | - | |
50 | -$nclasses {numeric} - Número de classes | |
51 | - | |
52 | -$cores {array} - Cores. Array de array de cores cores[0] = array(r,g,b) | |
53 | - | |
54 | -Retorno: | |
55 | - | |
56 | -(start code) | |
57 | -array( | |
58 | - array( | |
59 | - "nomeclasse"=>, | |
60 | - "expressao"=>, | |
61 | - "cores"=> | |
62 | - ) | |
63 | -) | |
64 | -(end) | |
65 | -*/ | |
66 | -//error_reporting(0); | |
67 | -function classesRasterI($minvalor,$maxvalor,$nclasses,$cores) | |
68 | -{ | |
69 | - $resultado = array(); | |
70 | - $intervalo = intval(250 / $nclasses); | |
71 | - $trans = 250 / ($maxvalor - $minvalor); | |
72 | - $intervalo = (($maxvalor*$trans) - ($minvalor*$trans)) / $nclasses; | |
73 | - $conta = 0; | |
74 | - for ($i=0; $i < $nclasses; ++$i) | |
75 | - { | |
76 | - $expressao = "([pixel]>=".$conta." and [pixel]<".($conta+$intervalo).")"; | |
77 | - $nomeclasse = ">= ".($conta/$trans)." e < que ".(($conta + $intervalo)/$trans); | |
78 | - $resultado[] = array("nomeclasse"=>$nomeclasse,"expressao"=>$expressao,"cores"=>$cores[$i]); | |
79 | - $conta = $conta + $intervalo; | |
80 | - } | |
81 | - return $resultado; | |
82 | -} | |
83 | -/* | |
84 | -Function: fusaoGrafico | |
85 | - | |
86 | -Faz a fusao de uma imagem com outra grafico+imagem. | |
87 | - | |
88 | -Globais: | |
89 | - | |
90 | -$imagem {objeto} - imagem base, caso $map_file for "" | |
91 | - | |
92 | -$grafico {objeto} - imagem do grafico | |
93 | - | |
94 | -$dir_tmp {string} - diretorio onde estao as imagens | |
95 | - | |
96 | -$cp {CPAINT} - Objeto CPAINT | |
97 | - | |
98 | -$map_file [string} - arquivo mapfile que será utilizado para gerar a imagem base. Se for "", será utilizado a imagem definida em $imagem | |
99 | - | |
100 | -Retorno: | |
101 | - | |
102 | -{string} - endereço da imagem criada | |
103 | - | |
104 | -*/ | |
105 | -function fusaoGrafico() | |
106 | -{ | |
107 | - global $imagem,$grafico,$dir_tmp,$map_file; | |
108 | - include_once("classe_imagem.php"); | |
109 | - if($map_file != "") | |
110 | - { | |
111 | - $mapa = ms_newMapObj($map_file); | |
112 | - $imgo = $mapa->draw(); | |
113 | - $nome = ($imgo->imagepath).nomeRandomico().".png"; | |
114 | - $imgo->saveImage($nome); | |
115 | - $imagem = ($imgo->imageurl).basename($nome); | |
116 | - //$imgo->free(); | |
117 | - } | |
118 | - $m = new Imagem(dirname($dir_tmp).$imagem); | |
119 | - $i = $m->fundeIm(dirname($dir_tmp).$grafico); | |
120 | - imagepng($i,dirname($dir_tmp).$imagem); | |
121 | - return ($imagem); | |
122 | -} | |
123 | -/* | |
124 | -Section: R | |
125 | -*/ | |
126 | -/* | |
127 | -Function: executaR | |
128 | - | |
129 | -Executa comandos do R. | |
130 | - | |
131 | -Parametros: | |
132 | - | |
133 | -$rcode {array} - Código que será executado. | |
134 | - | |
135 | -$dir_tmp {string} - Diretório temporário onde ficarão os arquivos para processamento. | |
136 | - | |
137 | -$R_path {string} - Executável do R. | |
138 | - | |
139 | -$gfile_name {string} - nome da imagem que será criada | |
140 | - | |
141 | -Retorno: | |
142 | - | |
143 | -{string} - nome do arquivo com o código R que foi executado | |
144 | -*/ | |
145 | -function executaR($rcode,$dir_tmp,$R_path,$gfile_name="") | |
146 | -{ | |
147 | - $R_options = "--slave --no-save"; | |
148 | - $r_name = nomeRandomico(20); | |
149 | - $r_input = $dir_tmp."/".$r_name.".R"; | |
150 | - $r_output = $dir_tmp."/".$r_name.".Rout"; | |
151 | - gravaDados($rcode,$r_input); | |
152 | - $command = $R_path." $R_options < $r_input > $r_output"; | |
153 | - $result = ""; | |
154 | - $error = ""; | |
155 | - $exec_result = exec($command,$result,$error); | |
156 | - //corta a imagem final | |
157 | - //include_once("classe_imagem.php"); | |
158 | - //$m = new Imagem($dir_tmp."/".$gfile_name.".png"); | |
159 | - //$i = $m->cortaBorda(); | |
160 | - //imagepng($i,$dir_tmp."/".$gfile_name.".png"); | |
161 | - return($r_input); | |
162 | -} | |
163 | -/* | |
164 | -Function: criaImagemR | |
165 | - | |
166 | -Cria uma imagem png a partir de dados armazenados em disco. | |
167 | - | |
168 | -Utilizado para gerar uma imagem com base nos resultados de comandos R. | |
169 | - | |
170 | -O nome da imagem criada será o mesmo nome de $nomearq, porém com extensão .png | |
171 | - | |
172 | -Parametros: | |
173 | - | |
174 | -$nomearq {string} - Nome do arquivo no servidor que será utilizado para gerar a imagem. | |
175 | - | |
176 | -Retorno: | |
177 | - | |
178 | -{array($minpixel,$maxpixel)} - tamanho da imagem gerada. | |
179 | -*/ | |
180 | -function criaImagemR($nomearq) | |
181 | -{ | |
182 | - if (!file_exists($nomearq."img")) | |
183 | - {return "erro";} | |
184 | - //pega os parametros | |
185 | - $abre = fopen($nomearq."h", "r"); | |
186 | - while (!feof($abre)) | |
187 | - { | |
188 | - $buffer = fgets($abre); | |
189 | - $pararray[] = $buffer; | |
190 | - } | |
191 | - fclose($abre); | |
192 | - $xsize = $pararray[0]; | |
193 | - $ysize = $pararray[1]; | |
194 | - $xdim = $pararray[2]; | |
195 | - $ydim = $pararray[3]; | |
196 | - $wh = explode(" ",$pararray[4]); | |
197 | - // pega os valores dos pixels | |
198 | - $abre = fopen($nomearq."img", "r"); | |
199 | - $buffer = fgets($abre); | |
200 | - fclose($abre); | |
201 | - $pixelimg = explode(" ",$buffer); | |
202 | - $minpixel = min($pixelimg); | |
203 | - $maxpixel = max($pixelimg); | |
204 | - $trans = 250 / ($maxpixel - $minpixel); | |
205 | - $img = imagecreatetruecolor($wh[0],$wh[1]); | |
206 | - $celula = 0; | |
207 | - for ($x = 0; $x < $wh[0]; ++$x) | |
208 | - { | |
209 | - for ($y = ($wh[1] - 1); $y >= 0; $y--) | |
210 | - { | |
211 | - $cor = imagecolorresolve($img,$pixelimg[$celula] * $trans, $pixelimg[$celula] * $trans, $pixelimg[$celula] * $trans); | |
212 | - imagesetpixel($img, $x, $y,$cor); | |
213 | - $celula = $celula + 1; | |
214 | - } | |
215 | - } | |
216 | - Imagepng($img,$nomearq.".png"); | |
217 | - ImageDestroy($nomearq.".png"); | |
218 | - $dadosw[] = trim($xsize); | |
219 | - $dadosw[] = 0; | |
220 | - $dadosw[] = 0; | |
221 | - $dadosw[] = trim($ysize * -1); | |
222 | - $temp = explode(" ",$xdim); | |
223 | - $dadosw[] = trim($temp[0]); | |
224 | - $temp = explode(" ",$ydim); | |
225 | - $dadosw[] = trim($temp[1]); | |
226 | - $fp = fopen($nomearq.".wld","w"); | |
227 | - foreach ($dadosw as $dado) | |
228 | - { | |
229 | - fwrite($fp,$dado."\n"); | |
230 | - } | |
231 | - fclose($fp); | |
232 | - $retorno = array($minpixel,$maxpixel); | |
233 | - return $retorno; | |
234 | -} | |
235 | -/* | |
236 | 35 | Section: cor |
237 | 36 | */ |
238 | 37 | /* |
... | ... | @@ -1016,7 +815,7 @@ function desligamargem($objmapa) |
1016 | 815 | return $objmapa; |
1017 | 816 | } |
1018 | 817 | /* |
1019 | -Function: desligaTemas | |
818 | +Function: desligaTemas (depreciado na versao 4.7) | |
1020 | 819 | |
1021 | 820 | Desliga todos os temas de um mapa. |
1022 | 821 | |
... | ... | @@ -1097,281 +896,6 @@ function gravaImagemMapa($mapa) |
1097 | 896 | Section: atributos |
1098 | 897 | */ |
1099 | 898 | /* |
1100 | -Function: pegaValores | |
1101 | - | |
1102 | -Pega os valores de um item de um tema. | |
1103 | - | |
1104 | -Parametros: | |
1105 | - | |
1106 | -$layer {objeto} - Layer que será processado. | |
1107 | - | |
1108 | -$item {string} - Item que será processado. | |
1109 | - | |
1110 | -$numerico {boleano} - O item e numerico (true ou false). | |
1111 | - | |
1112 | -$ignorar {string} - valor que será ignorado na listagem final | |
1113 | - | |
1114 | -Retorno: | |
1115 | - | |
1116 | -{array} | |
1117 | -*/ | |
1118 | -function pegaValores($mapa,$layer,$item,$numerico=false,$ignorar="") | |
1119 | -{ | |
1120 | - $layer->set("template","none.htm"); | |
1121 | - $layer->setfilter(""); | |
1122 | - $versao = versao(); | |
1123 | - $versao = $versao["principal"]; | |
1124 | - $ignorararray = explode(",",$ignorar); | |
1125 | - if (@$layer->queryByrect($mapa->extent) == MS_SUCCESS) | |
1126 | - { | |
1127 | - $sopen = $layer->open(); | |
1128 | - if($sopen == MS_FAILURE){ | |
1129 | - return "erro"; | |
1130 | - } | |
1131 | - $res_count = $layer->getNumresults(); | |
1132 | - $valitem = array(); | |
1133 | - for ($i=0;$i<$res_count;++$i) | |
1134 | - { | |
1135 | - if($versao == 6) | |
1136 | - { | |
1137 | - $shape = $layer->getShape($layer->getResult($i)); | |
1138 | - } | |
1139 | - else{ | |
1140 | - $result = $layer->getResult($i); | |
1141 | - $shp_index = $result->shapeindex; | |
1142 | - $shape = $layer->getfeature($shp_index,-1); | |
1143 | - } | |
1144 | - $v = trim($shape->values[$item]); | |
1145 | - if ($numerico) | |
1146 | - { | |
1147 | - if (is_numeric($v)) | |
1148 | - { | |
1149 | - if ($ignorar == "") | |
1150 | - { | |
1151 | - $valitem[] = $v; | |
1152 | - } | |
1153 | - else | |
1154 | - { | |
1155 | - //if ($v != $ignorar) | |
1156 | - if(!in_array($v,$ignorararray)) | |
1157 | - { | |
1158 | - $valitem[] = $v; | |
1159 | - } | |
1160 | - } | |
1161 | - } | |
1162 | - } | |
1163 | - else | |
1164 | - { | |
1165 | - if ($ignorar == "") | |
1166 | - { | |
1167 | - $valitem[] = $v; | |
1168 | - } | |
1169 | - else | |
1170 | - { | |
1171 | - if(!in_array($v,$ignorararray)) | |
1172 | - { | |
1173 | - $valitem[] = $v; | |
1174 | - } | |
1175 | - } | |
1176 | - } | |
1177 | - } | |
1178 | - $fechou = $layer->close(); | |
1179 | - } | |
1180 | - $layer->close(); | |
1181 | - return ($valitem); | |
1182 | -} | |
1183 | -/* | |
1184 | -Function: pegaValoresM | |
1185 | - | |
1186 | -Pega os valores de múltiplos itens de um tema. | |
1187 | - | |
1188 | -Se for passado apenas um item, o array de retorno será unidimensional. | |
1189 | - | |
1190 | -Parametros: | |
1191 | - | |
1192 | -$layer {objeto} - Layer que será processado. | |
1193 | - | |
1194 | -$itens {array} - Itens que serão processados. | |
1195 | - | |
1196 | -$exclui {string} - O registro não será considerado se um dos valores for igual a esse valor. | |
1197 | - | |
1198 | -$selecionados {string} - sim|nao Utiliza apenas os selecionados ou todos | |
1199 | - | |
1200 | -$chaves {boolean} - inclui ou não os nomes dos itens como chave no array resultante | |
1201 | - | |
1202 | -$centroide {boolean} - captura ou não o WKT com o centroide do elemento | |
1203 | - | |
1204 | -Retorno: | |
1205 | - | |
1206 | -{array} | |
1207 | -*/ | |
1208 | -function pegaValoresM($mapa,$layer,$itens,$exclui="nulo",$selecionados="nao",$chaves=false,$centroide=false) | |
1209 | -{ | |
1210 | - $versao = versao(); | |
1211 | - $versao = $versao["principal"]; | |
1212 | - $prjMapa = $mapa->getProjection(); | |
1213 | - $prjTema = $layer->getProjection(); | |
1214 | - $layer->set("template","none.htm"); | |
1215 | - $layer->setfilter(""); | |
1216 | - | |
1217 | - $indicesel = array(); | |
1218 | - //pega os valores dos indices dos elementos selecionados para comparacao posterior | |
1219 | - if ($selecionados == "sim") | |
1220 | - { | |
1221 | - $sopen = $layer->open(); | |
1222 | - if($sopen == MS_FAILURE){return "erro";} | |
1223 | - $res_count = $layer->getNumresults(); | |
1224 | - for ($i = 0; $i < $res_count; ++$i) | |
1225 | - { | |
1226 | - $result = $layer->getResult($i); | |
1227 | - $indicesel[] = $result->shapeindex; | |
1228 | - } | |
1229 | - $layer->close(); | |
1230 | - } | |
1231 | - $valores = array(); | |
1232 | - $nclasses = $layer->numclasses; | |
1233 | - if (@$layer->queryByrect($mapa->extent) == MS_SUCCESS) | |
1234 | - { | |
1235 | - //$layer->draw(); | |
1236 | - $sopen = $layer->open(); | |
1237 | - if($sopen == MS_FAILURE){return "erro";} | |
1238 | - $res_count = $layer->getNumresults(); | |
1239 | - | |
1240 | - for ($i=0;$i<$res_count;++$i) | |
1241 | - { | |
1242 | - if($versao == 6){ | |
1243 | - $shape = $layer->getShape($layer->getResult($i)); | |
1244 | - $shp_index = $shape->index; | |
1245 | - } | |
1246 | - else{ | |
1247 | - $result = $layer->getResult($i); | |
1248 | - $shp_index = $result->shapeindex; | |
1249 | - $shape = $layer->getfeature($shp_index,-1); | |
1250 | - } | |
1251 | - if (($selecionados == "sim") && (array_search($shp_index,$indicesel) === FALSE)) | |
1252 | - {continue;} | |
1253 | - $considera = "sim"; | |
1254 | - //verifica se no registro deve ser considerado | |
1255 | - if ($exclui != "nulo") | |
1256 | - { | |
1257 | - foreach ($itens as $item) | |
1258 | - {if($shape->values[$item] == $exclui){$considera = "nao";}} | |
1259 | - } | |
1260 | - //pega os valores | |
1261 | - $v = array(); | |
1262 | - if ($considera == "sim") | |
1263 | - { | |
1264 | - foreach ($itens as $item){ | |
1265 | - if($chaves == false) | |
1266 | - {$v[] = $shape->values[$item];} | |
1267 | - else | |
1268 | - {$v[$item] = $shape->values[$item];} | |
1269 | - } | |
1270 | - if($centroide == true){ | |
1271 | - $c = $shape->getCentroid(); | |
1272 | - if (($prjTema != "") && ($prjMapa != $prjTema)) | |
1273 | - { | |
1274 | - $projOutObj = ms_newprojectionobj($prjTema); | |
1275 | - $projInObj = ms_newprojectionobj($prjMapa); | |
1276 | - $c->project($projInObj, $projOutObj); | |
1277 | - } | |
1278 | - $v["centroide"] = "POINT(".$c->x." ".$c->y.")"; | |
1279 | - } | |
1280 | - if($nclasses > 0){ | |
1281 | - $classe = $layer->getclass($shape->classindex); | |
1282 | - $cor = $classe->getstyle(0)->color; | |
1283 | - $v["cores"] = $cor->red." ".$cor->green." ".$cor->blue; | |
1284 | - } | |
1285 | - if (count($v) == 1) | |
1286 | - {$valores[] = $v[0];} | |
1287 | - else | |
1288 | - {$valores[] = $v;} | |
1289 | - } | |
1290 | - } | |
1291 | - $layer->close(); | |
1292 | - } | |
1293 | - return ($valores); | |
1294 | -} | |
1295 | -/* | |
1296 | -Function: agrupaValores | |
1297 | - | |
1298 | -Agrupa os valores de um array por um método de cálculo. | |
1299 | - | |
1300 | -No caso de soma e média, será considerado apenas um item e uma chave. | |
1301 | - | |
1302 | -Parametros: | |
1303 | - | |
1304 | -$lista {array} - Lista com os arrays contendo os dados que serão processados. | |
1305 | - | |
1306 | -$indiceChave {string} - Índice do array da lista que será considerado como a chave do array. | |
1307 | - | |
1308 | -$indiceValor {string} - Índice do array da lista que será considerado como o valor. | |
1309 | - | |
1310 | -$tipo {string} - Tipo de processamento soma|media|contagem|nenhum. | |
1311 | - | |
1312 | -Retorno: | |
1313 | - | |
1314 | -{array} | |
1315 | -*/ | |
1316 | -function agrupaValores($lista,$indiceChave,$indiceValor,$tipo) | |
1317 | -{ | |
1318 | - $valores = null; | |
1319 | - foreach ($lista as $linha) | |
1320 | - { | |
1321 | - $c = $linha[$indiceChave]; | |
1322 | - $v = $linha[$indiceValor]; | |
1323 | - if ($tipo == "conta") | |
1324 | - { | |
1325 | - if(@$valores[$c]) | |
1326 | - $valores[$c] = $valores[$c] + 1; | |
1327 | - else | |
1328 | - $valores[$c] = 1; | |
1329 | - } | |
1330 | - if (($tipo == "soma")) | |
1331 | - { | |
1332 | - if (($v != "") && (is_numeric($v))) | |
1333 | - { | |
1334 | - if(@$valores[$c]) | |
1335 | - $valores[$c] = $valores[$c] + $v; | |
1336 | - else | |
1337 | - $valores[$c] = $v; | |
1338 | - } | |
1339 | - } | |
1340 | - if ($tipo == "media") | |
1341 | - { | |
1342 | - if (($v != "") && (is_numeric($v))) | |
1343 | - { | |
1344 | - if(@$soma[$c]) | |
1345 | - $soma[$c] = $soma[$c] + $v; | |
1346 | - else | |
1347 | - $soma[$c] = $v; | |
1348 | - | |
1349 | - if(@$conta[$c]) | |
1350 | - $conta[$c] = $conta[$c] + 1; | |
1351 | - else | |
1352 | - $conta[$c] = 1; | |
1353 | - } | |
1354 | - } | |
1355 | - if ($tipo == "nenhum") | |
1356 | - { | |
1357 | - //if (($v != "") && (is_numeric($v))) | |
1358 | - //{ | |
1359 | - $valoresn[] = $v; | |
1360 | - //} | |
1361 | - $valores = $valoresn; | |
1362 | - } | |
1363 | - } | |
1364 | - if ($tipo == "media") | |
1365 | - { | |
1366 | - $chaves = array_keys($conta); | |
1367 | - foreach ($chaves as $c) | |
1368 | - { | |
1369 | - $valores[$c] = $soma[$c] / $conta[$c]; | |
1370 | - } | |
1371 | - } | |
1372 | - return ($valores); | |
1373 | -} | |
1374 | -/* | |
1375 | 899 | Function: pegaItens |
1376 | 900 | |
1377 | 901 | Pega os itens da tabela de atributos de um tema. |
... | ... | @@ -1566,7 +1090,6 @@ function imagem2xy($map_file,$xy) |
1566 | 1090 | $y = ($e->maxy) - $xy[1] * $c; |
1567 | 1091 | return array($x,$y); |
1568 | 1092 | } |
1569 | - | |
1570 | 1093 | /* |
1571 | 1094 | Function: xy2wkt |
1572 | 1095 | |
... | ... | @@ -1675,37 +1198,6 @@ function geo2utm($x,$y,$zona) |
1675 | 1198 | Section: web services |
1676 | 1199 | */ |
1677 | 1200 | /* |
1678 | -Function: reSLD | |
1679 | - | |
1680 | -Gera o SLD de um tema WMS. | |
1681 | - | |
1682 | -Parametros: | |
1683 | - | |
1684 | -$map_file {string} - arquivo map_file | |
1685 | - | |
1686 | -$tema {string} - código do tema | |
1687 | - | |
1688 | -$sld {string} - arquivo onde o sld será gravado | |
1689 | -*/ | |
1690 | -function reSLD($map_file,$tema,$sld) | |
1691 | -{ | |
1692 | - $map = ms_newMapObj($map_file); | |
1693 | - $layer = $map->getlayerbyname($tema); | |
1694 | - $layer->set("name",$layer->getmetadata("nomeoriginal")); | |
1695 | - $tiporep = $layer->getmetadata("tipooriginal"); | |
1696 | - $layer->set("type",MS_LAYER_POLYGON); | |
1697 | - if ($tiporep == "linear") | |
1698 | - {$layer->set("type",MS_LAYER_LINE);} | |
1699 | - if ($tiporep == "pontual") | |
1700 | - {$layer->set("type",MS_LAYER_POINT);} | |
1701 | - $sldf = $layer->generateSLD(); | |
1702 | - if (file_exists($sld)) | |
1703 | - {unlink($sld);} | |
1704 | - $fp = fopen($sld, "a"); | |
1705 | - fputs( $fp, $sldf ); | |
1706 | - fclose($fp); | |
1707 | -} | |
1708 | -/* | |
1709 | 1201 | georssCanais (depreciado) |
1710 | 1202 | |
1711 | 1203 | Lista os canais de um GeoRss. |
... | ... | @@ -2644,50 +2136,6 @@ function removeAcentos($var) |
2644 | 2136 | return str_replace($a, $b, $var); |
2645 | 2137 | } |
2646 | 2138 | /* |
2647 | -Function: criaDirMapa | |
2648 | - | |
2649 | -Cria os diretórios temporários para a aplicação. | |
2650 | - | |
2651 | -Parametro: | |
2652 | - | |
2653 | -$dir_tmp {string} - Diretório temporário (no servidor) utilizado pelo mapserver. | |
2654 | - | |
2655 | -$$cachedir {string} - Diretório de cache temporário definido no ms_configura.php | |
2656 | - | |
2657 | -Retorno: | |
2658 | - | |
2659 | -{boleano} | |
2660 | -*/ | |
2661 | -function criaDirMapa($dir_tmp,$cachedir="") | |
2662 | -{ | |
2663 | - if(!file_exists($dir_tmp)){ | |
2664 | - @mkdir ($dir_tmp,0777); | |
2665 | - } | |
2666 | - if(file_exists($dir_tmp)) | |
2667 | - { | |
2668 | - $tmpdirname = nomeRandomico(); | |
2669 | - $crdir = @mkdir ($dir_tmp."/".$tmpdirname,0777); | |
2670 | - $crdiri = @mkdir ($dir_tmp."/img".$tmpdirname,0777); | |
2671 | - $mapfile = $dir_tmp."/".$tmpdirname."/".$tmpdirname.".map"; | |
2672 | - $tmpimgname = "img".$tmpdirname; | |
2673 | - @mkdir($dir_tmp."/comum",0777); | |
2674 | - if($cachedir == ""){ | |
2675 | - @mkdir($dir_tmp."/cache",0777); | |
2676 | - @mkdir($dir_tmp."/cache/googlemaps",0777); | |
2677 | - } | |
2678 | - else{ | |
2679 | - @mkdir($cachedir,0777); | |
2680 | - @mkdir($cachedir."/googlemaps",0777); | |
2681 | - } | |
2682 | - if(file_exists($dir_tmp."/".$tmpdirname)) | |
2683 | - return array($mapfile,$tmpdirname,$tmpimgname); | |
2684 | - else | |
2685 | - {return false;} | |
2686 | - } | |
2687 | - else | |
2688 | - {return false;} | |
2689 | -} | |
2690 | -/* | |
2691 | 2139 | Function: array2json |
2692 | 2140 | |
2693 | 2141 | Converte um array em uma string no formato JSON. Utiliza as funções nativas do PHP para gerar o objeto. |
... | ... | @@ -2867,6 +2315,7 @@ Return: |
2867 | 2315 | |
2868 | 2316 | {string} - sim|nao |
2869 | 2317 | */ |
2318 | +//TODO remover | |
2870 | 2319 | function verificaEditores($editores) |
2871 | 2320 | { |
2872 | 2321 | if (strtolower($_SERVER['HTTP_HOST']) == "localhost") |
... | ... | @@ -2989,67 +2438,6 @@ function retornaShapesSelecionados($objLayer,$map_file,$objMapa){ |
2989 | 2438 | return $shapes; |
2990 | 2439 | } |
2991 | 2440 | /* |
2992 | -Function: permissoesarquivo | |
2993 | - | |
2994 | -Retorna as permissões de um arquivo | |
2995 | - | |
2996 | -Parametros: | |
2997 | - | |
2998 | -$arquivo | |
2999 | -*/ | |
3000 | -function permissoesarquivo($arquivo){ | |
3001 | - $perms = fileperms($arquivo); | |
3002 | - | |
3003 | - if (($perms & 0xC000) == 0xC000) { | |
3004 | - // Socket | |
3005 | - $info = 's'; | |
3006 | - } elseif (($perms & 0xA000) == 0xA000) { | |
3007 | - // Symbolic Link | |
3008 | - $info = 'l'; | |
3009 | - } elseif (($perms & 0x8000) == 0x8000) { | |
3010 | - // Regular | |
3011 | - $info = '-'; | |
3012 | - } elseif (($perms & 0x6000) == 0x6000) { | |
3013 | - // Block special | |
3014 | - $info = 'b'; | |
3015 | - } elseif (($perms & 0x4000) == 0x4000) { | |
3016 | - // Directory | |
3017 | - $info = 'd'; | |
3018 | - } elseif (($perms & 0x2000) == 0x2000) { | |
3019 | - // Character special | |
3020 | - $info = 'c'; | |
3021 | - } elseif (($perms & 0x1000) == 0x1000) { | |
3022 | - // FIFO pipe | |
3023 | - $info = 'p'; | |
3024 | - } else { | |
3025 | - // Unknown | |
3026 | - $info = 'u'; | |
3027 | - } | |
3028 | - | |
3029 | - // Owner | |
3030 | - $info .= (($perms & 0x0100) ? 'r' : '-'); | |
3031 | - $info .= (($perms & 0x0080) ? 'w' : '-'); | |
3032 | - $info .= (($perms & 0x0040) ? | |
3033 | - (($perms & 0x0800) ? 's' : 'x' ) : | |
3034 | - (($perms & 0x0800) ? 'S' : '-')); | |
3035 | - | |
3036 | - // Group | |
3037 | - $info .= (($perms & 0x0020) ? 'r' : '-'); | |
3038 | - $info .= (($perms & 0x0010) ? 'w' : '-'); | |
3039 | - $info .= (($perms & 0x0008) ? | |
3040 | - (($perms & 0x0400) ? 's' : 'x' ) : | |
3041 | - (($perms & 0x0400) ? 'S' : '-')); | |
3042 | - | |
3043 | - // World | |
3044 | - $info .= (($perms & 0x0004) ? 'r' : '-'); | |
3045 | - $info .= (($perms & 0x0002) ? 'w' : '-'); | |
3046 | - $info .= (($perms & 0x0001) ? | |
3047 | - (($perms & 0x0200) ? 't' : 'x' ) : | |
3048 | - (($perms & 0x0200) ? 'T' : '-')); | |
3049 | - | |
3050 | - return $info; | |
3051 | -} | |
3052 | -/* | |
3053 | 2441 | Function: validaAcessoTemas |
3054 | 2442 | |
3055 | 2443 | Remocao dos layers com restricoes de acesso registradas no sistema de controle de usuarios | ... | ... |
classesphp/graficos.php
... | ... | @@ -580,4 +580,234 @@ function dadosPerfilRelevo($pontos,$opcao,$amostragem,$item="",$map_file=""){ |
580 | 580 | } |
581 | 581 | return $result; |
582 | 582 | } |
583 | +/* | |
584 | +Function: executaR | |
585 | + | |
586 | +Executa comandos do R. | |
587 | + | |
588 | +Parametros: | |
589 | + | |
590 | +$rcode {array} - Código que será executado. | |
591 | + | |
592 | +$dir_tmp {string} - Diretório temporário onde ficarão os arquivos para processamento. | |
593 | + | |
594 | +$R_path {string} - Executável do R. | |
595 | + | |
596 | +$gfile_name {string} - nome da imagem que será criada | |
597 | + | |
598 | +Retorno: | |
599 | + | |
600 | +{string} - nome do arquivo com o código R que foi executado | |
601 | +*/ | |
602 | + | |
603 | +function executaR($rcode,$dir_tmp,$R_path,$gfile_name="") | |
604 | +{ | |
605 | + $R_options = "--slave --no-save"; | |
606 | + $r_name = nomeRandomico(20); | |
607 | + $r_input = $dir_tmp."/".$r_name.".R"; | |
608 | + $r_output = $dir_tmp."/".$r_name.".Rout"; | |
609 | + gravaDados($rcode,$r_input); | |
610 | + $command = $R_path." $R_options < $r_input > $r_output"; | |
611 | + $result = ""; | |
612 | + $error = ""; | |
613 | + $exec_result = exec($command,$result,$error); | |
614 | + //corta a imagem final | |
615 | + //include_once("classe_imagem.php"); | |
616 | + //$m = new Imagem($dir_tmp."/".$gfile_name.".png"); | |
617 | + //$i = $m->cortaBorda(); | |
618 | + //imagepng($i,$dir_tmp."/".$gfile_name.".png"); | |
619 | + return($r_input); | |
620 | +} | |
621 | +/* | |
622 | +Function: pegaValoresM | |
623 | + | |
624 | +Pega os valores de múltiplos itens de um tema. | |
625 | + | |
626 | +Se for passado apenas um item, o array de retorno será unidimensional. | |
627 | + | |
628 | +Parametros: | |
629 | + | |
630 | +$layer {objeto} - Layer que será processado. | |
631 | + | |
632 | +$itens {array} - Itens que serão processados. | |
633 | + | |
634 | +$exclui {string} - O registro não será considerado se um dos valores for igual a esse valor. | |
635 | + | |
636 | +$selecionados {string} - sim|nao Utiliza apenas os selecionados ou todos | |
637 | + | |
638 | +$chaves {boolean} - inclui ou não os nomes dos itens como chave no array resultante | |
639 | + | |
640 | +$centroide {boolean} - captura ou não o WKT com o centroide do elemento | |
641 | + | |
642 | +Retorno: | |
643 | + | |
644 | +{array} | |
645 | +*/ | |
646 | +function pegaValoresM($mapa,$layer,$itens,$exclui="nulo",$selecionados="nao",$chaves=false,$centroide=false) | |
647 | +{ | |
648 | + $versao = versao(); | |
649 | + $versao = $versao["principal"]; | |
650 | + $prjMapa = $mapa->getProjection(); | |
651 | + $prjTema = $layer->getProjection(); | |
652 | + $layer->set("template","none.htm"); | |
653 | + $layer->setfilter(""); | |
654 | + | |
655 | + $indicesel = array(); | |
656 | + //pega os valores dos indices dos elementos selecionados para comparacao posterior | |
657 | + if ($selecionados == "sim") | |
658 | + { | |
659 | + $sopen = $layer->open(); | |
660 | + if($sopen == MS_FAILURE){return "erro";} | |
661 | + $res_count = $layer->getNumresults(); | |
662 | + for ($i = 0; $i < $res_count; ++$i) | |
663 | + { | |
664 | + $result = $layer->getResult($i); | |
665 | + $indicesel[] = $result->shapeindex; | |
666 | + } | |
667 | + $layer->close(); | |
668 | + } | |
669 | + $valores = array(); | |
670 | + $nclasses = $layer->numclasses; | |
671 | + if (@$layer->queryByrect($mapa->extent) == MS_SUCCESS) | |
672 | + { | |
673 | + //$layer->draw(); | |
674 | + $sopen = $layer->open(); | |
675 | + if($sopen == MS_FAILURE){return "erro";} | |
676 | + $res_count = $layer->getNumresults(); | |
677 | + | |
678 | + for ($i=0;$i<$res_count;++$i) | |
679 | + { | |
680 | + if($versao == 6){ | |
681 | + $shape = $layer->getShape($layer->getResult($i)); | |
682 | + $shp_index = $shape->index; | |
683 | + } | |
684 | + else{ | |
685 | + $result = $layer->getResult($i); | |
686 | + $shp_index = $result->shapeindex; | |
687 | + $shape = $layer->getfeature($shp_index,-1); | |
688 | + } | |
689 | + if (($selecionados == "sim") && (array_search($shp_index,$indicesel) === FALSE)) | |
690 | + {continue;} | |
691 | + $considera = "sim"; | |
692 | + //verifica se no registro deve ser considerado | |
693 | + if ($exclui != "nulo") | |
694 | + { | |
695 | + foreach ($itens as $item) | |
696 | + {if($shape->values[$item] == $exclui){$considera = "nao";}} | |
697 | + } | |
698 | + //pega os valores | |
699 | + $v = array(); | |
700 | + if ($considera == "sim") | |
701 | + { | |
702 | + foreach ($itens as $item){ | |
703 | + if($chaves == false) | |
704 | + {$v[] = $shape->values[$item];} | |
705 | + else | |
706 | + {$v[$item] = $shape->values[$item];} | |
707 | + } | |
708 | + if($centroide == true){ | |
709 | + $c = $shape->getCentroid(); | |
710 | + if (($prjTema != "") && ($prjMapa != $prjTema)) | |
711 | + { | |
712 | + $projOutObj = ms_newprojectionobj($prjTema); | |
713 | + $projInObj = ms_newprojectionobj($prjMapa); | |
714 | + $c->project($projInObj, $projOutObj); | |
715 | + } | |
716 | + $v["centroide"] = "POINT(".$c->x." ".$c->y.")"; | |
717 | + } | |
718 | + if($nclasses > 0){ | |
719 | + $classe = $layer->getclass($shape->classindex); | |
720 | + $cor = $classe->getstyle(0)->color; | |
721 | + $v["cores"] = $cor->red." ".$cor->green." ".$cor->blue; | |
722 | + } | |
723 | + if (count($v) == 1) | |
724 | + {$valores[] = $v[0];} | |
725 | + else | |
726 | + {$valores[] = $v;} | |
727 | + } | |
728 | + } | |
729 | + $layer->close(); | |
730 | + } | |
731 | + return ($valores); | |
732 | +} | |
733 | +/* | |
734 | +Function: agrupaValores | |
735 | + | |
736 | +Agrupa os valores de um array por um método de cálculo. | |
737 | + | |
738 | +No caso de soma e média, será considerado apenas um item e uma chave. | |
739 | + | |
740 | +Parametros: | |
741 | + | |
742 | +$lista {array} - Lista com os arrays contendo os dados que serão processados. | |
743 | + | |
744 | +$indiceChave {string} - Índice do array da lista que será considerado como a chave do array. | |
745 | + | |
746 | +$indiceValor {string} - Índice do array da lista que será considerado como o valor. | |
747 | + | |
748 | +$tipo {string} - Tipo de processamento soma|media|contagem|nenhum. | |
749 | + | |
750 | +Retorno: | |
751 | + | |
752 | +{array} | |
753 | +*/ | |
754 | +function agrupaValores($lista,$indiceChave,$indiceValor,$tipo) | |
755 | +{ | |
756 | + $valores = null; | |
757 | + foreach ($lista as $linha) | |
758 | + { | |
759 | + $c = $linha[$indiceChave]; | |
760 | + $v = $linha[$indiceValor]; | |
761 | + if ($tipo == "conta") | |
762 | + { | |
763 | + if(@$valores[$c]) | |
764 | + $valores[$c] = $valores[$c] + 1; | |
765 | + else | |
766 | + $valores[$c] = 1; | |
767 | + } | |
768 | + if (($tipo == "soma")) | |
769 | + { | |
770 | + if (($v != "") && (is_numeric($v))) | |
771 | + { | |
772 | + if(@$valores[$c]) | |
773 | + $valores[$c] = $valores[$c] + $v; | |
774 | + else | |
775 | + $valores[$c] = $v; | |
776 | + } | |
777 | + } | |
778 | + if ($tipo == "media") | |
779 | + { | |
780 | + if (($v != "") && (is_numeric($v))) | |
781 | + { | |
782 | + if(@$soma[$c]) | |
783 | + $soma[$c] = $soma[$c] + $v; | |
784 | + else | |
785 | + $soma[$c] = $v; | |
786 | + | |
787 | + if(@$conta[$c]) | |
788 | + $conta[$c] = $conta[$c] + 1; | |
789 | + else | |
790 | + $conta[$c] = 1; | |
791 | + } | |
792 | + } | |
793 | + if ($tipo == "nenhum") | |
794 | + { | |
795 | + //if (($v != "") && (is_numeric($v))) | |
796 | + //{ | |
797 | + $valoresn[] = $v; | |
798 | + //} | |
799 | + $valores = $valoresn; | |
800 | + } | |
801 | + } | |
802 | + if ($tipo == "media") | |
803 | + { | |
804 | + $chaves = array_keys($conta); | |
805 | + foreach ($chaves as $c) | |
806 | + { | |
807 | + $valores[$c] = $soma[$c] / $conta[$c]; | |
808 | + } | |
809 | + } | |
810 | + return ($valores); | |
811 | +} | |
812 | + | |
583 | 813 | ?> |
584 | 814 | \ No newline at end of file | ... | ... |
classesphp/mapa_controle.php
... | ... | @@ -1802,10 +1802,20 @@ Faz a fus&atilde;o da imagem de um gr&aacute;fico com a imagem do mapa atual. |
1802 | 1802 | */ |
1803 | 1803 | case "FUSAOGRAFICO": |
1804 | 1804 | include_once("graficos.php"); |
1805 | - //$_SESSION["utilizacgi"] = "nao"; | |
1806 | - //$utilizacgi = "nao"; | |
1807 | 1805 | restauraCon($map_file,$postgis_mapa); |
1808 | - $retorno = fusaoGrafico(); | |
1806 | + include_once("classe_imagem.php"); | |
1807 | + if($map_file != "") | |
1808 | + { | |
1809 | + $mapa = ms_newMapObj($map_file); | |
1810 | + $imgo = $mapa->draw(); | |
1811 | + $nome = ($imgo->imagepath).nomeRandomico().".png"; | |
1812 | + $imgo->saveImage($nome); | |
1813 | + $imagem = ($imgo->imageurl).basename($nome); | |
1814 | + } | |
1815 | + $m = new Imagem(dirname($dir_tmp).$imagem); | |
1816 | + $i = $m->fundeIm(dirname($dir_tmp).$grafico); | |
1817 | + imagepng($i,dirname($dir_tmp).$imagem); | |
1818 | + $retorno = $imagem; | |
1809 | 1819 | break; |
1810 | 1820 | /* |
1811 | 1821 | Valor: GRAFICOESTRELA | ... | ... |
guia_de_migracao.txt
... | ... | @@ -26,6 +26,17 @@ Para a versão 4.7 |
26 | 26 | - Os layers com a ZEE e base raster do MMA foram removidos dos mapfiles de inicialização |
27 | 27 | - ms_configura.php |
28 | 28 | - Nova variável de configuração para indicar o local das bibliotecas adicionais do software R: R_libpath |
29 | +- Funções removidas de classesphp/funcoes_gerais.php e inseridas nos respectivos programas que as chamam: | |
30 | + classesRasterI | |
31 | + fusaoGrafico | |
32 | + executaR | |
33 | + criaImagemR | |
34 | + pegaValores | |
35 | + pegaValoresM | |
36 | + agrupaValores | |
37 | + reSLD | |
38 | + criaDirMapa | |
39 | + permissoesarquivo | |
29 | 40 | ------------------------------------------------------------------------------------------------- |
30 | 41 | Para a versão 4.6 |
31 | 42 | ... | ... |
ms_criamapa.php
... | ... | @@ -83,7 +83,7 @@ interface - nome da interface que ser&aacute; utilizada para abrir o mapa. As in |
83 | 83 | |
84 | 84 | perfil - perfil utilizado para restringir os menus de temas. ms_criamapa.php?perfil=usuário1 |
85 | 85 | |
86 | -caminho - caminho para os programas que serão incluídos com "include". Ao chamar o programa ms_criamapa.php por meio de "include" é necessário especificar essa variável para indicar o caminho correto do i3geo. | |
86 | +caminho - caminho relativo que indica o local onde a interface do mapa esta localizada. | |
87 | 87 | |
88 | 88 | pontos - lista de coordenadas x e y que serão adicionadas como pontos no mapa. |
89 | 89 | |
... | ... | @@ -130,14 +130,6 @@ gvsiggvp - endere&ccedil;o no servidor do arquivo de projeto gvSig (gvp) que ser |
130 | 130 | gvsigview - nome da view do projeto gvSig (http://localhost/i3geo/ms_criamapa.php?gvsiggvp=c:\temp\teste.gvp&gvsigview=Untitled - 0) |
131 | 131 | */ |
132 | 132 | |
133 | -/* | |
134 | -Verifica a variável $caminho | |
135 | - | |
136 | -Essa variável deve ser definida em programas que utilizam o ms_criamapa.php via include. | |
137 | -Indica onde está o diretório i3geo para que os includes seguintes possam ser localizados. | |
138 | -$caminho é sempre colocada antes do nome dos arquivos que serão incluídos, p.e., | |
139 | -require_once ($caminho."classesphp/carrega_ext.php"); | |
140 | -*/ | |
141 | 133 | //$_COOKIE = array(); |
142 | 134 | // |
143 | 135 | //quando $funcao existe, é pq o ms_criamapa.php está sendo utilizado como um include em classesphp/mapa_controle.php |
... | ... | @@ -149,28 +141,23 @@ else |
149 | 141 | {error_reporting(E_ALL);$debug="sim";} |
150 | 142 | if(!isset($funcao)) |
151 | 143 | {ob_end_clean();} |
152 | -if (!isset($caminho)) | |
153 | -{$caminho = "";} | |
154 | -if (!file_exists($caminho."classesphp/carrega_ext.php")) | |
155 | -{echo "<b> Nao foi possivel localizar o diretório classephp. Provavelmente vc precisara definir a variavel $caminho";exit;} | |
156 | -if (isset($parurl["caminho"])) | |
157 | -{$caminho = $parurl["caminho"];} | |
158 | 144 | /* |
159 | 145 | Carrega as extensões PHP |
160 | 146 | |
161 | 147 | Carrega as extensões utilizadas no programa de inicialização. |
162 | 148 | A carga das extensões geralmente é necessária nas instalações windows (ms4w) ou quando as mesmas não são carregadas pela própria inicialização do PHP. |
163 | 149 | */ |
164 | -include_once ($caminho."classesphp/carrega_ext.php"); | |
150 | +include_once (__DIR__."/classesphp/carrega_ext.php"); | |
165 | 151 | /* |
166 | 152 | Include dos arquivos PHP. |
167 | 153 | |
168 | 154 | Inclui os programas php com funções utilizadas pelo ms_criamapa.php |
169 | 155 | */ |
170 | -include_once ($caminho."classesphp/pega_variaveis.php"); | |
171 | -include_once ($caminho."classesphp/funcoes_gerais.php"); | |
156 | +include_once (__DIR__."/classesphp/pega_variaveis.php"); | |
157 | +include_once (__DIR__."/classesphp/funcoes_gerais.php"); | |
172 | 158 | $versao = versao(); |
173 | 159 | $versao = $versao["principal"]; |
160 | + | |
174 | 161 | // |
175 | 162 | //verifica a sessao que controla o login do usuario |
176 | 163 | // |
... | ... | @@ -191,7 +178,7 @@ if(empty($_SESSION["usuario"])){ |
191 | 178 | if(isset($base)) |
192 | 179 | {$tempBaseX = $base;} |
193 | 180 | if(!isset($dir_tmp)) |
194 | -{include_once ($caminho."ms_configura.php");} | |
181 | +{include_once (__DIR__."/ms_configura.php");} | |
195 | 182 | if(isset($tempBaseX) && $tempBaseX != "") |
196 | 183 | {$base = $tempBaseX;} |
197 | 184 | /* |
... | ... | @@ -467,7 +454,7 @@ if(isset($url_wms)) |
467 | 454 | adaptaLayers(); |
468 | 455 | |
469 | 456 | if (file_exists($locaplic."/pacotes/geoip") && file_exists($locaplic."/pacotes/geoip/GeoLiteCity.dat")) |
470 | -{require_once($caminho."ms_registraip.php");} | |
457 | +{require_once(__DIR__."/ms_registraip.php");} | |
471 | 458 | //echo $tmpfname;exit; |
472 | 459 | if ($interface != "mashup") |
473 | 460 | {abreInterface();} |
... | ... | @@ -518,7 +505,7 @@ function abreInterface(){ |
518 | 505 | { |
519 | 506 | if(file_exists($caminho."interface/".$interface)) |
520 | 507 | {include_once($caminho."interface/".$interface);} |
521 | - else | |
508 | + else | |
522 | 509 | {include_once($interface);} |
523 | 510 | exit; |
524 | 511 | } |
... | ... | @@ -526,7 +513,7 @@ function abreInterface(){ |
526 | 513 | { |
527 | 514 | if(file_exists($caminho."interface/".$interface)) |
528 | 515 | {$urln = $caminho."interface/".$interface."?".session_id();} |
529 | - else | |
516 | + else | |
530 | 517 | {$urln = $interface."?".session_id();} |
531 | 518 | if(!headers_sent()) |
532 | 519 | {header("Location:".$urln);} |
... | ... | @@ -726,7 +713,7 @@ Mostra a mensagem de aguarde |
726 | 713 | */ |
727 | 714 | function mostraAguarde() |
728 | 715 | { |
729 | - global $interface,$caminho,$mensagemInicia,$tituloInstituicao; | |
716 | + global $interface,$mensagemInicia,$tituloInstituicao; | |
730 | 717 | if (!isset($interface)) |
731 | 718 | { |
732 | 719 | echo "<html><head>"; |
... | ... | @@ -735,11 +722,11 @@ function mostraAguarde() |
735 | 722 | echo '<div id="aguarde"><center>'; |
736 | 723 | echo '<p class=paguarde style="font-family: Verdana, Arial, Helvetica, sans-serif;color:black;text-align:center;font-size:12pt"><b>'.$mensagemInicia.'</b><br> Aguarde...preparando o mapa</p>'; |
737 | 724 | echo '<table><tr>'; |
738 | - echo "<td colspan=3 ><center><img src='".$caminho."imagens/i3geo1.jpg'></td></tr>"; | |
739 | - echo "<tr><td><center><img src='".$caminho."imagens/pspb.png'></td>"; | |
740 | - echo "<td><center><img src='".$caminho."imagens/mapserv.png'></td>"; | |
741 | - echo "<td><center><img src='".$caminho."imagens/yui-logo.png'></td>"; | |
742 | - echo "<td><center><a href='http://mapas.mma.gov.br/download' target=blank ><img src='".$caminho."imagens/somerights20_pt.gif' ></a></td>"; | |
725 | + echo "<td colspan=3 ><center><img src='".__DIR__."/imagens/i3geo1.jpg'></td></tr>"; | |
726 | + echo "<tr><td><center><img src='".__DIR__."/imagens/pspb.png'></td>"; | |
727 | + echo "<td><center><img src='".__DIR__."/imagens/mapserv.png'></td>"; | |
728 | + echo "<td><center><img src='".__DIR__."/imagens/yui-logo.png'></td>"; | |
729 | + echo "<td><center><a href='http://mapas.mma.gov.br/download' target=blank ><img src='".__DIR__."/imagens/somerights20_pt.gif' ></a></td>"; | |
743 | 730 | echo "</tr></table>"; |
744 | 731 | echo '<BODY bgcolor="white" style="background-color:white">'; |
745 | 732 | } |
... | ... | @@ -1128,5 +1115,49 @@ function erroCriacao(){ |
1128 | 1115 | } |
1129 | 1116 | ms_ResetErrorList(); |
1130 | 1117 | } |
1118 | +/* | |
1119 | +Function: criaDirMapa | |
1120 | + | |
1121 | +Cria os diretórios temporários para a aplicação. | |
1122 | + | |
1123 | +Parametro: | |
1124 | + | |
1125 | +$dir_tmp {string} - Diretório temporário (no servidor) utilizado pelo mapserver. | |
1126 | + | |
1127 | +$$cachedir {string} - Diretório de cache temporário definido no ms_configura.php | |
1128 | + | |
1129 | +Retorno: | |
1130 | + | |
1131 | +{boleano} | |
1132 | +*/ | |
1133 | +function criaDirMapa($dir_tmp,$cachedir="") | |
1134 | +{ | |
1135 | + if(!file_exists($dir_tmp)){ | |
1136 | + @mkdir ($dir_tmp,0777); | |
1137 | + } | |
1138 | + if(file_exists($dir_tmp)) | |
1139 | + { | |
1140 | + $tmpdirname = nomeRandomico(); | |
1141 | + $crdir = @mkdir ($dir_tmp."/".$tmpdirname,0777); | |
1142 | + $crdiri = @mkdir ($dir_tmp."/img".$tmpdirname,0777); | |
1143 | + $mapfile = $dir_tmp."/".$tmpdirname."/".$tmpdirname.".map"; | |
1144 | + $tmpimgname = "img".$tmpdirname; | |
1145 | + @mkdir($dir_tmp."/comum",0777); | |
1146 | + if($cachedir == ""){ | |
1147 | + @mkdir($dir_tmp."/cache",0777); | |
1148 | + @mkdir($dir_tmp."/cache/googlemaps",0777); | |
1149 | + } | |
1150 | + else{ | |
1151 | + @mkdir($cachedir,0777); | |
1152 | + @mkdir($cachedir."/googlemaps",0777); | |
1153 | + } | |
1154 | + if(file_exists($dir_tmp."/".$tmpdirname)) | |
1155 | + return array($mapfile,$tmpdirname,$tmpimgname); | |
1156 | + else | |
1157 | + {return false;} | |
1158 | + } | |
1159 | + else | |
1160 | + {return false;} | |
1161 | +} | |
1131 | 1162 | |
1132 | 1163 | ?> |
1133 | 1164 | \ No newline at end of file | ... | ... |
testainstal.php
... | ... | @@ -302,6 +302,68 @@ $nome = ($imgo->imageurl).basename($nome); |
302 | 302 | echo "<p><img src=$nome /></p></body></html>"; |
303 | 303 | |
304 | 304 | function saindo($men){echo "<span style=color:red ><br><b>Erro. Saindo...".$men;} |
305 | +/* | |
306 | +Function: permissoesarquivo | |
307 | + | |
308 | +Retorna as permissões de um arquivo | |
309 | + | |
310 | +Parametros: | |
311 | + | |
312 | +$arquivo | |
313 | +*/ | |
314 | +function permissoesarquivo($arquivo){ | |
315 | + $perms = fileperms($arquivo); | |
316 | + | |
317 | + if (($perms & 0xC000) == 0xC000) { | |
318 | + // Socket | |
319 | + $info = 's'; | |
320 | + } elseif (($perms & 0xA000) == 0xA000) { | |
321 | + // Symbolic Link | |
322 | + $info = 'l'; | |
323 | + } elseif (($perms & 0x8000) == 0x8000) { | |
324 | + // Regular | |
325 | + $info = '-'; | |
326 | + } elseif (($perms & 0x6000) == 0x6000) { | |
327 | + // Block special | |
328 | + $info = 'b'; | |
329 | + } elseif (($perms & 0x4000) == 0x4000) { | |
330 | + // Directory | |
331 | + $info = 'd'; | |
332 | + } elseif (($perms & 0x2000) == 0x2000) { | |
333 | + // Character special | |
334 | + $info = 'c'; | |
335 | + } elseif (($perms & 0x1000) == 0x1000) { | |
336 | + // FIFO pipe | |
337 | + $info = 'p'; | |
338 | + } else { | |
339 | + // Unknown | |
340 | + $info = 'u'; | |
341 | + } | |
342 | + | |
343 | + // Owner | |
344 | + $info .= (($perms & 0x0100) ? 'r' : '-'); | |
345 | + $info .= (($perms & 0x0080) ? 'w' : '-'); | |
346 | + $info .= (($perms & 0x0040) ? | |
347 | + (($perms & 0x0800) ? 's' : 'x' ) : | |
348 | + (($perms & 0x0800) ? 'S' : '-')); | |
349 | + | |
350 | + // Group | |
351 | + $info .= (($perms & 0x0020) ? 'r' : '-'); | |
352 | + $info .= (($perms & 0x0010) ? 'w' : '-'); | |
353 | + $info .= (($perms & 0x0008) ? | |
354 | + (($perms & 0x0400) ? 's' : 'x' ) : | |
355 | + (($perms & 0x0400) ? 'S' : '-')); | |
356 | + | |
357 | + // World | |
358 | + $info .= (($perms & 0x0004) ? 'r' : '-'); | |
359 | + $info .= (($perms & 0x0002) ? 'w' : '-'); | |
360 | + $info .= (($perms & 0x0001) ? | |
361 | + (($perms & 0x0200) ? 't' : 'x' ) : | |
362 | + (($perms & 0x0200) ? 'T' : '-')); | |
363 | + | |
364 | + return $info; | |
365 | +} | |
366 | + | |
305 | 367 | ?> |
306 | 368 | </div> |
307 | 369 | <script> | ... | ... |