@@ -201,8 +201,7 @@ discard block |
||
201 | 201 | |
202 | 202 | if ($country->fetch($id) < 0) { |
203 | 203 | throw new RestException(503, 'Error when retrieving country : '.$country->error); |
204 | - } |
|
205 | - else if ($country->fetch($id) == 0) { |
|
204 | + } else if ($country->fetch($id) == 0) { |
|
206 | 205 | throw new RestException(404, 'country not found'); |
207 | 206 | } |
208 | 207 | |
@@ -340,8 +339,12 @@ discard block |
||
340 | 339 | $sql = "SELECT id, code, type, libelle as label, module"; |
341 | 340 | $sql.= " FROM ".MAIN_DB_PREFIX."c_actioncomm as t"; |
342 | 341 | $sql.= " WHERE t.active = 1"; |
343 | - if ($type) $sql.=" AND t.type LIKE '%" . $this->db->escape($type) . "%'"; |
|
344 | - if ($module) $sql.=" AND t.module LIKE '%" . $this->db->escape($module) . "%'"; |
|
342 | + if ($type) { |
|
343 | + $sql.=" AND t.type LIKE '%" . $this->db->escape($type) . "%'"; |
|
344 | + } |
|
345 | + if ($module) { |
|
346 | + $sql.=" AND t.module LIKE '%" . $this->db->escape($module) . "%'"; |
|
347 | + } |
|
345 | 348 | // Add sql filters |
346 | 349 | if ($sqlfilters) |
347 | 350 | { |
@@ -402,7 +405,9 @@ discard block |
||
402 | 405 | $sql = "SELECT rowid, code, label, module"; |
403 | 406 | $sql.= " FROM ".MAIN_DB_PREFIX."c_civility as t"; |
404 | 407 | $sql.= " WHERE t.active = 1"; |
405 | - if ($module) $sql.=" AND t.module LIKE '%" . $this->db->escape($module) . "%'"; |
|
408 | + if ($module) { |
|
409 | + $sql.=" AND t.module LIKE '%" . $this->db->escape($module) . "%'"; |
|
410 | + } |
|
406 | 411 | // Add sql filters |
407 | 412 | if ($sqlfilters) |
408 | 413 | { |
@@ -458,13 +463,19 @@ discard block |
||
458 | 463 | { |
459 | 464 | $list = array(); |
460 | 465 | |
461 | - if ($type == 'thirdparty') $type='societe'; |
|
462 | - if ($type == 'contact') $type='socpeople'; |
|
466 | + if ($type == 'thirdparty') { |
|
467 | + $type='societe'; |
|
468 | + } |
|
469 | + if ($type == 'contact') { |
|
470 | + $type='socpeople'; |
|
471 | + } |
|
463 | 472 | |
464 | 473 | $sql = "SELECT t.rowid, t.name, t.label, t.type, t.size, t.elementtype, t.fieldunique, t.fieldrequired, t.param, t.pos, t.alwayseditable, t.perms, t.list, t.fielddefault, t.fieldcomputed"; |
465 | 474 | $sql.= " FROM ".MAIN_DB_PREFIX."extrafields as t"; |
466 | 475 | $sql.= " WHERE t.entity IN (".getEntity('extrafields').")"; |
467 | - if (! empty($type)) $sql.= " AND t.elementtype = '".$this->db->escape($type)."'"; |
|
476 | + if (! empty($type)) { |
|
477 | + $sql.= " AND t.elementtype = '".$this->db->escape($type)."'"; |
|
478 | + } |
|
468 | 479 | // Add sql filters |
469 | 480 | if ($sqlfilters) |
470 | 481 | { |
@@ -501,8 +512,7 @@ discard block |
||
501 | 512 | $list[$tab->elementtype][$tab->name]['list']=$tab->list; |
502 | 513 | } |
503 | 514 | } |
504 | - } |
|
505 | - else |
|
515 | + } else |
|
506 | 516 | { |
507 | 517 | throw new RestException(503, 'Error when retrieving list of extra fields : '.$this->db->lasterror()); |
508 | 518 | } |
@@ -539,8 +549,12 @@ discard block |
||
539 | 549 | $sql = "SELECT rowid AS id, zip, town, fk_county, fk_pays AS fk_country"; |
540 | 550 | $sql.= " FROM ".MAIN_DB_PREFIX."c_ziptown as t"; |
541 | 551 | $sql.= " WHERE t.active = 1"; |
542 | - if ($zipcode) $sql.=" AND t.zip LIKE '%" . $this->db->escape($zipcode) . "%'"; |
|
543 | - if ($town) $sql.=" AND t.town LIKE '%" . $this->db->escape($town) . "%'"; |
|
552 | + if ($zipcode) { |
|
553 | + $sql.=" AND t.zip LIKE '%" . $this->db->escape($zipcode) . "%'"; |
|
554 | + } |
|
555 | + if ($town) { |
|
556 | + $sql.=" AND t.town LIKE '%" . $this->db->escape($town) . "%'"; |
|
557 | + } |
|
544 | 558 | // Add sql filters |
545 | 559 | if ($sqlfilters) |
546 | 560 | { |
@@ -781,8 +795,12 @@ discard block |
||
781 | 795 | $sql = "SELECT rowid, code, pos, label, use_default, description"; |
782 | 796 | $sql.= " FROM ".MAIN_DB_PREFIX."c_ticket_type as t"; |
783 | 797 | $sql.= " WHERE t.active = 1"; |
784 | - if ($type) $sql.=" AND t.type LIKE '%" . $this->db->escape($type) . "%'"; |
|
785 | - if ($module) $sql.=" AND t.module LIKE '%" . $this->db->escape($module) . "%'"; |
|
798 | + if ($type) { |
|
799 | + $sql.=" AND t.type LIKE '%" . $this->db->escape($type) . "%'"; |
|
800 | + } |
|
801 | + if ($module) { |
|
802 | + $sql.=" AND t.module LIKE '%" . $this->db->escape($module) . "%'"; |
|
803 | + } |
|
786 | 804 | // Add sql filters |
787 | 805 | if ($sqlfilters) |
788 | 806 | { |
@@ -858,23 +876,27 @@ discard block |
||
858 | 876 | $xmlfile = DOL_DOCUMENT_ROOT.$xmlshortfile; |
859 | 877 | // Remote file to compare to |
860 | 878 | $xmlremote = ($target == 'default' ? '' : $target); |
861 | - if (empty($xmlremote) && ! empty($conf->global->MAIN_FILECHECK_URL)) $xmlremote = $conf->global->MAIN_FILECHECK_URL; |
|
879 | + if (empty($xmlremote) && ! empty($conf->global->MAIN_FILECHECK_URL)) { |
|
880 | + $xmlremote = $conf->global->MAIN_FILECHECK_URL; |
|
881 | + } |
|
862 | 882 | $param='MAIN_FILECHECK_URL_'.DOL_VERSION; |
863 | - if (empty($xmlremote) && ! empty($conf->global->$param)) $xmlremote = $conf->global->$param; |
|
864 | - if (empty($xmlremote)) $xmlremote = 'https://www.dolibarr.org/files/stable/signatures/filelist-'.DOL_VERSION.'.xml'; |
|
883 | + if (empty($xmlremote) && ! empty($conf->global->$param)) { |
|
884 | + $xmlremote = $conf->global->$param; |
|
885 | + } |
|
886 | + if (empty($xmlremote)) { |
|
887 | + $xmlremote = 'https://www.dolibarr.org/files/stable/signatures/filelist-'.DOL_VERSION.'.xml'; |
|
888 | + } |
|
865 | 889 | |
866 | 890 | if ($target == 'local') |
867 | 891 | { |
868 | 892 | if (dol_is_file($xmlfile)) |
869 | 893 | { |
870 | 894 | $xml = simplexml_load_file($xmlfile); |
871 | - } |
|
872 | - else |
|
895 | + } else |
|
873 | 896 | { |
874 | 897 | throw new RestException(500, $langs->trans('XmlNotFound') . ': ' . $xmlfile); |
875 | 898 | } |
876 | - } |
|
877 | - else |
|
899 | + } else |
|
878 | 900 | { |
879 | 901 | $xmlarray = getURLContent($xmlremote); |
880 | 902 | |
@@ -884,8 +906,7 @@ discard block |
||
884 | 906 | $xmlfile = $xmlarray['content']; |
885 | 907 | //print "xmlfilestart".$xmlfile."endxmlfile"; |
886 | 908 | $xml = simplexml_load_string($xmlfile); |
887 | - } |
|
888 | - else |
|
909 | + } else |
|
889 | 910 | { |
890 | 911 | $errormsg=$langs->trans('XmlNotFound') . ': ' . $xmlremote.' - '.$xmlarray['http_code'].' '.$xmlarray['curl_error_no'].' '.$xmlarray['curl_error_msg']; |
891 | 912 | throw new RestException(500, $errormsg); |
@@ -915,14 +936,18 @@ discard block |
||
915 | 936 | $out.='</tr>'."\n"; |
916 | 937 | |
917 | 938 | $i = 0; |
918 | - foreach ($xml->dolibarr_constants[0]->constant as $constant) // $constant is a simpleXMLElement |
|
939 | + foreach ($xml->dolibarr_constants[0]->constant as $constant) { |
|
940 | + // $constant is a simpleXMLElement |
|
919 | 941 | { |
920 | 942 | $constname=$constant['name']; |
943 | + } |
|
921 | 944 | $constvalue=(string) $constant; |
922 | 945 | $constvalue = (empty($constvalue)?'0':$constvalue); |
923 | 946 | // Value found |
924 | 947 | $value=''; |
925 | - if ($constname && $conf->global->$constname != '') $value=$conf->global->$constname; |
|
948 | + if ($constname && $conf->global->$constname != '') { |
|
949 | + $value=$conf->global->$constname; |
|
950 | + } |
|
926 | 951 | $valueforchecksum=(empty($value)?'0':$value); |
927 | 952 | |
928 | 953 | $checksumconcat[]=$valueforchecksum; |
@@ -993,8 +1018,7 @@ discard block |
||
993 | 1018 | $out.='<td align="center">'.$file['expectedmd5'].'</td>' . "\n"; |
994 | 1019 | $out.="</tr>\n"; |
995 | 1020 | } |
996 | - } |
|
997 | - else |
|
1021 | + } else |
|
998 | 1022 | { |
999 | 1023 | $out.='<tr class="oddeven"><td colspan="3" class="opacitymedium">'.$langs->trans("None").'</td></tr>'; |
1000 | 1024 | } |
@@ -1043,8 +1067,7 @@ discard block |
||
1043 | 1067 | $out.='<td align="right">'.dol_print_size($totalsize).'</td>' . "\n"; |
1044 | 1068 | $out.='<td align="right"></td>' . "\n"; |
1045 | 1069 | $out.="</tr>\n"; |
1046 | - } |
|
1047 | - else |
|
1070 | + } else |
|
1048 | 1071 | { |
1049 | 1072 | $out.='<tr class="oddeven"><td colspan="5" class="opacitymedium">'.$langs->trans("None").'</td></tr>'; |
1050 | 1073 | } |
@@ -1093,8 +1116,7 @@ discard block |
||
1093 | 1116 | $out.='<td align="right">'.dol_print_size($totalsize).'</td>' . "\n"; |
1094 | 1117 | $out.='<td align="right"></td>' . "\n"; |
1095 | 1118 | $out.="</tr>\n"; |
1096 | - } |
|
1097 | - else |
|
1119 | + } else |
|
1098 | 1120 | { |
1099 | 1121 | $out.='<tr class="oddeven"><td colspan="5" class="opacitymedium">'.$langs->trans("None").'</td></tr>'; |
1100 | 1122 | } |
@@ -1106,13 +1128,11 @@ discard block |
||
1106 | 1128 | if (empty($tmpfilelist) && empty($tmpfilelist2) && empty($tmpfilelist3)) |
1107 | 1129 | { |
1108 | 1130 | //setEventMessages($langs->trans("FileIntegrityIsStrictlyConformedWithReference"), null, 'mesgs'); |
1109 | - } |
|
1110 | - else |
|
1131 | + } else |
|
1111 | 1132 | { |
1112 | 1133 | //setEventMessages($langs->trans("FileIntegritySomeFilesWereRemovedOrModified"), null, 'warnings'); |
1113 | 1134 | } |
1114 | - } |
|
1115 | - else |
|
1135 | + } else |
|
1116 | 1136 | { |
1117 | 1137 | throw new RestException(500, 'Error: Failed to found dolibarr_htdocs_dir into XML file '.$xmlfile); |
1118 | 1138 | } |
@@ -1135,24 +1155,21 @@ discard block |
||
1135 | 1155 | $resultcomment='FileIntegrityIsOkButFilesWereAdded'; |
1136 | 1156 | //$outcurrentchecksum = $checksumget.' - <span class="'.$resultcode.'">'.$langs->trans("FileIntegrityIsOkButFilesWereAdded").'</span>'; |
1137 | 1157 | $outcurrentchecksum = $checksumget; |
1138 | - } |
|
1139 | - else |
|
1158 | + } else |
|
1140 | 1159 | { |
1141 | 1160 | $resultcode = 'ok'; |
1142 | 1161 | $resultcomment='Success'; |
1143 | 1162 | //$outcurrentchecksum = '<span class="'.$resultcode.'">'.$checksumget.'</span>'; |
1144 | 1163 | $outcurrentchecksum = $checksumget; |
1145 | 1164 | } |
1146 | - } |
|
1147 | - else |
|
1165 | + } else |
|
1148 | 1166 | { |
1149 | 1167 | $resultcode = 'error'; |
1150 | 1168 | $resultcomment='Error'; |
1151 | 1169 | //$outcurrentchecksum = '<span class="'.$resultcode.'">'.$checksumget.'</span>'; |
1152 | 1170 | $outcurrentchecksum = $checksumget; |
1153 | 1171 | } |
1154 | - } |
|
1155 | - else { |
|
1172 | + } else { |
|
1156 | 1173 | throw new RestException(404, 'No signature file known'); |
1157 | 1174 | } |
1158 | 1175 |
@@ -181,8 +181,7 @@ discard block |
||
181 | 181 | if( $result <= 0 ) { |
182 | 182 | throw new RestException(500, 'Error generating document'); |
183 | 183 | } |
184 | - } |
|
185 | - elseif ($module_part == 'commande' || $module_part == 'order') |
|
184 | + } elseif ($module_part == 'commande' || $module_part == 'order') |
|
186 | 185 | { |
187 | 186 | require_once DOL_DOCUMENT_ROOT.'/commande/class/commande.class.php'; |
188 | 187 | $this->order = new Commande($this->db); |
@@ -195,8 +194,7 @@ discard block |
||
195 | 194 | if( $result <= 0 ) { |
196 | 195 | throw new RestException(500, 'Error generating document'); |
197 | 196 | } |
198 | - } |
|
199 | - elseif ($module_part == 'propal' || $module_part == 'proposal') |
|
197 | + } elseif ($module_part == 'propal' || $module_part == 'proposal') |
|
200 | 198 | { |
201 | 199 | require_once DOL_DOCUMENT_ROOT.'/comm/propal/class/propal.class.php'; |
202 | 200 | $this->propal = new Propal($this->db); |
@@ -209,8 +207,7 @@ discard block |
||
209 | 207 | if( $result <= 0 ) { |
210 | 208 | throw new RestException(500, 'Error generating document'); |
211 | 209 | } |
212 | - } |
|
213 | - else |
|
210 | + } else |
|
214 | 211 | { |
215 | 212 | throw new RestException(403, 'Generation not available for this modulepart'); |
216 | 213 | } |
@@ -274,8 +271,7 @@ discard block |
||
274 | 271 | } |
275 | 272 | |
276 | 273 | $upload_dir = $conf->societe->multidir_output[$object->entity] . "/" . $object->id; |
277 | - } |
|
278 | - else if ($modulepart == 'adherent' || $modulepart == 'member') |
|
274 | + } else if ($modulepart == 'adherent' || $modulepart == 'member') |
|
279 | 275 | { |
280 | 276 | require_once DOL_DOCUMENT_ROOT.'/adherents/class/adherent.class.php'; |
281 | 277 | |
@@ -290,8 +286,7 @@ discard block |
||
290 | 286 | } |
291 | 287 | |
292 | 288 | $upload_dir = $conf->adherent->dir_output . "/" . get_exdir(0, 0, 0, 1, $object, 'member'); |
293 | - } |
|
294 | - else if ($modulepart == 'propal' || $modulepart == 'proposal') |
|
289 | + } else if ($modulepart == 'propal' || $modulepart == 'proposal') |
|
295 | 290 | { |
296 | 291 | require_once DOL_DOCUMENT_ROOT.'/comm/propal/class/propal.class.php'; |
297 | 292 | |
@@ -306,8 +301,7 @@ discard block |
||
306 | 301 | } |
307 | 302 | |
308 | 303 | $upload_dir = $conf->propal->multidir_output[$object->entity] . "/" . get_exdir(0, 0, 0, 1, $object, 'propal'); |
309 | - } |
|
310 | - else if ($modulepart == 'commande' || $modulepart == 'order') |
|
304 | + } else if ($modulepart == 'commande' || $modulepart == 'order') |
|
311 | 305 | { |
312 | 306 | require_once DOL_DOCUMENT_ROOT.'/commande/class/commande.class.php'; |
313 | 307 | |
@@ -322,8 +316,7 @@ discard block |
||
322 | 316 | } |
323 | 317 | |
324 | 318 | $upload_dir = $conf->commande->dir_output . "/" . get_exdir(0, 0, 0, 1, $object, 'commande'); |
325 | - } |
|
326 | - else if ($modulepart == 'shipment' || $modulepart == 'expedition') |
|
319 | + } else if ($modulepart == 'shipment' || $modulepart == 'expedition') |
|
327 | 320 | { |
328 | 321 | require_once DOL_DOCUMENT_ROOT.'/expedition/class/expedition.class.php'; |
329 | 322 | |
@@ -338,8 +331,7 @@ discard block |
||
338 | 331 | } |
339 | 332 | |
340 | 333 | $upload_dir = $conf->expedition->dir_output . "/sending/" . get_exdir(0, 0, 0, 1, $object, 'shipment'); |
341 | - } |
|
342 | - else if ($modulepart == 'facture' || $modulepart == 'invoice') |
|
334 | + } else if ($modulepart == 'facture' || $modulepart == 'invoice') |
|
343 | 335 | { |
344 | 336 | require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php'; |
345 | 337 | |
@@ -354,8 +346,7 @@ discard block |
||
354 | 346 | } |
355 | 347 | |
356 | 348 | $upload_dir = $conf->facture->dir_output . "/" . get_exdir(0, 0, 0, 1, $object, 'invoice'); |
357 | - } |
|
358 | - else if ($modulepart == 'agenda' || $modulepart == 'action' || $modulepart == 'event') |
|
349 | + } else if ($modulepart == 'agenda' || $modulepart == 'action' || $modulepart == 'event') |
|
359 | 350 | { |
360 | 351 | require_once DOL_DOCUMENT_ROOT.'/comm/action/class/actioncomm.class.php'; |
361 | 352 | |
@@ -370,8 +361,7 @@ discard block |
||
370 | 361 | } |
371 | 362 | |
372 | 363 | $upload_dir = $conf->agenda->dir_output.'/'.dol_sanitizeFileName($object->ref); |
373 | - } |
|
374 | - else |
|
364 | + } else |
|
375 | 365 | { |
376 | 366 | throw new RestException(500, 'Modulepart '.$modulepart.' not implemented yet.'); |
377 | 367 | } |
@@ -440,8 +430,12 @@ discard block |
||
440 | 430 | } |
441 | 431 | |
442 | 432 | $newfilecontent = ''; |
443 | - if (empty($fileencoding)) $newfilecontent = $filecontent; |
|
444 | - if ($fileencoding == 'base64') $newfilecontent = base64_decode($filecontent); |
|
433 | + if (empty($fileencoding)) { |
|
434 | + $newfilecontent = $filecontent; |
|
435 | + } |
|
436 | + if ($fileencoding == 'base64') { |
|
437 | + $newfilecontent = base64_decode($filecontent); |
|
438 | + } |
|
445 | 439 | |
446 | 440 | $original_file = dol_sanitizeFileName($filename); |
447 | 441 | |
@@ -458,13 +452,11 @@ discard block |
||
458 | 452 | |
459 | 453 | require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php'; |
460 | 454 | $object = new Facture($this->db); |
461 | - } |
|
462 | - elseif ($modulepart == 'project') |
|
455 | + } elseif ($modulepart == 'project') |
|
463 | 456 | { |
464 | 457 | require_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php'; |
465 | 458 | $object = new Project($this->db); |
466 | - } |
|
467 | - elseif ($modulepart == 'task' || $modulepart == 'project_task') |
|
459 | + } elseif ($modulepart == 'task' || $modulepart == 'project_task') |
|
468 | 460 | { |
469 | 461 | $modulepart = 'project_task'; |
470 | 462 | |
@@ -482,8 +474,7 @@ discard block |
||
482 | 474 | { |
483 | 475 | $tmpreldir = dol_sanitizeFileName($object->project->ref).'/'; |
484 | 476 | } |
485 | - } |
|
486 | - else |
|
477 | + } else |
|
487 | 478 | { |
488 | 479 | throw new RestException(500, 'Error while fetching Task '.$ref); |
489 | 480 | } |
@@ -501,8 +492,7 @@ discard block |
||
501 | 492 | if($result == 0) |
502 | 493 | { |
503 | 494 | throw new RestException(404, "Object with ref '".$ref."' was not found."); |
504 | - } |
|
505 | - elseif ($result < 0) |
|
495 | + } elseif ($result < 0) |
|
506 | 496 | { |
507 | 497 | throw new RestException(500, 'Error while fetching object.'); |
508 | 498 | } |
@@ -522,10 +512,11 @@ discard block |
||
522 | 512 | { |
523 | 513 | throw new RestException(500, 'This value of modulepart does not support yet usage of ref. Check modulepart parameter or try to use subdir parameter instead of ref.'); |
524 | 514 | } |
525 | - } |
|
526 | - else |
|
515 | + } else |
|
527 | 516 | { |
528 | - if ($modulepart == 'invoice') $modulepart ='facture'; |
|
517 | + if ($modulepart == 'invoice') { |
|
518 | + $modulepart ='facture'; |
|
519 | + } |
|
529 | 520 | |
530 | 521 | $relativefile = $subdir; |
531 | 522 | |
@@ -561,8 +552,7 @@ discard block |
||
561 | 552 | $nbofbyteswrote = fwrite($fhandle, $newfilecontent); |
562 | 553 | fclose($fhandle); |
563 | 554 | @chmod($destfiletmp, octdec($conf->global->MAIN_UMASK)); |
564 | - } |
|
565 | - else |
|
555 | + } else |
|
566 | 556 | { |
567 | 557 | throw new RestException(500, "Failed to open file '".$destfiletmp."' for write"); |
568 | 558 | } |
@@ -586,8 +576,9 @@ discard block |
||
586 | 576 | function _validate_file($data) { |
587 | 577 | $result = array(); |
588 | 578 | foreach (Documents::$DOCUMENT_FIELDS as $field) { |
589 | - if (!isset($data[$field])) |
|
590 | - throw new RestException(400, "$field field missing"); |
|
579 | + if (!isset($data[$field])) { |
|
580 | + throw new RestException(400, "$field field missing"); |
|
581 | + } |
|
591 | 582 | $result[$field] = $data[$field]; |
592 | 583 | } |
593 | 584 | return $result; |
@@ -32,8 +32,9 @@ discard block |
||
32 | 32 | // Load translation files required by the page |
33 | 33 | $langs->load("admin"); |
34 | 34 | |
35 | -if (! $user->admin) |
|
35 | +if (! $user->admin) { |
|
36 | 36 | accessforbidden(); |
37 | +} |
|
37 | 38 | |
38 | 39 | $action=GETPOST('action','aZ09'); |
39 | 40 | |
@@ -54,8 +55,7 @@ discard block |
||
54 | 55 | setEventMessages($langs->trans("ErrorFailedToCreateDir", $conf->api->dir_temp), null, 'errors'); |
55 | 56 | $error++; |
56 | 57 | } |
57 | - } |
|
58 | - else |
|
58 | + } else |
|
59 | 59 | { |
60 | 60 | // Delete the cache file otherwise it does not update |
61 | 61 | $result = dol_delete_file($conf->api->dir_temp.'/routes.php'); |
@@ -71,8 +71,7 @@ discard block |
||
71 | 71 | header("Location: ".$_SERVER["PHP_SELF"]); |
72 | 72 | exit; |
73 | 73 | } |
74 | - } |
|
75 | - else |
|
74 | + } else |
|
76 | 75 | { |
77 | 76 | dol_print_error($db); |
78 | 77 | } |
@@ -111,8 +110,7 @@ discard block |
||
111 | 110 | print '<td align="center"><a href="'.$_SERVER['PHP_SELF'].'?action=setproductionmode&value='.($i+1).'&status=0">'; |
112 | 111 | print img_picto($langs->trans("Activated"),'switch_on'); |
113 | 112 | print '</a></td>'; |
114 | -} |
|
115 | -else |
|
113 | +} else |
|
116 | 114 | { |
117 | 115 | print '<td align="center"><a href="'.$_SERVER['PHP_SELF'].'?action=setproductionmode&value='.($i+1).'&status=1">'; |
118 | 116 | print img_picto($langs->trans("Disabled"),'switch_off'); |
@@ -144,8 +142,7 @@ discard block |
||
144 | 142 | { |
145 | 143 | $url=DOL_MAIN_URL_ROOT.'/api/index.php/explorer'; |
146 | 144 | print img_picto('','object_globe.png').' <a href="'.$url.'" target="_blank">'.$url."</a><br>\n"; |
147 | -} |
|
148 | -else |
|
145 | +} else |
|
149 | 146 | { |
150 | 147 | print $langs->trans("NotAvailableWithThisDistribution"); |
151 | 148 | } |
@@ -94,7 +94,9 @@ discard block |
||
94 | 94 | $module='fichinter'; |
95 | 95 | } |
96 | 96 | |
97 | - if (empty($conf->$module->enabled)) $enabled=false; |
|
97 | + if (empty($conf->$module->enabled)) { |
|
98 | + $enabled=false; |
|
99 | + } |
|
98 | 100 | |
99 | 101 | if ($enabled) |
100 | 102 | { |
@@ -190,8 +192,12 @@ discard block |
||
190 | 192 | print $langs->trans("ListOfAvailableAPIs").':<br>'; |
191 | 193 | foreach($listofapis['v1'] as $key => $val) |
192 | 194 | { |
193 | - if ($key == 'login') continue; |
|
194 | - if ($key == 'index') continue; |
|
195 | + if ($key == 'login') { |
|
196 | + continue; |
|
197 | + } |
|
198 | + if ($key == 'index') { |
|
199 | + continue; |
|
200 | + } |
|
195 | 201 | |
196 | 202 | if ($key) |
197 | 203 | { |
@@ -199,7 +205,9 @@ discard block |
||
199 | 205 | { |
200 | 206 | $newclass=$val2['className']; |
201 | 207 | |
202 | - if (preg_match('/restler/i', $newclass)) continue; |
|
208 | + if (preg_match('/restler/i', $newclass)) { |
|
209 | + continue; |
|
210 | + } |
|
203 | 211 | |
204 | 212 | if ($oldclass != $newclass) |
205 | 213 | { |
@@ -24,21 +24,45 @@ discard block |
||
24 | 24 | * \file htdocs/api/index.php |
25 | 25 | */ |
26 | 26 | |
27 | -if (! defined('NOCSRFCHECK')) define('NOCSRFCHECK','1'); // Do not check anti CSRF attack test |
|
28 | -if (! defined('NOTOKENRENEWAL')) define('NOTOKENRENEWAL','1'); // Do not check anti POST attack test |
|
29 | -if (! defined('NOREQUIREMENU')) define('NOREQUIREMENU','1'); // If there is no need to load and show top and left menu |
|
30 | -if (! defined('NOREQUIREHTML')) define('NOREQUIREHTML','1'); // If we don't need to load the html.form.class.php |
|
31 | -if (! defined('NOREQUIREAJAX')) define('NOREQUIREAJAX','1'); // Do not load ajax.lib.php library |
|
32 | -if (! defined("NOLOGIN")) define("NOLOGIN",'1'); // If this page is public (can be called outside logged session) |
|
27 | +if (! defined('NOCSRFCHECK')) { |
|
28 | + define('NOCSRFCHECK','1'); |
|
29 | +} |
|
30 | +// Do not check anti CSRF attack test |
|
31 | +if (! defined('NOTOKENRENEWAL')) { |
|
32 | + define('NOTOKENRENEWAL','1'); |
|
33 | +} |
|
34 | +// Do not check anti POST attack test |
|
35 | +if (! defined('NOREQUIREMENU')) { |
|
36 | + define('NOREQUIREMENU','1'); |
|
37 | +} |
|
38 | +// If there is no need to load and show top and left menu |
|
39 | +if (! defined('NOREQUIREHTML')) { |
|
40 | + define('NOREQUIREHTML','1'); |
|
41 | +} |
|
42 | +// If we don't need to load the html.form.class.php |
|
43 | +if (! defined('NOREQUIREAJAX')) { |
|
44 | + define('NOREQUIREAJAX','1'); |
|
45 | +} |
|
46 | +// Do not load ajax.lib.php library |
|
47 | +if (! defined("NOLOGIN")) { |
|
48 | + define("NOLOGIN",'1'); |
|
49 | +} |
|
50 | +// If this page is public (can be called outside logged session) |
|
33 | 51 | |
34 | 52 | |
35 | 53 | // Force entity if a value is provided into HTTP header. Otherwise, will use the entity of user of token used. |
36 | -if (! empty($_SERVER['HTTP_DOLAPIENTITY'])) define("DOLENTITY", (int) $_SERVER['HTTP_DOLAPIENTITY']); |
|
54 | +if (! empty($_SERVER['HTTP_DOLAPIENTITY'])) { |
|
55 | + define("DOLENTITY", (int) $_SERVER['HTTP_DOLAPIENTITY']); |
|
56 | +} |
|
37 | 57 | |
38 | 58 | |
39 | 59 | $res=0; |
40 | -if (! $res && file_exists("../main.inc.php")) $res=include '../main.inc.php'; |
|
41 | -if (! $res) die("Include of main fails"); |
|
60 | +if (! $res && file_exists("../main.inc.php")) { |
|
61 | + $res=include '../main.inc.php'; |
|
62 | +} |
|
63 | +if (! $res) { |
|
64 | + die("Include of main fails"); |
|
65 | +} |
|
42 | 66 | |
43 | 67 | require_once DOL_DOCUMENT_ROOT.'/includes/restler/framework/Luracast/Restler/AutoLoader.php'; |
44 | 68 | |
@@ -146,7 +170,9 @@ discard block |
||
146 | 170 | |
147 | 171 | // Defined if module is enabled |
148 | 172 | $enabled=true; |
149 | - if (empty($conf->$modulenameforenabled->enabled)) $enabled=false; |
|
173 | + if (empty($conf->$modulenameforenabled->enabled)) { |
|
174 | + $enabled=false; |
|
175 | + } |
|
150 | 176 | |
151 | 177 | if ($enabled) |
152 | 178 | { |
@@ -160,7 +186,9 @@ discard block |
||
160 | 186 | { |
161 | 187 | while (($file_searched = readdir($handle_part))!==false) |
162 | 188 | { |
163 | - if ($file_searched == 'api_access.class.php') continue; |
|
189 | + if ($file_searched == 'api_access.class.php') { |
|
190 | + continue; |
|
191 | + } |
|
164 | 192 | |
165 | 193 | if (is_readable($dir_part.$file_searched) && preg_match("/^api_(.*)\.class\.php$/i",$file_searched,$regapi)) |
166 | 194 | { |
@@ -171,13 +199,11 @@ discard block |
||
171 | 199 | { |
172 | 200 | //dol_syslog("Found API by index.php: classname=".$classname."Api for module ".$dir." into ".$dir_part.$file_searched); |
173 | 201 | $listofapis[strtolower($classname.'Api')] = $classname.'Api'; |
174 | - } |
|
175 | - elseif (class_exists($classname)) |
|
202 | + } elseif (class_exists($classname)) |
|
176 | 203 | { |
177 | 204 | //dol_syslog("Found API by index.php: classname=".$classname." for module ".$dir." into ".$dir_part.$file_searched); |
178 | 205 | $listofapis[strtolower($classname)] = $classname; |
179 | - } |
|
180 | - else |
|
206 | + } else |
|
181 | 207 | { |
182 | 208 | dol_syslog("We found an api_xxx file (".$file_searched.") but class ".$classname." does not exists after loading file", LOG_WARNING); |
183 | 209 | } |
@@ -204,10 +230,12 @@ discard block |
||
204 | 230 | if (! empty($reg[1]) && ($reg[1] != 'explorer' || ($reg[2] != '/swagger.json' && $reg[2] != '/resources.json' && preg_match('/^\/(swagger|resources)\.json\/(.+)$/', $reg[2], $regbis) && $regbis[2] != 'root'))) |
205 | 231 | { |
206 | 232 | $module = $reg[1]; |
207 | - if ($module == 'explorer') // If we call page to explore details of a service |
|
233 | + if ($module == 'explorer') { |
|
234 | + // If we call page to explore details of a service |
|
208 | 235 | { |
209 | 236 | $module = $regbis[2]; |
210 | 237 | } |
238 | + } |
|
211 | 239 | |
212 | 240 | $module=strtolower($module); |
213 | 241 | $moduledirforclass = getModuleDirForApiClass($module); |
@@ -216,19 +244,25 @@ discard block |
||
216 | 244 | dol_syslog("Load a dedicated API file module=".$module." moduledirforclass=".$moduledirforclass); |
217 | 245 | |
218 | 246 | $tmpmodule = $module; |
219 | - if ($tmpmodule != 'api') |
|
220 | - $tmpmodule = preg_replace('/api$/i', '', $tmpmodule); |
|
247 | + if ($tmpmodule != 'api') { |
|
248 | + $tmpmodule = preg_replace('/api$/i', '', $tmpmodule); |
|
249 | + } |
|
221 | 250 | $classfile = str_replace('_', '', $tmpmodule); |
222 | - if ($module == 'supplierproposals') |
|
223 | - $classfile = 'supplier_proposals'; |
|
224 | - if ($module == 'supplierorders') |
|
225 | - $classfile = 'supplier_orders'; |
|
226 | - if ($module == 'supplierinvoices') |
|
227 | - $classfile = 'supplier_invoices'; |
|
228 | - if ($module == 'ficheinter') |
|
229 | - $classfile = 'interventions'; |
|
230 | - if ($module == 'interventions') |
|
231 | - $classfile = 'interventions'; |
|
251 | + if ($module == 'supplierproposals') { |
|
252 | + $classfile = 'supplier_proposals'; |
|
253 | + } |
|
254 | + if ($module == 'supplierorders') { |
|
255 | + $classfile = 'supplier_orders'; |
|
256 | + } |
|
257 | + if ($module == 'supplierinvoices') { |
|
258 | + $classfile = 'supplier_invoices'; |
|
259 | + } |
|
260 | + if ($module == 'ficheinter') { |
|
261 | + $classfile = 'interventions'; |
|
262 | + } |
|
263 | + if ($module == 'interventions') { |
|
264 | + $classfile = 'interventions'; |
|
265 | + } |
|
232 | 266 | |
233 | 267 | $dir_part_file = dol_buildpath('/' . $moduledirforclass . '/class/api_' . $classfile . '.class.php', 0, 2); |
234 | 268 | |
@@ -237,17 +271,19 @@ discard block |
||
237 | 271 | dol_syslog('Search /' . $moduledirforclass . '/class/api_' . $classfile . '.class.php => dir_part_file=' . $dir_part_file . ' classname=' . $classname); |
238 | 272 | |
239 | 273 | $res = false; |
240 | - if ($dir_part_file) |
|
241 | - $res = include_once $dir_part_file; |
|
274 | + if ($dir_part_file) { |
|
275 | + $res = include_once $dir_part_file; |
|
276 | + } |
|
242 | 277 | if (! $res) { |
243 | 278 | print 'API not found (failed to include API file)'; |
244 | 279 | header('HTTP/1.1 501 API not found (failed to include API file)'); |
245 | 280 | exit(0); |
246 | 281 | } |
247 | 282 | |
248 | - if (class_exists($classname)) |
|
249 | - $api->r->addAPIClass($classname); |
|
250 | -} |
|
283 | + if (class_exists($classname)) { |
|
284 | + $api->r->addAPIClass($classname); |
|
285 | + } |
|
286 | + } |
|
251 | 287 | |
252 | 288 | // TODO If not found, redirect to explorer |
253 | 289 | //var_dump($api->r->apiVersionMap); |
@@ -25,11 +25,13 @@ discard block |
||
25 | 25 | if (session_id() == "") |
26 | 26 | { |
27 | 27 | session_start(); |
28 | - if (ini_get('register_globals')) // To solve bug in using $_SESSION |
|
28 | + if (ini_get('register_globals')) { |
|
29 | + // To solve bug in using $_SESSION |
|
29 | 30 | { |
30 | 31 | foreach ($_SESSION as $key=>$value) |
31 | 32 | { |
32 | 33 | if (isset($GLOBALS[$key])) unset($GLOBALS[$key]); |
34 | + } |
|
33 | 35 | } |
34 | 36 | } |
35 | 37 | } |
@@ -48,12 +50,13 @@ discard block |
||
48 | 50 | ' For the sandbox, the URL is https://www.sandbox.paypal.com/webscr&cmd=_express-checkout&token= |
49 | 51 | ' For the live site, the URL is https://www.paypal.com/webscr&cmd=_express-checkout&token= |
50 | 52 | */ |
51 | -if (! empty($conf->global->PAYPAL_API_SANDBOX) || GETPOST('forcesandbox','alpha')) // We can force sand box with param 'forcesandbox' |
|
53 | +if (! empty($conf->global->PAYPAL_API_SANDBOX) || GETPOST('forcesandbox','alpha')) { |
|
54 | + // We can force sand box with param 'forcesandbox' |
|
52 | 55 | { |
53 | 56 | $API_Endpoint = "https://api-3t.sandbox.paypal.com/nvp"; |
54 | - $API_Url = "https://www.sandbox.paypal.com/webscr?cmd=_express-checkout&token="; |
|
55 | 57 | } |
56 | -else |
|
58 | + $API_Url = "https://www.sandbox.paypal.com/webscr?cmd=_express-checkout&token="; |
|
59 | +} else |
|
57 | 60 | { |
58 | 61 | $API_Endpoint = "https://api-3t.paypal.com/nvp"; |
59 | 62 | $API_Url = "https://www.paypal.com/cgi-bin/webscr?cmd=_express-checkout&token="; |
@@ -61,13 +64,21 @@ discard block |
||
61 | 64 | |
62 | 65 | // Clean parameters |
63 | 66 | $PAYPAL_API_USER=""; |
64 | -if (! empty($conf->global->PAYPAL_API_USER)) $PAYPAL_API_USER=$conf->global->PAYPAL_API_USER; |
|
67 | +if (! empty($conf->global->PAYPAL_API_USER)) { |
|
68 | + $PAYPAL_API_USER=$conf->global->PAYPAL_API_USER; |
|
69 | +} |
|
65 | 70 | $PAYPAL_API_PASSWORD=""; |
66 | -if (! empty($conf->global->PAYPAL_API_PASSWORD)) $PAYPAL_API_PASSWORD=$conf->global->PAYPAL_API_PASSWORD; |
|
71 | +if (! empty($conf->global->PAYPAL_API_PASSWORD)) { |
|
72 | + $PAYPAL_API_PASSWORD=$conf->global->PAYPAL_API_PASSWORD; |
|
73 | +} |
|
67 | 74 | $PAYPAL_API_SIGNATURE=""; |
68 | -if (! empty($conf->global->PAYPAL_API_SIGNATURE)) $PAYPAL_API_SIGNATURE=$conf->global->PAYPAL_API_SIGNATURE; |
|
75 | +if (! empty($conf->global->PAYPAL_API_SIGNATURE)) { |
|
76 | + $PAYPAL_API_SIGNATURE=$conf->global->PAYPAL_API_SIGNATURE; |
|
77 | +} |
|
69 | 78 | $PAYPAL_API_SANDBOX=""; |
70 | -if (! empty($conf->global->PAYPAL_API_SANDBOX)) $PAYPAL_API_SANDBOX=$conf->global->PAYPAL_API_SANDBOX; |
|
79 | +if (! empty($conf->global->PAYPAL_API_SANDBOX)) { |
|
80 | + $PAYPAL_API_SANDBOX=$conf->global->PAYPAL_API_SANDBOX; |
|
81 | +} |
|
71 | 82 | |
72 | 83 | // Proxy |
73 | 84 | $PROXY_HOST = $conf->global->MAIN_PROXY_HOST; |
@@ -99,24 +99,36 @@ discard block |
||
99 | 99 | $out=DOL_MAIN_URL_ROOT.'/public/paypal/newpayment.php?amount='.($mode?'<font color="#666666">':'').$amount.($mode?'</font>':'').'&tag='.($mode?'<font color="#666666">':'').$freetag.($mode?'</font>':''); |
100 | 100 | if (! empty($conf->global->PAYPAL_SECURITY_TOKEN)) |
101 | 101 | { |
102 | - if (empty($conf->global->PAYPAL_SECURITY_TOKEN_UNIQUE)) $out.='&securekey='.$conf->global->PAYPAL_SECURITY_TOKEN; |
|
103 | - else $out.='&securekey='.dol_hash($conf->global->PAYPAL_SECURITY_TOKEN, 2); |
|
102 | + if (empty($conf->global->PAYPAL_SECURITY_TOKEN_UNIQUE)) { |
|
103 | + $out.='&securekey='.$conf->global->PAYPAL_SECURITY_TOKEN; |
|
104 | + } else { |
|
105 | + $out.='&securekey='.dol_hash($conf->global->PAYPAL_SECURITY_TOKEN, 2); |
|
106 | + } |
|
104 | 107 | } |
105 | 108 | } |
106 | 109 | if ($type == 'order') |
107 | 110 | { |
108 | 111 | $out=DOL_MAIN_URL_ROOT.'/public/paypal/newpayment.php?source=order&ref='.($mode?'<font color="#666666">':''); |
109 | - if ($mode == 1) $out.='order_ref'; |
|
110 | - if ($mode == 0) $out.=urlencode($ref); |
|
112 | + if ($mode == 1) { |
|
113 | + $out.='order_ref'; |
|
114 | + } |
|
115 | + if ($mode == 0) { |
|
116 | + $out.=urlencode($ref); |
|
117 | + } |
|
111 | 118 | $out.=($mode?'</font>':''); |
112 | 119 | if (! empty($conf->global->PAYPAL_SECURITY_TOKEN)) |
113 | 120 | { |
114 | - if (empty($conf->global->PAYPAL_SECURITY_TOKEN_UNIQUE)) $out.='&securekey='.$conf->global->PAYPAL_SECURITY_TOKEN; |
|
115 | - else |
|
121 | + if (empty($conf->global->PAYPAL_SECURITY_TOKEN_UNIQUE)) { |
|
122 | + $out.='&securekey='.$conf->global->PAYPAL_SECURITY_TOKEN; |
|
123 | + } else |
|
116 | 124 | { |
117 | 125 | $out.='&securekey='.($mode?'<font color="#666666">':''); |
118 | - if ($mode == 1) $out.="hash('".$conf->global->PAYPAL_SECURITY_TOKEN."' + '".$type."' + order_ref)"; |
|
119 | - if ($mode == 0) $out.= dol_hash($conf->global->PAYPAL_SECURITY_TOKEN . $type . $ref, 2); |
|
126 | + if ($mode == 1) { |
|
127 | + $out.="hash('".$conf->global->PAYPAL_SECURITY_TOKEN."' + '".$type."' + order_ref)"; |
|
128 | + } |
|
129 | + if ($mode == 0) { |
|
130 | + $out.= dol_hash($conf->global->PAYPAL_SECURITY_TOKEN . $type . $ref, 2); |
|
131 | + } |
|
120 | 132 | $out.=($mode?'</font>':''); |
121 | 133 | } |
122 | 134 | } |
@@ -124,17 +136,26 @@ discard block |
||
124 | 136 | if ($type == 'invoice') |
125 | 137 | { |
126 | 138 | $out=DOL_MAIN_URL_ROOT.'/public/paypal/newpayment.php?source=invoice&ref='.($mode?'<font color="#666666">':''); |
127 | - if ($mode == 1) $out.='invoice_ref'; |
|
128 | - if ($mode == 0) $out.=urlencode($ref); |
|
139 | + if ($mode == 1) { |
|
140 | + $out.='invoice_ref'; |
|
141 | + } |
|
142 | + if ($mode == 0) { |
|
143 | + $out.=urlencode($ref); |
|
144 | + } |
|
129 | 145 | $out.=($mode?'</font>':''); |
130 | 146 | if (! empty($conf->global->PAYPAL_SECURITY_TOKEN)) |
131 | 147 | { |
132 | - if (empty($conf->global->PAYPAL_SECURITY_TOKEN_UNIQUE)) $out.='&securekey='.$conf->global->PAYPAL_SECURITY_TOKEN; |
|
133 | - else |
|
148 | + if (empty($conf->global->PAYPAL_SECURITY_TOKEN_UNIQUE)) { |
|
149 | + $out.='&securekey='.$conf->global->PAYPAL_SECURITY_TOKEN; |
|
150 | + } else |
|
134 | 151 | { |
135 | 152 | $out.='&securekey='.($mode?'<font color="#666666">':''); |
136 | - if ($mode == 1) $out.="hash('".$conf->global->PAYPAL_SECURITY_TOKEN."' + '".$type."' + invoice_ref)"; |
|
137 | - if ($mode == 0) $out.= dol_hash($conf->global->PAYPAL_SECURITY_TOKEN . $type . $ref, 2); |
|
153 | + if ($mode == 1) { |
|
154 | + $out.="hash('".$conf->global->PAYPAL_SECURITY_TOKEN."' + '".$type."' + invoice_ref)"; |
|
155 | + } |
|
156 | + if ($mode == 0) { |
|
157 | + $out.= dol_hash($conf->global->PAYPAL_SECURITY_TOKEN . $type . $ref, 2); |
|
158 | + } |
|
138 | 159 | $out.=($mode?'</font>':''); |
139 | 160 | } |
140 | 161 | } |
@@ -142,17 +163,26 @@ discard block |
||
142 | 163 | if ($type == 'contractline') |
143 | 164 | { |
144 | 165 | $out=DOL_MAIN_URL_ROOT.'/public/paypal/newpayment.php?source=contractline&ref='.($mode?'<font color="#666666">':''); |
145 | - if ($mode == 1) $out.='contractline_ref'; |
|
146 | - if ($mode == 0) $out.=urlencode($ref); |
|
166 | + if ($mode == 1) { |
|
167 | + $out.='contractline_ref'; |
|
168 | + } |
|
169 | + if ($mode == 0) { |
|
170 | + $out.=urlencode($ref); |
|
171 | + } |
|
147 | 172 | $out.=($mode?'</font>':''); |
148 | 173 | if (! empty($conf->global->PAYPAL_SECURITY_TOKEN)) |
149 | 174 | { |
150 | - if (empty($conf->global->PAYPAL_SECURITY_TOKEN_UNIQUE)) $out.='&securekey='.$conf->global->PAYPAL_SECURITY_TOKEN; |
|
151 | - else |
|
175 | + if (empty($conf->global->PAYPAL_SECURITY_TOKEN_UNIQUE)) { |
|
176 | + $out.='&securekey='.$conf->global->PAYPAL_SECURITY_TOKEN; |
|
177 | + } else |
|
152 | 178 | { |
153 | 179 | $out.='&securekey='.($mode?'<font color="#666666">':''); |
154 | - if ($mode == 1) $out.="hash('".$conf->global->PAYPAL_SECURITY_TOKEN."' + '".$type."' + contractline_ref)"; |
|
155 | - if ($mode == 0) $out.= dol_hash($conf->global->PAYPAL_SECURITY_TOKEN . $type . $ref, 2); |
|
180 | + if ($mode == 1) { |
|
181 | + $out.="hash('".$conf->global->PAYPAL_SECURITY_TOKEN."' + '".$type."' + contractline_ref)"; |
|
182 | + } |
|
183 | + if ($mode == 0) { |
|
184 | + $out.= dol_hash($conf->global->PAYPAL_SECURITY_TOKEN . $type . $ref, 2); |
|
185 | + } |
|
156 | 186 | $out.=($mode?'</font>':''); |
157 | 187 | } |
158 | 188 | } |
@@ -160,17 +190,26 @@ discard block |
||
160 | 190 | if ($type == 'membersubscription') |
161 | 191 | { |
162 | 192 | $out=DOL_MAIN_URL_ROOT.'/public/paypal/newpayment.php?source=membersubscription&ref='.($mode?'<font color="#666666">':''); |
163 | - if ($mode == 1) $out.='member_ref'; |
|
164 | - if ($mode == 0) $out.=urlencode($ref); |
|
193 | + if ($mode == 1) { |
|
194 | + $out.='member_ref'; |
|
195 | + } |
|
196 | + if ($mode == 0) { |
|
197 | + $out.=urlencode($ref); |
|
198 | + } |
|
165 | 199 | $out.=($mode?'</font>':''); |
166 | 200 | if (! empty($conf->global->PAYPAL_SECURITY_TOKEN)) |
167 | 201 | { |
168 | - if (empty($conf->global->PAYPAL_SECURITY_TOKEN_UNIQUE)) $out.='&securekey='.$conf->global->PAYPAL_SECURITY_TOKEN; |
|
169 | - else |
|
202 | + if (empty($conf->global->PAYPAL_SECURITY_TOKEN_UNIQUE)) { |
|
203 | + $out.='&securekey='.$conf->global->PAYPAL_SECURITY_TOKEN; |
|
204 | + } else |
|
170 | 205 | { |
171 | 206 | $out.='&securekey='.($mode?'<font color="#666666">':''); |
172 | - if ($mode == 1) $out.="hash('".$conf->global->PAYPAL_SECURITY_TOKEN."' + '".$type."' + member_ref)"; |
|
173 | - if ($mode == 0) $out.= dol_hash($conf->global->PAYPAL_SECURITY_TOKEN . $type . $ref, 2); |
|
207 | + if ($mode == 1) { |
|
208 | + $out.="hash('".$conf->global->PAYPAL_SECURITY_TOKEN."' + '".$type."' + member_ref)"; |
|
209 | + } |
|
210 | + if ($mode == 0) { |
|
211 | + $out.= dol_hash($conf->global->PAYPAL_SECURITY_TOKEN . $type . $ref, 2); |
|
212 | + } |
|
174 | 213 | $out.=($mode?'</font>':''); |
175 | 214 | } |
176 | 215 | } |
@@ -209,7 +248,9 @@ discard block |
||
209 | 248 | //' |
210 | 249 | //'------------------------------------------------- |
211 | 250 | |
212 | - if (empty($conf->global->PAYPAL_API_INTEGRAL_OR_PAYPALONLY)) $conf->global->PAYPAL_API_INTEGRAL_OR_PAYPALONLY='integral'; |
|
251 | + if (empty($conf->global->PAYPAL_API_INTEGRAL_OR_PAYPALONLY)) { |
|
252 | + $conf->global->PAYPAL_API_INTEGRAL_OR_PAYPALONLY='integral'; |
|
253 | + } |
|
213 | 254 | |
214 | 255 | $solutionType='Sole'; |
215 | 256 | $landingPage='Billing'; |
@@ -263,8 +304,7 @@ discard block |
||
263 | 304 | $payPalURL = $API_Url . $token; |
264 | 305 | header("Location: ".$payPalURL); |
265 | 306 | exit; |
266 | - } |
|
267 | - else |
|
307 | + } else |
|
268 | 308 | { |
269 | 309 | //Display a user friendly Error on the page using any of the following error information returned by PayPal |
270 | 310 | $ErrorCode = urldecode($resArray["L_ERRORCODE0"]); |
@@ -275,8 +315,7 @@ discard block |
||
275 | 315 | if ($ErrorCode == 10729) |
276 | 316 | { |
277 | 317 | $mesg.= "PayPal can't accept payments for this thirdparty. An address is defined but is not complete (missing State).<br>Ask system administrator to fix address or to setup Paypal module to accept payments even on not complete addresses (remove option PAYPAL_REQUIRE_VALID_SHIPPING_ADDRESS).<br>\n"; |
278 | - } |
|
279 | - else |
|
318 | + } else |
|
280 | 319 | { |
281 | 320 | $mesg = $langs->trans('SetExpressCheckoutAPICallFailed') . "<br>\n"; |
282 | 321 | $mesg.= $langs->trans('DetailedErrorMessage') . ": " . $ErrorLongMsg."<br>\n"; |
@@ -351,8 +390,7 @@ discard block |
||
351 | 390 | if (empty($conf->global->PAYPAL_REQUIRE_VALID_SHIPPING_ADDRESS)) |
352 | 391 | { |
353 | 392 | $nvpstr = $nvpstr . "&NOSHIPPING=1"; // An empty or not complete shipping address will be accepted |
354 | - } |
|
355 | - else |
|
393 | + } else |
|
356 | 394 | { |
357 | 395 | $nvpstr = $nvpstr . "&NOSHIPPING=0"; // A valid shipping address is required (full required fields mandatory) |
358 | 396 | } |
@@ -365,7 +403,9 @@ discard block |
||
365 | 403 | |
366 | 404 | $paypalprefix = 'PAYMENTREQUEST_0_'; |
367 | 405 | //$paypalprefix = ''; |
368 | - if (! empty($paypalprefix) && $paymentType == 'Sole') $paymentType='Sale'; |
|
406 | + if (! empty($paypalprefix) && $paymentType == 'Sole') { |
|
407 | + $paymentType='Sale'; |
|
408 | + } |
|
369 | 409 | |
370 | 410 | $nvpstr = $nvpstr . "&AMT=". urlencode($paymentAmount); // Total for all elements |
371 | 411 | |
@@ -388,8 +428,14 @@ discard block |
||
388 | 428 | $nvpstr = $nvpstr . "&".$paypalprefix."SHIPTOCOUNTRYCODE=" . urlencode($shipToCountryCode); |
389 | 429 | $nvpstr = $nvpstr . "&".$paypalprefix."SHIPTOZIP=" . urlencode($shipToZip); |
390 | 430 | $nvpstr = $nvpstr . "&".$paypalprefix."PHONENUM=" . urlencode($phoneNum); |
391 | - if (! empty($email)) $nvpstr = $nvpstr . "&".$paypalprefix."EMAIL=" . urlencode($email); // EMAIL deprecated by paypal -> PAYMENTREQUEST_n_EMAIL |
|
392 | - if (! empty($desc)) $nvpstr = $nvpstr . "&".$paypalprefix."DESC=" . urlencode($desc); // DESC deprecated by paypal -> PAYMENTREQUEST_n_DESC |
|
431 | + if (! empty($email)) { |
|
432 | + $nvpstr = $nvpstr . "&".$paypalprefix."EMAIL=" . urlencode($email); |
|
433 | + } |
|
434 | + // EMAIL deprecated by paypal -> PAYMENTREQUEST_n_EMAIL |
|
435 | + if (! empty($desc)) { |
|
436 | + $nvpstr = $nvpstr . "&".$paypalprefix."DESC=" . urlencode($desc); |
|
437 | + } |
|
438 | + // DESC deprecated by paypal -> PAYMENTREQUEST_n_DESC |
|
393 | 439 | |
394 | 440 | if (! empty($conf->global->PAYPAL_LOGOIMG) && $mysoc->logo) |
395 | 441 | { |
@@ -592,12 +638,13 @@ discard block |
||
592 | 638 | |
593 | 639 | // TODO problem with triggers |
594 | 640 | $API_version="98.0"; |
595 | - if (! empty($conf->global->PAYPAL_API_SANDBOX) || GETPOST('forcesandbox','alpha')) // We can force sand box with param 'forcesandbox' |
|
641 | + if (! empty($conf->global->PAYPAL_API_SANDBOX) || GETPOST('forcesandbox','alpha')) { |
|
642 | + // We can force sand box with param 'forcesandbox' |
|
596 | 643 | { |
597 | 644 | $API_Endpoint = "https://api-3t.sandbox.paypal.com/nvp"; |
598 | - $API_Url = "https://www.sandbox.paypal.com/webscr?cmd=_express-checkout&token="; |
|
599 | 645 | } |
600 | - else |
|
646 | + $API_Url = "https://www.sandbox.paypal.com/webscr?cmd=_express-checkout&token="; |
|
647 | + } else |
|
601 | 648 | { |
602 | 649 | $API_Endpoint = "https://api-3t.paypal.com/nvp"; |
603 | 650 | $API_Url = "https://www.paypal.com/cgi-bin/webscr?cmd=_express-checkout&token="; |
@@ -605,13 +652,21 @@ discard block |
||
605 | 652 | |
606 | 653 | // Clean parameters |
607 | 654 | $PAYPAL_API_USER=""; |
608 | - if (! empty($conf->global->PAYPAL_API_USER)) $PAYPAL_API_USER=$conf->global->PAYPAL_API_USER; |
|
655 | + if (! empty($conf->global->PAYPAL_API_USER)) { |
|
656 | + $PAYPAL_API_USER=$conf->global->PAYPAL_API_USER; |
|
657 | + } |
|
609 | 658 | $PAYPAL_API_PASSWORD=""; |
610 | - if (! empty($conf->global->PAYPAL_API_PASSWORD)) $PAYPAL_API_PASSWORD=$conf->global->PAYPAL_API_PASSWORD; |
|
659 | + if (! empty($conf->global->PAYPAL_API_PASSWORD)) { |
|
660 | + $PAYPAL_API_PASSWORD=$conf->global->PAYPAL_API_PASSWORD; |
|
661 | + } |
|
611 | 662 | $PAYPAL_API_SIGNATURE=""; |
612 | - if (! empty($conf->global->PAYPAL_API_SIGNATURE)) $PAYPAL_API_SIGNATURE=$conf->global->PAYPAL_API_SIGNATURE; |
|
663 | + if (! empty($conf->global->PAYPAL_API_SIGNATURE)) { |
|
664 | + $PAYPAL_API_SIGNATURE=$conf->global->PAYPAL_API_SIGNATURE; |
|
665 | + } |
|
613 | 666 | $PAYPAL_API_SANDBOX=""; |
614 | - if (! empty($conf->global->PAYPAL_API_SANDBOX)) $PAYPAL_API_SANDBOX=$conf->global->PAYPAL_API_SANDBOX; |
|
667 | + if (! empty($conf->global->PAYPAL_API_SANDBOX)) { |
|
668 | + $PAYPAL_API_SANDBOX=$conf->global->PAYPAL_API_SANDBOX; |
|
669 | + } |
|
615 | 670 | // TODO END problem with triggers |
616 | 671 | |
617 | 672 | dol_syslog("Paypal API endpoint ".$API_Endpoint); |
@@ -644,7 +699,9 @@ discard block |
||
644 | 699 | dol_syslog("Paypal API hash_call set proxy to ".$PROXY_HOST. ":" . $PROXY_PORT." - ".$PROXY_USER. ":" . $PROXY_PASS); |
645 | 700 | //curl_setopt ($ch, CURLOPT_PROXYTYPE, CURLPROXY_HTTP); // Curl 7.10 |
646 | 701 | curl_setopt($ch, CURLOPT_PROXY, $PROXY_HOST. ":" . $PROXY_PORT); |
647 | - if ($PROXY_USER) curl_setopt($ch, CURLOPT_PROXYUSERPWD, $PROXY_USER. ":" . $PROXY_PASS); |
|
702 | + if ($PROXY_USER) { |
|
703 | + curl_setopt($ch, CURLOPT_PROXYUSERPWD, $PROXY_USER. ":" . $PROXY_PASS); |
|
704 | + } |
|
648 | 705 | } |
649 | 706 | |
650 | 707 | //NVPRequest for submitting to server |
@@ -676,8 +733,7 @@ discard block |
||
676 | 733 | $_SESSION['curl_error_msg']=curl_error($ch); |
677 | 734 | |
678 | 735 | //Execute the Error handling module to display errors. |
679 | - } |
|
680 | - else |
|
736 | + } else |
|
681 | 737 | { |
682 | 738 | //closing the curl |
683 | 739 | curl_close($ch); |
@@ -35,7 +35,9 @@ discard block |
||
35 | 35 | // Load translation files required by the page |
36 | 36 | $langs->loadLangs(array('admin', 'other', 'paypal', 'paybox')); |
37 | 37 | |
38 | -if (! $user->admin) accessforbidden(); |
|
38 | +if (! $user->admin) { |
|
39 | + accessforbidden(); |
|
40 | +} |
|
39 | 41 | |
40 | 42 | $action = GETPOST('action','alpha'); |
41 | 43 | |
@@ -44,43 +46,72 @@ discard block |
||
44 | 46 | $db->begin(); |
45 | 47 | |
46 | 48 | $result=dolibarr_set_const($db, "PAYPAL_API_USER",GETPOST('PAYPAL_API_USER','alpha'),'chaine',0,'',$conf->entity); |
47 | - if (! $result > 0) $error++; |
|
49 | + if (! $result > 0) { |
|
50 | + $error++; |
|
51 | + } |
|
48 | 52 | $result=dolibarr_set_const($db, "PAYPAL_API_PASSWORD",GETPOST('PAYPAL_API_PASSWORD','alpha'),'chaine',0,'',$conf->entity); |
49 | - if (! $result > 0) $error++; |
|
53 | + if (! $result > 0) { |
|
54 | + $error++; |
|
55 | + } |
|
50 | 56 | $result=dolibarr_set_const($db, "PAYPAL_API_SIGNATURE",GETPOST('PAYPAL_API_SIGNATURE','alpha'),'chaine',0,'',$conf->entity); |
51 | - if (! $result > 0) $error++; |
|
57 | + if (! $result > 0) { |
|
58 | + $error++; |
|
59 | + } |
|
52 | 60 | $result=dolibarr_set_const($db, "PAYPAL_SSLVERSION",GETPOST('PAYPAL_SSLVERSION','alpha'),'chaine',0,'',$conf->entity); |
53 | - if (! $result > 0) $error++; |
|
61 | + if (! $result > 0) { |
|
62 | + $error++; |
|
63 | + } |
|
54 | 64 | $result=dolibarr_set_const($db, "ONLINE_PAYMENT_CREDITOR",GETPOST('ONLINE_PAYMENT_CREDITOR','alpha'),'chaine',0,'',$conf->entity); |
55 | - if (! $result > 0) $error++; |
|
65 | + if (! $result > 0) { |
|
66 | + $error++; |
|
67 | + } |
|
56 | 68 | $result=dolibarr_set_const($db, "PAYPAL_BANK_ACCOUNT_FOR_PAYMENTS",GETPOST('PAYPAL_BANK_ACCOUNT_FOR_PAYMENTS','int'),'chaine',0,'',$conf->entity); |
57 | - if (! $result > 0) $error++; |
|
69 | + if (! $result > 0) { |
|
70 | + $error++; |
|
71 | + } |
|
58 | 72 | $result=dolibarr_set_const($db, "PAYPAL_API_INTEGRAL_OR_PAYPALONLY",GETPOST('PAYPAL_API_INTEGRAL_OR_PAYPALONLY','alpha'),'chaine',0,'',$conf->entity); |
59 | - if (! $result > 0) $error++; |
|
73 | + if (! $result > 0) { |
|
74 | + $error++; |
|
75 | + } |
|
60 | 76 | $result=dolibarr_set_const($db, "ONLINE_PAYMENT_CSS_URL",GETPOST('ONLINE_PAYMENT_CSS_URL','alpha'),'chaine',0,'',$conf->entity); |
61 | - if (! $result > 0) $error++; |
|
77 | + if (! $result > 0) { |
|
78 | + $error++; |
|
79 | + } |
|
62 | 80 | $result=dolibarr_set_const($db, "PAYPAL_ADD_PAYMENT_URL",GETPOST('PAYPAL_ADD_PAYMENT_URL','alpha'),'chaine',0,'',$conf->entity); |
63 | - if (! $result > 0) $error++; |
|
81 | + if (! $result > 0) { |
|
82 | + $error++; |
|
83 | + } |
|
64 | 84 | $result=dolibarr_set_const($db, "ONLINE_PAYMENT_MESSAGE_FORM",GETPOST('ONLINE_PAYMENT_MESSAGE_FORM'),'chaine',0,'',$conf->entity); |
65 | - if (! $result > 0) $error++; |
|
85 | + if (! $result > 0) { |
|
86 | + $error++; |
|
87 | + } |
|
66 | 88 | $result=dolibarr_set_const($db, "ONLINE_PAYMENT_MESSAGE_OK",GETPOST('ONLINE_PAYMENT_MESSAGE_OK'),'chaine',0,'',$conf->entity); |
67 | - if (! $result > 0) $error++; |
|
89 | + if (! $result > 0) { |
|
90 | + $error++; |
|
91 | + } |
|
68 | 92 | $result=dolibarr_set_const($db, "ONLINE_PAYMENT_MESSAGE_KO",GETPOST('ONLINE_PAYMENT_MESSAGE_KO'),'chaine',0,'',$conf->entity); |
69 | - if (! $result > 0) $error++; |
|
93 | + if (! $result > 0) { |
|
94 | + $error++; |
|
95 | + } |
|
70 | 96 | $result=dolibarr_set_const($db, "ONLINE_PAYMENT_SENDEMAIL",GETPOST('ONLINE_PAYMENT_SENDEMAIL'),'chaine',0,'',$conf->entity); |
71 | - if (! $result > 0) $error++; |
|
97 | + if (! $result > 0) { |
|
98 | + $error++; |
|
99 | + } |
|
72 | 100 | // Payment token for URL |
73 | 101 | $result=dolibarr_set_const($db, "PAYMENT_SECURITY_TOKEN",GETPOST('PAYMENT_SECURITY_TOKEN','alpha'),'chaine',0,'',$conf->entity); |
74 | - if (! $result > 0) $error++; |
|
102 | + if (! $result > 0) { |
|
103 | + $error++; |
|
104 | + } |
|
75 | 105 | $result=dolibarr_set_const($db, "PAYMENT_SECURITY_TOKEN_UNIQUE",GETPOST('PAYMENT_SECURITY_TOKEN_UNIQUE','alpha'),'chaine',0,'',$conf->entity); |
76 | - if (! $result > 0) $error++; |
|
106 | + if (! $result > 0) { |
|
107 | + $error++; |
|
108 | + } |
|
77 | 109 | |
78 | 110 | if (! $error) |
79 | 111 | { |
80 | 112 | $db->commit(); |
81 | 113 | setEventMessages($langs->trans("SetupSaved"), null, 'mesgs'); |
82 | - } |
|
83 | - else |
|
114 | + } else |
|
84 | 115 | { |
85 | 116 | $db->rollback(); |
86 | 117 | dol_print_error($db); |
@@ -91,12 +122,13 @@ discard block |
||
91 | 122 | { |
92 | 123 | $liveenable = GETPOST('value','int')?0:1; |
93 | 124 | $res = dolibarr_set_const($db, "PAYPAL_API_SANDBOX", $liveenable,'yesno',0,'',$conf->entity); |
94 | - if (! $res > 0) $error++; |
|
125 | + if (! $res > 0) { |
|
126 | + $error++; |
|
127 | + } |
|
95 | 128 | if (! $error) |
96 | 129 | { |
97 | 130 | setEventMessages($langs->trans("SetupSaved"), null, 'mesgs'); |
98 | - } |
|
99 | - else |
|
131 | + } else |
|
100 | 132 | { |
101 | 133 | setEventMessages($langs->trans("Error"), null, 'errors'); |
102 | 134 | } |
@@ -151,8 +183,7 @@ discard block |
||
151 | 183 | { |
152 | 184 | print '<a href="'.$_SERVER['PHP_SELF'].'?action=setlive&value=0">'; |
153 | 185 | print img_picto($langs->trans("Activated"),'switch_on'); |
154 | -} |
|
155 | -else |
|
186 | +} else |
|
156 | 187 | { |
157 | 188 | print '<a href="'.$_SERVER['PHP_SELF'].'?action=setlive&value=1">'; |
158 | 189 | print img_picto($langs->trans("Disabled"),'switch_off'); |
@@ -267,8 +298,9 @@ discard block |
||
267 | 298 | print '<tr class="oddeven"><td>'; |
268 | 299 | print $langs->trans("SecurityToken").'</td><td>'; |
269 | 300 | print '<input size="48" type="text" id="PAYMENT_SECURITY_TOKEN" name="PAYMENT_SECURITY_TOKEN" value="'.$conf->global->PAYMENT_SECURITY_TOKEN.'">'; |
270 | -if (! empty($conf->use_javascript_ajax)) |
|
301 | +if (! empty($conf->use_javascript_ajax)) { |
|
271 | 302 | print ' '.img_picto($langs->trans('Generate'), 'refresh', 'id="generate_token" class="linkobject"'); |
303 | +} |
|
272 | 304 | print '</td></tr>'; |
273 | 305 | |
274 | 306 | print '<tr class="oddeven"><td>'; |
@@ -288,8 +320,9 @@ discard block |
||
288 | 320 | |
289 | 321 | // Help doc |
290 | 322 | print '<u>'.$langs->trans("InformationToFindParameters","Paypal").'</u>:<br>'; |
291 | -if (! empty($conf->use_javascript_ajax)) |
|
323 | +if (! empty($conf->use_javascript_ajax)) { |
|
292 | 324 | print '<a href="#" class="reposition" id="apidoca">'.$langs->trans("ClickHere").'...</a>'; |
325 | +} |
|
293 | 326 | |
294 | 327 | $realpaypalurl='www.paypal.com'; |
295 | 328 | $sandboxpaypalurl='developer.paypal.com'; |
@@ -28,7 +28,9 @@ discard block |
||
28 | 28 | $langs->loadLangs(array("admin", "ftp")); |
29 | 29 | |
30 | 30 | // Security check |
31 | -if (!$user->admin) accessforbidden(); |
|
31 | +if (!$user->admin) { |
|
32 | + accessforbidden(); |
|
33 | +} |
|
32 | 34 | |
33 | 35 | $def = array(); |
34 | 36 | $lastftpentry=0; |
@@ -49,9 +51,10 @@ discard block |
||
49 | 51 | { |
50 | 52 | $obj = $db->fetch_object($result); |
51 | 53 | preg_match('/([0-9]+)$/i',$obj->name,$reg); |
52 | - if ($reg[1]) $lastftpentry = $reg[1]; |
|
53 | -} |
|
54 | -else |
|
54 | + if ($reg[1]) { |
|
55 | + $lastftpentry = $reg[1]; |
|
56 | + } |
|
57 | + } else |
|
55 | 58 | { |
56 | 59 | dol_print_error($db); |
57 | 60 | } |
@@ -85,19 +88,28 @@ discard block |
||
85 | 88 | $db->begin(); |
86 | 89 | |
87 | 90 | $result1=dolibarr_set_const($db, "FTP_PORT_" . $entry,GETPOST($ftp_port,'alpha'),'chaine',0,'',$conf->entity); |
88 | - if ($result1) $result2=dolibarr_set_const($db, "FTP_SERVER_" . $entry, GETPOST($ftp_server,'alpha'),'chaine',0,'',$conf->entity); |
|
89 | - if ($result2) $result3=dolibarr_set_const($db, "FTP_USER_" . $entry,GETPOST($ftp_user,'alpha'),'chaine',0,'',$conf->entity); |
|
90 | - if ($result3) $result4=dolibarr_set_const($db, "FTP_PASSWORD_" . $entry,GETPOST($ftp_password,'alpha'),'chaine',0,'',$conf->entity); |
|
91 | - if ($result4) $result5=dolibarr_set_const($db, "FTP_NAME_" . $entry,GETPOST($ftp_name,'alpha'),'chaine',0,'',$conf->entity); |
|
92 | - if ($result5) $result6=dolibarr_set_const($db, "FTP_PASSIVE_" . $entry,GETPOST($ftp_passive,'alpha'),'chaine',0,'',$conf->entity); |
|
91 | + if ($result1) { |
|
92 | + $result2=dolibarr_set_const($db, "FTP_SERVER_" . $entry, GETPOST($ftp_server,'alpha'),'chaine',0,'',$conf->entity); |
|
93 | + } |
|
94 | + if ($result2) { |
|
95 | + $result3=dolibarr_set_const($db, "FTP_USER_" . $entry,GETPOST($ftp_user,'alpha'),'chaine',0,'',$conf->entity); |
|
96 | + } |
|
97 | + if ($result3) { |
|
98 | + $result4=dolibarr_set_const($db, "FTP_PASSWORD_" . $entry,GETPOST($ftp_password,'alpha'),'chaine',0,'',$conf->entity); |
|
99 | + } |
|
100 | + if ($result4) { |
|
101 | + $result5=dolibarr_set_const($db, "FTP_NAME_" . $entry,GETPOST($ftp_name,'alpha'),'chaine',0,'',$conf->entity); |
|
102 | + } |
|
103 | + if ($result5) { |
|
104 | + $result6=dolibarr_set_const($db, "FTP_PASSIVE_" . $entry,GETPOST($ftp_passive,'alpha'),'chaine',0,'',$conf->entity); |
|
105 | + } |
|
93 | 106 | |
94 | 107 | if ($result1 && $result2 && $result3 && $result4 && $result5 && $result6) |
95 | 108 | { |
96 | 109 | $db->commit(); |
97 | 110 | header("Location: ".$_SERVER["PHP_SELF"]); |
98 | 111 | exit; |
99 | - } |
|
100 | - else |
|
112 | + } else |
|
101 | 113 | { |
102 | 114 | $db->rollback(); |
103 | 115 | dol_print_error($db); |
@@ -112,19 +124,28 @@ discard block |
||
112 | 124 | $db->begin(); |
113 | 125 | |
114 | 126 | $result1=dolibarr_del_const($db,"FTP_PORT_" . $entry,$conf->entity); |
115 | - if ($result1) $result2=dolibarr_del_const($db,"FTP_SERVER_" . $entry,$conf->entity); |
|
116 | - if ($result2) $result3=dolibarr_del_const($db,"FTP_USER_" . $entry,$conf->entity); |
|
117 | - if ($result3) $result4=dolibarr_del_const($db,"FTP_PASSWORD_" . $entry,$conf->entity); |
|
118 | - if ($result4) $result5=dolibarr_del_const($db,"FTP_NAME_" . $entry,$conf->entity); |
|
119 | - if ($result4) $result6=dolibarr_del_const($db,"FTP_PASSIVE_" . $entry,$conf->entity); |
|
127 | + if ($result1) { |
|
128 | + $result2=dolibarr_del_const($db,"FTP_SERVER_" . $entry,$conf->entity); |
|
129 | + } |
|
130 | + if ($result2) { |
|
131 | + $result3=dolibarr_del_const($db,"FTP_USER_" . $entry,$conf->entity); |
|
132 | + } |
|
133 | + if ($result3) { |
|
134 | + $result4=dolibarr_del_const($db,"FTP_PASSWORD_" . $entry,$conf->entity); |
|
135 | + } |
|
136 | + if ($result4) { |
|
137 | + $result5=dolibarr_del_const($db,"FTP_NAME_" . $entry,$conf->entity); |
|
138 | + } |
|
139 | + if ($result4) { |
|
140 | + $result6=dolibarr_del_const($db,"FTP_PASSIVE_" . $entry,$conf->entity); |
|
141 | + } |
|
120 | 142 | |
121 | 143 | if ($result1 && $result2 && $result3 && $result4 && $result5 && $result6) |
122 | 144 | { |
123 | 145 | $db->commit(); |
124 | 146 | header("Location: ".$_SERVER["PHP_SELF"]); |
125 | 147 | exit; |
126 | - } |
|
127 | - else |
|
148 | + } else |
|
128 | 149 | { |
129 | 150 | $db->rollback(); |
130 | 151 | dol_print_error($db); |
@@ -148,8 +169,7 @@ discard block |
||
148 | 169 | if (! function_exists('ftp_connect')) |
149 | 170 | { |
150 | 171 | print $langs->trans("FTPFeatureNotSupportedByYourPHP"); |
151 | -} |
|
152 | -else |
|
172 | +} else |
|
153 | 173 | { |
154 | 174 | |
155 | 175 | // Formulaire ajout |
@@ -195,7 +215,9 @@ discard block |
||
195 | 215 | print '<tr class="impair">'; |
196 | 216 | print '<td>'.$langs->trans("FTPPassiveMode").'</td>'; |
197 | 217 | $defaultpassive=GETPOST("FTP_PASSIVE_" . ($lastftpentry+1)); |
198 | - if (! isset($_POST["FTP_PASSIVE_" . ($lastftpentry+1)])) $defaultpassive=empty($conf->global->FTP_SUGGEST_PASSIVE_BYDEFAULT)?0:1; |
|
218 | + if (! isset($_POST["FTP_PASSIVE_" . ($lastftpentry+1)])) { |
|
219 | + $defaultpassive=empty($conf->global->FTP_SUGGEST_PASSIVE_BYDEFAULT)?0:1; |
|
220 | + } |
|
199 | 221 | print '<td>'.$form->selectyesno('FTP_PASSIVE_'.($lastftpentry+1), $defaultpassive, 2).'</td>'; |
200 | 222 | print '<td>'.$langs->trans("No").'</td>'; |
201 | 223 | print '</tr>'; |
@@ -301,8 +323,7 @@ discard block |
||
301 | 323 | |
302 | 324 | $i++; |
303 | 325 | } |
304 | - } |
|
305 | - else |
|
326 | + } else |
|
306 | 327 | { |
307 | 328 | dol_print_error($db); |
308 | 329 | } |