Completed
Push — master ( 73f088...7f17b6 )
by Yannick
07:13
created
require/libs/geoPHP/lib/geometry/LineString.class.php 3 patches
Indentation   +116 added lines, -116 removed lines patch added patch discarded remove patch
@@ -19,173 +19,173 @@
 block discarded – undo
19 19
       throw new Exception("Cannot construct a LineString with a single point");
20 20
     }
21 21
 */
22
-    // Call the Collection constructor to build the LineString
23
-    parent::__construct($points);
22
+	// Call the Collection constructor to build the LineString
23
+	parent::__construct($points);
24 24
   }
25 25
 
26 26
   // The boundary of a linestring is itself
27 27
   public function boundary() {
28
-    return $this;
28
+	return $this;
29 29
   }
30 30
 
31 31
   public function startPoint() {
32
-    return $this->pointN(1);
32
+	return $this->pointN(1);
33 33
   }
34 34
 
35 35
   public function endPoint() {
36
-    $last_n = $this->numPoints();
37
-    return $this->pointN($last_n);
36
+	$last_n = $this->numPoints();
37
+	return $this->pointN($last_n);
38 38
   }
39 39
 
40 40
   public function isClosed() {
41
-    return ($this->startPoint()->equals($this->endPoint()));
41
+	return ($this->startPoint()->equals($this->endPoint()));
42 42
   }
43 43
 
44 44
   public function isRing() {
45
-    return ($this->isClosed() && $this->isSimple());
45
+	return ($this->isClosed() && $this->isSimple());
46 46
   }
47 47
 
48 48
   public function numPoints() {
49
-    return $this->numGeometries();
49
+	return $this->numGeometries();
50 50
   }
51 51
 
52 52
   public function pointN($n) {
53
-    return $this->geometryN($n);
53
+	return $this->geometryN($n);
54 54
   }
55 55
 
56 56
   public function dimension() {
57
-    if ($this->isEmpty()) return 0;
58
-    return 1;
57
+	if ($this->isEmpty()) return 0;
58
+	return 1;
59 59
   }
60 60
 
61 61
   public function area() {
62
-    return 0;
62
+	return 0;
63 63
   }
64 64
 
65 65
   public function length() {
66
-    if ($this->geos()) {
67
-      return $this->geos()->length();
68
-    }
69
-    $length = 0;
70
-    foreach ($this->getPoints() as $delta => $point) {
71
-      $previous_point = $this->geometryN($delta);
72
-      if ($previous_point) {
73
-        $length += sqrt(pow(($previous_point->getX() - $point->getX()), 2) + pow(($previous_point->getY()- $point->getY()), 2));
74
-      }
75
-    }
76
-    return $length;
66
+	if ($this->geos()) {
67
+	  return $this->geos()->length();
68
+	}
69
+	$length = 0;
70
+	foreach ($this->getPoints() as $delta => $point) {
71
+	  $previous_point = $this->geometryN($delta);
72
+	  if ($previous_point) {
73
+		$length += sqrt(pow(($previous_point->getX() - $point->getX()), 2) + pow(($previous_point->getY()- $point->getY()), 2));
74
+	  }
75
+	}
76
+	return $length;
77 77
   }
78 78
 
79 79
   public function greatCircleLength($radius = 6378137) {
80
-    $length = 0;
81
-    $points = $this->getPoints();
82
-    for($i=0; $i<$this->numPoints()-1; $i++) {
83
-      $point = $points[$i];
84
-      $next_point = $points[$i+1];
85
-      if (!is_object($next_point)) {continue;}
86
-      // Great circle method
87
-      $lat1 = deg2rad($point->getY());
88
-      $lat2 = deg2rad($next_point->getY());
89
-      $lon1 = deg2rad($point->getX());
90
-      $lon2 = deg2rad($next_point->getX());
91
-      $dlon = $lon2 - $lon1;
92
-      $length +=
93
-        $radius *
94
-          atan2(
95
-            sqrt(
96
-              pow(cos($lat2) * sin($dlon), 2) +
97
-                pow(cos($lat1) * sin($lat2) - sin($lat1) * cos($lat2) * cos($dlon), 2)
98
-            )
99
-            ,
100
-            sin($lat1) * sin($lat2) +
101
-              cos($lat1) * cos($lat2) * cos($dlon)
102
-          );
103
-    }
104
-    // Returns length in meters.
105
-    return $length;
80
+	$length = 0;
81
+	$points = $this->getPoints();
82
+	for($i=0; $i<$this->numPoints()-1; $i++) {
83
+	  $point = $points[$i];
84
+	  $next_point = $points[$i+1];
85
+	  if (!is_object($next_point)) {continue;}
86
+	  // Great circle method
87
+	  $lat1 = deg2rad($point->getY());
88
+	  $lat2 = deg2rad($next_point->getY());
89
+	  $lon1 = deg2rad($point->getX());
90
+	  $lon2 = deg2rad($next_point->getX());
91
+	  $dlon = $lon2 - $lon1;
92
+	  $length +=
93
+		$radius *
94
+		  atan2(
95
+			sqrt(
96
+			  pow(cos($lat2) * sin($dlon), 2) +
97
+				pow(cos($lat1) * sin($lat2) - sin($lat1) * cos($lat2) * cos($dlon), 2)
98
+			)
99
+			,
100
+			sin($lat1) * sin($lat2) +
101
+			  cos($lat1) * cos($lat2) * cos($dlon)
102
+		  );
103
+	}
104
+	// Returns length in meters.
105
+	return $length;
106 106
   }
107 107
 
108 108
   public function haversineLength() {
109
-    $degrees = 0;
110
-    $points = $this->getPoints();
111
-    for($i=0; $i<$this->numPoints()-1; $i++) {
112
-      $point = $points[$i];
113
-      $next_point = $points[$i+1];
114
-      if (!is_object($next_point)) {continue;}
115
-      $degree = rad2deg(
116
-        acos(
117
-          sin(deg2rad($point->getY())) * sin(deg2rad($next_point->getY())) +
118
-            cos(deg2rad($point->getY())) * cos(deg2rad($next_point->getY())) *
119
-              cos(deg2rad(abs($point->getX() - $next_point->getX())))
120
-        )
121
-      );
122
-      $degrees += $degree;
123
-    }
124
-    // Returns degrees
125
-    return $degrees;
109
+	$degrees = 0;
110
+	$points = $this->getPoints();
111
+	for($i=0; $i<$this->numPoints()-1; $i++) {
112
+	  $point = $points[$i];
113
+	  $next_point = $points[$i+1];
114
+	  if (!is_object($next_point)) {continue;}
115
+	  $degree = rad2deg(
116
+		acos(
117
+		  sin(deg2rad($point->getY())) * sin(deg2rad($next_point->getY())) +
118
+			cos(deg2rad($point->getY())) * cos(deg2rad($next_point->getY())) *
119
+			  cos(deg2rad(abs($point->getX() - $next_point->getX())))
120
+		)
121
+	  );
122
+	  $degrees += $degree;
123
+	}
124
+	// Returns degrees
125
+	return $degrees;
126 126
   }
127 127
 
128 128
   public function explode() {
129
-    $parts = array();
130
-    $points = $this->getPoints();
129
+	$parts = array();
130
+	$points = $this->getPoints();
131 131
 
132
-    foreach ($points as $i => $point) {
133
-      if (isset($points[$i+1])) {
134
-        $parts[] = new LineString(array($point, $points[$i+1]));
135
-      }
136
-    }
137
-    return $parts;
132
+	foreach ($points as $i => $point) {
133
+	  if (isset($points[$i+1])) {
134
+		$parts[] = new LineString(array($point, $points[$i+1]));
135
+	  }
136
+	}
137
+	return $parts;
138 138
   }
139 139
 
140 140
   public function isSimple() {
141
-    if ($this->geos()) {
142
-      return $this->geos()->isSimple();
143
-    }
141
+	if ($this->geos()) {
142
+	  return $this->geos()->isSimple();
143
+	}
144 144
 
145
-    $segments = $this->explode();
145
+	$segments = $this->explode();
146 146
 
147
-    foreach ($segments as $i => $segment) {
148
-      foreach ($segments as $j => $check_segment) {
149
-        if ($i != $j) {
150
-          if ($segment->lineSegmentIntersect($check_segment)) {
151
-            return FALSE;
152
-          }
153
-        }
154
-      }
155
-    }
156
-    return TRUE;
147
+	foreach ($segments as $i => $segment) {
148
+	  foreach ($segments as $j => $check_segment) {
149
+		if ($i != $j) {
150
+		  if ($segment->lineSegmentIntersect($check_segment)) {
151
+			return FALSE;
152
+		  }
153
+		}
154
+	  }
155
+	}
156
+	return TRUE;
157 157
   }
158 158
 
159 159
   // Utility function to check if any line sigments intersect
160 160
   // Derived from http://stackoverflow.com/questions/563198/how-do-you-detect-where-two-line-segments-intersect
161 161
   public function lineSegmentIntersect($segment) {
162
-    $p0_x = $this->startPoint()->x();
163
-    $p0_y = $this->startPoint()->y();
164
-    $p1_x = $this->endPoint()->x();
165
-    $p1_y = $this->endPoint()->y();
166
-    $p2_x = $segment->startPoint()->x();
167
-    $p2_y = $segment->startPoint()->y();
168
-    $p3_x = $segment->endPoint()->x();
169
-    $p3_y = $segment->endPoint()->y();
170
-
171
-    $s1_x = $p1_x - $p0_x;     $s1_y = $p1_y - $p0_y;
172
-    $s2_x = $p3_x - $p2_x;     $s2_y = $p3_y - $p2_y;
173
-
174
-    $fps = (-$s2_x * $s1_y) + ($s1_x * $s2_y);
175
-    $fpt = (-$s2_x * $s1_y) + ($s1_x * $s2_y);
176
-
177
-    if ($fps == 0 || $fpt == 0) {
178
-      return FALSE;
179
-    }
180
-
181
-    $s = (-$s1_y * ($p0_x - $p2_x) + $s1_x * ($p0_y - $p2_y)) / $fps;
182
-    $t = ( $s2_x * ($p0_y - $p2_y) - $s2_y * ($p0_x - $p2_x)) / $fpt;
183
-
184
-    if ($s > 0 && $s < 1 && $t > 0 && $t < 1) {
185
-      // Collision detected
186
-      return TRUE;
187
-    }
188
-    return FALSE;
162
+	$p0_x = $this->startPoint()->x();
163
+	$p0_y = $this->startPoint()->y();
164
+	$p1_x = $this->endPoint()->x();
165
+	$p1_y = $this->endPoint()->y();
166
+	$p2_x = $segment->startPoint()->x();
167
+	$p2_y = $segment->startPoint()->y();
168
+	$p3_x = $segment->endPoint()->x();
169
+	$p3_y = $segment->endPoint()->y();
170
+
171
+	$s1_x = $p1_x - $p0_x;     $s1_y = $p1_y - $p0_y;
172
+	$s2_x = $p3_x - $p2_x;     $s2_y = $p3_y - $p2_y;
173
+
174
+	$fps = (-$s2_x * $s1_y) + ($s1_x * $s2_y);
175
+	$fpt = (-$s2_x * $s1_y) + ($s1_x * $s2_y);
176
+
177
+	if ($fps == 0 || $fpt == 0) {
178
+	  return FALSE;
179
+	}
180
+
181
+	$s = (-$s1_y * ($p0_x - $p2_x) + $s1_x * ($p0_y - $p2_y)) / $fps;
182
+	$t = ( $s2_x * ($p0_y - $p2_y) - $s2_y * ($p0_x - $p2_x)) / $fpt;
183
+
184
+	if ($s > 0 && $s < 1 && $t > 0 && $t < 1) {
185
+	  // Collision detected
186
+	  return TRUE;
187
+	}
188
+	return FALSE;
189 189
   }
190 190
 }
191 191
 
Please login to merge, or discard this patch.
Spacing   +22 added lines, -22 removed lines patch added patch discarded remove patch
@@ -70,7 +70,7 @@  discard block
 block discarded – undo
70 70
     foreach ($this->getPoints() as $delta => $point) {
71 71
       $previous_point = $this->geometryN($delta);
72 72
       if ($previous_point) {
73
-        $length += sqrt(pow(($previous_point->getX() - $point->getX()), 2) + pow(($previous_point->getY()- $point->getY()), 2));
73
+        $length += sqrt(pow(($previous_point->getX() - $point->getX()), 2) + pow(($previous_point->getY() - $point->getY()), 2));
74 74
       }
75 75
     }
76 76
     return $length;
@@ -79,10 +79,10 @@  discard block
 block discarded – undo
79 79
   public function greatCircleLength($radius = 6378137) {
80 80
     $length = 0;
81 81
     $points = $this->getPoints();
82
-    for($i=0; $i<$this->numPoints()-1; $i++) {
82
+    for ($i = 0; $i < $this->numPoints() - 1; $i++) {
83 83
       $point = $points[$i];
84
-      $next_point = $points[$i+1];
85
-      if (!is_object($next_point)) {continue;}
84
+      $next_point = $points[$i + 1];
85
+      if (!is_object($next_point)) {continue; }
86 86
       // Great circle method
87 87
       $lat1 = deg2rad($point->getY());
88 88
       $lat2 = deg2rad($next_point->getY());
@@ -90,15 +90,15 @@  discard block
 block discarded – undo
90 90
       $lon2 = deg2rad($next_point->getX());
91 91
       $dlon = $lon2 - $lon1;
92 92
       $length +=
93
-        $radius *
93
+        $radius*
94 94
           atan2(
95 95
             sqrt(
96
-              pow(cos($lat2) * sin($dlon), 2) +
97
-                pow(cos($lat1) * sin($lat2) - sin($lat1) * cos($lat2) * cos($dlon), 2)
96
+              pow(cos($lat2)*sin($dlon), 2) +
97
+                pow(cos($lat1)*sin($lat2) - sin($lat1)*cos($lat2)*cos($dlon), 2)
98 98
             )
99 99
             ,
100
-            sin($lat1) * sin($lat2) +
101
-              cos($lat1) * cos($lat2) * cos($dlon)
100
+            sin($lat1)*sin($lat2) +
101
+              cos($lat1)*cos($lat2)*cos($dlon)
102 102
           );
103 103
     }
104 104
     // Returns length in meters.
@@ -108,14 +108,14 @@  discard block
 block discarded – undo
108 108
   public function haversineLength() {
109 109
     $degrees = 0;
110 110
     $points = $this->getPoints();
111
-    for($i=0; $i<$this->numPoints()-1; $i++) {
111
+    for ($i = 0; $i < $this->numPoints() - 1; $i++) {
112 112
       $point = $points[$i];
113
-      $next_point = $points[$i+1];
114
-      if (!is_object($next_point)) {continue;}
113
+      $next_point = $points[$i + 1];
114
+      if (!is_object($next_point)) {continue; }
115 115
       $degree = rad2deg(
116 116
         acos(
117
-          sin(deg2rad($point->getY())) * sin(deg2rad($next_point->getY())) +
118
-            cos(deg2rad($point->getY())) * cos(deg2rad($next_point->getY())) *
117
+          sin(deg2rad($point->getY()))*sin(deg2rad($next_point->getY())) +
118
+            cos(deg2rad($point->getY()))*cos(deg2rad($next_point->getY()))*
119 119
               cos(deg2rad(abs($point->getX() - $next_point->getX())))
120 120
         )
121 121
       );
@@ -130,8 +130,8 @@  discard block
 block discarded – undo
130 130
     $points = $this->getPoints();
131 131
 
132 132
     foreach ($points as $i => $point) {
133
-      if (isset($points[$i+1])) {
134
-        $parts[] = new LineString(array($point, $points[$i+1]));
133
+      if (isset($points[$i + 1])) {
134
+        $parts[] = new LineString(array($point, $points[$i + 1]));
135 135
       }
136 136
     }
137 137
     return $parts;
@@ -168,18 +168,18 @@  discard block
 block discarded – undo
168 168
     $p3_x = $segment->endPoint()->x();
169 169
     $p3_y = $segment->endPoint()->y();
170 170
 
171
-    $s1_x = $p1_x - $p0_x;     $s1_y = $p1_y - $p0_y;
172
-    $s2_x = $p3_x - $p2_x;     $s2_y = $p3_y - $p2_y;
171
+    $s1_x = $p1_x - $p0_x; $s1_y = $p1_y - $p0_y;
172
+    $s2_x = $p3_x - $p2_x; $s2_y = $p3_y - $p2_y;
173 173
 
174
-    $fps = (-$s2_x * $s1_y) + ($s1_x * $s2_y);
175
-    $fpt = (-$s2_x * $s1_y) + ($s1_x * $s2_y);
174
+    $fps = (-$s2_x*$s1_y) + ($s1_x*$s2_y);
175
+    $fpt = (-$s2_x*$s1_y) + ($s1_x*$s2_y);
176 176
 
177 177
     if ($fps == 0 || $fpt == 0) {
178 178
       return FALSE;
179 179
     }
180 180
 
181
-    $s = (-$s1_y * ($p0_x - $p2_x) + $s1_x * ($p0_y - $p2_y)) / $fps;
182
-    $t = ( $s2_x * ($p0_y - $p2_y) - $s2_y * ($p0_x - $p2_x)) / $fpt;
181
+    $s = (-$s1_y*($p0_x - $p2_x) + $s1_x*($p0_y - $p2_y))/$fps;
182
+    $t = ($s2_x*($p0_y - $p2_y) - $s2_y*($p0_x - $p2_x))/$fpt;
183 183
 
184 184
     if ($s > 0 && $s < 1 && $t > 0 && $t < 1) {
185 185
       // Collision detected
Please login to merge, or discard this patch.
Braces   +3 added lines, -1 removed lines patch added patch discarded remove patch
@@ -54,7 +54,9 @@
 block discarded – undo
54 54
   }
55 55
 
56 56
   public function dimension() {
57
-    if ($this->isEmpty()) return 0;
57
+    if ($this->isEmpty()) {
58
+    	return 0;
59
+    }
58 60
     return 1;
59 61
   }
60 62
 
Please login to merge, or discard this patch.
require/libs/geoPHP/lib/geometry/Geometry.class.php 3 patches
Indentation   +146 added lines, -146 removed lines patch added patch discarded remove patch
@@ -46,38 +46,38 @@  discard block
 block discarded – undo
46 46
   // Public: Standard -- Common to all geometries
47 47
   // --------------------------------------------
48 48
   public function SRID() {
49
-    return $this->srid;
49
+	return $this->srid;
50 50
   }
51 51
 
52 52
   public function setSRID($srid) {
53
-    if ($this->geos()) {
54
-      $this->geos()->setSRID($srid);
55
-    }
56
-    $this->srid = $srid;
53
+	if ($this->geos()) {
54
+	  $this->geos()->setSRID($srid);
55
+	}
56
+	$this->srid = $srid;
57 57
   }
58 58
 
59 59
   public function envelope() {
60
-    if ($this->isEmpty()) return new Polygon();
60
+	if ($this->isEmpty()) return new Polygon();
61 61
 
62
-    if ($this->geos()) {
63
-      return geoPHP::geosToGeometry($this->geos()->envelope());
64
-    }
62
+	if ($this->geos()) {
63
+	  return geoPHP::geosToGeometry($this->geos()->envelope());
64
+	}
65 65
 
66
-    $bbox = $this->getBBox();
67
-    $points = array (
68
-      new Point($bbox['maxx'],$bbox['miny']),
69
-      new Point($bbox['maxx'],$bbox['maxy']),
70
-      new Point($bbox['minx'],$bbox['maxy']),
71
-      new Point($bbox['minx'],$bbox['miny']),
72
-      new Point($bbox['maxx'],$bbox['miny']),
73
-    );
66
+	$bbox = $this->getBBox();
67
+	$points = array (
68
+	  new Point($bbox['maxx'],$bbox['miny']),
69
+	  new Point($bbox['maxx'],$bbox['maxy']),
70
+	  new Point($bbox['minx'],$bbox['maxy']),
71
+	  new Point($bbox['minx'],$bbox['miny']),
72
+	  new Point($bbox['maxx'],$bbox['miny']),
73
+	);
74 74
 
75
-    $outer_boundary = new LineString($points);
76
-    return new Polygon(array($outer_boundary));
75
+	$outer_boundary = new LineString($points);
76
+	return new Polygon(array($outer_boundary));
77 77
   }
78 78
 
79 79
   public function geometryType() {
80
-    return $this->geom_type;
80
+	return $this->geom_type;
81 81
   }
82 82
 
83 83
   // Public: Non-Standard -- Common to all geometries
@@ -85,263 +85,263 @@  discard block
 block discarded – undo
85 85
 
86 86
   // $this->out($format, $other_args);
87 87
   public function out() {
88
-    $args = func_get_args();
88
+	$args = func_get_args();
89 89
 
90
-    $format = array_shift($args);
91
-    $type_map = geoPHP::getAdapterMap();
92
-    $processor_type = $type_map[$format];
93
-    $processor = new $processor_type();
90
+	$format = array_shift($args);
91
+	$type_map = geoPHP::getAdapterMap();
92
+	$processor_type = $type_map[$format];
93
+	$processor = new $processor_type();
94 94
 
95
-    array_unshift($args, $this);
96
-    $result = call_user_func_array(array($processor, 'write'), $args);
95
+	array_unshift($args, $this);
96
+	$result = call_user_func_array(array($processor, 'write'), $args);
97 97
 
98
-    return $result;
98
+	return $result;
99 99
   }
100 100
 
101 101
 
102 102
   // Public: Aliases
103 103
   // ---------------
104 104
   public function getCentroid() {
105
-    return $this->centroid();
105
+	return $this->centroid();
106 106
   }
107 107
 
108 108
   public function getArea() {
109
-    return $this->area();
109
+	return $this->area();
110 110
   }
111 111
 
112 112
   public function getX() {
113
-    return $this->x();
113
+	return $this->x();
114 114
   }
115 115
 
116 116
   public function getY() {
117
-    return $this->y();
117
+	return $this->y();
118 118
   }
119 119
 
120 120
   public function getGeos() {
121
-    return $this->geos();
121
+	return $this->geos();
122 122
   }
123 123
 
124 124
   public function getGeomType() {
125
-    return $this->geometryType();
125
+	return $this->geometryType();
126 126
   }
127 127
 
128 128
   public function getSRID() {
129
-    return $this->SRID();
129
+	return $this->SRID();
130 130
   }
131 131
 
132 132
   public function asText() {
133
-    return $this->out('wkt');
133
+	return $this->out('wkt');
134 134
   }
135 135
 
136 136
   public function asBinary() {
137
-    return $this->out('wkb');
137
+	return $this->out('wkb');
138 138
   }
139 139
 
140 140
   // Public: GEOS Only Functions
141 141
   // ---------------------------
142 142
   public function geos() {
143
-    // If it's already been set, just return it
144
-    if ($this->geos && geoPHP::geosInstalled()) {
145
-      return $this->geos;
146
-    }
147
-    // It hasn't been set yet, generate it
148
-    if (geoPHP::geosInstalled()) {
149
-      $reader = new GEOSWKBReader();
150
-      $this->geos = $reader->readHEX($this->out('wkb',TRUE));
151
-    }
152
-    else {
153
-      $this->geos = FALSE;
154
-    }
155
-    return $this->geos;
143
+	// If it's already been set, just return it
144
+	if ($this->geos && geoPHP::geosInstalled()) {
145
+	  return $this->geos;
146
+	}
147
+	// It hasn't been set yet, generate it
148
+	if (geoPHP::geosInstalled()) {
149
+	  $reader = new GEOSWKBReader();
150
+	  $this->geos = $reader->readHEX($this->out('wkb',TRUE));
151
+	}
152
+	else {
153
+	  $this->geos = FALSE;
154
+	}
155
+	return $this->geos;
156 156
   }
157 157
 
158 158
   public function setGeos($geos) {
159
-    $this->geos = $geos;
159
+	$this->geos = $geos;
160 160
   }
161 161
 
162 162
   public function pointOnSurface() {
163
-    if ($this->geos()) {
164
-      return geoPHP::geosToGeometry($this->geos()->pointOnSurface());
165
-    }
163
+	if ($this->geos()) {
164
+	  return geoPHP::geosToGeometry($this->geos()->pointOnSurface());
165
+	}
166 166
   }
167 167
 
168 168
   public function equalsExact(Geometry $geometry) {
169
-    if ($this->geos()) {
170
-      return $this->geos()->equalsExact($geometry->geos());
171
-    }
169
+	if ($this->geos()) {
170
+	  return $this->geos()->equalsExact($geometry->geos());
171
+	}
172 172
   }
173 173
 
174 174
   public function relate(Geometry $geometry, $pattern = NULL) {
175
-    if ($this->geos()) {
176
-      if ($pattern) {
177
-        return $this->geos()->relate($geometry->geos(), $pattern);
178
-      }
179
-      else {
180
-        return $this->geos()->relate($geometry->geos());
181
-      }
182
-    }
175
+	if ($this->geos()) {
176
+	  if ($pattern) {
177
+		return $this->geos()->relate($geometry->geos(), $pattern);
178
+	  }
179
+	  else {
180
+		return $this->geos()->relate($geometry->geos());
181
+	  }
182
+	}
183 183
   }
184 184
 
185 185
   public function checkValidity() {
186
-    if ($this->geos()) {
187
-      return $this->geos()->checkValidity();
188
-    }
186
+	if ($this->geos()) {
187
+	  return $this->geos()->checkValidity();
188
+	}
189 189
   }
190 190
 
191 191
   public function buffer($distance) {
192
-    if ($this->geos()) {
193
-      return geoPHP::geosToGeometry($this->geos()->buffer($distance));
194
-    }
192
+	if ($this->geos()) {
193
+	  return geoPHP::geosToGeometry($this->geos()->buffer($distance));
194
+	}
195 195
   }
196 196
 
197 197
   public function intersection(Geometry $geometry) {
198
-    if ($this->geos()) {
199
-      return geoPHP::geosToGeometry($this->geos()->intersection($geometry->geos()));
200
-    }
198
+	if ($this->geos()) {
199
+	  return geoPHP::geosToGeometry($this->geos()->intersection($geometry->geos()));
200
+	}
201 201
   }
202 202
 
203 203
   public function convexHull() {
204
-    if ($this->geos()) {
205
-      return geoPHP::geosToGeometry($this->geos()->convexHull());
206
-    }
204
+	if ($this->geos()) {
205
+	  return geoPHP::geosToGeometry($this->geos()->convexHull());
206
+	}
207 207
   }
208 208
 
209 209
   public function difference(Geometry $geometry) {
210
-    if ($this->geos()) {
211
-      return geoPHP::geosToGeometry($this->geos()->difference($geometry->geos()));
212
-    }
210
+	if ($this->geos()) {
211
+	  return geoPHP::geosToGeometry($this->geos()->difference($geometry->geos()));
212
+	}
213 213
   }
214 214
 
215 215
   public function symDifference(Geometry $geometry) {
216
-    if ($this->geos()) {
217
-      return geoPHP::geosToGeometry($this->geos()->symDifference($geometry->geos()));
218
-    }
216
+	if ($this->geos()) {
217
+	  return geoPHP::geosToGeometry($this->geos()->symDifference($geometry->geos()));
218
+	}
219 219
   }
220 220
 
221 221
   // Can pass in a geometry or an array of geometries
222 222
   public function union(Geometry $geometry) {
223
-    if ($this->geos()) {
224
-      if (is_array($geometry)) {
225
-        $geom = $this->geos();
226
-        foreach ($geometry as $item) {
227
-          $geom = $geom->union($item->geos());
228
-        }
229
-        return geoPHP::geosToGeometry($geom);
230
-      }
231
-      else {
232
-        return geoPHP::geosToGeometry($this->geos()->union($geometry->geos()));
233
-      }
234
-    }
223
+	if ($this->geos()) {
224
+	  if (is_array($geometry)) {
225
+		$geom = $this->geos();
226
+		foreach ($geometry as $item) {
227
+		  $geom = $geom->union($item->geos());
228
+		}
229
+		return geoPHP::geosToGeometry($geom);
230
+	  }
231
+	  else {
232
+		return geoPHP::geosToGeometry($this->geos()->union($geometry->geos()));
233
+	  }
234
+	}
235 235
   }
236 236
 
237 237
   public function simplify($tolerance, $preserveTopology = FALSE) {
238
-    if ($this->geos()) {
239
-      return geoPHP::geosToGeometry($this->geos()->simplify($tolerance, $preserveTopology));
240
-    }
238
+	if ($this->geos()) {
239
+	  return geoPHP::geosToGeometry($this->geos()->simplify($tolerance, $preserveTopology));
240
+	}
241 241
   }
242 242
 
243 243
   public function disjoint(Geometry $geometry) {
244
-    if ($this->geos()) {
245
-      return $this->geos()->disjoint($geometry->geos());
246
-    }
244
+	if ($this->geos()) {
245
+	  return $this->geos()->disjoint($geometry->geos());
246
+	}
247 247
   }
248 248
 
249 249
   public function touches(Geometry $geometry) {
250
-    if ($this->geos()) {
251
-      return $this->geos()->touches($geometry->geos());
252
-    }
250
+	if ($this->geos()) {
251
+	  return $this->geos()->touches($geometry->geos());
252
+	}
253 253
   }
254 254
 
255 255
   public function intersects(Geometry $geometry) {
256
-    if ($this->geos()) {
257
-      return $this->geos()->intersects($geometry->geos());
258
-    }
256
+	if ($this->geos()) {
257
+	  return $this->geos()->intersects($geometry->geos());
258
+	}
259 259
   }
260 260
 
261 261
   public function crosses(Geometry $geometry) {
262
-    if ($this->geos()) {
263
-      return $this->geos()->crosses($geometry->geos());
264
-    }
262
+	if ($this->geos()) {
263
+	  return $this->geos()->crosses($geometry->geos());
264
+	}
265 265
   }
266 266
 
267 267
   public function within(Geometry $geometry) {
268
-    if ($this->geos()) {
269
-      return $this->geos()->within($geometry->geos());
270
-    }
268
+	if ($this->geos()) {
269
+	  return $this->geos()->within($geometry->geos());
270
+	}
271 271
   }
272 272
 
273 273
   public function contains(Geometry $geometry) {
274
-    if ($this->geos()) {
275
-      return $this->geos()->contains($geometry->geos());
276
-    }
274
+	if ($this->geos()) {
275
+	  return $this->geos()->contains($geometry->geos());
276
+	}
277 277
   }
278 278
 
279 279
   public function overlaps(Geometry $geometry) {
280
-    if ($this->geos()) {
281
-      return $this->geos()->overlaps($geometry->geos());
282
-    }
280
+	if ($this->geos()) {
281
+	  return $this->geos()->overlaps($geometry->geos());
282
+	}
283 283
   }
284 284
 
285 285
   public function covers(Geometry $geometry) {
286
-    if ($this->geos()) {
287
-      return $this->geos()->covers($geometry->geos());
288
-    }
286
+	if ($this->geos()) {
287
+	  return $this->geos()->covers($geometry->geos());
288
+	}
289 289
   }
290 290
 
291 291
   public function coveredBy(Geometry $geometry) {
292
-    if ($this->geos()) {
293
-      return $this->geos()->coveredBy($geometry->geos());
294
-    }
292
+	if ($this->geos()) {
293
+	  return $this->geos()->coveredBy($geometry->geos());
294
+	}
295 295
   }
296 296
 
297 297
   public function distance(Geometry $geometry) {
298
-    if ($this->geos()) {
299
-      return $this->geos()->distance($geometry->geos());
300
-    }
298
+	if ($this->geos()) {
299
+	  return $this->geos()->distance($geometry->geos());
300
+	}
301 301
   }
302 302
 
303 303
   public function hausdorffDistance(Geometry $geometry) {
304
-    if ($this->geos()) {
305
-      return $this->geos()->hausdorffDistance($geometry->geos());
306
-    }
304
+	if ($this->geos()) {
305
+	  return $this->geos()->hausdorffDistance($geometry->geos());
306
+	}
307 307
   }
308 308
 
309 309
   public function project(Geometry $point, $normalized = NULL) {
310
-    if ($this->geos()) {
311
-      return $this->geos()->project($point->geos(), $normalized);
312
-    }
310
+	if ($this->geos()) {
311
+	  return $this->geos()->project($point->geos(), $normalized);
312
+	}
313 313
   }
314 314
 
315 315
   // Public - Placeholders
316 316
   // ---------------------
317 317
   public function hasZ() {
318
-    // geoPHP does not support Z values at the moment
319
-    return FALSE;
318
+	// geoPHP does not support Z values at the moment
319
+	return FALSE;
320 320
   }
321 321
 
322 322
   public function is3D() {
323
-    // geoPHP does not support 3D geometries at the moment
324
-    return FALSE;
323
+	// geoPHP does not support 3D geometries at the moment
324
+	return FALSE;
325 325
   }
326 326
 
327 327
   public function isMeasured() {
328
-    // geoPHP does not yet support M values
329
-    return FALSE;
328
+	// geoPHP does not yet support M values
329
+	return FALSE;
330 330
   }
331 331
 
332 332
   public function coordinateDimension() {
333
-    // geoPHP only supports 2-dimentional space
334
-    return 2;
333
+	// geoPHP only supports 2-dimentional space
334
+	return 2;
335 335
   }
336 336
 
337 337
   public function z() {
338
-    // geoPHP only supports 2-dimentional space
339
-    return NULL;
338
+	// geoPHP only supports 2-dimentional space
339
+	return NULL;
340 340
   }
341 341
 
342 342
   public function m() {
343
-    // geoPHP only supports 2-dimentional space
344
-    return NULL;
343
+	// geoPHP only supports 2-dimentional space
344
+	return NULL;
345 345
   }
346 346
 
347 347
 }
Please login to merge, or discard this patch.
Spacing   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -21,8 +21,8 @@  discard block
 block discarded – undo
21 21
   abstract public function geometryN($n);
22 22
   abstract public function startPoint();
23 23
   abstract public function endPoint();
24
-  abstract public function isRing();            // Mssing dependancy
25
-  abstract public function isClosed();          // Missing dependancy
24
+  abstract public function isRing(); // Mssing dependancy
25
+  abstract public function isClosed(); // Missing dependancy
26 26
   abstract public function numPoints();
27 27
   abstract public function pointN($n);
28 28
   abstract public function exteriorRing();
@@ -64,12 +64,12 @@  discard block
 block discarded – undo
64 64
     }
65 65
 
66 66
     $bbox = $this->getBBox();
67
-    $points = array (
68
-      new Point($bbox['maxx'],$bbox['miny']),
69
-      new Point($bbox['maxx'],$bbox['maxy']),
70
-      new Point($bbox['minx'],$bbox['maxy']),
71
-      new Point($bbox['minx'],$bbox['miny']),
72
-      new Point($bbox['maxx'],$bbox['miny']),
67
+    $points = array(
68
+      new Point($bbox['maxx'], $bbox['miny']),
69
+      new Point($bbox['maxx'], $bbox['maxy']),
70
+      new Point($bbox['minx'], $bbox['maxy']),
71
+      new Point($bbox['minx'], $bbox['miny']),
72
+      new Point($bbox['maxx'], $bbox['miny']),
73 73
     );
74 74
 
75 75
     $outer_boundary = new LineString($points);
@@ -147,7 +147,7 @@  discard block
 block discarded – undo
147 147
     // It hasn't been set yet, generate it
148 148
     if (geoPHP::geosInstalled()) {
149 149
       $reader = new GEOSWKBReader();
150
-      $this->geos = $reader->readHEX($this->out('wkb',TRUE));
150
+      $this->geos = $reader->readHEX($this->out('wkb', TRUE));
151 151
     }
152 152
     else {
153 153
       $this->geos = FALSE;
Please login to merge, or discard this patch.
Braces   +6 added lines, -7 removed lines patch added patch discarded remove patch
@@ -57,7 +57,9 @@  discard block
 block discarded – undo
57 57
   }
58 58
 
59 59
   public function envelope() {
60
-    if ($this->isEmpty()) return new Polygon();
60
+    if ($this->isEmpty()) {
61
+    	return new Polygon();
62
+    }
61 63
 
62 64
     if ($this->geos()) {
63 65
       return geoPHP::geosToGeometry($this->geos()->envelope());
@@ -148,8 +150,7 @@  discard block
 block discarded – undo
148 150
     if (geoPHP::geosInstalled()) {
149 151
       $reader = new GEOSWKBReader();
150 152
       $this->geos = $reader->readHEX($this->out('wkb',TRUE));
151
-    }
152
-    else {
153
+    } else {
153 154
       $this->geos = FALSE;
154 155
     }
155 156
     return $this->geos;
@@ -175,8 +176,7 @@  discard block
 block discarded – undo
175 176
     if ($this->geos()) {
176 177
       if ($pattern) {
177 178
         return $this->geos()->relate($geometry->geos(), $pattern);
178
-      }
179
-      else {
179
+      } else {
180 180
         return $this->geos()->relate($geometry->geos());
181 181
       }
182 182
     }
@@ -227,8 +227,7 @@  discard block
 block discarded – undo
227 227
           $geom = $geom->union($item->geos());
228 228
         }
229 229
         return geoPHP::geosToGeometry($geom);
230
-      }
231
-      else {
230
+      } else {
232 231
         return geoPHP::geosToGeometry($this->geos()->union($geometry->geos()));
233 232
       }
234 233
     }
Please login to merge, or discard this patch.
require/class.ATC.php 3 patches
Indentation   +64 added lines, -64 removed lines patch added patch discarded remove patch
@@ -4,76 +4,76 @@
 block discarded – undo
4 4
 
5 5
 class ATC {
6 6
 	public $db;
7
-        function __construct($dbc = null) {
8
-    		$Connection = new Connection($dbc);
9
-    		$this->db = $Connection->db;
7
+		function __construct($dbc = null) {
8
+			$Connection = new Connection($dbc);
9
+			$this->db = $Connection->db;
10 10
 	}
11 11
 
12
-       public function getAll() {
13
-                $query = "SELECT * FROM atc GROUP BY ident";
14
-                $query_values = array();
15
-                 try {
16
-                        $sth = $this->db->prepare($query);
17
-                        $sth->execute($query_values);
18
-                } catch(PDOException $e) {
19
-                        return "error : ".$e->getMessage();
20
-                }
21
-                $all = $sth->fetchAll(PDO::FETCH_ASSOC);
22
-                return $all;
23
-        }
12
+	   public function getAll() {
13
+				$query = "SELECT * FROM atc GROUP BY ident";
14
+				$query_values = array();
15
+				 try {
16
+						$sth = $this->db->prepare($query);
17
+						$sth->execute($query_values);
18
+				} catch(PDOException $e) {
19
+						return "error : ".$e->getMessage();
20
+				}
21
+				$all = $sth->fetchAll(PDO::FETCH_ASSOC);
22
+				return $all;
23
+		}
24 24
 
25
-       public function add($ident,$frequency,$latitude,$longitude,$range,$info,$date,$type = '',$ivao_id = '',$ivao_name = '') {
26
-    		$info = preg_replace('/[^(\x20-\x7F)]*/','',$info);
27
-    		$info = str_replace('^','<br />',$info);
28
-    		$info = str_replace('&amp;sect;','',$info);
29
-    		$info = str_replace('"','',$info);
30
-    		if ($type == '') $type = NULL;
31
-                $query = "INSERT INTO atc (ident,frequency,latitude,longitude,atc_range,info,atc_lastseen,type,ivao_id,ivao_name) VALUES (:ident,:frequency,:latitude,:longitude,:range,:info,:date,:type,:ivao_id,:ivao_name)";
32
-                $query_values = array(':ident' => $ident,':frequency' => $frequency,':latitude' => $latitude,':longitude' => $longitude,':range' => $range,':info' => $info,':date' => $date,':ivao_id' => $ivao_id,':ivao_name' => $ivao_name, ':type' => $type);
33
-                 try {
34
-                        $sth = $this->db->prepare($query);
35
-                        $sth->execute($query_values);
36
-                } catch(PDOException $e) {
37
-                        return "error : ".$e->getMessage();
38
-                }
39
-        }
25
+	   public function add($ident,$frequency,$latitude,$longitude,$range,$info,$date,$type = '',$ivao_id = '',$ivao_name = '') {
26
+			$info = preg_replace('/[^(\x20-\x7F)]*/','',$info);
27
+			$info = str_replace('^','<br />',$info);
28
+			$info = str_replace('&amp;sect;','',$info);
29
+			$info = str_replace('"','',$info);
30
+			if ($type == '') $type = NULL;
31
+				$query = "INSERT INTO atc (ident,frequency,latitude,longitude,atc_range,info,atc_lastseen,type,ivao_id,ivao_name) VALUES (:ident,:frequency,:latitude,:longitude,:range,:info,:date,:type,:ivao_id,:ivao_name)";
32
+				$query_values = array(':ident' => $ident,':frequency' => $frequency,':latitude' => $latitude,':longitude' => $longitude,':range' => $range,':info' => $info,':date' => $date,':ivao_id' => $ivao_id,':ivao_name' => $ivao_name, ':type' => $type);
33
+				 try {
34
+						$sth = $this->db->prepare($query);
35
+						$sth->execute($query_values);
36
+				} catch(PDOException $e) {
37
+						return "error : ".$e->getMessage();
38
+				}
39
+		}
40 40
 
41
-       public function deleteById($id) {
42
-                $query = "DELETE FROM atc WHERE atc_id = :id";
43
-                $query_values = array(':id' => $id);
44
-                 try {
45
-                        $sth = $this->db->prepare($query);
46
-                        $sth->execute($query_values);
47
-                } catch(PDOException $e) {
48
-                        return "error : ".$e->getMessage();
49
-                }
50
-        }
41
+	   public function deleteById($id) {
42
+				$query = "DELETE FROM atc WHERE atc_id = :id";
43
+				$query_values = array(':id' => $id);
44
+				 try {
45
+						$sth = $this->db->prepare($query);
46
+						$sth->execute($query_values);
47
+				} catch(PDOException $e) {
48
+						return "error : ".$e->getMessage();
49
+				}
50
+		}
51 51
 
52
-       public function deleteAll() {
53
-                $query = "DELETE FROM atc";
54
-                $query_values = array();
55
-                 try {
56
-                        $sth = $this->db->prepare($query);
57
-                        $sth->execute($query_values);
58
-                } catch(PDOException $e) {
59
-                        return "error : ".$e->getMessage();
60
-                }
61
-        }
52
+	   public function deleteAll() {
53
+				$query = "DELETE FROM atc";
54
+				$query_values = array();
55
+				 try {
56
+						$sth = $this->db->prepare($query);
57
+						$sth->execute($query_values);
58
+				} catch(PDOException $e) {
59
+						return "error : ".$e->getMessage();
60
+				}
61
+		}
62 62
 
63 63
 	public function deleteOldATC() {
64
-                global $globalDBdriver;
65
-                if ($globalDBdriver == 'mysql') {
66
-                        $query  = "DELETE FROM atc WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 HOUR) >= atc.atc_lastseen";
67
-                } elseif ($globalDBdriver == 'pgsql') {
68
-                        $query  = "DELETE FROM atc WHERE NOW() AT TIME ZONE 'UTC' - '1 HOUR'->INTERVAL >= atc.atc_lastseen";
69
-                }
70
-                try {
71
-                        $sth = $this->db->prepare($query);
72
-                        $sth->execute();
73
-                } catch(PDOException $e) {
74
-                        return "error";
75
-                }
76
-                return "success";
77
-        }
64
+				global $globalDBdriver;
65
+				if ($globalDBdriver == 'mysql') {
66
+						$query  = "DELETE FROM atc WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 HOUR) >= atc.atc_lastseen";
67
+				} elseif ($globalDBdriver == 'pgsql') {
68
+						$query  = "DELETE FROM atc WHERE NOW() AT TIME ZONE 'UTC' - '1 HOUR'->INTERVAL >= atc.atc_lastseen";
69
+				}
70
+				try {
71
+						$sth = $this->db->prepare($query);
72
+						$sth->execute();
73
+				} catch(PDOException $e) {
74
+						return "error";
75
+				}
76
+				return "success";
77
+		}
78 78
 }
79 79
 ?>
80 80
\ No newline at end of file
Please login to merge, or discard this patch.
Spacing   +11 added lines, -11 removed lines patch added patch discarded remove patch
@@ -15,25 +15,25 @@  discard block
 block discarded – undo
15 15
                  try {
16 16
                         $sth = $this->db->prepare($query);
17 17
                         $sth->execute($query_values);
18
-                } catch(PDOException $e) {
18
+                } catch (PDOException $e) {
19 19
                         return "error : ".$e->getMessage();
20 20
                 }
21 21
                 $all = $sth->fetchAll(PDO::FETCH_ASSOC);
22 22
                 return $all;
23 23
         }
24 24
 
25
-       public function add($ident,$frequency,$latitude,$longitude,$range,$info,$date,$type = '',$ivao_id = '',$ivao_name = '') {
26
-    		$info = preg_replace('/[^(\x20-\x7F)]*/','',$info);
27
-    		$info = str_replace('^','<br />',$info);
28
-    		$info = str_replace('&amp;sect;','',$info);
29
-    		$info = str_replace('"','',$info);
25
+       public function add($ident, $frequency, $latitude, $longitude, $range, $info, $date, $type = '', $ivao_id = '', $ivao_name = '') {
26
+    		$info = preg_replace('/[^(\x20-\x7F)]*/', '', $info);
27
+    		$info = str_replace('^', '<br />', $info);
28
+    		$info = str_replace('&amp;sect;', '', $info);
29
+    		$info = str_replace('"', '', $info);
30 30
     		if ($type == '') $type = NULL;
31 31
                 $query = "INSERT INTO atc (ident,frequency,latitude,longitude,atc_range,info,atc_lastseen,type,ivao_id,ivao_name) VALUES (:ident,:frequency,:latitude,:longitude,:range,:info,:date,:type,:ivao_id,:ivao_name)";
32
-                $query_values = array(':ident' => $ident,':frequency' => $frequency,':latitude' => $latitude,':longitude' => $longitude,':range' => $range,':info' => $info,':date' => $date,':ivao_id' => $ivao_id,':ivao_name' => $ivao_name, ':type' => $type);
32
+                $query_values = array(':ident' => $ident, ':frequency' => $frequency, ':latitude' => $latitude, ':longitude' => $longitude, ':range' => $range, ':info' => $info, ':date' => $date, ':ivao_id' => $ivao_id, ':ivao_name' => $ivao_name, ':type' => $type);
33 33
                  try {
34 34
                         $sth = $this->db->prepare($query);
35 35
                         $sth->execute($query_values);
36
-                } catch(PDOException $e) {
36
+                } catch (PDOException $e) {
37 37
                         return "error : ".$e->getMessage();
38 38
                 }
39 39
         }
@@ -44,7 +44,7 @@  discard block
 block discarded – undo
44 44
                  try {
45 45
                         $sth = $this->db->prepare($query);
46 46
                         $sth->execute($query_values);
47
-                } catch(PDOException $e) {
47
+                } catch (PDOException $e) {
48 48
                         return "error : ".$e->getMessage();
49 49
                 }
50 50
         }
@@ -55,7 +55,7 @@  discard block
 block discarded – undo
55 55
                  try {
56 56
                         $sth = $this->db->prepare($query);
57 57
                         $sth->execute($query_values);
58
-                } catch(PDOException $e) {
58
+                } catch (PDOException $e) {
59 59
                         return "error : ".$e->getMessage();
60 60
                 }
61 61
         }
@@ -70,7 +70,7 @@  discard block
 block discarded – undo
70 70
                 try {
71 71
                         $sth = $this->db->prepare($query);
72 72
                         $sth->execute();
73
-                } catch(PDOException $e) {
73
+                } catch (PDOException $e) {
74 74
                         return "error";
75 75
                 }
76 76
                 return "success";
Please login to merge, or discard this patch.
Braces   +3 added lines, -1 removed lines patch added patch discarded remove patch
@@ -27,7 +27,9 @@
 block discarded – undo
27 27
     		$info = str_replace('^','<br />',$info);
28 28
     		$info = str_replace('&amp;sect;','',$info);
29 29
     		$info = str_replace('"','',$info);
30
-    		if ($type == '') $type = NULL;
30
+    		if ($type == '') {
31
+    			$type = NULL;
32
+    		}
31 33
                 $query = "INSERT INTO atc (ident,frequency,latitude,longitude,atc_range,info,atc_lastseen,type,ivao_id,ivao_name) VALUES (:ident,:frequency,:latitude,:longitude,:range,:info,:date,:type,:ivao_id,:ivao_name)";
32 34
                 $query_values = array(':ident' => $ident,':frequency' => $frequency,':latitude' => $latitude,':longitude' => $longitude,':range' => $range,':info' => $info,':date' => $date,':ivao_id' => $ivao_id,':ivao_name' => $ivao_name, ':type' => $type);
33 35
                  try {
Please login to merge, or discard this patch.
require/class.SpotterServer.php 3 patches
Indentation   +63 added lines, -63 removed lines patch added patch discarded remove patch
@@ -7,121 +7,121 @@
 block discarded – undo
7 7
 require_once(dirname(__FILE__).'/class.Translation.php');
8 8
 
9 9
 class SpotterServer {
10
-    public $dbs = null;
10
+	public $dbs = null;
11 11
     
12
-    function __construct($dbs = null) {
12
+	function __construct($dbs = null) {
13 13
 	if ($dbs === null) {
14
-	    $Connection = new Connection(null,'server');
15
-	    $this->dbs = $Connection->dbs;
16
-	    $query = "CREATE TABLE IF NOT EXISTS `spotter_temp` ( `id_data` INT NOT NULL AUTO_INCREMENT , `id_user` INT NOT NULL , `datetime` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP , `hex` VARCHAR(20) NOT NULL , `ident` VARCHAR(20) NULL , `latitude` FLOAT NULL , `longitude` FLOAT NULL , `verticalrate` INT NULL , `speed` INT NULL , `squawk` INT NULL , `altitude` INT NULL , `heading` INT NULL , `registration` VARCHAR(10) NULL , `aircraft_icao` VARCHAR(10) NULL , `waypoints` VARCHAR(255) NULL , `noarchive` BOOLEAN NOT NULL DEFAULT FALSE, `id_source` INT NOT NULL DEFAULT '1', `format_source` VARCHAR(25) NULL, `source_name` VARCHAR(25) NULL, `over_country` VARCHAR(255) NULL, PRIMARY KEY (`id_data`) ) ENGINE = MEMORY;";
17
-	    try {
14
+		$Connection = new Connection(null,'server');
15
+		$this->dbs = $Connection->dbs;
16
+		$query = "CREATE TABLE IF NOT EXISTS `spotter_temp` ( `id_data` INT NOT NULL AUTO_INCREMENT , `id_user` INT NOT NULL , `datetime` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP , `hex` VARCHAR(20) NOT NULL , `ident` VARCHAR(20) NULL , `latitude` FLOAT NULL , `longitude` FLOAT NULL , `verticalrate` INT NULL , `speed` INT NULL , `squawk` INT NULL , `altitude` INT NULL , `heading` INT NULL , `registration` VARCHAR(10) NULL , `aircraft_icao` VARCHAR(10) NULL , `waypoints` VARCHAR(255) NULL , `noarchive` BOOLEAN NOT NULL DEFAULT FALSE, `id_source` INT NOT NULL DEFAULT '1', `format_source` VARCHAR(25) NULL, `source_name` VARCHAR(25) NULL, `over_country` VARCHAR(255) NULL, PRIMARY KEY (`id_data`) ) ENGINE = MEMORY;";
17
+		try {
18 18
 		$sth = $this->dbs['server']->exec($query);
19
-	    } catch(PDOException $e) {
19
+		} catch(PDOException $e) {
20 20
 		return "error : ".$e->getMessage();
21
-	    }
21
+		}
22
+	}
22 23
 	}
23
-    }
24 24
     
25
-    function checkAll() {
26
-        return true;
27
-    }
25
+	function checkAll() {
26
+		return true;
27
+	}
28 28
     
29
-    function add($line) {
29
+	function add($line) {
30 30
 	global $globalDebug, $globalServerUserID;
31 31
 	date_default_timezone_set('UTC');
32 32
 	//if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw' || $line['format_source'] === 'deltadbtxt' || $line['format_source'] === 'aprs')) {
33 33
 	if (isset($line['format_source'])) {
34
-	    if(is_array($line) && isset($line['hex'])) {
34
+		if(is_array($line) && isset($line['hex'])) {
35 35
 		if ($line['hex'] != '' && $line['hex'] != '00000' && $line['hex'] != '000000' && $line['hex'] != '111111' && ctype_xdigit($line['hex']) && strlen($line['hex']) === 6) {
36
-		    $data['hex'] = trim($line['hex']);
37
-		    if (preg_match('/^(\d{4}(?:\-\d{2}){2} \d{2}(?:\:\d{2}){2})$/',$line['datetime'])) {
38
-		        $data['datetime'] = $line['datetime'];
39
-		    } else $data['datetime'] = date('Y-m-d H:i:s');
40
-		    if (!isset($line['aircraft_icao'])) {
41
-		        $Spotter = new Spotter();
42
-		        $aircraft_icao = $Spotter->getAllAircraftType($data['hex']);
43
-		        $Spotter->db = null;
36
+			$data['hex'] = trim($line['hex']);
37
+			if (preg_match('/^(\d{4}(?:\-\d{2}){2} \d{2}(?:\:\d{2}){2})$/',$line['datetime'])) {
38
+				$data['datetime'] = $line['datetime'];
39
+			} else $data['datetime'] = date('Y-m-d H:i:s');
40
+			if (!isset($line['aircraft_icao'])) {
41
+				$Spotter = new Spotter();
42
+				$aircraft_icao = $Spotter->getAllAircraftType($data['hex']);
43
+				$Spotter->db = null;
44 44
 			if ($aircraft_icao == '' && isset($line['aircraft_type'])) {
45
-			    if ($line['aircraft_type'] == 'PARA_GLIDER') $aircraft_icao = 'GLID';
46
-			    elseif ($line['aircraft_type'] == 'HELICOPTER_ROTORCRAFT') $aircraft_icao = 'UHEL';
47
-			    elseif ($line['aircraft_type'] == 'TOW_PLANE') $aircraft_icao = 'TOWPLANE';
48
-			    elseif ($line['aircraft_type'] == 'POWERED_AIRCRAFT') $aircraft_icao = 'POWAIRC';
45
+				if ($line['aircraft_type'] == 'PARA_GLIDER') $aircraft_icao = 'GLID';
46
+				elseif ($line['aircraft_type'] == 'HELICOPTER_ROTORCRAFT') $aircraft_icao = 'UHEL';
47
+				elseif ($line['aircraft_type'] == 'TOW_PLANE') $aircraft_icao = 'TOWPLANE';
48
+				elseif ($line['aircraft_type'] == 'POWERED_AIRCRAFT') $aircraft_icao = 'POWAIRC';
49 49
 			}
50 50
 			$data['aircraft_icao'] = $aircraft_icao;
51
-		    } else $data['aircraft_icao'] = $line['aircraft_icao'];
52
-		    //if ($globalDebug) echo "*********** New aircraft hex : ".$data['hex']." ***********\n";
51
+			} else $data['aircraft_icao'] = $line['aircraft_icao'];
52
+			//if ($globalDebug) echo "*********** New aircraft hex : ".$data['hex']." ***********\n";
53 53
 		}
54 54
 		if (isset($line['registration']) && $line['registration'] != '') {
55
-		    $data['registration'] = $line['registration'];
55
+			$data['registration'] = $line['registration'];
56 56
 		} else $data['registration'] = null;
57 57
 		if (isset($line['waypoints']) && $line['waypoints'] != '') {
58
-		    $data['waypoints'] = $line['waypoints'];
58
+			$data['waypoints'] = $line['waypoints'];
59 59
 		} else $data['waypoints'] = null;
60 60
 		if (isset($line['ident']) && $line['ident'] != '' && $line['ident'] != '????????' && $line['ident'] != '00000000' && preg_match('/^[a-zA-Z0-9]+$/', $line['ident'])) {
61
-		    $data['ident'] = trim($line['ident']);
61
+			$data['ident'] = trim($line['ident']);
62 62
 		} else $data['ident'] = null;
63 63
 
64
-	        if (isset($line['latitude']) && isset($line['longitude']) && $line['latitude'] != '' && $line['longitude'] != '') {
65
-		    if (isset($line['latitude']) && $line['latitude'] != '' && $line['latitude'] != 0 && $line['latitude'] < 91 && $line['latitude'] > -90) {
64
+			if (isset($line['latitude']) && isset($line['longitude']) && $line['latitude'] != '' && $line['longitude'] != '') {
65
+			if (isset($line['latitude']) && $line['latitude'] != '' && $line['latitude'] != 0 && $line['latitude'] < 91 && $line['latitude'] > -90) {
66 66
 			$data['latitude'] = $line['latitude'];
67
-		    } else $data['latitude'] = null;
68
-		    if (isset($line['longitude']) && $line['longitude'] != '' && $line['longitude'] != 0 && $line['longitude'] < 360 && $line['longitude'] > -180) {
69
-		        if ($line['longitude'] > 180) $line['longitude'] = $line['longitude'] - 360;
67
+			} else $data['latitude'] = null;
68
+			if (isset($line['longitude']) && $line['longitude'] != '' && $line['longitude'] != 0 && $line['longitude'] < 360 && $line['longitude'] > -180) {
69
+				if ($line['longitude'] > 180) $line['longitude'] = $line['longitude'] - 360;
70 70
 			$data['longitude'] = $line['longitude'];
71
-		    } else $data['longitude'] = null;
71
+			} else $data['longitude'] = null;
72 72
 		} else {
73
-		    $data['latitude'] = null;
74
-		    $data['longitude'] = null;
73
+			$data['latitude'] = null;
74
+			$data['longitude'] = null;
75 75
 		}
76 76
 		if (isset($line['verticalrate']) && $line['verticalrate'] != '') {
77
-		    $data['verticalrate'] = $line['verticalrate'];
77
+			$data['verticalrate'] = $line['verticalrate'];
78 78
 		} else $data['verticalrate'] = null;
79 79
 		if (isset($line['emergency']) && $line['emergency'] != '') {
80
-		    $data['emergency'] = $line['emergency'];
80
+			$data['emergency'] = $line['emergency'];
81 81
 		} else $data['emergency'] = null;
82 82
 		if (isset($line['ground']) && $line['ground'] != '') {
83
-		    $data['ground'] = $line['ground'];
83
+			$data['ground'] = $line['ground'];
84 84
 		} else $data['ground'] = null;
85 85
 		if (isset($line['speed']) && $line['speed'] != '') {
86
-		    $data['speed'] = round($line['speed']);
86
+			$data['speed'] = round($line['speed']);
87 87
 		} else $data['speed'] = null;
88 88
 		if (isset($line['squawk']) && $line['squawk'] != '') {
89
-		    $data['squawk'] = $line['squawk'];
89
+			$data['squawk'] = $line['squawk'];
90 90
 		} else $data['squawk'] = null;
91 91
 
92 92
 		if (isset($line['altitude']) && $line['altitude'] != '') {
93 93
 			$data['altitude'] = round($line['altitude']);
94 94
   		} else $data['altitude'] = null;
95 95
 		if (isset($line['heading']) && $line['heading'] != '') {
96
-		    $data['heading'] = round($line['heading']);
96
+			$data['heading'] = round($line['heading']);
97 97
   		} else $data['heading'] = null;
98 98
 		if (isset($line['source_name']) && $line['source_name'] != '') {
99
-		    $data['source_name'] = $line['source_name'];
99
+			$data['source_name'] = $line['source_name'];
100 100
   		} else $data['source_name'] = null;
101 101
 		if (isset($line['over_country']) && $line['over_country'] != '') {
102
-		    $data['over_country'] = $line['over_country'];
102
+			$data['over_country'] = $line['over_country'];
103 103
   		} else $data['over_country'] = null;
104 104
   		if (isset($line['noarchive']) && $line['noarchive']) {
105
-  		    $data['noarchive'] = true;
105
+  			$data['noarchive'] = true;
106 106
   		} else $data['noarchive'] = false;
107 107
   		$data['format_source'] = $line['format_source'];
108 108
   		if (isset($line['id_source'])) $id_source = $line['id_source'];
109 109
   		if (isset($data['hex'])) {
110
-  		    echo '.';
111
-  		    $id_user = $globalServerUserID;
112
-  		    if ($id_user == NULL) $id_user = 1;
113
-  		    if (!isset($id_source)) $id_source = 1;
114
-  		    $query = 'INSERT INTO spotter_temp (id_user,datetime,hex,ident,latitude,longitude,verticalrate,speed,squawk,altitude,heading,registration,aircraft_icao,waypoints,id_source,noarchive,format_source,source_name,over_country) VALUES (:id_user,:datetime,:hex,:ident,:latitude,:longitude,:verticalrate,:speed,:squawk,:altitude,:heading,:registration,:aircraft_icao,:waypoints,:id_source,:noarchive, :format_source, :source_name, :over_country)';
115
-		    $query_values = array(':id_user' => $id_user,':datetime' => $data['datetime'],':hex' => $data['hex'],':ident' => $data['ident'],':latitude' => $data['latitude'],':longitude' => $data['longitude'],':verticalrate' => $data['verticalrate'],':speed' => $data['speed'],':squawk' => $data['squawk'],':altitude' => $data['altitude'],':heading' => $data['heading'],':registration' => $data['registration'],':aircraft_icao' => $data['aircraft_icao'],':waypoints' => $data['waypoints'],':id_source' => $id_source,':noarchive' => $data['noarchive'], ':format_source' => $data['format_source'], ':source_name' => $data['source_name'],':over_country' => $data['over_country']);
116
-		    try {
117
-                        $sth = $this->dbs['server']->prepare($query);
118
-                        $sth->execute($query_values);
119
-                    } catch(PDOException $e) {
120
-                        return "error : ".$e->getMessage();
121
-            	    }
122
-        	}
123
-    	    }
110
+  			echo '.';
111
+  			$id_user = $globalServerUserID;
112
+  			if ($id_user == NULL) $id_user = 1;
113
+  			if (!isset($id_source)) $id_source = 1;
114
+  			$query = 'INSERT INTO spotter_temp (id_user,datetime,hex,ident,latitude,longitude,verticalrate,speed,squawk,altitude,heading,registration,aircraft_icao,waypoints,id_source,noarchive,format_source,source_name,over_country) VALUES (:id_user,:datetime,:hex,:ident,:latitude,:longitude,:verticalrate,:speed,:squawk,:altitude,:heading,:registration,:aircraft_icao,:waypoints,:id_source,:noarchive, :format_source, :source_name, :over_country)';
115
+			$query_values = array(':id_user' => $id_user,':datetime' => $data['datetime'],':hex' => $data['hex'],':ident' => $data['ident'],':latitude' => $data['latitude'],':longitude' => $data['longitude'],':verticalrate' => $data['verticalrate'],':speed' => $data['speed'],':squawk' => $data['squawk'],':altitude' => $data['altitude'],':heading' => $data['heading'],':registration' => $data['registration'],':aircraft_icao' => $data['aircraft_icao'],':waypoints' => $data['waypoints'],':id_source' => $id_source,':noarchive' => $data['noarchive'], ':format_source' => $data['format_source'], ':source_name' => $data['source_name'],':over_country' => $data['over_country']);
116
+			try {
117
+						$sth = $this->dbs['server']->prepare($query);
118
+						$sth->execute($query_values);
119
+					} catch(PDOException $e) {
120
+						return "error : ".$e->getMessage();
121
+					}
122
+			}
123
+			}
124
+	}
124 125
 	}
125
-    }
126 126
 }
127 127
 ?>
Please login to merge, or discard this patch.
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -11,12 +11,12 @@  discard block
 block discarded – undo
11 11
     
12 12
     function __construct($dbs = null) {
13 13
 	if ($dbs === null) {
14
-	    $Connection = new Connection(null,'server');
14
+	    $Connection = new Connection(null, 'server');
15 15
 	    $this->dbs = $Connection->dbs;
16 16
 	    $query = "CREATE TABLE IF NOT EXISTS `spotter_temp` ( `id_data` INT NOT NULL AUTO_INCREMENT , `id_user` INT NOT NULL , `datetime` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP , `hex` VARCHAR(20) NOT NULL , `ident` VARCHAR(20) NULL , `latitude` FLOAT NULL , `longitude` FLOAT NULL , `verticalrate` INT NULL , `speed` INT NULL , `squawk` INT NULL , `altitude` INT NULL , `heading` INT NULL , `registration` VARCHAR(10) NULL , `aircraft_icao` VARCHAR(10) NULL , `waypoints` VARCHAR(255) NULL , `noarchive` BOOLEAN NOT NULL DEFAULT FALSE, `id_source` INT NOT NULL DEFAULT '1', `format_source` VARCHAR(25) NULL, `source_name` VARCHAR(25) NULL, `over_country` VARCHAR(255) NULL, PRIMARY KEY (`id_data`) ) ENGINE = MEMORY;";
17 17
 	    try {
18 18
 		$sth = $this->dbs['server']->exec($query);
19
-	    } catch(PDOException $e) {
19
+	    } catch (PDOException $e) {
20 20
 		return "error : ".$e->getMessage();
21 21
 	    }
22 22
 	}
@@ -31,10 +31,10 @@  discard block
 block discarded – undo
31 31
 	date_default_timezone_set('UTC');
32 32
 	//if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw' || $line['format_source'] === 'deltadbtxt' || $line['format_source'] === 'aprs')) {
33 33
 	if (isset($line['format_source'])) {
34
-	    if(is_array($line) && isset($line['hex'])) {
34
+	    if (is_array($line) && isset($line['hex'])) {
35 35
 		if ($line['hex'] != '' && $line['hex'] != '00000' && $line['hex'] != '000000' && $line['hex'] != '111111' && ctype_xdigit($line['hex']) && strlen($line['hex']) === 6) {
36 36
 		    $data['hex'] = trim($line['hex']);
37
-		    if (preg_match('/^(\d{4}(?:\-\d{2}){2} \d{2}(?:\:\d{2}){2})$/',$line['datetime'])) {
37
+		    if (preg_match('/^(\d{4}(?:\-\d{2}){2} \d{2}(?:\:\d{2}){2})$/', $line['datetime'])) {
38 38
 		        $data['datetime'] = $line['datetime'];
39 39
 		    } else $data['datetime'] = date('Y-m-d H:i:s');
40 40
 		    if (!isset($line['aircraft_icao'])) {
@@ -112,11 +112,11 @@  discard block
 block discarded – undo
112 112
   		    if ($id_user == NULL) $id_user = 1;
113 113
   		    if (!isset($id_source)) $id_source = 1;
114 114
   		    $query = 'INSERT INTO spotter_temp (id_user,datetime,hex,ident,latitude,longitude,verticalrate,speed,squawk,altitude,heading,registration,aircraft_icao,waypoints,id_source,noarchive,format_source,source_name,over_country) VALUES (:id_user,:datetime,:hex,:ident,:latitude,:longitude,:verticalrate,:speed,:squawk,:altitude,:heading,:registration,:aircraft_icao,:waypoints,:id_source,:noarchive, :format_source, :source_name, :over_country)';
115
-		    $query_values = array(':id_user' => $id_user,':datetime' => $data['datetime'],':hex' => $data['hex'],':ident' => $data['ident'],':latitude' => $data['latitude'],':longitude' => $data['longitude'],':verticalrate' => $data['verticalrate'],':speed' => $data['speed'],':squawk' => $data['squawk'],':altitude' => $data['altitude'],':heading' => $data['heading'],':registration' => $data['registration'],':aircraft_icao' => $data['aircraft_icao'],':waypoints' => $data['waypoints'],':id_source' => $id_source,':noarchive' => $data['noarchive'], ':format_source' => $data['format_source'], ':source_name' => $data['source_name'],':over_country' => $data['over_country']);
115
+		    $query_values = array(':id_user' => $id_user, ':datetime' => $data['datetime'], ':hex' => $data['hex'], ':ident' => $data['ident'], ':latitude' => $data['latitude'], ':longitude' => $data['longitude'], ':verticalrate' => $data['verticalrate'], ':speed' => $data['speed'], ':squawk' => $data['squawk'], ':altitude' => $data['altitude'], ':heading' => $data['heading'], ':registration' => $data['registration'], ':aircraft_icao' => $data['aircraft_icao'], ':waypoints' => $data['waypoints'], ':id_source' => $id_source, ':noarchive' => $data['noarchive'], ':format_source' => $data['format_source'], ':source_name' => $data['source_name'], ':over_country' => $data['over_country']);
116 116
 		    try {
117 117
                         $sth = $this->dbs['server']->prepare($query);
118 118
                         $sth->execute($query_values);
119
-                    } catch(PDOException $e) {
119
+                    } catch (PDOException $e) {
120 120
                         return "error : ".$e->getMessage();
121 121
             	    }
122 122
         	}
Please login to merge, or discard this patch.
Braces   +72 added lines, -25 removed lines patch added patch discarded remove patch
@@ -36,81 +36,128 @@
 block discarded – undo
36 36
 		    $data['hex'] = trim($line['hex']);
37 37
 		    if (preg_match('/^(\d{4}(?:\-\d{2}){2} \d{2}(?:\:\d{2}){2})$/',$line['datetime'])) {
38 38
 		        $data['datetime'] = $line['datetime'];
39
-		    } else $data['datetime'] = date('Y-m-d H:i:s');
39
+		    } else {
40
+		    	$data['datetime'] = date('Y-m-d H:i:s');
41
+		    }
40 42
 		    if (!isset($line['aircraft_icao'])) {
41 43
 		        $Spotter = new Spotter();
42 44
 		        $aircraft_icao = $Spotter->getAllAircraftType($data['hex']);
43 45
 		        $Spotter->db = null;
44 46
 			if ($aircraft_icao == '' && isset($line['aircraft_type'])) {
45
-			    if ($line['aircraft_type'] == 'PARA_GLIDER') $aircraft_icao = 'GLID';
46
-			    elseif ($line['aircraft_type'] == 'HELICOPTER_ROTORCRAFT') $aircraft_icao = 'UHEL';
47
-			    elseif ($line['aircraft_type'] == 'TOW_PLANE') $aircraft_icao = 'TOWPLANE';
48
-			    elseif ($line['aircraft_type'] == 'POWERED_AIRCRAFT') $aircraft_icao = 'POWAIRC';
47
+			    if ($line['aircraft_type'] == 'PARA_GLIDER') {
48
+			    	$aircraft_icao = 'GLID';
49
+			    } elseif ($line['aircraft_type'] == 'HELICOPTER_ROTORCRAFT') {
50
+			    	$aircraft_icao = 'UHEL';
51
+			    } elseif ($line['aircraft_type'] == 'TOW_PLANE') {
52
+			    	$aircraft_icao = 'TOWPLANE';
53
+			    } elseif ($line['aircraft_type'] == 'POWERED_AIRCRAFT') {
54
+			    	$aircraft_icao = 'POWAIRC';
55
+			    }
49 56
 			}
50 57
 			$data['aircraft_icao'] = $aircraft_icao;
51
-		    } else $data['aircraft_icao'] = $line['aircraft_icao'];
58
+		    } else {
59
+		    	$data['aircraft_icao'] = $line['aircraft_icao'];
60
+		    }
52 61
 		    //if ($globalDebug) echo "*********** New aircraft hex : ".$data['hex']." ***********\n";
53 62
 		}
54 63
 		if (isset($line['registration']) && $line['registration'] != '') {
55 64
 		    $data['registration'] = $line['registration'];
56
-		} else $data['registration'] = null;
65
+		} else {
66
+			$data['registration'] = null;
67
+		}
57 68
 		if (isset($line['waypoints']) && $line['waypoints'] != '') {
58 69
 		    $data['waypoints'] = $line['waypoints'];
59
-		} else $data['waypoints'] = null;
70
+		} else {
71
+			$data['waypoints'] = null;
72
+		}
60 73
 		if (isset($line['ident']) && $line['ident'] != '' && $line['ident'] != '????????' && $line['ident'] != '00000000' && preg_match('/^[a-zA-Z0-9]+$/', $line['ident'])) {
61 74
 		    $data['ident'] = trim($line['ident']);
62
-		} else $data['ident'] = null;
75
+		} else {
76
+			$data['ident'] = null;
77
+		}
63 78
 
64 79
 	        if (isset($line['latitude']) && isset($line['longitude']) && $line['latitude'] != '' && $line['longitude'] != '') {
65 80
 		    if (isset($line['latitude']) && $line['latitude'] != '' && $line['latitude'] != 0 && $line['latitude'] < 91 && $line['latitude'] > -90) {
66 81
 			$data['latitude'] = $line['latitude'];
67
-		    } else $data['latitude'] = null;
82
+		    } else {
83
+		    	$data['latitude'] = null;
84
+		    }
68 85
 		    if (isset($line['longitude']) && $line['longitude'] != '' && $line['longitude'] != 0 && $line['longitude'] < 360 && $line['longitude'] > -180) {
69
-		        if ($line['longitude'] > 180) $line['longitude'] = $line['longitude'] - 360;
86
+		        if ($line['longitude'] > 180) {
87
+		        	$line['longitude'] = $line['longitude'] - 360;
88
+		        }
70 89
 			$data['longitude'] = $line['longitude'];
71
-		    } else $data['longitude'] = null;
90
+		    } else {
91
+		    	$data['longitude'] = null;
92
+		    }
72 93
 		} else {
73 94
 		    $data['latitude'] = null;
74 95
 		    $data['longitude'] = null;
75 96
 		}
76 97
 		if (isset($line['verticalrate']) && $line['verticalrate'] != '') {
77 98
 		    $data['verticalrate'] = $line['verticalrate'];
78
-		} else $data['verticalrate'] = null;
99
+		} else {
100
+			$data['verticalrate'] = null;
101
+		}
79 102
 		if (isset($line['emergency']) && $line['emergency'] != '') {
80 103
 		    $data['emergency'] = $line['emergency'];
81
-		} else $data['emergency'] = null;
104
+		} else {
105
+			$data['emergency'] = null;
106
+		}
82 107
 		if (isset($line['ground']) && $line['ground'] != '') {
83 108
 		    $data['ground'] = $line['ground'];
84
-		} else $data['ground'] = null;
109
+		} else {
110
+			$data['ground'] = null;
111
+		}
85 112
 		if (isset($line['speed']) && $line['speed'] != '') {
86 113
 		    $data['speed'] = round($line['speed']);
87
-		} else $data['speed'] = null;
114
+		} else {
115
+			$data['speed'] = null;
116
+		}
88 117
 		if (isset($line['squawk']) && $line['squawk'] != '') {
89 118
 		    $data['squawk'] = $line['squawk'];
90
-		} else $data['squawk'] = null;
119
+		} else {
120
+			$data['squawk'] = null;
121
+		}
91 122
 
92 123
 		if (isset($line['altitude']) && $line['altitude'] != '') {
93 124
 			$data['altitude'] = round($line['altitude']);
94
-  		} else $data['altitude'] = null;
125
+  		} else {
126
+  			$data['altitude'] = null;
127
+  		}
95 128
 		if (isset($line['heading']) && $line['heading'] != '') {
96 129
 		    $data['heading'] = round($line['heading']);
97
-  		} else $data['heading'] = null;
130
+  		} else {
131
+  			$data['heading'] = null;
132
+  		}
98 133
 		if (isset($line['source_name']) && $line['source_name'] != '') {
99 134
 		    $data['source_name'] = $line['source_name'];
100
-  		} else $data['source_name'] = null;
135
+  		} else {
136
+  			$data['source_name'] = null;
137
+  		}
101 138
 		if (isset($line['over_country']) && $line['over_country'] != '') {
102 139
 		    $data['over_country'] = $line['over_country'];
103
-  		} else $data['over_country'] = null;
140
+  		} else {
141
+  			$data['over_country'] = null;
142
+  		}
104 143
   		if (isset($line['noarchive']) && $line['noarchive']) {
105 144
   		    $data['noarchive'] = true;
106
-  		} else $data['noarchive'] = false;
145
+  		} else {
146
+  			$data['noarchive'] = false;
147
+  		}
107 148
   		$data['format_source'] = $line['format_source'];
108
-  		if (isset($line['id_source'])) $id_source = $line['id_source'];
149
+  		if (isset($line['id_source'])) {
150
+  			$id_source = $line['id_source'];
151
+  		}
109 152
   		if (isset($data['hex'])) {
110 153
   		    echo '.';
111 154
   		    $id_user = $globalServerUserID;
112
-  		    if ($id_user == NULL) $id_user = 1;
113
-  		    if (!isset($id_source)) $id_source = 1;
155
+  		    if ($id_user == NULL) {
156
+  		    	$id_user = 1;
157
+  		    }
158
+  		    if (!isset($id_source)) {
159
+  		    	$id_source = 1;
160
+  		    }
114 161
   		    $query = 'INSERT INTO spotter_temp (id_user,datetime,hex,ident,latitude,longitude,verticalrate,speed,squawk,altitude,heading,registration,aircraft_icao,waypoints,id_source,noarchive,format_source,source_name,over_country) VALUES (:id_user,:datetime,:hex,:ident,:latitude,:longitude,:verticalrate,:speed,:squawk,:altitude,:heading,:registration,:aircraft_icao,:waypoints,:id_source,:noarchive, :format_source, :source_name, :over_country)';
115 162
 		    $query_values = array(':id_user' => $id_user,':datetime' => $data['datetime'],':hex' => $data['hex'],':ident' => $data['ident'],':latitude' => $data['latitude'],':longitude' => $data['longitude'],':verticalrate' => $data['verticalrate'],':speed' => $data['speed'],':squawk' => $data['squawk'],':altitude' => $data['altitude'],':heading' => $data['heading'],':registration' => $data['registration'],':aircraft_icao' => $data['aircraft_icao'],':waypoints' => $data['waypoints'],':id_source' => $id_source,':noarchive' => $data['noarchive'], ':format_source' => $data['format_source'], ':source_name' => $data['source_name'],':over_country' => $data['over_country']);
116 163
 		    try {
Please login to merge, or discard this patch.
date-statistics-route.php 1 patch
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -3,12 +3,12 @@  discard block
 block discarded – undo
3 3
 require_once('require/class.Spotter.php');
4 4
 require_once('require/class.Language.php');
5 5
 $Spotter = new Spotter();
6
-$sort = filter_input(INPUT_GET,'sort',FILTER_SANITIZE_STRING);
7
-$spotter_array = $Spotter->getSpotterDataByDate($_GET['date'],"0,1", $sort);
6
+$sort = filter_input(INPUT_GET, 'sort', FILTER_SANITIZE_STRING);
7
+$spotter_array = $Spotter->getSpotterDataByDate($_GET['date'], "0,1", $sort);
8 8
 
9 9
 if (!empty($spotter_array))
10 10
 {
11
-	$title = sprintf(_("Most Common Routes on %s"),date("l F j, Y", strtotime($spotter_array[0]['date_iso_8601'])));
11
+	$title = sprintf(_("Most Common Routes on %s"), date("l F j, Y", strtotime($spotter_array[0]['date_iso_8601'])));
12 12
 
13 13
 	require_once('header.php');
14 14
 	print '<div class="select-item">';
@@ -20,13 +20,13 @@  discard block
 block discarded – undo
20 20
 	print '</div>';
21 21
 
22 22
 	print '<div class="info column">';
23
-	print '<h1>'.sprintf(_("Flights from %s"),date("l F j, Y", strtotime($spotter_array[0]['date_iso_8601']))).'</h1>';
23
+	print '<h1>'.sprintf(_("Flights from %s"), date("l F j, Y", strtotime($spotter_array[0]['date_iso_8601']))).'</h1>';
24 24
 	print '</div>';
25 25
 
26 26
 	include('date-sub-menu.php');
27 27
 	print '<div class="column">';
28 28
 	print '<h2>'._("Most Common Routes").'</h2>';
29
-	print '<p>'.sprintf(_("The statistic below shows the most common routes on <strong>%s</strong>."),date("l F j, Y", strtotime($spotter_array[0]['date_iso_8601']))).'</p>';
29
+	print '<p>'.sprintf(_("The statistic below shows the most common routes on <strong>%s</strong>."), date("l F j, Y", strtotime($spotter_array[0]['date_iso_8601']))).'</p>';
30 30
 
31 31
 	$route_array = $Spotter->countAllRoutesByDate($_GET['date']);
32 32
 	if (!empty($route_array))
@@ -43,7 +43,7 @@  discard block
 block discarded – undo
43 43
 		print '</thead>';
44 44
 		print '<tbody>';
45 45
 		$i = 1;
46
-		foreach($route_array as $route_item)
46
+		foreach ($route_array as $route_item)
47 47
 		{
48 48
 			print '<tr>';
49 49
 			print '<td><strong>'.$i.'</strong></td>';
Please login to merge, or discard this patch.
manufacturer-statistics-time.php 2 patches
Indentation   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -3,8 +3,8 @@  discard block
 block discarded – undo
3 3
 require_once('require/class.Spotter.php');
4 4
 require_once('require/class.Language.php');
5 5
 if (!isset($_GET['aircraft_manufacturer'])) {
6
-        header('Location: '.$globalURL.'/manufacturer');
7
-        die();
6
+		header('Location: '.$globalURL.'/manufacturer');
7
+		die();
8 8
 }
9 9
 $Spotter = new Spotter();
10 10
 $manufacturer = ucwords(str_replace("-", " ", filter_input(INPUT_GET,'aircraft_manufacturer',FILTER_SANITIZE_STRING)));
@@ -53,7 +53,7 @@  discard block
 block discarded – undo
53 53
           function drawChart() {
54 54
             var data = google.visualization.arrayToDataTable([
55 55
             	["'._("Hour").'", "'._("# of Flights").'"], ';
56
-            	$hour_data = '';
56
+				$hour_data = '';
57 57
 	foreach($hour_array as $hour_item)
58 58
 	{
59 59
 		$hour_data .= '[ "'.date("ga", strtotime($hour_item['hour_name'].":00")).'",'.$hour_item['hour_count'].'],';
Please login to merge, or discard this patch.
Spacing   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -7,23 +7,23 @@  discard block
 block discarded – undo
7 7
         die();
8 8
 }
9 9
 $Spotter = new Spotter();
10
-$manufacturer = ucwords(str_replace("-", " ", filter_input(INPUT_GET,'aircraft_manufacturer',FILTER_SANITIZE_STRING)));
10
+$manufacturer = ucwords(str_replace("-", " ", filter_input(INPUT_GET, 'aircraft_manufacturer', FILTER_SANITIZE_STRING)));
11 11
 
12
-$sort = filter_input(INPUT_GET,'sort',FILTER_SANITIZE_STRING);
13
-$spotter_array = $Spotter->getSpotterDataByManufacturer($manufacturer,"0,1", $sort);
12
+$sort = filter_input(INPUT_GET, 'sort', FILTER_SANITIZE_STRING);
13
+$spotter_array = $Spotter->getSpotterDataByManufacturer($manufacturer, "0,1", $sort);
14 14
 
15 15
 if (!empty($spotter_array))
16 16
 {
17
-	$title = sprintf(_("Most Common Time of Day from %s"),$manufacturer);
17
+	$title = sprintf(_("Most Common Time of Day from %s"), $manufacturer);
18 18
 	require_once('header.php');
19 19
 	print '<div class="select-item">';
20 20
 	print '<form action="'.$globalURL.'/manufacturer" method="post">';
21 21
 	print '<select name="aircraft_manufacturer" class="selectpicker" data-live-search="true">';
22 22
 	print '<option></option>';
23 23
 	$all_manufacturers = $Spotter->getAllManufacturers();
24
-	foreach($all_manufacturers as $all_manufacturer)
24
+	foreach ($all_manufacturers as $all_manufacturer)
25 25
 	{
26
-		if($_GET['aircraft_manufacturer'] == strtolower(str_replace(" ", "-", $all_manufacturer['aircraft_manufacturer'])))
26
+		if ($_GET['aircraft_manufacturer'] == strtolower(str_replace(" ", "-", $all_manufacturer['aircraft_manufacturer'])))
27 27
 		{
28 28
 			print '<option value="'.strtolower(str_replace(" ", "-", $all_manufacturer['aircraft_manufacturer'])).'" selected="selected">'.$all_manufacturer['aircraft_manufacturer'].'</option>';
29 29
 		} else {
@@ -42,7 +42,7 @@  discard block
 block discarded – undo
42 42
 	include('manufacturer-sub-menu.php');
43 43
 	print '<div class="column">';
44 44
 	print '<h2>'._("Most Common Time of Day").'</h2>';
45
-	print '<p>'.sprintf(_("The statistic below shows the most common time of day from <strong>%s</strong>."),$manufacturer).'</p>';
45
+	print '<p>'.sprintf(_("The statistic below shows the most common time of day from <strong>%s</strong>."), $manufacturer).'</p>';
46 46
 
47 47
 	$hour_array = $Spotter->countAllHoursByManufacturer($manufacturer);
48 48
 	print '<script type="text/javascript" src="https://www.google.com/jsapi"></script>';
@@ -54,7 +54,7 @@  discard block
 block discarded – undo
54 54
             var data = google.visualization.arrayToDataTable([
55 55
             	["'._("Hour").'", "'._("# of Flights").'"], ';
56 56
             	$hour_data = '';
57
-	foreach($hour_array as $hour_item)
57
+	foreach ($hour_array as $hour_item)
58 58
 	{
59 59
 		$hour_data .= '[ "'.date("ga", strtotime($hour_item['hour_name'].":00")).'",'.$hour_item['hour_count'].'],';
60 60
 	}
Please login to merge, or discard this patch.
ident-statistics-airline.php 2 patches
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -7,13 +7,13 @@  discard block
 block discarded – undo
7 7
         die();
8 8
 }
9 9
 $Spotter = new Spotter();
10
-$sort = filter_input(INPUT_GET,'sort',FILTER_SANITIZE_STRING);
11
-$isent = filter_input(INPUT_GET,'ident',FILTER_SANITIZE_STRING);
12
-$spotter_array = $Spotter->getSpotterDataByIdent($ident,"0,1", $sort);
10
+$sort = filter_input(INPUT_GET, 'sort', FILTER_SANITIZE_STRING);
11
+$isent = filter_input(INPUT_GET, 'ident', FILTER_SANITIZE_STRING);
12
+$spotter_array = $Spotter->getSpotterDataByIdent($ident, "0,1", $sort);
13 13
 
14 14
 if (!empty($spotter_array))
15 15
 {
16
-	$title = sprintf(_("Most Common Airlines of %s"),$spotter_array[0]['ident']);
16
+	$title = sprintf(_("Most Common Airlines of %s"), $spotter_array[0]['ident']);
17 17
 	require_once('header.php');
18 18
 	print '<div class="info column">';
19 19
 	print '<h1>'.$spotter_array[0]['ident'].'</h1>';
@@ -24,7 +24,7 @@  discard block
 block discarded – undo
24 24
 	include('ident-sub-menu.php');
25 25
 	print '<div class="column">';
26 26
 	print '<h2>'._("Most Common Airlines").'</h2>';
27
-	print '<p>'.sprintf(_("The statistic below shows the most common airlines of flights using the ident/callsign <strong>%s</strong>."),$spotter_array[0]['ident']).'</p>';
27
+	print '<p>'.sprintf(_("The statistic below shows the most common airlines of flights using the ident/callsign <strong>%s</strong>."), $spotter_array[0]['ident']).'</p>';
28 28
 
29 29
 	$airline_array = $Spotter->countAllAirlinesByIdent($_GET['ident']);
30 30
 	if (!empty($airline_array))
@@ -41,7 +41,7 @@  discard block
 block discarded – undo
41 41
 		print '</thead>';
42 42
 		print '<tbody>';
43 43
 		$i = 1;
44
-		foreach($airline_array as $airline_item)
44
+		foreach ($airline_array as $airline_item)
45 45
 		{
46 46
 			print '<tr>';
47 47
 			print '<td><strong>'.$i.'</strong></td>';
Please login to merge, or discard this patch.
Indentation   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -3,8 +3,8 @@
 block discarded – undo
3 3
 require_once('require/class.Spotter.php');
4 4
 require_once('require/class.Language.php');
5 5
 if (!isset($_GET['ident'])) {
6
-        header('Location: '.$globalURL.'/ident');
7
-        die();
6
+		header('Location: '.$globalURL.'/ident');
7
+		die();
8 8
 }
9 9
 $Spotter = new Spotter();
10 10
 $ident = filter_input(INPUT_GET,'ident',FILTER_SANITIZE_STRING);
Please login to merge, or discard this patch.
statistics-year.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -22,7 +22,7 @@  discard block
 block discarded – undo
22 22
             	["'._("Month").'", "'._("# of Flights").'"], ';
23 23
 
24 24
 $date_data = '';
25
-foreach($date_array as $date_item)
25
+foreach ($date_array as $date_item)
26 26
 {
27 27
 	$date_data .= '[ "'.date("F, Y", strtotime($date_item['year_name'].'-'.$date_item['month_name'].'-01')).'",'.$date_item['date_count'].'],';
28 28
 }
@@ -59,7 +59,7 @@  discard block
 block discarded – undo
59 59
 	print '</thead>';
60 60
 	print '<tbody>';
61 61
 	$i = 1;
62
-	foreach($date_array as $date_item)
62
+	foreach ($date_array as $date_item)
63 63
 	{
64 64
 		print '<tr>';
65 65
 		print '<td><strong>'.$i.'</strong></td>';
Please login to merge, or discard this patch.
search-json.php 3 patches
Indentation   +81 added lines, -81 removed lines patch added patch discarded remove patch
@@ -4,55 +4,55 @@  discard block
 block discarded – undo
4 4
 require_once('require/class.Language.php');
5 5
 $Spotter = new Spotter();
6 6
 if (isset($_GET['start_date'])) {
7
-        //for the date manipulation into the query
8
-        if($_GET['start_date'] != "" && $_GET['end_date'] != ""){
9
-                $start_date = $_GET['start_date'].":00";
10
-                $end_date = $_GET['end_date'].":00";
11
-                $sql_date = $start_date.",".$end_date;
12
-        } else if($_GET['start_date'] != ""){
13
-                $start_date = $_GET['start_date'].":00";
14
-                $sql_date = $start_date;
15
-        } else if($_GET['start_date'] == "" && $_GET['end_date'] != ""){
16
-                $end_date = date("Y-m-d H:i:s", strtotime("2014-04-12")).",".$_GET['end_date'].":00";
17
-                $sql_date = $end_date;
18
-        } else $sql_date = '';
7
+		//for the date manipulation into the query
8
+		if($_GET['start_date'] != "" && $_GET['end_date'] != ""){
9
+				$start_date = $_GET['start_date'].":00";
10
+				$end_date = $_GET['end_date'].":00";
11
+				$sql_date = $start_date.",".$end_date;
12
+		} else if($_GET['start_date'] != ""){
13
+				$start_date = $_GET['start_date'].":00";
14
+				$sql_date = $start_date;
15
+		} else if($_GET['start_date'] == "" && $_GET['end_date'] != ""){
16
+				$end_date = date("Y-m-d H:i:s", strtotime("2014-04-12")).",".$_GET['end_date'].":00";
17
+				$sql_date = $end_date;
18
+		} else $sql_date = '';
19 19
 } else $sql_date = '';
20 20
 
21 21
 if (isset($_GET['highest_altitude'])) {
22
-        //for altitude manipulation
23
-        if($_GET['highest_altitude'] != "" && $_GET['lowest_altitude'] != ""){
24
-                $end_altitude = $_GET['highest_altitude'];
25
-                $start_altitude = $_GET['lowest_altitude'];
26
-                $sql_altitude = $start_altitude.",".$end_altitude;
27
-        } else if($_GET['highest_altitude'] != ""){
28
-                $end_altitude = $_GET['highest_altitude'];
29
-                $sql_altitude = $end_altitude;
30
-        } else if($_GET['highest_altitude'] == "" && $_GET['lowest_altitude'] != ""){
31
-                $start_altitude = $_GET['lowest_altitude'].",60000";
32
-                $sql_altitude = $start_altitude;
33
-        } else $sql_altitude = '';
22
+		//for altitude manipulation
23
+		if($_GET['highest_altitude'] != "" && $_GET['lowest_altitude'] != ""){
24
+				$end_altitude = $_GET['highest_altitude'];
25
+				$start_altitude = $_GET['lowest_altitude'];
26
+				$sql_altitude = $start_altitude.",".$end_altitude;
27
+		} else if($_GET['highest_altitude'] != ""){
28
+				$end_altitude = $_GET['highest_altitude'];
29
+				$sql_altitude = $end_altitude;
30
+		} else if($_GET['highest_altitude'] == "" && $_GET['lowest_altitude'] != ""){
31
+				$start_altitude = $_GET['lowest_altitude'].",60000";
32
+				$sql_altitude = $start_altitude;
33
+		} else $sql_altitude = '';
34 34
 } else $sql_altitude = '';
35 35
 
36 36
 //calculuation for the pagination
37 37
 if(!isset($_GET['limit']))
38 38
 {
39
-        if (!isset($_GET['number_results']))
40
-        {
41
-                $limit_start = 0;
42
-                $limit_end = 25;
43
-                $absolute_difference = 25;
44
-        } else {
45
-                if ($_GET['number_results'] > 1000){
46
-                        $_GET['number_results'] = 1000;
47
-                }
48
-                $limit_start = 0;
49
-                $limit_end = $_GET['number_results'];
50
-                $absolute_difference = $_GET['number_results'];
51
-        }
39
+		if (!isset($_GET['number_results']))
40
+		{
41
+				$limit_start = 0;
42
+				$limit_end = 25;
43
+				$absolute_difference = 25;
44
+		} else {
45
+				if ($_GET['number_results'] > 1000){
46
+						$_GET['number_results'] = 1000;
47
+				}
48
+				$limit_start = 0;
49
+				$limit_end = $_GET['number_results'];
50
+				$absolute_difference = $_GET['number_results'];
51
+		}
52 52
 }  else {
53
-        $limit_explode = explode(",", $_GET['limit']);
54
-        $limit_start = $limit_explode[0];
55
-        $limit_end = $limit_explode[1];
53
+		$limit_explode = explode(",", $_GET['limit']);
54
+		$limit_start = $limit_explode[0];
55
+		$limit_end = $limit_explode[1];
56 56
 }
57 57
 
58 58
 $absolute_difference = abs($limit_start - $limit_end);
@@ -89,52 +89,52 @@  discard block
 block discarded – undo
89 89
        
90 90
 $output = '{';
91 91
   $output .= '"flightairmap": {';
92
-    $output .= '"title": "FlightAirMap JSON Feed",';
93
-    $output .= '"link": "http://www.flightairmap.fr",';
94
-    $output .= '"aircraft": [';
92
+	$output .= '"title": "FlightAirMap JSON Feed",';
93
+	$output .= '"link": "http://www.flightairmap.fr",';
94
+	$output .= '"aircraft": [';
95 95
     
96
-    if (!empty($spotter_array))
96
+	if (!empty($spotter_array))
97 97
 	  {
98
-	    foreach($spotter_array as $spotter_item)
99
-	    {
98
+		foreach($spotter_array as $spotter_item)
99
+		{
100 100
 				
101 101
 				$output .= '{';    	
102
-		            $output .= '"id": "'.$spotter_item['spotter_id'].'",';
103
-                    $output .= '"ident": "'.$spotter_item['ident'].'",';
104
-                    $output .= '"registration": "'.$spotter_item['registration'].'",';
105
-                    $output .= '"aircraft_icao": "'.$spotter_item['aircraft_type'].'",';
106
-                    $output .= '"aircraft_name": "'.$spotter_item['aircraft_name'].'",';
107
-                    $output .= '"aircraft_manufacturer": "'.$spotter_item['aircraft_manufacturer'].'",';
108
-                    $output .= '"airline_name": "'.$spotter_item['airline_name'].'",';
109
-                    $output .= '"airline_icao": "'.$spotter_item['airline_icao'].'",';
110
-                    $output .= '"airline_iata": "'.$spotter_item['airline_iata'].'",';
111
-                    $output .= '"airline_country": "'.$spotter_item['airline_country'].'",';
112
-                    $output .= '"airline_callsign": "'.$spotter_item['airline_callsign'].'",';
113
-                    $output .= '"airline_type": "'.$spotter_item['airline_type'].'",';
114
-                    $output .= '"departure_airport_city": "'.$spotter_item['departure_airport_city'].'",';
115
-                    $output .= '"departure_airport_country": "'.$spotter_item['departure_airport_country'].'",';
116
-                    $output .= '"departure_airport_iata": "'.$spotter_item['departure_airport_iata'].'",';
117
-                    $output .= '"departure_airport_icao": "'.$spotter_item['departure_airport_icao'].'",';
118
-                    $output .= '"departure_airport_latitude": "'.$spotter_item['departure_airport_latitude'].'",';
119
-                    $output .= '"departure_airport_longitude": "'.$spotter_item['departure_airport_longitude'].'",';
120
-                    $output .= '"departure_airport_altitude": "'.$spotter_item['departure_airport_altitude'].'",'; 
121
-                    $output .= '"arrival_airport_city": "'.$spotter_item['arrival_airport_city'].'",';
122
-                    $output .= '"arrival_airport_country": "'.$spotter_item['arrival_airport_country'].'",';
123
-                    $output .= '"arrival_airport_iata": "'.$spotter_item['arrival_airport_iata'].'",';
124
-                    $output .= '"departure_airport_icao": "'.$spotter_item['arrival_airport_icao'].'",';
125
-                    $output .= '"arrival_airport_latitude": "'.$spotter_item['arrival_airport_latitude'].'",';
126
-                    $output .= '"arrival_airport_longitude": "'.$spotter_item['arrival_airport_longitude'].'",';
127
-                    $output .= '"arrival_airport_altitude": "'.$spotter_item['arrival_airport_altitude'].'",';
128
-                    $output .= '"latitude": "'.$spotter_item['latitude'].'",';
129
-                    $output .= '"longitude": "'.$spotter_item['longitude'].'",';
130
-                    $output .= '"altitude": "'.$spotter_item['altitude'].'",';
131
-                    $output .= '"ground_speed": "'.$spotter_item['ground_speed'].'",';
132
-                    $output .= '"heading": "'.$spotter_item['heading'].'",';
133
-                    $output .= '"heading_name": "'.$spotter_item['heading_name'].'",';
134
-                    $output .= '"waypoints": "'.$spotter_item['waypoints'].'",';
135
-                    $output .= '"date": "'.date("c", strtotime($spotter_item['date_iso_8601'])).'"';
102
+					$output .= '"id": "'.$spotter_item['spotter_id'].'",';
103
+					$output .= '"ident": "'.$spotter_item['ident'].'",';
104
+					$output .= '"registration": "'.$spotter_item['registration'].'",';
105
+					$output .= '"aircraft_icao": "'.$spotter_item['aircraft_type'].'",';
106
+					$output .= '"aircraft_name": "'.$spotter_item['aircraft_name'].'",';
107
+					$output .= '"aircraft_manufacturer": "'.$spotter_item['aircraft_manufacturer'].'",';
108
+					$output .= '"airline_name": "'.$spotter_item['airline_name'].'",';
109
+					$output .= '"airline_icao": "'.$spotter_item['airline_icao'].'",';
110
+					$output .= '"airline_iata": "'.$spotter_item['airline_iata'].'",';
111
+					$output .= '"airline_country": "'.$spotter_item['airline_country'].'",';
112
+					$output .= '"airline_callsign": "'.$spotter_item['airline_callsign'].'",';
113
+					$output .= '"airline_type": "'.$spotter_item['airline_type'].'",';
114
+					$output .= '"departure_airport_city": "'.$spotter_item['departure_airport_city'].'",';
115
+					$output .= '"departure_airport_country": "'.$spotter_item['departure_airport_country'].'",';
116
+					$output .= '"departure_airport_iata": "'.$spotter_item['departure_airport_iata'].'",';
117
+					$output .= '"departure_airport_icao": "'.$spotter_item['departure_airport_icao'].'",';
118
+					$output .= '"departure_airport_latitude": "'.$spotter_item['departure_airport_latitude'].'",';
119
+					$output .= '"departure_airport_longitude": "'.$spotter_item['departure_airport_longitude'].'",';
120
+					$output .= '"departure_airport_altitude": "'.$spotter_item['departure_airport_altitude'].'",'; 
121
+					$output .= '"arrival_airport_city": "'.$spotter_item['arrival_airport_city'].'",';
122
+					$output .= '"arrival_airport_country": "'.$spotter_item['arrival_airport_country'].'",';
123
+					$output .= '"arrival_airport_iata": "'.$spotter_item['arrival_airport_iata'].'",';
124
+					$output .= '"departure_airport_icao": "'.$spotter_item['arrival_airport_icao'].'",';
125
+					$output .= '"arrival_airport_latitude": "'.$spotter_item['arrival_airport_latitude'].'",';
126
+					$output .= '"arrival_airport_longitude": "'.$spotter_item['arrival_airport_longitude'].'",';
127
+					$output .= '"arrival_airport_altitude": "'.$spotter_item['arrival_airport_altitude'].'",';
128
+					$output .= '"latitude": "'.$spotter_item['latitude'].'",';
129
+					$output .= '"longitude": "'.$spotter_item['longitude'].'",';
130
+					$output .= '"altitude": "'.$spotter_item['altitude'].'",';
131
+					$output .= '"ground_speed": "'.$spotter_item['ground_speed'].'",';
132
+					$output .= '"heading": "'.$spotter_item['heading'].'",';
133
+					$output .= '"heading_name": "'.$spotter_item['heading_name'].'",';
134
+					$output .= '"waypoints": "'.$spotter_item['waypoints'].'",';
135
+					$output .= '"date": "'.date("c", strtotime($spotter_item['date_iso_8601'])).'"';
136 136
 				$output .= '},';
137
-	    }
137
+		}
138 138
 	   }
139 139
 	   $output  = substr($output, 0, -1);
140 140
 		 $output .= ']';
Please login to merge, or discard this patch.
Spacing   +27 added lines, -27 removed lines patch added patch discarded remove patch
@@ -5,14 +5,14 @@  discard block
 block discarded – undo
5 5
 $Spotter = new Spotter();
6 6
 if (isset($_GET['start_date'])) {
7 7
         //for the date manipulation into the query
8
-        if($_GET['start_date'] != "" && $_GET['end_date'] != ""){
8
+        if ($_GET['start_date'] != "" && $_GET['end_date'] != "") {
9 9
                 $start_date = $_GET['start_date'].":00";
10 10
                 $end_date = $_GET['end_date'].":00";
11 11
                 $sql_date = $start_date.",".$end_date;
12
-        } else if($_GET['start_date'] != ""){
12
+        } else if ($_GET['start_date'] != "") {
13 13
                 $start_date = $_GET['start_date'].":00";
14 14
                 $sql_date = $start_date;
15
-        } else if($_GET['start_date'] == "" && $_GET['end_date'] != ""){
15
+        } else if ($_GET['start_date'] == "" && $_GET['end_date'] != "") {
16 16
                 $end_date = date("Y-m-d H:i:s", strtotime("2014-04-12")).",".$_GET['end_date'].":00";
17 17
                 $sql_date = $end_date;
18 18
         } else $sql_date = '';
@@ -20,21 +20,21 @@  discard block
 block discarded – undo
20 20
 
21 21
 if (isset($_GET['highest_altitude'])) {
22 22
         //for altitude manipulation
23
-        if($_GET['highest_altitude'] != "" && $_GET['lowest_altitude'] != ""){
23
+        if ($_GET['highest_altitude'] != "" && $_GET['lowest_altitude'] != "") {
24 24
                 $end_altitude = $_GET['highest_altitude'];
25 25
                 $start_altitude = $_GET['lowest_altitude'];
26 26
                 $sql_altitude = $start_altitude.",".$end_altitude;
27
-        } else if($_GET['highest_altitude'] != ""){
27
+        } else if ($_GET['highest_altitude'] != "") {
28 28
                 $end_altitude = $_GET['highest_altitude'];
29 29
                 $sql_altitude = $end_altitude;
30
-        } else if($_GET['highest_altitude'] == "" && $_GET['lowest_altitude'] != ""){
30
+        } else if ($_GET['highest_altitude'] == "" && $_GET['lowest_altitude'] != "") {
31 31
                 $start_altitude = $_GET['lowest_altitude'].",60000";
32 32
                 $sql_altitude = $start_altitude;
33 33
         } else $sql_altitude = '';
34 34
 } else $sql_altitude = '';
35 35
 
36 36
 //calculuation for the pagination
37
-if(!isset($_GET['limit']))
37
+if (!isset($_GET['limit']))
38 38
 {
39 39
         if (!isset($_GET['number_results']))
40 40
         {
@@ -42,14 +42,14 @@  discard block
 block discarded – undo
42 42
                 $limit_end = 25;
43 43
                 $absolute_difference = 25;
44 44
         } else {
45
-                if ($_GET['number_results'] > 1000){
45
+                if ($_GET['number_results'] > 1000) {
46 46
                         $_GET['number_results'] = 1000;
47 47
                 }
48 48
                 $limit_start = 0;
49 49
                 $limit_end = $_GET['number_results'];
50 50
                 $absolute_difference = $_GET['number_results'];
51 51
         }
52
-}  else {
52
+} else {
53 53
         $limit_explode = explode(",", $_GET['limit']);
54 54
         $limit_start = $limit_explode[0];
55 55
         $limit_end = $limit_explode[1];
@@ -69,23 +69,23 @@  discard block
 block discarded – undo
69 69
 
70 70
 if (isset($_GET['sort'])) $sort = $_GET['sort'];
71 71
 else $sort = '';
72
-$q = filter_input(INPUT_GET,'q',FILTER_SANITIZE_STRING);
73
-$registration = filter_input(INPUT_GET,'registratrion',FILTER_SANITIZE_STRING);
74
-$aircraft = filter_input(INPUT_GET,'aircraft',FILTER_SANITIZE_STRING);
75
-$manufacturer = filter_input(INPUT_GET,'manufacturer',FILTER_SANITIZE_STRING);
76
-$highlights = filter_input(INPUT_GET,'highlights',FILTER_SANITIZE_STRING);
77
-$airline = filter_input(INPUT_GET,'airline',FILTER_SANITIZE_STRING);
78
-$airline_country = filter_input(INPUT_GET,'airline_country',FILTER_SANITIZE_STRING);
79
-$airline_type = filter_input(INPUT_GET,'airline_type',FILTER_SANITIZE_STRING);
80
-$airport = filter_input(INPUT_GET,'airport',FILTER_SANITIZE_STRING);
81
-$airport_country = filter_input(INPUT_GET,'airport_country',FILTER_SANITIZE_STRING);
82
-$callsign = filter_input(INPUT_GET,'callsign',FILTER_SANITIZE_STRING);
83
-$owner = filter_input(INPUT_GET,'owner',FILTER_SANITIZE_STRING);
84
-$pilot_id = filter_input(INPUT_GET,'pilot_id',FILTER_SANITIZE_STRING);
85
-$pilot_name = filter_input(INPUT_GET,'pilot_name',FILTER_SANITIZE_STRING);
86
-$departure_airport_route = filter_input(INPUT_GET,'departure_airport_route',FILTER_SANITIZE_STRING);
87
-$arrival_airport_route = filter_input(INPUT_GET,'arrival_airport_route',FILTER_SANITIZE_STRING);
88
-$spotter_array = $Spotter->searchSpotterData($q,$registration,$aircraft,strtolower(str_replace("-", " ", $manufacturer)),$highlights,$airline,$airline_country,$airline_type,$airport,$airport_country,$callsign,$departure_airport_route,$arrival_airport_route,$owner,$pilot_id,$pilot_name,$sql_altitude,$sql_date,$limit_start.",".$absolute_difference,$sort,'');
72
+$q = filter_input(INPUT_GET, 'q', FILTER_SANITIZE_STRING);
73
+$registration = filter_input(INPUT_GET, 'registratrion', FILTER_SANITIZE_STRING);
74
+$aircraft = filter_input(INPUT_GET, 'aircraft', FILTER_SANITIZE_STRING);
75
+$manufacturer = filter_input(INPUT_GET, 'manufacturer', FILTER_SANITIZE_STRING);
76
+$highlights = filter_input(INPUT_GET, 'highlights', FILTER_SANITIZE_STRING);
77
+$airline = filter_input(INPUT_GET, 'airline', FILTER_SANITIZE_STRING);
78
+$airline_country = filter_input(INPUT_GET, 'airline_country', FILTER_SANITIZE_STRING);
79
+$airline_type = filter_input(INPUT_GET, 'airline_type', FILTER_SANITIZE_STRING);
80
+$airport = filter_input(INPUT_GET, 'airport', FILTER_SANITIZE_STRING);
81
+$airport_country = filter_input(INPUT_GET, 'airport_country', FILTER_SANITIZE_STRING);
82
+$callsign = filter_input(INPUT_GET, 'callsign', FILTER_SANITIZE_STRING);
83
+$owner = filter_input(INPUT_GET, 'owner', FILTER_SANITIZE_STRING);
84
+$pilot_id = filter_input(INPUT_GET, 'pilot_id', FILTER_SANITIZE_STRING);
85
+$pilot_name = filter_input(INPUT_GET, 'pilot_name', FILTER_SANITIZE_STRING);
86
+$departure_airport_route = filter_input(INPUT_GET, 'departure_airport_route', FILTER_SANITIZE_STRING);
87
+$arrival_airport_route = filter_input(INPUT_GET, 'arrival_airport_route', FILTER_SANITIZE_STRING);
88
+$spotter_array = $Spotter->searchSpotterData($q, $registration, $aircraft, strtolower(str_replace("-", " ", $manufacturer)), $highlights, $airline, $airline_country, $airline_type, $airport, $airport_country, $callsign, $departure_airport_route, $arrival_airport_route, $owner, $pilot_id, $pilot_name, $sql_altitude, $sql_date, $limit_start.",".$absolute_difference, $sort, '');
89 89
        
90 90
 $output = '{';
91 91
   $output .= '"flightairmap": {';
@@ -95,7 +95,7 @@  discard block
 block discarded – undo
95 95
     
96 96
     if (!empty($spotter_array))
97 97
 	  {
98
-	    foreach($spotter_array as $spotter_item)
98
+	    foreach ($spotter_array as $spotter_item)
99 99
 	    {
100 100
 				
101 101
 				$output .= '{';    	
Please login to merge, or discard this patch.
Braces   +18 added lines, -7 removed lines patch added patch discarded remove patch
@@ -15,8 +15,12 @@  discard block
 block discarded – undo
15 15
         } else if($_GET['start_date'] == "" && $_GET['end_date'] != ""){
16 16
                 $end_date = date("Y-m-d H:i:s", strtotime("2014-04-12")).",".$_GET['end_date'].":00";
17 17
                 $sql_date = $end_date;
18
-        } else $sql_date = '';
19
-} else $sql_date = '';
18
+        } else {
19
+        	$sql_date = '';
20
+        }
21
+        } else {
22
+	$sql_date = '';
23
+}
20 24
 
21 25
 if (isset($_GET['highest_altitude'])) {
22 26
         //for altitude manipulation
@@ -30,8 +34,12 @@  discard block
 block discarded – undo
30 34
         } else if($_GET['highest_altitude'] == "" && $_GET['lowest_altitude'] != ""){
31 35
                 $start_altitude = $_GET['lowest_altitude'].",60000";
32 36
                 $sql_altitude = $start_altitude;
33
-        } else $sql_altitude = '';
34
-} else $sql_altitude = '';
37
+        } else {
38
+        	$sql_altitude = '';
39
+        }
40
+        } else {
41
+	$sql_altitude = '';
42
+}
35 43
 
36 44
 //calculuation for the pagination
37 45
 if(!isset($_GET['limit']))
@@ -49,7 +57,7 @@  discard block
 block discarded – undo
49 57
                 $limit_end = $_GET['number_results'];
50 58
                 $absolute_difference = $_GET['number_results'];
51 59
         }
52
-}  else {
60
+} else {
53 61
         $limit_explode = explode(",", $_GET['limit']);
54 62
         $limit_start = $limit_explode[0];
55 63
         $limit_end = $limit_explode[1];
@@ -67,8 +75,11 @@  discard block
 block discarded – undo
67 75
 
68 76
 header("Content-type: text/yaml");
69 77
 
70
-if (isset($_GET['sort'])) $sort = $_GET['sort'];
71
-else $sort = '';
78
+if (isset($_GET['sort'])) {
79
+	$sort = $_GET['sort'];
80
+} else {
81
+	$sort = '';
82
+}
72 83
 $q = filter_input(INPUT_GET,'q',FILTER_SANITIZE_STRING);
73 84
 $registration = filter_input(INPUT_GET,'registratrion',FILTER_SANITIZE_STRING);
74 85
 $aircraft = filter_input(INPUT_GET,'aircraft',FILTER_SANITIZE_STRING);
Please login to merge, or discard this patch.