dolibarr  7.0.0-beta
login.tpl.php
1 <?php
2 /* Copyright (C) 2009-2015 Regis Houssin <regis.houssin@capnetworks.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 <http://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 // Protection to avoid direct call of template
23 if (empty($conf) || ! is_object($conf))
24 {
25  print "Error, template page can't be called as URL";
26  exit;
27 }
28 
29 
30 header('Cache-Control: Public, must-revalidate');
31 header("Content-type: text/html; charset=".$conf->file->character_set_client);
32 
33 if (GETPOST('dol_hide_topmenu')) $conf->dol_hide_topmenu=1;
34 if (GETPOST('dol_hide_leftmenu')) $conf->dol_hide_leftmenu=1;
35 if (GETPOST('dol_optimize_smallscreen')) $conf->dol_optimize_smallscreen=1;
36 if (GETPOST('dol_no_mouse_hover')) $conf->dol_no_mouse_hover=1;
37 if (GETPOST('dol_use_jmobile')) $conf->dol_use_jmobile=1;
38 
39 // If we force to use jmobile, then we reenable javascript
40 if (! empty($conf->dol_use_jmobile)) $conf->use_javascript_ajax=1;
41 
42 $php_self = dol_escape_htmltag($_SERVER['PHP_SELF']);
43 $php_self.= dol_escape_htmltag($_SERVER["QUERY_STRING"])?'?'.dol_escape_htmltag($_SERVER["QUERY_STRING"]):'';
44 if (! preg_match('/mainmenu=/',$php_self)) $php_self.=(preg_match('/\?/',$php_self)?'&':'?').'mainmenu=home';
45 
46 // Javascript code on logon page only to detect user tz, dst_observed, dst_first, dst_second
47 $arrayofjs=array(
48  '/includes/jstz/jstz.min.js'.(empty($conf->dol_use_jmobile)?'':'?version='.urlencode(DOL_VERSION)),
49  '/core/js/dst.js'.(empty($conf->dol_use_jmobile)?'':'?version='.urlencode(DOL_VERSION))
50 );
51 $titleofloginpage=$langs->trans('Login').' @ '.$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.
52 
53 $disablenofollow=1;
54 if (! preg_match('/'.constant('DOL_APPLICATION_TITLE').'/', $title)) $disablenofollow=0;
55 
56 print top_htmlhead('', $titleofloginpage, 0, 0, $arrayofjs, array(), 0, $disablenofollow);
57 
58 ?>
59 <!-- BEGIN PHP TEMPLATE LOGIN.TPL.PHP -->
60 
61 <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='.urlencode($conf->global->MAIN_LOGIN_BACKGROUND).'\')"'; ?>>
62 
63 <?php if (empty($conf->dol_use_jmobile)) { ?>
64 <script type="text/javascript">
65 $(document).ready(function () {
66  /* Set focus on correct field */
67  <?php if ($focus_element) { ?>$('#<?php echo $focus_element; ?>').focus(); <?php } ?> // Warning to use this only on visible element
68 });
69 </script>
70 <?php } ?>
71 
72 <div class="login_center center">
73 <div class="login_vertical_align">
74 
75 <form id="login" name="login" method="post" action="<?php echo $php_self; ?>">
76 <input type="hidden" name="token" value="<?php echo $_SESSION['newtoken']; ?>" />
77 <input type="hidden" name="loginfunction" value="loginfunction" />
78 <!-- Add fields to send local user information -->
79 <input type="hidden" name="tz" id="tz" value="" />
80 <input type="hidden" name="tz_string" id="tz_string" value="" />
81 <input type="hidden" name="dst_observed" id="dst_observed" value="" />
82 <input type="hidden" name="dst_first" id="dst_first" value="" />
83 <input type="hidden" name="dst_second" id="dst_second" value="" />
84 <input type="hidden" name="screenwidth" id="screenwidth" value="" />
85 <input type="hidden" name="screenheight" id="screenheight" value="" />
86 <input type="hidden" name="dol_hide_topmenu" id="dol_hide_topmenu" value="<?php echo $dol_hide_topmenu; ?>" />
87 <input type="hidden" name="dol_hide_leftmenu" id="dol_hide_leftmenu" value="<?php echo $dol_hide_leftmenu; ?>" />
88 <input type="hidden" name="dol_optimize_smallscreen" id="dol_optimize_smallscreen" value="<?php echo $dol_optimize_smallscreen; ?>" />
89 <input type="hidden" name="dol_no_mouse_hover" id="dol_no_mouse_hover" value="<?php echo $dol_no_mouse_hover; ?>" />
90 <input type="hidden" name="dol_use_jmobile" id="dol_use_jmobile" value="<?php echo $dol_use_jmobile; ?>" />
91 
92 
93 
94 <!-- Title with version -->
95 <div class="login_table_title center" title="<?php echo dol_escape_htmltag($title); ?>">
96 <?php
97 if ($disablenofollow) echo '<a class="login_table_title" href="https://www.dolibarr.org" target="_blank">';
99 if ($disablenofollow) echo '</a>';
100 ?>
101 </div>
102 
103 
104 
105 <div class="login_table">
106 
107 <div id="login_line1">
108 
109 <div id="login_left">
110 <img alt="" src="<?php echo $urllogo; ?>" id="img_logo" />
111 </div>
112 
113 
114 <div id="login_right">
115 
116 <table class="left centpercent" title="<?php echo $langs->trans("EnterLoginDetail"); ?>">
117 <!-- Login -->
118 <tr>
119 <td class="nowrap center valignmiddle">
120 <?php if (! empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER)) { ?><label for="username" class="hidden"><?php echo $langs->trans("Login"); ?></label><?php } ?>
121 <span class="span-icon-user">
122 <input type="text" id="username" placeholder="<?php echo $langs->trans("Login"); ?>" name="username" class="flat input-icon-user" size="20" value="<?php echo dol_escape_htmltag($login); ?>" tabindex="1" autofocus="autofocus" />
123 </span>
124 </td>
125 </tr>
126 <!-- Password -->
127 <tr>
128 <td class="nowrap center valignmiddle">
129 <?php if (! empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER)) { ?><label for="password" class="hidden"><?php echo $langs->trans("Password"); ?></label><?php } ?>
130 <span class="span-icon-password">
131 <input id="password" placeholder="<?php echo $langs->trans("Password"); ?>" name="password" class="flat input-icon-password" type="password" size="20" value="<?php echo dol_escape_htmltag($password); ?>" tabindex="2" autocomplete="<?php echo empty($conf->global->MAIN_LOGIN_ENABLE_PASSWORD_AUTOCOMPLETE)?'off':'on'; ?>" />
132 </span>
133 </td></tr>
134 <?php
135 if (! empty($morelogincontent)) {
136  if (is_array($morelogincontent)) {
137  foreach ($morelogincontent as $format => $option)
138  {
139  if ($format == 'table') {
140  echo '<!-- Option by hook -->';
141  echo $option;
142  }
143  }
144  }
145  else {
146  echo '<!-- Option by hook -->';
147  echo $morelogincontent;
148  }
149 }
150 
151 if ($captcha) {
152  // Add a variable param to force not using cache (jmobile)
153  $php_self = preg_replace('/[&\?]time=(\d+)/','',$php_self); // Remove param time
154  if (preg_match('/\?/',$php_self)) $php_self.='&time='.dol_print_date(dol_now(),'dayhourlog');
155  else $php_self.='?time='.dol_print_date(dol_now(),'dayhourlog');
156  // TODO: provide accessible captcha variants
157 ?>
158  <!-- Captcha -->
159  <tr>
160  <td class="nowrap none center">
161 
162  <table class="login_table_securitycode centpercent"><tr>
163  <td>
164  <span class="span-icon-security">
165  <input id="securitycode" placeholder="<?php echo $langs->trans("SecurityCode"); ?>" class="flat input-icon-security" type="text" size="12" maxlength="5" name="code" tabindex="3" />
166  </span>
167  </td>
168  <td><img src="<?php echo DOL_URL_ROOT ?>/core/antispamimage.php" border="0" width="80" height="32" id="img_securitycode" /></td>
169  <td><a href="<?php echo $php_self; ?>" tabindex="4" data-role="button"><?php echo $captcha_refresh; ?></a></td>
170  </tr></table>
171 
172  </td></tr>
173 <?php } ?>
174 </table>
175 
176 </div> <!-- end div login-right -->
177 
178 </div> <!-- end div login-line1 -->
179 
180 
181 <div id="login_line2" style="clear: both">
182 
183 <!-- Button Connection -->
184 <br><input type="submit" class="button" value="&nbsp; <?php echo $langs->trans('Connection'); ?> &nbsp;" tabindex="5" />
185 
186 <?php
187 if ($forgetpasslink || $helpcenterlink)
188 {
189  $moreparam='';
190  if ($dol_hide_topmenu) $moreparam.=(strpos($moreparam,'?')===false?'?':'&').'dol_hide_topmenu='.$dol_hide_topmenu;
191  if ($dol_hide_leftmenu) $moreparam.=(strpos($moreparam,'?')===false?'?':'&').'dol_hide_leftmenu='.$dol_hide_leftmenu;
192  if ($dol_no_mouse_hover) $moreparam.=(strpos($moreparam,'?')===false?'?':'&').'dol_no_mouse_hover='.$dol_no_mouse_hover;
193  if ($dol_use_jmobile) $moreparam.=(strpos($moreparam,'?')===false?'?':'&').'dol_use_jmobile='.$dol_use_jmobile;
194 
195  echo '<br>';
196  echo '<div class="center" style="margin-top: 8px;">';
197  if ($forgetpasslink) {
198  echo '<a class="alogin" href="'.DOL_URL_ROOT.'/user/passwordforgotten.php'.$moreparam.'">(';
199  echo $langs->trans('PasswordForgotten');
200  if (! $helpcenterlink) echo ')';
201  echo '</a>';
202  }
203 
204  if ($forgetpasslink && $helpcenterlink) echo '&nbsp;-&nbsp;';
205 
206  if ($helpcenterlink) {
207  $url=DOL_URL_ROOT.'/support/index.php'.$moreparam;
208  if (! empty($conf->global->MAIN_HELPCENTER_LINKTOUSE)) $url=$conf->global->MAIN_HELPCENTER_LINKTOUSE;
209  echo '<a class="alogin" href="'.dol_escape_htmltag($url).'" target="_blank">';
210  if (! $forgetpasslink) echo '(';
211  echo $langs->trans('NeedHelpCenter');
212  echo ')</a>';
213  }
214  echo '</div>';
215 }
216 
217 if (isset($conf->file->main_authentication) && preg_match('/openid/',$conf->file->main_authentication))
218 {
219  $langs->load("users");
220 
221  //if (! empty($conf->global->MAIN_OPENIDURL_PERUSER)) $url=
222  echo '<br>';
223  echo '<div class="center" style="margin-top: 4px;">';
224 
225  $url=$conf->global->MAIN_AUTHENTICATION_OPENID_URL;
226  if (! empty($url)) print '<a class="alogin" href="'.$url.'">'.$langs->trans("LoginUsingOpenID").'</a>';
227  else
228  {
229  $langs->load("errors");
230  print '<font class="warning">'.$langs->trans("ErrorOpenIDSetupNotComplete",'MAIN_AUTHENTICATION_OPENID_URL').'</font>';
231  }
232 
233  echo '</div>';
234 }
235 
236 
237 ?>
238 
239 </div> <!-- end login line 2 -->
240 
241 </div> <!-- end login table -->
242 
243 
244 </form>
245 
246 
247 <?php
248 // Show error message if defined
249 if (! empty($_SESSION['dol_loginmesg']))
250 {
251 ?>
252  <div class="center login_main_message"><div class="error">
253  <?php echo $_SESSION['dol_loginmesg']; ?>
254  </div></div>
255 <?php
256 }
257 
258 // Add commit strip
259 if (!empty($conf->global->MAIN_EASTER_EGG_COMMITSTRIP)) {
260  include_once DOL_DOCUMENT_ROOT.'/core/lib/geturl.lib.php';
261  if (substr($langs->defaultlang,0,2)=='fr') {
262  $resgetcommitstrip = getURLContent("http://www.commitstrip.com/fr/feed/");
263  } else {
264  $resgetcommitstrip = getURLContent("http://www.commitstrip.com/en/feed/");
265  }
266  if ($resgetcommitstrip && $resgetcommitstrip['http_code'] == '200')
267  {
268  $xml = simplexml_load_string($resgetcommitstrip['content']);
269  $little = $xml->channel->item[0]->children('content',true);
270  print $little->encoded;
271  }
272 }
273 
274 ?>
275 
276 <?php if ($main_home)
277 {
278 ?>
279  <div class="center login_main_home paddingtopbottom <?php echo empty($conf->global->MAIN_LOGIN_BACKGROUND)?'':' backgroundsemitransparent'; ?>" style="max-width: 70%">
280  <?php echo $main_home; ?>
281  </div><br>
282 <?php
283 }
284 ?>
285 
286 <!-- authentication mode = <?php echo $main_authentication ?> -->
287 <!-- cookie name used for this session = <?php echo $session_name ?> -->
288 <!-- urlfrom in this session = <?php echo isset($_SESSION["urlfrom"])?$_SESSION["urlfrom"]:''; ?> -->
289 
290 <!-- Common footer is not used for login page, this is same than footer but inside login tpl -->
291 
292 <?php
293 if (! empty($conf->global->MAIN_HTML_FOOTER)) print $conf->global->MAIN_HTML_FOOTER;
294 
295 if (! empty($morelogincontent) && is_array($morelogincontent)) {
296  foreach ($morelogincontent as $format => $option)
297  {
298  if ($format == 'js') {
299  echo "\n".'<!-- Javascript by hook -->';
300  echo $option."\n";
301  }
302  }
303 }
304 else if (! empty($moreloginextracontent)) {
305  echo '<!-- Javascript by hook -->';
306  echo $moreloginextracontent;
307 }
308 
309 // Google Analytics (need Google module)
310 if (! empty($conf->google->enabled) && ! empty($conf->global->MAIN_GOOGLE_AN_ID))
311 {
312  if (empty($conf->dol_use_jmobile))
313  {
314  print "\n";
315  print '<script type="text/javascript">'."\n";
316  print ' var _gaq = _gaq || [];'."\n";
317  print ' _gaq.push([\'_setAccount\', \''.$conf->global->MAIN_GOOGLE_AN_ID.'\']);'."\n";
318  print ' _gaq.push([\'_trackPageview\']);'."\n";
319  print ''."\n";
320  print ' (function() {'."\n";
321  print ' var ga = document.createElement(\'script\'); ga.type = \'text/javascript\'; ga.async = true;'."\n";
322  print ' ga.src = (\'https:\' == document.location.protocol ? \'https://ssl\' : \'http://www\') + \'.google-analytics.com/ga.js\';'."\n";
323  print ' var s = document.getElementsByTagName(\'script\')[0]; s.parentNode.insertBefore(ga, s);'."\n";
324  print ' })();'."\n";
325  print '</script>'."\n";
326  }
327 }
328 
329 // Google Adsense
330 if (! empty($conf->google->enabled) && ! empty($conf->global->MAIN_GOOGLE_AD_CLIENT) && ! empty($conf->global->MAIN_GOOGLE_AD_SLOT))
331 {
332  if (empty($conf->dol_use_jmobile))
333  {
334 ?>
335  <div class="center"><br>
336  <script type="text/javascript"><!--
337  google_ad_client = "<?php echo $conf->global->MAIN_GOOGLE_AD_CLIENT ?>";
338  google_ad_slot = "<?php echo $conf->global->MAIN_GOOGLE_AD_SLOT ?>";
339  google_ad_width = <?php echo $conf->global->MAIN_GOOGLE_AD_WIDTH ?>;
340  google_ad_height = <?php echo $conf->global->MAIN_GOOGLE_AD_HEIGHT ?>;
341  //-->
342  </script>
343  <script type="text/javascript"
344  src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
345  </script>
346  </div>
347 <?php
348  }
349 }
350 ?>
351 
352 
353 </div>
354 </div> <!-- end of center -->
355 
356 
357 </body>
358 </html>
359 <!-- END PHP TEMPLATE -->
API that allows to log in with an user account.
dol_escape_htmltag($stringtoescape, $keepb=0, $keepn=0)
Returns text escaped for inclusion in HTML alt or title tags, or into values of HTML input fields...
GETPOST($paramname, $check='none', $method=0, $filter=NULL, $options=NULL, $noreplace=0)
Return value of a param into GET or POST supervariable.
getURLContent($url, $postorget='GET', $param='', $followlocation=1, $addheaders=array())
Function get content from an URL (use proxy if proxy defined)
Definition: geturl.lib.php:34
if($_POST["cancel"]==$langs->trans("Cancel")&&!$id) if($action== 'setdatev'&&$user->rights->tax->charges->creer) if($action== 'add'&&$_POST["cancel"]<> $langs->trans("Cancel")) if($action== 'delete') $title
Actions.
Definition: card.php:183
dol_now($mode='gmt')
Return date for now.
$conf db name
Only used if Module[ID]Name translation string is not found.
Definition: repair.php:104
top_htmlhead($head, $title='', $disablejs=0, $disablehead=0, $arrayofjs='', $arrayofcss='', $disablejmobile=0, $disablenofollow=0)
Ouput html header of a page.
Definition: main.inc.php:1091
print
Draft customers invoices.
Definition: index.php:91
type
Definition: viewcat.php:283