PageRenderTime 47ms CodeModel.GetById 23ms RepoModel.GetById 0ms app.codeStats 0ms

/template/inc_script/frontend_render/disabled/_deprecated___fe.login.data.php

http://phpwcms.googlecode.com/
PHP | 115 lines | 55 code | 30 blank | 30 comment | 12 complexity | 43bb6f18dffc481b62665f77cb286eeb MD5 | raw file
Possible License(s): AGPL-1.0, LGPL-2.1, ISC, MIT, LGPL-3.0, GPL-2.0, MPL-2.0-no-copyleft-exception, LGPL-2.0, BSD-3-Clause
  1. <?php
  2. /*************************************************************************************
  3. Copyright notice
  4. (c) 2002-2011 Oliver Georgi (oliver@phpwcms.de) // All rights reserved.
  5. This script is part of PHPWCMS. The PHPWCMS web content management system is
  6. free software; you can redistribute it and/or modify it under the terms of
  7. the GNU General Public License as published by the Free Software Foundation;
  8. either version 2 of the License, or (at your option) any later version.
  9. The GNU General Public License can be found at http://www.gnu.org/copyleft/gpl.html
  10. A copy is found in the textfile GPL.txt and important notices to the license
  11. from the author is found in LICENSE.txt distributed with these scripts.
  12. This script is distributed in the hope that it will be useful, but WITHOUT ANY
  13. WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
  14. PARTICULAR PURPOSE. See the GNU General Public License for more details.
  15. This copyright notice MUST APPEAR in all copies of the script!
  16. *************************************************************************************/
  17. // ----------------------------------------------------------------
  18. // obligate check for phpwcms constants
  19. if (!defined('PHPWCMS_ROOT')) {
  20. die("You Cannot Access This Script Directly, Have a Nice Day.");
  21. }
  22. // ----------------------------------------------------------------
  23. // general frontend login form
  24. $_loginData = array();
  25. $_loginData['template'] = ''; // this is what is to be displayed in frontend
  26. if(strpos($content['all'], '{LOGIN_DATA}')) {
  27. // 1st we load template data
  28. if(is_file(PHPWCMS_TEMPLATE.'inc_default/fe_login.tmpl')) {
  29. $_loginData['template'] = @file_get_contents(PHPWCMS_TEMPLATE.'inc_default/fe_login.tmpl');
  30. $_loginData['form'] = get_tmpl_section('LOGIN_FORM', $_loginData['template']);
  31. $_loginData['logged_in'] = get_tmpl_section('LOGIN_IS', $_loginData['template']);
  32. $_loginData['settings'] = get_tmpl_section('LOGIN_SETTINGS', $_loginData['template']);
  33. $_loginData['settings'] = parse_ini_str($_loginData['settings'], false);
  34. $_loginData['settings'] = array_merge( array( 'date_format' => "%m/%d/%y",
  35. 'set_locale' => '',
  36. 'cookie_exire' => 7776000
  37. ) , $_loginData['settings'] );
  38. // for future use
  39. //$_loginData['profile'] = get_tmpl_section('LOGIN_PROFIE', $_loginData['template']);
  40. $_loginData['session_key'] = session_id();
  41. $_loginData['template'] = $_loginData['form'];
  42. $_loginData['error'] = false;
  43. $_loginData['login'] = '';
  44. $_loginData['password'] = '';
  45. $_loginData['remember'] = 0;
  46. // handle Login
  47. if(isset($_POST['feLogin'])) {
  48. $_loginData['login'] = slweg($_POST['feLogin']);
  49. $_loginData['password'] = slweg($_POST['fePassword']);
  50. $_loginData['remember'] = empty($_POST['feRemember']) ? 0 : 1;
  51. $_loginData['query_result'] = _checkFrontendUserLogin($_loginData['login'], md5($_loginData['password']));
  52. // ok, and now check if we got valid login data
  53. if($_loginData['query_result'] !== false && is_array($_loginData['query_result']) && count($_loginData['query_result'])) {
  54. $_SESSION[ $_loginData['session_key'] ] = $_loginData['login'];
  55. if($_loginData['remember']) {
  56. setcookie( 'phpwcmsFeLoginRemember', $_loginData['login'].'##-|-##'.md5($_loginData['password']),
  57. time()+$_loginData['settings']['cookie_expire'], '/', getCookieDomain() );
  58. }
  59. } else {
  60. $_loginData['error'] = true;
  61. }
  62. }
  63. if(_getFeUserLoginStatus()) {
  64. // user is logged in
  65. if(isset($_POST['feLogin'])) {
  66. headerRedirect(decode_entities(FE_CURRENT_URL));
  67. }
  68. $_loginData['template'] = $_loginData['logged_in'];
  69. $_loginData['template'] = str_replace('{LOGIN}', html_specialchars( $_SESSION[ $_loginData['session_key'] ] ), $_loginData['template']);
  70. } else {
  71. $_loginData['template'] = render_cnt_template($_loginData['template'], 'ERROR', ($_loginData['error'] ? 'login/pass wrong' : '') );
  72. $_loginData['template'] = render_cnt_template($_loginData['template'], 'LOGIN', html_specialchars($_loginData['login']));
  73. $_loginData['template'] = render_cnt_template($_loginData['template'], 'PASSWORD', '');
  74. $_loginData['template'] = render_cnt_template($_loginData['template'], 'REMEMBER', ($_loginData['remember'] ? ' checked="checked"' : '') );
  75. }
  76. $_loginData['template'] = str_replace('{FORM_TARGET}', FE_CURRENT_URL, $_loginData['template']);
  77. }
  78. }
  79. $content['all'] = str_replace('{LOGIN_DATA}', $_loginData['template'], $content['all']);
  80. ?>