member.php 24 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765
  1. <?php
  2. /**
  3. * 管理员后台会员操作类
  4. */
  5. defined('IN_PHPCMS') or exit('No permission resources.');
  6. //模型缓存路径
  7. define('CACHE_MODEL_PATH',CACHE_PATH.'caches_model'.DIRECTORY_SEPARATOR.'caches_data'.DIRECTORY_SEPARATOR);
  8. pc_base::load_app_class('admin', 'admin', 0);
  9. pc_base::load_sys_class('format', '', 0);
  10. pc_base::load_sys_class('form', '', 0);
  11. pc_base::load_app_func('util', 'content');
  12. class member extends admin {
  13. private $db, $verify_db;
  14. function __construct() {
  15. parent::__construct();
  16. $this->db = pc_base::load_model('member_model');
  17. $this->_init_phpsso();
  18. }
  19. /**
  20. * defalut
  21. */
  22. function init() {
  23. $show_header = $show_scroll = true;
  24. pc_base::load_sys_class('form', '', 0);
  25. $this->verify_db = pc_base::load_model('member_verify_model');
  26. //搜索框
  27. $keyword = isset($_GET['keyword']) ? $_GET['keyword'] : '';
  28. $type = isset($_GET['type']) ? $_GET['type'] : '';
  29. $groupid = isset($_GET['groupid']) ? $_GET['groupid'] : '';
  30. $start_time = isset($_GET['start_time']) ? $_GET['start_time'] : date('Y-m-d', SYS_TIME-date('t', SYS_TIME)*86400);
  31. $end_time = isset($_GET['end_time']) ? $_GET['end_time'] : date('Y-m-d', SYS_TIME);
  32. $grouplist = getcache('grouplist');
  33. foreach($grouplist as $k=>$v) {
  34. $grouplist[$k] = $v['name'];
  35. }
  36. $memberinfo['totalnum'] = $this->db->count();
  37. $memberinfo['vipnum'] = $this->db->count(array('vip'=>1));
  38. $memberinfo['verifynum'] = $this->verify_db->count(array('status'=>0));
  39. $todaytime = strtotime(date('Y-m-d', SYS_TIME));
  40. $memberinfo['today_member'] = $this->db->count("`regdate` > '$todaytime'");
  41. include $this->admin_tpl('member_init');
  42. }
  43. /**
  44. * 会员搜索
  45. */
  46. function search() {
  47. //搜索框
  48. $keyword = isset($_GET['keyword']) ? $_GET['keyword'] : '';
  49. $type = isset($_GET['type']) ? $_GET['type'] : '';
  50. $groupid = isset($_GET['groupid']) ? $_GET['groupid'] : '';
  51. $modelid = isset($_GET['modelid']) ? $_GET['modelid'] : '';
  52. //站点信息
  53. $sitelistarr = getcache('sitelist', 'commons');
  54. $siteid = isset($_GET['siteid']) ? intval($_GET['siteid']) : '0';
  55. foreach ($sitelistarr as $k=>$v) {
  56. $sitelist[$k] = $v['name'];
  57. }
  58. $status = isset($_GET['status']) ? $_GET['status'] : '';
  59. $amount_from = isset($_GET['amount_from']) ? $_GET['amount_from'] : '';
  60. $amount_to = isset($_GET['amount_to']) ? $_GET['amount_to'] : '';
  61. $point_from = isset($_GET['point_from']) ? $_GET['point_from'] : '';
  62. $point_to = isset($_GET['point_to']) ? $_GET['point_to'] : '';
  63. $start_time = isset($_GET['start_time']) ? $_GET['start_time'] : '';
  64. $end_time = isset($_GET['end_time']) ? $_GET['end_time'] : date('Y-m-d', SYS_TIME);
  65. $grouplist = getcache('grouplist');
  66. foreach($grouplist as $k=>$v) {
  67. $grouplist[$k] = $v['name'];
  68. }
  69. //会员所属模型
  70. $modellistarr = getcache('member_model', 'commons');
  71. foreach ($modellistarr as $k=>$v) {
  72. $modellist[$k] = $v['name'];
  73. }
  74. if (isset($_GET['search'])) {
  75. //默认选取一个月内的用户,防止用户量过大给数据造成灾难
  76. $where_start_time = strtotime($start_time) ? strtotime($start_time) : 0;
  77. $where_end_time = strtotime($end_time) + 86400;
  78. //开始时间大于结束时间,置换变量
  79. if($where_start_time > $where_end_time) {
  80. $tmp = $where_start_time;
  81. $where_start_time = $where_end_time;
  82. $where_end_time = $tmp;
  83. $tmptime = $start_time;
  84. $start_time = $end_time;
  85. $end_time = $tmptime;
  86. unset($tmp, $tmptime);
  87. }
  88. $where = '';
  89. //如果是超级管理员角色,显示所有用户,否则显示当前站点用户
  90. if($_SESSION['roleid'] == 1) {
  91. if(!empty($siteid)) {
  92. $where .= "`siteid` = '$siteid' AND ";
  93. }
  94. } else {
  95. $siteid = get_siteid();
  96. $where .= "`siteid` = '$siteid' AND ";
  97. }
  98. if($status) {
  99. $islock = $status == 1 ? 1 : 0;
  100. $where .= "`islock` = '$islock' AND ";
  101. }
  102. if($groupid) {
  103. $where .= "`groupid` = '$groupid' AND ";
  104. }
  105. if($modelid) {
  106. $where .= "`modelid` = '$modelid' AND ";
  107. }
  108. $where .= "`regdate` BETWEEN '$where_start_time' AND '$where_end_time' AND ";
  109. //资金范围
  110. if($amount_from) {
  111. if($amount_to) {
  112. if($amount_from > $amount_to) {
  113. $tmp = $amount_from;
  114. $amount_from = $amount_to;
  115. $amount_to = $tmp;
  116. unset($tmp);
  117. }
  118. $where .= "`amount` BETWEEN '$amount_from' AND '$amount_to' AND ";
  119. } else {
  120. $where .= "`amount` > '$amount_from' AND ";
  121. }
  122. }
  123. //点数范围
  124. if($point_from) {
  125. if($point_to) {
  126. if($point_from > $point_to) {
  127. $tmp = $amount_from;
  128. $point_from = $point_to;
  129. $point_to = $tmp;
  130. unset($tmp);
  131. }
  132. $where .= "`point` BETWEEN '$point_from' AND '$point_to' AND ";
  133. } else {
  134. $where .= "`point` > '$point_from' AND ";
  135. }
  136. }
  137. if($keyword) {
  138. if ($type == '1') {
  139. $where .= "`username` LIKE '%$keyword%'";
  140. } elseif($type == '2') {
  141. $where .= "`userid` = '$keyword'";
  142. } elseif($type == '3') {
  143. $where .= "`email` like '%$keyword%'";
  144. } elseif($type == '4') {
  145. $where .= "`regip` = '$keyword'";
  146. } elseif($type == '5') {
  147. $where .= "`nickname` LIKE '%$keyword%'";
  148. } else {
  149. $where .= "`username` like '%$keyword%'";
  150. }
  151. } else {
  152. $where .= '1';
  153. }
  154. } else {
  155. $where = '';
  156. }
  157. $page = isset($_GET['page']) ? intval($_GET['page']) : 1;
  158. $memberlist = $this->db->listinfo($where, 'userid DESC', $page, 15);
  159. //查询会员头像
  160. foreach($memberlist as $k=>$v) {
  161. $memberlist[$k]['avatar'] = get_memberavatar($v['phpssouid']);
  162. }
  163. $pages = $this->db->pages;
  164. $big_menu = array('?m=member&c=member&a=manage&menuid=72', L('member_research'));
  165. include $this->admin_tpl('member_list');
  166. }
  167. /**
  168. * member list
  169. */
  170. function manage() {
  171. $sitelistarr = getcache('sitelist', 'commons');
  172. foreach ($sitelistarr as $k=>$v) {
  173. $sitelist[$k] = $v['name'];
  174. }
  175. $groupid = isset($_GET['groupid']) ? intval($_GET['groupid']) : '';
  176. $page = isset($_GET['page']) ? intval($_GET['page']) : 1;
  177. //如果是超级管理员角色,显示所有用户,否则显示当前站点用户
  178. if($_SESSION['roleid'] == 1) {
  179. $where = '';
  180. } else {
  181. $siteid = get_siteid();
  182. $where .= "`siteid` = '$siteid'";
  183. }
  184. $memberlist_arr = $this->db->listinfo($where, 'userid DESC', $page, 15);
  185. $pages = $this->db->pages;
  186. //搜索框
  187. $keyword = isset($_GET['keyword']) ? $_GET['keyword'] : '';
  188. $type = isset($_GET['type']) ? $_GET['type'] : '';
  189. $start_time = isset($_GET['start_time']) ? $_GET['start_time'] : '';
  190. $end_time = isset($_GET['end_time']) ? $_GET['end_time'] : date('Y-m-d', SYS_TIME);
  191. $grouplist = getcache('grouplist');
  192. foreach($grouplist as $k=>$v) {
  193. $grouplist[$k] = $v['name'];
  194. }
  195. //会员所属模型
  196. $modellistarr = getcache('member_model', 'commons');
  197. foreach ($modellistarr as $k=>$v) {
  198. $modellist[$k] = $v['name'];
  199. }
  200. //查询会员头像
  201. foreach($memberlist_arr as $k=>$v) {
  202. $memberlist[$k] = $v;
  203. $memberlist[$k]['avatar'] = get_memberavatar($v['phpssouid']);
  204. }
  205. $big_menu = array('javascript:window.top.art.dialog({id:\'add\',iframe:\'?m=member&c=member&a=add\', title:\''.L('member_add').'\', width:\'700\', height:\'500\', lock:true}, function(){var d = window.top.art.dialog({id:\'add\'}).data.iframe;var form = d.document.getElementById(\'dosubmit\');form.click();return false;}, function(){window.top.art.dialog({id:\'add\'}).close()});void(0);', L('member_add'));
  206. include $this->admin_tpl('member_list');
  207. }
  208. /**
  209. * add member
  210. */
  211. function add() {
  212. header("Cache-control: private");
  213. if(isset($_POST['dosubmit'])) {
  214. $info = array();
  215. if(!$this->_checkname($_POST['info']['username'])){
  216. showmessage(L('member_exist'));
  217. }
  218. $info = $this->_checkuserinfo($_POST['info']);
  219. if(!$this->_checkpasswd($info['password'])){
  220. showmessage(L('password_format_incorrect'));
  221. }
  222. $info['regip'] = ip();
  223. $info['overduedate'] = strtotime($info['overduedate']);
  224. $status = $this->client->ps_member_register($info['username'], $info['password'], $info['email'], $info['regip']);
  225. if($status > 0) {
  226. unset($info[pwdconfirm]);
  227. $info['phpssouid'] = $status;
  228. //取phpsso密码随机数
  229. $memberinfo = $this->client->ps_get_member_info($status);
  230. $memberinfo = unserialize($memberinfo);
  231. $info['encrypt'] = $memberinfo['random'];
  232. $info['password'] = password($info['password'], $info['encrypt']);
  233. $info['regdate'] = $info['lastdate'] = SYS_TIME;
  234. $this->db->insert($info);
  235. if($this->db->insert_id()){
  236. showmessage(L('operation_success'),'?m=member&c=member&a=add', '', 'add');
  237. }
  238. } elseif($status == -4) {
  239. showmessage(L('username_deny'), HTTP_REFERER);
  240. } elseif($status == -5) {
  241. showmessage(L('email_deny'), HTTP_REFERER);
  242. } else {
  243. showmessage(L('operation_failure'), HTTP_REFERER);
  244. }
  245. } else {
  246. $show_header = $show_scroll = true;
  247. $siteid = get_siteid();
  248. //会员组缓存
  249. $group_cache = getcache('grouplist', 'member');
  250. foreach($group_cache as $_key=>$_value) {
  251. $grouplist[$_key] = $_value['name'];
  252. }
  253. //会员模型缓存
  254. $member_model_cache = getcache('member_model', 'commons');
  255. foreach($member_model_cache as $_key=>$_value) {
  256. if($siteid == $_value['siteid']) {
  257. $modellist[$_key] = $_value['name'];
  258. }
  259. }
  260. include $this->admin_tpl('member_add');
  261. }
  262. }
  263. /**
  264. * edit member
  265. */
  266. function edit() {
  267. if(isset($_POST['dosubmit'])) {
  268. $memberinfo = $info = array();
  269. $basicinfo['userid'] = $_POST['info']['userid'];
  270. $basicinfo['username'] = $_POST['info']['username'];
  271. $basicinfo['nickname'] = $_POST['info']['nickname'];
  272. $basicinfo['email'] = $_POST['info']['email'];
  273. $basicinfo['point'] = $_POST['info']['point'];
  274. $basicinfo['password'] = $_POST['info']['password'];
  275. $basicinfo['groupid'] = $_POST['info']['groupid'];
  276. $basicinfo['modelid'] = $_POST['info']['modelid'];
  277. $basicinfo['vip'] = $_POST['info']['vip'];
  278. $basicinfo['mobile'] = $_POST['info']['mobile'];
  279. $basicinfo['overduedate'] = strtotime($_POST['info']['overduedate']);
  280. //会员基本信息
  281. $info = $this->_checkuserinfo($basicinfo, 1);
  282. //会员模型信息
  283. $modelinfo = array_diff_key($_POST['info'], $info);
  284. //过滤vip过期时间
  285. unset($modelinfo['overduedate']);
  286. unset($modelinfo['pwdconfirm']);
  287. $userid = $info['userid'];
  288. //如果是超级管理员角色,显示所有用户,否则显示当前站点用户
  289. if($_SESSION['roleid'] == 1) {
  290. $where = array('userid'=>$userid);
  291. } else {
  292. $siteid = get_siteid();
  293. $where = array('userid'=>$userid, 'siteid'=>$siteid);
  294. }
  295. $userinfo = $this->db->get_one($where);
  296. if(empty($userinfo)) {
  297. showmessage(L('user_not_exist').L('or').L('no_permission'), HTTP_REFERER);
  298. }
  299. //删除用户头像
  300. if(!empty($_POST['delavatar'])) {
  301. $this->client->ps_deleteavatar($userinfo['phpssouid']);
  302. }
  303. $status = $this->client->ps_member_edit($info['username'], $info['email'], '', $info['password'], $userinfo['phpssouid'], $userinfo['encrypt']);
  304. if($status >= 0) {
  305. unset($info['userid']);
  306. unset($info['username']);
  307. //如果密码不为空,修改用户密码。
  308. if(isset($info['password']) && !empty($info['password'])) {
  309. $info['password'] = password($info['password'], $userinfo['encrypt']);
  310. } else {
  311. unset($info['password']);
  312. }
  313. $this->db->update($info, array('userid'=>$userid));
  314. require_once CACHE_MODEL_PATH.'member_input.class.php';
  315. require_once CACHE_MODEL_PATH.'member_update.class.php';
  316. $member_input = new member_input($basicinfo['modelid']);
  317. $modelinfo = $member_input->get($modelinfo);
  318. //更新模型表,方法更新了$this->table
  319. $this->db->set_model($info['modelid']);
  320. $userinfo = $this->db->get_one(array('userid'=>$userid));
  321. if($userinfo) {
  322. $this->db->update($modelinfo, array('userid'=>$userid));
  323. } else {
  324. $modelinfo['userid'] = $userid;
  325. $this->db->insert($modelinfo);
  326. }
  327. showmessage(L('operation_success'), '?m=member&c=member&a=manage', '', 'edit');
  328. } else {
  329. showmessage(L('operation_failure'), HTTP_REFERER);
  330. }
  331. } else {
  332. $show_header = $show_scroll = true;
  333. $siteid = get_siteid();
  334. $userid = isset($_GET['userid']) ? $_GET['userid'] : showmessage(L('illegal_parameters'), HTTP_REFERER);
  335. //会员组缓存
  336. $group_cache = getcache('grouplist', 'member');
  337. foreach($group_cache as $_key=>$_value) {
  338. $grouplist[$_key] = $_value['name'];
  339. }
  340. //会员模型缓存
  341. $member_model_cache = getcache('member_model', 'commons');
  342. foreach($member_model_cache as $_key=>$_value) {
  343. if($siteid == $_value['siteid']) {
  344. $modellist[$_key] = $_value['name'];
  345. }
  346. }
  347. //如果是超级管理员角色,显示所有用户,否则显示当前站点用户
  348. if($_SESSION['roleid'] == 1) {
  349. $where = array('userid'=>$userid);
  350. } else {
  351. $where = array('userid'=>$userid, 'siteid'=>$siteid);
  352. }
  353. $memberinfo = $this->db->get_one($where);
  354. if(empty($memberinfo)) {
  355. showmessage(L('user_not_exist').L('or').L('no_permission'), HTTP_REFERER);
  356. }
  357. $memberinfo['avatar'] = get_memberavatar($memberinfo['phpssouid'], '', 90);
  358. $modelid = isset($_GET['modelid']) ? $_GET['modelid'] : $memberinfo['modelid'];
  359. //获取会员模型表单
  360. require CACHE_MODEL_PATH.'member_form.class.php';
  361. $member_form = new member_form($modelid);
  362. $form_overdudate = form::date('info[overduedate]', date('Y-m-d H:i:s',$memberinfo['overduedate']), 1);
  363. $this->db->set_model($modelid);
  364. $membermodelinfo = $this->db->get_one(array('userid'=>$userid));
  365. $forminfos = $forminfos_arr = $member_form->get($membermodelinfo);
  366. //万能字段过滤
  367. foreach($forminfos as $field=>$info) {
  368. if($info['isomnipotent']) {
  369. unset($forminfos[$field]);
  370. } else {
  371. if($info['formtype']=='omnipotent') {
  372. foreach($forminfos_arr as $_fm=>$_fm_value) {
  373. if($_fm_value['isomnipotent']) {
  374. $info['form'] = str_replace('{'.$_fm.'}',$_fm_value['form'], $info['form']);
  375. }
  376. }
  377. $forminfos[$field]['form'] = $info['form'];
  378. }
  379. }
  380. }
  381. $show_dialog = 1;
  382. include $this->admin_tpl('member_edit');
  383. }
  384. }
  385. /**
  386. * delete member
  387. */
  388. function delete() {
  389. $uidarr = isset($_POST['userid']) ? $_POST['userid'] : showmessage(L('illegal_parameters'), HTTP_REFERER);
  390. $uidarr = array_map('intval',$uidarr);
  391. $where = to_sqls($uidarr, '', 'userid');
  392. $phpsso_userinfo = $this->db->listinfo($where);
  393. $phpssouidarr = array();
  394. if(is_array($phpsso_userinfo)) {
  395. foreach($phpsso_userinfo as $v) {
  396. if(!empty($v['phpssouid'])) {
  397. $phpssouidarr[] = $v['phpssouid'];
  398. }
  399. }
  400. }
  401. //查询用户信息
  402. $userinfo_arr = $this->db->select($where, "userid, modelid");
  403. $userinfo = array();
  404. if(is_array($userinfo_arr)) {
  405. foreach($userinfo_arr as $v) {
  406. $userinfo[$v['userid']] = $v['modelid'];
  407. }
  408. }
  409. //delete phpsso member first
  410. if(!empty($phpssouidarr)) {
  411. $status = $this->client->ps_delete_member($phpssouidarr, 1);
  412. if($status > 0) {
  413. if ($this->db->delete($where)) {
  414. //删除用户模型用户资料
  415. foreach($uidarr as $v) {
  416. if(!empty($userinfo[$v])) {
  417. $this->db->set_model($userinfo[$v]);
  418. $this->db->delete(array('userid'=>$v));
  419. }
  420. }
  421. showmessage(L('operation_success'), HTTP_REFERER);
  422. } else {
  423. showmessage(L('operation_failure'), HTTP_REFERER);
  424. }
  425. } else {
  426. showmessage(L('operation_failure'), HTTP_REFERER);
  427. }
  428. } else {
  429. if ($this->db->delete($where)) {
  430. showmessage(L('operation_success'), HTTP_REFERER);
  431. } else {
  432. showmessage(L('operation_failure'), HTTP_REFERER);
  433. }
  434. }
  435. }
  436. /**
  437. * lock member
  438. */
  439. function lock() {
  440. if(isset($_POST['userid'])) {
  441. $uidarr = isset($_POST['userid']) ? $_POST['userid'] : showmessage(L('illegal_parameters'), HTTP_REFERER);
  442. $where = to_sqls($uidarr, '', 'userid');
  443. $this->db->update(array('islock'=>1), $where);
  444. showmessage(L('member_lock').L('operation_success'), HTTP_REFERER);
  445. } else {
  446. showmessage(L('operation_failure'), HTTP_REFERER);
  447. }
  448. }
  449. /**
  450. * unlock member
  451. */
  452. function unlock() {
  453. if(isset($_POST['userid'])) {
  454. $uidarr = isset($_POST['userid']) ? $_POST['userid'] : showmessage(L('illegal_parameters'), HTTP_REFERER);
  455. $where = to_sqls($uidarr, '', 'userid');
  456. $this->db->update(array('islock'=>0), $where);
  457. showmessage(L('member_unlock').L('operation_success'), HTTP_REFERER);
  458. } else {
  459. showmessage(L('operation_failure'), HTTP_REFERER);
  460. }
  461. }
  462. /**
  463. * move member
  464. */
  465. function move() {
  466. if(isset($_POST['dosubmit'])) {
  467. $uidarr = isset($_POST['userid']) ? $_POST['userid'] : showmessage(L('illegal_parameters'), HTTP_REFERER);
  468. $groupid = isset($_POST['groupid']) && !empty($_POST['groupid']) ? $_POST['groupid'] : showmessage(L('illegal_parameters'), HTTP_REFERER);
  469. $where = to_sqls($uidarr, '', 'userid');
  470. $this->db->update(array('groupid'=>$groupid), $where);
  471. showmessage(L('member_move').L('operation_success'), HTTP_REFERER, '', 'move');
  472. } else {
  473. $show_header = $show_scroll = true;
  474. $grouplist = getcache('grouplist');
  475. foreach($grouplist as $k=>$v) {
  476. $grouplist[$k] = $v['name'];
  477. }
  478. $ids = isset($_GET['ids']) ? explode(',', $_GET['ids']): showmessage(L('illegal_parameters'), HTTP_REFERER);
  479. array_pop($ids);
  480. if(!empty($ids)) {
  481. $where = to_sqls($ids, '', 'userid');
  482. $userarr = $this->db->listinfo($where);
  483. } else {
  484. showmessage(L('illegal_parameters'), HTTP_REFERER, '', 'move');
  485. }
  486. include $this->admin_tpl('member_move');
  487. }
  488. }
  489. function memberinfo() {
  490. $show_header = false;
  491. $userid = !empty($_GET['userid']) ? intval($_GET['userid']) : '';
  492. $username = !empty($_GET['username']) ? trim($_GET['username']) : '';
  493. if(!empty($userid)) {
  494. $memberinfo = $this->db->get_one(array('userid'=>$userid));
  495. } elseif(!empty($username)) {
  496. $memberinfo = $this->db->get_one(array('username'=>$username));
  497. } else {
  498. showmessage(L('illegal_parameters'), HTTP_REFERER);
  499. }
  500. if(empty($memberinfo)) {
  501. showmessage(L('user').L('not_exists'), HTTP_REFERER);
  502. }
  503. $memberinfo['avatar'] = get_memberavatar($memberinfo['phpssouid'], '', 90);
  504. $grouplist = getcache('grouplist');
  505. //会员模型缓存
  506. $modellist = getcache('member_model', 'commons');
  507. $modelid = !empty($_GET['modelid']) ? intval($_GET['modelid']) : $memberinfo['modelid'];
  508. //站群缓存
  509. $sitelist =getcache('sitelist', 'commons');
  510. $this->db->set_model($modelid);
  511. $member_modelinfo = $this->db->get_one(array('userid'=>$userid));
  512. //模型字段名称
  513. $model_fieldinfo = getcache('model_field_'.$modelid, 'model');
  514. //图片字段显示图片
  515. foreach($model_fieldinfo as $k=>$v) {
  516. if($v['formtype'] == 'image') {
  517. $member_modelinfo[$k] = "<a href='.$member_modelinfo[$k].' target='_blank'><img src='.$member_modelinfo[$k].' height='40' widht='40' onerror=\"this.src='$phpsso_api_url/statics/images/member/nophoto.gif'\"></a>";
  518. } elseif($v['formtype'] == 'images') {
  519. $tmp = string2array($member_modelinfo[$k]);
  520. $member_modelinfo[$k] = '';
  521. if(is_array($tmp)) {
  522. foreach ($tmp as $tv) {
  523. $member_modelinfo[$k] .= " <a href='$tv[url]' target='_blank'><img src='$tv[url]' height='40' widht='40' onerror=\"this.src='$phpsso_api_url/statics/images/member/nophoto.gif'\"></a>";
  524. }
  525. unset($tmp);
  526. }
  527. } elseif($v['formtype'] == 'box') { //box字段,获取字段名称和值的数组
  528. $tmp = explode("\n",$v['options']);
  529. if(is_array($tmp)) {
  530. foreach($tmp as $boxv) {
  531. $box_tmp_arr = explode('|', trim($boxv));
  532. if(is_array($box_tmp_arr) && isset($box_tmp_arr[1]) && isset($box_tmp_arr[0])) {
  533. $box_tmp[$box_tmp_arr[1]] = $box_tmp_arr[0];
  534. $tmp_key = intval($member_modelinfo[$k]);
  535. }
  536. }
  537. }
  538. if(isset($box_tmp[$tmp_key])) {
  539. $member_modelinfo[$k] = $box_tmp[$tmp_key];
  540. } else {
  541. $member_modelinfo[$k] = $member_modelinfo_arr[$k];
  542. }
  543. unset($tmp, $tmp_key, $box_tmp, $box_tmp_arr);
  544. } elseif($v['formtype'] == 'linkage') { //如果为联动菜单
  545. $tmp = string2array($v['setting']);
  546. $tmpid = $tmp['linageid'];
  547. $linkagelist = getcache($tmpid, 'linkage');
  548. $fullname = $this->_get_linkage_fullname($member_modelinfo[$k], $linkagelist);
  549. $member_modelinfo[$v['name']] = substr($fullname, 0, -1);
  550. unset($tmp, $tmpid, $linkagelist, $fullname);
  551. } else {
  552. $member_modelinfo[$k] = $member_modelinfo[$k];
  553. }
  554. }
  555. $member_fieldinfo = array();
  556. //交换数组key值
  557. foreach($model_fieldinfo as $v) {
  558. if(!empty($member_modelinfo) && array_key_exists($v['field'], $member_modelinfo)) {
  559. $tmp = $member_modelinfo[$v['field']];
  560. unset($member_modelinfo[$v['field']]);
  561. $member_fieldinfo[$v['name']] = $tmp;
  562. unset($tmp);
  563. } else {
  564. $member_fieldinfo[$v['name']] = '';
  565. }
  566. }
  567. include $this->admin_tpl('member_moreinfo');
  568. }
  569. /*
  570. * 通过linkageid获取名字路径
  571. */
  572. private function _get_linkage_fullname($linkageid, $linkagelist) {
  573. $fullname = '';
  574. if($linkagelist['data'][$linkageid]['parentid'] != 0) {
  575. $fullname = $this->_get_linkage_fullname($linkagelist['data'][$linkageid]['parentid'], $linkagelist);
  576. }
  577. //所在地区名称
  578. $return = $fullname.$linkagelist['data'][$linkageid]['name'].'>';
  579. return $return;
  580. }
  581. private function _checkuserinfo($data, $is_edit=0) {
  582. if(!is_array($data)){
  583. showmessage(L('need_more_param'));return false;
  584. } elseif (!is_username($data['username']) && !$is_edit){
  585. showmessage(L('username_format_incorrect'));return false;
  586. } elseif (!isset($data['userid']) && $is_edit) {
  587. showmessage(L('username_format_incorrect'));return false;
  588. } elseif (empty($data['email']) || !is_email($data['email'])){
  589. showmessage(L('email_format_incorrect'));return false;
  590. }
  591. return $data;
  592. }
  593. private function _checkpasswd($password){
  594. if (!is_password($password)){
  595. return false;
  596. }
  597. return true;
  598. }
  599. private function _checkname($username) {
  600. $username = trim($username);
  601. if ($this->db->get_one(array('username'=>$username))){
  602. return false;
  603. }
  604. return true;
  605. }
  606. /**
  607. * 初始化phpsso
  608. * about phpsso, include client and client configure
  609. * @return string phpsso_api_url phpsso地址
  610. */
  611. private function _init_phpsso() {
  612. pc_base::load_app_class('client', '', 0);
  613. define('APPID', pc_base::load_config('system', 'phpsso_appid'));
  614. $phpsso_api_url = pc_base::load_config('system', 'phpsso_api_url');
  615. $phpsso_auth_key = pc_base::load_config('system', 'phpsso_auth_key');
  616. $this->client = new client($phpsso_api_url, $phpsso_auth_key);
  617. return $phpsso_api_url;
  618. }
  619. /**
  620. * 检查用户名
  621. * @param string $username 用户名
  622. * @return $status {-4:用户名禁止注册;-1:用户名已经存在 ;1:成功}
  623. */
  624. public function public_checkname_ajax() {
  625. $username = isset($_GET['username']) && trim($_GET['username']) ? trim($_GET['username']) : exit(0);
  626. if(CHARSET != 'utf-8') {
  627. $username = iconv('utf-8', CHARSET, $username);
  628. $username = addslashes($username);
  629. }
  630. $status = $this->client->ps_checkname($username);
  631. if($status == -4 || $status == -1) {
  632. exit('0');
  633. } else {
  634. exit('1');
  635. }
  636. }
  637. /**
  638. * 检查邮箱
  639. * @param string $email
  640. * @return $status {-1:email已经存在 ;-5:邮箱禁止注册;1:成功}
  641. */
  642. public function public_checkemail_ajax() {
  643. $email = isset($_GET['email']) && trim($_GET['email']) ? trim($_GET['email']) : exit(0);
  644. $status = $this->client->ps_checkemail($email);
  645. if($status == -5) { //禁止注册
  646. exit('0');
  647. } elseif($status == -1) { //用户名已存在,但是修改用户的时候需要判断邮箱是否是当前用户的
  648. if(isset($_GET['phpssouid'])) { //修改用户传入phpssouid
  649. $status = $this->client->ps_get_member_info($email, 3);
  650. if($status) {
  651. $status = unserialize($status); //接口返回序列化,进行判断
  652. if (isset($status['uid']) && $status['uid'] == intval($_GET['phpssouid'])) {
  653. exit('1');
  654. } else {
  655. exit('0');
  656. }
  657. } else {
  658. exit('0');
  659. }
  660. } else {
  661. exit('0');
  662. }
  663. } else {
  664. exit('1');
  665. }
  666. }
  667. }
  668. ?>