member.class.php 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152
  1. <?php
  2. class mymps_member_log
  3. {
  4. public $cookiepre;
  5. public function __construct($cookiepre)
  6. {
  7. $this->cookiepre = $cookiepre;
  8. }
  9. public function mymps_member_log($cookiepre)
  10. {
  11. $this->__construct($cookiepre);
  12. }
  13. public function PutLogin($s_uid = '', $s_pwd = '', $memory = '')
  14. {
  15. global $cookiepre;
  16. global $cookiedomain;
  17. global $cookiepath;
  18. global $timestamp;
  19. $timestamp = $timestamp ? $timestamp : time();
  20. if ($memory == 'on') {
  21. msetcookie('s_uid', $s_uid, 3600 * 24 * 30);
  22. msetcookie('s_pwd', mmd5($s_pwd, 'EN'), 3600 * 24 * 30);
  23. }
  24. else {
  25. msetcookie('s_uid', $s_uid, 0);
  26. msetcookie('s_pwd', mmd5($s_pwd, 'EN'));
  27. }
  28. }
  29. public function in($s_uid = '', $s_pwd = '', $memory = '', $url = '', $type = '')
  30. {
  31. global $mymps_global;
  32. global $uid;
  33. global $db_mymps;
  34. global $db;
  35. global $timestamp;
  36. global $do;
  37. global $mymps_mymps;
  38. if ($s_uid && $s_pwd) {
  39. $this->PutLogin($s_uid, $s_pwd, $memory);
  40. if ($do != 'power' && !defined('WAP')) {
  41. $timestamp = $timestamp ? $timestamp : time();
  42. $loginip = GetIP();
  43. if ($mymps_mymps['cfg_iflogin_port'] == 1) {
  44. if ($loginip) {
  45. $ip2area = ip2area($loginip);
  46. }
  47. else {
  48. $ip2area = '';
  49. }
  50. $browser = getbrowser();
  51. $os = getos();
  52. $port = getport();
  53. }
  54. else {
  55. $ip2area = $browser = $os = $port = '';
  56. }
  57. $db->query('DELETE FROM `' . $db_mymps . 'member_record_login` WHERE userid = \'' . $s_uid . '\'');
  58. $db->query('INSERT INTO `' . $db_mymps . 'member_record_login` (id,userid,userpwd,pubdate,ip,ip2area,browser,os,port,result) VALUES (\'\',\'' . $s_uid . '\',\'' . $userpwd . '\',\'' . $timestamp . '\',\'' . $loginip . '\',\'' . $ip2area . '\',\'' . $browser . '\',\'' . $os . '\',\'' . $port . '\',\'1\')');
  59. $db->query('UPDATE `' . $db_mymps . 'member` SET logintime = \'' . $timestamp . '\' WHERE userid = \'' . $s_uid . '\'');
  60. }
  61. if ($url != 'noredirect') {
  62. if (empty($url) && empty($type)) {
  63. echo mymps_goto($mymps_global['SiteUrl'] . '/member/index.php');
  64. }
  65. else {
  66. if (!empty($url) && empty($type)) {
  67. $url = urldecode($url);
  68. echo mymps_goto($url);
  69. }
  70. }
  71. }
  72. }
  73. }
  74. public function out($url = '')
  75. {
  76. global $mymps_global;
  77. global $db;
  78. global $db_mymps;
  79. global $timestamp;
  80. global $s_uid;
  81. $s_uid = mgetcookie('s_uid');
  82. $s_uid = isset($s_uid) ? addslashes($s_uid) : '';
  83. $timestamp = $timestamp ? $timestamp : time();
  84. if ($s_uid && !defined('WAP')) {
  85. $db->query('UPDATE `' . $db_mymps . 'member_record_login` SET outdate = \'' . $timestamp . '\' WHERE userid = \'' . $s_uid . '\'');
  86. }
  87. msetcookie('s_uid', '');
  88. msetcookie('s_pwd', '');
  89. if ($url == 'noredirect') {
  90. }
  91. else if (empty($url)) {
  92. echo mymps_goto('../index.php');
  93. }
  94. else {
  95. $url = urldecode($url);
  96. echo mymps_goto($url);
  97. }
  98. }
  99. public function chk_in()
  100. {
  101. global $db;
  102. global $db_mymps;
  103. global $s_uid;
  104. global $cookie;
  105. $s_uid = mgetcookie('s_uid');
  106. $s_pwd = mgetcookie('s_pwd');
  107. if (empty($s_uid)) {
  108. msetcookie('s_uid', '');
  109. msetcookie('s_pwd', '');
  110. return false;
  111. }
  112. else {
  113. $m = $db->getRow('SELECT userpwd,openid FROM `' . $db_mymps . 'member` WHERE userid = \'' . $s_uid . '\'');
  114. if ($m['openid'] && !$m['userpwd']) {
  115. return true;
  116. }
  117. else {
  118. return mmd5($m['userpwd'], 'EN', '', $this->cookiepre) == $s_pwd ? true : false;
  119. }
  120. }
  121. }
  122. public function get_info()
  123. {
  124. global $s_uid;
  125. global $db;
  126. global $db_mymps;
  127. $s_uid = mgetcookie('s_uid');
  128. return $db->getRow('SELECT * FROM ' . $db_mymps . 'member WHERE userid = \'' . $s_uid . '\'');
  129. }
  130. }
  131. !defined('IN_MYMPS') && exit('FORBIDDEN');
  132. $member_log = new mymps_member_log($cookiepre);
  133. ?>