From 71833f598776928ce6eb93ee9cb24a45b6730683 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur <eldy@destailleur.fr> Date: Sat, 13 May 2017 15:19:35 +0200 Subject: [PATCH] Standardize code --- htdocs/externalsite/frametop.php | 4 + htdocs/main.inc.php | 31 ++--- htdocs/paybox/lib/paybox.lib.php | 2 +- htdocs/paypal/admin/paypal.php | 5 +- htdocs/paypal/lib/paypal.lib.php | 6 +- htdocs/public/members/new.php | 1 + htdocs/public/paybox/newpayment.php | 27 ++-- htdocs/public/paybox/paymentko.php | 6 +- htdocs/public/paybox/paymentok.php | 12 +- htdocs/public/payment/newpayment.php | 143 +++++++++++++++++----- htdocs/public/payment/paymentko.php | 21 ++-- htdocs/public/payment/paymentok.php | 40 ++++-- htdocs/public/paypal/newpayment.php | 19 ++- htdocs/public/paypal/paymentko.php | 12 +- htdocs/public/paypal/paymentok.php | 12 +- htdocs/societe/checkvat/checkVatPopup.php | 8 +- htdocs/theme/eldy/style.css.php | 3 + htdocs/websites/frametop.php | 5 +- htdocs/websites/index.php | 4 +- 19 files changed, 251 insertions(+), 110 deletions(-) diff --git a/htdocs/externalsite/frametop.php b/htdocs/externalsite/frametop.php index f33c8ae61a2..3fb50ec6745 100644 --- a/htdocs/externalsite/frametop.php +++ b/htdocs/externalsite/frametop.php @@ -27,5 +27,9 @@ require ("../main.inc.php"); $langs->load("externalsite"); top_htmlhead("",""); + +print '<body id="mainbody">' . "\n"; + top_menu("","","_top"); +print '</body>'; diff --git a/htdocs/main.inc.php b/htdocs/main.inc.php index 333eb25ad89..c6bf910a8af 100644 --- a/htdocs/main.inc.php +++ b/htdocs/main.inc.php @@ -950,20 +950,24 @@ if (! function_exists("llxHeader")) * @param array $arrayofjs Array of complementary js files * @param array $arrayofcss Array of complementary css files * @param string $morequerystring Query string to add to the link "print" to get same parameters (use only if autodetect fails) + * @param string $morecssonbody More CSS on body tag. * @return void */ - function llxHeader($head='', $title='', $help_url='', $target='', $disablejs=0, $disablehead=0, $arrayofjs='', $arrayofcss='', $morequerystring='') + function llxHeader($head='', $title='', $help_url='', $target='', $disablejs=0, $disablehead=0, $arrayofjs='', $arrayofcss='', $morequerystring='', $morecssonbody='') { global $conf; // html header top_htmlhead($head, $title, $disablejs, $disablehead, $arrayofjs, $arrayofcss); + print '<body id="mainbody"'.($morecssonbody?' class="'.$morecssonbody.'"':'').'>' . "\n"; + // top menu and left menu area if (empty($conf->dol_hide_topmenu)) { top_menu($head, $title, $target, $disablejs, $disablehead, $arrayofjs, $arrayofcss, $morequerystring, $help_url); } + if (empty($conf->dol_hide_leftmenu)) { left_menu('', $help_url, '', '', 1, $title, 1); @@ -1219,19 +1223,6 @@ function top_htmlhead($head, $title='', $disablejs=0, $disablehead=0, $arrayofjs print '<script type="text/javascript" src="'.DOL_URL_ROOT.'/core/js/editinplace.js'.($ext?'?'.$ext:'').'"></script>'."\n"; print '<script type="text/javascript" src="'.DOL_URL_ROOT.'/includes/jquery/plugins/jeditable/jquery.jeditable.ckeditor.js'.($ext?'?'.$ext:'').'"></script>'."\n"; } - // jQuery File Upload - /* - if (! empty($conf->global->MAIN_USE_JQUERY_FILEUPLOAD) || (defined('REQUIRE_JQUERY_FILEUPLOAD') && constant('REQUIRE_JQUERY_FILEUPLOAD'))) - { - print '<script type="text/javascript" src="'.DOL_URL_ROOT.'/includes/jquery/plugins/template/tmpl.min'.$ext.'"></script>'."\n"; - print '<script type="text/javascript" src="'.DOL_URL_ROOT.'/includes/jquery/plugins/fileupload/js/jquery.iframe-transport'.$ext.'"></script>'."\n"; - print '<script type="text/javascript" src="'.DOL_URL_ROOT.'/includes/jquery/plugins/fileupload/js/jquery.fileupload'.$ext.'"></script>'."\n"; - print '<script type="text/javascript" src="'.DOL_URL_ROOT.'/includes/jquery/plugins/fileupload/js/jquery.fileupload-fp'.$ext.'"></script>'."\n"; - print '<script type="text/javascript" src="'.DOL_URL_ROOT.'/includes/jquery/plugins/fileupload/js/jquery.fileupload-ui'.$ext.'"></script>'."\n"; - print '<script type="text/javascript" src="'.DOL_URL_ROOT.'/includes/jquery/plugins/fileupload/js/jquery.fileupload-jui'.$ext.'"></script>'."\n"; - print '<!-- The XDomainRequest Transport is included for cross-domain file deletion for IE8+ -->'."\n"; - print '<!--[if gte IE 8]><script type="text/javascript" src="'.DOL_URL_ROOT.'/includes/jquery/plugins/fileupload/js/cors/jquery.xdr-transport'.$ext.'"></script><![endif]-->'."\n"; - }*/ // jQuery DataTables /* Removed a old hidden problematic feature never used in Dolibarr. If an external module need datatable, the module must provide all lib it needs and manage version problems with other dolibarr components if (! empty($conf->global->MAIN_USE_JQUERY_DATATABLES) || (defined('REQUIRE_JQUERY_DATATABLES') && constant('REQUIRE_JQUERY_DATATABLES'))) @@ -1377,9 +1368,11 @@ function top_menu($head, $title='', $target='', $disablejs=0, $disablehead=0, $a $toprightmenu=''; // For backward compatibility with old modules - if (empty($conf->headerdone)) top_htmlhead($head, $title, $disablejs, $disablehead, $arrayofjs, $arrayofcss); - - print '<body id="mainbody">' . "\n"; + if (empty($conf->headerdone)) + { + top_htmlhead($head, $title, $disablejs, $disablehead, $arrayofjs, $arrayofcss); + print '<body id="mainbody">'; + } /* * Top menu @@ -1762,6 +1755,7 @@ function main_area($title='') print "\n"; print '<!-- Begin div class="fiche" -->'."\n".'<div class="fiche">'."\n"; + if (! empty($conf->global->MAIN_ONLY_LOGIN_ALLOWED)) print info_admin($langs->trans("WarningYouAreInMaintenanceMode",$conf->global->MAIN_ONLY_LOGIN_ALLOWED)); } @@ -1899,7 +1893,8 @@ if (! function_exists("llxFooter")) } print "\n\n"; - print '</div> <!-- End div class="fiche" -->'."\n"; + + print '</div> <!-- End div class="fiche" -->'."\n"; // End div fiche if (empty($conf->dol_hide_leftmenu)) print '</div> <!-- End div id-right -->'; // End div id-right diff --git a/htdocs/paybox/lib/paybox.lib.php b/htdocs/paybox/lib/paybox.lib.php index 09848ed905e..a4106488f53 100644 --- a/htdocs/paybox/lib/paybox.lib.php +++ b/htdocs/paybox/lib/paybox.lib.php @@ -33,7 +33,7 @@ * @param string $EMAIL EMail * @param string $urlok Url to go back if payment is OK * @param string $urlko Url to go back if payment is KO - * @param string $TAG Tag + * @param string $TAG Full tag * @return int 1 if OK, -1 if ERROR */ function print_paybox_redirect($PRICE,$CURRENCY,$EMAIL,$urlok,$urlko,$TAG) diff --git a/htdocs/paypal/admin/paypal.php b/htdocs/paypal/admin/paypal.php index 4942d15a9ce..ef0c40f2813 100644 --- a/htdocs/paypal/admin/paypal.php +++ b/htdocs/paypal/admin/paypal.php @@ -96,7 +96,6 @@ llxHeader('',$langs->trans("PaypalSetup")); $linkback='<a href="'.DOL_URL_ROOT.'/admin/modules.php">'.$langs->trans("BackToModuleList").'</a>'; print load_fiche_titre($langs->trans("ModuleSetup").' PayPal',$linkback); -print '<br>'; $head=paypaladmin_prepare_head(); @@ -105,7 +104,7 @@ print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">'; print '<input type="hidden" name="action" value="setvalue">'; -dol_fiche_head($head, 'paypalaccount', ''); +dol_fiche_head($head, 'paypalaccount', '', -1); print $langs->trans("PaypalDesc")."<br>\n"; @@ -138,7 +137,7 @@ print '</td></tr>'; print '<tr class="oddeven"><td class="fieldrequired">'; print $langs->trans("PAYPAL_API_USER").'</td><td>'; print '<input size="32" type="text" name="PAYPAL_API_USER" value="'.$conf->global->PAYPAL_API_USER.'">'; -print ' '.$langs->trans("Example").': paypal_api1.mywebsite.com'; +print ' '.$langs->trans("Example").': admin-facilitator_api1.example.com, paypal_api1.mywebsite.com'; print '</td></tr>'; diff --git a/htdocs/paypal/lib/paypal.lib.php b/htdocs/paypal/lib/paypal.lib.php index 9f08ffcb924..944afd34b1a 100644 --- a/htdocs/paypal/lib/paypal.lib.php +++ b/htdocs/paypal/lib/paypal.lib.php @@ -191,7 +191,7 @@ function getPaypalPaymentUrl($mode,$type,$ref='',$amount='9.99',$freetag='your_f * @param string $paymentType Payment type * @param string $returnURL Url to use if payment is OK * @param string $cancelURL Url to use if payment is KO - * @param string $tag Tag + * @param string $tag Full tag * @return void */ function print_paypal_redirect($paymentAmount,$currencyCodeType,$paymentType,$returnURL,$cancelURL,$tag) @@ -306,7 +306,7 @@ function print_paypal_redirect($paymentAmount,$currencyCodeType,$paymentType,$re * @param string $paymentType Payment type * @param string $returnURL Return Url * @param string $cancelURL Cancel Url - * @param string $tag Tag + * @param string $tag Full tag * @param string $solutionType Type * @param string $landingPage Landing page * @param string $shipToName Ship to name @@ -429,7 +429,7 @@ function getDetails($token) * @param string $payerID Payer ID * @param string $ipaddress IP Address * @param string $FinalPaymentAmt Amount - * @param string $tag Tag + * @param string $tag Full tag * @return void */ function confirmPayment($token, $paymentType, $currencyCodeType, $payerID, $ipaddress, $FinalPaymentAmt, $tag) diff --git a/htdocs/public/members/new.php b/htdocs/public/members/new.php index c307512e257..4130b616a0e 100644 --- a/htdocs/public/members/new.php +++ b/htdocs/public/members/new.php @@ -91,6 +91,7 @@ $extrafields = new ExtraFields($db); function llxHeaderVierge($title, $head="", $disablejs=0, $disablehead=0, $arrayofjs='', $arrayofcss='') { global $user, $conf, $langs, $mysoc; + top_htmlhead($head, $title, $disablejs, $disablehead, $arrayofjs, $arrayofcss); // Show html headers print '<body id="mainbody" class="publicnewmemberform" style="margin-top: 10px;">'; diff --git a/htdocs/public/paybox/newpayment.php b/htdocs/public/paybox/newpayment.php index b4b978009b7..a52358dab24 100644 --- a/htdocs/public/paybox/newpayment.php +++ b/htdocs/public/paybox/newpayment.php @@ -36,6 +36,7 @@ if (is_numeric($entity)) define("DOLENTITY", $entity); require '../../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/paybox/lib/paybox.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php'; +require_once DOL_DOCUMENT_ROOT.'/core/lib/payments.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php'; require_once DOL_DOCUMENT_ROOT.'/product/class/product.class.php'; @@ -95,6 +96,7 @@ $ref=$REF=GETPOST('ref','alpha'); $TAG=GETPOST("tag",'alpha'); $FULLTAG=GETPOST("fulltag",'alpha'); // fulltag is tag with more informations $SECUREKEY=GETPOST("securekey"); // Secure key +$FULLTAG.=($FULLTAG?'.':'').'PM=paybox'; if (! empty($SOURCE)) { @@ -126,19 +128,22 @@ $valid=true; /* * Actions */ + if (GETPOST("action") == 'dopayment') { $PRICE=price2num(GETPOST("newamount"),'MT'); $email=GETPOST("email"); + $origfulltag=GETPOST("fulltag",'alpha'); + $mesg=''; if (empty($PRICE) || ! is_numeric($PRICE)) $mesg=$langs->trans("ErrorFieldRequired",$langs->transnoentitiesnoconv("Amount")); - elseif (empty($email)) $mesg=$langs->trans("ErrorFieldRequired",$langs->transnoentitiesnoconv("YourEMail")); - elseif (! isValidEMail($email)) $mesg=$langs->trans("ErrorBadEMail",$email); - elseif (empty($FULLTAG)) $mesg=$langs->trans("ErrorFieldRequired",$langs->transnoentitiesnoconv("PaymentCode")); - elseif (dol_strlen($urlok) > 150) $mesg='Error urlok too long '.$urlok; + elseif (empty($email)) $mesg=$langs->trans("ErrorFieldRequired",$langs->transnoentitiesnoconv("YourEMail")); + elseif (! isValidEMail($email)) $mesg=$langs->trans("ErrorBadEMail",$email); + elseif (! $origfulltag) $mesg=$langs->trans("ErrorFieldRequired",$langs->transnoentitiesnoconv("PaymentCode")); + elseif (dol_strlen($urlok) > 150) $mesg='Error urlok too long '.$urlok; elseif (dol_strlen($urlko) > 150) $mesg='Error urlko too long '.$urlko; - + if (empty($mesg)) { dol_syslog("newpayment.php call paybox api and do redirect", LOG_DEBUG); @@ -156,7 +161,13 @@ if (GETPOST("action") == 'dopayment') * View */ -llxHeaderPayBox($langs->trans("PaymentForm")); +$head=''; +if (! empty($conf->global->PAYBOX_CSS_URL)) $head='<link rel="stylesheet" type="text/css" href="'.$conf->global->PAYBOX_CSS_URL.'?lang='.$langs->defaultlang.'">'."\n"; + +$conf->dol_hide_topmenu=1; +$conf->dol_hide_leftmenu=1; + +llxHeader($head, $langs->trans("PaymentForm"), '', '', 0, 0, '', '', '', 'onlinepaymentbody'); // Common variables @@ -782,9 +793,9 @@ print '</div>'."\n"; print '<br>'; -html_print_paybox_footer($mysoc,$langs); +htmlPrintOnlinePaymentFooter($mysoc,$langs); -llxFooterPayBox(); +llxFooter('', 'public'); $db->close(); diff --git a/htdocs/public/paybox/paymentko.php b/htdocs/public/paybox/paymentko.php index 0b6b0955bb2..f5f42c8a529 100644 --- a/htdocs/public/paybox/paymentko.php +++ b/htdocs/public/paybox/paymentko.php @@ -97,8 +97,10 @@ if (! empty($conf->global->PAYBOX_PAYONLINE_SENDEMAIL)) $head=''; if (! empty($conf->global->PAYBOX_CSS_URL)) $head='<link rel="stylesheet" type="text/css" href="'.$conf->global->PAYBOX_CSS_URL.'?lang='.$langs->defaultlang.'">'."\n"; +$conf->dol_hide_topmenu=1; +$conf->dol_hide_leftmenu=1; -llxHeader($head, $langs->trans("PaymentForm")); +llxHeader($head, $langs->trans("PaymentForm"), '', '', 0, 0, '', '', '', 'onlinepaymentbody'); // Show message @@ -115,6 +117,6 @@ print "\n</div>\n"; htmlPrintOnlinePaymentFooter($mysoc,$langs); -llxFooter(); +llxFooter('', 'public'); $db->close(); diff --git a/htdocs/public/paybox/paymentok.php b/htdocs/public/paybox/paymentok.php index 482f58ed909..92bd484cde5 100644 --- a/htdocs/public/paybox/paymentok.php +++ b/htdocs/public/paybox/paymentok.php @@ -55,8 +55,8 @@ if (empty($PAYBOXTOKEN)) $PAYBOXTOKEN=GETPOST('token'); $PAYBOXPAYERID=GETPOST('PAYERID'); if (empty($PAYBOXPAYERID)) $PAYBOXPAYERID=GETPOST('PayerID'); */ -$PAYBOXFULLTAG=GETPOST('FULLTAG'); -if (empty($PAYBOXFULLTAG)) $PAYBOXFULLTAG=GETPOST('fulltag'); +$FULLTAG=GETPOST('FULLTAG'); +if (empty($FULLTAG)) $FULLTAG=GETPOST('fulltag'); /* @@ -81,8 +81,10 @@ dol_syslog("POST=".$tracepost, LOG_DEBUG, 0, '_paybox'); $head=''; if (! empty($conf->global->PAYBOX_CSS_URL)) $head='<link rel="stylesheet" type="text/css" href="'.$conf->global->PAYBOX_CSS_URL.'?lang='.$langs->defaultlang.'">'."\n"; +$conf->dol_hide_topmenu=1; +$conf->dol_hide_leftmenu=1; -llxHeader($head, $langs->trans("PaymentForm")); +llxHeader($head, $langs->trans("PaymentForm"), '', '', 0, 0, '', '', '', 'onlinepaymentbody'); // Show message @@ -93,7 +95,7 @@ print '<div id="dolpaymentdiv" align="center">'."\n"; /* $token = $PAYBOXTOKEN; */ -$fulltag = $PAYBOXFULLTAG; +$fulltag = $FULLTAG; /*$payerID = $PAYBOXPAYERID; // Set by newpayment.php $paymentType = $_SESSION['PaymentType']; @@ -173,6 +175,6 @@ print "\n</div>\n"; htmlPrintOnlinePaymentFooter($mysoc,$langs); -llxFooter(); +llxFooter('', 'public'); $db->close(); diff --git a/htdocs/public/payment/newpayment.php b/htdocs/public/payment/newpayment.php index 4c4b6863aaa..1ea8e7385ea 100644 --- a/htdocs/public/payment/newpayment.php +++ b/htdocs/public/payment/newpayment.php @@ -16,7 +16,8 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. * - * For test: https://developer.paypal.com/ + * For paypal test: https://developer.paypal.com/ + * For paybox test: ??? */ /** @@ -37,6 +38,7 @@ if (is_numeric($entity)) define("DOLENTITY", $entity); require '../../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php'; +require_once DOL_DOCUMENT_ROOT.'/core/lib/payments.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php'; require_once DOL_DOCUMENT_ROOT.'/product/class/product.class.php'; @@ -49,6 +51,9 @@ $langs->load("dict"); $langs->load("bills"); $langs->load("companies"); $langs->load("errors"); +$langs->load("paybox"); // File with generic data + +$action=GETPOST('action','alpha'); // Input are: // type ('invoice','order','contractline'), @@ -62,7 +67,7 @@ $amount=price2num(GETPOST("amount")); if (! GETPOST("currency",'alpha')) $currency=$conf->currency; else $currency=GETPOST("currency",'alpha'); -if (! GETPOST("action")) +if (! $action) { if (! GETPOST("amount") && ! GETPOST("source")) { @@ -81,10 +86,25 @@ if (! GETPOST("action")) } } + +$paymentmethod=''; +$validpaymentmethod=array(); + +// Detect $paymentmethod +foreach($_POST as $key => $val) +{ + if (preg_match('/^dopayment_(.*)$/', $key, $reg)) + { + $paymentmethod=$reg[1]; + break; + } +} + + // Define $urlwithroot //$urlwithouturlroot=preg_replace('/'.preg_quote(DOL_URL_ROOT,'/').'$/i','',trim($dolibarr_main_url_root)); //$urlwithroot=$urlwithouturlroot.DOL_URL_ROOT; // This is to use external domain name found into config file -$urlwithroot=DOL_MAIN_URL_ROOT; // This is to use same domain name than current +$urlwithroot=DOL_MAIN_URL_ROOT; // This is to use same domain name than current. For Paypal payment, we can use internal URL like localhost. $urlok=$urlwithroot.'/public/payment/paymentok.php?'; $urlko=$urlwithroot.'/public/payment/paymentko.php?'; @@ -95,6 +115,7 @@ $ref=$REF=GETPOST('ref','alpha'); $TAG=GETPOST("tag",'alpha'); $FULLTAG=GETPOST("fulltag",'alpha'); // fulltag is tag with more informations $SECUREKEY=GETPOST("securekey"); // Secure key +if ($paymentmethod) $FULLTAG.=($FULLTAG?'.':'').'PM='.$paymentmethod; if (! empty($SOURCE)) { @@ -129,9 +150,10 @@ if (! empty($entity)) $urlok=preg_replace('/&$/','',$urlok); // Remove last & $urlko=preg_replace('/&$/','',$urlko); // Remove last & -$paymentmethod=array(); -// Check parameters + +// Find valid payment methods + if (! empty($conf->paypal->enabled)) { $langs->load("paypal"); @@ -158,7 +180,7 @@ if (! empty($conf->paypal->enabled)) dol_print_error('',"Paypal setup param PAYPAL_API_SIGNATURE not defined"); return -1; } - + // Check security token $valid=true; if (! empty($conf->global->PAYPAL_SECURITY_TOKEN)) @@ -173,28 +195,57 @@ if (! empty($conf->paypal->enabled)) $token = $conf->global->PAYPAL_SECURITY_TOKEN; } if ($SECUREKEY != $token) $valid=false; - + if (! $valid) { print '<div class="error">Bad value for key.</div>'; //print 'SECUREKEY='.$SECUREKEY.' token='.$token.' valid='.$valid; exit; } - else - { - $paymentmethod[]='paypal'; - } } + + $validpaymentmethod['paypal']='valid'; } + if (! empty($conf->paybox->enabled)) { $langs->load("paybox"); + // TODO + + $validpaymentmethod['paybox']='valid'; } + // TODO Add check of other payment mode -if (empty($paymentmethod)) accessforbidden('', 0, 0, 1); +// Check security token +$valid=true; +if (! empty($conf->global->PAYMENT_SECURITY_TOKEN)) +{ + if (! empty($conf->global->PAYMENT_SECURITY_TOKEN_UNIQUE)) + { + if ($SOURCE && $REF) $token = dol_hash($conf->global->PAYMENT_SECURITY_TOKEN . $SOURCE . $REF, 2); // Use the source in the hash to avoid duplicates if the references are identical + else $token = dol_hash($conf->global->PAYMENT_SECURITY_TOKEN, 2); + } + else + { + $token = $conf->global->PAYMENT_SECURITY_TOKEN; + } + if ($SECUREKEY != $token) $valid=false; + + if (! $valid) + { + print '<div class="error">Bad value for key.</div>'; + //print 'SECUREKEY='.$SECUREKEY.' token='.$token.' valid='.$valid; + exit; + } +} + + + + +if (empty($validpaymentmethod)) accessforbidden('', 0, 0, 1); @@ -202,13 +253,15 @@ if (empty($paymentmethod)) accessforbidden('', 0, 0, 1); * Actions */ -if (GETPOST("action") == 'dopayment') + +if ($action == 'dopayment') { - if (GETPOST('paymentmethod') == 'paypal') + if ($paymentmethod == 'paypal') { $PAYPAL_API_PRICE=price2num(GETPOST("newamount"),'MT'); $PAYPAL_PAYMENT_TYPE='Sale'; + $origfulltag=GETPOST("fulltag",'alpha'); $shipToName=GETPOST("shipToName"); $shipToStreet=GETPOST("shipToStreet"); $shipToCity=GETPOST("shipToCity"); @@ -224,7 +277,7 @@ if (GETPOST("action") == 'dopayment') if (empty($PAYPAL_API_PRICE) || ! is_numeric($PAYPAL_API_PRICE)) $mesg=$langs->trans("ErrorFieldRequired",$langs->transnoentitiesnoconv("Amount")); //elseif (empty($EMAIL)) $mesg=$langs->trans("ErrorFieldRequired",$langs->transnoentitiesnoconv("YourEMail")); //elseif (! isValidEMail($EMAIL)) $mesg=$langs->trans("ErrorBadEMail",$EMAIL); - elseif (empty($FULLTAG)) $mesg=$langs->trans("ErrorFieldRequired",$langs->transnoentitiesnoconv("PaymentCode")); + elseif (! $origfulltag) $mesg=$langs->trans("ErrorFieldRequired",$langs->transnoentitiesnoconv("PaymentCode")); //var_dump($_POST); if (empty($mesg)) @@ -275,7 +328,14 @@ if (GETPOST("action") == 'dopayment') * View */ -llxHeaderPaypal($langs->trans("PaymentForm")); +$head=''; +if (! empty($conf->global->PAYMENT_CSS_URL)) $head='<link rel="stylesheet" type="text/css" href="'.$conf->global->PAYMENT_CSS_URL.'?lang='.$langs->defaultlang.'">'."\n"; + +$conf->dol_hide_topmenu=1; +$conf->dol_hide_leftmenu=1; + +llxHeader($head, $langs->trans("PaymentForm"), '', '', 0, 0, '', '', '', 'onlinepaymentbody'); + if (! empty($conf->paypal->enabled)) { @@ -302,12 +362,18 @@ print '<input type="hidden" name="securekey" value="'.$SECUREKEY.'">'."\n"; print '<input type="hidden" name="entity" value="'.$entity.'" />'; print "\n"; print '<!-- Form to send a payment -->'."\n"; +// Additionnal information for each payment system if (! empty($conf->paypal->enabled)) { print '<!-- PAYPAL_API_SANDBOX = '.$conf->global->PAYPAL_API_SANDBOX.' -->'."\n"; print '<!-- PAYPAL_API_INTEGRAL_OR_PAYPALONLY = '.$conf->global->PAYPAL_API_INTEGRAL_OR_PAYPALONLY.' -->'."\n"; print '<!-- creditor = '.$creditor.' -->'."\n"; } +if (! empty($conf->paybox->enabled)) +{ + +} +// TODO Add others print '<!-- urlok = '.$urlok.' -->'."\n"; print '<!-- urlko = '.$urlko.' -->'."\n"; print "\n"; @@ -370,7 +436,7 @@ $error=0; $var=false; // Free payment -if (! GETPOST("source") && $valid) +if (! GETPOST("source")) { $found=true; $tag=GETPOST("tag"); @@ -417,7 +483,7 @@ if (! GETPOST("source") && $valid) // Payment on customer order -if (GETPOST("source") == 'order' && $valid) +if (GETPOST("source") == 'order') { $found=true; $langs->load("orders"); @@ -524,7 +590,7 @@ if (GETPOST("source") == 'order' && $valid) // Payment on customer invoice -if (GETPOST("source") == 'invoice' && $valid) +if (GETPOST("source") == 'invoice') { $found=true; $langs->load("bills"); @@ -630,7 +696,7 @@ if (GETPOST("source") == 'invoice' && $valid) } // Payment on contract line -if (GETPOST("source") == 'contractline' && $valid) +if (GETPOST("source") == 'contractline') { $found=true; $langs->load("contracts"); @@ -825,7 +891,7 @@ if (GETPOST("source") == 'contractline' && $valid) } // Payment on member subscription -if (GETPOST("source") == 'membersubscription' && $valid) +if (GETPOST("source") == 'membersubscription') { $found=true; $langs->load("members"); @@ -971,16 +1037,29 @@ print "\n"; if ($found && ! $error) // We are in a management option and no error { - if (empty($conf->global->PAYPAL_API_INTEGRAL_OR_PAYPALONLY)) $conf->global->PAYPAL_API_INTEGRAL_OR_PAYPALONLY='integral'; + // Buttons for all payments registration methods + + if (! empty($conf->paypal->enabled)) + { + if (empty($conf->global->PAYPAL_API_INTEGRAL_OR_PAYPALONLY)) $conf->global->PAYPAL_API_INTEGRAL_OR_PAYPALONLY='integral'; + + if ($conf->global->PAYPAL_API_INTEGRAL_OR_PAYPALONLY == 'integral') + { + print '<br><input class="button" type="submit" name="dopayment_paypal" value="'.$langs->trans("PaypalOrCBDoPayment").'">'; + } + if ($conf->global->PAYPAL_API_INTEGRAL_OR_PAYPALONLY == 'paypalonly') + { + print '<br><input class="button" type="submit" name="dopayment_paypal" value="'.$langs->trans("PaypalDoPayment").'">'; + } + } - if ($conf->global->PAYPAL_API_INTEGRAL_OR_PAYPALONLY == 'integral') - { - print '<br><input class="button" type="submit" name="dopayment" value="'.$langs->trans("PaypalOrCBDoPayment").'">'; - } - if ($conf->global->PAYPAL_API_INTEGRAL_OR_PAYPALONLY == 'paypalonly') - { - print '<br><input class="button" type="submit" name="dopayment" value="'.$langs->trans("PaypalDoPayment").'">'; - } + if (! empty($conf->paypal->enabled)) + { + + + } + + // TODO Other methods } else { @@ -995,8 +1074,8 @@ print '</div>'."\n"; print '<br>'; -html_print_paypal_footer($mysoc,$langs); +htmlPrintOnlinePaymentFooter($mysoc,$langs); -llxFooterPaypal(); +llxFooter('', 'public'); $db->close(); diff --git a/htdocs/public/payment/paymentko.php b/htdocs/public/payment/paymentko.php index 5bd09f845da..ceface2a9c0 100644 --- a/htdocs/public/payment/paymentko.php +++ b/htdocs/public/payment/paymentko.php @@ -57,16 +57,16 @@ $PAYPALTOKEN=GETPOST('TOKEN'); if (empty($PAYPALTOKEN)) $PAYPALTOKEN=GETPOST('token'); $PAYPALPAYERID=GETPOST('PAYERID'); if (empty($PAYPALPAYERID)) $PAYPALPAYERID=GETPOST('PayerID'); -$PAYPALFULLTAG=GETPOST('FULLTAG'); -if (empty($PAYPALFULLTAG)) $PAYPALFULLTAG=GETPOST('fulltag'); +$FULLTAG=GETPOST('FULLTAG'); +if (empty($FULLTAG)) $FULLTAG=GETPOST('fulltag'); -$paymentmethod=array(); -if (! empty($conf->paypal->enabled)) $paymentmethod['paypal']='paypal'; -if (! empty($conf->paybox->enabled)) $paymentmethod['paybox']='paybox'; +$validpaymentmethod=array(); +if (! empty($conf->paypal->enabled)) $validpaymentmethod['paypal']='paypal'; +if (! empty($conf->paybox->enabled)) $validpaymentmethod['paybox']='paybox'; // Security check -if (empty($paymentmethod)) accessforbidden('', 0, 0, 1); +if (empty($validpaymentmethod)) accessforbidden('', 0, 0, 1); /* @@ -94,7 +94,7 @@ if (! empty($conf->paypal->enabled)) { // Get on url call $token = $PAYPALTOKEN; - $fulltag = $PAYPALFULLTAG; + $fulltag = $FULLTAG; $payerID = $PAYPALPAYERID; // Set by newpayment.php $paymentType = $_SESSION['PaymentType']; @@ -128,7 +128,10 @@ if (! empty($conf->paypal->enabled)) $head=''; if (! empty($conf->global->PAYMENT_CSS_URL)) $head='<link rel="stylesheet" type="text/css" href="'.$conf->global->PAYMENT_CSS_URL.'?lang='.$langs->defaultlang.'">'."\n"; -llxHeader($head, $langs->trans("PaymentForm")); +$conf->dol_hide_topmenu=1; +$conf->dol_hide_leftmenu=1; + +llxHeader($head, $langs->trans("PaymentForm"), '', '', 0, 0, '', '', '', 'onlinepaymentbody'); // Show ko message @@ -143,6 +146,6 @@ print "\n</div>\n"; htmlPrintOnlinePaymentFooter($mysoc,$langs); -llxFooter(); +llxFooter('', 'public'); $db->close(); diff --git a/htdocs/public/payment/paymentok.php b/htdocs/public/payment/paymentok.php index 221abec032f..c138cc29267 100644 --- a/htdocs/public/payment/paymentok.php +++ b/htdocs/public/payment/paymentok.php @@ -88,28 +88,46 @@ if (! empty($conf->paypal->enabled)) if (empty($PAYPALTOKEN)) $PAYPALTOKEN=GETPOST('token'); $PAYPALPAYERID=GETPOST('PAYERID'); if (empty($PAYPALPAYERID)) $PAYPALPAYERID=GETPOST('PayerID'); - $PAYPALFULLTAG=GETPOST('FULLTAG'); - if (empty($PAYPALFULLTAG)) $PAYPALFULLTAG=GETPOST('fulltag'); + $FULLTAG=GETPOST('FULLTAG'); + if (empty($FULLTAG)) $FULLTAG=GETPOST('fulltag'); } $source=GETPOST('source'); $ref=GETPOST('ref'); -$paymentmethod=array(); -if (! empty($conf->paypal->enabled)) $paymentmethod['paypal']='paypal'; -if (! empty($conf->paybox->enabled)) $paymentmethod['paybox']='paybox'; +// Detect $paymentmethod +$paymentmethod=''; +if (preg_match('/PM=([^\.]+)/', $FULLTAG, $reg)) +{ + $paymentmethod=$reg[1]; +} +if (empty($paymentmethod)) +{ + dol_print_error(null, 'The back url does not contains a parameter fulltag that should help us to find the payment method used'); + exit; +} +else +{ + dol_syslog("paymentmethod=".$paymentmethod); +} + + +$validpaymentmethod=array(); +if (! empty($conf->paypal->enabled)) $validpaymentmethod['paypal']='paypal'; +if (! empty($conf->paybox->enabled)) $validpaymentmethod['paybox']='paybox'; // Security check -if (empty($paymentmethod)) accessforbidden('', 0, 0, 1); +if (empty($validpaymentmethod)) accessforbidden('', 0, 0, 1); +$ispaymentok = false; // If payment is ok $PAYMENTSTATUS=$TRANSACTIONID=$TAXAMT=$NOTE=''; // If payment is ko $ErrorCode=$ErrorShortMsg=$ErrorLongMsg=$ErrorSeverityCode=''; -$ispaymentok = false; + /* @@ -131,8 +149,10 @@ dol_syslog("POST=".$tracepost, LOG_DEBUG, 0, '_payment'); $head=''; if (! empty($conf->global->PAYMENT_CSS_URL)) $head='<link rel="stylesheet" type="text/css" href="'.$conf->global->PAYMENT_CSS_URL.'?lang='.$langs->defaultlang.'">'."\n"; +$conf->dol_hide_topmenu=1; +$conf->dol_hide_leftmenu=1; -llxHeader($head, $langs->trans("PaymentForm")); +llxHeader($head, $langs->trans("PaymentForm"), '', '', 0, 0, '', '', '', 'onlinepaymentbody'); @@ -147,7 +167,7 @@ if (! empty($conf->paypal->enabled)) { // Get on url call $token = $PAYPALTOKEN; - $fulltag = $PAYPALFULLTAG; + $fulltag = $FULLTAG; $payerID = $PAYPALPAYERID; // Set by newpayment.php $paymentType = $_SESSION['PaymentType']; @@ -334,6 +354,6 @@ print "\n</div>\n"; htmlPrintOnlinePaymentFooter($mysoc,$langs); -llxFooter(); +llxFooter('', 'public'); $db->close(); diff --git a/htdocs/public/paypal/newpayment.php b/htdocs/public/paypal/newpayment.php index 4acce4ac803..9698f42afa7 100644 --- a/htdocs/public/paypal/newpayment.php +++ b/htdocs/public/paypal/newpayment.php @@ -39,6 +39,7 @@ require '../../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/paypal/lib/paypal.lib.php'; require_once DOL_DOCUMENT_ROOT.'/paypal/lib/paypalfunctions.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php'; +require_once DOL_DOCUMENT_ROOT.'/core/lib/payments.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php'; require_once DOL_DOCUMENT_ROOT.'/product/class/product.class.php'; @@ -51,7 +52,7 @@ $langs->load("dict"); $langs->load("bills"); $langs->load("companies"); $langs->load("errors"); -$langs->load("paybox"); +$langs->load("paybox"); // File with generic data $langs->load("paypal"); // Input are: @@ -99,6 +100,7 @@ $ref=$REF=GETPOST('ref','alpha'); $TAG=GETPOST("tag",'alpha'); $FULLTAG=GETPOST("fulltag",'alpha'); // fulltag is tag with more informations $SECUREKEY=GETPOST("securekey"); // Secure key +$FULLTAG.=($FULLTAG?'.':'').'PM=paypal'; if (! empty($SOURCE)) { @@ -188,6 +190,7 @@ if (GETPOST("action") == 'dopayment') $PAYPAL_API_PRICE=price2num(GETPOST("newamount"),'MT'); $PAYPAL_PAYMENT_TYPE='Sale'; + $origfulltag=GETPOST("fulltag",'alpha'); $shipToName=GETPOST("shipToName"); $shipToStreet=GETPOST("shipToStreet"); $shipToCity=GETPOST("shipToCity"); @@ -203,7 +206,7 @@ if (GETPOST("action") == 'dopayment') if (empty($PAYPAL_API_PRICE) || ! is_numeric($PAYPAL_API_PRICE)) $mesg=$langs->trans("ErrorFieldRequired",$langs->transnoentitiesnoconv("Amount")); //elseif (empty($EMAIL)) $mesg=$langs->trans("ErrorFieldRequired",$langs->transnoentitiesnoconv("YourEMail")); //elseif (! isValidEMail($EMAIL)) $mesg=$langs->trans("ErrorBadEMail",$EMAIL); - elseif (empty($FULLTAG)) $mesg=$langs->trans("ErrorFieldRequired",$langs->transnoentitiesnoconv("PaymentCode")); + elseif (! $origfulltag) $mesg=$langs->trans("ErrorFieldRequired",$langs->transnoentitiesnoconv("PaymentCode")); //var_dump($_POST); if (empty($mesg)) @@ -254,7 +257,13 @@ if (GETPOST("action") == 'dopayment') * View */ -llxHeaderPaypal($langs->trans("PaymentForm")); +$head=''; +if (! empty($conf->global->PAYPAL_CSS_URL)) $head='<link rel="stylesheet" type="text/css" href="'.$conf->global->PAYPAL_CSS_URL.'?lang='.$langs->defaultlang.'">'."\n"; + +$conf->dol_hide_topmenu=1; +$conf->dol_hide_leftmenu=1; + +llxHeader($head, $langs->trans("PaymentForm"), '', '', 0, 0, '', '', '', 'onlinepaymentbody'); if (! empty($PAYPAL_API_SANDBOX)) { @@ -968,8 +977,8 @@ print '</div>'."\n"; print '<br>'; -html_print_paypal_footer($mysoc,$langs); +htmlPrintOnlinePaymentFooter($mysoc,$langs); -llxFooterPaypal(); +llxFooter('', 'public'); $db->close(); diff --git a/htdocs/public/paypal/paymentko.php b/htdocs/public/paypal/paymentko.php index 7436693a1c1..a3ff8b5b7a3 100644 --- a/htdocs/public/paypal/paymentko.php +++ b/htdocs/public/paypal/paymentko.php @@ -56,8 +56,8 @@ $PAYPALTOKEN=GETPOST('TOKEN'); if (empty($PAYPALTOKEN)) $PAYPALTOKEN=GETPOST('token'); $PAYPALPAYERID=GETPOST('PAYERID'); if (empty($PAYPALPAYERID)) $PAYPALPAYERID=GETPOST('PayerID'); -$PAYPALFULLTAG=GETPOST('FULLTAG'); -if (empty($PAYPALFULLTAG)) $PAYPALFULLTAG=GETPOST('fulltag'); +$FULLTAG=GETPOST('FULLTAG'); +if (empty($FULLTAG)) $FULLTAG=GETPOST('fulltag'); /* @@ -83,7 +83,7 @@ if (! empty($conf->global->PAYPAL_PAYONLINE_SENDEMAIL)) { // Get on url call $token = $PAYPALTOKEN; - $fulltag = $PAYPALFULLTAG; + $fulltag = $FULLTAG; $payerID = $PAYPALPAYERID; // Set by newpayment.php $paymentType = $_SESSION['PaymentType']; @@ -117,8 +117,10 @@ if (! empty($conf->global->PAYPAL_PAYONLINE_SENDEMAIL)) $head=''; if (! empty($conf->global->PAYPAL_CSS_URL)) $head='<link rel="stylesheet" type="text/css" href="'.$conf->global->PAYPAL_CSS_URL.'?lang='.$langs->defaultlang.'">'."\n"; +$conf->dol_hide_topmenu=1; +$conf->dol_hide_leftmenu=1; -llxHeader($head, $langs->trans("PaymentForm")); +llxHeader($head, $langs->trans("PaymentForm"), '', '', 0, 0, '', '', '', 'onlinepaymentbody'); // Show ko message @@ -133,6 +135,6 @@ print "\n</div>\n"; htmlPrintOnlinePaymentFooter($mysoc,$langs); -llxFooter(); +llxFooter('', 'public'); $db->close(); diff --git a/htdocs/public/paypal/paymentok.php b/htdocs/public/paypal/paymentok.php index 984c282d161..c38612c8ac8 100644 --- a/htdocs/public/paypal/paymentok.php +++ b/htdocs/public/paypal/paymentok.php @@ -87,8 +87,8 @@ $PAYPALTOKEN=GETPOST('TOKEN'); if (empty($PAYPALTOKEN)) $PAYPALTOKEN=GETPOST('token'); $PAYPALPAYERID=GETPOST('PAYERID'); if (empty($PAYPALPAYERID)) $PAYPALPAYERID=GETPOST('PayerID'); -$PAYPALFULLTAG=GETPOST('FULLTAG'); -if (empty($PAYPALFULLTAG)) $PAYPALFULLTAG=GETPOST('fulltag'); +$FULLTAG=GETPOST('FULLTAG'); +if (empty($FULLTAG)) $FULLTAG=GETPOST('fulltag'); /* @@ -111,8 +111,10 @@ dol_syslog("POST=".$tracepost, LOG_DEBUG, 0, '_paypal'); $head=''; if (! empty($conf->global->PAYPAL_CSS_URL)) $head='<link rel="stylesheet" type="text/css" href="'.$conf->global->PAYPAL_CSS_URL.'?lang='.$langs->defaultlang.'">'."\n"; +$conf->dol_hide_topmenu=1; +$conf->dol_hide_leftmenu=1; -llxHeader($head, $langs->trans("PaymentForm")); +llxHeader($head, $langs->trans("PaymentForm"), '', '', 0, 0, '', '', '', 'onlinepaymentbody'); // Show message @@ -123,7 +125,7 @@ if ($PAYPALTOKEN) { // Get on url call $token = $PAYPALTOKEN; - $fulltag = $PAYPALFULLTAG; + $fulltag = $FULLTAG; $payerID = $PAYPALPAYERID; // Set by newpayment.php $paymentType = $_SESSION['PaymentType']; @@ -289,6 +291,6 @@ print "\n</div>\n"; htmlPrintOnlinePaymentFooter($mysoc,$langs); -llxFooter(); +llxFooter('', 'public'); $db->close(); diff --git a/htdocs/societe/checkvat/checkVatPopup.php b/htdocs/societe/checkvat/checkVatPopup.php index dd1cd7df740..f1e56d4a359 100644 --- a/htdocs/societe/checkvat/checkVatPopup.php +++ b/htdocs/societe/checkvat/checkVatPopup.php @@ -34,8 +34,12 @@ $WS_DOL_URL_WSDL='http://ec.europa.eu/taxation_customs/vies/checkVatService.wsdl $WS_METHOD ='checkVat'; -top_htmlhead("", $langs->trans("VATIntraCheckableOnEUSite")); -print '<body style="margin: 10px">'; + +$conf->dol_hide_topmenu=1; +$conf->dol_hide_leftmenu=1; + +llxHeader('', $langs->trans("VATIntraCheckableOnEUSite")); + print '<div>'; print '<div>'; diff --git a/htdocs/theme/eldy/style.css.php b/htdocs/theme/eldy/style.css.php index f1d17801072..39f17317076 100644 --- a/htdocs/theme/eldy/style.css.php +++ b/htdocs/theme/eldy/style.css.php @@ -988,6 +988,9 @@ div.fiche { <?php if (! empty($conf->dol_hide_leftmenu) && ! empty($conf->dol_hide_topmenu)) print 'margin-top: 4px;'."\n"; ?> <?php if (! empty($conf->dol_hide_leftmenu)) print 'margin-bottom: 12px;'."\n"; ?> } +body.onlinepaymentbody div.fiche { /* For online payment page */ + margin: 40px !important; +} div.fiche>table:first-child { margin-bottom: 15px !important; } diff --git a/htdocs/websites/frametop.php b/htdocs/websites/frametop.php index 9001691b72c..7cebf239e28 100644 --- a/htdocs/websites/frametop.php +++ b/htdocs/websites/frametop.php @@ -28,11 +28,14 @@ require ("../main.inc.php"); $langs->load("externalsite"); top_htmlhead("",""); + +print '<body id="mainbody">' . "\n"; + top_menu("","","_top"); +print '</body>'; /* $website = new Website($db); $listofwebsites = $website->fetchAll(); */ -print 'rrr'; diff --git a/htdocs/websites/index.php b/htdocs/websites/index.php index b78a172e01f..e7dbb898145 100644 --- a/htdocs/websites/index.php +++ b/htdocs/websites/index.php @@ -38,7 +38,7 @@ define('NOSTYLECHECK',1); * @param int $disablehead More content into html header * @param array $arrayofjs Array of complementary js files * @param array $arrayofcss Array of complementary css files - * @param string $morequerystring Query string to add to the link "print" to get same parameters (use only if autodetect fails) + * @param string $morequerystring Query string to add to the link "print" to get same parameters (set this only if autodetect fails) * @return void */ function llxHeader($head='', $title='', $help_url='', $target='', $disablejs=0, $disablehead=0, $arrayofjs='', $arrayofcss='', $morequerystring='') @@ -48,6 +48,8 @@ function llxHeader($head='', $title='', $help_url='', $target='', $disablejs=0, // html header top_htmlhead($head, $title, $disablejs, $disablehead, $arrayofjs, $arrayofcss); + print '<body id="mainbody">'; + // top menu and left menu area if (empty($conf->dol_hide_topmenu)) { -- GitLab