switch.mod.php 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  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_user_common_module($module_name) {
  12. return table('users_lastuse')->getByType('module_common_' . $module_name);
  13. }
  14. function switch_getall_lastuse_by_module($module_name) {
  15. return table('users_lastuse')->searchWithModulename($module_name)->getall();
  16. }
  17. function switch_save_uniacid($uniacid) {
  18. isetcookie('__uniacid', $uniacid, 7 * 86400);
  19. return true;
  20. }
  21. function switch_save_account_display($uniacid) {
  22. switch_save_uniacid($uniacid);
  23. return switch_save($uniacid, '', 'account_display');
  24. }
  25. function switch_save_module_display($uniacid, $module_name) {
  26. load()->model('visit');
  27. return switch_save($uniacid, $module_name, 'module_display');
  28. }
  29. function switch_save_module($uniacid, $module_name) {
  30. return switch_save($uniacid, $module_name, 'module_display_' . $module_name);
  31. }
  32. function switch_save_user_common_module($uniacid, $module_name) {
  33. return switch_save($uniacid, $module_name, 'module_common_' . $module_name);
  34. }
  35. function switch_save($uniacid, $module_name, $type) {
  36. global $_W;
  37. if (empty($uniacid) || empty($type)) {
  38. return false;
  39. }
  40. $users_lastuse_table = table('users_lastuse');
  41. $if_exists = $users_lastuse_table->getByType($type);
  42. $fill_data = array('uniacid' => $uniacid, 'modulename' => $module_name);
  43. if ($if_exists) {
  44. $users_lastuse_table->where('id', $if_exists['id'])->fill($fill_data)->save();
  45. } else {
  46. $fill_data['uid'] = $_W['uid'];
  47. $fill_data['type'] = $type;
  48. $users_lastuse_table->fill($fill_data)->save();
  49. }
  50. return true;
  51. }