/Admin/Lib/Action/BaseAction.class.php

http://nblog-thinkphp.googlecode.com/ · PHP · 99 lines · 52 code · 19 blank · 28 comment · 8 complexity · dd4130612d78b02f9cdf72c6006792c3 MD5 · raw file

  1. <?php
  2. // +----------------------------------------------------------------------
  3. // | ??Action?????
  4. // +----------------------------------------------------------------------
  5. // | @link ( http://www.yurnero.net )
  6. // +----------------------------------------------------------------------
  7. // | @copyright
  8. // +----------------------------------------------------------------------
  9. // | @licensed ( http://www.apache.org/licenses/LICENSE-2.0 )
  10. // +----------------------------------------------------------------------
  11. // | @author Haijun Wu <nicholasinlove@126.com>
  12. // +----------------------------------------------------------------------
  13. // | $Id: BaseAction.class.php 115 2011-05-11 09:06:41Z nicholasinlove1986@gmail.com $
  14. // +----------------------------------------------------------------------
  15. class BaseAction extends Action {
  16. //?????
  17. public function _initialize() {
  18. if (!$_SESSION[C('USER_AUTH_KEY')]) {
  19. //???????
  20. redirect(PHP_FILE.C('USER_AUTH_GATEWAY'));
  21. }
  22. /* ???????? */
  23. $this->checkOnline();
  24. /* ?????????????????*/
  25. all_stripslashes();
  26. /* ?????? */
  27. global $_CFG;
  28. $_CFG = get_config();
  29. /* ???? */
  30. smilies_init();
  31. /* ???????? */
  32. import("@.ORG.StaticCaches");
  33. $cache = new StaticCaches();
  34. $cache->cacheInit();
  35. //create_static_caches();
  36. header('Expires: Fri, 14 Mar 1980 20:53:00 GMT');
  37. header('Last-Modified: ' . gmdate('D, d M Y H:i:s') . ' GMT');
  38. header('Cache-Control: no-cache, must-revalidate');
  39. header('Pragma: no-cache');
  40. /* ??????gzip?? */
  41. if (gzip_enabled()) {
  42. ob_start('ob_gzhandler');
  43. } else {
  44. ob_start();
  45. }
  46. /* ???????? */
  47. clearstatcache();
  48. /* ???? */
  49. require_cache (ROOT_PATH.'Public/Plugins/fml/fml.php');
  50. }
  51. //????????,??1800s
  52. protected function checkOnline($online='1800') {
  53. $nowtime = gmtime();
  54. if ($nowtime - $_SESSION['user_logintime'] > $online) {
  55. $this->assign('jumpUrl',__APP__.'/Admin/login/');
  56. $this->success(L('login_online'));
  57. } else {
  58. $_SESSION['user_logintime'] = gmtime();
  59. }
  60. }
  61. //????????
  62. protected function checkUser() {
  63. if (!isset($_SESSION[C('USER_AUTH_KEY')])) {
  64. $this->assign('jumpUrl',__APP__.'/Admin/login/');
  65. $this->error(L('login_first'));
  66. }
  67. }
  68. //????
  69. protected function checkLimits() {
  70. if ($_SESSION['user_level'] != 0) {
  71. $this->error(L('no_limits'));
  72. }
  73. }
  74. //???
  75. public function _empty() {
  76. $this->assign('jumpUrl',__APP__);
  77. $this->error(L('illegal'));
  78. }
  79. }
  80. ?>