switch.mod.php 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. <?php
  2. /**
  3. * [WeEngine System] Copyright (c) 2014 WE7.CC
  4. * WeEngine is NOT a free software, it under the license terms, visited http://www.we7.cc/ for more details.
  5. */
  6. defined('IN_IA') or exit('Access Denied');
  7. function switch_get_account_display() {
  8. $last_use_account = table('users_lastuse')->getByType('account_display');
  9. return !empty($last_use_account) ? $last_use_account['uniacid'] : 0;
  10. }
  11. function switch_get_module_display() {
  12. return table('users_lastuse')->getByType('module_display');
  13. }
  14. function switch_get_user_common_module($module_name) {
  15. return table('users_lastuse')->getByType('module_common_' . $module_name);
  16. }
  17. function switch_getall_lastuse_by_module($module_name) {
  18. return table('users_lastuse')->searchWithModulename($module_name)->getall();
  19. }
  20. function switch_save_uniacid($uniacid) {
  21. global $_W;
  22. load()->model('visit');
  23. visit_system_update(array('uniacid' => $uniacid, 'uid' => $_W['uid']));
  24. isetcookie('__uniacid', $uniacid, 7 * 86400);
  25. return true;
  26. }
  27. function switch_save_account_display($uniacid) {
  28. switch_save_uniacid($uniacid);
  29. return switch_save($uniacid, '', 'account_display');
  30. }
  31. function switch_save_module_display($uniacid, $module_name) {
  32. global $_W;
  33. load()->model('visit');
  34. visit_system_update(array('modulename' => $module_name, 'uid' => $_W['uid'], 'uniacid' => $uniacid));
  35. return switch_save($uniacid, $module_name, 'module_display');
  36. }
  37. function switch_save_module($uniacid, $module_name) {
  38. return switch_save($uniacid, $module_name, 'module_display_' . $module_name);
  39. }
  40. function switch_save_user_common_module($uniacid, $module_name) {
  41. return switch_save($uniacid, $module_name, 'module_common_' . $module_name);
  42. }
  43. function switch_save($uniacid, $module_name, $type) {
  44. global $_W;
  45. if (empty($uniacid) || empty($type)) {
  46. return false;
  47. }
  48. $users_lastuse_table = table('users_lastuse');
  49. $if_exists = $users_lastuse_table->getByType($type);
  50. $fill_data = array('uniacid' => $uniacid, 'modulename' => $module_name);
  51. if ($if_exists) {
  52. $users_lastuse_table->where('id', $if_exists['id'])->fill($fill_data)->save();
  53. } else {
  54. $fill_data['uid'] = $_W['uid'];
  55. $fill_data['type'] = $type;
  56. $users_lastuse_table->fill($fill_data)->save();
  57. }
  58. return true;
  59. }