Rwkregime

Untitled

Mar 23rd, 2020
864
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 9.25 KB | None | 0 0
  1.  
  2. <?php
  3.  
  4. /*
  5. [UCenter] (C)2001-2009 Comsenz Inc.
  6. This is NOT a freeware, use is subject to license terms
  7.  
  8. $Id: user.php 916 2009-01-19 05:56:07Z monkey $
  9. */
  10.  
  11. !defined('IN_UC') && exit('Access Denied');
  12.  
  13. define('UC_USER_CHECK_USERNAME_FAILED', -1);
  14. define('UC_USER_USERNAME_BADWORD', -2);
  15. define('UC_USER_USERNAME_EXISTS', -3);
  16. define('UC_USER_EMAIL_FORMAT_ILLEGAL', -4);
  17. define('UC_USER_EMAIL_ACCESS_ILLEGAL', -5);
  18. define('UC_USER_EMAIL_EXISTS', -6);
  19.  
  20. class usercontrol extends base {
  21.  
  22.  
  23. function __construct() {
  24. $this->usercontrol();
  25. }
  26.  
  27. function usercontrol() {
  28. parent::__construct();
  29. $this->load('user');
  30. $this->app = $this->cache['apps'][UC_APPID];
  31. }
  32.  
  33. // -1 ���
  34. function onsynlogin() {
  35. $this->init_input();
  36. $uid = $this->input('uid');
  37. if($this->app['synlogin']) {
  38. if($this->user = $_ENV['user']->get_user_by_uid($uid)) {
  39. $synstr = '';
  40. foreach($this->cache['apps'] as $appid => $app) {
  41. if($app['synlogin'] && $app['appid'] != $this->app['appid']) {
  42. $synstr .= '<script type="text/javascript" src="'.$app['url'].'/api/uc.php?time='.$this->time.'&code='.urlencode($this->authcode('action=synlogin&username='.$this->user['username'].'&uid='.$this->user['uid'].'&password='.$this->user['password']."&time=".$this->time, 'ENCODE', $app['authkey'])).'"></script>';
  43. }
  44. }
  45. return $synstr;
  46. }
  47. }
  48. return '';
  49. }
  50.  
  51. function onsynlogout() {
  52. $this->init_input();
  53. if($this->app['synlogin']) {
  54. $synstr = '';
  55. foreach($this->cache['apps'] as $appid => $app) {
  56. if($app['synlogin'] && $app['appid'] != $this->app['appid']) {
  57. $synstr .= '<script type="text/javascript" src="'.$app['url'].'/api/uc.php?time='.$this->time.'&code='.urlencode($this->authcode('action=synlogout&time='.$this->time, 'ENCODE', $app['authkey'])).'"></script>';
  58. }
  59. }
  60. return $synstr;
  61. }
  62. return '';
  63. }
  64.  
  65. function onregister() {
  66. $this->init_input();
  67. $username = $this->input('username');
  68. $password = $this->input('password');
  69. $email = $this->input('email');
  70. $questionid = $this->input('questionid');
  71. $answer = $this->input('answer');
  72.  
  73. if(($status = $this->_check_username($username)) < 0) {
  74. return $status;
  75. }
  76. if(($status = $this->_check_email($email)) < 0) {
  77. return $status;
  78. }
  79. $uid = $_ENV['user']->add_user($username, $password, $email, 0, $questionid, $answer);
  80. return $uid;
  81. }
  82.  
  83. function onedit() {
  84. $this->init_input();
  85. $username = $this->input('username');
  86. $oldpw = $this->input('oldpw');
  87. $newpw = $this->input('newpw');
  88. $email = $this->input('email');
  89. $ignoreoldpw = $this->input('ignoreoldpw');
  90. $questionid = $this->input('questionid');
  91. $answer = $this->input('answer');
  92.  
  93. if(!$ignoreoldpw && $email && ($status = $this->_check_email($email, $username)) < 0) {
  94. return $status;
  95. }
  96. $status = $_ENV['user']->edit_user($username, $oldpw, $newpw, $email, $ignoreoldpw, $questionid, $answer);
  97.  
  98. if($newpw && $status > 0) {
  99. $this->load('note');
  100. $_ENV['note']->add('updatepw', 'username='.urlencode($username).'&password=');
  101. $_ENV['note']->send();
  102. }
  103. return $status;
  104. }
  105.  
  106. function onlogin() {
  107. $this->init_input();
  108. $isuid = $this->input('isuid');
  109. $username = $this->input('username');
  110. $password = $this->input('password');
  111. $checkques = $this->input('checkques');
  112. $questionid = $this->input('questionid');
  113. $answer = $this->input('answer');
  114. if($isuid) {
  115. $user = $_ENV['user']->get_user_by_uid($username);
  116. } else {
  117. $user = $_ENV['user']->get_user_by_username($username);
  118. }
  119.  
  120. $passwordmd5 = preg_match('/^\w{32}$/', $password) ? $password : md5($password);
  121. if(empty($user)) {
  122. $status = -1;
  123. } elseif($user['password'] != md5($passwordmd5.$user['salt'])) {
  124. $status = -2;
  125. } elseif($checkques && $user['secques'] != '' && $user['secques'] != $_ENV['user']->quescrypt($questionid, $answer)) {
  126. $status = -3;
  127. } else {
  128. $status = $user['uid'];
  129. }
  130. $merge = $status != -1 && !$isuid && $_ENV['user']->check_mergeuser($username) ? 1 : 0;
  131. return array($status, $user['username'], $password, $user['email'], $merge);
  132. }
  133.  
  134. function oncheck_email() {
  135. $this->init_input();
  136. $email = $this->input('email');
  137. return $this->_check_email($email);
  138. }
  139.  
  140. function oncheck_username() {
  141. $this->init_input();
  142. $username = $this->input('username');
  143. if(($status = $this->_check_username($username)) < 0) {
  144. return $status;
  145. } else {
  146. return 1;
  147. }
  148. }
  149.  
  150. function onget_user() {
  151. $this->init_input();
  152. $username = $this->input('username');
  153. if(!$this->input('isuid')) {
  154. $status = $_ENV['user']->get_user_by_username($username);
  155. } else {
  156. $status = $_ENV['user']->get_user_by_uid($username);
  157. }
  158. if($status) {
  159. return array($status['uid'],$status['username'],$status['email']);
  160. } else {
  161. return 0;
  162. }
  163. }
  164.  
  165.  
  166. function ongetprotected() {
  167. $protectedmembers = $this->db->fetch_all("SELECT uid,username FROM ".UC_DBTABLEPRE."protectedmembers GROUP BY username");
  168. return $protectedmembers;
  169. }
  170.  
  171. function ondelete() {
  172. $this->init_input();
  173. $uid = $this->input('uid');
  174. return $_ENV['user']->delete_user($uid);
  175. }
  176.  
  177. function onaddprotected() {
  178. $this->init_input();
  179. $username = $this->input('username');
  180. $admin = $this->input('admin');
  181. $appid = $this->app['appid'];
  182. $usernames = (array)$username;
  183. foreach($usernames as $username) {
  184. $user = $_ENV['user']->get_user_by_username($username);
  185. $uid = $user['uid'];
  186. $this->db->query("REPLACE INTO ".UC_DBTABLEPRE."protectedmembers SET uid='$uid', username='$username', appid='$appid', dateline='{$this->time}', admin='$admin'", 'SILENT');
  187. }
  188. return $this->db->errno() ? -1 : 1;
  189. }
  190.  
  191. function ondeleteprotected() {
  192. $this->init_input();
  193. $username = $this->input('username');
  194. $appid = $this->app['appid'];
  195. $usernames = (array)$username;
  196. foreach($usernames as $username) {
  197. $this->db->query("DELETE FROM ".UC_DBTABLEPRE."protectedmembers WHERE username='$username' AND appid='$appid'");
  198. }
  199. return $this->db->errno() ? -1 : 1;
  200. }
  201.  
  202. function onmerge() {
  203. $this->init_input();
  204. $oldusername = $this->input('oldusername');
  205. $newusername = $this->input('newusername');
  206. $uid = $this->input('uid');
  207. $password = $this->input('password');
  208. $email = $this->input('email');
  209. if(($status = $this->_check_username($newusername)) < 0) {
  210. return $status;
  211. }
  212. $uid = $_ENV['user']->add_user($newusername, $password, $email, $uid);
  213. $this->db->query("UPDATE ".UC_DBTABLEPRE."pms SET msgfrom='$newusername' WHERE msgfromid='$uid' AND msgfrom='$oldusername'");
  214. $this->db->query("DELETE FROM ".UC_DBTABLEPRE."mergemembers WHERE appid='".$this->app['appid']."' AND username='$oldusername'");
  215. return $uid;
  216. }
  217.  
  218. function onmerge_remove() {
  219. $this->init_input();
  220. $username = $this->input('username');
  221. $this->db->query("DELETE FROM ".UC_DBTABLEPRE."mergemembers WHERE appid='".$this->app['appid']."' AND username='$username'");
  222. return NULL;
  223. }
  224.  
  225. function _check_username($username) {
  226. $username = addslashes(trim(stripslashes($username)));
  227. if(!$_ENV['user']->check_username($username)) {
  228. return UC_USER_CHECK_USERNAME_FAILED;
  229. } elseif(!$_ENV['user']->check_usernamecensor($username)) {
  230. return UC_USER_USERNAME_BADWORD;
  231. } elseif($_ENV['user']->check_usernameexists($username)) {
  232. return UC_USER_USERNAME_EXISTS;
  233. }
  234. return 1;
  235. }
  236.  
  237. function _check_email($email, $username = '') {
  238. if(empty($this->settings)) {
  239. $this->settings = $this->cache('settings');
  240. }
  241. if(!$_ENV['user']->check_emailformat($email)) {
  242. return UC_USER_EMAIL_FORMAT_ILLEGAL;
  243. } elseif(!$_ENV['user']->check_emailaccess($email)) {
  244. return UC_USER_EMAIL_ACCESS_ILLEGAL;
  245. } elseif(!$this->settings['doublee'] && $_ENV['user']->check_emailexists($email, $username)) {
  246. return UC_USER_EMAIL_EXISTS;
  247. } else {
  248. return 1;
  249. }
  250. }
  251.  
  252. function onuploadavatar() {
  253. }
  254.  
  255. function onrectavatar() {
  256. }
  257. function flashdata_decode($s) {
  258. }
  259. }
  260.  
  261. ?>
Advertisement
Add Comment
Please, Sign In to add comment