PageRenderTime 70ms CodeModel.GetById 23ms RepoModel.GetById 0ms app.codeStats 1ms

/Quản lý website trường trung học phổ thông PHP/lc1/includes/core/admin_relogin.php

https://gitlab.com/phamngsinh/baitaplon_sinhvien
PHP | 127 lines | 108 code | 13 blank | 6 comment | 19 complexity | 45c5f8e8fa1c4d127ad865cafbb17d22 MD5 | raw file
  1. <?php
  2. /**
  3. * @Project NUKEVIET 3.0
  4. * @Author VINADES.,JSC (contact@vinades.vn)
  5. * @copyright 2010
  6. * @createdate 1/10/2010 9:3
  7. */
  8. if ( ! defined( 'NV_MAINFILE' ) ) die( 'Stop!!!' );
  9. if ( defined( "NV_IS_ADMIN" ) )
  10. {
  11. if ( empty( $admin_info['checkpass'] ) )
  12. {
  13. if ( $nv_Request->isset_request( NV_ADMINRELOGIN_VARIABLE, 'get' ) and $nv_Request->get_int( NV_ADMINRELOGIN_VARIABLE, 'get' ) == 1 )
  14. {
  15. $redirect = $nv_Request->get_string( 'admin_relogin_redirect', 'session' );
  16. $check_hits = $admin_info['checkhits'];
  17. $check_hits ++;
  18. $nv_Request->set_Session( 'online', '0|' . $admin_info['last_online'] . '|' . NV_CURRENTTIME . '|' . $check_hits );
  19. $error = "";
  20. $password = "";
  21. if ( $nv_Request->get_int( 'save', 'post' ) == '1' )
  22. {
  23. if ( $client_info['is_myreferer'] != 1 ) trigger_error( "Wrong URL", 256 );
  24. $nv_password = filter_text_input( 'nv_password', 'post', '', '', 50 );
  25. if ( empty( $nv_password ) )
  26. {
  27. $error = $lang_global['password_empty'];
  28. }
  29. else
  30. {
  31. if ( defined( 'NV_IS_USER_FORUM' ) )
  32. {
  33. $nv_username = $admin_info['username'];
  34. define( 'NV_IS_MOD_USER', true );
  35. nv_insert_logs( NV_LANG_DATA, "login", "[" . $nv_username . "] " . strtolower( $lang_global['loginsubmit'] ), " Client IP:" . NV_CLIENT_IP, 0 );
  36. require_once ( NV_ROOTDIR . '/' . DIR_FORUM . '/nukeviet/login.php' );
  37. }
  38. $query = $db->constructQuery( "SELECT t1.admin_id as admin_id, t1.lev as admin_lev, t1.last_agent as admin_last_agent, t1.last_ip as admin_last_ip, t1.last_login as admin_last_login, t2.password as admin_pass FROM `" . NV_AUTHORS_GLOBALTABLE . "` AS t1 INNER JOIN `" . NV_USERS_GLOBALTABLE . "` AS t2 ON t1.admin_id = t2.userid WHERE t1.admin_id = [s] AND t1.lev!=0 AND t1.is_suspend=0 AND t2.active=1", $admin_info['admin_id'] );
  39. $result = $db->sql_query( $query );
  40. $row = $db->sql_fetchrow( $result );
  41. $db->sql_freeresult( $result );
  42. if ( ! $crypt->validate( $nv_password, $row['admin_pass'] ) )
  43. {
  44. $error = $lang_global['incorrect_password'];
  45. }
  46. else
  47. {
  48. $nv_Request->set_Session( 'online', '1|' . NV_CURRENTTIME . '|' . NV_CURRENTTIME . '|0' );
  49. $nv_Request->unset_request( 'admin_login_redirect', 'session' );
  50. if ( ! empty( $redirect ) and nv_is_myreferer( $redirect ) == 1 )
  51. {
  52. Header( "Location: " . nv_url_rewrite( $redirect, true ) );
  53. exit();
  54. }
  55. else
  56. {
  57. Header( "Location: " . NV_BASE_ADMINURL );
  58. exit();
  59. }
  60. }
  61. }
  62. }
  63. if ( $check_hits > NV_ADMINRELOGIN_MAX )
  64. {
  65. $nv_Request->unset_request( 'admin,online', 'session' );
  66. $nv_Request->unset_request( 'admin_relogin_redirect', 'session' );
  67. if ( ! empty( $redirect ) and nv_is_myreferer( $redirect ) == 1 )
  68. {
  69. $server_name = preg_replace( '/^www\./e', '', nv_getenv( "HTTP_HOST" ) );
  70. $nohttp_redirect = preg_replace( array( '/^[a-zA-Z]+\:\/\//e', '/www\./e' ), array( '', '' ), $redirect );
  71. if ( ! preg_match( "/^" . preg_quote( $server_name ) . '\/' . preg_quote( NV_ADMINDIR ) . "/", $nohttp_redirect ) )
  72. {
  73. Header( "Location: " . $redirect );
  74. exit();
  75. }
  76. }
  77. Header( "Location: " . NV_BASE_SITEURL );
  78. die();
  79. }
  80. $info = ( ! empty( $error ) ) ? '<div class="error">' . sprintf( $lang_global['relogin_error_info'], $error, ( NV_ADMINRELOGIN_MAX - $check_hits + 1 ) ) . '</div>' : '<div class="normal">' . sprintf( $lang_global['relogin_info'], NV_ADMINRELOGIN_MAX - $check_hits + 1 ) . '</div>';
  81. $size = @getimagesize( NV_ROOTDIR . '/' . $global_config['site_logo'] );
  82. $dir_template = "";
  83. if ( file_exists( NV_ROOTDIR . "/themes/" . $global_config['admin_theme'] . "/system/relogin.tpl" ) )
  84. {
  85. $dir_template = NV_ROOTDIR . "/themes/" . $global_config['admin_theme'] . "/system";
  86. }
  87. else
  88. {
  89. $dir_template = NV_ROOTDIR . "/themes/admin_default/system";
  90. $global_config['admin_theme'] = "admin_default";
  91. }
  92. $xtpl = new XTemplate( "relogin.tpl", $dir_template );
  93. $xtpl->assign( 'CHARSET', $global_config['site_charset'] );
  94. $xtpl->assign( 'SITE_NAME', $global_config['site_name'] );
  95. $xtpl->assign( 'PAGE_TITLE', $lang_global['admin_page'] );
  96. $xtpl->assign( 'CSS', NV_BASE_SITEURL . "themes/" . $global_config['admin_theme'] . "/css/login.css" );
  97. $xtpl->assign( 'SITELANG', NV_LANG_INTERFACE );
  98. $xtpl->assign( 'NV_BASE_SITEURL', NV_BASE_SITEURL );
  99. $xtpl->assign( 'LOGO_SRC', NV_BASE_SITEURL . $global_config['site_logo'] );
  100. $xtpl->assign( 'LOGO_WIDTH', $size[0] );
  101. $xtpl->assign( 'LOGO_HEIGHT', $size[1] );
  102. $xtpl->assign( 'LOGIN_TITLE', $lang_global['adminlogin'] );
  103. $xtpl->assign( 'LOGIN_INFO', $info );
  104. $xtpl->assign( 'N_PASSWORD', $lang_global['password'] );
  105. $xtpl->assign( 'N_SUBMIT', $lang_global['loginsubmit'] );
  106. $xtpl->assign( 'NV_LOGOUT', $lang_global['admin_logout_title'] );
  107. $xtpl->parse( 'main' );
  108. include ( NV_ROOTDIR . "/includes/header.php" );
  109. $xtpl->out( 'main' );
  110. include ( NV_ROOTDIR . "/includes/footer.php" );
  111. }
  112. }
  113. }
  114. ?>