webapp.mod.php 1.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. <?php
  2. defined('IN_IA') or exit('Access Denied');
  3. function webapp_switch($uniacid, $redirect = '') {
  4. global $_W;
  5. webapp_save_switch($uniacid);
  6. isetcookie('__uid', $_W['uid'], 7 * 86400);
  7. if (!empty($redirect)) {
  8. header('Location: ' . $redirect);
  9. exit;
  10. }
  11. return true;
  12. }
  13. function webapp_save_switch($uniacid) {
  14. global $_W, $_GPC;
  15. if (empty($_GPC['__switch'])) {
  16. $_GPC['__switch'] = random(5);
  17. }
  18. $cache_key = cache_system_key(CACHE_KEY_ACCOUNT_SWITCH, $_GPC['__switch']);
  19. $cache_lastaccount = cache_load($cache_key);
  20. if (empty($cache_lastaccount)) {
  21. $cache_lastaccount = array(
  22. 'webapp' => $uniacid,
  23. );
  24. } else {
  25. $cache_lastaccount['webapp'] = $uniacid;
  26. }
  27. cache_write($cache_key, $cache_lastaccount);
  28. isetcookie('__uniacid', $uniacid, 7 * 86400);
  29. isetcookie('__switch', $_GPC['__switch'], 7 * 86400);
  30. return true;
  31. }
  32. function webapp_can_create($uid) {
  33. if(user_is_founder($uid)) {
  34. return true;
  35. }
  36. $data = permission_user_account_num($uid);
  37. return isset($data['webapp_limit']) && $data['webapp_limit'] > 0;
  38. }