Commit 6825a3cc4ae6bcfa5eedd85a2dcde2ff53b75ca2
1 parent
223aaf91
Exists in
master
and in
7 other branches
Inclusão de validação na criação do objeto mapa
Showing
2 changed files
with
10 additions
and
3 deletions
Show diff stats
classesphp/classe_mapa.php
... | ... | @@ -44,7 +44,7 @@ class Mapa |
44 | 44 | |
45 | 45 | Arquivo map file |
46 | 46 | */ |
47 | - protected $arquivo; | |
47 | + public $arquivo; | |
48 | 48 | /* |
49 | 49 | Variable: $layers |
50 | 50 | |
... | ... | @@ -64,13 +64,18 @@ $map_file - Endereço do mapfile no servidor. |
64 | 64 | function __construct($map_file,$locaplic="") |
65 | 65 | { |
66 | 66 | //error_reporting(E_ALL); |
67 | + if (!function_exists('ms_newMapObj')) {return false;} | |
67 | 68 | if(file_exists($locaplic."/funcoes_gerais.php")) |
68 | 69 | require_once($locaplic."/funcoes_gerais.php"); |
69 | 70 | else |
70 | 71 | require_once("funcoes_gerais.php"); |
71 | 72 | $this->locaplic = $locaplic; |
72 | - $this->mapa = ms_newMapObj($map_file); | |
73 | - $this->arquivo = $map_file; | |
73 | + if(!file_exists($map_file)) | |
74 | + {return $this->arquivo = false;} | |
75 | + if(!@ms_newMapObj($map_file)) | |
76 | + {return $this->mapa = false;} | |
77 | + $this->mapa = @ms_newMapObj($map_file); | |
78 | + $this->arquivo = $map_file; | |
74 | 79 | for ($i=0;$i < ($this->mapa->numlayers);$i++) |
75 | 80 | {$this->layers[] = $this->mapa->getlayer($i);} |
76 | 81 | } | ... | ... |
classesphp/mapa_inicia.php
... | ... | @@ -94,6 +94,8 @@ function iniciaMapa() |
94 | 94 | //altera o tamanho do query map para ficar igual ao do mapa |
95 | 95 | include("classe_mapa.php"); |
96 | 96 | $m = new Mapa($map_file); |
97 | + if(!$m->arquivo){$cp->set_data(" erro. Mapfile $map_file nao existe");return;} | |
98 | + if(!$m->mapa){$cp->set_data(" erro. Problemas com o mapfile $map_file");return;} | |
97 | 99 | $m->mudaQS($w,$h); |
98 | 100 | $m = new Mapa($map_file); |
99 | 101 | $m->mapa->setsize($w,$h); | ... | ... |