Issues (843)

Security Analysis    not enabled

This project does not seem to handle request data directly as such no vulnerable execution paths were found.

  Cross-Site Scripting
Cross-Site Scripting enables an attacker to inject code into the response of a web-request that is viewed by other users. It can for example be used to bypass access controls, or even to take over other users' accounts.
  File Exposure
File Exposure allows an attacker to gain access to local files that he should not be able to access. These files can for example include database credentials, or other configuration files.
  File Manipulation
File Manipulation enables an attacker to write custom data to files. This potentially leads to injection of arbitrary code on the server.
  Object Injection
Object Injection enables an attacker to inject an object into PHP code, and can lead to arbitrary code execution, file exposure, or file manipulation attacks.
  Code Injection
Code Injection enables an attacker to execute arbitrary code on the server.
  Response Splitting
Response Splitting can be used to send arbitrary responses.
  File Inclusion
File Inclusion enables an attacker to inject custom files into PHP's file loading mechanism, either explicitly passed to include, or for example via PHP's auto-loading mechanism.
  Command Injection
Command Injection enables an attacker to inject a shell command that is execute with the privileges of the web-server. This can be used to expose sensitive data, or gain access of your server.
  SQL Injection
SQL Injection enables an attacker to execute arbitrary SQL code on your database server gaining access to user data, or manipulating user data.
  XPath Injection
XPath Injection enables an attacker to modify the parts of XML document that are read. If that XML document is for example used for authentication, this can lead to further vulnerabilities similar to SQL Injection.
  LDAP Injection
LDAP Injection enables an attacker to inject LDAP statements potentially granting permission to run unauthorized queries, or modify content inside the LDAP tree.
  Header Injection
  Other Vulnerability
This category comprises other attack vectors such as manipulating the PHP runtime, loading custom extensions, freezing the runtime, or similar.
  Regex Injection
Regex Injection enables an attacker to execute arbitrary code in your PHP process.
  XML Injection
XML Injection enables an attacker to read files on your local filesystem including configuration files, or can be abused to freeze your web-server process.
  Variable Injection
Variable Injection enables an attacker to overwrite program variables with custom data, and can lead to further vulnerabilities.
Unfortunately, the security analysis is currently not available for your project. If you are a non-commercial open-source project, please contact support to gain access.

require/class.Translation.php (1 issue)

Severity

Upgrade to new PHP Analysis Engine

These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more

1
<?php
2
/**
3
 * This class is part of FlightAirmap. It's used to do flight ident translation
4
 *
5
 * Copyright (c) Ycarus (Yannick Chabanois) <[email protected]>
6
 * Licensed under AGPL license.
7
 * For more information see: https://www.flightairmap.com/
8
*/
9
require_once(dirname(__FILE__).'/settings.php');
10
require_once(dirname(__FILE__).'/class.Connection.php');
11
require_once(dirname(__FILE__).'/class.Spotter.php');
12
require_once(dirname(__FILE__).'/class.Common.php');
13
require_once(dirname(__FILE__).'/libs/uagent/uagent.php');
14
15
16
class Translation {
17
	public $db;
18
	
19
	/*
20
	* Initialize DB connection
21
	*/
22
	public function __construct($dbc = null) {
23
		$Connection = new Connection($dbc);
24
		$this->db = $Connection->db();
25
	}
26
27
	/**
28
	* Change IATA to ICAO value for ident
29
	* 
30
	* @param string $ident ident
31
	* @return string the icao
32
	*/
33
	public function ident2icao($ident) {
34
		$Spotter = new Spotter();
35
		if (!is_numeric(substr($ident, 0, 3))) {
36
			if (is_numeric(substr(substr($ident, 0, 3), -1, 1))) {
37
				$airline_icao = substr($ident, 0, 2);
38
			} elseif (is_numeric(substr(substr($ident, 0, 4), -1, 1))) {
39
				//$airline_icao = substr($ident, 0, 3);
40
				return $ident;
41
			} else return $ident;
42
		} else return $ident;
43
		if ($airline_icao == 'AF') {
44
			if (filter_var(substr($ident,2),FILTER_VALIDATE_INT,array("flags"=>FILTER_FLAG_ALLOW_OCTAL))) $icao = $ident;
45
			else $icao = 'AFR'.ltrim(substr($ident,2),'0');
46
		} else {
47
			$identicao = $Spotter->getAllAirlineInfo($airline_icao);
48
			if (isset($identicao[0])) {
49
				$icao = $identicao[0]['icao'].ltrim(substr($ident,2),'0');
50
			} else $icao = $ident;
51
		}
52
		return $icao;
53
	}
54
55
    /**
56
     * @param $ident
57
     * @return string
58
     */
59
    public function getOperator($ident) {
60
		$query = "SELECT * FROM translation WHERE Operator = :ident LIMIT 1";
61
		$query_values = array(':ident' => $ident);
62
		try {
63
			$sth = $this->db->prepare($query);
64
			$sth->execute($query_values);
65
		} catch(PDOException $e) {
66
			return "error : ".$e->getMessage();
67
		}
68
		$row = $sth->fetch(PDO::FETCH_ASSOC);
69
		$sth->closeCursor();
70
		if (isset($row['operator_correct'])) {
71
			return $row['operator_correct'];
72
		} else return $ident;
73
	}
74
75
    /**
76
     * @param $ident
77
     * @param $correct_ident
78
     * @param $source
79
     * @return string
80
     */
81
    public function addOperator($ident, $correct_ident, $source) {
82
		$query = "INSERT INTO translation (Operator,Operator_correct,Source) VALUES (:ident,:correct_ident,:source)";
83
		$query_values = array(':ident' => $ident,':correct_ident' => $correct_ident, ':source' => $source);
84
		try {
85
			$sth = $this->db->prepare($query);
86
			$sth->execute($query_values);
87
		} catch(PDOException $e) {
88
			return "error : ".$e->getMessage();
89
		}
90
	}
91
92
    /**
93
     * @param $ident
94
     * @param $correct_ident
95
     * @param $source
96
     * @return string
97
     */
98
    public function updateOperator($ident, $correct_ident, $source) {
99
		$query = "UPDATE translation SET Operator_correct = :correct_ident,Source = :source WHERE Operator = :ident";
100
		$query_values = array(':ident' => $ident,':correct_ident' => $correct_ident, ':source' => $source);
101
		try {
102
			$sth = $this->db->prepare($query);
103
			$sth->execute($query_values);
104
		} catch(PDOException $e) {
105
			return "error : ".$e->getMessage();
106
		}
107
	}
108
109
    /**
110
     * @param $ident
111
     * @param bool $web
112
     * @return string
113
     */
114
    public function checkTranslation($ident, $web = false) {
0 ignored issues
show
The parameter $web is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
115
		global $globalTranslationSources, $globalTranslationFetch;
116
		//if (!isset($globalTranslationSources)) $globalTranslationSources = array('planefinder');
117
		$globalTranslationSources = array();
118
		if (!isset($globalTranslationFetch)) $globalTranslationFetch = TRUE;
119
		//echo "Check Translation for ".$ident."...";
120
		$correct = $this->getOperator($ident);
121
		if ($correct != '' && $correct != $ident) {
122
			//echo "Found in DB !\n";
123
			return $correct;
124
		}
125
		/*
126
		elseif ($web && $globalTranslationFetch) {
127
			if (! is_numeric(substr($ident,-4))) {
128
				if (count($globalTranslationSources) > 0) {
129
					$correct = $this->fromPlanefinder($ident);
130
					if ($correct != '') {
131
						$correct = $this->ident2icao($correct);
132
						if ($correct != $ident) {
133
							$this->addOperator($ident,$correct,'planefinder');
134
							//echo "Add to DB ! (".$correct.") \n";
135
							return $correct;
136
						}
137
					}
138
				}
139
			}
140
		}
141
		*/
142
		return $this->ident2icao($ident);
143
	}
144
145
/*  
146
	// Disabled as Planefinder request
147
	function fromPlanefinder($icao) {
148
		$url = 'http://planefinder.net/data/endpoints/search_ajax.php?searchText='.$icao;
149
		$Common = new Common();
150
		$json = $Common->getData($url);
151
		$parsed_json = json_decode($json);
152
		if (isset($parsed_json->flights[0]->title) && isset($parsed_json->flights[0]->subtitle) && $parsed_json->flights[0]->subtitle == $icao) return $parsed_json->flights[0]->title;
153
		else return '';
154
	}
155
*/
156
}
157
//echo Translation->checkTranslation('EZY268X');
158
//Translation->fromPlanefinder('EZY268X');
159
?>