|
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) |
|
|
|
|
|
|
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 ; |
|
|
|
|
|
|
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', |
|
|
|
|
|
|
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); |
|
|
|
|
|
|
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); |
|
|
|
|
|
|
110
|
|
|
return $idDocument; |
|
111
|
|
|
} |
|
112
|
|
|
catch (SoapFault $fault) |
|
113
|
|
|
{ |
|
114
|
|
|
return("Erreur getDoc()" . $fault->faultcode . " " .$fault->faultstring); |
|
|
|
|
|
|
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); |
|
|
|
|
|
|
132
|
|
|
return $idDocument; |
|
133
|
|
|
} |
|
134
|
|
|
catch (SoapFault $fault) |
|
135
|
|
|
{ |
|
136
|
|
|
return("Erreur getReportUrl()" . $fault->faultcode ." " .$fault->faultstring); |
|
|
|
|
|
|
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); |
|
|
|
|
|
|
154
|
|
|
} |
|
155
|
|
|
catch (SoapFault $fault) |
|
156
|
|
|
{ |
|
157
|
|
|
return("Erreur deldoc()" . $fault->faultcode . " " .$fault->faultstring); |
|
|
|
|
|
|
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); |
|
|
|
|
|
|
175
|
|
|
} |
|
176
|
|
|
catch (SoapFault $fault) |
|
177
|
|
|
{ |
|
178
|
|
|
return("Erreur startAnalyse()" . $fault->faultcode ." " .$fault->faultstring); |
|
|
|
|
|
|
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); |
|
|
|
|
|
|
195
|
|
|
return $resultat; |
|
196
|
|
|
} |
|
197
|
|
|
catch (SoapFault $fault) |
|
198
|
|
|
{ |
|
199
|
|
|
return("Erreur getQuotas()" . $fault->faultcode ." " .$fault->faultstring); |
|
|
|
|
|
|
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;'> </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
|
|
|
?> |
|
|
|
|
|