login.html.php 8.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196
  1. <?php
  2. /**
  3. * The login view file of user module of ZenTaoPMS.
  4. * @copyright Copyright 2009-2023 禅道软件(青岛)有限公司(ZenTao Software (Qingdao) Co., Ltd. www.zentao.net)
  5. * @license ZPL(https://zpl.pub/page/zplv12.html) or AGPL(https://www.gnu.org/licenses/agpl-3.0.en.html)
  6. * @author Wang Yidong <yidong@easycorp.ltd>
  7. * @package user
  8. * @link https://www.zentao.net
  9. */
  10. namespace zin;
  11. if(empty($config->notMd5Pwd)) h::import($config->webRoot . 'js/md5.js', 'js');
  12. $resetLink = empty($this->config->resetPWDByMail) ? inlink('reset') : inlink('forgetPassword');
  13. $zentaoDirName = basename($this->app->getBasePath());
  14. $clientLang = $app->getClientLang();
  15. $langItems = array();
  16. foreach($config->langs as $key => $value) $langItems[] = array('text' => $value, 'data-on' => 'click', 'data-call' => 'switchLang', 'data-params' => $key, 'active' => $key == $clientLang);
  17. $pluginTips = '';
  18. $expiredPlugins = implode('、', $plugins['expired']);
  19. $expiringPlugins = implode('、', $plugins['expiring']);
  20. $expiredTips = sprintf($lang->misc->expiredPluginTips, $expiredPlugins);
  21. $expiringTips = sprintf($lang->misc->expiringPluginTips, $expiringPlugins);
  22. if($expiredPlugins) $pluginTips = $expiredTips;
  23. if($expiringPlugins) $pluginTips = $expiringTips;
  24. if($expiredPlugins and $expiringPlugins) $pluginTips = $expiredTips . $pluginTips;
  25. $pluginTotal = count($plugins['expired']) + count($plugins['expiring']);
  26. $expiredCountTips = sprintf($lang->misc->expiredCountTips, $pluginTips, $pluginTotal);
  27. $demoUserItems = array();
  28. if(!empty($this->config->global->showDemoUsers))
  29. {
  30. $demoPassword = '123456';
  31. $md5Password = md5('123456');
  32. $demoUsers = 'productManager,projectManager,dev1,dev2,dev3,tester1,tester2,tester3,testManager';
  33. $demoUsers = $this->dao->select('account,password,realname')->from(TABLE_USER)->where('account')->in($demoUsers)->andWhere('deleted')->eq(0)->andWhere('password')->eq($md5Password)->fetchAll('account');
  34. $link = inlink('login');
  35. $link .= strpos($link, '?') !== false ? '&' : '?';
  36. foreach($demoUsers as $demoAccount => $demoUser)
  37. {
  38. if($demoUser->password != $md5Password) continue;
  39. $demoUserItems[] = a(set::href('#'), set::onclick('window.demoSubmit(this)'), set('data-account', $demoAccount), set('data-password', md5($md5Password . $this->session->rand)), $demoUser->realname);
  40. }
  41. }
  42. if($unsafeSites and !empty($unsafeSites[$zentaoDirName]))
  43. {
  44. $paths = array();
  45. $databases = array();
  46. $isXampp = false;
  47. foreach($unsafeSites as $webRoot => $site)
  48. {
  49. $path = $site['path'];
  50. if(strpos($path, 'xampp') !== false) $isXampp = true;
  51. $paths[] = $site['path'];
  52. $databases[] = $site['database'];
  53. }
  54. $process4Safe = $isXampp ? $lang->user->process4DB : $lang->user->process4DIR;
  55. $process4Safe = sprintf($process4Safe, join(' ', $isXampp ? $databases : $paths));
  56. jsVar('process4Safe', $process4Safe);
  57. }
  58. jsVar('loginTimeoutTip', $lang->user->error->loginTimeoutTip);
  59. $imgBasePath = $config->webRoot . 'theme/default/images/main/';
  60. $logoVerticalMargin = !empty($config->safe->loginCaptcha) ? '80px' : '60px';
  61. $aiVerticalMargin = !empty($config->safe->loginCaptcha) ? '64px' : '48px';
  62. set::zui(true);
  63. div
  64. (
  65. setID('main'),
  66. setClass('no-padding'),
  67. div
  68. (
  69. setID('login'),
  70. div
  71. (
  72. setID('loginPanel'),
  73. div
  74. (
  75. setClass('flex items-start loginBody'),
  76. cell
  77. (
  78. set::width('5/12'),
  79. setID('logo-box'),
  80. set::style(array('background-image' => 'url(' . $imgBasePath . $config->user->loginImg['bg'] . ')')),
  81. h::img(setID('login-logo'), set::style(array('top' => $logoVerticalMargin)), set::src($imgBasePath . $config->user->loginImg['logo'])),
  82. h::img(setID('login-ai'), set::style(array('bottom' => $aiVerticalMargin)), set::src($imgBasePath . $config->user->loginImg['ai']))
  83. ),
  84. cell
  85. (
  86. set::width('7/12'),
  87. setID('loginBox'),
  88. div
  89. (
  90. setClass('header'),
  91. h2(setClass('font-bold'), sprintf($lang->welcome, $app->company->name)),
  92. dropdown
  93. (
  94. setID('langs'),
  95. setClass('actions btn'),
  96. set::title('Change Language/更换语言/更換語言'),
  97. set::items($langItems),
  98. set::menuClass('langsDropMenu'),
  99. set::staticMenu(true),
  100. set::trigger('hover'),
  101. html($config->langs[$clientLang])
  102. )
  103. ),
  104. $loginExpired ? p(setClass('text-danger loginExpired'), $lang->user->loginExpired) : null,
  105. form
  106. (
  107. set::layout('grid'),
  108. on::click('#submit', 'safeSubmit'),
  109. set::requiredFields(false),
  110. setID('loginForm'),
  111. formGroup
  112. (
  113. set::width('full'),
  114. set::label($lang->user->account),
  115. set::control(array('control' => 'input', 'name' => 'account', 'id' => 'account'))
  116. ),
  117. formGroup
  118. (
  119. set::width('full'),
  120. set::label($lang->user->password),
  121. input(set(array('type' => 'password', 'name' => 'password', 'id' => 'password')))
  122. ),
  123. !empty($this->config->safe->loginCaptcha) ? formGroup
  124. (
  125. set::width('full'),
  126. set::label($lang->user->captcha),
  127. div
  128. (
  129. setClass('captchaBox'),
  130. inputGroup
  131. (
  132. input(set::name('captcha')),
  133. span(setClass('input-group-addon'), h::img(set::src($this->createLink('misc', 'captcha')), on::click('refreshCaptcha(e.target)'), set::style(array('height' => '2.1rem'))))
  134. )
  135. )
  136. ) : null,
  137. formGroup
  138. (
  139. setID('loginOptions'),
  140. set::width('full'),
  141. set::control(array('control' => 'checkList', 'items' => $lang->user->keepLogin, 'name' => 'keepLogin', 'value' => $keepLogin)),
  142. a(
  143. set('href', $resetLink),
  144. set('class', 'resetPassword'),
  145. $lang->user->forgetPassword
  146. )
  147. ),
  148. formHidden('referer', $referer),
  149. set::actions(array
  150. (
  151. array('text' => $lang->login, 'id' => 'submit', 'class' => 'primary', 'btnType' => 'submit'),
  152. $app->company->guest ? array('text' => $lang->user->asGuest, 'class' => 'w-full not-open-url', 'url' => createLink($config->default->module)) : null
  153. ))
  154. )
  155. )
  156. ),
  157. (count($plugins['expired']) > 0 || count($plugins['expiring']) > 0) ? div
  158. (
  159. setClass('table-row-extension'),
  160. div
  161. (
  162. setID('notice'),
  163. setClass('alert secondary'),
  164. div(setClass('content'), icon(setClass('text-secondary'), 'exclamation-sign'), html($expiredCountTips))
  165. )
  166. ) : null,
  167. empty($demoUsers) ? null : div
  168. (
  169. setClass('footer'),
  170. span($lang->user->loginWithDemoUser),
  171. $demoUserItems
  172. )
  173. ),
  174. div
  175. (
  176. setID('info'),
  177. div
  178. (
  179. setID('poweredby'),
  180. ($unsafeSites && !empty($unsafeSites[$zentaoDirName])) ? div(a(setClass('showNotice'), set::href('###'), on::click('showNotice'), $lang->user->notice4Safe)) : null,
  181. $config->checkVersion ? h::iframe(setID('updater'), setClass('hidden'), set::src(createLink('misc', 'checkUpdate', "sn=$sn"))) : null
  182. )
  183. )
  184. )
  185. );
  186. render('pagebase');