dolibarr 24.0.0-beta
index.php
Go to the documentation of this file.
1<?php
2/* Copyright (C) 2021 Dorian Vabre <dorian.vabre@gmail.com>
3 * Copyright (C) 2024-2026 Frédéric France <frederic.france@free.fr>
4 * Copyright (C) 2025 MDW <mdeweerd@users.noreply.github.com>
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 3 of the License, or
9 * (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program. If not, see <https://www.gnu.org/licenses/>.
18 */
19
27if (!defined('NOLOGIN')) {
28 define("NOLOGIN", 1); // This means this output page does not require to be logged.
29}
30if (!defined('NOCSRFCHECK')) {
31 define("NOCSRFCHECK", 1); // We accept to go on this page from external web site.
32}
33if (!defined('NOIPCHECK')) {
34 define('NOIPCHECK', '1'); // Do not check IP defined into conf $dolibarr_main_restrict_ip
35}
36if (!defined('NOBROWSERNOTIF')) {
37 define('NOBROWSERNOTIF', '1');
38}
39
40// For MultiCompany module.
41// Do not use GETPOST here, function is not defined and get of entity must be done before including main.inc.php
42// Because 2 entities can have the same ref.
43$entity = (!empty($_GET['entity']) ? (int) $_GET['entity'] : (!empty($_POST['entity']) ? (int) $_POST['entity'] : (!empty($_GET['e']) ? (int) $_GET['e'] : (!empty($_POST['e']) ? (int) $_POST['e'] : 1))));
44if (is_numeric($entity)) {
45 define("DOLENTITY", $entity);
46}
47
48// Load Dolibarr environment
49require '../../main.inc.php';
50require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php';
51require_once DOL_DOCUMENT_ROOT.'/core/lib/payments.lib.php';
52require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php';
53require_once DOL_DOCUMENT_ROOT.'/product/class/product.class.php';
54require_once DOL_DOCUMENT_ROOT.'/societe/class/societeaccount.class.php';
55require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php';
56require_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php';
57
69// Load translation files
70$langs->loadLangs(array("other", "dict", "bills", "companies", "errors", "paypal", "stripe")); // File with generic data
71
72// Security check
73// No check on module enabled. Done later according to $validpaymentmethod
74
75$errmsg = '';
76$error = 0;
77$action = GETPOST('action', 'aZ09');
78$id = GETPOSTINT('id');
79$securekeyreceived = GETPOST("securekey", 'alpha');
80$securekeytocompare = dol_hash(getDolGlobalString('EVENTORGANIZATION_SECUREKEY').'conferenceorbooth'.((int) $id), 'md5');
81
82if ($securekeytocompare != $securekeyreceived) {
83 print $langs->trans('MissingOrBadSecureKey');
84 exit;
85}
86
87// Define $urlwithroot
88//$urlwithouturlroot=preg_replace('/'.preg_quote(DOL_URL_ROOT,'/').'$/i','',trim($dolibarr_main_url_root));
89//$urlwithroot=$urlwithouturlroot.DOL_URL_ROOT; // This is to use external domain name found into config file
90$urlwithroot = DOL_MAIN_URL_ROOT; // This is to use same domain name than current. For Paypal payment, we can use internal URL like localhost.
91
92$project = new Project($db);
93$resultproject = $project->fetch($id);
94if ($resultproject < 0) {
95 $error++;
96 $errmsg .= $project->error;
97}
98
99$hookmanager->initHooks(array('newpayment'));
100
101$user->loadDefaultValues();
102
103// Security check
104if (empty($conf->project->enabled)) {
105 httponly_accessforbidden('Module Project not enabled');
106}
107
108
109
124function llxHeaderVierge($title, $head = "", $disablejs = 0, $disablehead = 0, $arrayofjs = [], $arrayofcss = [], $ws = '') // @phan-suppress-current-line PhanRedefineFunction
125{
126 global $conf, $langs, $mysoc;
127
128 top_htmlhead($head, $title, $disablejs, $disablehead, $arrayofjs, $arrayofcss); // Show html headers
129
130 print '<body id="mainbody" class="publicnewmemberform">';
131
132 // Define urllogo
133 $urllogo = DOL_URL_ROOT.'/theme/common/login_logo.png';
134
135 if (!empty($mysoc->logo_small) && is_readable($conf->mycompany->dir_output.'/logos/thumbs/'.$mysoc->logo_small)) {
136 $urllogo = DOL_URL_ROOT.'/viewimage.php?cache=1&amp;modulepart=mycompany&amp;file='.urlencode('logos/thumbs/'.$mysoc->logo_small);
137 } elseif (!empty($mysoc->logo) && is_readable($conf->mycompany->dir_output.'/logos/'.$mysoc->logo)) {
138 $urllogo = DOL_URL_ROOT.'/viewimage.php?cache=1&amp;modulepart=mycompany&amp;file='.urlencode('logos/'.$mysoc->logo);
139 } elseif (is_readable(DOL_DOCUMENT_ROOT.'/theme/dolibarr_logo.svg')) {
140 $urllogo = DOL_URL_ROOT.'/theme/dolibarr_logo.svg';
141 }
142
143 print '<div class="center">';
144 // Output html code for logo
145 print '<div class="backgreypublicpayment">';
146 print '<div class="logopublicpayment">';
147 if ($urllogo) {
148 print '<img id="dolpaymentlogo" src="'.$urllogo.'">';
149 }
150 if (empty($urllogo)) {
151 print $mysoc->name;
152 }
153 print '</div>';
154 if (!getDolGlobalString('MAIN_HIDE_POWERED_BY')) {
155 print '<div class="poweredbypublicpayment opacitymedium right"><a class="poweredbyhref" href="https://www.dolibarr.org?utm_medium=website&utm_source=poweredby" target="dolibarr" rel="noopener">'.$langs->trans("PoweredBy").'<br><img class="poweredbyimg" src="'.DOL_URL_ROOT.'/theme/dolibarr_logo.svg" width="80px"></a></div>';
156 }
157 print '</div>';
158
159 if (getDolGlobalString('PROJECT_IMAGE_PUBLIC_ORGANIZEDEVENT')) {
160 print '<div class="backimagepubliceventorganizationsubscription">';
161 print '<img id="idPROJECT_IMAGE_PUBLIC_ORGANIZEDEVENT" src="' . getDolGlobalString('PROJECT_IMAGE_PUBLIC_ORGANIZEDEVENT').'">';
162 print '</div>';
163 }
164
165 print '</div>';
166
167 print '<div class="divmainbodylarge">';
168}
169
177function llxFooterVierge() // @phan-suppress-current-line PhanRedefineFunction
178{
179 print '</div>';
180
181 printCommonFooter('public');
182
183 print "</body>\n";
184 print "</html>\n";
185}
186
187
188/*
189 * Actions
190 */
191
192if (GETPOST('suggestbooth')) {
193 header("Location: ".dol_buildpath('/public/project/suggestbooth.php', 1).'?id='.$id."&securekey=".$securekeyreceived);
194 exit;
195}
196
197if (GETPOST('suggestconference')) {
198 header("Location: ".dol_buildpath('/public/project/suggestconference.php', 1).'?id='.$id."&securekey=".$securekeyreceived);
199 exit;
200}
201
202if (GETPOST('viewandvote')) {
203 header("Location: ".dol_buildpath('/public/project/viewandvote.php', 1).'?id='.$id."&securekey=".$securekeyreceived);
204 exit;
205}
206
207
208/*
209 * View
210 */
211
212$head = '';
213if (getDolGlobalString('ONLINE_PAYMENT_CSS_URL')) {
214 $head = '<link rel="stylesheet" type="text/css" href="' . getDolGlobalString('ONLINE_PAYMENT_CSS_URL').'?lang='.$langs->defaultlang.'">'."\n";
215}
216
217$conf->dol_hide_topmenu = 1;
218$conf->dol_hide_leftmenu = 1;
219
220$replacemainarea = (empty($conf->dol_hide_leftmenu) ? '<div>' : '').'<div>';
221
222//llxHeader($head, $langs->trans("SuggestForm"), '', '', 0, 0, '', '', '', 'onlinepaymentbody', $replacemainarea);
223
224llxHeaderVierge($langs->trans("SuggestForm"));
225
226
227print '<span id="dolpaymentspan"></span>'."\n";
228print '<div class="center">'."\n";
229
230print '<form id="dolpaymentform" class="center" name="paymentform" action="'.$_SERVER["PHP_SELF"].'" method="POST">'."\n";
231print '<input type="hidden" name="token" value="'.newToken().'">'."\n";
232print '<input type="hidden" name="action" value="dopayment">'."\n";
233print '<input type="hidden" name="tag" value="'.GETPOST("tag", 'alpha').'">'."\n";
234//print '<input type="hidden" name="suffix" value="'.dol_escape_htmltag($suffix).'">'."\n";
235print '<input type="hidden" name="id" value="'.dol_escape_htmltag((string) $id).'">'."\n";
236print '<input type="hidden" name="securekey" value="'.dol_escape_htmltag($securekeyreceived).'">'."\n";
237print '<input type="hidden" name="e" value="'.$entity.'" />';
238//print '<input type="hidden" name="forcesandbox" value="'.GETPOSTINT('forcesandbox').'" />';
239print "\n";
240
241
242print '<div class="centergrid">';
243print '<div id="divsubscribe">';
244
245
246// Sub banner
247print '<div class="center subscriptionformbanner subbanner justify margintoponly paddingtop marginbottomonly padingbottom">';
248print load_fiche_titre($langs->trans("NewRegistration"), '', '', 0, '', 'center');
249// Welcome message
250print '<br>';
251print '<span class="opacitymedium">'.$langs->trans("EvntOrgRegistrationWelcomeMessage").'</span>';
252print '<br>';
253// Title
254print '<span class="eventlabel large">'.dol_escape_htmltag($project->title).'</span><br>';
255print '</div>';
256
257// Help text
258print '<div class="justify subscriptionformhelptext">';
259
260if ($project->date_start_event || $project->date_end_event) {
261 print '<br><span class="fa fa-calendar pictofixedwidth opacitymedium"></span>';
262}
263if ($project->date_start_event) {
264 $format = 'day';
265 $tmparray = dol_getdate($project->date_start_event, false, '');
266 if ($tmparray['hours'] || $tmparray['minutes'] || $tmparray['minutes']) {
267 $format = 'dayhour';
268 }
269 print dol_print_date($project->date_start_event, $format);
270}
271if ($project->date_start_event && $project->date_end_event) {
272 print ' - ';
273}
274if ($project->date_end_event) {
275 $format = 'day';
276 $tmparray = dol_getdate($project->date_end_event, false, '');
277 if ($tmparray['hours'] || $tmparray['minutes'] || $tmparray['minutes']) {
278 $format = 'dayhour';
279 }
280 print dol_print_date($project->date_end_event, $format);
281}
282if ($project->date_start_event || $project->date_end_event) {
283 print '<br>';
284}
285if ($project->location) {
286 print '<span class="fa fa-map-marked-alt pictofixedwidth opacitymedium"></span>'.dol_escape_htmltag($project->location).'<br>';
287}
288
289print '</div>';
290
291
292print '<br>';
293
294print '<table id="dolsuggestboost" summary="Suggest a boost form" class="center">'."\n";
295
296// Output payment summary form
297print '<tr><td class="center">';
298
299print "\n";
300
301
302// Show all action buttons
303print '<br>';
304
305// Output introduction text
306$foundaction = 0;
307if ($project->accept_booth_suggestions) {
308 $foundaction++;
309 print '<input type="submit" value="'.$langs->trans("SuggestBooth").'" id="suggestbooth" name="suggestbooth" class="button minwidth250">';
310 print '<br><br>';
311}
312if ($project->accept_conference_suggestions == 1 || $project->accept_conference_suggestions == 2) { // Can suggest conferences
313 $foundaction++;
314 print '<input type="submit" value="'.$langs->trans("SuggestConference").'" id="suggestconference" name="suggestconference" class="button minwidth250">';
315 print '<br><br>';
316}
317if ($project->accept_conference_suggestions == 2 || $project->accept_conference_suggestions == 3) { // Can vote for conferences
318 $foundaction++;
319 print '<input type="submit" value="'.$langs->trans("ViewAndVote").'" id="viewandvote" name="viewandvote" class="button minwidth250">';
320}
321
322if (! $foundaction) {
323 print '<span class="opacitymedium">'.$langs->trans("NoPublicActionsAllowedForThisEvent").'</span>';
324}
325
326print '</td></tr>'."\n";
327
328print '</table>'."\n";
329
330
331print '</div></div>';
332
333
334print '</form>'."\n";
335print '</div>'."\n";
336print '<br>';
337
338
339$suffix = '';
340
341htmlPrintOnlineFooter($mysoc, $langs, 1, $suffix, $project);
342
343llxFooter('', 'public');
344
345$db->close();
$id
Support class for third parties, contacts, members, users or resources.
Definition account.php:47
llxFooter($comment='', $zone='private', $disabledoutputofmessages=0)
Empty footer.
Definition wrapper.php:91
Class to manage projects.
htmlPrintOnlineFooter($fromcompany, $langs, $addformmessage=0, $suffix='', $object=null)
Show footer of company in HTML public pages.
global $mysoc
if(!isModEnabled('ai')||!getDolGlobalString('AI_ASSISTANT_ENABLED')) global $conf
The main.inc.php has been included so the following variable are now defined:
if(!isModEnabled('ai')||!getDolGlobalString('AI_ASSISTANT_ENABLED')) global $db
API class for accounts.
GETPOSTINT($paramname, $method=0)
Return the value of a $_GET or $_POST supervariable, converted into integer.
printCommonFooter($zone='private')
Print common footer : conf->global->MAIN_HTML_FOOTER js for switch of menu hider js for conf->global-...
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
dol_buildpath($path, $type=0, $returnemptyifnotfound=0)
Return path of url or filesystem.
dol_print_date($time, $format='', $tzoutput='auto', $outputlangs=null, $encodetooutput=false, $decorate=0)
Output date in a string format according to outputlangs (or langs if not defined).
load_fiche_titre($title, $morehtmlright='', $picto='generic', $pictoisfullpath=0, $id='', $morecssontable='', $morehtmlcenter='', $morecssonpicto='widthpictotitle')
Load a title with picto.
getDolGlobalString($key, $default='')
Return a Dolibarr global constant string value.
dol_getdate($timestamp, $fast=false, $forcetimezone='')
Return an array with locale date info.
top_htmlhead($head, $title='', $disablejs=0, $disablehead=0, $arrayofjs=array(), $arrayofcss=array(), $disableforlogin=0, $disablenofollow=0, $disablenoindex=0)
Output html header of a page.
llxHeaderVierge($title, $head="", $disablejs=0, $disablehead=0, $arrayofjs=[], $arrayofcss=[], $ws='')
Show header for booking.
Definition index.php:143
llxFooterVierge()
Show footer for demo.
Definition index.php:508
httponly_accessforbidden($message='1', $http_response_code=403, $stringalreadysanitized=0)
Show a message to say access is forbidden and stop program.
dol_hash($chain, $type='0', $nosalt=0, $mode=0)
Returns a hash (non reversible encryption) of a string.