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,7 +44,7 @@ class Mapa | ||
| 44 | 44 | ||
| 45 | Arquivo map file | 45 | Arquivo map file |
| 46 | */ | 46 | */ |
| 47 | - protected $arquivo; | 47 | + public $arquivo; |
| 48 | /* | 48 | /* |
| 49 | Variable: $layers | 49 | Variable: $layers |
| 50 | 50 | ||
| @@ -64,13 +64,18 @@ $map_file - Endereço do mapfile no servidor. | @@ -64,13 +64,18 @@ $map_file - Endereço do mapfile no servidor. | ||
| 64 | function __construct($map_file,$locaplic="") | 64 | function __construct($map_file,$locaplic="") |
| 65 | { | 65 | { |
| 66 | //error_reporting(E_ALL); | 66 | //error_reporting(E_ALL); |
| 67 | + if (!function_exists('ms_newMapObj')) {return false;} | ||
| 67 | if(file_exists($locaplic."/funcoes_gerais.php")) | 68 | if(file_exists($locaplic."/funcoes_gerais.php")) |
| 68 | require_once($locaplic."/funcoes_gerais.php"); | 69 | require_once($locaplic."/funcoes_gerais.php"); |
| 69 | else | 70 | else |
| 70 | require_once("funcoes_gerais.php"); | 71 | require_once("funcoes_gerais.php"); |
| 71 | $this->locaplic = $locaplic; | 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 | for ($i=0;$i < ($this->mapa->numlayers);$i++) | 79 | for ($i=0;$i < ($this->mapa->numlayers);$i++) |
| 75 | {$this->layers[] = $this->mapa->getlayer($i);} | 80 | {$this->layers[] = $this->mapa->getlayer($i);} |
| 76 | } | 81 | } |
classesphp/mapa_inicia.php
| @@ -94,6 +94,8 @@ function iniciaMapa() | @@ -94,6 +94,8 @@ function iniciaMapa() | ||
| 94 | //altera o tamanho do query map para ficar igual ao do mapa | 94 | //altera o tamanho do query map para ficar igual ao do mapa |
| 95 | include("classe_mapa.php"); | 95 | include("classe_mapa.php"); |
| 96 | $m = new Mapa($map_file); | 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 | $m->mudaQS($w,$h); | 99 | $m->mudaQS($w,$h); |
| 98 | $m = new Mapa($map_file); | 100 | $m = new Mapa($map_file); |
| 99 | $m->mapa->setsize($w,$h); | 101 | $m->mapa->setsize($w,$h); |