Completed
Pull Request — 1.10.x (#1244)
by
unknown
42:26
created

compilatio::sendDoc()   A

Complexity

Conditions 3
Paths 4

Size

Total Lines 23
Code Lines 15

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 3
eloc 15
c 1
b 0
f 0
nc 4
nop 5
dl 0
loc 23
rs 9.0856
1
<?php
2
	/**
3
	 * Description:
4
	 * build the comunication with the SOAP server Compilatio.net
5
	 * call severals methods for the file management in Compilatio.net
6
	 *
7
	 * Date: 26/05/16
8
	 * @version:1.0
9
	 */
10
11
	class compilatio
12
	{
13
		/*Identification key for the Compilatio account*/
14
		var $key  = null;
15
		/*Webservice connection*/
16
		var $soapcli;
17
18
        /**
19
         * compilatio constructor.
20
         * @param $key
21
         * @param $urlsoap
22
         * @param $proxyHost
23
         * @param $proxyPort
24
         */
25
		function compilatio($key, $urlsoap, $proxyHost, $proxyPort)
0 ignored issues
show
Coding Style Best Practice introduced by
Please use __construct() instead of a PHP4-style constructor that is named after the class.
Loading history...
26
		{
27
			try
28
			{
29
				if(!empty($key)){
30
					$this->key = $key;
31
					if(!empty($urlsoap)){
32
						if(!empty($proxyHost)) {
33
							$param = array('trace' => false,
34
								'soap_version' => SOAP_1_2,
35
								'exceptions' => true,
36
								'proxy_host' => '"' . $proxyHost . '"',
37
								'proxy_port' => $proxyPort);
38
						} else {
39
							$param = array('trace' => false,
40
								'soap_version' => SOAP_1_2,
41
								'exceptions' => true);
42
						}
43
						$this->soapcli = new SoapClient($urlsoap,$param);
44
					}else{
45
						$this->soapcli = 'WS urlsoap not available' ;
46
					}
47
				}else{
48
					$this->soapcli ='API key not available';
49
				}
50
			}
51
			catch (SoapFault $fault)
52
			{
53
				$this->soapcli = "Error constructor compilatio " . $fault->faultcode ." " .$fault->faultstring ;
0 ignored issues
show
Bug introduced by
The property faultcode does not seem to exist in SoapFault.

An attempt at access to an undefined property has been detected. This may either be a typographical error or the property has been renamed but there are still references to its old name.

If you really want to allow access to undefined properties, you can define magic methods to allow access. See the php core documentation on Overloading.

Loading history...
54
			}
55
			catch (Exception $e) {
56
				$this->soapcli = "Error constructor compilatio with urlsoap" . $urlsoap;
57
			}
58
		}
59
60
61
		/**
62
		 * Method for the file load
63
		 *
64
		 * @param $title
65
		 * @param $description
66
		 * @param $filename
67
         * @param $mimeType
68
		 * @param $content
69
		 * @return string
70
		 */
71
        function sendDoc($title, $description, $filename, $mimeType, $content)
72
		{
73
			try
74
			{
75
				if (!is_object($this->soapcli))
76
					return("Error in constructor compilatio() " . $this->soapcli);
77
				$idDocument = $this->soapcli->__call('addDocumentBase64',
0 ignored issues
show
Bug introduced by
It seems like you code against a specific sub-type and not the parent class soapclient as the method __call() does only exist in the following sub-classes of soapclient: S3SoapClient. Maybe you want to instanceof check for one of these explicitly?

Let’s take a look at an example:

abstract class User
{
    /** @return string */
    abstract public function getPassword();
}

class MyUser extends User
{
    public function getPassword()
    {
        // return something
    }

    public function getDisplayName()
    {
        // return some name.
    }
}

class AuthSystem
{
    public function authenticate(User $user)
    {
        $this->logger->info(sprintf('Authenticating %s.', $user->getDisplayName()));
        // do something.
    }
}

In the above example, the authenticate() method works fine as long as you just pass instances of MyUser. However, if you now also want to pass a different sub-classes of User which does not have a getDisplayName() method, the code will break.

Available Fixes

  1. Change the type-hint for the parameter:

    class AuthSystem
    {
        public function authenticate(MyUser $user) { /* ... */ }
    }
    
  2. Add an additional type-check:

    class AuthSystem
    {
        public function authenticate(User $user)
        {
            if ($user instanceof MyUser) {
                $this->logger->info(/** ... */);
            }
    
            // or alternatively
            if ( ! $user instanceof MyUser) {
                throw new \LogicException(
                    '$user must be an instance of MyUser, '
                   .'other instances are not supported.'
                );
            }
    
        }
    }
    
Note: PHP Analyzer uses reverse abstract interpretation to narrow down the types inside the if block in such a case.
  1. Add the method to the parent class:

    abstract class User
    {
        /** @return string */
        abstract public function getPassword();
    
        /** @return string */
        abstract public function getDisplayName();
    }
    
Loading history...
78
					array(
79
						$this->key,
80
						utf8_encode(urlencode($title)),
81
						utf8_encode(urlencode($description)),
82
						utf8_encode(urlencode($filename)),
83
                        utf8_encode($mimeType),
84
						base64_encode($content)
85
					)
86
				);
87
				return $idDocument;
88
			}
89
			catch (SoapFault $fault)
90
			{
91
                return("Erreur sendDoc()" . $fault->faultcode ." " .$fault->faultstring);
0 ignored issues
show
Bug introduced by
The property faultcode does not seem to exist in SoapFault.

An attempt at access to an undefined property has been detected. This may either be a typographical error or the property has been renamed but there are still references to its old name.

If you really want to allow access to undefined properties, you can define magic methods to allow access. See the php core documentation on Overloading.

Loading history...
92
			}
93
		}
94
95
96
		/**
97
		 * Method for recover a document's information
98
		 * @param $compiHash
99
		 * @return string
100
		 */
101 View Code Duplication
        function getDoc($compiHash)
102
		{
103
			try
104
			{
105
				if (!is_object($this->soapcli)){
106
					return("Error in constructor compilatio() " . $this->soapcli);
107
				}
108
				$param = array($this->key, $compiHash);
109
				$idDocument = $this->soapcli->__call('getDocument', $param);
0 ignored issues
show
Bug introduced by
It seems like you code against a specific sub-type and not the parent class soapclient as the method __call() does only exist in the following sub-classes of soapclient: S3SoapClient. Maybe you want to instanceof check for one of these explicitly?

Let’s take a look at an example:

abstract class User
{
    /** @return string */
    abstract public function getPassword();
}

class MyUser extends User
{
    public function getPassword()
    {
        // return something
    }

    public function getDisplayName()
    {
        // return some name.
    }
}

class AuthSystem
{
    public function authenticate(User $user)
    {
        $this->logger->info(sprintf('Authenticating %s.', $user->getDisplayName()));
        // do something.
    }
}

In the above example, the authenticate() method works fine as long as you just pass instances of MyUser. However, if you now also want to pass a different sub-classes of User which does not have a getDisplayName() method, the code will break.

Available Fixes

  1. Change the type-hint for the parameter:

    class AuthSystem
    {
        public function authenticate(MyUser $user) { /* ... */ }
    }
    
  2. Add an additional type-check:

    class AuthSystem
    {
        public function authenticate(User $user)
        {
            if ($user instanceof MyUser) {
                $this->logger->info(/** ... */);
            }
    
            // or alternatively
            if ( ! $user instanceof MyUser) {
                throw new \LogicException(
                    '$user must be an instance of MyUser, '
                   .'other instances are not supported.'
                );
            }
    
        }
    }
    
Note: PHP Analyzer uses reverse abstract interpretation to narrow down the types inside the if block in such a case.
  1. Add the method to the parent class:

    abstract class User
    {
        /** @return string */
        abstract public function getPassword();
    
        /** @return string */
        abstract public function getDisplayName();
    }
    
Loading history...
110
				return $idDocument;
111
			}
112
			catch (SoapFault $fault)
113
			{
114
                return("Erreur getDoc()" . $fault->faultcode . " " .$fault->faultstring);
0 ignored issues
show
Bug introduced by
The property faultcode does not seem to exist in SoapFault.

An attempt at access to an undefined property has been detected. This may either be a typographical error or the property has been renamed but there are still references to its old name.

If you really want to allow access to undefined properties, you can define magic methods to allow access. See the php core documentation on Overloading.

Loading history...
115
			}
116
		}
117
118
		/**
119
		 * method for recover an url document's report
120
		 * @param $compiHash
121
		 * @return string
122
		 */
123 View Code Duplication
        function getReportUrl($compiHash)
124
		{
125
			try
126
			{
127
				if (!is_object($this->soapcli)){
128
					return("Error in constructor compilatio() " . $this->soapcli);
129
				}
130
				$param = array($this->key,$compiHash);
131
				$idDocument = $this->soapcli->__call('getDocumentReportUrl', $param);
0 ignored issues
show
Bug introduced by
It seems like you code against a specific sub-type and not the parent class soapclient as the method __call() does only exist in the following sub-classes of soapclient: S3SoapClient. Maybe you want to instanceof check for one of these explicitly?

Let’s take a look at an example:

abstract class User
{
    /** @return string */
    abstract public function getPassword();
}

class MyUser extends User
{
    public function getPassword()
    {
        // return something
    }

    public function getDisplayName()
    {
        // return some name.
    }
}

class AuthSystem
{
    public function authenticate(User $user)
    {
        $this->logger->info(sprintf('Authenticating %s.', $user->getDisplayName()));
        // do something.
    }
}

In the above example, the authenticate() method works fine as long as you just pass instances of MyUser. However, if you now also want to pass a different sub-classes of User which does not have a getDisplayName() method, the code will break.

Available Fixes

  1. Change the type-hint for the parameter:

    class AuthSystem
    {
        public function authenticate(MyUser $user) { /* ... */ }
    }
    
  2. Add an additional type-check:

    class AuthSystem
    {
        public function authenticate(User $user)
        {
            if ($user instanceof MyUser) {
                $this->logger->info(/** ... */);
            }
    
            // or alternatively
            if ( ! $user instanceof MyUser) {
                throw new \LogicException(
                    '$user must be an instance of MyUser, '
                   .'other instances are not supported.'
                );
            }
    
        }
    }
    
Note: PHP Analyzer uses reverse abstract interpretation to narrow down the types inside the if block in such a case.
  1. Add the method to the parent class:

    abstract class User
    {
        /** @return string */
        abstract public function getPassword();
    
        /** @return string */
        abstract public function getDisplayName();
    }
    
Loading history...
132
				return $idDocument;
133
			}
134
			catch (SoapFault $fault)
135
			{
136
                return("Erreur  getReportUrl()" . $fault->faultcode ." " .$fault->faultstring);
0 ignored issues
show
Bug introduced by
The property faultcode does not seem to exist in SoapFault.

An attempt at access to an undefined property has been detected. This may either be a typographical error or the property has been renamed but there are still references to its old name.

If you really want to allow access to undefined properties, you can define magic methods to allow access. See the php core documentation on Overloading.

Loading history...
137
			}
138
		}
139
140
		/**
141
		 *  Method for deleting a Compialtio's account document
142
		 * @param $compiHash
143
		 * @return string
144
		 */
145 View Code Duplication
        function deldoc($compiHash)
146
		{
147
			try
148
			{
149
				if (!is_object($this->soapcli)){
150
					return("Error in constructor compilatio() " . $this->soapcli);
151
				}
152
				$param = array($this->key,$compiHash);
153
				$this->soapcli->__call('deleteDocument', $param);
0 ignored issues
show
Bug introduced by
It seems like you code against a specific sub-type and not the parent class soapclient as the method __call() does only exist in the following sub-classes of soapclient: S3SoapClient. Maybe you want to instanceof check for one of these explicitly?

Let’s take a look at an example:

abstract class User
{
    /** @return string */
    abstract public function getPassword();
}

class MyUser extends User
{
    public function getPassword()
    {
        // return something
    }

    public function getDisplayName()
    {
        // return some name.
    }
}

class AuthSystem
{
    public function authenticate(User $user)
    {
        $this->logger->info(sprintf('Authenticating %s.', $user->getDisplayName()));
        // do something.
    }
}

In the above example, the authenticate() method works fine as long as you just pass instances of MyUser. However, if you now also want to pass a different sub-classes of User which does not have a getDisplayName() method, the code will break.

Available Fixes

  1. Change the type-hint for the parameter:

    class AuthSystem
    {
        public function authenticate(MyUser $user) { /* ... */ }
    }
    
  2. Add an additional type-check:

    class AuthSystem
    {
        public function authenticate(User $user)
        {
            if ($user instanceof MyUser) {
                $this->logger->info(/** ... */);
            }
    
            // or alternatively
            if ( ! $user instanceof MyUser) {
                throw new \LogicException(
                    '$user must be an instance of MyUser, '
                   .'other instances are not supported.'
                );
            }
    
        }
    }
    
Note: PHP Analyzer uses reverse abstract interpretation to narrow down the types inside the if block in such a case.
  1. Add the method to the parent class:

    abstract class User
    {
        /** @return string */
        abstract public function getPassword();
    
        /** @return string */
        abstract public function getDisplayName();
    }
    
Loading history...
154
			}
155
			catch (SoapFault $fault)
156
			{
157
                return("Erreur  deldoc()" . $fault->faultcode . " " .$fault->faultstring);
0 ignored issues
show
Bug introduced by
The property faultcode does not seem to exist in SoapFault.

An attempt at access to an undefined property has been detected. This may either be a typographical error or the property has been renamed but there are still references to its old name.

If you really want to allow access to undefined properties, you can define magic methods to allow access. See the php core documentation on Overloading.

Loading history...
158
			}
159
		}
160
161
		/**
162
		 * Method for start the analysis for a document
163
		 * @param $compiHash
164
		 * @return string
165
		 */
166 View Code Duplication
        function startAnalyse($compiHash)
167
		{
168
			try
169
			{
170
				if (!is_object($this->soapcli)){
171
					return("Error in constructor compilatio() " . $this->soapcli);
172
				}
173
				$param = array($this->key,$compiHash);
174
                $this->soapcli->__call('startDocumentAnalyse', $param);
0 ignored issues
show
Bug introduced by
It seems like you code against a specific sub-type and not the parent class soapclient as the method __call() does only exist in the following sub-classes of soapclient: S3SoapClient. Maybe you want to instanceof check for one of these explicitly?

Let’s take a look at an example:

abstract class User
{
    /** @return string */
    abstract public function getPassword();
}

class MyUser extends User
{
    public function getPassword()
    {
        // return something
    }

    public function getDisplayName()
    {
        // return some name.
    }
}

class AuthSystem
{
    public function authenticate(User $user)
    {
        $this->logger->info(sprintf('Authenticating %s.', $user->getDisplayName()));
        // do something.
    }
}

In the above example, the authenticate() method works fine as long as you just pass instances of MyUser. However, if you now also want to pass a different sub-classes of User which does not have a getDisplayName() method, the code will break.

Available Fixes

  1. Change the type-hint for the parameter:

    class AuthSystem
    {
        public function authenticate(MyUser $user) { /* ... */ }
    }
    
  2. Add an additional type-check:

    class AuthSystem
    {
        public function authenticate(User $user)
        {
            if ($user instanceof MyUser) {
                $this->logger->info(/** ... */);
            }
    
            // or alternatively
            if ( ! $user instanceof MyUser) {
                throw new \LogicException(
                    '$user must be an instance of MyUser, '
                   .'other instances are not supported.'
                );
            }
    
        }
    }
    
Note: PHP Analyzer uses reverse abstract interpretation to narrow down the types inside the if block in such a case.
  1. Add the method to the parent class:

    abstract class User
    {
        /** @return string */
        abstract public function getPassword();
    
        /** @return string */
        abstract public function getDisplayName();
    }
    
Loading history...
175
			}
176
			catch (SoapFault $fault)
177
			{
178
                return("Erreur  startAnalyse()" . $fault->faultcode ." " .$fault->faultstring);
0 ignored issues
show
Bug introduced by
The property faultcode does not seem to exist in SoapFault.

An attempt at access to an undefined property has been detected. This may either be a typographical error or the property has been renamed but there are still references to its old name.

If you really want to allow access to undefined properties, you can define magic methods to allow access. See the php core documentation on Overloading.

Loading history...
179
			}
180
		}
181
182
		/**
183
		 * Method for recover the account's quota
184
		 * @return string
185
		 */
186 View Code Duplication
        function getQuotas()
187
		{
188
			try
189
			{
190
				if (!is_object($this->soapcli)){
191
					return("Error in constructor compilatio() " . $this->soapcli);
192
				}
193
				$param=array($this->key);
194
                $resultat=$this->soapcli->__call('getAccountQuotas', $param);
0 ignored issues
show
Bug introduced by
It seems like you code against a specific sub-type and not the parent class soapclient as the method __call() does only exist in the following sub-classes of soapclient: S3SoapClient. Maybe you want to instanceof check for one of these explicitly?

Let’s take a look at an example:

abstract class User
{
    /** @return string */
    abstract public function getPassword();
}

class MyUser extends User
{
    public function getPassword()
    {
        // return something
    }

    public function getDisplayName()
    {
        // return some name.
    }
}

class AuthSystem
{
    public function authenticate(User $user)
    {
        $this->logger->info(sprintf('Authenticating %s.', $user->getDisplayName()));
        // do something.
    }
}

In the above example, the authenticate() method works fine as long as you just pass instances of MyUser. However, if you now also want to pass a different sub-classes of User which does not have a getDisplayName() method, the code will break.

Available Fixes

  1. Change the type-hint for the parameter:

    class AuthSystem
    {
        public function authenticate(MyUser $user) { /* ... */ }
    }
    
  2. Add an additional type-check:

    class AuthSystem
    {
        public function authenticate(User $user)
        {
            if ($user instanceof MyUser) {
                $this->logger->info(/** ... */);
            }
    
            // or alternatively
            if ( ! $user instanceof MyUser) {
                throw new \LogicException(
                    '$user must be an instance of MyUser, '
                   .'other instances are not supported.'
                );
            }
    
        }
    }
    
Note: PHP Analyzer uses reverse abstract interpretation to narrow down the types inside the if block in such a case.
  1. Add the method to the parent class:

    abstract class User
    {
        /** @return string */
        abstract public function getPassword();
    
        /** @return string */
        abstract public function getDisplayName();
    }
    
Loading history...
195
				return $resultat;
196
			}
197
			catch (SoapFault $fault)
198
			{
199
                return("Erreur  getQuotas()" . $fault->faultcode ." " .$fault->faultstring);
0 ignored issues
show
Bug introduced by
The property faultcode does not seem to exist in SoapFault.

An attempt at access to an undefined property has been detected. This may either be a typographical error or the property has been renamed but there are still references to its old name.

If you really want to allow access to undefined properties, you can define magic methods to allow access. See the php core documentation on Overloading.

Loading history...
200
			}
201
		}
202
203
	}
204
205
	/**
206
	 * Method for identify a file extension and the possibility that the document can be managed by Compilatio
207
	 * @param $filename
208
	 * @return bool
209
	 */
210
    function verifiFileType($filename)
211
	{
212
		$types = array("doc","docx", "rtf", "xls", "xlsx", "ppt", "pptx", "odt", "pdf", "txt", "htm", "html");
213
		$extension = substr($filename, strrpos($filename, ".")+1);
214
		$extension = strtolower($extension);
215
		if (in_array($extension, $types)) {
216
			return true;
217
		} else {
218
			return false;
219
		}
220
	}
221
222
	/**
223
	 * Fonction  affichage de la barre de progression d'analyse version 3.1
224
	 *
225
	 * @param $statut From the document
226
	 * @param $pour
227
	 * @param $imagesPath
228
	 * @param $text  Array includes the extract from the text
229
	 * @return unknown_type
230
	 */
231
	function getProgressionAnalyseDocv31($status, $pour = 0, $imagesPath = '', $text = '')
232
	{
233
234
		$refreshReturn = "<a href='javascript:window.location.reload(false);'><img src='"
235
			.$imagesPath
236
			."ajax-loader_green.gif' title='"
237
			. $text['refresh']
238
			. "' alt='"
239
			. $text['refresh']
240
			. "'/></a> ";
241
        $startReturn = "<table cellpadding='0' cellspacing='0' style='border:0;margin:0;padding:0;'><tr>";
242
        $startReturn .= "<td width='25' style='border:0;margin:0;padding:0;'>&nbsp;</td>";
243
        $startReturn .= "<td valign='middle' align='right' style='border:0;margin:0;padding-right:10px;'>"
244
			.$refreshReturn
245
			."</td>";
246
        $startReturn .= "<td style='border:0;margin:0;padding:0;'>";
247
        $startReturnLittleWidth = "<table cellpadding='0' cellspacing='0' style='border:0;margin:0;padding:0;'><tr>";
248
        $startReturnLittleWidth .= "<td width='25' valign='middle' align='right' style='border:0;margin:0;padding:0;'>"
249
			.$refreshReturn
250
			."</td>";
251
		$finretour = "</td></tr></table>";
252
		if($status == "ANALYSE_IN_QUEUE" ){
253
			return $startReturn . "<span style='font-size:11px'>" . $text['analysisinqueue'] . "</span>" . $finretour;
254
		}
255
		if($status == "ANALYSE_PROCESSING" ){
256
			if($pour == 100){
257
				return $startReturn
258
				. "<span style='font-size:11px'>"
259
				. $text['analysisinfinalization']
260
				. "</span>"
261
				. $finretour;
262
			} else {
263
				return $startReturnLittleWidth
264
                    . "<td align=\"right\" style=\"border:0;margin:0;padding-right:10px;\">"
265
				. $pour
266
                    . "%</td><td style=\"border:0;margin:0;padding:0;\"><div style=\"background"
267
				. ":transparent url("
268
				. $imagesPath
269
				. "mini-jauge_fond.png) no-repeat scroll 0;height:12px;padding:0 0 0 2px;width:55px;\"><div style=\""
270
				. "background:transparent url("
271
				. $imagesPath
272
				. "mini-jauge_gris.png) no-repeat scroll 0;height:12px;width:"
273
				. $pour/2
274
				. "px;\"></div></div>"
275
				. $finretour;
276
			}
277
		}
278
	}
279
280
	/**
281
	 * Method for display the PomprseuilmankBar (% de plagiat)
282
	 *
283
	 * @param $percentagePumping
284
	 * @param $weakThreshold
285
	 * @param $highThreshold
286
	 * @param $imagesPath
287
	 * @param $text : array  includes the extract from the text
288
	 * @return unknown_type
289
	 */
290
	function getPomprankBarv31($pourcentagePompage, $weakThreshold, $highThreshold, $chemin_images='',$texte='') {
291
292
		$pourcentagePompage = round($pourcentagePompage);
293
		$pour = round((50*$pourcentagePompage)/100);
294
		$return = "";
295
		$couleur = "";
296
		if($pourcentagePompage < $weakThreshold) {
297
			$couleur = "vert";
298
		} else if($pourcentagePompage >= $weakThreshold && $pourcentagePompage < $highThreshold) {
299
			$couleur = "orange";
300
		} else {
301
			$couleur = "rouge";
302
		}
303
		$return .= "<div style='float:left;margin-right:2px;'><img src='"
304
			. $chemin_images."mini-drapeau_$couleur.png' title='"
305
			. $texte['result']
306
			. "' alt='faible' width='15' height='15' /></div>";
307
		$return .= "<div style='float:left; margin-right:5px;width:45px;text-align:right;'>"
308
			. $pourcentagePompage
309
			. " %</div>";
310
		$return .= "<div style='float:left;background:transparent url("
311
			. $chemin_images
312
			. "mini-jauge_fond.png) no-repeat scroll 0;height:12px;margin-top:5px;padding:0 0 0 2px;width:55px;'>";
313
		$return .= "<div style='float:left;background:transparent url("
314
			. $chemin_images
315
			. "mini-jauge_"
316
			. $couleur
317
			. ".png) no-repeat scroll 0;height:12px;width:"
318
			. $pour
319
			. "px'></div></div>";
320
321
		return $return;
322
	}
323
	/*
324
     * Method for validation of hash
325
     * @param $hash
326
     * @return bool
327
     *
328
     */
329
	function isMd5($hash)
330
	{
331
		if(preg_match('`^[a-f0-9]{32}$`', $hash)) {
332
			return true;
333
		} else {
334
			return false;
335
		}
336
	}
337
	/*
338
     * Method for identify Internet media type
339
     * @param $filename
340
     */
341
	function typeMime($filename)
342
	{
343
		if (preg_match("@Opera(/| )([0-9].[0-9]{1,2})@", $_SERVER['HTTP_USER_AGENT'], $resultats)){
344
			$navigateur = "Opera";
345
		} elseif (preg_match("@MSIE ([0-9].[0-9]{1,2})@", $_SERVER['HTTP_USER_AGENT'], $resultats)){
346
			$navigateur = "Internet Explorer";
347
		} else {
348
			$navigateur = "Mozilla";
349
			$mime = parse_ini_file("mime.ini");
350
			$extension = substr($filename, strrpos($filename, ".")+1);
351
		}
352
		if(array_key_exists($extension, $mime)) {
353
			$type = $mime[$extension];
354
		} else {
355
			$type = ($navigateur!="Mozilla") ? 'application/octetstream' : 'application/octet-stream';
356
		}
357
		return $type;
358
	}
359
?>
0 ignored issues
show
Best Practice introduced by
It is not recommended to use PHP's closing tag ?> in files other than templates.

Using a closing tag in PHP files that only contain PHP code is not recommended as you might accidentally add whitespace after the closing tag which would then be output by PHP. This can cause severe problems, for example headers cannot be sent anymore.

A simple precaution is to leave off the closing tag as it is not required, and it also has no negative effects whatsoever.

Loading history...