@@ -182,12 +182,12 @@ discard block |
||
182 | 182 | if (!empty($user->email)) { |
183 | 183 | $sendto = dolGetFirstLastname($user->firstname, $user->lastname)." <".$user->email.">"; |
184 | 184 | } else { |
185 | - $sendto = getDolGlobalString('MAIN_INFO_SOCIETE_MAIL') . '" <' . getDolGlobalString('MAIN_INFO_SOCIETE_MAIL').'>'; |
|
185 | + $sendto = getDolGlobalString('MAIN_INFO_SOCIETE_MAIL').'" <'.getDolGlobalString('MAIN_INFO_SOCIETE_MAIL').'>'; |
|
186 | 186 | } |
187 | 187 | $replyto = $sendto; |
188 | 188 | $sendtocc = ''; |
189 | 189 | if (getDolGlobalString('ONLINE_PAYMENT_SENDEMAIL')) { |
190 | - $sendtocc = getDolGlobalString('ONLINE_PAYMENT_SENDEMAIL') . '" <' . getDolGlobalString('ONLINE_PAYMENT_SENDEMAIL').'>'; |
|
190 | + $sendtocc = getDolGlobalString('ONLINE_PAYMENT_SENDEMAIL').'" <'.getDolGlobalString('ONLINE_PAYMENT_SENDEMAIL').'>'; |
|
191 | 191 | } |
192 | 192 | |
193 | 193 | $message = "A bank transfer of ".price2num($event->data->object->amount / 100)." ".$event->data->object->currency." should arrive in your account the ".dol_print_date($event->data->object->arrival_date, 'dayhour'); |
@@ -272,12 +272,12 @@ discard block |
||
272 | 272 | if (!empty($user->email)) { |
273 | 273 | $sendto = dolGetFirstLastname($user->firstname, $user->lastname)." <".$user->email.">"; |
274 | 274 | } else { |
275 | - $sendto = getDolGlobalString('MAIN_INFO_SOCIETE_MAIL') . '" <' . getDolGlobalString('MAIN_INFO_SOCIETE_MAIL').'>'; |
|
275 | + $sendto = getDolGlobalString('MAIN_INFO_SOCIETE_MAIL').'" <'.getDolGlobalString('MAIN_INFO_SOCIETE_MAIL').'>'; |
|
276 | 276 | } |
277 | 277 | $replyto = $sendto; |
278 | 278 | $sendtocc = ''; |
279 | 279 | if (getDolGlobalString('ONLINE_PAYMENT_SENDEMAIL')) { |
280 | - $sendtocc = getDolGlobalString('ONLINE_PAYMENT_SENDEMAIL') . '" <' . getDolGlobalString('ONLINE_PAYMENT_SENDEMAIL').'>'; |
|
280 | + $sendtocc = getDolGlobalString('ONLINE_PAYMENT_SENDEMAIL').'" <'.getDolGlobalString('ONLINE_PAYMENT_SENDEMAIL').'>'; |
|
281 | 281 | } |
282 | 282 | |
283 | 283 | $message = "A bank transfer of ".price2num($event->data->object->amount / 100)." ".$event->data->object->currency." has been done to your account the ".dol_print_date($event->data->object->arrival_date, 'dayhour'); |
@@ -317,19 +317,19 @@ discard block |
||
317 | 317 | $db->commit(); |
318 | 318 | } elseif ($event->type == 'payment_intent.succeeded') { // Called when making payment with PaymentIntent method ($conf->global->STRIPE_USE_NEW_CHECKOUT is on). |
319 | 319 | //dol_syslog("object = ".var_export($event->data, true)); |
320 | - include_once DOL_DOCUMENT_ROOT . '/compta/paiement/class/paiement.class.php'; |
|
320 | + include_once DOL_DOCUMENT_ROOT.'/compta/paiement/class/paiement.class.php'; |
|
321 | 321 | global $stripearrayofkeysbyenv; |
322 | 322 | $error = 0; |
323 | 323 | $object = $event->data->object; |
324 | - $TRANSACTIONID = $object->id; // Example pi_123456789... |
|
324 | + $TRANSACTIONID = $object->id; // Example pi_123456789... |
|
325 | 325 | $ipaddress = $object->metadata->ipaddress; |
326 | 326 | $now = dol_now(); |
327 | 327 | $currencyCodeType = strtoupper($object->currency); |
328 | 328 | $paymentmethodstripeid = $object->payment_method; |
329 | 329 | $customer_id = $object->customer; |
330 | 330 | $invoice_id = ""; |
331 | - $paymentTypeId = ""; // payment type according to Stripe |
|
332 | - $paymentTypeIdInDolibarr = ""; // payment type according to Dolibarr |
|
331 | + $paymentTypeId = ""; // payment type according to Stripe |
|
332 | + $paymentTypeIdInDolibarr = ""; // payment type according to Dolibarr |
|
333 | 333 | $payment_amount = 0; |
334 | 334 | $payment_amountInDolibarr = 0; |
335 | 335 | |
@@ -394,7 +394,7 @@ discard block |
||
394 | 394 | $s = new \Stripe\StripeClient($stripeacc); |
395 | 395 | |
396 | 396 | $paymentmethodstripe = $s->paymentMethods->retrieve($paymentmethodstripeid); |
397 | - $paymentTypeId = $paymentmethodstripe->type; |
|
397 | + $paymentTypeId = $paymentmethodstripe->type; |
|
398 | 398 | if ($paymentTypeId == "ban" || $paymentTypeId == "sepa_debit") { |
399 | 399 | $paymentTypeId = "PRE"; |
400 | 400 | } elseif ($paymentTypeId == "card") { |
@@ -418,9 +418,9 @@ discard block |
||
418 | 418 | $paiement->datepaye = $now; |
419 | 419 | $paiement->date = $now; |
420 | 420 | if ($currencyCodeType == $conf->currency) { |
421 | - $paiement->amounts = [$invoice_id => $payment_amount]; // Array with all payments dispatching with invoice id |
|
421 | + $paiement->amounts = [$invoice_id => $payment_amount]; // Array with all payments dispatching with invoice id |
|
422 | 422 | } else { |
423 | - $paiement->multicurrency_amounts = [$invoice_id => $payment_amount]; // Array with all payments dispatching |
|
423 | + $paiement->multicurrency_amounts = [$invoice_id => $payment_amount]; // Array with all payments dispatching |
|
424 | 424 | |
425 | 425 | $postactionmessages[] = 'Payment was done in a different currency than currency expected of company'; |
426 | 426 | $ispostactionok = -1; |
@@ -430,8 +430,8 @@ discard block |
||
430 | 430 | $paiement->paiementid = $paymentTypeId; |
431 | 431 | $paiement->num_payment = ''; |
432 | 432 | $paiement->note_public = ''; |
433 | - $paiement->note_private = 'StripeSepa payment ' . dol_print_date($now, 'standard') . ' using ' . $servicestatus . ($ipaddress ? ' from ip ' . $ipaddress : '') . ' - Transaction ID = ' . $TRANSACTIONID; |
|
434 | - $paiement->ext_payment_id = $TRANSACTIONID.':'.$customer_id.'@'.$stripearrayofkeysbyenv[$servicestatus]['publishable_key']; // May be we should store py_... instead of pi_... but we started with pi_... so we continue. |
|
433 | + $paiement->note_private = 'StripeSepa payment '.dol_print_date($now, 'standard').' using '.$servicestatus.($ipaddress ? ' from ip '.$ipaddress : '').' - Transaction ID = '.$TRANSACTIONID; |
|
434 | + $paiement->ext_payment_id = $TRANSACTIONID.':'.$customer_id.'@'.$stripearrayofkeysbyenv[$servicestatus]['publishable_key']; // May be we should store py_... instead of pi_... but we started with pi_... so we continue. |
|
435 | 435 | $paiement->ext_payment_site = $service; |
436 | 436 | |
437 | 437 | $ispaymentdone = 0; |
@@ -449,20 +449,20 @@ discard block |
||
449 | 449 | $db->begin(); |
450 | 450 | |
451 | 451 | if (!$error && !$ispaymentdone) { |
452 | - dol_syslog('* Record payment for invoice id ' . $invoice_id . '. It includes closing of invoice and regenerating document'); |
|
452 | + dol_syslog('* Record payment for invoice id '.$invoice_id.'. It includes closing of invoice and regenerating document'); |
|
453 | 453 | |
454 | 454 | // This include closing invoices to 'paid' (and trigger including unsuspending) and regenerating document |
455 | 455 | $paiement_id = $paiement->create($user, 1); |
456 | 456 | if ($paiement_id < 0) { |
457 | - $postactionmessages[] = $paiement->error . ($paiement->error ? ' ' : '') . join("<br>\n", $paiement->errors); |
|
457 | + $postactionmessages[] = $paiement->error.($paiement->error ? ' ' : '').join("<br>\n", $paiement->errors); |
|
458 | 458 | $ispostactionok = -1; |
459 | 459 | $error++; |
460 | 460 | |
461 | - dol_syslog("Failed to create the payment for invoice id " . $invoice_id); |
|
461 | + dol_syslog("Failed to create the payment for invoice id ".$invoice_id); |
|
462 | 462 | } else { |
463 | 463 | $postactionmessages[] = 'Payment created'; |
464 | 464 | |
465 | - dol_syslog("The payment has been created for invoice id " . $invoice_id); |
|
465 | + dol_syslog("The payment has been created for invoice id ".$invoice_id); |
|
466 | 466 | } |
467 | 467 | } |
468 | 468 | |
@@ -492,14 +492,14 @@ discard block |
||
492 | 492 | $label = '(CustomerInvoicePayment)'; |
493 | 493 | $result = $paiement->addPaymentToBank($user, 'payment', $label, $bankaccountid, $customer_id, ''); |
494 | 494 | if ($result < 0) { |
495 | - $postactionmessages[] = $paiement->error . ($paiement->error ? ' ' : '') . join("<br>\n", $paiement->errors); |
|
495 | + $postactionmessages[] = $paiement->error.($paiement->error ? ' ' : '').join("<br>\n", $paiement->errors); |
|
496 | 496 | $ispostactionok = -1; |
497 | 497 | $error++; |
498 | 498 | } else { |
499 | 499 | $postactionmessages[] = 'Bank transaction of payment created (by ipn.php file)'; |
500 | 500 | } |
501 | 501 | } else { |
502 | - $postactionmessages[] = 'Setup of bank account to use in module ' . $paymentmethod . ' was not set. No way to record the payment.'; |
|
502 | + $postactionmessages[] = 'Setup of bank account to use in module '.$paymentmethod.' was not set. No way to record the payment.'; |
|
503 | 503 | $ispostactionok = -1; |
504 | 504 | $error++; |
505 | 505 | } |
@@ -663,7 +663,7 @@ discard block |
||
663 | 663 | $error++; |
664 | 664 | } |
665 | 665 | |
666 | - if (! $error) { |
|
666 | + if (!$error) { |
|
667 | 667 | $db->commit(); |
668 | 668 | } else { |
669 | 669 | $db->rollback(); |
@@ -98,8 +98,8 @@ discard block |
||
98 | 98 | |
99 | 99 | const STATUS_DRAFT = 0; |
100 | 100 | const STATUS_TRANSFERED = 1; |
101 | - const STATUS_CREDITED = 2; // STATUS_CREDITED and STATUS_DEBITED is same. Difference is in ->type |
|
102 | - const STATUS_DEBITED = 2; // STATUS_CREDITED and STATUS_DEBITED is same. Difference is in ->type |
|
101 | + const STATUS_CREDITED = 2; // STATUS_CREDITED and STATUS_DEBITED is same. Difference is in ->type |
|
102 | + const STATUS_DEBITED = 2; // STATUS_CREDITED and STATUS_DEBITED is same. Difference is in ->type |
|
103 | 103 | |
104 | 104 | |
105 | 105 | /** |
@@ -145,7 +145,7 @@ discard block |
||
145 | 145 | /** |
146 | 146 | * @var array Array with all fields and their property. Do not use it as a static var. It may be modified by constructor. |
147 | 147 | */ |
148 | - public $fields=array( |
|
148 | + public $fields = array( |
|
149 | 149 | 'rowid' => array('type'=>'integer', 'label'=>'TechnicalID', 'enabled'=>'1', 'position'=>10, 'notnull'=>1, 'visible'=>0,), |
150 | 150 | 'ref' => array('type'=>'varchar(12)', 'label'=>'Ref', 'enabled'=>'1', 'position'=>15, 'notnull'=>0, 'visible'=>-1, 'csslist'=>'tdoverflowmax150', 'showoncombobox'=>'1',), |
151 | 151 | 'datec' => array('type'=>'datetime', 'label'=>'DateCreation', 'enabled'=>'1', 'position'=>25, 'notnull'=>0, 'visible'=>-1,), |
@@ -339,7 +339,7 @@ discard block |
||
339 | 339 | $sql .= ", '".$this->db->escape($code_guichet)."'"; |
340 | 340 | $sql .= ", '".$this->db->escape($number)."'"; |
341 | 341 | $sql .= ", '".$this->db->escape($number_key)."'"; |
342 | - $sql .= (!empty($sourcetype) ? ", ". ((int) $client_id) : ''); |
|
342 | + $sql .= (!empty($sourcetype) ? ", ".((int) $client_id) : ''); |
|
343 | 343 | $sql .= ")"; |
344 | 344 | if ($this->db->query($sql)) { |
345 | 345 | $line_id = $this->db->last_insert_id(MAIN_DB_PREFIX."prelevement_lignes"); |
@@ -563,7 +563,7 @@ discard block |
||
563 | 563 | } else { |
564 | 564 | $modeforaddpayment = 'payment'; |
565 | 565 | $labelforaddpayment = '(CustomerInvoicePayment)'; |
566 | - $addbankurl = 'direct-debit'; // = 'directdebit' |
|
566 | + $addbankurl = 'direct-debit'; // = 'directdebit' |
|
567 | 567 | } |
568 | 568 | |
569 | 569 | $result = $paiement->addPaymentToBank($user, $modeforaddpayment, $labelforaddpayment, $fk_bank_account, '', '', 0, '', $addbankurl); |
@@ -973,7 +973,7 @@ discard block |
||
973 | 973 | $sql .= " FROM ".MAIN_DB_PREFIX."salary as f"; |
974 | 974 | $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."prelevement_demande as pd ON f.rowid = pd.fk_salary"; |
975 | 975 | $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."user as s ON s.rowid = f.fk_user"; |
976 | - $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."user_rib as sr ON s.rowid = sr.fk_user"; // TODO Add AND sr.default_rib = 1 here |
|
976 | + $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."user_rib as sr ON s.rowid = sr.fk_user"; // TODO Add AND sr.default_rib = 1 here |
|
977 | 977 | } |
978 | 978 | if ($sourcetype != 'salary') { |
979 | 979 | if ($type != 'bank-transfer') { |
@@ -996,7 +996,7 @@ discard block |
||
996 | 996 | $sql .= " AND pd.traite = 0"; |
997 | 997 | $sql .= " AND pd.ext_payment_id IS NULL"; |
998 | 998 | if ($sourcetype != 'salary') { |
999 | - $sql .= " AND sr.type = 'ban'"; // TODO Add AND sr.type = 'ban' for users too |
|
999 | + $sql .= " AND sr.type = 'ban'"; // TODO Add AND sr.type = 'ban' for users too |
|
1000 | 1000 | } |
1001 | 1001 | if ($did > 0) { |
1002 | 1002 | $sql .= " AND pd.rowid = ".((int) $did); |
@@ -1008,7 +1008,7 @@ discard block |
||
1008 | 1008 | $i = 0; |
1009 | 1009 | |
1010 | 1010 | while ($i < $num) { |
1011 | - $row = $this->db->fetch_row($resql); // TODO Replace with fetch_object() |
|
1011 | + $row = $this->db->fetch_row($resql); // TODO Replace with fetch_object() |
|
1012 | 1012 | $factures[$i] = $row; // All fields |
1013 | 1013 | |
1014 | 1014 | if ($row[7] == 0) { |
@@ -1086,30 +1086,30 @@ discard block |
||
1086 | 1086 | $tmpsoc->id = $fac[2]; |
1087 | 1087 | $tmpsoc->name = $fac[8]; |
1088 | 1088 | $invoice_url = "<a href='".DOL_URL_ROOT.'/compta/facture/card.php?facid='.$fac[0]."'>".$fac[9]."</a>"; |
1089 | - $this->invoice_in_error[$fac[0]] = "Error on default bank number IBAN/BIC for invoice " . $invoice_url . " for thirdparty " . $tmpsoc->getNomUrl(0); |
|
1090 | - $this->thirdparty_in_error[$tmpsoc->id] = "Error on default bank number IBAN/BIC for invoice " . $invoice_url . " for thirdparty " . $tmpsoc->getNomUrl(0); |
|
1089 | + $this->invoice_in_error[$fac[0]] = "Error on default bank number IBAN/BIC for invoice ".$invoice_url." for thirdparty ".$tmpsoc->getNomUrl(0); |
|
1090 | + $this->thirdparty_in_error[$tmpsoc->id] = "Error on default bank number IBAN/BIC for invoice ".$invoice_url." for thirdparty ".$tmpsoc->getNomUrl(0); |
|
1091 | 1091 | $error++; |
1092 | 1092 | } |
1093 | 1093 | if ($type == 'bank-transfer' && $sourcetype != 'salary') { |
1094 | 1094 | $tmpsoc->id = $fac[2]; |
1095 | 1095 | $tmpsoc->name = $fac[8]; |
1096 | 1096 | $invoice_url = "<a href='".DOL_URL_ROOT.'/fourn/facture/card.php?facid='.$fac[0]."'>".$fac[9]."</a>"; |
1097 | - $this->invoice_in_error[$fac[0]] = "Error on default bank number IBAN/BIC for invoice " . $invoice_url . " for thirdparty " . $tmpsoc->getNomUrl(0); |
|
1098 | - $this->thirdparty_in_error[$tmpsoc->id] = "Error on default bank number IBAN/BIC for invoice " . $invoice_url . " for thirdparty " . $tmpsoc->getNomUrl(0); |
|
1097 | + $this->invoice_in_error[$fac[0]] = "Error on default bank number IBAN/BIC for invoice ".$invoice_url." for thirdparty ".$tmpsoc->getNomUrl(0); |
|
1098 | + $this->thirdparty_in_error[$tmpsoc->id] = "Error on default bank number IBAN/BIC for invoice ".$invoice_url." for thirdparty ".$tmpsoc->getNomUrl(0); |
|
1099 | 1099 | $error++; |
1100 | 1100 | } |
1101 | 1101 | if ($type == 'bank-transfer' && $sourcetype == 'salary') { |
1102 | 1102 | $tmpuser->id = $fac[2]; |
1103 | 1103 | $tmpuser->firstname = $fac[8]; |
1104 | 1104 | $salary_url = "<a href='".DOL_URL_ROOT.'/salaries/card.php?id='.$fac[0]."'>".$fac[0]."</a>"; |
1105 | - $this->invoice_in_error[$fac[0]] = "Error on default bank number IBAN/BIC for salary " . $salary_url . " for employee " . $tmpuser->getNomUrl(0); |
|
1106 | - $this->thirdparty_in_error[$tmpuser->id] = "Error on default bank number IBAN/BIC for salary " . $salary_url . " for employee " . $tmpuser->getNomUrl(0); |
|
1105 | + $this->invoice_in_error[$fac[0]] = "Error on default bank number IBAN/BIC for salary ".$salary_url." for employee ".$tmpuser->getNomUrl(0); |
|
1106 | + $this->thirdparty_in_error[$tmpuser->id] = "Error on default bank number IBAN/BIC for salary ".$salary_url." for employee ".$tmpuser->getNomUrl(0); |
|
1107 | 1107 | $error++; |
1108 | 1108 | } |
1109 | - dol_syslog(__METHOD__ . " Check BAN Error on default bank number IBAN/BIC reported by verif(): " . join(', ', $fac), LOG_WARNING); |
|
1109 | + dol_syslog(__METHOD__." Check BAN Error on default bank number IBAN/BIC reported by verif(): ".join(', ', $fac), LOG_WARNING); |
|
1110 | 1110 | } |
1111 | 1111 | } else { |
1112 | - dol_syslog(__METHOD__ . " Check BAN Failed to read company", LOG_WARNING); |
|
1112 | + dol_syslog(__METHOD__." Check BAN Failed to read company", LOG_WARNING); |
|
1113 | 1113 | } |
1114 | 1114 | /* |
1115 | 1115 | } else { |
@@ -1162,7 +1162,7 @@ discard block |
||
1162 | 1162 | $ref = substr($year, -2).$month; |
1163 | 1163 | |
1164 | 1164 | // Get next free nunber for the ref of bon prelevement |
1165 | - $sql = "SELECT substring(ref from char_length(ref) - 1)"; // To extract "YYMMXX" from "TYYMMXX" |
|
1165 | + $sql = "SELECT substring(ref from char_length(ref) - 1)"; // To extract "YYMMXX" from "TYYMMXX" |
|
1166 | 1166 | $sql .= " FROM ".MAIN_DB_PREFIX."prelevement_bons"; |
1167 | 1167 | $sql .= " WHERE ref LIKE '_".$this->db->escape($ref)."%'"; |
1168 | 1168 | $sql .= " AND entity = ".((int) $conf->entity); |
@@ -1356,7 +1356,7 @@ discard block |
||
1356 | 1356 | |
1357 | 1357 | if (!$error) { |
1358 | 1358 | $this->db->commit(); |
1359 | - return count($factures_prev); // The error of failed lines are into $this->invoice_in_error and $this->thirdparty_in_error |
|
1359 | + return count($factures_prev); // The error of failed lines are into $this->invoice_in_error and $this->thirdparty_in_error |
|
1360 | 1360 | } else { |
1361 | 1361 | $this->db->rollback(); |
1362 | 1362 | return -1; |
@@ -2170,7 +2170,7 @@ discard block |
||
2170 | 2170 | $XML_CREDITOR .= ' <EndToEndId>'.(($conf->global->PRELEVEMENT_END_TO_END != "") ? $conf->global->PRELEVEMENT_END_TO_END : ('CT-'.dol_trunc($row_idfac.'-'.$row_ref, 20, 'right', 'UTF-8', 1)).'-'.$Rowing).'</EndToEndId>'.$CrLf; // ISO20022 states that EndToEndId has a MaxLength of 35 characters |
2171 | 2171 | $XML_CREDITOR .= ' </PmtId>'.$CrLf; |
2172 | 2172 | if (!empty($this->sepa_xml_pti_in_ctti)) { |
2173 | - $XML_CREDITOR .= ' <PmtTpInf>' . $CrLf; |
|
2173 | + $XML_CREDITOR .= ' <PmtTpInf>'.$CrLf; |
|
2174 | 2174 | |
2175 | 2175 | // Can be 'NORM' for normal or 'HIGH' for high priority level |
2176 | 2176 | if (getDolGlobalString('PAYMENTBYBANKTRANSFER_FORCE_HIGH_PRIORITY')) { |
@@ -2178,14 +2178,14 @@ discard block |
||
2178 | 2178 | } else { |
2179 | 2179 | $instrprty = 'NORM'; |
2180 | 2180 | } |
2181 | - $XML_CREDITOR .= ' <InstrPrty>'.$instrprty.'</InstrPrty>' . $CrLf; |
|
2182 | - $XML_CREDITOR .= ' <SvcLvl>' . $CrLf; |
|
2183 | - $XML_CREDITOR .= ' <Cd>SEPA</Cd>' . $CrLf; |
|
2184 | - $XML_CREDITOR .= ' </SvcLvl>' . $CrLf; |
|
2185 | - $XML_CREDITOR .= ' <CtgyPurp>' . $CrLf; |
|
2186 | - $XML_CREDITOR .= ' <Cd>CORE</Cd>' . $CrLf; |
|
2187 | - $XML_CREDITOR .= ' </CtgyPurp>' . $CrLf; |
|
2188 | - $XML_CREDITOR .= ' </PmtTpInf>' . $CrLf; |
|
2181 | + $XML_CREDITOR .= ' <InstrPrty>'.$instrprty.'</InstrPrty>'.$CrLf; |
|
2182 | + $XML_CREDITOR .= ' <SvcLvl>'.$CrLf; |
|
2183 | + $XML_CREDITOR .= ' <Cd>SEPA</Cd>'.$CrLf; |
|
2184 | + $XML_CREDITOR .= ' </SvcLvl>'.$CrLf; |
|
2185 | + $XML_CREDITOR .= ' <CtgyPurp>'.$CrLf; |
|
2186 | + $XML_CREDITOR .= ' <Cd>CORE</Cd>'.$CrLf; |
|
2187 | + $XML_CREDITOR .= ' </CtgyPurp>'.$CrLf; |
|
2188 | + $XML_CREDITOR .= ' </PmtTpInf>'.$CrLf; |
|
2189 | 2189 | } |
2190 | 2190 | $XML_CREDITOR .= ' <Amt>'.$CrLf; |
2191 | 2191 | $XML_CREDITOR .= ' <InstdAmt Ccy="EUR">'.round($row_somme, 2).'</InstdAmt>'.$CrLf; |
@@ -2347,7 +2347,7 @@ discard block |
||
2347 | 2347 | $this->emetteur_iban = $account->iban; |
2348 | 2348 | $this->emetteur_bic = $account->bic; |
2349 | 2349 | |
2350 | - $this->emetteur_ics = ($type == 'bank-transfer' ? $account->ics_transfer : $account->ics); // Ex: PRELEVEMENT_ICS = "FR78ZZZ123456"; |
|
2350 | + $this->emetteur_ics = ($type == 'bank-transfer' ? $account->ics_transfer : $account->ics); // Ex: PRELEVEMENT_ICS = "FR78ZZZ123456"; |
|
2351 | 2351 | |
2352 | 2352 | $this->raison_sociale = $account->proprio; |
2353 | 2353 | } |
@@ -2438,15 +2438,15 @@ discard block |
||
2438 | 2438 | $XML_SEPA_INFO .= ' <NbOfTxs>'.$nombre.'</NbOfTxs>'.$CrLf; |
2439 | 2439 | $XML_SEPA_INFO .= ' <CtrlSum>'.$total.'</CtrlSum>'.$CrLf; |
2440 | 2440 | if (!empty($this->sepa_xml_pti_in_ctti) && !empty($format)) { // @TODO Using $format (FRST ou RCUR) in a section for a Credit Transfer looks strange. |
2441 | - $XML_SEPA_INFO .= ' <PmtTpInf>' . $CrLf; |
|
2442 | - $XML_SEPA_INFO .= ' <SvcLvl>' . $CrLf; |
|
2443 | - $XML_SEPA_INFO .= ' <Cd>SEPA</Cd>' . $CrLf; |
|
2444 | - $XML_SEPA_INFO .= ' </SvcLvl>' . $CrLf; |
|
2445 | - $XML_SEPA_INFO .= ' <LclInstrm>' . $CrLf; |
|
2446 | - $XML_SEPA_INFO .= ' <Cd>CORE</Cd>' . $CrLf; |
|
2447 | - $XML_SEPA_INFO .= ' </LclInstrm>' . $CrLf; |
|
2448 | - $XML_SEPA_INFO .= ' <SeqTp>' . $format . '</SeqTp>' . $CrLf; |
|
2449 | - $XML_SEPA_INFO .= ' </PmtTpInf>' . $CrLf; |
|
2441 | + $XML_SEPA_INFO .= ' <PmtTpInf>'.$CrLf; |
|
2442 | + $XML_SEPA_INFO .= ' <SvcLvl>'.$CrLf; |
|
2443 | + $XML_SEPA_INFO .= ' <Cd>SEPA</Cd>'.$CrLf; |
|
2444 | + $XML_SEPA_INFO .= ' </SvcLvl>'.$CrLf; |
|
2445 | + $XML_SEPA_INFO .= ' <LclInstrm>'.$CrLf; |
|
2446 | + $XML_SEPA_INFO .= ' <Cd>CORE</Cd>'.$CrLf; |
|
2447 | + $XML_SEPA_INFO .= ' </LclInstrm>'.$CrLf; |
|
2448 | + $XML_SEPA_INFO .= ' <SeqTp>'.$format.'</SeqTp>'.$CrLf; |
|
2449 | + $XML_SEPA_INFO .= ' </PmtTpInf>'.$CrLf; |
|
2450 | 2450 | } |
2451 | 2451 | $XML_SEPA_INFO .= ' <ReqdExctnDt>'.dol_print_date($dateTime_ETAD, 'dayrfc').'</ReqdExctnDt>'.$CrLf; |
2452 | 2452 | $XML_SEPA_INFO .= ' <Dbtr>'.$CrLf; |
@@ -98,9 +98,9 @@ discard block |
||
98 | 98 | //print "before decoding $val\n"; |
99 | 99 | do { |
100 | 100 | $oldval = $val; |
101 | - $val = html_entity_decode($val, ENT_QUOTES | ENT_HTML5); // Decode ':', ''', '	', '&NewLine', ... |
|
101 | + $val = html_entity_decode($val, ENT_QUOTES | ENT_HTML5); // Decode ':', ''', '	', '&NewLine', ... |
|
102 | 102 | // Sometimes we have entities without the ; at end so html_entity_decode does not work but entities is still interpreted by browser. |
103 | - $val = preg_replace_callback('/&#(x?[0-9][0-9a-f]+;?)/i', function ($m) { |
|
103 | + $val = preg_replace_callback('/&#(x?[0-9][0-9a-f]+;?)/i', function($m) { |
|
104 | 104 | // Decode 'n', ... |
105 | 105 | return realCharForNumericEntities($m); }, $val); |
106 | 106 | |
@@ -138,7 +138,7 @@ discard block |
||
138 | 138 | $inj += preg_match('/user\s*\(/i', $val); // avoid to use function user() or mysql_user() that return current database login |
139 | 139 | $inj += preg_match('/information_schema/i', $val); // avoid to use request that read information_schema database |
140 | 140 | $inj += preg_match('/<svg/i', $val); // <svg can be allowed in POST |
141 | - $inj += preg_match('/update[^&=\w].*set.+=/i', $val); // the [^&=\w] test is to avoid error when request is like action=update&...set... or &updatemodule=...set... |
|
141 | + $inj += preg_match('/update[^&=\w].*set.+=/i', $val); // the [^&=\w] test is to avoid error when request is like action=update&...set... or &updatemodule=...set... |
|
142 | 142 | $inj += preg_match('/union.+select/i', $val); |
143 | 143 | } |
144 | 144 | if ($type == 3) { |
@@ -349,7 +349,7 @@ discard block |
||
349 | 349 | session_set_cookie_params($sessioncookieparams); |
350 | 350 | } |
351 | 351 | session_name($sessionname); |
352 | - session_start(); // This call the open and read of session handler |
|
352 | + session_start(); // This call the open and read of session handler |
|
353 | 353 | //exit; // this exist generates a call to write and close |
354 | 354 | } |
355 | 355 | |
@@ -377,11 +377,11 @@ discard block |
||
377 | 377 | if (!$ok) { |
378 | 378 | if (session_id() && isset($_SESSION["dol_login"]) && $_SESSION["dol_login"] != $conf->global->MAIN_ONLY_LOGIN_ALLOWED) { |
379 | 379 | print 'Sorry, your application is offline.'."\n"; |
380 | - print 'You are logged with user "'.$_SESSION["dol_login"].'" and only administrator user "' . getDolGlobalString('MAIN_ONLY_LOGIN_ALLOWED').'" is allowed to connect for the moment.'."\n"; |
|
380 | + print 'You are logged with user "'.$_SESSION["dol_login"].'" and only administrator user "'.getDolGlobalString('MAIN_ONLY_LOGIN_ALLOWED').'" is allowed to connect for the moment.'."\n"; |
|
381 | 381 | $nexturl = DOL_URL_ROOT.'/user/logout.php?token='.newToken(); |
382 | 382 | print 'Please try later or <a href="'.$nexturl.'">click here to disconnect and change login user</a>...'."\n"; |
383 | 383 | } else { |
384 | - print 'Sorry, your application is offline. Only administrator user "' . getDolGlobalString('MAIN_ONLY_LOGIN_ALLOWED').'" is allowed to connect for the moment.'."\n"; |
|
384 | + print 'Sorry, your application is offline. Only administrator user "'.getDolGlobalString('MAIN_ONLY_LOGIN_ALLOWED').'" is allowed to connect for the moment.'."\n"; |
|
385 | 385 | $nexturl = DOL_URL_ROOT.'/'; |
386 | 386 | print 'Please try later or <a href="'.$nexturl.'">click here to change login user</a>...'."\n"; |
387 | 387 | } |
@@ -583,7 +583,7 @@ discard block |
||
583 | 583 | print "Access to this page this way (POST method or GET with a sensible value for 'action' parameter) is refused by CSRF protection in main.inc.php. Token not provided.\n"; |
584 | 584 | print "If you access your server behind a proxy using url rewriting and the parameter is provided by caller, you might check that all HTTP header are propagated (or add the line \$dolibarr_nocsrfcheck=1 into your conf.php file or MAIN_SECURITY_CSRF_WITH_TOKEN to 0"; |
585 | 585 | if (getDolGlobalString('MAIN_SECURITY_CSRF_WITH_TOKEN')) { |
586 | - print " instead of " . getDolGlobalString('MAIN_SECURITY_CSRF_WITH_TOKEN'); |
|
586 | + print " instead of ".getDolGlobalString('MAIN_SECURITY_CSRF_WITH_TOKEN'); |
|
587 | 587 | } |
588 | 588 | print " into setup).\n"; |
589 | 589 | } |
@@ -595,7 +595,7 @@ discard block |
||
595 | 595 | $sessiontokenforthisurl = (empty($_SESSION['token']) ? '' : $_SESSION['token']); |
596 | 596 | // TODO Get the sessiontokenforthisurl into an array of session token (one array per base URL so we can use the CSRF per page and we keep ability for several tabs per url in a browser) |
597 | 597 | if (GETPOSTISSET('token') && GETPOST('token') != 'notrequired' && GETPOST('token', 'alpha') != $sessiontokenforthisurl) { |
598 | - dol_syslog("--- Access to ".(empty($_SERVER["REQUEST_METHOD"]) ? '' : $_SERVER["REQUEST_METHOD"].' ').$_SERVER["PHP_SELF"]." refused by CSRF protection (invalid token), so we disable POST and some GET parameters - referer=".(empty($_SERVER['HTTP_REFERER'])?'':$_SERVER['HTTP_REFERER']).", action=".GETPOST('action', 'aZ09').", _GET|POST['token']=".GETPOST('token', 'alpha'), LOG_WARNING); |
|
598 | + dol_syslog("--- Access to ".(empty($_SERVER["REQUEST_METHOD"]) ? '' : $_SERVER["REQUEST_METHOD"].' ').$_SERVER["PHP_SELF"]." refused by CSRF protection (invalid token), so we disable POST and some GET parameters - referer=".(empty($_SERVER['HTTP_REFERER']) ? '' : $_SERVER['HTTP_REFERER']).", action=".GETPOST('action', 'aZ09').", _GET|POST['token']=".GETPOST('token', 'alpha'), LOG_WARNING); |
|
599 | 599 | //dol_syslog("_SESSION['token']=".$sessiontokenforthisurl, LOG_DEBUG); |
600 | 600 | // Do not output anything on standard output because this create problems when using the BACK button on browsers. So we just set a message into session. |
601 | 601 | if (!defined('NOTOKENRENEWAL')) { |
@@ -611,7 +611,7 @@ discard block |
||
611 | 611 | unset($_GET['action']); |
612 | 612 | unset($_GET['confirmmassaction']); |
613 | 613 | unset($_GET['massaction']); |
614 | - unset($_GET['token']); // TODO Make a redirect if we have a token in url to remove it ? |
|
614 | + unset($_GET['token']); // TODO Make a redirect if we have a token in url to remove it ? |
|
615 | 615 | if (isset($savid)) { |
616 | 616 | $_POST['id'] = ((int) $savid); |
617 | 617 | } |
@@ -778,7 +778,7 @@ discard block |
||
778 | 778 | |
779 | 779 | $allowedmethodtopostusername = 3; |
780 | 780 | if (defined('MAIN_AUTHENTICATION_POST_METHOD')) { |
781 | - $allowedmethodtopostusername = constant('MAIN_AUTHENTICATION_POST_METHOD'); // Note a value of 2 is not compatible with some authentication methods that put username as GET parameter |
|
781 | + $allowedmethodtopostusername = constant('MAIN_AUTHENTICATION_POST_METHOD'); // Note a value of 2 is not compatible with some authentication methods that put username as GET parameter |
|
782 | 782 | } |
783 | 783 | // TODO Remove use of $_COOKIE['login_dolibarr'] ? Replace $usertotest = with $usertotest = GETPOST("username", "alpha", $allowedmethodtopostusername); |
784 | 784 | $usertotest = (!empty($_COOKIE['login_dolibarr']) ? preg_replace('/[^a-zA-Z0-9_@\-\.]/', '', $_COOKIE['login_dolibarr']) : GETPOST("username", "alpha", $allowedmethodtopostusername)); |
@@ -901,7 +901,7 @@ discard block |
||
901 | 901 | if (!empty($_SERVER["HTTP_USER_AGENT"]) && $_SERVER["HTTP_USER_AGENT"] == 'securitytest') { |
902 | 902 | http_response_code(401); // It makes easier to understand if session was broken during security tests |
903 | 903 | } |
904 | - dol_loginfunction($langs, $conf, (!empty($mysoc) ? $mysoc : '')); // This include http headers |
|
904 | + dol_loginfunction($langs, $conf, (!empty($mysoc) ? $mysoc : '')); // This include http headers |
|
905 | 905 | } |
906 | 906 | exit; |
907 | 907 | } |
@@ -1246,7 +1246,7 @@ discard block |
||
1246 | 1246 | } else { |
1247 | 1247 | // We may have NOLOGIN set, but NOREQUIREUSER not |
1248 | 1248 | if (!empty($user) && method_exists($user, 'loadDefaultValues') && !defined('NODEFAULTVALUES')) { |
1249 | - $user->loadDefaultValues(); // Load default values for everybody (works even if $user->id = 0 |
|
1249 | + $user->loadDefaultValues(); // Load default values for everybody (works even if $user->id = 0 |
|
1250 | 1250 | } |
1251 | 1251 | } |
1252 | 1252 | |
@@ -1426,7 +1426,7 @@ discard block |
||
1426 | 1426 | |
1427 | 1427 | if (!empty(GETPOST('seteventmessages', 'alpha'))) { |
1428 | 1428 | $message = GETPOST('seteventmessages', 'alpha'); |
1429 | - $messages = explode(',', $message); |
|
1429 | + $messages = explode(',', $message); |
|
1430 | 1430 | foreach ($messages as $key => $msg) { |
1431 | 1431 | $tmp = explode(':', $msg); |
1432 | 1432 | setEventMessages($tmp[0], null, !empty($tmp[1]) ? $tmp[1] : 'mesgs'); |
@@ -1721,7 +1721,7 @@ discard block |
||
1721 | 1721 | |
1722 | 1722 | if (getDolGlobalString('THEME_ELDY_TOPMENU_BACK1')) { |
1723 | 1723 | // TODO: use auto theme color switch |
1724 | - print '<meta name="theme-color" content="rgb(' . getDolGlobalString('THEME_ELDY_TOPMENU_BACK1').')">'."\n"; |
|
1724 | + print '<meta name="theme-color" content="rgb('.getDolGlobalString('THEME_ELDY_TOPMENU_BACK1').')">'."\n"; |
|
1725 | 1725 | } |
1726 | 1726 | |
1727 | 1727 | // Auto refresh page |
@@ -2038,7 +2038,7 @@ discard block |
||
2038 | 2038 | print $head."\n"; |
2039 | 2039 | } |
2040 | 2040 | if (getDolGlobalString('MAIN_HTML_HEADER')) { |
2041 | - print getDolGlobalString('MAIN_HTML_HEADER') . "\n"; |
|
2041 | + print getDolGlobalString('MAIN_HTML_HEADER')."\n"; |
|
2042 | 2042 | } |
2043 | 2043 | |
2044 | 2044 | $parameters = array(); |
@@ -2817,7 +2817,7 @@ discard block |
||
2817 | 2817 | $langs->load(explode('@', $item['name'])[1]); |
2818 | 2818 | $dropDownQuickAddHtml .= ' |
2819 | 2819 | <a class="dropdown-item quickadd-item" href="'.DOL_URL_ROOT.$item['url'].'" title="'.$langs->trans(explode('@', $item['title'])[0]).'"> |
2820 | - '. img_picto('', $item['picto'], 'style="width:18px;"') . ' ' . $langs->trans(explode('@', $item['name'])[0]) . '</a> |
|
2820 | + '. img_picto('', $item['picto'], 'style="width:18px;"').' '.$langs->trans(explode('@', $item['name'])[0]).'</a> |
|
2821 | 2821 | '; |
2822 | 2822 | } |
2823 | 2823 | |
@@ -3665,7 +3665,7 @@ discard block |
||
3665 | 3665 | $forceping = GETPOST('forceping', 'alpha'); |
3666 | 3666 | if (($_SERVER["PHP_SELF"] == DOL_URL_ROOT.'/index.php') || $forceping) { |
3667 | 3667 | //print '<!-- instance_unique_id='.$conf->file->instance_unique_id.' MAIN_FIRST_PING_OK_ID='.$conf->global->MAIN_FIRST_PING_OK_ID.' -->'; |
3668 | - $hash_unique_id = dol_hash('dolibarr'.$conf->file->instance_unique_id, 'sha256'); // Note: if the global salt changes, this hash changes too so ping may be counted twice. We don't mind. It is for statistics purpose only. |
|
3668 | + $hash_unique_id = dol_hash('dolibarr'.$conf->file->instance_unique_id, 'sha256'); // Note: if the global salt changes, this hash changes too so ping may be counted twice. We don't mind. It is for statistics purpose only. |
|
3669 | 3669 | |
3670 | 3670 | if (!getDolGlobalString('MAIN_FIRST_PING_OK_DATE') |
3671 | 3671 | || (!empty($conf->file->instance_unique_id) && ($hash_unique_id != $conf->global->MAIN_FIRST_PING_OK_ID) && ($conf->global->MAIN_FIRST_PING_OK_ID != 'disabled')) |
@@ -38,9 +38,9 @@ discard block |
||
38 | 38 | // Only works if you are not in safe_mode. / Ne fonctionne que si on est pas en safe_mode. |
39 | 39 | |
40 | 40 | $err = error_reporting(); |
41 | -error_reporting(0); // Disable all errors |
|
41 | +error_reporting(0); // Disable all errors |
|
42 | 42 | //error_reporting(E_ALL); |
43 | -@set_time_limit(1800); // Need 1800 on some very slow OS like Windows 7/64 |
|
43 | +@set_time_limit(1800); // Need 1800 on some very slow OS like Windows 7/64 |
|
44 | 44 | error_reporting($err); |
45 | 45 | |
46 | 46 | $action = GETPOST('action', 'aZ09') ? GETPOST('action', 'aZ09') : (empty($argv[1]) ? '' : $argv[1]); |
@@ -584,7 +584,7 @@ discard block |
||
584 | 584 | |
585 | 585 | $conf->file->instance_unique_id = (empty($dolibarr_main_instance_unique_id) ? (empty($dolibarr_main_cookie_cryptkey) ? '' : $dolibarr_main_cookie_cryptkey) : $dolibarr_main_instance_unique_id); // Unique id of instance |
586 | 586 | |
587 | -$hash_unique_id = dol_hash('dolibarr'.$conf->file->instance_unique_id, 'sha256'); // Note: if the global salt changes, this hash changes too so ping may be counted twice. We don't mind. It is for statistics purpose only. |
|
587 | +$hash_unique_id = dol_hash('dolibarr'.$conf->file->instance_unique_id, 'sha256'); // Note: if the global salt changes, this hash changes too so ping may be counted twice. We don't mind. It is for statistics purpose only. |
|
588 | 588 | |
589 | 589 | $out = '<input type="checkbox" name="dolibarrpingno" id="dolibarrpingno"'.((getDolGlobalString('MAIN_FIRST_PING_OK_ID') == 'disabled') ? '' : ' value="checked" checked="true"').'> '; |
590 | 590 | $out .= '<label for="dolibarrpingno">'.$langs->trans("MakeAnonymousPing").'</label>'; |
@@ -888,17 +888,17 @@ discard block |
||
888 | 888 | } |
889 | 889 | $labelextra = $langs->trans((string) $extrafields->attributes[$this->table_element]['label'][$key]); |
890 | 890 | if ($extrafields->attributes[$this->table_element]['type'][$key] == 'separate') { |
891 | - $datas[$key]= '<br><b><u>'. $labelextra . '</u></b>'; |
|
891 | + $datas[$key] = '<br><b><u>'.$labelextra.'</u></b>'; |
|
892 | 892 | } else { |
893 | - $value = (empty($this->array_options['options_' . $key]) ? '' : $this->array_options['options_' . $key]); |
|
894 | - $datas[$key]= '<br><b>'. $labelextra . ':</b> ' . $extrafields->showOutputField($key, $value, '', $this->table_element); |
|
893 | + $value = (empty($this->array_options['options_'.$key]) ? '' : $this->array_options['options_'.$key]); |
|
894 | + $datas[$key] = '<br><b>'.$labelextra.':</b> '.$extrafields->showOutputField($key, $value, '', $this->table_element); |
|
895 | 895 | $count++; |
896 | 896 | } |
897 | 897 | } |
898 | 898 | $datas['closedivextra'] = '</div>'; |
899 | 899 | } |
900 | 900 | |
901 | - $hookmanager->initHooks(array($this->element . 'dao')); |
|
901 | + $hookmanager->initHooks(array($this->element.'dao')); |
|
902 | 902 | $parameters = array( |
903 | 903 | 'tooltipcontentarray' => &$datas, |
904 | 904 | 'params' => $params, |
@@ -1389,7 +1389,7 @@ discard block |
||
1389 | 1389 | if ($source == 'external' || $source == 'thirdparty') { |
1390 | 1390 | $sql .= " AND tc.source = 'external'"; |
1391 | 1391 | if ($status >= 0) { |
1392 | - $sql .= " AND t.statut = ".((int) $status); // t is llx_socpeople |
|
1392 | + $sql .= " AND t.statut = ".((int) $status); // t is llx_socpeople |
|
1393 | 1393 | } |
1394 | 1394 | } |
1395 | 1395 | $sql .= " AND tc.active = 1"; |
@@ -1748,8 +1748,8 @@ discard block |
||
1748 | 1748 | if ($idtofetch) { |
1749 | 1749 | $thirdparty = new Societe($this->db); |
1750 | 1750 | $result = $thirdparty->fetch($idtofetch); |
1751 | - if ($result<0) { |
|
1752 | - $this->errors=array_merge($this->errors, $thirdparty->errors); |
|
1751 | + if ($result < 0) { |
|
1752 | + $this->errors = array_merge($this->errors, $thirdparty->errors); |
|
1753 | 1753 | } |
1754 | 1754 | $this->thirdparty = $thirdparty; |
1755 | 1755 | |
@@ -1779,7 +1779,7 @@ discard block |
||
1779 | 1779 | } |
1780 | 1780 | |
1781 | 1781 | $sql = "SELECT rowid FROM ".$this->db->prefix().$this->table_element; |
1782 | - $sql .= " WHERE ".$this->table_ref_field." LIKE '".$this->db->escape($ref)."'"; // no escapeforlike here |
|
1782 | + $sql .= " WHERE ".$this->table_ref_field." LIKE '".$this->db->escape($ref)."'"; // no escapeforlike here |
|
1783 | 1783 | $sql .= " LIMIT 1"; |
1784 | 1784 | |
1785 | 1785 | $query = $this->db->query($sql); |
@@ -2072,9 +2072,9 @@ discard block |
||
2072 | 2072 | if ($trigkey) { |
2073 | 2073 | $oldvalue = null; |
2074 | 2074 | |
2075 | - $sql = "SELECT " . $field; |
|
2076 | - $sql .= " FROM " . MAIN_DB_PREFIX . $table; |
|
2077 | - $sql .= " WHERE " . $id_field . " = " . ((int) $id); |
|
2075 | + $sql = "SELECT ".$field; |
|
2076 | + $sql .= " FROM ".MAIN_DB_PREFIX.$table; |
|
2077 | + $sql .= " WHERE ".$id_field." = ".((int) $id); |
|
2078 | 2078 | |
2079 | 2079 | $resql = $this->db->query($sql); |
2080 | 2080 | if ($resql) { |
@@ -2427,7 +2427,7 @@ discard block |
||
2427 | 2427 | // Triggers |
2428 | 2428 | if (!$error && !$notrigger) { |
2429 | 2429 | // Call triggers |
2430 | - $result = $this->call_trigger(strtoupper($this->element) . '_MODIFY', $user); |
|
2430 | + $result = $this->call_trigger(strtoupper($this->element).'_MODIFY', $user); |
|
2431 | 2431 | if ($result < 0) { |
2432 | 2432 | $error++; |
2433 | 2433 | } //Do also here what you must do to rollback action if trigger fail |
@@ -2793,7 +2793,7 @@ discard block |
||
2793 | 2793 | $sql = 'UPDATE '.$this->db->prefix().$this->table_element; |
2794 | 2794 | $sql .= " SET ".$fieldname." = ".(($id > 0 || $id == '0') ? ((int) $id) : 'NULL'); |
2795 | 2795 | if (in_array($this->table_element, array('propal', 'commande', 'societe'))) { |
2796 | - $sql .= " , deposit_percent = " . (empty($deposit_percent) ? 'NULL' : "'".$this->db->escape($deposit_percent)."'"); |
|
2796 | + $sql .= " , deposit_percent = ".(empty($deposit_percent) ? 'NULL' : "'".$this->db->escape($deposit_percent)."'"); |
|
2797 | 2797 | } |
2798 | 2798 | $sql .= ' WHERE rowid='.((int) $this->id); |
2799 | 2799 | |
@@ -3142,10 +3142,10 @@ discard block |
||
3142 | 3142 | $sql = "SELECT count(rowid) FROM ".$this->db->prefix().$this->table_element_line; |
3143 | 3143 | $sql .= " WHERE ".$this->fk_element." = ".((int) $this->id); |
3144 | 3144 | if (!$renum) { |
3145 | - $sql .= " AND " . $fieldposition . " = 0"; |
|
3145 | + $sql .= " AND ".$fieldposition." = 0"; |
|
3146 | 3146 | } |
3147 | 3147 | if ($renum) { |
3148 | - $sql .= " AND " . $fieldposition . " <> 0"; |
|
3148 | + $sql .= " AND ".$fieldposition." <> 0"; |
|
3149 | 3149 | } |
3150 | 3150 | |
3151 | 3151 | dol_syslog(get_class($this)."::line_order", LOG_DEBUG); |
@@ -3166,7 +3166,7 @@ discard block |
||
3166 | 3166 | if ($fk_parent_line) { |
3167 | 3167 | $sql .= ' AND fk_parent_line IS NULL'; |
3168 | 3168 | } |
3169 | - $sql .= " ORDER BY " . $fieldposition . " ASC, rowid " . $rowidorder; |
|
3169 | + $sql .= " ORDER BY ".$fieldposition." ASC, rowid ".$rowidorder; |
|
3170 | 3170 | |
3171 | 3171 | dol_syslog(get_class($this)."::line_order search all parent lines", LOG_DEBUG); |
3172 | 3172 | $resql = $this->db->query($sql); |
@@ -3217,7 +3217,7 @@ discard block |
||
3217 | 3217 | $sql = "SELECT rowid FROM ".$this->db->prefix().$this->table_element_line; |
3218 | 3218 | $sql .= " WHERE ".$this->fk_element." = ".((int) $this->id); |
3219 | 3219 | $sql .= ' AND fk_parent_line = '.((int) $id); |
3220 | - $sql .= " ORDER BY " . $fieldposition . " ASC"; |
|
3220 | + $sql .= " ORDER BY ".$fieldposition." ASC"; |
|
3221 | 3221 | |
3222 | 3222 | dol_syslog(get_class($this)."::getChildrenOfLine search children lines for line ".$id, LOG_DEBUG); |
3223 | 3223 | $resql = $this->db->query($sql); |
@@ -3300,8 +3300,8 @@ discard block |
||
3300 | 3300 | dol_print_error($this->db); |
3301 | 3301 | return -1; |
3302 | 3302 | } else { |
3303 | - $parameters=array('rowid'=>$rowid, 'rang'=>$rang, 'fieldposition' => $fieldposition); |
|
3304 | - $action=''; |
|
3303 | + $parameters = array('rowid'=>$rowid, 'rang'=>$rang, 'fieldposition' => $fieldposition); |
|
3304 | + $action = ''; |
|
3305 | 3305 | $reshook = $hookmanager->executeHooks('afterRankOfLineUpdate', $parameters, $this, $action); |
3306 | 3306 | return 1; |
3307 | 3307 | } |
@@ -3340,7 +3340,7 @@ discard block |
||
3340 | 3340 | |
3341 | 3341 | $sql = "UPDATE ".$this->db->prefix().$this->table_element_line." SET ".$fieldposition." = ".((int) $rang); |
3342 | 3342 | $sql .= " WHERE ".$this->fk_element." = ".((int) $this->id); |
3343 | - $sql .= " AND " . $fieldposition . " = " . ((int) ($rang - 1)); |
|
3343 | + $sql .= " AND ".$fieldposition." = ".((int) ($rang - 1)); |
|
3344 | 3344 | if ($this->db->query($sql)) { |
3345 | 3345 | $sql = "UPDATE ".$this->db->prefix().$this->table_element_line." SET ".$fieldposition." = ".((int) ($rang - 1)); |
3346 | 3346 | $sql .= ' WHERE rowid = '.((int) $rowid); |
@@ -3371,7 +3371,7 @@ discard block |
||
3371 | 3371 | |
3372 | 3372 | $sql = "UPDATE ".$this->db->prefix().$this->table_element_line." SET ".$fieldposition." = ".((int) $rang); |
3373 | 3373 | $sql .= " WHERE ".$this->fk_element." = ".((int) $this->id); |
3374 | - $sql .= " AND " . $fieldposition . " = " . ((int) ($rang + 1)); |
|
3374 | + $sql .= " AND ".$fieldposition." = ".((int) ($rang + 1)); |
|
3375 | 3375 | if ($this->db->query($sql)) { |
3376 | 3376 | $sql = "UPDATE ".$this->db->prefix().$this->table_element_line." SET ".$fieldposition." = ".((int) ($rang + 1)); |
3377 | 3377 | $sql .= ' WHERE rowid = '.((int) $rowid); |
@@ -3397,7 +3397,7 @@ discard block |
||
3397 | 3397 | $fieldposition = 'position'; |
3398 | 3398 | } |
3399 | 3399 | |
3400 | - $sql = "SELECT " . $fieldposition . " FROM ".$this->db->prefix().$this->table_element_line; |
|
3400 | + $sql = "SELECT ".$fieldposition." FROM ".$this->db->prefix().$this->table_element_line; |
|
3401 | 3401 | $sql .= " WHERE rowid = ".((int) $rowid); |
3402 | 3402 | |
3403 | 3403 | dol_syslog(get_class($this)."::getRangOfLine", LOG_DEBUG); |
@@ -3425,7 +3425,7 @@ discard block |
||
3425 | 3425 | |
3426 | 3426 | $sql = "SELECT rowid FROM ".$this->db->prefix().$this->table_element_line; |
3427 | 3427 | $sql .= " WHERE ".$this->fk_element." = ".((int) $this->id); |
3428 | - $sql .= " AND " . $fieldposition . " = ".((int) $rang); |
|
3428 | + $sql .= " AND ".$fieldposition." = ".((int) $rang); |
|
3429 | 3429 | $resql = $this->db->query($sql); |
3430 | 3430 | if ($resql) { |
3431 | 3431 | $row = $this->db->fetch_row($resql); |
@@ -3543,7 +3543,7 @@ discard block |
||
3543 | 3543 | $newsuffix = ''; |
3544 | 3544 | } |
3545 | 3545 | if (in_array($this->table_element, array('actioncomm', 'adherent', 'advtargetemailing', 'cronjob', 'establishment'))) { |
3546 | - $fieldusermod = "fk_user_mod"; |
|
3546 | + $fieldusermod = "fk_user_mod"; |
|
3547 | 3547 | } elseif ($this->table_element == 'ecm_files') { |
3548 | 3548 | $fieldusermod = "fk_user_m"; |
3549 | 3549 | } else { |
@@ -3585,7 +3585,7 @@ discard block |
||
3585 | 3585 | $trigger_name = 'EXPENSE_REPORT_MODIFY'; |
3586 | 3586 | break; |
3587 | 3587 | default: |
3588 | - $trigger_name = strtoupper($this->element) . '_MODIFY'; |
|
3588 | + $trigger_name = strtoupper($this->element).'_MODIFY'; |
|
3589 | 3589 | } |
3590 | 3590 | $ret = $this->call_trigger($trigger_name, $user); |
3591 | 3591 | if ($ret < 0) { |
@@ -3943,7 +3943,7 @@ discard block |
||
3943 | 3943 | // It's because an entry for this element may be exist in llx_element_element before this modification (version <=14.2) and ave named only with their element name in fk_source or fk_target. |
3944 | 3944 | $coremodule = array('knowledgemanagement', 'partnership', 'workstation', 'ticket', 'recruitment', 'eventorganization', 'asset'); |
3945 | 3945 | // Add module part to target type if object has $module property and isn't in core modules. |
3946 | - $targettype = ((!empty($this->module) && ! in_array($this->module, $coremodule)) ? $this->module.'_' : '').$this->element; |
|
3946 | + $targettype = ((!empty($this->module) && !in_array($this->module, $coremodule)) ? $this->module.'_' : '').$this->element; |
|
3947 | 3947 | |
3948 | 3948 | $parameters = array('targettype'=>$targettype); |
3949 | 3949 | // Hook for explicitly set the targettype if it must be differtent than $this->element |
@@ -3957,19 +3957,19 @@ discard block |
||
3957 | 3957 | $this->db->begin(); |
3958 | 3958 | $error = 0; |
3959 | 3959 | |
3960 | - $sql = "INSERT INTO " . $this->db->prefix() . "element_element ("; |
|
3960 | + $sql = "INSERT INTO ".$this->db->prefix()."element_element ("; |
|
3961 | 3961 | $sql .= "fk_source"; |
3962 | 3962 | $sql .= ", sourcetype"; |
3963 | 3963 | $sql .= ", fk_target"; |
3964 | 3964 | $sql .= ", targettype"; |
3965 | 3965 | $sql .= ") VALUES ("; |
3966 | 3966 | $sql .= ((int) $origin_id); |
3967 | - $sql .= ", '" . $this->db->escape($origin) . "'"; |
|
3968 | - $sql .= ", " . ((int) $this->id); |
|
3969 | - $sql .= ", '" . $this->db->escape($targettype) . "'"; |
|
3967 | + $sql .= ", '".$this->db->escape($origin)."'"; |
|
3968 | + $sql .= ", ".((int) $this->id); |
|
3969 | + $sql .= ", '".$this->db->escape($targettype)."'"; |
|
3970 | 3970 | $sql .= ")"; |
3971 | 3971 | |
3972 | - dol_syslog(get_class($this) . "::add_object_linked", LOG_DEBUG); |
|
3972 | + dol_syslog(get_class($this)."::add_object_linked", LOG_DEBUG); |
|
3973 | 3973 | if ($this->db->query($sql)) { |
3974 | 3974 | if (!$notrigger) { |
3975 | 3975 | // Call trigger |
@@ -4284,20 +4284,20 @@ discard block |
||
4284 | 4284 | $this->db->begin(); |
4285 | 4285 | $error = 0; |
4286 | 4286 | |
4287 | - $sql = "UPDATE " . $this->db->prefix() . "element_element SET "; |
|
4287 | + $sql = "UPDATE ".$this->db->prefix()."element_element SET "; |
|
4288 | 4288 | if ($updatesource) { |
4289 | - $sql .= "fk_source = " . ((int) $sourceid); |
|
4290 | - $sql .= ", sourcetype = '" . $this->db->escape($sourcetype) . "'"; |
|
4291 | - $sql .= " WHERE fk_target = " . ((int) $this->id); |
|
4292 | - $sql .= " AND targettype = '" . $this->db->escape($this->element) . "'"; |
|
4289 | + $sql .= "fk_source = ".((int) $sourceid); |
|
4290 | + $sql .= ", sourcetype = '".$this->db->escape($sourcetype)."'"; |
|
4291 | + $sql .= " WHERE fk_target = ".((int) $this->id); |
|
4292 | + $sql .= " AND targettype = '".$this->db->escape($this->element)."'"; |
|
4293 | 4293 | } elseif ($updatetarget) { |
4294 | - $sql .= "fk_target = " . ((int) $targetid); |
|
4295 | - $sql .= ", targettype = '" . $this->db->escape($targettype) . "'"; |
|
4296 | - $sql .= " WHERE fk_source = " . ((int) $this->id); |
|
4297 | - $sql .= " AND sourcetype = '" . $this->db->escape($this->element) . "'"; |
|
4294 | + $sql .= "fk_target = ".((int) $targetid); |
|
4295 | + $sql .= ", targettype = '".$this->db->escape($targettype)."'"; |
|
4296 | + $sql .= " WHERE fk_source = ".((int) $this->id); |
|
4297 | + $sql .= " AND sourcetype = '".$this->db->escape($this->element)."'"; |
|
4298 | 4298 | } |
4299 | 4299 | |
4300 | - dol_syslog(get_class($this) . "::updateObjectLinked", LOG_DEBUG); |
|
4300 | + dol_syslog(get_class($this)."::updateObjectLinked", LOG_DEBUG); |
|
4301 | 4301 | if ($this->db->query($sql)) { |
4302 | 4302 | if (!$notrigger) { |
4303 | 4303 | // Call trigger |
@@ -4373,25 +4373,25 @@ discard block |
||
4373 | 4373 | } |
4374 | 4374 | |
4375 | 4375 | if (!$error) { |
4376 | - $sql = "DELETE FROM " . $this->db->prefix() . "element_element"; |
|
4376 | + $sql = "DELETE FROM ".$this->db->prefix()."element_element"; |
|
4377 | 4377 | $sql .= " WHERE"; |
4378 | 4378 | if ($rowid > 0) { |
4379 | - $sql .= " rowid = " . ((int) $rowid); |
|
4379 | + $sql .= " rowid = ".((int) $rowid); |
|
4380 | 4380 | } else { |
4381 | 4381 | if ($deletesource) { |
4382 | - $sql .= " fk_source = " . ((int) $sourceid) . " AND sourcetype = '" . $this->db->escape($sourcetype) . "'"; |
|
4383 | - $sql .= " AND fk_target = " . ((int) $this->id) . " AND targettype = '" . $this->db->escape($this->element) . "'"; |
|
4382 | + $sql .= " fk_source = ".((int) $sourceid)." AND sourcetype = '".$this->db->escape($sourcetype)."'"; |
|
4383 | + $sql .= " AND fk_target = ".((int) $this->id)." AND targettype = '".$this->db->escape($this->element)."'"; |
|
4384 | 4384 | } elseif ($deletetarget) { |
4385 | - $sql .= " fk_target = " . ((int) $targetid) . " AND targettype = '" . $this->db->escape($targettype) . "'"; |
|
4386 | - $sql .= " AND fk_source = " . ((int) $this->id) . " AND sourcetype = '" . $this->db->escape($this->element) . "'"; |
|
4385 | + $sql .= " fk_target = ".((int) $targetid)." AND targettype = '".$this->db->escape($targettype)."'"; |
|
4386 | + $sql .= " AND fk_source = ".((int) $this->id)." AND sourcetype = '".$this->db->escape($this->element)."'"; |
|
4387 | 4387 | } else { |
4388 | - $sql .= " (fk_source = " . ((int) $this->id) . " AND sourcetype = '" . $this->db->escape($this->element) . "')"; |
|
4388 | + $sql .= " (fk_source = ".((int) $this->id)." AND sourcetype = '".$this->db->escape($this->element)."')"; |
|
4389 | 4389 | $sql .= " OR"; |
4390 | - $sql .= " (fk_target = " . ((int) $this->id) . " AND targettype = '" . $this->db->escape($this->element) . "')"; |
|
4390 | + $sql .= " (fk_target = ".((int) $this->id)." AND targettype = '".$this->db->escape($this->element)."')"; |
|
4391 | 4391 | } |
4392 | 4392 | } |
4393 | 4393 | |
4394 | - dol_syslog(get_class($this) . "::deleteObjectLinked", LOG_DEBUG); |
|
4394 | + dol_syslog(get_class($this)."::deleteObjectLinked", LOG_DEBUG); |
|
4395 | 4395 | if (!$this->db->query($sql)) { |
4396 | 4396 | $this->error = $this->db->lasterror(); |
4397 | 4397 | $this->errors[] = $this->error; |
@@ -4553,14 +4553,14 @@ discard block |
||
4553 | 4553 | $sql .= ", date_validation = '".$this->db->idate(dol_now())."'"; |
4554 | 4554 | } |
4555 | 4555 | $sql .= " WHERE rowid = ".((int) $elementId); |
4556 | - $sql .= " AND ".$fieldstatus." <> ".((int) $status); // We avoid update if status already correct |
|
4556 | + $sql .= " AND ".$fieldstatus." <> ".((int) $status); // We avoid update if status already correct |
|
4557 | 4557 | |
4558 | 4558 | dol_syslog(get_class($this)."::setStatut", LOG_DEBUG); |
4559 | 4559 | $resql = $this->db->query($sql); |
4560 | 4560 | if ($resql) { |
4561 | 4561 | $error = 0; |
4562 | 4562 | |
4563 | - $nb_rows_affected = $this->db->affected_rows($resql); // should be 1 or 0 if status was already correct |
|
4563 | + $nb_rows_affected = $this->db->affected_rows($resql); // should be 1 or 0 if status was already correct |
|
4564 | 4564 | |
4565 | 4565 | if ($nb_rows_affected > 0) { |
4566 | 4566 | if (empty($trigkey)) { |
@@ -4605,7 +4605,7 @@ discard block |
||
4605 | 4605 | if ($fieldstatus == 'tosell') { |
4606 | 4606 | $this->status = $status; |
4607 | 4607 | } elseif ($fieldstatus == 'tobuy') { |
4608 | - $this->status_buy = $status; // @phpstan-ignore-line |
|
4608 | + $this->status_buy = $status; // @phpstan-ignore-line |
|
4609 | 4609 | } else { |
4610 | 4610 | $this->statut = $status; |
4611 | 4611 | $this->status = $status; |
@@ -4714,7 +4714,7 @@ discard block |
||
4714 | 4714 | return -1; |
4715 | 4715 | } |
4716 | 4716 | |
4717 | - $arraytoscan = $this->childtables; // array('tablename'=>array('fk_element'=>'parentfield'), ...) or array('tablename'=>array('parent'=>table_parent, 'parentkey'=>'nameoffieldforparentfkkey'), ...) |
|
4717 | + $arraytoscan = $this->childtables; // array('tablename'=>array('fk_element'=>'parentfield'), ...) or array('tablename'=>array('parent'=>table_parent, 'parentkey'=>'nameoffieldforparentfkkey'), ...) |
|
4718 | 4718 | // For backward compatibility, we check if array is old format array('tablename1', 'tablename2', ...) |
4719 | 4719 | $tmparray = array_keys($this->childtables); |
4720 | 4720 | if (is_numeric($tmparray[0])) { |
@@ -4727,26 +4727,26 @@ discard block |
||
4727 | 4727 | //print $id.'-'.$table.'-'.$elementname.'<br>'; |
4728 | 4728 | // Check if element can be deleted |
4729 | 4729 | $sql = "SELECT COUNT(*) as nb"; |
4730 | - $sql.= " FROM ".$this->db->prefix().$table." as c"; |
|
4730 | + $sql .= " FROM ".$this->db->prefix().$table." as c"; |
|
4731 | 4731 | if (!empty($element['parent']) && !empty($element['parentkey'])) { |
4732 | - $sql.= ", ".$this->db->prefix().$element['parent']." as p"; |
|
4732 | + $sql .= ", ".$this->db->prefix().$element['parent']." as p"; |
|
4733 | 4733 | } |
4734 | 4734 | if (!empty($element['fk_element'])) { |
4735 | - $sql.= " WHERE c.".$element['fk_element']." = ".((int) $id); |
|
4735 | + $sql .= " WHERE c.".$element['fk_element']." = ".((int) $id); |
|
4736 | 4736 | } else { |
4737 | - $sql.= " WHERE c.".$this->fk_element." = ".((int) $id); |
|
4737 | + $sql .= " WHERE c.".$this->fk_element." = ".((int) $id); |
|
4738 | 4738 | } |
4739 | 4739 | if (!empty($element['parent']) && !empty($element['parentkey'])) { |
4740 | - $sql.= " AND c.".$element['parentkey']." = p.rowid"; |
|
4740 | + $sql .= " AND c.".$element['parentkey']." = p.rowid"; |
|
4741 | 4741 | } |
4742 | 4742 | if (!empty($element['parent']) && !empty($element['parenttypefield']) && !empty($element['parenttypevalue'])) { |
4743 | - $sql.= " AND c.".$element['parenttypefield']." = '".$this->db->escape($element['parenttypevalue'])."'"; |
|
4743 | + $sql .= " AND c.".$element['parenttypefield']." = '".$this->db->escape($element['parenttypevalue'])."'"; |
|
4744 | 4744 | } |
4745 | 4745 | if (!empty($entity)) { |
4746 | 4746 | if (!empty($element['parent']) && !empty($element['parentkey'])) { |
4747 | - $sql.= " AND p.entity = ".((int) $entity); |
|
4747 | + $sql .= " AND p.entity = ".((int) $entity); |
|
4748 | 4748 | } else { |
4749 | - $sql.= " AND c.entity = ".((int) $entity); |
|
4749 | + $sql .= " AND c.entity = ".((int) $entity); |
|
4750 | 4750 | } |
4751 | 4751 | } |
4752 | 4752 | |
@@ -5776,7 +5776,7 @@ discard block |
||
5776 | 5776 | $setsharekey = false; |
5777 | 5777 | if ($this->element == 'propal' || $this->element == 'proposal') { |
5778 | 5778 | if (getDolGlobalInt("PROPOSAL_ALLOW_ONLINESIGN")) { |
5779 | - $setsharekey = true; // feature to make online signature is not set or set to on (default) |
|
5779 | + $setsharekey = true; // feature to make online signature is not set or set to on (default) |
|
5780 | 5780 | } |
5781 | 5781 | if (getDolGlobalInt("PROPOSAL_ALLOW_EXTERNAL_DOWNLOAD")) { |
5782 | 5782 | $setsharekey = true; |
@@ -5834,7 +5834,7 @@ discard block |
||
5834 | 5834 | $ecmfile->gen_or_uploaded = 'generated'; |
5835 | 5835 | $ecmfile->description = ''; // indexed content |
5836 | 5836 | $ecmfile->keywords = ''; // keyword content |
5837 | - $ecmfile->src_object_type = $this->table_element; // $this->table_name is 'myobject' or 'mymodule_myobject'. |
|
5837 | + $ecmfile->src_object_type = $this->table_element; // $this->table_name is 'myobject' or 'mymodule_myobject'. |
|
5838 | 5838 | $ecmfile->src_object_id = $this->id; |
5839 | 5839 | |
5840 | 5840 | $result = $ecmfile->create($user); |
@@ -5886,7 +5886,7 @@ discard block |
||
5886 | 5886 | $maxwidthmini = $tmparraysize['maxwidthmini']; |
5887 | 5887 | $maxheightmini = $tmparraysize['maxheightmini']; |
5888 | 5888 | //$quality = $tmparraysize['quality']; |
5889 | - $quality = 50; // For thumbs, we force quality to 50 |
|
5889 | + $quality = 50; // For thumbs, we force quality to 50 |
|
5890 | 5890 | |
5891 | 5891 | // Create small thumbs for company (Ratio is near 16/9) |
5892 | 5892 | // Used on logon for example |
@@ -5988,8 +5988,8 @@ discard block |
||
5988 | 5988 | // phpcs:enable |
5989 | 5989 | global $langs, $conf; |
5990 | 5990 | |
5991 | - if (!empty(self::TRIGGER_PREFIX) && strpos($triggerName, self::TRIGGER_PREFIX . '_') !== 0) { |
|
5992 | - dol_print_error('', 'The trigger "' . $triggerName . '" does not start with "' . self::TRIGGER_PREFIX . '_" as required.'); |
|
5991 | + if (!empty(self::TRIGGER_PREFIX) && strpos($triggerName, self::TRIGGER_PREFIX.'_') !== 0) { |
|
5992 | + dol_print_error('', 'The trigger "'.$triggerName.'" does not start with "'.self::TRIGGER_PREFIX.'_" as required.'); |
|
5993 | 5993 | exit; |
5994 | 5994 | } |
5995 | 5995 | if (!is_object($langs)) { // If lang was not defined, we set it. It is required by run_triggers(). |
@@ -6183,7 +6183,7 @@ discard block |
||
6183 | 6183 | $savDisableCompute = $conf->disable_compute; |
6184 | 6184 | $conf->disable_compute = 1; |
6185 | 6185 | |
6186 | - $ret = $this->fetch($id); /* @phpstan-ignore-line */ |
|
6186 | + $ret = $this->fetch($id); /* @phpstan-ignore-line */ |
|
6187 | 6187 | |
6188 | 6188 | $conf->disable_compute = $savDisableCompute; |
6189 | 6189 | |
@@ -6287,9 +6287,9 @@ discard block |
||
6287 | 6287 | if (!empty($extrafields->attributes[$this->table_element]) && !empty($extrafields->attributes[$this->table_element]['computed'][$key])) { |
6288 | 6288 | //var_dump($conf->disable_compute); |
6289 | 6289 | if (empty($conf->disable_compute)) { |
6290 | - global $objectoffield; // We set a global variable to $objectoffield so |
|
6291 | - $objectoffield = $this; // we can use it inside computed formula |
|
6292 | - $this->array_options['options_' . $key] = dol_eval($extrafields->attributes[$this->table_element]['computed'][$key], 1, 0, '2'); |
|
6290 | + global $objectoffield; // We set a global variable to $objectoffield so |
|
6291 | + $objectoffield = $this; // we can use it inside computed formula |
|
6292 | + $this->array_options['options_'.$key] = dol_eval($extrafields->attributes[$this->table_element]['computed'][$key], 1, 0, '2'); |
|
6293 | 6293 | } |
6294 | 6294 | } |
6295 | 6295 | } |
@@ -6303,7 +6303,7 @@ discard block |
||
6303 | 6303 | return 0; |
6304 | 6304 | } |
6305 | 6305 | } else { |
6306 | - $this->errors[]=$this->db->lasterror; |
|
6306 | + $this->errors[] = $this->db->lasterror; |
|
6307 | 6307 | return -1; |
6308 | 6308 | } |
6309 | 6309 | } |
@@ -6470,7 +6470,7 @@ discard block |
||
6470 | 6470 | // If old value crypted in database is same than submited new value, it means we don't change it, so we don't update. |
6471 | 6471 | if ($algo == 'dolcrypt') { // dolibarr reversible encryption |
6472 | 6472 | if (!preg_match('/^dolcrypt:/', $this->array_options[$key])) { |
6473 | - $new_array_options[$key] = dolEncrypt($this->array_options[$key]); // warning, must be called when on the master |
|
6473 | + $new_array_options[$key] = dolEncrypt($this->array_options[$key]); // warning, must be called when on the master |
|
6474 | 6474 | } else { |
6475 | 6475 | $new_array_options[$key] = $this->array_options[$key]; // Value is kept |
6476 | 6476 | } |
@@ -6481,7 +6481,7 @@ discard block |
||
6481 | 6481 | // If value has changed |
6482 | 6482 | if ($algo == 'dolcrypt') { // dolibarr reversible encryption |
6483 | 6483 | if (!preg_match('/^dolcrypt:/', $this->array_options[$key])) { |
6484 | - $new_array_options[$key] = dolEncrypt($this->array_options[$key]); // warning, must be called when on the master |
|
6484 | + $new_array_options[$key] = dolEncrypt($this->array_options[$key]); // warning, must be called when on the master |
|
6485 | 6485 | } else { |
6486 | 6486 | $new_array_options[$key] = $this->array_options[$key]; // Value is kept |
6487 | 6487 | } |
@@ -6493,7 +6493,7 @@ discard block |
||
6493 | 6493 | //var_dump('jjj'.$algo.' '.$this->oldcopy->array_options[$key].' -> '.$this->array_options[$key]); |
6494 | 6494 | // If this->oldcopy is not defined, we can't know if we change attribute or not, so we must keep value |
6495 | 6495 | if ($algo == 'dolcrypt' && !preg_match('/^dolcrypt:/', $this->array_options[$key])) { // dolibarr reversible encryption |
6496 | - $new_array_options[$key] = dolEncrypt($this->array_options[$key]); // warning, must be called when on the master |
|
6496 | + $new_array_options[$key] = dolEncrypt($this->array_options[$key]); // warning, must be called when on the master |
|
6497 | 6497 | } else { |
6498 | 6498 | $new_array_options[$key] = $this->array_options[$key]; // Value is kept |
6499 | 6499 | } |
@@ -6879,7 +6879,7 @@ discard block |
||
6879 | 6879 | if (isset($this->oldcopy->array_options["options_".$key]) && $this->array_options["options_".$key] == $this->oldcopy->array_options["options_".$key]) { // If old value crypted in database is same than submited new value, it means we don't change it, so we don't update. |
6880 | 6880 | if ($algo == 'dolcrypt') { // dolibarr reversible encryption |
6881 | 6881 | if (!preg_match('/^dolcrypt:/', $this->array_options["options_".$key])) { |
6882 | - $new_array_options["options_".$key] = dolEncrypt($this->array_options["options_".$key]); // warning, must be called when on the master |
|
6882 | + $new_array_options["options_".$key] = dolEncrypt($this->array_options["options_".$key]); // warning, must be called when on the master |
|
6883 | 6883 | } else { |
6884 | 6884 | $new_array_options["options_".$key] = $this->array_options["options_".$key]; // Value is kept |
6885 | 6885 | } |
@@ -6899,7 +6899,7 @@ discard block |
||
6899 | 6899 | } |
6900 | 6900 | } else { |
6901 | 6901 | if ($algo == 'dolcrypt' && !preg_match('/^dolcrypt:/', $this->array_options["options_".$key])) { // dolibarr reversible encryption |
6902 | - $new_array_options["options_".$key] = dolEncrypt($this->array_options["options_".$key]); // warning, must be called when on the master |
|
6902 | + $new_array_options["options_".$key] = dolEncrypt($this->array_options["options_".$key]); // warning, must be called when on the master |
|
6903 | 6903 | } else { |
6904 | 6904 | $new_array_options["options_".$key] = $this->array_options["options_".$key]; // Value is kept |
6905 | 6905 | } |
@@ -7149,7 +7149,7 @@ discard block |
||
7149 | 7149 | // Special case that force options and type ($type can be integer, varchar, ...) |
7150 | 7150 | if (!empty($this->fields[$key]['arrayofkeyval']) && is_array($this->fields[$key]['arrayofkeyval'])) { |
7151 | 7151 | $param['options'] = $this->fields[$key]['arrayofkeyval']; |
7152 | - $type = (($this->fields[$key]['type']=='checkbox') ? $this->fields[$key]['type'] : 'select'); |
|
7152 | + $type = (($this->fields[$key]['type'] == 'checkbox') ? $this->fields[$key]['type'] : 'select'); |
|
7153 | 7153 | } |
7154 | 7154 | |
7155 | 7155 | $label = $this->fields[$key]['label']; |
@@ -7201,7 +7201,7 @@ discard block |
||
7201 | 7201 | |
7202 | 7202 | // Add validation state class |
7203 | 7203 | if (!empty($validationClass)) { |
7204 | - $morecss.= $validationClass; |
|
7204 | + $morecss .= $validationClass; |
|
7205 | 7205 | } |
7206 | 7206 | |
7207 | 7207 | if (in_array($type, array('date'))) { |
@@ -7309,7 +7309,7 @@ discard block |
||
7309 | 7309 | if (is_array($param['options'])) { |
7310 | 7310 | $param_list = array_keys($param['options']); |
7311 | 7311 | $InfoFieldList = explode(":", $param_list[0], 5); |
7312 | - if (! empty($InfoFieldList[4])) { |
|
7312 | + if (!empty($InfoFieldList[4])) { |
|
7313 | 7313 | $pos = 0; |
7314 | 7314 | $parenthesisopen = 0; |
7315 | 7315 | while (substr($InfoFieldList[4], $pos, 1) !== '' && ($parenthesisopen || $pos == 0 || substr($InfoFieldList[4], $pos, 1) != ':')) { |
@@ -7322,7 +7322,7 @@ discard block |
||
7322 | 7322 | $pos++; |
7323 | 7323 | } |
7324 | 7324 | $tmpbefore = substr($InfoFieldList[4], 0, $pos); |
7325 | - $tmpafter = substr($InfoFieldList[4], $pos+1); |
|
7325 | + $tmpafter = substr($InfoFieldList[4], $pos + 1); |
|
7326 | 7326 | //var_dump($InfoFieldList[4].' -> '.$pos); var_dump($tmpafter); |
7327 | 7327 | $InfoFieldList[4] = $tmpbefore; |
7328 | 7328 | if ($tmpafter !== '') { |
@@ -7370,8 +7370,8 @@ discard block |
||
7370 | 7370 | } |
7371 | 7371 | |
7372 | 7372 | $sqlwhere = ''; |
7373 | - $sql = "SELECT " . $keyList; |
|
7374 | - $sql .= " FROM " . $this->db->prefix() . $InfoFieldList[0]; |
|
7373 | + $sql = "SELECT ".$keyList; |
|
7374 | + $sql .= " FROM ".$this->db->prefix().$InfoFieldList[0]; |
|
7375 | 7375 | if (!empty($InfoFieldList[4])) { |
7376 | 7376 | // can use SELECT request |
7377 | 7377 | if (strpos($InfoFieldList[4], '$SEL$') !== false) { |
@@ -7388,18 +7388,18 @@ discard block |
||
7388 | 7388 | // We have to join on extrafield table |
7389 | 7389 | $errstr = ''; |
7390 | 7390 | if (strpos($InfoFieldList[4], 'extra') !== false) { |
7391 | - $sql .= " as main, " . $this->db->prefix() . $InfoFieldList[0] . "_extrafields as extra"; |
|
7392 | - $sqlwhere .= " WHERE extra.fk_object=main." . $InfoFieldList[2]; |
|
7393 | - $sqlwhere .= " AND " . forgeSQLFromUniversalSearchCriteria($InfoFieldList[4], $errstr, 1); |
|
7391 | + $sql .= " as main, ".$this->db->prefix().$InfoFieldList[0]."_extrafields as extra"; |
|
7392 | + $sqlwhere .= " WHERE extra.fk_object=main.".$InfoFieldList[2]; |
|
7393 | + $sqlwhere .= " AND ".forgeSQLFromUniversalSearchCriteria($InfoFieldList[4], $errstr, 1); |
|
7394 | 7394 | } else { |
7395 | - $sqlwhere .= " WHERE " . forgeSQLFromUniversalSearchCriteria($InfoFieldList[4], $errstr, 1); |
|
7395 | + $sqlwhere .= " WHERE ".forgeSQLFromUniversalSearchCriteria($InfoFieldList[4], $errstr, 1); |
|
7396 | 7396 | } |
7397 | 7397 | } else { |
7398 | 7398 | $sqlwhere .= ' WHERE 1=1'; |
7399 | 7399 | } |
7400 | 7400 | // Some tables may have field, some other not. For the moment we disable it. |
7401 | 7401 | if (in_array($InfoFieldList[0], array('tablewithentity'))) { |
7402 | - $sqlwhere .= " AND entity = " . ((int) $conf->entity); |
|
7402 | + $sqlwhere .= " AND entity = ".((int) $conf->entity); |
|
7403 | 7403 | } |
7404 | 7404 | $sql .= $sqlwhere; |
7405 | 7405 | //print $sql; |
@@ -7411,7 +7411,7 @@ discard block |
||
7411 | 7411 | $sql .= " ORDER BY ".$this->db->sanitize(implode(', ', $fields_label)); |
7412 | 7412 | } |
7413 | 7413 | |
7414 | - dol_syslog(get_class($this) . '::showInputField type=sellist', LOG_DEBUG); |
|
7414 | + dol_syslog(get_class($this).'::showInputField type=sellist', LOG_DEBUG); |
|
7415 | 7415 | $resql = $this->db->query($sql); |
7416 | 7416 | if ($resql) { |
7417 | 7417 | $out .= '<option value="0"> </option>'; |
@@ -7427,7 +7427,7 @@ discard block |
||
7427 | 7427 | if (count($fields_label) > 1) { |
7428 | 7428 | $notrans = true; |
7429 | 7429 | foreach ($fields_label as $field_toshow) { |
7430 | - $labeltoshow .= $obj->$field_toshow . ' '; |
|
7430 | + $labeltoshow .= $obj->$field_toshow.' '; |
|
7431 | 7431 | } |
7432 | 7432 | } else { |
7433 | 7433 | $labeltoshow = $obj->{$InfoFieldList[1]}; |
@@ -7438,12 +7438,12 @@ discard block |
||
7438 | 7438 | foreach ($fields_label as $field_toshow) { |
7439 | 7439 | $translabel = $langs->trans($obj->$field_toshow); |
7440 | 7440 | if ($translabel != $obj->$field_toshow) { |
7441 | - $labeltoshow = dol_trunc($translabel) . ' '; |
|
7441 | + $labeltoshow = dol_trunc($translabel).' '; |
|
7442 | 7442 | } else { |
7443 | - $labeltoshow = dol_trunc($obj->$field_toshow) . ' '; |
|
7443 | + $labeltoshow = dol_trunc($obj->$field_toshow).' '; |
|
7444 | 7444 | } |
7445 | 7445 | } |
7446 | - $out .= '<option value="' . $obj->rowid . '" selected>' . $labeltoshow . '</option>'; |
|
7446 | + $out .= '<option value="'.$obj->rowid.'" selected>'.$labeltoshow.'</option>'; |
|
7447 | 7447 | } else { |
7448 | 7448 | if (!$notrans) { |
7449 | 7449 | $translabel = $langs->trans($obj->{$InfoFieldList[1]}); |
@@ -7457,34 +7457,34 @@ discard block |
||
7457 | 7457 | $labeltoshow = '(not defined)'; |
7458 | 7458 | } |
7459 | 7459 | if ($value == $obj->rowid) { |
7460 | - $out .= '<option value="' . $obj->rowid . '" selected>' . $labeltoshow . '</option>'; |
|
7460 | + $out .= '<option value="'.$obj->rowid.'" selected>'.$labeltoshow.'</option>'; |
|
7461 | 7461 | } |
7462 | 7462 | |
7463 | 7463 | if (!empty($InfoFieldList[3]) && $parentField) { |
7464 | - $parent = $parentName . ':' . $obj->{$parentField}; |
|
7464 | + $parent = $parentName.':'.$obj->{$parentField}; |
|
7465 | 7465 | $isDependList = 1; |
7466 | 7466 | } |
7467 | 7467 | |
7468 | - $out .= '<option value="' . $obj->rowid . '"'; |
|
7468 | + $out .= '<option value="'.$obj->rowid.'"'; |
|
7469 | 7469 | $out .= ($value == $obj->rowid ? ' selected' : ''); |
7470 | - $out .= (!empty($parent) ? ' parent="' . $parent . '"' : ''); |
|
7471 | - $out .= '>' . $labeltoshow . '</option>'; |
|
7470 | + $out .= (!empty($parent) ? ' parent="'.$parent.'"' : ''); |
|
7471 | + $out .= '>'.$labeltoshow.'</option>'; |
|
7472 | 7472 | } |
7473 | 7473 | |
7474 | 7474 | $i++; |
7475 | 7475 | } |
7476 | 7476 | $this->db->free($resql); |
7477 | 7477 | } else { |
7478 | - print 'Error in request ' . $sql . ' ' . $this->db->lasterror() . '. Check setup of extra parameters.<br>'; |
|
7478 | + print 'Error in request '.$sql.' '.$this->db->lasterror().'. Check setup of extra parameters.<br>'; |
|
7479 | 7479 | } |
7480 | 7480 | } else { |
7481 | 7481 | require_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php'; |
7482 | 7482 | $data = $form->select_all_categories(Categorie::$MAP_ID_TO_CODE[$InfoFieldList[5]], '', 'parent', 64, $InfoFieldList[6], 1, 1); |
7483 | 7483 | $out .= '<option value="0"> </option>'; |
7484 | 7484 | foreach ($data as $data_key => $data_value) { |
7485 | - $out .= '<option value="' . $data_key . '"'; |
|
7485 | + $out .= '<option value="'.$data_key.'"'; |
|
7486 | 7486 | $out .= ($value == $data_key ? ' selected' : ''); |
7487 | - $out .= '>' . $data_value . '</option>'; |
|
7487 | + $out .= '>'.$data_value.'</option>'; |
|
7488 | 7488 | } |
7489 | 7489 | } |
7490 | 7490 | } |
@@ -7549,8 +7549,8 @@ discard block |
||
7549 | 7549 | } |
7550 | 7550 | |
7551 | 7551 | $sqlwhere = ''; |
7552 | - $sql = "SELECT " . $keyList; |
|
7553 | - $sql .= ' FROM ' . $this->db->prefix() . $InfoFieldList[0]; |
|
7552 | + $sql = "SELECT ".$keyList; |
|
7553 | + $sql .= ' FROM '.$this->db->prefix().$InfoFieldList[0]; |
|
7554 | 7554 | if (!empty($InfoFieldList[4])) { |
7555 | 7555 | // can use SELECT request |
7556 | 7556 | if (strpos($InfoFieldList[4], '$SEL$') !== false) { |
@@ -7566,23 +7566,23 @@ discard block |
||
7566 | 7566 | |
7567 | 7567 | // We have to join on extrafield table |
7568 | 7568 | if (strpos($InfoFieldList[4], 'extra') !== false) { |
7569 | - $sql .= ' as main, ' . $this->db->prefix() . $InfoFieldList[0] . '_extrafields as extra'; |
|
7570 | - $sqlwhere .= " WHERE extra.fk_object=main." . $InfoFieldList[2] . " AND " . $InfoFieldList[4]; |
|
7569 | + $sql .= ' as main, '.$this->db->prefix().$InfoFieldList[0].'_extrafields as extra'; |
|
7570 | + $sqlwhere .= " WHERE extra.fk_object=main.".$InfoFieldList[2]." AND ".$InfoFieldList[4]; |
|
7571 | 7571 | } else { |
7572 | - $sqlwhere .= " WHERE " . $InfoFieldList[4]; |
|
7572 | + $sqlwhere .= " WHERE ".$InfoFieldList[4]; |
|
7573 | 7573 | } |
7574 | 7574 | } else { |
7575 | 7575 | $sqlwhere .= ' WHERE 1=1'; |
7576 | 7576 | } |
7577 | 7577 | // Some tables may have field, some other not. For the moment we disable it. |
7578 | 7578 | if (in_array($InfoFieldList[0], array('tablewithentity'))) { |
7579 | - $sqlwhere .= " AND entity = " . ((int) $conf->entity); |
|
7579 | + $sqlwhere .= " AND entity = ".((int) $conf->entity); |
|
7580 | 7580 | } |
7581 | 7581 | // $sql.=preg_replace('/^ AND /','',$sqlwhere); |
7582 | 7582 | // print $sql; |
7583 | 7583 | |
7584 | 7584 | $sql .= $sqlwhere; |
7585 | - dol_syslog(get_class($this) . '::showInputField type=chkbxlst', LOG_DEBUG); |
|
7585 | + dol_syslog(get_class($this).'::showInputField type=chkbxlst', LOG_DEBUG); |
|
7586 | 7586 | $resql = $this->db->query($sql); |
7587 | 7587 | if ($resql) { |
7588 | 7588 | $num = $this->db->num_rows($resql); |
@@ -7600,7 +7600,7 @@ discard block |
||
7600 | 7600 | if (count($fields_label) > 1) { |
7601 | 7601 | $notrans = true; |
7602 | 7602 | foreach ($fields_label as $field_toshow) { |
7603 | - $labeltoshow .= $obj->$field_toshow . ' '; |
|
7603 | + $labeltoshow .= $obj->$field_toshow.' '; |
|
7604 | 7604 | } |
7605 | 7605 | } else { |
7606 | 7606 | $labeltoshow = $obj->{$InfoFieldList[1]}; |
@@ -7611,9 +7611,9 @@ discard block |
||
7611 | 7611 | foreach ($fields_label as $field_toshow) { |
7612 | 7612 | $translabel = $langs->trans($obj->$field_toshow); |
7613 | 7613 | if ($translabel != $obj->$field_toshow) { |
7614 | - $labeltoshow = dol_trunc($translabel, 18) . ' '; |
|
7614 | + $labeltoshow = dol_trunc($translabel, 18).' '; |
|
7615 | 7615 | } else { |
7616 | - $labeltoshow = dol_trunc($obj->$field_toshow, 18) . ' '; |
|
7616 | + $labeltoshow = dol_trunc($obj->$field_toshow, 18).' '; |
|
7617 | 7617 | } |
7618 | 7618 | } |
7619 | 7619 | |
@@ -7636,7 +7636,7 @@ discard block |
||
7636 | 7636 | } |
7637 | 7637 | |
7638 | 7638 | if (!empty($InfoFieldList[3]) && $parentField) { |
7639 | - $parent = $parentName . ':' . $obj->{$parentField}; |
|
7639 | + $parent = $parentName.':'.$obj->{$parentField}; |
|
7640 | 7640 | $isDependList = 1; |
7641 | 7641 | } |
7642 | 7642 | |
@@ -7647,14 +7647,14 @@ discard block |
||
7647 | 7647 | } |
7648 | 7648 | $this->db->free($resql); |
7649 | 7649 | |
7650 | - $out = $form->multiselectarray($keyprefix . $key . $keysuffix, $data, $value_arr, '', 0, $morecss, 0, '100%'); |
|
7650 | + $out = $form->multiselectarray($keyprefix.$key.$keysuffix, $data, $value_arr, '', 0, $morecss, 0, '100%'); |
|
7651 | 7651 | } else { |
7652 | - print 'Error in request ' . $sql . ' ' . $this->db->lasterror() . '. Check setup of extra parameters.<br>'; |
|
7652 | + print 'Error in request '.$sql.' '.$this->db->lasterror().'. Check setup of extra parameters.<br>'; |
|
7653 | 7653 | } |
7654 | 7654 | } else { |
7655 | 7655 | require_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php'; |
7656 | 7656 | $data = $form->select_all_categories(Categorie::$MAP_ID_TO_CODE[$InfoFieldList[5]], '', 'parent', 64, $InfoFieldList[6], 1, 1); |
7657 | - $out = $form->multiselectarray($keyprefix . $key . $keysuffix, $data, $value_arr, '', 0, $morecss, 0, '100%'); |
|
7657 | + $out = $form->multiselectarray($keyprefix.$key.$keysuffix, $data, $value_arr, '', 0, $morecss, 0, '100%'); |
|
7658 | 7658 | } |
7659 | 7659 | } |
7660 | 7660 | } elseif ($type == 'link') { |
@@ -7740,7 +7740,7 @@ discard block |
||
7740 | 7740 | $out = '<input type="hidden" value="'.$value.'" name="'.$keyprefix.$key.$keysuffix.'" id="'.$keyprefix.$key.$keysuffix.'"/>'; |
7741 | 7741 | } |
7742 | 7742 | |
7743 | - if ($isDependList==1) { |
|
7743 | + if ($isDependList == 1) { |
|
7744 | 7744 | $out .= $this->getJSListDependancies('_common'); |
7745 | 7745 | } |
7746 | 7746 | /* Add comments |
@@ -7791,7 +7791,7 @@ discard block |
||
7791 | 7791 | $type = 'varchar'; // convert varchar(xx) int varchar |
7792 | 7792 | } |
7793 | 7793 | if (!empty($val['arrayofkeyval']) && is_array($val['arrayofkeyval'])) { |
7794 | - $type = (($this->fields[$key]['type']=='checkbox') ? $this->fields[$key]['type'] : 'select'); |
|
7794 | + $type = (($this->fields[$key]['type'] == 'checkbox') ? $this->fields[$key]['type'] : 'select'); |
|
7795 | 7795 | } |
7796 | 7796 | if (preg_match('/^integer:(.*):(.*)/i', $val['type'], $reg)) { |
7797 | 7797 | $type = 'link'; |
@@ -7876,7 +7876,7 @@ discard block |
||
7876 | 7876 | $value = $this->getLibStatut(3); |
7877 | 7877 | } elseif ($type == 'date') { |
7878 | 7878 | if (!empty($value)) { |
7879 | - $value = dol_print_date($value, 'day'); // We suppose dates without time are always gmt (storage of course + output) |
|
7879 | + $value = dol_print_date($value, 'day'); // We suppose dates without time are always gmt (storage of course + output) |
|
7880 | 7880 | } else { |
7881 | 7881 | $value = ''; |
7882 | 7882 | } |
@@ -7974,9 +7974,9 @@ discard block |
||
7974 | 7974 | $translabel = $langs->trans($obj->$field_toshow); |
7975 | 7975 | } |
7976 | 7976 | if ($translabel != $field_toshow) { |
7977 | - $value .= dol_trunc($translabel, 18) . ' '; |
|
7977 | + $value .= dol_trunc($translabel, 18).' '; |
|
7978 | 7978 | } else { |
7979 | - $value .= $obj->$field_toshow . ' '; |
|
7979 | + $value .= $obj->$field_toshow.' '; |
|
7980 | 7980 | } |
7981 | 7981 | } |
7982 | 7982 | } else { |
@@ -7992,7 +7992,7 @@ discard block |
||
7992 | 7992 | } |
7993 | 7993 | } |
7994 | 7994 | } else { |
7995 | - require_once DOL_DOCUMENT_ROOT . '/categories/class/categorie.class.php'; |
|
7995 | + require_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php'; |
|
7996 | 7996 | |
7997 | 7997 | $toprint = array(); |
7998 | 7998 | $obj = $this->db->fetch_object($resql); |
@@ -8000,7 +8000,7 @@ discard block |
||
8000 | 8000 | $c->fetch($obj->rowid); |
8001 | 8001 | $ways = $c->print_all_ways(); // $ways[0] = "ccc2 >> ccc2a >> ccc2a1" with html formatted text |
8002 | 8002 | foreach ($ways as $way) { |
8003 | - $toprint[] = '<li class="select2-search-choice-dolibarr noborderoncategories"' . ($c->color ? ' style="background: #' . $c->color . ';"' : ' style="background: #aaa"') . '>' . img_object('', 'category') . ' ' . $way . '</li>'; |
|
8003 | + $toprint[] = '<li class="select2-search-choice-dolibarr noborderoncategories"'.($c->color ? ' style="background: #'.$c->color.';"' : ' style="background: #aaa"').'>'.img_object('', 'category').' '.$way.'</li>'; |
|
8004 | 8004 | } |
8005 | 8005 | $value = '<div class="select2-container-multi-dolibarr" style="width: 90%;"><ul class="select2-choices-dolibarr">'.implode(' ', $toprint).'</ul></div>'; |
8006 | 8006 | } |
@@ -8016,11 +8016,11 @@ discard block |
||
8016 | 8016 | $toprint = array(); |
8017 | 8017 | foreach ($value_arr as $keyval => $valueval) { |
8018 | 8018 | if (!empty($valueval)) { |
8019 | - $toprint[] = '<li class="select2-search-choice-dolibarr noborderoncategories" style="background: #bbb">' . $param['options'][$valueval] . '</li>'; |
|
8019 | + $toprint[] = '<li class="select2-search-choice-dolibarr noborderoncategories" style="background: #bbb">'.$param['options'][$valueval].'</li>'; |
|
8020 | 8020 | } |
8021 | 8021 | } |
8022 | 8022 | if (!empty($toprint)) { |
8023 | - $value = '<div class="select2-container-multi-dolibarr" style="width: 90%;"><ul class="select2-choices-dolibarr">' . implode(' ', $toprint) . '</ul></div>'; |
|
8023 | + $value = '<div class="select2-container-multi-dolibarr" style="width: 90%;"><ul class="select2-choices-dolibarr">'.implode(' ', $toprint).'</ul></div>'; |
|
8024 | 8024 | } |
8025 | 8025 | } |
8026 | 8026 | } elseif ($type == 'chkbxlst') { |
@@ -8075,9 +8075,9 @@ discard block |
||
8075 | 8075 | $translabel = $langs->trans($obj->$field_toshow); |
8076 | 8076 | } |
8077 | 8077 | if ($translabel != $field_toshow) { |
8078 | - $toprint[] = '<li class="select2-search-choice-dolibarr noborderoncategories" style="background: #bbb">' . dol_trunc($translabel, 18) . '</li>'; |
|
8078 | + $toprint[] = '<li class="select2-search-choice-dolibarr noborderoncategories" style="background: #bbb">'.dol_trunc($translabel, 18).'</li>'; |
|
8079 | 8079 | } else { |
8080 | - $toprint[] = '<li class="select2-search-choice-dolibarr noborderoncategories" style="background: #bbb">' . $obj->$field_toshow . '</li>'; |
|
8080 | + $toprint[] = '<li class="select2-search-choice-dolibarr noborderoncategories" style="background: #bbb">'.$obj->$field_toshow.'</li>'; |
|
8081 | 8081 | } |
8082 | 8082 | } |
8083 | 8083 | } else { |
@@ -8086,15 +8086,15 @@ discard block |
||
8086 | 8086 | $translabel = $langs->trans($obj->{$InfoFieldList[1]}); |
8087 | 8087 | } |
8088 | 8088 | if ($translabel != $obj->{$InfoFieldList[1]}) { |
8089 | - $toprint[] = '<li class="select2-search-choice-dolibarr noborderoncategories" style="background: #bbb">' . dol_trunc($translabel, 18) . '</li>'; |
|
8089 | + $toprint[] = '<li class="select2-search-choice-dolibarr noborderoncategories" style="background: #bbb">'.dol_trunc($translabel, 18).'</li>'; |
|
8090 | 8090 | } else { |
8091 | - $toprint[] = '<li class="select2-search-choice-dolibarr noborderoncategories" style="background: #bbb">' . $obj->{$InfoFieldList[1]} . '</li>'; |
|
8091 | + $toprint[] = '<li class="select2-search-choice-dolibarr noborderoncategories" style="background: #bbb">'.$obj->{$InfoFieldList[1]}.'</li>'; |
|
8092 | 8092 | } |
8093 | 8093 | } |
8094 | 8094 | } |
8095 | 8095 | } |
8096 | 8096 | } else { |
8097 | - require_once DOL_DOCUMENT_ROOT . '/categories/class/categorie.class.php'; |
|
8097 | + require_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php'; |
|
8098 | 8098 | |
8099 | 8099 | $toprint = array(); |
8100 | 8100 | while ($obj = $this->db->fetch_object($resql)) { |
@@ -8103,7 +8103,7 @@ discard block |
||
8103 | 8103 | $c->fetch($obj->rowid); |
8104 | 8104 | $ways = $c->print_all_ways(); // $ways[0] = "ccc2 >> ccc2a >> ccc2a1" with html formatted text |
8105 | 8105 | foreach ($ways as $way) { |
8106 | - $toprint[] = '<li class="select2-search-choice-dolibarr noborderoncategories"' . ($c->color ? ' style="background: #' . $c->color . ';"' : ' style="background: #aaa"') . '>' . img_object('', 'category') . ' ' . $way . '</li>'; |
|
8106 | + $toprint[] = '<li class="select2-search-choice-dolibarr noborderoncategories"'.($c->color ? ' style="background: #'.$c->color.';"' : ' style="background: #aaa"').'>'.img_object('', 'category').' '.$way.'</li>'; |
|
8107 | 8107 | } |
8108 | 8108 | } |
8109 | 8109 | } |
@@ -8250,7 +8250,7 @@ discard block |
||
8250 | 8250 | global $langs; |
8251 | 8251 | |
8252 | 8252 | if (!class_exists('Validate')) { |
8253 | - require_once DOL_DOCUMENT_ROOT . '/core/class/validate.class.php'; |
|
8253 | + require_once DOL_DOCUMENT_ROOT.'/core/class/validate.class.php'; |
|
8254 | 8254 | } |
8255 | 8255 | |
8256 | 8256 | $this->clearFieldError($fieldKey); |
@@ -8482,7 +8482,7 @@ discard block |
||
8482 | 8482 | $out .= "\n"; |
8483 | 8483 | |
8484 | 8484 | $nbofextrafieldsshown = 0; |
8485 | - $e = 0; // var to manage the modulo (odd/even) |
|
8485 | + $e = 0; // var to manage the modulo (odd/even) |
|
8486 | 8486 | |
8487 | 8487 | $lastseparatorkeyfound = ''; |
8488 | 8488 | $extrafields_collapse_num = ''; |
@@ -8533,7 +8533,7 @@ discard block |
||
8533 | 8533 | } |
8534 | 8534 | |
8535 | 8535 | $colspan = 0; |
8536 | - if (is_array($params) && count($params) > 0 && $display_type=='card') { |
|
8536 | + if (is_array($params) && count($params) > 0 && $display_type == 'card') { |
|
8537 | 8537 | if (array_key_exists('cols', $params)) { |
8538 | 8538 | $colspan = $params['cols']; |
8539 | 8539 | } elseif (array_key_exists('colspan', $params)) { // For backward compatibility. Use cols instead now. |
@@ -8620,7 +8620,7 @@ discard block |
||
8620 | 8620 | $domData .= ' data-targetid="'.$this->id.'"'; |
8621 | 8621 | |
8622 | 8622 | $html_id = (empty($this->id) ? '' : 'extrarow-'.$this->element.'_'.$key.'_'.$this->id); |
8623 | - if ($display_type=='card') { |
|
8623 | + if ($display_type == 'card') { |
|
8624 | 8624 | if (getDolGlobalString('MAIN_EXTRAFIELDS_USE_TWO_COLUMS') && ($e % 2) == 0) { |
8625 | 8625 | $colspan = 0; |
8626 | 8626 | } |
@@ -8731,12 +8731,12 @@ discard block |
||
8731 | 8731 | break; |
8732 | 8732 | } |
8733 | 8733 | |
8734 | - $out .= ($display_type=='card' ? '</td>' : '</div>'); |
|
8734 | + $out .= ($display_type == 'card' ? '</td>' : '</div>'); |
|
8735 | 8735 | |
8736 | 8736 | if (getDolGlobalString('MAIN_EXTRAFIELDS_USE_TWO_COLUMS') && (($e % 2) == 1)) { |
8737 | - $out .= ($display_type=='card' ? '</tr>' : '</div>'); |
|
8737 | + $out .= ($display_type == 'card' ? '</tr>' : '</div>'); |
|
8738 | 8738 | } else { |
8739 | - $out .= ($display_type=='card' ? '</tr>' : '</div>'); |
|
8739 | + $out .= ($display_type == 'card' ? '</tr>' : '</div>'); |
|
8740 | 8740 | } |
8741 | 8741 | |
8742 | 8742 | $e++; |
@@ -9540,7 +9540,7 @@ discard block |
||
9540 | 9540 | continue; |
9541 | 9541 | } |
9542 | 9542 | } |
9543 | - $keys_with_alias[] = $alias . '.' . $fieldname; |
|
9543 | + $keys_with_alias[] = $alias.'.'.$fieldname; |
|
9544 | 9544 | } |
9545 | 9545 | return implode(',', $keys_with_alias); |
9546 | 9546 | } else { |
@@ -9660,7 +9660,7 @@ discard block |
||
9660 | 9660 | if (!$error) { |
9661 | 9661 | $sql = "INSERT INTO ".$this->db->prefix().$this->table_element; |
9662 | 9662 | $sql .= " (".implode(", ", $keys).')'; |
9663 | - $sql .= " VALUES (".implode(", ", $values).")"; // $values can contains 'abc' or 123 |
|
9663 | + $sql .= " VALUES (".implode(", ", $values).")"; // $values can contains 'abc' or 123 |
|
9664 | 9664 | |
9665 | 9665 | $res = $this->db->query($sql); |
9666 | 9666 | if (!$res) { |
@@ -9945,7 +9945,7 @@ discard block |
||
9945 | 9945 | |
9946 | 9946 | // Update extrafield |
9947 | 9947 | if (!$error) { |
9948 | - $result = $this->insertExtraFields(); // This delete and reinsert extrafields |
|
9948 | + $result = $this->insertExtraFields(); // This delete and reinsert extrafields |
|
9949 | 9949 | if ($result < 0) { |
9950 | 9950 | $error++; |
9951 | 9951 | } |
@@ -10153,12 +10153,12 @@ discard block |
||
10153 | 10153 | $error++; |
10154 | 10154 | } else { |
10155 | 10155 | while ($obj = $this->db->fetch_object($resql)) { |
10156 | - $result = $this->fetch($obj->rowid); // @phpstan-ignore-line |
|
10156 | + $result = $this->fetch($obj->rowid); // @phpstan-ignore-line |
|
10157 | 10157 | if ($result < 0) { |
10158 | 10158 | $error++; |
10159 | 10159 | $this->errors[] = $this->error; |
10160 | 10160 | } else { |
10161 | - $result = $this->delete($user); // @phpstan-ignore-line |
|
10161 | + $result = $this->delete($user); // @phpstan-ignore-line |
|
10162 | 10162 | if ($result < 0) { |
10163 | 10163 | $error++; |
10164 | 10164 | $this->errors[] = $this->error; |
@@ -10323,7 +10323,7 @@ discard block |
||
10323 | 10323 | ); |
10324 | 10324 | foreach ($fields as $key => $value) { |
10325 | 10325 | if (array_key_exists($key, $this->fields)) { |
10326 | - $this->{$key} = $value; // @phpstan-ignore-line |
|
10326 | + $this->{$key} = $value; // @phpstan-ignore-line |
|
10327 | 10327 | } |
10328 | 10328 | } |
10329 | 10329 | |
@@ -10468,7 +10468,7 @@ discard block |
||
10468 | 10468 | // Process |
10469 | 10469 | foreach ($to_del as $del) { |
10470 | 10470 | if ($c->fetch($del) > 0) { |
10471 | - $result=$c->del_type($this, $type_categ); |
|
10471 | + $result = $c->del_type($this, $type_categ); |
|
10472 | 10472 | if ($result < 0) { |
10473 | 10473 | $error++; |
10474 | 10474 | $this->error = $c->error; |
@@ -100,10 +100,10 @@ discard block |
||
100 | 100 | function dolGetRandomBytes($length) |
101 | 101 | { |
102 | 102 | if (function_exists('random_bytes')) { // Available with PHP 7 only. |
103 | - return bin2hex(random_bytes((int) floor($length / 2))); // the bin2hex will double the number of bytes so we take length / 2 |
|
103 | + return bin2hex(random_bytes((int) floor($length / 2))); // the bin2hex will double the number of bytes so we take length / 2 |
|
104 | 104 | } |
105 | 105 | |
106 | - return bin2hex(openssl_random_pseudo_bytes((int) floor($length / 2))); // the bin2hex will double the number of bytes so we take length / 2. May be very slow on Windows. |
|
106 | + return bin2hex(openssl_random_pseudo_bytes((int) floor($length / 2))); // the bin2hex will double the number of bytes so we take length / 2. May be very slow on Windows. |
|
107 | 107 | } |
108 | 108 | |
109 | 109 | /** |
@@ -241,7 +241,7 @@ discard block |
||
241 | 241 | |
242 | 242 | // Salt value |
243 | 243 | if (getDolGlobalString('MAIN_SECURITY_SALT') && $type != '4' && $type !== 'openldap') { |
244 | - $chain = getDolGlobalString('MAIN_SECURITY_SALT') . $chain; |
|
244 | + $chain = getDolGlobalString('MAIN_SECURITY_SALT').$chain; |
|
245 | 245 | } |
246 | 246 | |
247 | 247 | if ($type == '1' || $type == 'sha1') { |
@@ -281,7 +281,7 @@ discard block |
||
281 | 281 | function dol_verifyHash($chain, $hash, $type = '0') |
282 | 282 | { |
283 | 283 | if ($type == '0' && getDolGlobalString('MAIN_SECURITY_HASH_ALGO') && getDolGlobalString('MAIN_SECURITY_HASH_ALGO') == 'password_hash' && function_exists('password_verify')) { |
284 | - if (! empty($hash[0]) && $hash[0] == '$') { |
|
284 | + if (!empty($hash[0]) && $hash[0] == '$') { |
|
285 | 285 | return password_verify($chain, $hash); |
286 | 286 | } elseif (dol_strlen($hash) == 32) { |
287 | 287 | return dol_verifyHash($chain, $hash, '3'); // md5 |
@@ -311,31 +311,31 @@ discard block |
||
311 | 311 | $salt = substr(sha1(time()), 0, 8); |
312 | 312 | |
313 | 313 | if ($type === 'md5') { |
314 | - return '{MD5}' . base64_encode(hash("md5", $password, true)); //For OpenLdap with md5 (based on an unencrypted password in base) |
|
314 | + return '{MD5}'.base64_encode(hash("md5", $password, true)); //For OpenLdap with md5 (based on an unencrypted password in base) |
|
315 | 315 | } elseif ($type === 'md5frommd5') { |
316 | - return '{MD5}' . base64_encode(hex2bin($password)); // Create OpenLDAP MD5 password from Dolibarr MD5 password |
|
316 | + return '{MD5}'.base64_encode(hex2bin($password)); // Create OpenLDAP MD5 password from Dolibarr MD5 password |
|
317 | 317 | } elseif ($type === 'smd5') { |
318 | - return "{SMD5}" . base64_encode(hash("md5", $password . $salt, true) . $salt); |
|
318 | + return "{SMD5}".base64_encode(hash("md5", $password.$salt, true).$salt); |
|
319 | 319 | } elseif ($type === 'sha') { |
320 | - return '{SHA}' . base64_encode(hash("sha1", $password, true)); |
|
320 | + return '{SHA}'.base64_encode(hash("sha1", $password, true)); |
|
321 | 321 | } elseif ($type === 'ssha') { |
322 | - return "{SSHA}" . base64_encode(hash("sha1", $password . $salt, true) . $salt); |
|
322 | + return "{SSHA}".base64_encode(hash("sha1", $password.$salt, true).$salt); |
|
323 | 323 | } elseif ($type === 'sha256') { |
324 | - return "{SHA256}" . base64_encode(hash("sha256", $password, true)); |
|
324 | + return "{SHA256}".base64_encode(hash("sha256", $password, true)); |
|
325 | 325 | } elseif ($type === 'ssha256') { |
326 | - return "{SSHA256}" . base64_encode(hash("sha256", $password . $salt, true) . $salt); |
|
326 | + return "{SSHA256}".base64_encode(hash("sha256", $password.$salt, true).$salt); |
|
327 | 327 | } elseif ($type === 'sha384') { |
328 | - return "{SHA384}" . base64_encode(hash("sha384", $password, true)); |
|
328 | + return "{SHA384}".base64_encode(hash("sha384", $password, true)); |
|
329 | 329 | } elseif ($type === 'ssha384') { |
330 | - return "{SSHA384}" . base64_encode(hash("sha384", $password . $salt, true) . $salt); |
|
330 | + return "{SSHA384}".base64_encode(hash("sha384", $password.$salt, true).$salt); |
|
331 | 331 | } elseif ($type === 'sha512') { |
332 | - return "{SHA512}" . base64_encode(hash("sha512", $password, true)); |
|
332 | + return "{SHA512}".base64_encode(hash("sha512", $password, true)); |
|
333 | 333 | } elseif ($type === 'ssha512') { |
334 | - return "{SSHA512}" . base64_encode(hash("sha512", $password . $salt, true) . $salt); |
|
334 | + return "{SSHA512}".base64_encode(hash("sha512", $password.$salt, true).$salt); |
|
335 | 335 | } elseif ($type === 'crypt') { |
336 | - return '{CRYPT}' . crypt($password, $salt); |
|
336 | + return '{CRYPT}'.crypt($password, $salt); |
|
337 | 337 | } elseif ($type === 'clear') { |
338 | - return '{CLEAR}' . $password; // Just for test, plain text password is not secured ! |
|
338 | + return '{CLEAR}'.$password; // Just for test, plain text password is not secured ! |
|
339 | 339 | } |
340 | 340 | return ""; |
341 | 341 | } |
@@ -369,13 +369,13 @@ discard block |
||
369 | 369 | if (is_object($object)) { |
370 | 370 | $objectid = $object->id; |
371 | 371 | } else { |
372 | - $objectid = $object; // $objectid can be X or 'X,Y,Z' |
|
372 | + $objectid = $object; // $objectid can be X or 'X,Y,Z' |
|
373 | 373 | } |
374 | 374 | if ($objectid == "-1") { |
375 | 375 | $objectid = 0; |
376 | 376 | } |
377 | 377 | if ($objectid) { |
378 | - $objectid = preg_replace('/[^0-9\.\,]/', '', $objectid); // For the case value is coming from a non sanitized user input |
|
378 | + $objectid = preg_replace('/[^0-9\.\,]/', '', $objectid); // For the case value is coming from a non sanitized user input |
|
379 | 379 | } |
380 | 380 | |
381 | 381 | //dol_syslog("functions.lib:restrictedArea $feature, $objectid, $dbtablename, $feature2, $dbt_socfield, $dbt_select, $isdraft"); |
@@ -852,9 +852,9 @@ discard block |
||
852 | 852 | if (is_object($object)) { |
853 | 853 | $objectid = $object->id; |
854 | 854 | } else { |
855 | - $objectid = $object; // $objectid can be X or 'X,Y,Z' |
|
855 | + $objectid = $object; // $objectid can be X or 'X,Y,Z' |
|
856 | 856 | } |
857 | - $objectid = preg_replace('/[^0-9\.\,]/', '', $objectid); // For the case value is coming from a non sanitized user input |
|
857 | + $objectid = preg_replace('/[^0-9\.\,]/', '', $objectid); // For the case value is coming from a non sanitized user input |
|
858 | 858 | |
859 | 859 | //dol_syslog("functions.lib:restrictedArea $feature, $objectid, $dbtablename, $feature2, $dbt_socfield, $dbt_select, $isdraft"); |
860 | 860 | //print "user_id=".$user->id.", features=".join(',', $featuresarray).", objectid=".$objectid; |
@@ -901,8 +901,8 @@ discard block |
||
901 | 901 | $checkparentsoc = array('agenda', 'contact', 'contrat'); // Test on entity + link to third party on field $dbt_keyfield. Allowed if link is empty (Ex: contacts...). |
902 | 902 | $checkproject = array('projet', 'project'); // Test for project object |
903 | 903 | $checktask = array('projet_task'); // Test for task object |
904 | - $checkhierarchy = array('expensereport', 'holiday'); // check permission among the hierarchy of user |
|
905 | - $checkuser = array('bookmark'); // check permission among the fk_user (must be myself or null) |
|
904 | + $checkhierarchy = array('expensereport', 'holiday'); // check permission among the hierarchy of user |
|
905 | + $checkuser = array('bookmark'); // check permission among the fk_user (must be myself or null) |
|
906 | 906 | $nocheck = array('barcode', 'stock'); // No test |
907 | 907 | |
908 | 908 | //$checkdefault = 'all other not already defined'; // Test on entity + link to third party on field $dbt_keyfield. Not allowed if link is empty (Ex: invoice, orders...). |
@@ -915,7 +915,7 @@ discard block |
||
915 | 915 | |
916 | 916 | // To avoid an access forbidden with a numeric ref |
917 | 917 | if ($dbt_select != 'rowid' && $dbt_select != 'id') { |
918 | - $objectid = "'".$objectid."'"; // Note: $objectid was already cast into int at begin of this method. |
|
918 | + $objectid = "'".$objectid."'"; // Note: $objectid was already cast into int at begin of this method. |
|
919 | 919 | } |
920 | 920 | // Check permission for objectid on entity only |
921 | 921 | if (in_array($feature, $check) && $objectid > 0) { // For $objectid = 0, no check |
@@ -156,7 +156,7 @@ discard block |
||
156 | 156 | define('REQUIRE_CKEDITOR', '1'); |
157 | 157 | } |
158 | 158 | |
159 | - $skin = getDolGlobalString('FCKEDITOR_SKIN', 'moono-lisa'); // default with ckeditor 4.6 : moono-lisa |
|
159 | + $skin = getDolGlobalString('FCKEDITOR_SKIN', 'moono-lisa'); // default with ckeditor 4.6 : moono-lisa |
|
160 | 160 | |
161 | 161 | $pluginstodisable = 'elementspath,save,flash,div,anchor'; |
162 | 162 | if (!getDolGlobalString('FCKEDITOR_ENABLE_SPECIALCHAR')) { |
@@ -172,7 +172,7 @@ discard block |
||
172 | 172 | $pluginstodisable .= ',exportpdf'; |
173 | 173 | } |
174 | 174 | if (getDolGlobalInt('MAIN_DISALLOW_URL_INTO_DESCRIPTIONS') == 2) { |
175 | - $this->uselocalbrowser = 0; // Can't use browser to navigate into files. Only links with "<img src=data:..." are allowed. |
|
175 | + $this->uselocalbrowser = 0; // Can't use browser to navigate into files. Only links with "<img src=data:..." are allowed. |
|
176 | 176 | } |
177 | 177 | $scaytautostartup = ''; |
178 | 178 | if (getDolGlobalString('FCKEDITOR_ENABLE_SCAYT_AUTOSTARTUP')) { |
@@ -245,10 +245,10 @@ discard block |
||
245 | 245 | filebrowserImageWindowWidth : \'900\', |
246 | 246 | filebrowserImageWindowHeight : \'500\''; |
247 | 247 | } |
248 | - $out .= ' })'.$morejs; // end CKEditor.replace |
|
248 | + $out .= ' })'.$morejs; // end CKEditor.replace |
|
249 | 249 | // Show the CKEditor javascript object once loaded is ready 'For debug) |
250 | 250 | //$out .= '; CKEDITOR.on(\'instanceReady\', function(ck) { ck.editor.removeMenuItem(\'maximize\'); ck.editor.removeMenuItem(\'Undo\'); ck.editor.removeMenuItem(\'undo\'); console.log(ck.editor); console.log(ck.editor.toolbar[0]); }); '; |
251 | - $out .= '});'."\n"; // end document.ready |
|
251 | + $out .= '});'."\n"; // end document.ready |
|
252 | 252 | $out .= '</script>'."\n"; |
253 | 253 | } |
254 | 254 | } |
@@ -268,8 +268,8 @@ discard block |
||
268 | 268 | $out .= '<script nonce="'.getNonce().'" type="text/javascript">'."\n"; |
269 | 269 | $out .= 'jQuery(document).ready(function() {'."\n"; |
270 | 270 | $out .= ' var aceEditor = window.ace.edit("'.$this->htmlname.'aceeditorid"); |
271 | - aceEditor.moveCursorTo('.($this->posy+1).','.$this->posx.'); |
|
272 | - aceEditor.gotoLine('.($this->posy+1).','.$this->posx.'); |
|
271 | + aceEditor.moveCursorTo('.($this->posy + 1).','.$this->posx.'); |
|
272 | + aceEditor.gotoLine('.($this->posy + 1).','.$this->posx.'); |
|
273 | 273 | var StatusBar = window.ace.require("ace/ext/statusbar").StatusBar; // Init status bar. Need lib ext-statusbar |
274 | 274 | var statusBar = new StatusBar(aceEditor, document.getElementById("statusBar'.$this->htmlname.'")); // Init status bar. Need lib ext-statusbar |
275 | 275 |
@@ -181,7 +181,7 @@ |
||
181 | 181 | |
182 | 182 | //var_dump($this->type);exit; |
183 | 183 | |
184 | - $pai->amounts[$facs[$i][0]] = price2num($amountrejected * -1); // The payment must be negative because it is a refund |
|
184 | + $pai->amounts[$facs[$i][0]] = price2num($amountrejected * -1); // The payment must be negative because it is a refund |
|
185 | 185 | |
186 | 186 | $pai->datepaye = $date_rejet; |
187 | 187 | $pai->paiementid = 3; // type of payment: withdrawal |
@@ -24,32 +24,32 @@ discard block |
||
24 | 24 | * \remarks To run this script as CLI: phpunit filename.php |
25 | 25 | */ |
26 | 26 | |
27 | -global $conf,$user,$langs,$db; |
|
27 | +global $conf, $user, $langs, $db; |
|
28 | 28 | //define('TEST_DB_FORCE_TYPE','mysql'); // This is to force using mysql driver |
29 | 29 | //require_once 'PHPUnit/Autoload.php'; |
30 | 30 | |
31 | -if (! defined('NOREQUIRESOC')) { |
|
31 | +if (!defined('NOREQUIRESOC')) { |
|
32 | 32 | define('NOREQUIRESOC', '1'); |
33 | 33 | } |
34 | -if (! defined('NOCSRFCHECK')) { |
|
34 | +if (!defined('NOCSRFCHECK')) { |
|
35 | 35 | define('NOCSRFCHECK', '1'); |
36 | 36 | } |
37 | -if (! defined('NOTOKENRENEWAL')) { |
|
37 | +if (!defined('NOTOKENRENEWAL')) { |
|
38 | 38 | define('NOTOKENRENEWAL', '1'); |
39 | 39 | } |
40 | -if (! defined('NOREQUIREMENU')) { |
|
40 | +if (!defined('NOREQUIREMENU')) { |
|
41 | 41 | define('NOREQUIREMENU', '1'); // If there is no menu to show |
42 | 42 | } |
43 | -if (! defined('NOREQUIREHTML')) { |
|
43 | +if (!defined('NOREQUIREHTML')) { |
|
44 | 44 | define('NOREQUIREHTML', '1'); // If we don't need to load the html.form.class.php |
45 | 45 | } |
46 | -if (! defined('NOREQUIREAJAX')) { |
|
46 | +if (!defined('NOREQUIREAJAX')) { |
|
47 | 47 | define('NOREQUIREAJAX', '1'); |
48 | 48 | } |
49 | -if (! defined("NOLOGIN")) { |
|
50 | - define("NOLOGIN", '1'); // If this page is public (can be called outside logged session) |
|
49 | +if (!defined("NOLOGIN")) { |
|
50 | + define("NOLOGIN", '1'); // If this page is public (can be called outside logged session) |
|
51 | 51 | } |
52 | -if (! defined("NOSESSION")) { |
|
52 | +if (!defined("NOSESSION")) { |
|
53 | 53 | define("NOSESSION", '1'); |
54 | 54 | } |
55 | 55 | |
@@ -63,7 +63,7 @@ discard block |
||
63 | 63 | $user->fetch(1); |
64 | 64 | $user->getrights(); |
65 | 65 | } |
66 | -$conf->global->MAIN_DISABLE_ALL_MAILS=1; |
|
66 | +$conf->global->MAIN_DISABLE_ALL_MAILS = 1; |
|
67 | 67 | |
68 | 68 | |
69 | 69 | /** |
@@ -92,11 +92,11 @@ discard block |
||
92 | 92 | parent::__construct($name); |
93 | 93 | |
94 | 94 | //$this->sharedFixture |
95 | - global $conf,$user,$langs,$db; |
|
96 | - $this->savconf=$conf; |
|
97 | - $this->savuser=$user; |
|
98 | - $this->savlangs=$langs; |
|
99 | - $this->savdb=$db; |
|
95 | + global $conf, $user, $langs, $db; |
|
96 | + $this->savconf = $conf; |
|
97 | + $this->savuser = $user; |
|
98 | + $this->savlangs = $langs; |
|
99 | + $this->savdb = $db; |
|
100 | 100 | |
101 | 101 | print __METHOD__." db->type=".$db->type." user->id=".$user->id; |
102 | 102 | //print " - db ".$db->db; |
@@ -110,8 +110,8 @@ discard block |
||
110 | 110 | */ |
111 | 111 | public static function setUpBeforeClass(): void |
112 | 112 | { |
113 | - global $conf,$user,$langs,$db; |
|
114 | - $db->begin(); // This is to have all actions inside a transaction even if test launched without suite. |
|
113 | + global $conf, $user, $langs, $db; |
|
114 | + $db->begin(); // This is to have all actions inside a transaction even if test launched without suite. |
|
115 | 115 | |
116 | 116 | print __METHOD__."\n"; |
117 | 117 | } |
@@ -123,7 +123,7 @@ discard block |
||
123 | 123 | */ |
124 | 124 | public static function tearDownAfterClass(): void |
125 | 125 | { |
126 | - global $conf,$user,$langs,$db; |
|
126 | + global $conf, $user, $langs, $db; |
|
127 | 127 | $db->rollback(); |
128 | 128 | |
129 | 129 | // Restore value to a neutral value (it was set to a test value by some tests) |
@@ -139,11 +139,11 @@ discard block |
||
139 | 139 | */ |
140 | 140 | protected function setUp(): void |
141 | 141 | { |
142 | - global $conf,$user,$langs,$db; |
|
143 | - $conf=$this->savconf; |
|
144 | - $user=$this->savuser; |
|
145 | - $langs=$this->savlangs; |
|
146 | - $db=$this->savdb; |
|
142 | + global $conf, $user, $langs, $db; |
|
143 | + $conf = $this->savconf; |
|
144 | + $user = $this->savuser; |
|
145 | + $langs = $this->savlangs; |
|
146 | + $db = $this->savdb; |
|
147 | 147 | |
148 | 148 | print __METHOD__."\n"; |
149 | 149 | } |
@@ -166,7 +166,7 @@ discard block |
||
166 | 166 | public function testSetLang() |
167 | 167 | { |
168 | 168 | global $conf; |
169 | - $conf=$this->savconf; |
|
169 | + $conf = $this->savconf; |
|
170 | 170 | |
171 | 171 | $tmplangs = new Translate('', $conf); |
172 | 172 | |
@@ -188,7 +188,7 @@ discard block |
||
188 | 188 | // More on https://www.owasp.org/index.php/XSS_Filter_Evasion_Cheat_Sheet |
189 | 189 | |
190 | 190 | // Should be OK |
191 | - $expectedresult=0; |
|
191 | + $expectedresult = 0; |
|
192 | 192 | |
193 | 193 | /* |
194 | 194 | $test = ''; |
@@ -196,107 +196,107 @@ discard block |
||
196 | 196 | $this->assertGreaterThanOrEqual(0, $result, 'Error on testSqlAndScriptInject kkk'); |
197 | 197 | */ |
198 | 198 | |
199 | - $_SERVER["PHP_SELF"]='/DIR WITH SPACE/htdocs/admin/index.php'; |
|
200 | - $result=testSqlAndScriptInject($_SERVER["PHP_SELF"], 2); |
|
199 | + $_SERVER["PHP_SELF"] = '/DIR WITH SPACE/htdocs/admin/index.php'; |
|
200 | + $result = testSqlAndScriptInject($_SERVER["PHP_SELF"], 2); |
|
201 | 201 | $this->assertEquals($expectedresult, $result, 'Error on testSqlAndScriptInject for PHP_SELF that should be ok'); |
202 | 202 | |
203 | 203 | $test = 'This is a < inside string with < and > also and tag like <a> before the >'; |
204 | - $result=testSqlAndScriptInject($test, 0); |
|
204 | + $result = testSqlAndScriptInject($test, 0); |
|
205 | 205 | $this->assertEquals($expectedresult, $result, 'Error on testSqlAndScriptInject expected 0b'); |
206 | 206 | |
207 | 207 | $test = 'This is the union of all for the selection of the best'; |
208 | - $result=testSqlAndScriptInject($test, 0); |
|
208 | + $result = testSqlAndScriptInject($test, 0); |
|
209 | 209 | $this->assertEquals($expectedresult, $result, 'Error on testSqlAndScriptInject expected 0c'); |
210 | 210 | |
211 | - $test='/user/perms.php?id=1&action=addrights&entity=1&rights=123&confirm=yes&token=123456789&updatedmodulename=lmscoursetracking'; |
|
212 | - $result=testSqlAndScriptInject($test, 1); |
|
211 | + $test = '/user/perms.php?id=1&action=addrights&entity=1&rights=123&confirm=yes&token=123456789&updatedmodulename=lmscoursetracking'; |
|
212 | + $result = testSqlAndScriptInject($test, 1); |
|
213 | 213 | print "test=".$test." result=".$result."\n"; |
214 | 214 | $this->assertEquals($expectedresult, $result, 'Error on testSqlAndScriptInject with a valid url'); |
215 | 215 | |
216 | 216 | // Should detect attack |
217 | - $expectedresult=1; |
|
217 | + $expectedresult = 1; |
|
218 | 218 | |
219 | - $_SERVER["PHP_SELF"]='/DIR WITH SPACE/htdocs/admin/index.php/<svg>'; |
|
220 | - $result=testSqlAndScriptInject($_SERVER["PHP_SELF"], 2); |
|
219 | + $_SERVER["PHP_SELF"] = '/DIR WITH SPACE/htdocs/admin/index.php/<svg>'; |
|
220 | + $result = testSqlAndScriptInject($_SERVER["PHP_SELF"], 2); |
|
221 | 221 | $this->assertGreaterThanOrEqual($expectedresult, $result, 'Error on testSqlAndScriptInject for PHP_SELF that should detect XSS'); |
222 | 222 | |
223 | 223 | $test = 'select @@version'; |
224 | - $result=testSqlAndScriptInject($test, 0); |
|
224 | + $result = testSqlAndScriptInject($test, 0); |
|
225 | 225 | $this->assertEquals($expectedresult, $result, 'Error on testSqlAndScriptInject for SQL1a. Should find an attack on POST param and did not.'); |
226 | 226 | |
227 | 227 | $test = 'select @@version'; |
228 | - $result=testSqlAndScriptInject($test, 1); |
|
228 | + $result = testSqlAndScriptInject($test, 1); |
|
229 | 229 | $this->assertEquals($expectedresult, $result, 'Error on testSqlAndScriptInject for SQL1b. Should find an attack on GET param and did not.'); |
230 | 230 | |
231 | 231 | $test = '... update ... set ... ='; |
232 | - $result=testSqlAndScriptInject($test, 1); |
|
232 | + $result = testSqlAndScriptInject($test, 1); |
|
233 | 233 | $this->assertEquals($expectedresult, $result, 'Error on testSqlAndScriptInject for SQL2a. Should find an attack on GET param and did not.'); |
234 | 234 | |
235 | 235 | $test = "delete\nfrom"; |
236 | - $result=testSqlAndScriptInject($test, 1); |
|
236 | + $result = testSqlAndScriptInject($test, 1); |
|
237 | 237 | $this->assertEquals($expectedresult, $result, 'Error on testSqlAndScriptInject for SQL2b. Should find an attack on GET param and did not.'); |
238 | 238 | |
239 | 239 | $test = 'action=update& ... set ... ='; |
240 | - $result=testSqlAndScriptInject($test, 1); |
|
240 | + $result = testSqlAndScriptInject($test, 1); |
|
241 | 241 | $this->assertEquals(0, $result, 'Error on testSqlAndScriptInject for SQL2b. Should not find an attack on GET param and did.'); |
242 | 242 | |
243 | 243 | $test = '... union ... selection '; |
244 | - $result=testSqlAndScriptInject($test, 1); |
|
244 | + $result = testSqlAndScriptInject($test, 1); |
|
245 | 245 | $this->assertEquals($expectedresult, $result, 'Error on testSqlAndScriptInject for SQL2c. Should find an attack on GET param and did not.'); |
246 | 246 | |
247 | 247 | $test = 'javascript:'; |
248 | - $result=testSqlAndScriptInject($test, 0); |
|
248 | + $result = testSqlAndScriptInject($test, 0); |
|
249 | 249 | $this->assertEquals($expectedresult, $result, 'Error on testSqlAndScriptInject for javascript1. Should find an attack and did not.'); |
250 | 250 | |
251 | 251 | $test = 'javascript:'; |
252 | - $result=testSqlAndScriptInject($test, 0); |
|
252 | + $result = testSqlAndScriptInject($test, 0); |
|
253 | 253 | $this->assertEquals($expectedresult, $result, 'Error on testSqlAndScriptInject for javascript2. Should find an attack and did not.'); |
254 | 254 | |
255 | 255 | $test = 'javascript&colon;alert(1)'; |
256 | - $result=testSqlAndScriptInject($test, 0); |
|
256 | + $result = testSqlAndScriptInject($test, 0); |
|
257 | 257 | $this->assertEquals($expectedresult, $result, 'Error on testSqlAndScriptInject for javascript2'); |
258 | 258 | |
259 | - $test="<img src='1.jpg' onerror =javascript:alert('XSS')>"; |
|
260 | - $result=testSqlAndScriptInject($test, 0); |
|
259 | + $test = "<img src='1.jpg' onerror =javascript:alert('XSS')>"; |
|
260 | + $result = testSqlAndScriptInject($test, 0); |
|
261 | 261 | $this->assertGreaterThanOrEqual($expectedresult, $result, 'Error on testSqlAndScriptInject aaa1'); |
262 | 262 | |
263 | - $test="<img src='1.jpg' onerror =javascript:alert('XSS')>"; |
|
264 | - $result=testSqlAndScriptInject($test, 2); |
|
263 | + $test = "<img src='1.jpg' onerror =javascript:alert('XSS')>"; |
|
264 | + $result = testSqlAndScriptInject($test, 2); |
|
265 | 265 | $this->assertGreaterThanOrEqual($expectedresult, $result, 'Error on testSqlAndScriptInject aaa2'); |
266 | 266 | |
267 | - $test='<IMG SRC=# onmouseover="alert(1)">'; |
|
268 | - $result=testSqlAndScriptInject($test, 0); |
|
267 | + $test = '<IMG SRC=# onmouseover="alert(1)">'; |
|
268 | + $result = testSqlAndScriptInject($test, 0); |
|
269 | 269 | $this->assertGreaterThanOrEqual($expectedresult, $result, 'Error on testSqlAndScriptInject aaa3'); |
270 | - $test='<IMG SRC onmouseover="alert(1)">'; |
|
271 | - $result=testSqlAndScriptInject($test, 0); |
|
270 | + $test = '<IMG SRC onmouseover="alert(1)">'; |
|
271 | + $result = testSqlAndScriptInject($test, 0); |
|
272 | 272 | $this->assertGreaterThanOrEqual($expectedresult, $result, 'Error on testSqlAndScriptInject aaa4'); |
273 | - $test='<IMG onmouseover="alert(1)">'; |
|
274 | - $result=testSqlAndScriptInject($test, 0); |
|
273 | + $test = '<IMG onmouseover="alert(1)">'; |
|
274 | + $result = testSqlAndScriptInject($test, 0); |
|
275 | 275 | $this->assertGreaterThanOrEqual($expectedresult, $result, 'Error on testSqlAndScriptInject aaa5'); |
276 | - $test='<IMG SRC=/ onerror="alert(1)">'; |
|
277 | - $result=testSqlAndScriptInject($test, 0); |
|
276 | + $test = '<IMG SRC=/ onerror="alert(1)">'; |
|
277 | + $result = testSqlAndScriptInject($test, 0); |
|
278 | 278 | $this->assertGreaterThanOrEqual($expectedresult, $result, 'Error on testSqlAndScriptInject aaa6'); |
279 | - $test='<IMG SRC="  javascript:alert(1);">'; |
|
280 | - $result=testSqlAndScriptInject($test, 0); |
|
279 | + $test = '<IMG SRC="  javascript:alert(1);">'; |
|
280 | + $result = testSqlAndScriptInject($test, 0); |
|
281 | 281 | $this->assertGreaterThanOrEqual($expectedresult, $result, 'Error on testSqlAndScriptInject aaa7'); |
282 | 282 | |
283 | - $test='<IMG SRC=javascript:alert('XSS')>'; |
|
284 | - $result=testSqlAndScriptInject($test, 0); |
|
283 | + $test = '<IMG SRC=javascript:alert('XSS')>'; |
|
284 | + $result = testSqlAndScriptInject($test, 0); |
|
285 | 285 | $this->assertGreaterThanOrEqual($expectedresult, $result, 'Error on testSqlAndScriptInject bbb'); |
286 | 286 | |
287 | - $test='<SCRIPT SRC=http://xss.rocks/xss.js></SCRIPT>'; |
|
288 | - $result=testSqlAndScriptInject($test, 0); |
|
287 | + $test = '<SCRIPT SRC=http://xss.rocks/xss.js></SCRIPT>'; |
|
288 | + $result = testSqlAndScriptInject($test, 0); |
|
289 | 289 | $this->assertGreaterThanOrEqual($expectedresult, $result, 'Error on testSqlAndScriptInject ccc'); |
290 | 290 | |
291 | - $test='<IMG SRC="javascript:alert(\'XSS\');">'; |
|
292 | - $result=testSqlAndScriptInject($test, 1); |
|
291 | + $test = '<IMG SRC="javascript:alert(\'XSS\');">'; |
|
292 | + $result = testSqlAndScriptInject($test, 1); |
|
293 | 293 | $this->assertGreaterThanOrEqual($expectedresult, $result, 'Error on testSqlAndScriptInject ddd'); |
294 | 294 | |
295 | - $test='<IMG """><SCRIPT>alert("XSS")</SCRIPT>">'; |
|
296 | - $result=testSqlAndScriptInject($test, 0); |
|
295 | + $test = '<IMG """><SCRIPT>alert("XSS")</SCRIPT>">'; |
|
296 | + $result = testSqlAndScriptInject($test, 0); |
|
297 | 297 | $this->assertGreaterThanOrEqual($expectedresult, $result, 'Error on testSqlAndScriptInject eee'); |
298 | 298 | |
299 | - $test='<!-- Google analytics --> |
|
299 | + $test = '<!-- Google analytics --> |
|
300 | 300 | <script> |
301 | 301 | (function(i,s,o,g,r,a,m){i[\'GoogleAnalyticsObject\']=r;i[r]=i[r]||function(){ |
302 | 302 | (i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o), |
@@ -307,60 +307,60 @@ discard block |
||
307 | 307 | ga(\'send\', \'pageview\'); |
308 | 308 | |
309 | 309 | </script>'; |
310 | - $result=testSqlAndScriptInject($test, 0); |
|
310 | + $result = testSqlAndScriptInject($test, 0); |
|
311 | 311 | $this->assertGreaterThanOrEqual($expectedresult, $result, 'Error on testSqlAndScriptInject eee'); |
312 | 312 | |
313 | - $test="<IMG SRC=\"jav\tascript:alert('XSS');\">"; // Is locked by some browser like chrome because the default directive no-referrer-when-downgrade is sent when requesting the SRC and then refused because of browser protection on img src load without referrer. |
|
314 | - $test="<IMG SRC=\"jav
ascript:alert('XSS');\">"; // Same |
|
313 | + $test = "<IMG SRC=\"jav\tascript:alert('XSS');\">"; // Is locked by some browser like chrome because the default directive no-referrer-when-downgrade is sent when requesting the SRC and then refused because of browser protection on img src load without referrer. |
|
314 | + $test = "<IMG SRC=\"jav
ascript:alert('XSS');\">"; // Same |
|
315 | 315 | |
316 | - $test='<SCRIPT/XSS SRC="http://xss.rocks/xss.js"></SCRIPT>'; |
|
317 | - $result=testSqlAndScriptInject($test, 0); |
|
316 | + $test = '<SCRIPT/XSS SRC="http://xss.rocks/xss.js"></SCRIPT>'; |
|
317 | + $result = testSqlAndScriptInject($test, 0); |
|
318 | 318 | $this->assertGreaterThanOrEqual($expectedresult, $result, 'Error on testSqlAndScriptInject fff1'); |
319 | - $test='<SCRIPT/SRC="http://xss.rocks/xss.js"></SCRIPT>'; |
|
320 | - $result=testSqlAndScriptInject($test, 0); |
|
319 | + $test = '<SCRIPT/SRC="http://xss.rocks/xss.js"></SCRIPT>'; |
|
320 | + $result = testSqlAndScriptInject($test, 0); |
|
321 | 321 | $this->assertGreaterThanOrEqual($expectedresult, $result, 'Error on testSqlAndScriptInject fff2'); |
322 | 322 | |
323 | 323 | // This case seems to be filtered by browsers now. |
324 | - $test='<BODY onload!#$%&()*~+-_.,:;?@[/|\]^`=alert(1)>'; |
|
324 | + $test = '<BODY onload!#$%&()*~+-_.,:;?@[/|\]^`=alert(1)>'; |
|
325 | 325 | //$result=testSqlAndScriptInject($test, 0); |
326 | 326 | //$this->assertGreaterThanOrEqual($expectedresult, $result, 'Error on testSqlAndScriptInject ggg'); |
327 | 327 | |
328 | - $test='<iframe src=http://xss.rocks/scriptlet.html <'; |
|
329 | - $result=testSqlAndScriptInject($test, 0); |
|
328 | + $test = '<iframe src=http://xss.rocks/scriptlet.html <'; |
|
329 | + $result = testSqlAndScriptInject($test, 0); |
|
330 | 330 | $this->assertGreaterThanOrEqual($expectedresult, $result, 'Error on testSqlAndScriptInject hhh'); |
331 | 331 | |
332 | - $test='Set.constructor`alert\x281\x29```'; |
|
333 | - $result=testSqlAndScriptInject($test, 0); |
|
332 | + $test = 'Set.constructor`alert\x281\x29```'; |
|
333 | + $result = testSqlAndScriptInject($test, 0); |
|
334 | 334 | $this->assertGreaterThanOrEqual($expectedresult, $result, 'Error on testSqlAndScriptInject iii'); |
335 | 335 | |
336 | - $test="on<!-- ab\nc -->error=alert(1)"; |
|
337 | - $result=testSqlAndScriptInject($test, 0); |
|
336 | + $test = "on<!-- ab\nc -->error=alert(1)"; |
|
337 | + $result = testSqlAndScriptInject($test, 0); |
|
338 | 338 | $this->assertGreaterThanOrEqual($expectedresult, $result, 'Error on testSqlAndScriptInject jjj'); |
339 | 339 | |
340 | - $test="<img src=x one<a>rror=alert(document.location)"; |
|
341 | - $result=testSqlAndScriptInject($test, 0); |
|
340 | + $test = "<img src=x one<a>rror=alert(document.location)"; |
|
341 | + $result = testSqlAndScriptInject($test, 0); |
|
342 | 342 | $this->assertGreaterThanOrEqual($expectedresult, $result, 'Error on testSqlAndScriptInject kkk'); |
343 | 343 | |
344 | - $test="<a onpointerdown=alert(document.domain)>XSS</a>"; |
|
345 | - $result=testSqlAndScriptInject($test, 0); |
|
344 | + $test = "<a onpointerdown=alert(document.domain)>XSS</a>"; |
|
345 | + $result = testSqlAndScriptInject($test, 0); |
|
346 | 346 | $this->assertGreaterThanOrEqual($expectedresult, $result, 'Error on testSqlAndScriptInject lll'); |
347 | 347 | |
348 | - $test='<a onscrollend=alert(1) style="display:block;overflow:auto;border:1px+dashed;width:500px;height:100px;"><br><br><br><br><br><span+id=x>test</span></a>'; // Add the char %F6 into the variable |
|
349 | - $result=testSqlAndScriptInject($test, 0); |
|
348 | + $test = '<a onscrollend=alert(1) style="display:block;overflow:auto;border:1px+dashed;width:500px;height:100px;"><br><br><br><br><br><span+id=x>test</span></a>'; // Add the char %F6 into the variable |
|
349 | + $result = testSqlAndScriptInject($test, 0); |
|
350 | 350 | //print "test=".$test." result=".$result."\n"; |
351 | 351 | $this->assertGreaterThanOrEqual($expectedresult, $result, 'Error on testSqlAndScriptInject mmm'); |
352 | 352 | |
353 | 353 | |
354 | - $test="Text with ' encoded with the numeric html entity converted into text entity ' (like when submited by CKEditor)"; |
|
355 | - $result=testSqlAndScriptInject($test, 0); // result must be 0 |
|
354 | + $test = "Text with ' encoded with the numeric html entity converted into text entity ' (like when submited by CKEditor)"; |
|
355 | + $result = testSqlAndScriptInject($test, 0); // result must be 0 |
|
356 | 356 | $this->assertEquals(0, $result, 'Error on testSqlAndScriptInject mmm, result should be 0 and is not'); |
357 | 357 | |
358 | - $test ='<a href="j	a	v	asc
ri	pt:(a	l	e	r	t	(document.cookie))">XSS</a>'; |
|
359 | - $result=testSqlAndScriptInject($test, 0); |
|
358 | + $test = '<a href="j	a	v	asc
ri	pt:(a	l	e	r	t	(document.cookie))">XSS</a>'; |
|
359 | + $result = testSqlAndScriptInject($test, 0); |
|
360 | 360 | $this->assertGreaterThanOrEqual($expectedresult, $result, 'Error on testSqlAndScriptInject nnn, result should be >= 1 and is not'); |
361 | 361 | |
362 | - $test="/dolibarr/htdocs/index.php/".chr('246')."abc"; // Add the char %F6 into the variable |
|
363 | - $result=testSqlAndScriptInject($test, 2); |
|
362 | + $test = "/dolibarr/htdocs/index.php/".chr('246')."abc"; // Add the char %F6 into the variable |
|
363 | + $result = testSqlAndScriptInject($test, 2); |
|
364 | 364 | //print "test=".$test." result=".$result."\n"; |
365 | 365 | $this->assertGreaterThanOrEqual($expectedresult, $result, 'Error on testSqlAndScriptInject with a non valid UTF8 char'); |
366 | 366 | } |
@@ -372,11 +372,11 @@ discard block |
||
372 | 372 | */ |
373 | 373 | public function testGETPOST() |
374 | 374 | { |
375 | - global $conf,$user,$langs,$db; |
|
376 | - $conf=$this->savconf; |
|
377 | - $user=$this->savuser; |
|
378 | - $langs=$this->savlangs; |
|
379 | - $db=$this->savdb; |
|
375 | + global $conf, $user, $langs, $db; |
|
376 | + $conf = $this->savconf; |
|
377 | + $user = $this->savuser; |
|
378 | + $langs = $this->savlangs; |
|
379 | + $db = $this->savdb; |
|
380 | 380 | |
381 | 381 | // Force default mode |
382 | 382 | $conf->global->MAIN_RESTRICTHTML_ONLY_VALID_HTML = 0; |
@@ -384,206 +384,206 @@ discard block |
||
384 | 384 | $conf->global->MAIN_RESTRICTHTML_REMOVE_ALSO_BAD_ATTRIBUTES = 0; |
385 | 385 | $conf->global->MAIN_DISALLOW_URL_INTO_DESCRIPTIONS = 0; |
386 | 386 | |
387 | - $_COOKIE["id"]=111; |
|
388 | - $_POST["param0"]='A real string with <a href="rrr" title="aa"bb">aaa</a> and " and \' and & inside content'; |
|
389 | - $_GET["param1"]="222"; |
|
390 | - $_POST["param1"]="333"; |
|
391 | - $_GET["param2"]='a/b#e(pr)qq-rr\cc'; |
|
392 | - $_GET["param3"]='"na/b#e(pr)qq-rr\cc'; // Same than param2 + " and n |
|
393 | - $_GET["param4a"]='../../dir'; |
|
394 | - $_GET["param4b"]='..\..\dirwindows'; |
|
395 | - $_GET["param5"]="a_1-b"; |
|
396 | - $_POST["param6"]=""><svg onload='console.log("123")'>"; |
|
397 | - $_POST["param6b"]='<<<../>../>../svg><<<../>../>../animate =alert(1)>abc'; |
|
398 | - $_GET["param7"]='"c:\this is a path~1\aaan &#x110;" abc<bad>def</bad>'; |
|
399 | - $_POST["param8a"]="Hacker<svg onload='console.log("123")'"; // html tag is not closed so it is not detected as html tag but is still harmfull |
|
400 | - $_POST['param8b']='<img src=x onerror=alert(document.location) t='; // this is html obfuscated by non closing tag |
|
401 | - $_POST['param8c']='< with space after is ok'; |
|
402 | - $_POST['param8d']='<abc123 is html to clean'; |
|
403 | - $_POST['param8e']='<123abc is not html to clean'; // other similar case: '<2021-12-12' |
|
404 | - $_POST['param8f']='abc<<svg <><<animate onbegin=alert(document.domain) a'; |
|
405 | - $_POST["param9"]='is_object($object) ? ($object->id < 10 ? round($object->id / 2, 2) : (2 * $user->id) * (int) substr($mysoc->zip, 1, 2)) : \'objnotdefined\''; |
|
406 | - $_POST["param10"]='is_object($object) ? ($object->id < 10 ? round($object->id / 2, 2) : (2 * $user->id) * (int) substr($mysoc->zip, 1, 2)) : \'<abc>objnotdefined\''; |
|
407 | - $_POST["param11"]=' Name <[email protected]> '; |
|
408 | - $_POST["param12"]='<!DOCTYPE html><html>aaa</html>'; |
|
409 | - $_POST["param13"]='n n > < " <a href=\"javascript:alert(document.domain)\">XSS</a>'; |
|
410 | - $_POST["param13b"]='n n > < " <a href=\"javascript:alert(document.domain)\">XSS</a>'; |
|
411 | - $_POST["param14"]="Text with ' encoded with the numeric html entity converted into text entity ' (like when submited by CKEditor)"; |
|
412 | - $_POST["param15"]="<img onerror<=alert(document.domain)> src=>0xbeefed"; |
|
387 | + $_COOKIE["id"] = 111; |
|
388 | + $_POST["param0"] = 'A real string with <a href="rrr" title="aa"bb">aaa</a> and " and \' and & inside content'; |
|
389 | + $_GET["param1"] = "222"; |
|
390 | + $_POST["param1"] = "333"; |
|
391 | + $_GET["param2"] = 'a/b#e(pr)qq-rr\cc'; |
|
392 | + $_GET["param3"] = '"na/b#e(pr)qq-rr\cc'; // Same than param2 + " and n |
|
393 | + $_GET["param4a"] = '../../dir'; |
|
394 | + $_GET["param4b"] = '..\..\dirwindows'; |
|
395 | + $_GET["param5"] = "a_1-b"; |
|
396 | + $_POST["param6"] = ""><svg onload='console.log("123")'>"; |
|
397 | + $_POST["param6b"] = '<<<../>../>../svg><<<../>../>../animate =alert(1)>abc'; |
|
398 | + $_GET["param7"] = '"c:\this is a path~1\aaan &#x110;" abc<bad>def</bad>'; |
|
399 | + $_POST["param8a"] = "Hacker<svg onload='console.log("123")'"; // html tag is not closed so it is not detected as html tag but is still harmfull |
|
400 | + $_POST['param8b'] = '<img src=x onerror=alert(document.location) t='; // this is html obfuscated by non closing tag |
|
401 | + $_POST['param8c'] = '< with space after is ok'; |
|
402 | + $_POST['param8d'] = '<abc123 is html to clean'; |
|
403 | + $_POST['param8e'] = '<123abc is not html to clean'; // other similar case: '<2021-12-12' |
|
404 | + $_POST['param8f'] = 'abc<<svg <><<animate onbegin=alert(document.domain) a'; |
|
405 | + $_POST["param9"] = 'is_object($object) ? ($object->id < 10 ? round($object->id / 2, 2) : (2 * $user->id) * (int) substr($mysoc->zip, 1, 2)) : \'objnotdefined\''; |
|
406 | + $_POST["param10"] = 'is_object($object) ? ($object->id < 10 ? round($object->id / 2, 2) : (2 * $user->id) * (int) substr($mysoc->zip, 1, 2)) : \'<abc>objnotdefined\''; |
|
407 | + $_POST["param11"] = ' Name <[email protected]> '; |
|
408 | + $_POST["param12"] = '<!DOCTYPE html><html>aaa</html>'; |
|
409 | + $_POST["param13"] = 'n n > < " <a href=\"javascript:alert(document.domain)\">XSS</a>'; |
|
410 | + $_POST["param13b"] = 'n n > < " <a href=\"javascript:alert(document.domain)\">XSS</a>'; |
|
411 | + $_POST["param14"] = "Text with ' encoded with the numeric html entity converted into text entity ' (like when submited by CKEditor)"; |
|
412 | + $_POST["param15"] = "<img onerror<=alert(document.domain)> src=>0xbeefed"; |
|
413 | 413 | //$_POST["param15b"]="<html><head><title>Example HTML</title></head><body><div><p>This is a paragraph.</div><ul><li>Item 1</li><li>Item 2</li></ol></body><html>"; |
414 | - $_POST["param16"]='<a style="z-index: 1000">abc</a>'; |
|
415 | - $_POST["param17"]='<span style="background-image: url(logout.php)">abc</span>'; |
|
416 | - $_POST["param18"]='<span style="background-image: url(...?...action=aaa)">abc</span>'; |
|
417 | - $_POST["param19"]='<a href="j	a	v	asc
ri	pt:(alert(document.cookie))">XSS</a>'; |
|
414 | + $_POST["param16"] = '<a style="z-index: 1000">abc</a>'; |
|
415 | + $_POST["param17"] = '<span style="background-image: url(logout.php)">abc</span>'; |
|
416 | + $_POST["param18"] = '<span style="background-image: url(...?...action=aaa)">abc</span>'; |
|
417 | + $_POST["param19"] = '<a href="j	a	v	asc
ri	pt:(alert(document.cookie))">XSS</a>'; |
|
418 | 418 | //$_POST["param19"]='<a href="javascript:alert(document.cookie)">XSS</a>'; |
419 | 419 | |
420 | 420 | |
421 | 421 | |
422 | - $result=GETPOST('id', 'int'); // Must return nothing |
|
422 | + $result = GETPOST('id', 'int'); // Must return nothing |
|
423 | 423 | print __METHOD__." result=".$result."\n"; |
424 | 424 | $this->assertEquals('', $result); |
425 | 425 | |
426 | - $result=GETPOST("param1", 'int'); |
|
426 | + $result = GETPOST("param1", 'int'); |
|
427 | 427 | print __METHOD__." result=".$result."\n"; |
428 | 428 | $this->assertEquals(222, $result, 'Test on param1 with no 3rd param'); |
429 | 429 | |
430 | - $result=GETPOST("param1", 'int', 2); |
|
430 | + $result = GETPOST("param1", 'int', 2); |
|
431 | 431 | print __METHOD__." result=".$result."\n"; |
432 | 432 | $this->assertEquals(333, $result, 'Test on param1 with 3rd param = 2'); |
433 | 433 | |
434 | 434 | // Test with alpha |
435 | 435 | |
436 | - $result=GETPOST("param0", 'alpha'); // a simple format, so " completely removed |
|
436 | + $result = GETPOST("param0", 'alpha'); // a simple format, so " completely removed |
|
437 | 437 | $resultexpected = 'A real string with aaa and and \' and & inside content'; |
438 | 438 | print __METHOD__." result=".$result."\n"; |
439 | 439 | $this->assertEquals($resultexpected, $result, 'Test on param0'); |
440 | 440 | |
441 | - $result=GETPOST("param2", 'alpha'); |
|
441 | + $result = GETPOST("param2", 'alpha'); |
|
442 | 442 | print __METHOD__." result=".$result."\n"; |
443 | 443 | $this->assertEquals($result, $_GET["param2"], 'Test on param2'); |
444 | 444 | |
445 | - $result=GETPOST("param3", 'alpha'); // Must return string sanitized from char " |
|
445 | + $result = GETPOST("param3", 'alpha'); // Must return string sanitized from char " |
|
446 | 446 | print __METHOD__." result=".$result."\n"; |
447 | 447 | $this->assertEquals($result, 'na/b#e(pr)qq-rr\cc', 'Test on param3'); |
448 | 448 | |
449 | - $result=GETPOST("param4a", 'alpha'); // Must return string sanitized from ../ |
|
449 | + $result = GETPOST("param4a", 'alpha'); // Must return string sanitized from ../ |
|
450 | 450 | print __METHOD__." result=".$result."\n"; |
451 | 451 | $this->assertEquals($result, 'dir'); |
452 | 452 | |
453 | - $result=GETPOST("param4b", 'alpha'); // Must return string sanitized from ../ |
|
453 | + $result = GETPOST("param4b", 'alpha'); // Must return string sanitized from ../ |
|
454 | 454 | print __METHOD__." result=".$result."\n"; |
455 | 455 | $this->assertEquals($result, 'dirwindows'); |
456 | 456 | |
457 | 457 | // Test with aZ09 |
458 | 458 | |
459 | - $result=GETPOST("param1", 'aZ09'); |
|
459 | + $result = GETPOST("param1", 'aZ09'); |
|
460 | 460 | print __METHOD__." result=".$result."\n"; |
461 | 461 | $this->assertEquals($result, $_GET["param1"]); |
462 | 462 | |
463 | - $result=GETPOST("param2", 'aZ09'); // Must return '' as string contains car not in aZ09 definition |
|
463 | + $result = GETPOST("param2", 'aZ09'); // Must return '' as string contains car not in aZ09 definition |
|
464 | 464 | print __METHOD__." result=".$result."\n"; |
465 | 465 | $this->assertEquals($result, ''); |
466 | 466 | |
467 | - $result=GETPOST("param3", 'aZ09'); // Must return '' as string contains car not in aZ09 definition |
|
467 | + $result = GETPOST("param3", 'aZ09'); // Must return '' as string contains car not in aZ09 definition |
|
468 | 468 | print __METHOD__." result=".$result."\n"; |
469 | 469 | $this->assertEquals($result, ''); |
470 | 470 | |
471 | - $result=GETPOST("param4a", 'aZ09'); // Must return '' as string contains car not in aZ09 definition |
|
471 | + $result = GETPOST("param4a", 'aZ09'); // Must return '' as string contains car not in aZ09 definition |
|
472 | 472 | print __METHOD__." result=".$result."\n"; |
473 | 473 | $this->assertEquals('', $result); |
474 | 474 | |
475 | - $result=GETPOST("param4b", 'aZ09'); // Must return '' as string contains car not in aZ09 definition |
|
475 | + $result = GETPOST("param4b", 'aZ09'); // Must return '' as string contains car not in aZ09 definition |
|
476 | 476 | print __METHOD__." result=".$result."\n"; |
477 | 477 | $this->assertEquals('', $result); |
478 | 478 | |
479 | - $result=GETPOST("param5", 'aZ09'); |
|
479 | + $result = GETPOST("param5", 'aZ09'); |
|
480 | 480 | print __METHOD__." result=".$result."\n"; |
481 | 481 | $this->assertEquals($_GET["param5"], $result); |
482 | 482 | |
483 | 483 | // Test with nohtml |
484 | 484 | |
485 | - $result=GETPOST("param6", 'nohtml'); |
|
485 | + $result = GETPOST("param6", 'nohtml'); |
|
486 | 486 | print __METHOD__." result6=".$result."\n"; |
487 | 487 | $this->assertEquals('">', $result); |
488 | 488 | |
489 | 489 | // Test with alpha = alphanohtml. We must convert the html entities like n and disable all entities |
490 | 490 | |
491 | - $result=GETPOST("param6", 'alphanohtml'); |
|
491 | + $result = GETPOST("param6", 'alphanohtml'); |
|
492 | 492 | print __METHOD__." result=".$result."\n"; |
493 | 493 | $this->assertEquals('>', $result); |
494 | 494 | |
495 | - $result=GETPOST("param6b", 'alphanohtml'); |
|
495 | + $result = GETPOST("param6b", 'alphanohtml'); |
|
496 | 496 | print __METHOD__." result=".$result."\n"; |
497 | 497 | $this->assertEquals('abc', $result); |
498 | 498 | |
499 | - $result=GETPOST("param8a", 'alphanohtml'); |
|
499 | + $result = GETPOST("param8a", 'alphanohtml'); |
|
500 | 500 | print __METHOD__." result=".$result."\n"; |
501 | 501 | $this->assertEquals("Hackersvg onload='console.log(123)'", $result); |
502 | 502 | |
503 | - $result=GETPOST("param8b", 'alphanohtml'); |
|
503 | + $result = GETPOST("param8b", 'alphanohtml'); |
|
504 | 504 | print __METHOD__." result=".$result."\n"; |
505 | 505 | $this->assertEquals('img src=x onerror=alert(document.location) t=', $result, 'Test a string with non closing html tag with alphanohtml'); |
506 | 506 | |
507 | - $result=GETPOST("param8c", 'alphanohtml'); |
|
507 | + $result = GETPOST("param8c", 'alphanohtml'); |
|
508 | 508 | print __METHOD__." result=".$result."\n"; |
509 | 509 | $this->assertEquals($_POST['param8c'], $result, 'Test a string with non closing html tag with alphanohtml'); |
510 | 510 | |
511 | - $result=GETPOST("param8d", 'alphanohtml'); |
|
511 | + $result = GETPOST("param8d", 'alphanohtml'); |
|
512 | 512 | print __METHOD__." result=".$result."\n"; |
513 | 513 | $this->assertEquals('abc123 is html to clean', $result, 'Test a string with non closing html tag with alphanohtml'); |
514 | 514 | |
515 | - $result=GETPOST("param8e", 'alphanohtml'); |
|
515 | + $result = GETPOST("param8e", 'alphanohtml'); |
|
516 | 516 | print __METHOD__." result=".$result."\n"; |
517 | 517 | $this->assertEquals($_POST['param8e'], $result, 'Test a string with non closing html tag with alphanohtml'); |
518 | 518 | |
519 | - $result=GETPOST("param8f", 'alphanohtml'); |
|
519 | + $result = GETPOST("param8f", 'alphanohtml'); |
|
520 | 520 | print __METHOD__." result=".$result."\n"; |
521 | 521 | $this->assertEquals('abcsvg animate onbegin=alert(document.domain) a', $result, 'Test a string with html tag open with several <'); |
522 | 522 | |
523 | - $result=GETPOST("param9", 'alphanohtml'); |
|
523 | + $result = GETPOST("param9", 'alphanohtml'); |
|
524 | 524 | print __METHOD__." result=".$result."\n"; |
525 | 525 | $this->assertEquals($_POST["param9"], $result); |
526 | 526 | |
527 | - $result=GETPOST("param10", 'alphanohtml'); |
|
527 | + $result = GETPOST("param10", 'alphanohtml'); |
|
528 | 528 | print __METHOD__." result=".$result."\n"; |
529 | 529 | $this->assertEquals($_POST["param9"], $result, 'We should get param9 after processing param10'); |
530 | 530 | |
531 | - $result=GETPOST("param11", 'alphanohtml'); |
|
531 | + $result = GETPOST("param11", 'alphanohtml'); |
|
532 | 532 | print __METHOD__." result=".$result."\n"; |
533 | 533 | $this->assertEquals("Name", $result, 'Test an email string with alphanohtml'); |
534 | 534 | |
535 | - $result=GETPOST("param13", 'alphanohtml'); |
|
535 | + $result = GETPOST("param13", 'alphanohtml'); |
|
536 | 536 | print __METHOD__." result=".$result."\n"; |
537 | 537 | $this->assertEquals('n n > < XSS', $result, 'Test that html entities are decoded with alpha'); |
538 | 538 | |
539 | 539 | |
540 | 540 | // Test with alphawithlgt |
541 | 541 | |
542 | - $result=GETPOST("param11", 'alphawithlgt'); |
|
542 | + $result = GETPOST("param11", 'alphawithlgt'); |
|
543 | 543 | print __METHOD__." result=".$result."\n"; |
544 | 544 | $this->assertEquals(trim($_POST["param11"]), $result, 'Test an email string with alphawithlgt'); |
545 | 545 | |
546 | 546 | |
547 | 547 | // Test with restricthtml: we must remove html open/close tag and content but not htmlentities (we can decode html entities for ascii chars like n) |
548 | 548 | |
549 | - $result=GETPOST("param0", 'restricthtml'); |
|
549 | + $result = GETPOST("param0", 'restricthtml'); |
|
550 | 550 | $resultexpected = 'A real string with <a href="rrr" title="aa"bb">aaa</a> and " and \' and & inside content'; |
551 | 551 | print __METHOD__." result=".$result."\n"; |
552 | 552 | $this->assertEquals($resultexpected, $result, 'Test on param0'); |
553 | 553 | |
554 | - $result=GETPOST("param6", 'restricthtml'); |
|
554 | + $result = GETPOST("param6", 'restricthtml'); |
|
555 | 555 | print __METHOD__." result for param6=".$result." - before=".$_POST["param6"]."\n"; |
556 | 556 | $this->assertEquals('">', $result); |
557 | 557 | |
558 | - $result=GETPOST("param7", 'restricthtml'); |
|
558 | + $result = GETPOST("param7", 'restricthtml'); |
|
559 | 559 | print __METHOD__." result param7 = ".$result."\n"; |
560 | 560 | $this->assertEquals('"c:\this is a path~1\aaan &#x;;;;" abcdef', $result); |
561 | 561 | |
562 | - $result=GETPOST("param8e", 'restricthtml'); |
|
562 | + $result = GETPOST("param8e", 'restricthtml'); |
|
563 | 563 | print __METHOD__." result param8e = ".$result."\n"; |
564 | 564 | $this->assertEquals('', $result); |
565 | 565 | |
566 | - $result=GETPOST("param12", 'restricthtml'); |
|
566 | + $result = GETPOST("param12", 'restricthtml'); |
|
567 | 567 | print __METHOD__." result=".$result."\n"; |
568 | 568 | $this->assertEquals(trim($_POST["param12"]), $result, 'Test a string with DOCTYPE and restricthtml'); |
569 | 569 | |
570 | - $result=GETPOST("param13", 'restricthtml'); |
|
570 | + $result = GETPOST("param13", 'restricthtml'); |
|
571 | 571 | print __METHOD__." result=".$result."\n"; |
572 | 572 | $this->assertEquals('n n > < " <a href=\"alert(document.domain)\">XSS</a>', $result, 'Test 13 that HTML entities are decoded with restricthtml, but only for common alpha chars'); |
573 | 573 | |
574 | - $result=GETPOST("param13b", 'restricthtml'); |
|
574 | + $result = GETPOST("param13b", 'restricthtml'); |
|
575 | 575 | print __METHOD__." result=".$result."\n"; |
576 | 576 | $this->assertEquals('n n > < " <a href=\"alert(document.domain)\">XSS</a>', $result, 'Test 13b that HTML entities are decoded with restricthtml, but only for common alpha chars'); |
577 | 577 | |
578 | - $result=GETPOST("param14", 'restricthtml'); |
|
578 | + $result = GETPOST("param14", 'restricthtml'); |
|
579 | 579 | print __METHOD__." result=".$result."\n"; |
580 | 580 | $this->assertEquals("Text with ' encoded with the numeric html entity converted into text entity ' (like when submited by CKEditor)", $result, 'Test 14'); |
581 | 581 | |
582 | - $result=GETPOST("param15", 'restricthtml'); // param15 = <img onerror<=alert(document.domain)> src=>0xbeefed that is a dangerous string |
|
582 | + $result = GETPOST("param15", 'restricthtml'); // param15 = <img onerror<=alert(document.domain)> src=>0xbeefed that is a dangerous string |
|
583 | 583 | print __METHOD__." result=".$result."\n"; |
584 | - $this->assertEquals("<img onerror=alert(document.domain) src=>0xbeefed", $result, 'Test 15'); // The GETPOST return a harmull string |
|
584 | + $this->assertEquals("<img onerror=alert(document.domain) src=>0xbeefed", $result, 'Test 15'); // The GETPOST return a harmull string |
|
585 | 585 | |
586 | - $result=GETPOST("param19", 'restricthtml'); |
|
586 | + $result = GETPOST("param19", 'restricthtml'); |
|
587 | 587 | print __METHOD__." result=".$result."\n"; |
588 | 588 | $this->assertEquals('<a href="(alert(document.cookie))">XSS</a>', $result, 'Test 19'); |
589 | 589 | |
@@ -594,22 +594,22 @@ discard block |
||
594 | 594 | $conf->global->MAIN_RESTRICTHTML_ONLY_VALID_HTML_TIDY = 0; |
595 | 595 | |
596 | 596 | //$_POST["param0"] = 'A real string with <a href="rrr" title="aabb">aaa</a> and " inside content'; |
597 | - $result=GETPOST("param0", 'restricthtml'); |
|
597 | + $result = GETPOST("param0", 'restricthtml'); |
|
598 | 598 | $resultexpected = 'A real string with <a href="rrr" title=\'aa"bb\'>aaa</a> and " and \' and & inside content'; |
599 | 599 | print __METHOD__." result for param0=".$result."\n"; |
600 | 600 | $this->assertEquals($resultexpected, $result, 'Test on param0'); |
601 | 601 | |
602 | - $result=GETPOST("param15", 'restricthtml'); // param15 = <img onerror<=alert(document.domain)> src=>0xbeefed that is a dangerous string |
|
602 | + $result = GETPOST("param15", 'restricthtml'); // param15 = <img onerror<=alert(document.domain)> src=>0xbeefed that is a dangerous string |
|
603 | 603 | print __METHOD__." result for param15=".$result."\n"; |
604 | 604 | //$this->assertEquals('InvalidHTMLStringCantBeCleaned', $result, 'Test 15b'); // With some PHP and libxml version, we got this result when parsing invalid HTML, but ... |
605 | 605 | //$this->assertEquals('<img onerror> src=>0xbeefed', $result, 'Test 15b'); // ... on other PHP and libxml versions, we got a HTML that has been cleaned |
606 | 606 | |
607 | - $result=GETPOST("param6", 'restricthtml'); // param6 = ""><svg onload='console.log("123")'>" |
|
607 | + $result = GETPOST("param6", 'restricthtml'); // param6 = ""><svg onload='console.log("123")'>" |
|
608 | 608 | print __METHOD__." result for param6=".$result." - before=".$_POST["param6"]."\n"; |
609 | 609 | //$this->assertEquals('InvalidHTMLStringCantBeCleaned', $result, 'Test 15b'); // With some PHP and libxml version, we got this result when parsing invalid HTML, but ... |
610 | 610 | //$this->assertEquals('">', $result); // ... on other PHP and libxml versions, we got a HTML that has been cleaned |
611 | 611 | |
612 | - $result=GETPOST("param7", 'restricthtml'); // param7 = "c:\this is a path~1\aaan &#x110;" abc<bad>def</bad> |
|
612 | + $result = GETPOST("param7", 'restricthtml'); // param7 = "c:\this is a path~1\aaan &#x110;" abc<bad>def</bad> |
|
613 | 613 | print __METHOD__." result param7 = ".$result."\n"; |
614 | 614 | //$this->assertEquals('InvalidHTMLStringCantBeCleaned', $result, 'Test 15b'); // With some PHP and libxml version, we got this result when parsing invalid HTML, but ... |
615 | 615 | //$this->assertEquals('"c:\this is a path~1\aaan 110;" abcdef', $result); // ... on other PHP and libxml versions, we got a HTML that has been cleaned |
@@ -621,19 +621,19 @@ discard block |
||
621 | 621 | $conf->global->MAIN_RESTRICTHTML_ONLY_VALID_HTML = 0; |
622 | 622 | $conf->global->MAIN_RESTRICTHTML_ONLY_VALID_HTML_TIDY = 1; |
623 | 623 | |
624 | - $result=GETPOST("param0", 'restricthtml'); |
|
624 | + $result = GETPOST("param0", 'restricthtml'); |
|
625 | 625 | $resultexpected = 'A real string with <a href="rrr" title="aa"bb">aaa</a> and " and \' and & inside content'; |
626 | 626 | print __METHOD__." result for param0=".$result."\n"; |
627 | 627 | $this->assertEquals($resultexpected, $result, 'Test on param0'); |
628 | 628 | |
629 | - $result=GETPOST("param15", 'restricthtml'); // param15 = <img onerror<=alert(document.domain)> src=>0xbeefed that is a dangerous string |
|
629 | + $result = GETPOST("param15", 'restricthtml'); // param15 = <img onerror<=alert(document.domain)> src=>0xbeefed that is a dangerous string |
|
630 | 630 | print __METHOD__." result=".$result."\n"; |
631 | 631 | |
632 | - $result=GETPOST("param6", 'restricthtml'); |
|
632 | + $result = GETPOST("param6", 'restricthtml'); |
|
633 | 633 | print __METHOD__." result for param6=".$result." - before=".$_POST["param6"]."\n"; |
634 | 634 | $this->assertEquals('">', $result); |
635 | 635 | |
636 | - $result=GETPOST("param7", 'restricthtml'); |
|
636 | + $result = GETPOST("param7", 'restricthtml'); |
|
637 | 637 | print __METHOD__." result param7 = ".$result."\n"; |
638 | 638 | $this->assertEquals('"c:\this is a path~1\aaan &#x110;" abcdef', $result); |
639 | 639 | } |
@@ -645,19 +645,19 @@ discard block |
||
645 | 645 | $conf->global->MAIN_RESTRICTHTML_ONLY_VALID_HTML = 1; |
646 | 646 | $conf->global->MAIN_RESTRICTHTML_ONLY_VALID_HTML_TIDY = 1; |
647 | 647 | |
648 | - $result=GETPOST("param0", 'restricthtml'); |
|
648 | + $result = GETPOST("param0", 'restricthtml'); |
|
649 | 649 | $resultexpected = 'A real string with <a href="rrr" title=\'aa"bb\'>aaa</a> and " and \' and & inside content'; |
650 | 650 | print __METHOD__." result for param0=".$result."\n"; |
651 | 651 | $this->assertEquals($resultexpected, $result, 'Test on param0'); |
652 | 652 | |
653 | - $result=GETPOST("param15", 'restricthtml'); // param15 = <img onerror<=alert(document.domain)> src=>0xbeefed that is a dangerous string |
|
653 | + $result = GETPOST("param15", 'restricthtml'); // param15 = <img onerror<=alert(document.domain)> src=>0xbeefed that is a dangerous string |
|
654 | 654 | print __METHOD__." result=".$result."\n"; |
655 | 655 | |
656 | - $result=GETPOST("param6", 'restricthtml'); |
|
656 | + $result = GETPOST("param6", 'restricthtml'); |
|
657 | 657 | print __METHOD__." result for param6=".$result." - before=".$_POST["param6"]."\n"; |
658 | 658 | $this->assertEquals('">', $result); |
659 | 659 | |
660 | - $result=GETPOST("param7", 'restricthtml'); |
|
660 | + $result = GETPOST("param7", 'restricthtml'); |
|
661 | 661 | print __METHOD__." result param7 = ".$result."\n"; |
662 | 662 | $this->assertEquals('"c:\this is a path~1\aaan 110;" abcdef', $result); |
663 | 663 | } |
@@ -669,19 +669,19 @@ discard block |
||
669 | 669 | unset($conf->global->MAIN_RESTRICTHTML_ONLY_VALID_HTML_TIDY); |
670 | 670 | $conf->global->MAIN_RESTRICTHTML_REMOVE_ALSO_BAD_ATTRIBUTES = 1; |
671 | 671 | |
672 | - $result=GETPOST("param15", 'restricthtml'); |
|
672 | + $result = GETPOST("param15", 'restricthtml'); |
|
673 | 673 | print __METHOD__." result=".$result."\n"; |
674 | 674 | $this->assertEquals('<img src="">0xbeefed', $result, 'Test 15c'); |
675 | 675 | |
676 | - $result=GETPOST('param16', 'restricthtml'); |
|
676 | + $result = GETPOST('param16', 'restricthtml'); |
|
677 | 677 | print __METHOD__." result=".$result."\n"; |
678 | 678 | $this->assertEquals('<a style=" 1000">abc</a>', $result, 'Test tag a with forbidden attribute z-index'); |
679 | 679 | |
680 | - $result=GETPOST('param17', 'restricthtml'); |
|
680 | + $result = GETPOST('param17', 'restricthtml'); |
|
681 | 681 | print __METHOD__." result=".$result."\n"; |
682 | 682 | $this->assertEquals('<span style="background-image: url()">abc</span>', $result, 'Test anytag with a forbidden value for attribute'); |
683 | 683 | |
684 | - $result=GETPOST('param18', 'restricthtml'); |
|
684 | + $result = GETPOST('param18', 'restricthtml'); |
|
685 | 685 | print __METHOD__." result=".$result."\n"; |
686 | 686 | $this->assertEquals('<span style="background-image: url(...?...aaa)">abc</span>', $result, 'Test anytag with a forbidden value for attribute'); |
687 | 687 | |
@@ -690,75 +690,75 @@ discard block |
||
690 | 690 | |
691 | 691 | // Special test for GETPOST of backtopage, backtolist or backtourl parameter |
692 | 692 | |
693 | - $_POST["backtopage"]='//www.google.com'; |
|
694 | - $result=GETPOST("backtopage"); |
|
693 | + $_POST["backtopage"] = '//www.google.com'; |
|
694 | + $result = GETPOST("backtopage"); |
|
695 | 695 | print __METHOD__." result=".$result."\n"; |
696 | 696 | $this->assertEquals('www.google.com', $result, 'Test for backtopage param'); |
697 | 697 | |
698 | - $_POST["backtopage"]='https:https://www.google.com'; |
|
699 | - $result=GETPOST("backtopage"); |
|
698 | + $_POST["backtopage"] = 'https:https://www.google.com'; |
|
699 | + $result = GETPOST("backtopage"); |
|
700 | 700 | print __METHOD__." result=".$result."\n"; |
701 | 701 | $this->assertEquals('www.google.com', $result, 'Test for backtopage param'); |
702 | 702 | |
703 | - $_POST["backtolist"]='::HTTPS://www.google.com'; |
|
704 | - $result=GETPOST("backtolist"); |
|
703 | + $_POST["backtolist"] = '::HTTPS://www.google.com'; |
|
704 | + $result = GETPOST("backtolist"); |
|
705 | 705 | print __METHOD__." result=".$result."\n"; |
706 | 706 | $this->assertEquals('www.google.com', $result, 'Test for backtopage param'); |
707 | 707 | |
708 | - $_POST["backtopage"]='http:www.google.com'; |
|
709 | - $result=GETPOST("backtopage"); |
|
708 | + $_POST["backtopage"] = 'http:www.google.com'; |
|
709 | + $result = GETPOST("backtopage"); |
|
710 | 710 | print __METHOD__." result=".$result."\n"; |
711 | 711 | $this->assertEquals('httpwww.google.com', $result, 'Test for backtopage param'); |
712 | 712 | |
713 | - $_POST["backtopage"]='/mydir/mypage.php?aa=a%10a'; |
|
714 | - $result=GETPOST("backtopage"); |
|
713 | + $_POST["backtopage"] = '/mydir/mypage.php?aa=a%10a'; |
|
714 | + $result = GETPOST("backtopage"); |
|
715 | 715 | print __METHOD__." result=".$result."\n"; |
716 | 716 | $this->assertEquals('/mydir/mypage.php?aa=a%10a', $result, 'Test for backtopage param'); |
717 | 717 | |
718 | - $_POST["backtopage"]='javascripT&javascript#javascriptxjavascript3a alert(1)'; |
|
719 | - $result=GETPOST("backtopage"); |
|
718 | + $_POST["backtopage"] = 'javascripT&javascript#javascriptxjavascript3a alert(1)'; |
|
719 | + $result = GETPOST("backtopage"); |
|
720 | 720 | print __METHOD__." result=".$result."\n"; |
721 | 721 | $this->assertEquals('x3aalert(1)', $result, 'Test for backtopage param'); |
722 | 722 | |
723 | 723 | |
724 | 724 | $conf->global->MAIN_SECURITY_MAX_IMG_IN_HTML_CONTENT = 3; |
725 | - $_POST["pagecontentwithlinks"]='<img src="aaa"><img src="bbb"><img src="/ccc"><span style="background: url(/ddd)"></span>'; |
|
726 | - $result=GETPOST("pagecontentwithlinks", 'restricthtml'); |
|
725 | + $_POST["pagecontentwithlinks"] = '<img src="aaa"><img src="bbb"><img src="/ccc"><span style="background: url(/ddd)"></span>'; |
|
726 | + $result = GETPOST("pagecontentwithlinks", 'restricthtml'); |
|
727 | 727 | print __METHOD__." result=".$result."\n"; |
728 | 728 | $this->assertEquals('ErrorTooManyLinksIntoHTMLString', $result, 'Test on limit on GETPOST fails'); |
729 | 729 | |
730 | 730 | // Test that img src="data:..." is excluded from the count of external links |
731 | 731 | $conf->global->MAIN_SECURITY_MAX_IMG_IN_HTML_CONTENT = 3; |
732 | - $_POST["pagecontentwithlinks"]='<img src="data:abc"><img src="bbb"><img src="/ccc"><span style="background: url(/ddd)"></span>'; |
|
733 | - $result=GETPOST("pagecontentwithlinks", 'restricthtml'); |
|
732 | + $_POST["pagecontentwithlinks"] = '<img src="data:abc"><img src="bbb"><img src="/ccc"><span style="background: url(/ddd)"></span>'; |
|
733 | + $result = GETPOST("pagecontentwithlinks", 'restricthtml'); |
|
734 | 734 | print __METHOD__." result=".$result."\n"; |
735 | 735 | $this->assertEquals('<img src="data:abc"><img src="bbb"><img src="/ccc"><span style="background: url(/ddd)"></span>', $result, 'Test on limit on GETPOST fails'); |
736 | 736 | |
737 | 737 | $conf->global->MAIN_DISALLOW_URL_INTO_DESCRIPTIONS = 2; |
738 | 738 | |
739 | 739 | // Test that no links is allowed |
740 | - $_POST["pagecontentwithlinks"]='<img src="data:abc"><img src="bbb"><img src="/ccc"><span style="background: url(/ddd)"></span>'; |
|
741 | - $result=GETPOST("pagecontentwithlinks", 'restricthtml'); |
|
740 | + $_POST["pagecontentwithlinks"] = '<img src="data:abc"><img src="bbb"><img src="/ccc"><span style="background: url(/ddd)"></span>'; |
|
741 | + $result = GETPOST("pagecontentwithlinks", 'restricthtml'); |
|
742 | 742 | print __METHOD__." result=".$result."\n"; |
743 | 743 | $this->assertEquals('ErrorHTMLLinksNotAllowed', $result, 'Test on limit on MAIN_DISALLOW_URL_INTO_DESCRIPTIONS = 2 (no links allowed)'); |
744 | 744 | |
745 | 745 | $conf->global->MAIN_DISALLOW_URL_INTO_DESCRIPTIONS = 1; |
746 | 746 | |
747 | 747 | // Test that links on wrapper or local url are allowed |
748 | - $_POST["pagecontentwithnowrapperlinks"]='<img src="data:abc"><img src="bbb"><img src="/ccc"><span style="background: url(/ddd)"></span>'; |
|
749 | - $result=GETPOST("pagecontentwithnowrapperlinks", 'restricthtml'); |
|
748 | + $_POST["pagecontentwithnowrapperlinks"] = '<img src="data:abc"><img src="bbb"><img src="/ccc"><span style="background: url(/ddd)"></span>'; |
|
749 | + $result = GETPOST("pagecontentwithnowrapperlinks", 'restricthtml'); |
|
750 | 750 | print __METHOD__." result=".$result."\n"; |
751 | 751 | $this->assertEquals('<img src="data:abc"><img src="bbb"><img src="/ccc"><span style="background: url(/ddd)"></span>', $result, 'Test on MAIN_DISALLOW_URL_INTO_DESCRIPTIONS = 1 (links on data or relative links ar allowed)'); |
752 | 752 | |
753 | 753 | // Test that links not on wrapper and not data are disallowed |
754 | - $_POST["pagecontentwithnowrapperlinks"]='<img src="https://aaa">'; |
|
755 | - $result=GETPOST("pagecontentwithnowrapperlinks", 'restricthtml'); |
|
754 | + $_POST["pagecontentwithnowrapperlinks"] = '<img src="https://aaa">'; |
|
755 | + $result = GETPOST("pagecontentwithnowrapperlinks", 'restricthtml'); |
|
756 | 756 | print __METHOD__." result=".$result."\n"; |
757 | 757 | $this->assertEquals('ErrorHTMLExternalLinksNotAllowed', $result, 'Test on MAIN_DISALLOW_URL_INTO_DESCRIPTIONS = 1 (no links to http allowed)'); |
758 | 758 | |
759 | 759 | // Test that links not on wrapper and not data are disallowed |
760 | - $_POST["pagecontentwithnowrapperlinks"]='<span style="background: url(http://ddd)"></span>'; |
|
761 | - $result=GETPOST("pagecontentwithnowrapperlinks", 'restricthtml'); |
|
760 | + $_POST["pagecontentwithnowrapperlinks"] = '<span style="background: url(http://ddd)"></span>'; |
|
761 | + $result = GETPOST("pagecontentwithnowrapperlinks", 'restricthtml'); |
|
762 | 762 | print __METHOD__." result=".$result."\n"; |
763 | 763 | $this->assertEquals('ErrorHTMLExternalLinksNotAllowed', $result, 'Test on MAIN_DISALLOW_URL_INTO_DESCRIPTIONS = 1 (no links to http allowed)'); |
764 | 764 | |
@@ -772,15 +772,15 @@ discard block |
||
772 | 772 | */ |
773 | 773 | public function testEncodeDecode() |
774 | 774 | { |
775 | - $stringtotest="This is a string to test encode/decode. This is a string to test encode/decode. This is a string to test encode/decode."; |
|
775 | + $stringtotest = "This is a string to test encode/decode. This is a string to test encode/decode. This is a string to test encode/decode."; |
|
776 | 776 | |
777 | - $encodedstring=dol_encode($stringtotest); |
|
778 | - $decodedstring=dol_decode($encodedstring); |
|
777 | + $encodedstring = dol_encode($stringtotest); |
|
778 | + $decodedstring = dol_decode($encodedstring); |
|
779 | 779 | print __METHOD__." encodedstring=".$encodedstring." ".base64_encode($stringtotest)."\n"; |
780 | 780 | $this->assertEquals($stringtotest, $decodedstring, 'Use dol_encode/decode with no parameter'); |
781 | 781 | |
782 | - $encodedstring=dol_encode($stringtotest, 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ'); |
|
783 | - $decodedstring=dol_decode($encodedstring, 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ'); |
|
782 | + $encodedstring = dol_encode($stringtotest, 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ'); |
|
783 | + $decodedstring = dol_decode($encodedstring, 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ'); |
|
784 | 784 | print __METHOD__." encodedstring=".$encodedstring." ".base64_encode($stringtotest)."\n"; |
785 | 785 | $this->assertEquals($stringtotest, $decodedstring, 'Use dol_encode/decode with a key parameter'); |
786 | 786 | |
@@ -799,7 +799,7 @@ discard block |
||
799 | 799 | $this->assertEquals('a : b " c \' d ' e é', $decodedstring, 'Function did not sanitize correclty'); |
800 | 800 | |
801 | 801 | $stringtotest = 'a : b " c ' d ' e é'; |
802 | - $decodedstring = dol_html_entity_decode($stringtotest, ENT_QUOTES|ENT_HTML5); |
|
802 | + $decodedstring = dol_html_entity_decode($stringtotest, ENT_QUOTES | ENT_HTML5); |
|
803 | 803 | $this->assertEquals('a : b " c \' d \' e é', $decodedstring, 'Function did not sanitize correclty'); |
804 | 804 | |
805 | 805 | return 0; |
@@ -863,21 +863,21 @@ discard block |
||
863 | 863 | { |
864 | 864 | global $conf; |
865 | 865 | |
866 | - $genpass1=getRandomPassword(true); // Should be a string return by dol_hash (if no option set, will be md5) |
|
866 | + $genpass1 = getRandomPassword(true); // Should be a string return by dol_hash (if no option set, will be md5) |
|
867 | 867 | print __METHOD__." genpass1=".$genpass1."\n"; |
868 | 868 | $this->assertEquals(strlen($genpass1), 32); |
869 | 869 | |
870 | - $genpass1=getRandomPassword(true, array('I')); // Should be a string return by dol_hash (if no option set, will be md5) |
|
870 | + $genpass1 = getRandomPassword(true, array('I')); // Should be a string return by dol_hash (if no option set, will be md5) |
|
871 | 871 | print __METHOD__." genpass1=".$genpass1."\n"; |
872 | 872 | $this->assertEquals(strlen($genpass1), 32); |
873 | 873 | |
874 | - $conf->global->USER_PASSWORD_GENERATED='None'; |
|
875 | - $genpass2=getRandomPassword(false); // Should return an empty string |
|
874 | + $conf->global->USER_PASSWORD_GENERATED = 'None'; |
|
875 | + $genpass2 = getRandomPassword(false); // Should return an empty string |
|
876 | 876 | print __METHOD__." genpass2=".$genpass2."\n"; |
877 | 877 | $this->assertEquals($genpass2, ''); |
878 | 878 | |
879 | - $conf->global->USER_PASSWORD_GENERATED='Standard'; |
|
880 | - $genpass3=getRandomPassword(false); // Should return a password of 12 chars |
|
879 | + $conf->global->USER_PASSWORD_GENERATED = 'Standard'; |
|
880 | + $genpass3 = getRandomPassword(false); // Should return a password of 12 chars |
|
881 | 881 | print __METHOD__." genpass3=".$genpass3."\n"; |
882 | 882 | $this->assertEquals(strlen($genpass3), 12); |
883 | 883 | |
@@ -891,16 +891,16 @@ discard block |
||
891 | 891 | */ |
892 | 892 | public function testRestrictedArea() |
893 | 893 | { |
894 | - global $conf,$user,$langs,$db; |
|
895 | - $conf=$this->savconf; |
|
896 | - $user=$this->savuser; |
|
897 | - $langs=$this->savlangs; |
|
898 | - $db=$this->savdb; |
|
894 | + global $conf, $user, $langs, $db; |
|
895 | + $conf = $this->savconf; |
|
896 | + $user = $this->savuser; |
|
897 | + $langs = $this->savlangs; |
|
898 | + $db = $this->savdb; |
|
899 | 899 | |
900 | 900 | //$dummyuser=new User($db); |
901 | 901 | //$result=restrictedArea($dummyuser,'societe'); |
902 | 902 | |
903 | - $result=restrictedArea($user, 'societe'); |
|
903 | + $result = restrictedArea($user, 'societe'); |
|
904 | 904 | $this->assertEquals(1, $result); |
905 | 905 | } |
906 | 906 | |
@@ -918,42 +918,42 @@ discard block |
||
918 | 918 | $url = 'ftp://mydomain.com'; |
919 | 919 | $tmp = getURLContent($url); |
920 | 920 | print __METHOD__." url=".$url."\n"; |
921 | - $this->assertGreaterThan(0, strpos($tmp['curl_error_msg'], 'not supported')); // Test error if return does not contains 'not supported' |
|
921 | + $this->assertGreaterThan(0, strpos($tmp['curl_error_msg'], 'not supported')); // Test error if return does not contains 'not supported' |
|
922 | 922 | |
923 | - $url = 'https://www.dolibarr.fr'; // This is a redirect 301 page |
|
924 | - $tmp = getURLContent($url, 'GET', '', 0); // We do NOT follow |
|
923 | + $url = 'https://www.dolibarr.fr'; // This is a redirect 301 page |
|
924 | + $tmp = getURLContent($url, 'GET', '', 0); // We do NOT follow |
|
925 | 925 | print __METHOD__." url=".$url."\n"; |
926 | 926 | $this->assertEquals(301, $tmp['http_code'], 'Should GET url 301 response and stop here'); |
927 | 927 | |
928 | - $url = 'https://www.dolibarr.fr'; // This is a redirect 301 page |
|
929 | - $tmp = getURLContent($url); // We DO follow a page with return 300 so result should be 200 |
|
928 | + $url = 'https://www.dolibarr.fr'; // This is a redirect 301 page |
|
929 | + $tmp = getURLContent($url); // We DO follow a page with return 300 so result should be 200 |
|
930 | 930 | print __METHOD__." url=".$url."\n"; |
931 | 931 | $this->assertEquals(200, $tmp['http_code'], 'Should GET url 301 with a follow -> 200 but we get '.$tmp['http_code']); |
932 | 932 | |
933 | 933 | $url = 'http://localhost'; |
934 | - $tmp = getURLContent($url, 'GET', '', 0, array(), array('http', 'https'), 0); // Only external URL |
|
934 | + $tmp = getURLContent($url, 'GET', '', 0, array(), array('http', 'https'), 0); // Only external URL |
|
935 | 935 | print __METHOD__." url=".$url."\n"; |
936 | - $this->assertEquals(400, $tmp['http_code'], 'Should GET url to '.$url.' that resolves to a local URL'); // Test we receive an error because localtest.me is not an external URL |
|
936 | + $this->assertEquals(400, $tmp['http_code'], 'Should GET url to '.$url.' that resolves to a local URL'); // Test we receive an error because localtest.me is not an external URL |
|
937 | 937 | |
938 | 938 | $url = 'http://127.0.0.1'; |
939 | - $tmp = getURLContent($url, 'GET', '', 0, array(), array('http', 'https'), 0); // Only external URL |
|
939 | + $tmp = getURLContent($url, 'GET', '', 0, array(), array('http', 'https'), 0); // Only external URL |
|
940 | 940 | print __METHOD__." url=".$url."\n"; |
941 | - $this->assertEquals(400, $tmp['http_code'], 'Should GET url to '.$url.' that is a local URL'); // Test we receive an error because 127.0.0.1 is not an external URL |
|
941 | + $this->assertEquals(400, $tmp['http_code'], 'Should GET url to '.$url.' that is a local URL'); // Test we receive an error because 127.0.0.1 is not an external URL |
|
942 | 942 | |
943 | 943 | $url = 'http://127.0.2.1'; |
944 | - $tmp = getURLContent($url, 'GET', '', 0, array(), array('http', 'https'), 0); // Only external URL |
|
944 | + $tmp = getURLContent($url, 'GET', '', 0, array(), array('http', 'https'), 0); // Only external URL |
|
945 | 945 | print __METHOD__." url=".$url."\n"; |
946 | - $this->assertEquals(400, $tmp['http_code'], 'Should GET url to '.$url.' that is a local URL'); // Test we receive an error because 127.0.2.1 is not an external URL |
|
946 | + $this->assertEquals(400, $tmp['http_code'], 'Should GET url to '.$url.' that is a local URL'); // Test we receive an error because 127.0.2.1 is not an external URL |
|
947 | 947 | |
948 | 948 | $url = 'https://169.254.0.1'; |
949 | - $tmp = getURLContent($url, 'GET', '', 0, array(), array('http', 'https'), 0); // Only external URL |
|
949 | + $tmp = getURLContent($url, 'GET', '', 0, array(), array('http', 'https'), 0); // Only external URL |
|
950 | 950 | print __METHOD__." url=".$url."\n"; |
951 | - $this->assertEquals(400, $tmp['http_code'], 'Should GET url to '.$url.' that is a local URL'); // Test we receive an error because 169.254.0.1 is not an external URL |
|
951 | + $this->assertEquals(400, $tmp['http_code'], 'Should GET url to '.$url.' that is a local URL'); // Test we receive an error because 169.254.0.1 is not an external URL |
|
952 | 952 | |
953 | 953 | $url = 'http://[::1]'; |
954 | - $tmp = getURLContent($url, 'GET', '', 0, array(), array('http', 'https'), 0); // Only external URL |
|
954 | + $tmp = getURLContent($url, 'GET', '', 0, array(), array('http', 'https'), 0); // Only external URL |
|
955 | 955 | print __METHOD__." url=".$url."\n"; |
956 | - $this->assertEquals(400, $tmp['http_code'], 'Should GET url to '.$url.' that is a local URL'); // Test we receive an error because [::1] is not an external URL |
|
956 | + $this->assertEquals(400, $tmp['http_code'], 'Should GET url to '.$url.' that is a local URL'); // Test we receive an error because [::1] is not an external URL |
|
957 | 957 | |
958 | 958 | /*$url = 'localtest.me'; |
959 | 959 | $tmp = getURLContent($url, 'GET', '', 0, array(), array('http', 'https'), 0); // Only external URL |
@@ -962,9 +962,9 @@ discard block |
||
962 | 962 | */ |
963 | 963 | |
964 | 964 | $url = 'http://192.0.0.192'; |
965 | - $tmp = getURLContent($url, 'GET', '', 0, array(), array('http', 'https'), 0); // Only external URL but on an IP in blacklist |
|
965 | + $tmp = getURLContent($url, 'GET', '', 0, array(), array('http', 'https'), 0); // Only external URL but on an IP in blacklist |
|
966 | 966 | print __METHOD__." url=".$url." tmp['http_code'] = ".$tmp['http_code']."\n"; |
967 | - $this->assertEquals(400, $tmp['http_code'], 'Access should be refused and was not'); // Test we receive an error because ip is in blacklist |
|
967 | + $this->assertEquals(400, $tmp['http_code'], 'Access should be refused and was not'); // Test we receive an error because ip is in blacklist |
|
968 | 968 | |
969 | 969 | return 0; |
970 | 970 | } |
@@ -976,22 +976,22 @@ discard block |
||
976 | 976 | */ |
977 | 977 | public function testDolSanitizeUrl() |
978 | 978 | { |
979 | - global $conf,$user,$langs,$db; |
|
980 | - $conf=$this->savconf; |
|
981 | - $user=$this->savuser; |
|
982 | - $langs=$this->savlangs; |
|
983 | - $db=$this->savdb; |
|
979 | + global $conf, $user, $langs, $db; |
|
980 | + $conf = $this->savconf; |
|
981 | + $user = $this->savuser; |
|
982 | + $langs = $this->savlangs; |
|
983 | + $db = $this->savdb; |
|
984 | 984 | |
985 | 985 | $test = 'javascripT&javascript#x3a alert(1)'; |
986 | - $result=dol_sanitizeUrl($test); |
|
986 | + $result = dol_sanitizeUrl($test); |
|
987 | 987 | $this->assertEquals('x3a alert(1)', $result, 'Test on dol_sanitizeUrl A'); |
988 | 988 | |
989 | 989 | $test = 'javajavascriptscript&cjavascriptolon;alert(1)'; |
990 | - $result=dol_sanitizeUrl($test); |
|
990 | + $result = dol_sanitizeUrl($test); |
|
991 | 991 | $this->assertEquals('alert(1)', $result, 'Test on dol_sanitizeUrl B'); |
992 | 992 | |
993 | 993 | $test = '/javas:cript/google.com'; |
994 | - $result=dol_sanitizeUrl($test); |
|
994 | + $result = dol_sanitizeUrl($test); |
|
995 | 995 | $this->assertEquals('google.com', $result, 'Test on dol_sanitizeUrl C'); |
996 | 996 | } |
997 | 997 | |
@@ -1002,26 +1002,26 @@ discard block |
||
1002 | 1002 | */ |
1003 | 1003 | public function testDolSanitizeEmail() |
1004 | 1004 | { |
1005 | - global $conf,$user,$langs,$db; |
|
1006 | - $conf=$this->savconf; |
|
1007 | - $user=$this->savuser; |
|
1008 | - $langs=$this->savlangs; |
|
1009 | - $db=$this->savdb; |
|
1005 | + global $conf, $user, $langs, $db; |
|
1006 | + $conf = $this->savconf; |
|
1007 | + $user = $this->savuser; |
|
1008 | + $langs = $this->savlangs; |
|
1009 | + $db = $this->savdb; |
|
1010 | 1010 | |
1011 | 1011 | $test = '[email protected] <My name>, [email protected] <Another name>'; |
1012 | - $result=dol_sanitizeEmail($test); |
|
1012 | + $result = dol_sanitizeEmail($test); |
|
1013 | 1013 | $this->assertEquals($test, $result, 'Test on dol_sanitizeEmail A'); |
1014 | 1014 | |
1015 | 1015 | $test = "[email protected] <My name>,\[email protected] <Another name>"; |
1016 | - $result=dol_sanitizeEmail($test); |
|
1016 | + $result = dol_sanitizeEmail($test); |
|
1017 | 1017 | $this->assertEquals('[email protected] <My name>,[email protected] <Another name>', $result, 'Test on dol_sanitizeEmail B'); |
1018 | 1018 | |
1019 | 1019 | $test = '[email protected] <My name>,\[email protected] <Another name>'; |
1020 | - $result=dol_sanitizeEmail($test); |
|
1020 | + $result = dol_sanitizeEmail($test); |
|
1021 | 1021 | $this->assertEquals('[email protected] <My name>,[email protected] <Another name>', $result, 'Test on dol_sanitizeEmail C'); |
1022 | 1022 | |
1023 | 1023 | $test = '[email protected] <My name>, "bcc:bbb"@mycompany.com <Another name>'; |
1024 | - $result=dol_sanitizeEmail($test); |
|
1024 | + $result = dol_sanitizeEmail($test); |
|
1025 | 1025 | $this->assertEquals('[email protected] <My name>, [email protected] <Another name>', $result, 'Test on dol_sanitizeEmail D'); |
1026 | 1026 | } |
1027 | 1027 | |
@@ -1032,19 +1032,19 @@ discard block |
||
1032 | 1032 | */ |
1033 | 1033 | public function testDolSanitizeFileName() |
1034 | 1034 | { |
1035 | - global $conf,$user,$langs,$db; |
|
1036 | - $conf=$this->savconf; |
|
1037 | - $user=$this->savuser; |
|
1038 | - $langs=$this->savlangs; |
|
1039 | - $db=$this->savdb; |
|
1035 | + global $conf, $user, $langs, $db; |
|
1036 | + $conf = $this->savconf; |
|
1037 | + $user = $this->savuser; |
|
1038 | + $langs = $this->savlangs; |
|
1039 | + $db = $this->savdb; |
|
1040 | 1040 | |
1041 | 1041 | //$dummyuser=new User($db); |
1042 | 1042 | //$result=restrictedArea($dummyuser,'societe'); |
1043 | 1043 | |
1044 | - $result=dol_sanitizeFileName('bad file | evilaction'); |
|
1044 | + $result = dol_sanitizeFileName('bad file | evilaction'); |
|
1045 | 1045 | $this->assertEquals('bad file _ evilaction', $result); |
1046 | 1046 | |
1047 | - $result=dol_sanitizeFileName('bad file -evilparam --evilparam ---evilparam ----evilparam'); |
|
1047 | + $result = dol_sanitizeFileName('bad file -evilparam --evilparam ---evilparam ----evilparam'); |
|
1048 | 1048 | $this->assertEquals('bad file _evilparam _evilparam _evilparam _evilparam', $result); |
1049 | 1049 | } |
1050 | 1050 | |
@@ -1055,17 +1055,17 @@ discard block |
||
1055 | 1055 | */ |
1056 | 1056 | public function testDolEval() |
1057 | 1057 | { |
1058 | - global $conf,$user,$langs,$db; |
|
1059 | - $conf=$this->savconf; |
|
1060 | - $user=$this->savuser; |
|
1061 | - $langs=$this->savlangs; |
|
1062 | - $db=$this->savdb; |
|
1058 | + global $conf, $user, $langs, $db; |
|
1059 | + $conf = $this->savconf; |
|
1060 | + $user = $this->savuser; |
|
1061 | + $langs = $this->savlangs; |
|
1062 | + $db = $this->savdb; |
|
1063 | 1063 | |
1064 | - $result=dol_eval('1==1', 1, 0); |
|
1064 | + $result = dol_eval('1==1', 1, 0); |
|
1065 | 1065 | print "result1 = ".$result."\n"; |
1066 | 1066 | $this->assertTrue($result); |
1067 | 1067 | |
1068 | - $result=dol_eval('1==2', 1, 0); |
|
1068 | + $result = dol_eval('1==2', 1, 0); |
|
1069 | 1069 | print "result2 = ".$result."\n"; |
1070 | 1070 | $this->assertFalse($result); |
1071 | 1071 | |
@@ -1073,7 +1073,7 @@ discard block |
||
1073 | 1073 | include_once DOL_DOCUMENT_ROOT.'/projet/class/task.class.php'; |
1074 | 1074 | |
1075 | 1075 | $s = '(($reloadedobj = new Task($db)) && ($reloadedobj->fetchNoCompute($object->id) > 0) && ($secondloadedobj = new Project($db)) && ($secondloadedobj->fetchNoCompute($reloadedobj->fk_project) > 0)) ? $secondloadedobj->ref : "Parent project not found"'; |
1076 | - $result=dol_eval($s, 1, 1, '2'); |
|
1076 | + $result = dol_eval($s, 1, 1, '2'); |
|
1077 | 1077 | print "result3 = ".$result."\n"; |
1078 | 1078 | $this->assertEquals('Parent project not found', $result); |
1079 | 1079 | |
@@ -1114,48 +1114,48 @@ discard block |
||
1114 | 1114 | print "result12 = ".$result."\n"; |
1115 | 1115 | $this->assertStringContainsString('Bad string syntax to evaluate', $result); |
1116 | 1116 | |
1117 | - $result=dol_eval("90402.38+267678+0", 1, 1, 1); |
|
1117 | + $result = dol_eval("90402.38+267678+0", 1, 1, 1); |
|
1118 | 1118 | print "result13 = ".$result."\n"; |
1119 | 1119 | $this->assertEquals('358080.38', $result); |
1120 | 1120 | |
1121 | - global $leftmenu; // Used into strings to eval |
|
1121 | + global $leftmenu; // Used into strings to eval |
|
1122 | 1122 | |
1123 | 1123 | $leftmenu = 'AAA'; |
1124 | - $result=dol_eval('$conf->currency && preg_match(\'/^(AAA|BBB)/\',$leftmenu)', 1, 1, '1'); |
|
1124 | + $result = dol_eval('$conf->currency && preg_match(\'/^(AAA|BBB)/\',$leftmenu)', 1, 1, '1'); |
|
1125 | 1125 | print "result = ".$result."\n"; |
1126 | 1126 | $this->assertTrue($result); |
1127 | 1127 | |
1128 | 1128 | // Same with a value that does not match |
1129 | 1129 | $leftmenu = 'XXX'; |
1130 | - $result=dol_eval('$conf->currency && preg_match(\'/^(AAA|BBB)/\',$leftmenu)', 1, 1, '1'); |
|
1130 | + $result = dol_eval('$conf->currency && preg_match(\'/^(AAA|BBB)/\',$leftmenu)', 1, 1, '1'); |
|
1131 | 1131 | print "result14 = ".$result."\n"; |
1132 | 1132 | $this->assertFalse($result); |
1133 | 1133 | |
1134 | 1134 | $leftmenu = 'AAA'; |
1135 | - $result=dol_eval('$conf->currency && isStringVarMatching(\'leftmenu\', \'(AAA|BBB)\')', 1, 1, '1'); |
|
1135 | + $result = dol_eval('$conf->currency && isStringVarMatching(\'leftmenu\', \'(AAA|BBB)\')', 1, 1, '1'); |
|
1136 | 1136 | print "result15 = ".$result."\n"; |
1137 | 1137 | $this->assertTrue($result); |
1138 | 1138 | |
1139 | 1139 | $leftmenu = 'XXX'; |
1140 | - $result=dol_eval('$conf->currency && isStringVarMatching(\'leftmenu\', \'(AAA|BBB)\')', 1, 1, '1'); |
|
1140 | + $result = dol_eval('$conf->currency && isStringVarMatching(\'leftmenu\', \'(AAA|BBB)\')', 1, 1, '1'); |
|
1141 | 1141 | print "result16 = ".$result."\n"; |
1142 | 1142 | $this->assertFalse($result); |
1143 | 1143 | |
1144 | 1144 | $string = '(isModEnabled("agenda") || isModEnabled("resource")) && getDolGlobalInt("MAIN_FEATURES_LEVEL") >= 0 && preg_match(\'/^(admintools|all|XXX)/\', $leftmenu)'; |
1145 | - $result=dol_eval($string, 1, 1, '1'); |
|
1145 | + $result = dol_eval($string, 1, 1, '1'); |
|
1146 | 1146 | print "result17 = ".$result."\n"; |
1147 | 1147 | $this->assertTrue($result); |
1148 | 1148 | |
1149 | - $result=dol_eval('1 && getDolGlobalInt("doesnotexist1") && $conf->global->MAIN_FEATURES_LEVEL', 1, 0); // Should return false and not a 'Bad string syntax to evaluate ...' |
|
1149 | + $result = dol_eval('1 && getDolGlobalInt("doesnotexist1") && $conf->global->MAIN_FEATURES_LEVEL', 1, 0); // Should return false and not a 'Bad string syntax to evaluate ...' |
|
1150 | 1150 | print "result18 = ".$result."\n"; |
1151 | 1151 | $this->assertFalse($result); |
1152 | 1152 | |
1153 | - $a='ab'; |
|
1153 | + $a = 'ab'; |
|
1154 | 1154 | $result = (string) dol_eval("(\$a.'s')", 1, 0); |
1155 | 1155 | print "result19 = ".$result."\n"; |
1156 | 1156 | $this->assertStringContainsString('Bad string syntax to evaluate', $result); |
1157 | 1157 | |
1158 | - $leftmenu='abs'; |
|
1158 | + $leftmenu = 'abs'; |
|
1159 | 1159 | $result = (string) dol_eval('$leftmenu(-5)', 1, 0); |
1160 | 1160 | print "result20 = ".$result."\n"; |
1161 | 1161 | $this->assertStringContainsString('Bad string syntax to evaluate', $result); |
@@ -1173,12 +1173,12 @@ discard block |
||
1173 | 1173 | global $conf; |
1174 | 1174 | |
1175 | 1175 | // Set options for cleaning data |
1176 | - $conf->global->MAIN_RESTRICTHTML_ONLY_VALID_HTML = 0; // disabled, does not work on HTML5 and some libxml versions |
|
1176 | + $conf->global->MAIN_RESTRICTHTML_ONLY_VALID_HTML = 0; // disabled, does not work on HTML5 and some libxml versions |
|
1177 | 1177 | // Enabled option MAIN_RESTRICTHTML_ONLY_VALID_HTML_TIDY if possible |
1178 | 1178 | if (extension_loaded('tidy') && class_exists("tidy")) { |
1179 | 1179 | $conf->global->MAIN_RESTRICTHTML_ONLY_VALID_HTML_TIDY = 1; |
1180 | 1180 | } |
1181 | - $conf->global->MAIN_RESTRICTHTML_REMOVE_ALSO_BAD_ATTRIBUTES = 0; // disabled, does not work on HTML5 and some libxml versions |
|
1181 | + $conf->global->MAIN_RESTRICTHTML_REMOVE_ALSO_BAD_ATTRIBUTES = 0; // disabled, does not work on HTML5 and some libxml versions |
|
1182 | 1182 | |
1183 | 1183 | |
1184 | 1184 | |
@@ -1191,7 +1191,7 @@ discard block |
||
1191 | 1191 | //$result = dol_escape_htmltag(dol_htmlwithnojs(dol_string_onlythesehtmltags(dol_htmlentitiesbr($stringtotest), 1, 1, 1, 0)), 1, 1, 'common', 0, 1); |
1192 | 1192 | $result = dolPrintHTML($stringtotest); |
1193 | 1193 | print __METHOD__." result=".$result."\n"; |
1194 | - $this->assertEquals($stringfixed, $result, 'Error'); // Expected '' because should failed because login 'auto' does not exists |
|
1194 | + $this->assertEquals($stringfixed, $result, 'Error'); // Expected '' because should failed because login 'auto' does not exists |
|
1195 | 1195 | |
1196 | 1196 | |
1197 | 1197 | // For a string that is already HTML (contains HTML tags) with special tags but badly formated |
@@ -1240,24 +1240,24 @@ discard block |
||
1240 | 1240 | */ |
1241 | 1241 | public function testCheckLoginPassEntity() |
1242 | 1242 | { |
1243 | - $login=checkLoginPassEntity('loginbidon', 'passwordbidon', 1, array('dolibarr')); |
|
1243 | + $login = checkLoginPassEntity('loginbidon', 'passwordbidon', 1, array('dolibarr')); |
|
1244 | 1244 | print __METHOD__." login=".$login."\n"; |
1245 | 1245 | $this->assertEquals($login, ''); |
1246 | 1246 | |
1247 | - $login=checkLoginPassEntity('admin', 'passwordbidon', 1, array('dolibarr')); |
|
1247 | + $login = checkLoginPassEntity('admin', 'passwordbidon', 1, array('dolibarr')); |
|
1248 | 1248 | print __METHOD__." login=".$login."\n"; |
1249 | 1249 | $this->assertEquals($login, ''); |
1250 | 1250 | |
1251 | - $login=checkLoginPassEntity('admin', 'admin', 1, array('dolibarr')); // Should works because admin/admin exists |
|
1251 | + $login = checkLoginPassEntity('admin', 'admin', 1, array('dolibarr')); // Should works because admin/admin exists |
|
1252 | 1252 | print __METHOD__." login=".$login."\n"; |
1253 | 1253 | $this->assertEquals($login, 'admin', 'The test to check if pass of user "admin" is "admin" has failed'); |
1254 | 1254 | |
1255 | - $login=checkLoginPassEntity('admin', 'admin', 1, array('http','dolibarr')); // Should work because of second authentication method |
|
1255 | + $login = checkLoginPassEntity('admin', 'admin', 1, array('http', 'dolibarr')); // Should work because of second authentication method |
|
1256 | 1256 | print __METHOD__." login=".$login."\n"; |
1257 | 1257 | $this->assertEquals($login, 'admin'); |
1258 | 1258 | |
1259 | - $login=checkLoginPassEntity('admin', 'admin', 1, array('forceuser')); |
|
1259 | + $login = checkLoginPassEntity('admin', 'admin', 1, array('forceuser')); |
|
1260 | 1260 | print __METHOD__." login=".$login."\n"; |
1261 | - $this->assertEquals('', $login, 'Error'); // Expected '' because should failed because login 'auto' does not exists |
|
1261 | + $this->assertEquals('', $login, 'Error'); // Expected '' because should failed because login 'auto' does not exists |
|
1262 | 1262 | } |
1263 | 1263 | } |