global.php
上传用户:gzy2002
上传日期:2010-02-11
资源大小:1785k
文件大小:6k
源码类别:

电子政务应用

开发平台:

Java

  1. <?php
  2. // +-------------------------------------------------------------+
  3. // | DeskPRO v [2.0.1 Production]
  4. // | Copyright (C) 2001 - 2004 Headstart Solutions Limited
  5. // | Supplied by WTN-WDYL
  6. // | Nullified by WTN-WDYL
  7. // | Distribution via WebForum, ForumRU and associated file dumps
  8. // +-------------------------------------------------------------+
  9. // | DESKPRO IS NOT FREE SOFTWARE
  10. // +-------------------------------------------------------------+
  11. // | License ID : Full Enterprise License =) ...
  12. // | License Owner : WTN-WDYL Team
  13. // +-------------------------------------------------------------+
  14. // | $RCSfile: global.php,v $
  15. // | $Date: 2004/02/10 01:34:26 $
  16. // | $Revision: 1.75 $
  17. // +-------------------------------------------------------------+
  18. // | File Details:
  19. // | - Global initialization for technician interface.
  20. // +-------------------------------------------------------------+
  21. error_reporting(E_ALL ^ E_NOTICE);
  22. define('TECHZONE', 1);
  23. define('LOC_JAVASCRIPT', './../../includes/javascript/');
  24. define('LOC_IMAGES', './../../images/');
  25. define('LOC_CSS', './../../includes/css/');
  26. define('INCLUDE_PATH', './../../includes/');
  27. require_once(INCLUDE_PATH . 'init.php');
  28. ############################### SESSIONS / USER DATA ###############################
  29. // If we are *NOT* showing the login page, perform authentication checks
  30. // log out
  31. if ($_REQUEST['do'] == 'logout') {
  32. // it needs to be a valid session before we can log out of it otherwise we are just adding
  33. // entries to tech_log that we shouldn't be
  34. $session = validate_session(NULL, NULL, 1);
  35. logout_tech_session($_COOKIE['dp_tech_sessionid'], $session['techid']);
  36. global_login('You have been logged out.', 1);
  37. }
  38. // if we are not about to show the login page
  39. if (!defined('LOGIN')) { 
  40. $session = validate_session(NULL, NULL, 1);
  41. if ($_REQUEST['original_uri']) {
  42. $req = $_REQUEST['original_uri'];
  43. } else {
  44. $req = $_SERVER['REQUEST_URI'];
  45. }
  46. // we have a session so get tech details
  47. if (is_array($session)) {
  48. if ($session['techid']) {
  49. $user = $db->query_return("SELECT * FROM tech WHERE id = '$session[techid]'");
  50. }
  51. // bad session, check userid/password if they are being remembered
  52. } elseif ($_COOKIE['dp_tech_userid'] AND $_COOKIE['dp_tech_password']) {
  53. $user = $db->query_return("
  54. SELECT * FROM tech 
  55. WHERE id = '" . mysql_escape_string($_COOKIE['dp_tech_userid']) . "' 
  56. AND password_cookie = '" . mysql_escape_string($_COOKIE['dp_tech_password']) . "'
  57. ");
  58. // If the cookie is bogus but he's logging in anyway, keep going.
  59. if (!is_array($user) AND !(($_REQUEST['login_form'] == 'login') OR strtolower($_REQUEST['submit'] == 'login'))) {
  60. delete_cookies();
  61. sleep(1);
  62. global_login('The cookie your browser provided is invalid.');
  63. }
  64. // if we are here then the username/password match so we make a new session based on that
  65. $session = make_session($user[id]);
  66. // No headers yet if making a PDF
  67. if (!defined('PDF')) { 
  68. dp_setcookie('dp_tech_sessionid', $session[sessionid]);
  69. }
  70. }
  71. // is tech/admin trying to login
  72. if ($_REQUEST['login_form'] == 'login' OR strtolower($_REQUEST['submit']) == 'login') { 
  73. // clear old sessions before login
  74. prune_sessions();
  75. max_limits('users');
  76. $user = $db->query_return("
  77. SELECT * FROM tech 
  78. WHERE username = '". mysql_escape_string($_POST['username']) . "'
  79. ");
  80. // check username exists
  81. if (!$db->num_rows()) {
  82. delete_cookies();
  83. sleep(1);
  84. global_login('The username you specified is not registered.');
  85. }
  86. if (($user['id'] AND $_POST['username'] != '') AND ($_POST['password'] == $user['password'])) {
  87. $session = make_session($user[id]);
  88. if (!defined('PDF')) {
  89. dp_setcookie('dp_tech_sessionid', $session[sessionid]);
  90. }
  91. // if we are staying logged in, we remember the userid/password at this point
  92. if ($_REQUEST[cookie]) {
  93. dp_setcookie('dp_tech_userid', $user[id], 'ever');
  94. dp_setcookie('dp_tech_password', $user[password_cookie], 'ever');
  95. }
  96. // Rebuild GET, POST and FILE data
  97. $_getvars = unserialize($_POST['_getvars']);
  98. $_GET = array_merge($_GET, $_getvars);
  99. $_postvars = unserialize($_POST['_postvars']);
  100. $_POST = array_merge($_POST, $_postvars);
  101. $_filevars = unserialize($_POST['_filevars']);
  102. $_FILES = array_merge($_FILES, $_filevars);
  103. if ($_REQUEST['_request']) {
  104. $_REQUEST = unserialize($_REQUEST['_request']);
  105. } else {
  106. $_REQUEST = array_merge($_GET,$_POST,$_COOKIE);
  107. }
  108. // fix where we are
  109. if (!$_REQUEST['original_url']) { 
  110. $_REQUEST['original_url'] = "./../home/index.php";
  111. } else {
  112. // username is correct, but password is wrong
  113. delete_cookies();
  114. sleep(1);
  115. global_login('The password you specified was invalid.');
  116. }
  117. }
  118. // no session at this point? need to login
  119. if (!is_array($session)) {
  120. global_login('Please login');
  121. }
  122. // is tech disabled?
  123. if (is_array($user)) {
  124. if ($user[disabled]) {
  125. sleep(1);
  126. global_login($user['disabled_reason']);
  127. }
  128. }
  129. }
  130. ############################### GET LANGUAGES ###############################
  131. // we need $dplang in tech zone
  132. $db->query("SELECT * FROM template_words WHERE language = '0' OR language = '$session[language]' OR language = '$settings[default_language]'");
  133. while ($result = $db->row_array()) {
  134. if ($result[language] == '0') {
  135. $start_lang[$result[wordref]] = trim($result[text]);
  136. } elseif ($result[language] == $settings[default_language]) {
  137. $default_lang[$result[wordref]] = trim($result[text]);
  138. } else {
  139. $this_lang[$result[wordref]] = trim($result[text]);
  140. }
  141. }
  142. $dplang = array_merge($start_lang, $default_lang);
  143. $dplang = array_merge($dplang, $this_lang); 
  144. $settings['timezone'] -= ($settings['timezone'] - $settings['timezone_offset']);
  145. if ($user['timezone'] != NULL) {
  146.     $settings['timezone'] -= ($settings['timezone'] - $user['timezone']);
  147. }   
  148. if ($user['timezone_dst']) {
  149.     $settings['timezone']++;
  150. }   
  151. ?>