Skip to content

Commit

Permalink
FIX missing token
Browse files Browse the repository at this point in the history
  • Loading branch information
eldy committed Nov 25, 2024
1 parent 25cf365 commit 3b0efa3
Show file tree
Hide file tree
Showing 3 changed files with 68 additions and 62 deletions.
16 changes: 9 additions & 7 deletions htdocs/ovh/admin/ovh_importinvoice.php
Original file line number Diff line number Diff line change
Expand Up @@ -155,16 +155,17 @@

print '<tr class="oddeven"><td class="fieldrequired">';
print $langs->trans("SupplierToUseForImport") . '</td><td>';
print $form->select_company($conf->global->OVH_THIRDPARTY_IMPORT, 'OVH_THIRDPARTY_IMPORT', 's.fournisseur = 1', 1,
print img_picto('', 'company', 'class="pictofixedwidth"');
print $form->select_company(getDolGlobalString('OVH_THIRDPARTY_IMPORT'), 'OVH_THIRDPARTY_IMPORT', '(s.fournisseur:=:1)', 1,
'supplier');
print '<td>';
print '</td></tr>';

if (isModEnabled("product") || isModEnabled("service")) {
print '<tr class="oddeven"><td>';
print $langs->trans("ProductGenericToUseForImport") . '</td><td>';
$form->select_produits($conf->global->OVH_IMPORT_SUPPLIER_INVOICE_PRODUCT_ID,
'OVH_IMPORT_SUPPLIER_INVOICE_PRODUCT_ID', '', 0, 0, -1);
print $langs->trans("ProductGenericToUseForImport") . '</td><td class="nowraponall">';
print img_picto('', 'product', 'class="pictofixedwidth"');
$form->select_produits(getDolGlobalString('OVH_IMPORT_SUPPLIER_INVOICE_PRODUCT_ID'), 'OVH_IMPORT_SUPPLIER_INVOICE_PRODUCT_ID', '', 0, 0, -1, 2, '', 0, array(), 0, '1', 0, 'minwidth200 maxwidth500 widthcentpercentminusx');
print '<td>';
print $langs->trans("KeepEmptyToSaveLinesAsFreeLines");
print '</td></tr>';
Expand All @@ -173,7 +174,8 @@
if (isModEnabled("banque")) {
print '<tr class="oddeven"><td>';
print $langs->trans("OvhDefaultBankAccount") . '</td><td>';
$form->select_comptes($conf->global->OVH_DEFAULT_BANK_ACCOUNT, 'OVH_DEFAULT_BANK_ACCOUNT', 0, '', 1);
print img_picto('', 'bank', 'class="pictofixedwidth"');
$form->select_comptes(getDolGlobalString('OVH_DEFAULT_BANK_ACCOUNT'), 'OVH_DEFAULT_BANK_ACCOUNT', 0, '', 1);
print '<td>';
//print $langs->trans("KeepEmptyToSaveLinesAsFreeLines");
print '</td></tr>';
Expand All @@ -188,7 +190,7 @@
global $mysoc;
$countryVat .= "'$mysoc->country_code'";
// }
if ($company->fetch($conf->global->OVH_THIRDPARTY_IMPORT)) {
if ($company->fetch(getDolGlobalInt('OVH_THIRDPARTY_IMPORT'))) {
if ($countryVat) {
$countryVat .= ',';
}
Expand All @@ -198,7 +200,7 @@
foreach ($form->cache_vatrates as $rate) {
$vatArray[$rate['rowid']] = vatrate($rate['label']);
}
print $form->multiselectarray('OVH_VAT_VALID_LIST', $vatArray, explode(';', $conf->global->OVH_VAT_VALID_LIST), '',
print $form->multiselectarray('OVH_VAT_VALID_LIST', $vatArray, explode(';', getDolGlobalString('OVH_VAT_VALID_LIST')), '',
'', '', '', '200');
print '<td>';
print $langs->trans("OVHVatKeepEmptyToAcceptAll");
Expand Down
100 changes: 53 additions & 47 deletions htdocs/ovh/admin/ovh_setup.php
Original file line number Diff line number Diff line change
Expand Up @@ -141,11 +141,11 @@ function traitementErreur($code, $message, $fichier, $ligne, $contexte)
// Informations about your application
$applicationKey = $conf->global->OVHAPPKEY;
$applicationSecret = $conf->global->OVHAPPSECRET;
$redirect_uri=dol_buildpath('/ovh/admin/ovh_setup.php?action=backfromauth', 2);
$redirect_uri=dol_buildpath('/ovh/admin/ovh_setup.php?action=backfromauth&token='.newToken(), 2);
if ($action == 'requestcredential2') {
$applicationKey = $conf->global->OVHAPPKEY2;
$applicationSecret = $conf->global->OVHAPPSECRET2;
$redirect_uri=dol_buildpath('/ovh/admin/ovh_setup.php?action=backfromauth2', 2);
$redirect_uri=dol_buildpath('/ovh/admin/ovh_setup.php?action=backfromauth2&token='.newToken(), 2);
}

// Information about API and rights asked
Expand Down Expand Up @@ -222,6 +222,7 @@ function traitementErreur($code, $message, $fichier, $ligne, $contexte)

$head=ovhadmin_prepare_head();

//$conf->global->OVH_USE_2_ACCOUNTS=1;

print '<form method="post" action="'.$_SERVER["PHP_SELF"].'">';
print '<input type="hidden" name="token" value="'.newToken().'">';
Expand All @@ -237,16 +238,16 @@ function traitementErreur($code, $message, $fichier, $ligne, $contexte)

dol_fiche_head($head, 'common', $langs->trans("Ovh"), -1);

if (empty($conf->global->OVH_OLDAPI)) {
if (!getDolGlobalString('OVH_OLDAPI')) {
print '<div class="opacitymedium">';
print $langs->trans("GoOnPageToCreateYourAPIKey", 'https://eu.api.ovh.com/createApp/', 'https://eu.api.ovh.com/createApp/').'<br>';
print $langs->trans("ListOfExistingAPIApp", 'https://eu.api.ovh.com/console/#/me/api/application#GET', 'https://eu.api.ovh.com/console/#/me/api/application#GET').' (first log in on top right corner)<br><br>';
print '</div>';
}


if (! empty($conf->global->OVH_OLDAPI)) {
print '<table class="noborder" width="100%">';
if (getDolGlobalString('OVH_OLDAPI')) {
print '<table class="noborder centpercent">';

// Old API

Expand All @@ -259,8 +260,8 @@ function traitementErreur($code, $message, $fichier, $ligne, $contexte)
print '<tr class="oddeven"><td width="200px" class="fieldrequired">';
print $langs->trans("OvhSmsNick").'</td><td>';
print '<input size="64" type="text" name="OVHSMS_NICK" value="' . getDolGlobalString('OVHSMS_NICK').'">';
print '</td><td>'.$langs->trans("Example").': AA123-OVH';
print '</td></tr>';
print '</td><td><span class="opacitymedium">'.$langs->trans("Example").': AA123-OVH';
print '</span></td></tr>';

print '<tr class="oddeven"><td class="fieldrequired">';
print $langs->trans("OvhSmsPass").'</td><td>';
Expand All @@ -270,12 +271,12 @@ function traitementErreur($code, $message, $fichier, $ligne, $contexte)
print '<tr class="oddeven"><td class="fieldrequired">';
print $langs->trans("OvhSmsSoapUrl").'</td><td>';
print '<input size="64" type="text" name="OVHSMS_SOAPURL" value="' . getDolGlobalString('OVHSMS_SOAPURL').'">';
print '</td><td>'.$langs->trans("Example").': '.$urlexample;
print '</td></tr>';
print '</td><td><span class="opacitymedium">'.$langs->trans("Example").': '.$urlexample;
print '</span></td></tr>';

print '</table>';
} else {
if (! empty($conf->global->OVH_USE_2_ACCOUNTS)) {
if (getDolGlobalString('OVH_USE_2_ACCOUNTS')) {
print "<br>\n";
print $langs->trans("Account").' 1<br>';
}
Expand All @@ -287,40 +288,42 @@ function traitementErreur($code, $message, $fichier, $ligne, $contexte)
print '<tr class="oddeven"><td class="titlefield fieldrequired">';
print $langs->trans("OvhApplicationName").'</td><td>';
print '<input size="64" type="text" name="OVHAPPNAME" value="' . getDolGlobalString('OVHAPPNAME').'">';
print '</td><td>'.$langs->trans("Example").': My App';
print '</td><td><span class="opacitymedium">'.$langs->trans("Example").': My App</span>';
print '</td></tr>';

print '<tr class="oddeven"><td class="fieldrequired">';
print $langs->trans("OvhApplicationKey").'</td><td>';
print '<input size="64" type="text" name="OVHAPPKEY" value="' . getDolGlobalString('OVHAPPKEY').'">';
print '</td><td>'.$langs->trans("Example").': Ld9GQ3AfaXDyZdsM';
print '</td><td><span class="opacitymedium">'.$langs->trans("Example").': Ld9GQ3AfaXDyZdsM</span>';
print '</td></tr>';

print '<tr class="oddeven"><td class="fieldrequired">';
print $langs->trans("OvhApplicationSecret").'</td><td>';
print '<input size="64" type="text" name="OVHAPPSECRET" value="' . getDolGlobalString('OVHAPPSECRET').'">';
print '</td><td>'.$langs->trans("Example").': V3dTtzY4PCMUYp2dURlGyIkI67C54S67';
print '</td></tr>';

print '<tr class="oddeven"><td class="fieldrequired">';
print $langs->trans("OvhConsumerkey").'</td><td>';
if (! empty($conf->global->OVHAPPNAME) && ! empty($conf->global->OVHAPPKEY) && ! empty($conf->global->OVHAPPSECRET)) {
print '<input size="64" type="text" name="OVHCONSUMERKEY" value="' . getDolGlobalString('OVHCONSUMERKEY').'">';
} else {
print $langs->trans("PleaseFillOtherFieldFirst");
}
print '</td><td>';
if (! empty($conf->global->OVHAPPNAME) && ! empty($conf->global->OVHAPPKEY) && ! empty($conf->global->OVHAPPSECRET)) {
if (empty($conf->global->OVHCONSUMERKEY)) print img_warning().' ';
print $langs->trans("ClickHereToLoginAndGetYourConsumerKey", $_SERVER["PHP_SELF"].'?action=requestcredential');
//print '<br>'.info_admin($langs->trans('OVHURLMustNotBeLocal')); Can work with a local URL.
}
print '</td><td><span class="opacitymedium">'.$langs->trans("Example").': V3dTtzY4PCMUYp2dURlGyIkI67C54S67</span>';
print '</td></tr>';

print '</table>';

print '<br>';

if (getDolGlobalString('OVHAPPNAME') && getDolGlobalString('OVHAPPKEY') && getDolGlobalString('OVHAPPSECRET')) {
if (!getDolGlobalString('OVHCONSUMERKEY')) print img_warning().' ';
print $langs->trans("ClickHereToLoginAndGetYourConsumerKey", $_SERVER["PHP_SELF"].'?action=requestcredential&token='.newToken());
print '<br><br>';

print '<table class="noborder centpercent">';

print '<tr class="oddeven"><td class="fieldrequired">';
print $langs->trans("OvhConsumerkey").'</td><td>';
print '<input size="64" type="text" name="OVHCONSUMERKEY" value="' . getDolGlobalString('OVHCONSUMERKEY').'">';
print '</td><td>';
print '</td></tr>';

if (! empty($conf->global->OVH_USE_2_ACCOUNTS)) {
print '</table>';
}

if (getDolGlobalString('OVH_USE_2_ACCOUNTS')) {
print "<br><br>\n";
print $langs->trans("Account").' 2<br>';

Expand All @@ -331,37 +334,40 @@ function traitementErreur($code, $message, $fichier, $ligne, $contexte)
print '<tr class="oddeven"><td class="titlefield fieldrequired">';
print $langs->trans("OvhApplicationName").'</td><td>';
print '<input size="64" type="text" name="OVHAPPNAME2" value="' . getDolGlobalString('OVHAPPNAME2').'">';
print '</td><td>'.$langs->trans("Example").': My App';
print '</td><td><span class="opacitymedium">'.$langs->trans("Example").': My App</span>';
print '</td></tr>';

print '<tr class="oddeven"><td class="fieldrequired">';
print $langs->trans("OvhApplicationKey").'</td><td>';
print '<input size="64" type="text" name="OVHAPPKEY2" value="' . getDolGlobalString('OVHAPPKEY2').'">';
print '</td><td>'.$langs->trans("Example").': Ld9GQ3AfaXDyZdsM';
print '</td><td><span class="opacitymedium">'.$langs->trans("Example").': Ld9GQ3AfaXDyZdsM</span>';
print '</td></tr>';

print '<tr class="oddeven"><td class="fieldrequired">';
print $langs->trans("OvhApplicationSecret").'</td><td>';
print '<input size="64" type="text" name="OVHAPPSECRET2" value="' . getDolGlobalString('OVHAPPSECRET2').'">';
print '</td><td>'.$langs->trans("Example").': V3dTtzY4PCMUYp2dURlGyIkI67C54S67';
print '</td><td><span class="opacitymedium">'.$langs->trans("Example").': V3dTtzY4PCMUYp2dURlGyIkI67C54S67</span>';
print '</td></tr>';

print '<tr class="oddeven"><td class="fieldrequired">';
print $langs->trans("OvhConsumerkey").'</td><td>';
if (! empty($conf->global->OVHAPPNAME2) && ! empty($conf->global->OVHAPPKEY2) && ! empty($conf->global->OVHAPPSECRET2)) {
print '</table>';

print '<br>';

if (getDolGlobalString('OVHAPPNAME2') && getDolGlobalString('OVHAPPKEY2') && getDolGlobalString('OVHAPPSECRET2')) {
if (!getDolGlobalString('OVHCONSUMERKEY2')) print img_warning().' ';
print $langs->trans("ClickHereToLoginAndGetYourConsumerKey", $_SERVER["PHP_SELF"].'?action=requestcredential2&token='.newToken());
print '<br><br>';

print '<table class="noborder centpercent">';

print '<tr class="oddeven"><td class="fieldrequired">';
print $langs->trans("OvhConsumerkey").'</td><td>';
print '<input size="64" type="text" name="OVHCONSUMERKEY2" value="' . getDolGlobalString('OVHCONSUMERKEY2').'">';
} else {
print $langs->trans("PleaseFillOtherFieldFirst");
}
print '</td><td>';
if (! empty($conf->global->OVHAPPNAME2) && ! empty($conf->global->OVHAPPKEY2) && ! empty($conf->global->OVHAPPSECRET2)) {
if (empty($conf->global->OVHCONSUMERKEY2)) print img_warning().' ';
print $langs->trans("ClickHereToLoginAndGetYourConsumerKey", $_SERVER["PHP_SELF"].'?action=requestcredential2');
//print '<br>'.info_admin($langs->trans('OVHURLMustNotBeLocal')); Can work with a local URL.
}
print '</td></tr>';
print '</td><td>';
print '</td></tr>';

print '</table>';
print '</table>';
}
}
}

Expand All @@ -386,7 +392,7 @@ function traitementErreur($code, $message, $fichier, $ligne, $contexte)
echo '<br><div class="warning">'.$langs->trans("OvhSmsNotConfigured").'</div>';
} else {
print '<br>';
print '<a class="butAction" href="'.$_SERVER["PHP_SELF"].'?action=test">'.$langs->trans("TestLoginToAPI").'</a><br><br>';
print '<a class="butAction" href="'.$_SERVER["PHP_SELF"].'?action=test&token='.newToken().'">'.$langs->trans("TestLoginToAPI").'</a><br><br>';

if ($action == 'test') {
require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php';
Expand Down
14 changes: 6 additions & 8 deletions htdocs/ovh/admin/ovh_sms_setup.php
Original file line number Diff line number Diff line change
Expand Up @@ -211,24 +211,22 @@ function traitementErreur($code, $message, $fichier, $ligne, $contexte)

$head=ovhadmin_prepare_head();

if (! empty($conf->global->OVH_OLDAPI) && (empty($conf->global->OVHSMS_NICK) || empty($WS_DOL_URL))) {
if (getDolGlobalString('OVH_OLDAPI') && (empty($conf->global->OVHSMS_NICK) || empty($WS_DOL_URL))) {
echo '<div class="warning">'.$langs->trans("OvhSmsNotConfigured").'</div>';
} else {
dol_htmloutput_mesg($mesg);

// Formulaire d'ajout de compte SMS qui sera valable pour tout Dolibarr
print '<form method="post" action="'.$_SERVER["PHP_SELF"].'">';
print '<form method="POST" action="'.$_SERVER["PHP_SELF"].'">';
print '<input type="hidden" name="token" value="'.newToken().'">';
print '<input type="hidden" name="action" value="setvalue_account">';

print dol_get_fiche_head($head, 'sms', $langs->trans("Ovh"), -1);

if (empty($conf->global->OVH_OLDAPI) && (empty($conf->global->OVHAPPKEY) || empty($conf->global->OVHAPPSECRET) || empty($conf->global->OVHCONSUMERKEY))) {
if (!getDolGlobalString('OVH_OLDAPI') && (!getDolGlobalString('OVHAPPKEY') || !getDolGlobalString('OVHAPPSECRET') || !getDolGlobalString('OVHCONSUMERKEY'))) {
echo '<div class="warning">'.$langs->trans("OvhAuthenticationPartNotConfigured").'</div>';
}

$var=true;

print '<table class="noborder centpercent">';

print '<tr class="liste_titre">';
Expand All @@ -246,18 +244,18 @@ function traitementErreur($code, $message, $fichier, $ligne, $contexte)

print '</table>';

print dol_get_fiche_end();

print '<div class="center"><input type="submit" class="button" value="'.$langs->trans("Modify").'"></div>';

print dol_get_fiche_end();

print '</form>';



if ($action != 'testsms') {
print '<br>';
if (! empty($smsAccount)) {
print '<a class="butAction" href="'.$_SERVER["PHP_SELF"].'?action=testsms">'.$langs->trans("DoTestSend").'</a>';
print '<a class="butAction" href="'.$_SERVER["PHP_SELF"].'?action=testsms&token='.newToken().'">'.$langs->trans("DoTestSend").'</a>';
} else {
print '<a class="butActionRefused" href="#">'.$langs->trans("DoTestSend").'</a>';
}
Expand Down

0 comments on commit 3b0efa3

Please sign in to comment.