dolibarr  13.0.2
login.tpl.php
1 <?php
2 /* Copyright (C) 2009-2015 Regis Houssin <regis.houssin@inodbox.com>
3  * Copyright (C) 2011-2013 Laurent Destailleur <eldy@users.sourceforge.net>
4  *
5  * This program is free software; you can redistribute it and/or modify
6  * it under the terms of the GNU General Public License as published by
7  * the Free Software Foundation; either version 3 of the License, or
8  * (at your option) any later version.
9  *
10  * This program is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  * GNU General Public License for more details.
14  *
15  * You should have received a copy of the GNU General Public License
16  * along with this program. If not, see <https://www.gnu.org/licenses/>.
17  */
18 
19 // Need global variable $title to be defined by caller (like dol_loginfunction)
20 // Caller can also set $morelogincontent = array(['options']=>array('js'=>..., 'table'=>...);
21 
22 
23 if (!defined('NOBROWSERNOTIF')) define('NOBROWSERNOTIF', 1);
24 
25 // Protection to avoid direct call of template
26 if (empty($conf) || !is_object($conf)) {
27  print "Error, template page can't be called as URL";
28  exit;
29 }
30 
31 
32 require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php';
33 
34 header('Cache-Control: Public, must-revalidate');
35 header("Content-type: text/html; charset=".$conf->file->character_set_client);
36 
37 if (GETPOST('dol_hide_topmenu')) $conf->dol_hide_topmenu = 1;
38 if (GETPOST('dol_hide_leftmenu')) $conf->dol_hide_leftmenu = 1;
39 if (GETPOST('dol_optimize_smallscreen')) $conf->dol_optimize_smallscreen = 1;
40 if (GETPOST('dol_no_mouse_hover')) $conf->dol_no_mouse_hover = 1;
41 if (GETPOST('dol_use_jmobile')) $conf->dol_use_jmobile = 1;
42 
43 // If we force to use jmobile, then we reenable javascript
44 if (!empty($conf->dol_use_jmobile)) $conf->use_javascript_ajax = 1;
45 
46 $php_self = dol_escape_htmltag($_SERVER['PHP_SELF']);
47 $php_self .= dol_escape_htmltag($_SERVER["QUERY_STRING"]) ? '?'.dol_escape_htmltag($_SERVER["QUERY_STRING"]) : '';
48 if (!preg_match('/mainmenu=/', $php_self)) $php_self .= (preg_match('/\?/', $php_self) ? '&' : '?').'mainmenu=home';
49 
50 // Javascript code on logon page only to detect user tz, dst_observed, dst_first, dst_second
51 $arrayofjs = array(
52  '/includes/jstz/jstz.min.js'.(empty($conf->dol_use_jmobile) ? '' : '?version='.urlencode(DOL_VERSION)),
53  '/core/js/dst.js'.(empty($conf->dol_use_jmobile) ? '' : '?version='.urlencode(DOL_VERSION))
54 );
55 
56 // We display application title instead Login term
57 if (!empty($conf->global->MAIN_APPLICATION_TITLE)) {
58  $titleofloginpage = $conf->global->MAIN_APPLICATION_TITLE;
59 } else {
60  $titleofloginpage = $langs->trans('Login');
61 }
62 $titleofloginpage .= ' @ '.$titletruedolibarrversion; // $titletruedolibarrversion is defined by dol_loginfunction in security2.lib.php. We must keep the @, some tools use it to know it is login page and find true dolibarr version.
63 
64 $disablenofollow = 1;
65 if (!preg_match('/'.constant('DOL_APPLICATION_TITLE').'/', $title)) $disablenofollow = 0;
66 if (!empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER)) $disablenofollow = 0;
67 
68 print top_htmlhead('', $titleofloginpage, 0, 0, $arrayofjs, array(), 0, $disablenofollow);
69 
70 
71 $colorbackhmenu1 = '60,70,100'; // topmenu
72 if (!isset($conf->global->THEME_ELDY_TOPMENU_BACK1)) $conf->global->THEME_ELDY_TOPMENU_BACK1 = $colorbackhmenu1;
73 $colorbackhmenu1 = empty($user->conf->THEME_ELDY_ENABLE_PERSONALIZED) ? (empty($conf->global->THEME_ELDY_TOPMENU_BACK1) ? $colorbackhmenu1 : $conf->global->THEME_ELDY_TOPMENU_BACK1) : (empty($user->conf->THEME_ELDY_TOPMENU_BACK1) ? $colorbackhmenu1 : $user->conf->THEME_ELDY_TOPMENU_BACK1);
74 $colorbackhmenu1 = join(',', colorStringToArray($colorbackhmenu1)); // Normalize value to 'x,y,z'
75 
76 print "<!-- BEGIN PHP TEMPLATE LOGIN.TPL.PHP -->\n";
77 
78 if (!empty($conf->global->ADD_UNSPLASH_LOGIN_BACKGROUND)) {
79  // For example $conf->global->ADD_UNSPLASH_LOGIN_BACKGROUND = 'https://source.unsplash.com/random'
80  ?>
81  <body class="body bodylogin" style="background-image: url('<?php echo dol_escape_htmltag($conf->global->ADD_UNSPLASH_LOGIN_BACKGROUND); ?>'); background-repeat: no-repeat; background-position: center center; background-attachment: fixed; background-size: cover; background-color: #ffffff;">
82  <?php
83 } else {
84  ?>
85  <body class="body bodylogin"<?php print empty($conf->global->MAIN_LOGIN_BACKGROUND) ? '' : ' style="background-size: cover; background-position: center center; background-attachment: fixed; background-repeat: no-repeat; background-image: url(\''.DOL_URL_ROOT.'/viewimage.php?cache=1&noalt=1&modulepart=mycompany&file=logos/'.urlencode($conf->global->MAIN_LOGIN_BACKGROUND).'\')"'; ?>>
86  <?php
87 }
88 ?>
89 
90 <?php if (empty($conf->dol_use_jmobile)) { ?>
91 <script>
92 $(document).ready(function () {
93  /* Set focus on correct field */
94  <?php if ($focus_element) { ?>$('#<?php echo $focus_element; ?>').focus(); <?php } ?> // Warning to use this only on visible element
95 });
96 </script>
97 <?php } ?>
98 
99 <div class="login_center center"<?php print empty($conf->global->MAIN_LOGIN_BACKGROUND) ? ' style="background-size: cover; background-position: center center; background-attachment: fixed; background-repeat: no-repeat; background-image: linear-gradient(rgb('.$colorbackhmenu1.',0.3), rgb(240,240,240));"' : '' ?>>
100 <div class="login_vertical_align">
101 
102 <form id="login" name="login" method="post" action="<?php echo $php_self; ?>">
103 <input type="hidden" name="token" value="<?php echo newToken(); ?>" />
104 <input type="hidden" name="actionlogin" value="login">
105 <input type="hidden" name="loginfunction" value="loginfunction" />
106 <!-- Add fields to send local user information -->
107 <input type="hidden" name="tz" id="tz" value="" />
108 <input type="hidden" name="tz_string" id="tz_string" value="" />
109 <input type="hidden" name="dst_observed" id="dst_observed" value="" />
110 <input type="hidden" name="dst_first" id="dst_first" value="" />
111 <input type="hidden" name="dst_second" id="dst_second" value="" />
112 <input type="hidden" name="screenwidth" id="screenwidth" value="" />
113 <input type="hidden" name="screenheight" id="screenheight" value="" />
114 <input type="hidden" name="dol_hide_topmenu" id="dol_hide_topmenu" value="<?php echo $dol_hide_topmenu; ?>" />
115 <input type="hidden" name="dol_hide_leftmenu" id="dol_hide_leftmenu" value="<?php echo $dol_hide_leftmenu; ?>" />
116 <input type="hidden" name="dol_optimize_smallscreen" id="dol_optimize_smallscreen" value="<?php echo $dol_optimize_smallscreen; ?>" />
117 <input type="hidden" name="dol_no_mouse_hover" id="dol_no_mouse_hover" value="<?php echo $dol_no_mouse_hover; ?>" />
118 <input type="hidden" name="dol_use_jmobile" id="dol_use_jmobile" value="<?php echo $dol_use_jmobile; ?>" />
119 
120 
121 
122 <!-- Title with version -->
123 <div class="login_table_title center" title="<?php echo dol_escape_htmltag($title); ?>">
124 <?php
125 if ($disablenofollow) echo '<a class="login_table_title" href="https://www.dolibarr.org" target="_blank">';
126 echo dol_escape_htmltag($title);
127 if ($disablenofollow) echo '</a>';
128 ?>
129 </div>
130 
131 
132 
133 <div class="login_table">
134 
135 <div id="login_line1">
136 
137 <div id="login_left">
138 <img alt="" src="<?php echo $urllogo; ?>" id="img_logo" />
139 </div>
140 
141 <br>
142 
143 <div id="login_right">
144 
145 <div class="tagtable left centpercent" title="<?php echo $langs->trans("EnterLoginDetail"); ?>">
146 
147 <!-- Login -->
148 <div class="trinputlogin">
149 <div class="tagtd nowraponall center valignmiddle tdinputlogin">
150 <?php if (!empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER)) { ?><label for="username" class="hidden"><?php echo $langs->trans("Login"); ?></label><?php } ?>
151 <!-- <span class="span-icon-user">-->
152 <span class="fa fa-user"></span>
153 <input type="text" id="username" placeholder="<?php echo $langs->trans("Login"); ?>" name="username" class="flat input-icon-user minwidth150" value="<?php echo dol_escape_htmltag($login); ?>" tabindex="1" autofocus="autofocus" />
154 </div>
155 </div>
156 
157 <!-- Password -->
158 <div class="trinputlogin">
159 <div class="tagtd nowraponall center valignmiddle tdinputlogin">
160 <?php if (!empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER)) { ?><label for="password" class="hidden"><?php echo $langs->trans("Password"); ?></label><?php } ?>
161 <!--<span class="span-icon-password">-->
162 <span class="fa fa-key"></span>
163 <input id="password" placeholder="<?php echo $langs->trans("Password"); ?>" name="password" class="flat input-icon-password minwidth150" type="password" value="<?php echo dol_escape_htmltag($password); ?>" tabindex="2" autocomplete="<?php echo empty($conf->global->MAIN_LOGIN_ENABLE_PASSWORD_AUTOCOMPLETE) ? 'off' : 'on'; ?>" />
164 </div></div>
165 
166 <?php
167 if ($captcha) {
168  // Add a variable param to force not using cache (jmobile)
169  $php_self = preg_replace('/[&\?]time=(\d+)/', '', $php_self); // Remove param time
170  if (preg_match('/\?/', $php_self)) $php_self .= '&time='.dol_print_date(dol_now(), 'dayhourlog');
171  else $php_self .= '?time='.dol_print_date(dol_now(), 'dayhourlog');
172  // TODO: provide accessible captcha variants
173  ?>
174  <!-- Captcha -->
175  <div class="trinputlogin">
176  <div class="tagtd none valignmiddle tdinputlogin">
177 
178  <span class="fa fa-unlock"></span>
179  <span class="span-icon-security inline-block">
180  <input id="securitycode" placeholder="<?php echo $langs->trans("SecurityCode"); ?>" class="flat input-icon-security width150" type="text" maxlength="5" name="code" tabindex="3" />
181  </span>
182  <span class="nowrap inline-block">
183  <img class="inline-block valignmiddle" src="<?php echo DOL_URL_ROOT ?>/core/antispamimage.php" border="0" width="80" height="32" id="img_securitycode" />
184  <a class="inline-block valignmiddle" href="<?php echo $php_self; ?>" tabindex="4" data-role="button"><?php echo $captcha_refresh; ?></a>
185  </span>
186 
187  </div></div>
188  <?php
189 }
190 
191 if (!empty($morelogincontent)) {
192  if (is_array($morelogincontent)) {
193  foreach ($morelogincontent as $format => $option)
194  {
195  if ($format == 'table') {
196  echo '<!-- Option by hook -->';
197  echo $option;
198  }
199  }
200  } else {
201  echo '<!-- Option by hook -->';
202  echo $morelogincontent;
203  }
204 }
205 
206 ?>
207 
208 </div>
209 
210 </div> <!-- end div login_right -->
211 
212 </div> <!-- end div login_line1 -->
213 
214 
215 <div id="login_line2" style="clear: both">
216 
217 <!-- Button Connection -->
218 <br>
219 <div id="login-submit-wrapper">
220 <input type="submit" class="button" value="&nbsp; <?php echo $langs->trans('Connection'); ?> &nbsp;" tabindex="5" />
221 </div>
222 
223 <?php
224 if ($forgetpasslink || $helpcenterlink)
225 {
226  $moreparam = '';
227  if ($dol_hide_topmenu) $moreparam .= (strpos($moreparam, '?') === false ? '?' : '&').'dol_hide_topmenu='.$dol_hide_topmenu;
228  if ($dol_hide_leftmenu) $moreparam .= (strpos($moreparam, '?') === false ? '?' : '&').'dol_hide_leftmenu='.$dol_hide_leftmenu;
229  if ($dol_no_mouse_hover) $moreparam .= (strpos($moreparam, '?') === false ? '?' : '&').'dol_no_mouse_hover='.$dol_no_mouse_hover;
230  if ($dol_use_jmobile) $moreparam .= (strpos($moreparam, '?') === false ? '?' : '&').'dol_use_jmobile='.$dol_use_jmobile;
231 
232  echo '<br>';
233  echo '<div class="center" style="margin-top: 5px;">';
234  if ($forgetpasslink) {
235  $url = DOL_URL_ROOT.'/user/passwordforgotten.php'.$moreparam;
236  if (!empty($conf->global->MAIN_PASSWORD_FORGOTLINK)) $url = $conf->global->MAIN_PASSWORD_FORGOTLINK;
237  echo '<a class="alogin" href="'.dol_escape_htmltag($url).'">';
238  echo $langs->trans('PasswordForgotten');
239  echo '</a>';
240  }
241 
242  if ($forgetpasslink && $helpcenterlink) echo '&nbsp;-&nbsp;';
243 
244  if ($helpcenterlink) {
245  $url = DOL_URL_ROOT.'/support/index.php'.$moreparam;
246  if (!empty($conf->global->MAIN_HELPCENTER_LINKTOUSE)) $url = $conf->global->MAIN_HELPCENTER_LINKTOUSE;
247  echo '<a class="alogin" href="'.dol_escape_htmltag($url).'" target="_blank">';
248  echo $langs->trans('NeedHelpCenter');
249  echo '</a>';
250  }
251  echo '</div>';
252 }
253 
254 if (isset($conf->file->main_authentication) && preg_match('/openid/', $conf->file->main_authentication))
255 {
256  $langs->load("users");
257 
258  //if (! empty($conf->global->MAIN_OPENIDURL_PERUSER)) $url=
259  echo '<br>';
260  echo '<div class="center" style="margin-top: 4px;">';
261 
262  $url = $conf->global->MAIN_AUTHENTICATION_OPENID_URL;
263  if (!empty($url)) print '<a class="alogin" href="'.$url.'">'.$langs->trans("LoginUsingOpenID").'</a>';
264  else {
265  $langs->load("errors");
266  print '<font class="warning">'.$langs->trans("ErrorOpenIDSetupNotComplete", 'MAIN_AUTHENTICATION_OPENID_URL').'</font>';
267  }
268 
269  echo '</div>';
270 }
271 
272 
273 ?>
274 
275 </div> <!-- end login line 2 -->
276 
277 </div> <!-- end login table -->
278 
279 
280 </form>
281 
282 
283 <?php
284 // Show error message if defined
285 if (!empty($_SESSION['dol_loginmesg']))
286 {
287  ?>
288  <div class="center login_main_message"><div class="error">
289  <?php echo $_SESSION['dol_loginmesg']; ?>
290  </div></div>
291  <?php
292 }
293 
294 // Add commit strip
295 if (!empty($conf->global->MAIN_EASTER_EGG_COMMITSTRIP)) {
296  include_once DOL_DOCUMENT_ROOT.'/core/lib/geturl.lib.php';
297  if (substr($langs->defaultlang, 0, 2) == 'fr') {
298  $resgetcommitstrip = getURLContent("https://www.commitstrip.com/fr/feed/");
299  } else {
300  $resgetcommitstrip = getURLContent("https://www.commitstrip.com/en/feed/");
301  }
302  if ($resgetcommitstrip && $resgetcommitstrip['http_code'] == '200')
303  {
304  $xml = simplexml_load_string($resgetcommitstrip['content']);
305  $little = $xml->channel->item[0]->children('content', true);
306  print preg_replace('/width="650" height="658"/', '', $little->encoded);
307  }
308 }
309 
310 ?>
311 
312 <?php if ($main_home)
313 {
314  ?>
315  <div class="center login_main_home paddingtopbottom <?php echo empty($conf->global->MAIN_LOGIN_BACKGROUND) ? '' : ' backgroundsemitransparent'; ?>" style="max-width: 70%">
316  <?php echo $main_home; ?>
317  </div><br>
318  <?php
319 }
320 ?>
321 
322 <!-- authentication mode = <?php echo $main_authentication ?> -->
323 <!-- cookie name used for this session = <?php echo $session_name ?> -->
324 <!-- urlfrom in this session = <?php echo isset($_SESSION["urlfrom"]) ? $_SESSION["urlfrom"] : ''; ?> -->
325 
326 <!-- Common footer is not used for login page, this is same than footer but inside login tpl -->
327 
328 <?php
329 if (!empty($conf->global->MAIN_HTML_FOOTER)) print $conf->global->MAIN_HTML_FOOTER;
330 
331 if (!empty($morelogincontent) && is_array($morelogincontent)) {
332  foreach ($morelogincontent as $format => $option)
333  {
334  if ($format == 'js') {
335  echo "\n".'<!-- Javascript by hook -->';
336  echo $option."\n";
337  }
338  }
339 } elseif (!empty($moreloginextracontent)) {
340  echo '<!-- Javascript by hook -->';
341  echo $moreloginextracontent;
342 }
343 
344 // Google Analytics
345 // TODO Add a hook here
346 if (!empty($conf->google->enabled) && !empty($conf->global->MAIN_GOOGLE_AN_ID))
347 {
348  $tmptagarray = explode(',', $conf->global->MAIN_GOOGLE_AN_ID);
349  foreach ($tmptagarray as $tmptag) {
350  print "\n";
351  print "<!-- JS CODE TO ENABLE for google analtics tag -->\n";
352  print "
353  <!-- Global site tag (gtag.js) - Google Analytics -->
354  <script async src=\"https://www.googletagmanager.com/gtag/js?id=".trim($tmptag)."\"></script>
355  <script>
356  window.dataLayer = window.dataLayer || [];
357  function gtag(){dataLayer.push(arguments);}
358  gtag('js', new Date());
359 
360  gtag('config', '".trim($tmptag)."');
361  </script>";
362  print "\n";
363  }
364 }
365 
366 // TODO Replace this with a hook
367 // Google Adsense (need Google module)
368 if (!empty($conf->google->enabled) && !empty($conf->global->MAIN_GOOGLE_AD_CLIENT) && !empty($conf->global->MAIN_GOOGLE_AD_SLOT))
369 {
370  if (empty($conf->dol_use_jmobile))
371  {
372  ?>
373  <div class="center"><br>
374  <script><!--
375  google_ad_client = "<?php echo $conf->global->MAIN_GOOGLE_AD_CLIENT ?>";
376  google_ad_slot = "<?php echo $conf->global->MAIN_GOOGLE_AD_SLOT ?>";
377  google_ad_width = <?php echo $conf->global->MAIN_GOOGLE_AD_WIDTH ?>;
378  google_ad_height = <?php echo $conf->global->MAIN_GOOGLE_AD_HEIGHT ?>;
379  //-->
380  </script>
381  <script src="//pagead2.googlesyndication.com/pagead/show_ads.js"></script>
382  </div>
383  <?php
384  }
385 }
386 ?>
387 
388 
389 </div>
390 </div><!-- end of center -->
391 
392 
393 </body>
394 </html>
395 <!-- END PHP TEMPLATE -->
GETPOST($paramname, $check= 'alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
dol_now($mode= 'auto')
Return date for now.
API that allows to log in with an user account.
top_htmlhead($head, $title= '', $disablejs=0, $disablehead=0, $arrayofjs= '', $arrayofcss= '', $disablejmobile=0, $disablenofollow=0)
Ouput html header of a page.
Definition: main.inc.php:1280
$conf db name
Only used if Module[ID]Name translation string is not found.
Definition: repair.php:108
getURLContent($url, $postorget= 'GET', $param= '', $followlocation=1, $addheaders=array(), $allowedschemes=array('http', 'https'), $localurl=0)
Function to get a content from an URL (use proxy if proxy defined).
Definition: geturl.lib.php:38
colorStringToArray($stringcolor, $colorifnotfound=array(88, 88, 88))
Convert a string RGB value (&#39;FFFFFF&#39;, &#39;255,255,255&#39;) into an array RGB array(255,255,255).
print $_SERVER["PHP_SELF"]
Edit parameters.
print
Draft customers invoices.
Definition: index.php:89
newToken()
Return the value of token currently saved into session with name &#39;newtoken&#39;.
if(preg_match('/crypted:/i', $dolibarr_main_db_pass)||!empty($dolibarr_main_db_encrypted_pass)) $conf db type
Definition: repair.php:105
dol_escape_htmltag($stringtoescape, $keepb=0, $keepn=0, $keepmoretags= '', $escapeonlyhtmltags=0)
Returns text escaped for inclusion in HTML alt or title tags, or into values of HTML input fields...