Completed
Push — master ( f55b0d...980a74 )
by Yannick
54:56 queued 21:33
created
require/class.ATC.php 1 patch
Spacing   +31 added lines, -31 removed lines patch added patch discarded remove patch
@@ -15,22 +15,22 @@  discard block
 block discarded – undo
15 15
 	* @param Array $filter the filter
16 16
 	* @return Array the SQL part
17 17
 	*/
18
-	public function getFilter($filter = array(),$where = false,$and = false) {
18
+	public function getFilter($filter = array(), $where = false, $and = false) {
19 19
 		global $globalFilter, $globalStatsFilters, $globalFilterName;
20 20
 		if (is_array($globalStatsFilters) && isset($globalStatsFilters[$globalFilterName])) {
21 21
 			if (isset($globalStatsFilters[$globalFilterName][0]['source'])) {
22
-				foreach($globalStatsFilters[$globalFilterName] as $source) {
22
+				foreach ($globalStatsFilters[$globalFilterName] as $source) {
23 23
 					if (isset($source['source'])) $filter['source'][] = $source['source'];
24 24
 				}
25 25
 			} else {
26 26
 				$filter = $globalStatsFilters[$globalFilterName];
27 27
 			}
28 28
 		}
29
-		if (is_array($globalFilter)) $filter = array_merge($filter,$globalFilter);
29
+		if (is_array($globalFilter)) $filter = array_merge($filter, $globalFilter);
30 30
 		$filter_query_join = '';
31 31
 		$filter_query_where = '';
32 32
 		if (isset($filter['source']) && !empty($filter['source'])) {
33
-			$filter_query_where = " WHERE format_source IN ('".implode("','",$filter['source'])."')";
33
+			$filter_query_where = " WHERE format_source IN ('".implode("','", $filter['source'])."')";
34 34
 		}
35 35
 		if ($filter_query_where == '' && $where) $filter_query_where = ' WHERE';
36 36
 		elseif ($filter_query_where != '' && $and) $filter_query_where .= ' AND';
@@ -45,7 +45,7 @@  discard block
 block discarded – undo
45 45
 		try {
46 46
 			$sth = $this->db->prepare($query);
47 47
 			$sth->execute($query_values);
48
-		} catch(PDOException $e) {
48
+		} catch (PDOException $e) {
49 49
 			return "error : ".$e->getMessage();
50 50
 		}
51 51
 		$all = $sth->fetchAll(PDO::FETCH_ASSOC);
@@ -53,66 +53,66 @@  discard block
 block discarded – undo
53 53
 	}
54 54
 
55 55
 	public function getById($id) {
56
-		$filter_query = $this->getFilter(array(),true,true);
56
+		$filter_query = $this->getFilter(array(), true, true);
57 57
 		$query = "SELECT * FROM atc".$filter_query." atc_id = :id";
58 58
 		$query_values = array(':id' => $id);
59 59
 		try {
60 60
 			$sth = $this->db->prepare($query);
61 61
 			$sth->execute($query_values);
62
-		} catch(PDOException $e) {
62
+		} catch (PDOException $e) {
63 63
 			return "error : ".$e->getMessage();
64 64
 		}
65 65
 		$all = $sth->fetchAll(PDO::FETCH_ASSOC);
66 66
 		return $all;
67 67
 	}
68 68
 
69
-	public function getByIdent($ident,$format_source = '') {
70
-		$filter_query = $this->getFilter(array(),true,true);
69
+	public function getByIdent($ident, $format_source = '') {
70
+		$filter_query = $this->getFilter(array(), true, true);
71 71
 		if ($format_source == '') {
72 72
 			$query = "SELECT * FROM atc".$filter_query." ident = :ident";
73 73
 			$query_values = array(':ident' => $ident);
74 74
 		} else {
75 75
 			$query = "SELECT * FROM atc".$filter_query." ident = :ident AND format_source = :format_source";
76
-			$query_values = array(':ident' => $ident,':format_source' => $format_source);
76
+			$query_values = array(':ident' => $ident, ':format_source' => $format_source);
77 77
 		}
78 78
 		try {
79 79
 			$sth = $this->db->prepare($query);
80 80
 			$sth->execute($query_values);
81
-		} catch(PDOException $e) {
81
+		} catch (PDOException $e) {
82 82
 			return "error : ".$e->getMessage();
83 83
 		}
84 84
 		$all = $sth->fetchAll(PDO::FETCH_ASSOC);
85 85
 		return $all;
86 86
 	}
87 87
 
88
-	public function add($ident,$frequency,$latitude,$longitude,$range,$info,$date,$type = '',$ivao_id = '',$ivao_name = '',$format_source = '',$source_name = '') {
89
-		$info = preg_replace('/[^(\x20-\x7F)]*/','',$info);
90
-		$info = str_replace('^','<br />',$info);
91
-		$info = str_replace('&amp;sect;','',$info);
92
-		$info = str_replace('"','',$info);
88
+	public function add($ident, $frequency, $latitude, $longitude, $range, $info, $date, $type = '', $ivao_id = '', $ivao_name = '', $format_source = '', $source_name = '') {
89
+		$info = preg_replace('/[^(\x20-\x7F)]*/', '', $info);
90
+		$info = str_replace('^', '<br />', $info);
91
+		$info = str_replace('&amp;sect;', '', $info);
92
+		$info = str_replace('"', '', $info);
93 93
 		if ($type == '') $type = NULL;
94 94
 		$query = "INSERT INTO atc (ident,frequency,latitude,longitude,atc_range,info,atc_lastseen,type,ivao_id,ivao_name,format_source,source_name) VALUES (:ident,:frequency,:latitude,:longitude,:range,:info,:date,:type,:ivao_id,:ivao_name,:format_source,:source_name)";
95
-		$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,':format_source' => $format_source,':source_name' => $source_name);
95
+		$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, ':format_source' => $format_source, ':source_name' => $source_name);
96 96
 		try {
97 97
 			$sth = $this->db->prepare($query);
98 98
 			$sth->execute($query_values);
99
-		} catch(PDOException $e) {
99
+		} catch (PDOException $e) {
100 100
 			return "error : ".$e->getMessage();
101 101
 		}
102 102
 	}
103 103
 
104
-	public function update($ident,$frequency,$latitude,$longitude,$range,$info,$date,$type = '',$ivao_id = '',$ivao_name = '',$format_source = '',$source_name = '') {
105
-		$info = preg_replace('/[^(\x20-\x7F)]*/','',$info);
106
-		$info = str_replace('^','<br />',$info);
107
-		$info = str_replace('&amp;sect;','',$info);
108
-		$info = str_replace('"','',$info);
104
+	public function update($ident, $frequency, $latitude, $longitude, $range, $info, $date, $type = '', $ivao_id = '', $ivao_name = '', $format_source = '', $source_name = '') {
105
+		$info = preg_replace('/[^(\x20-\x7F)]*/', '', $info);
106
+		$info = str_replace('^', '<br />', $info);
107
+		$info = str_replace('&amp;sect;', '', $info);
108
+		$info = str_replace('"', '', $info);
109 109
 		if ($type == '') $type = NULL;
110 110
 		$query = "UPDATE atc SET frequency = :frequency,latitude = :latitude,longitude = :longitude,atc_range = :range,info = :info,atc_lastseen = :date,type = :type,ivao_id = :ivao_id,ivao_name = :ivao_name WHERE ident = :ident AND format_source = :format_source AND source_name = :source_name";
111
-		$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,':format_source' => $format_source,':source_name' => $source_name);
111
+		$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, ':format_source' => $format_source, ':source_name' => $source_name);
112 112
 		try {
113 113
 			$sth = $this->db->prepare($query);
114 114
 			$sth->execute($query_values);
115
-		} catch(PDOException $e) {
115
+		} catch (PDOException $e) {
116 116
 			return "error : ".$e->getMessage();
117 117
 		}
118 118
 	}
@@ -123,18 +123,18 @@  discard block
 block discarded – undo
123 123
 		try {
124 124
 			$sth = $this->db->prepare($query);
125 125
 			$sth->execute($query_values);
126
-		} catch(PDOException $e) {
126
+		} catch (PDOException $e) {
127 127
 			return "error : ".$e->getMessage();
128 128
 		}
129 129
 	}
130 130
 
131
-	public function deleteByIdent($ident,$format_source) {
131
+	public function deleteByIdent($ident, $format_source) {
132 132
 		$query = "DELETE FROM atc WHERE ident = :ident AND format_source = :format_source";
133
-		$query_values = array(':ident' => $ident,':format_source' => $format_source);
133
+		$query_values = array(':ident' => $ident, ':format_source' => $format_source);
134 134
 		try {
135 135
 			$sth = $this->db->prepare($query);
136 136
 			$sth->execute($query_values);
137
-		} catch(PDOException $e) {
137
+		} catch (PDOException $e) {
138 138
 			return "error : ".$e->getMessage();
139 139
 		}
140 140
 	}
@@ -145,7 +145,7 @@  discard block
 block discarded – undo
145 145
 		try {
146 146
 			$sth = $this->db->prepare($query);
147 147
 			$sth->execute($query_values);
148
-		} catch(PDOException $e) {
148
+		} catch (PDOException $e) {
149 149
 			return "error : ".$e->getMessage();
150 150
 		}
151 151
 	}
@@ -160,7 +160,7 @@  discard block
 block discarded – undo
160 160
 		try {
161 161
 			$sth = $this->db->prepare($query);
162 162
 			$sth->execute();
163
-		} catch(PDOException $e) {
163
+		} catch (PDOException $e) {
164 164
 			return "error";
165 165
 		}
166 166
 		return "success";
Please login to merge, or discard this patch.