PageRenderTime 28ms CodeModel.GetById 19ms RepoModel.GetById 1ms app.codeStats 0ms

/PigCms/Lib/Action/Home/IndexAction.class.php

https://gitlab.com/colin.luo/shbs
PHP | 153 lines | 130 code | 20 blank | 3 comment | 12 complexity | c5c29ab13933139e5d5180f2f4391bf5 MD5 | raw file
  1. <?php
  2. class IndexAction extends BaseAction
  3. {
  4. public $includePath;
  5. private $hometheme;
  6. protected function _initialize()
  7. {
  8. parent::_initialize();
  9. session('uid',null);
  10. session('gid',null);
  11. session('uname',null);
  12. session('currDomainId',null);
  13. session("currDomainType",null);
  14. session("currDomainName",null);
  15. session('is_open_domain',null);
  16. session('domainList',null);
  17. session('token',null);
  18. unset($_SESSION[token]);
  19. unset($_SESSION[uid]);
  20. unset($_SESSION[uname]);
  21. session_regenerate_id(true);
  22. if ($_GET['company']){
  23. $this->hometheme = $_GET['company'];
  24. }
  25. else if(session('companyCode')){
  26. $this->hometheme = session('companyCode');
  27. }
  28. else{
  29. $this->hometheme = C('DEFAULT_THEME');
  30. }
  31. session("hometheme", $this->hometheme);
  32. $this->includePath = './tpl/Home/' . $this->hometheme . '/';
  33. $themeHead = $this->hometheme;
  34. if(!is_dir($_SERVER['DOCUMENT_ROOT'].$this->includePath)){
  35. $this->includePath = './tpl/Home/default/';
  36. $themeHead = "default";
  37. }
  38. $this->assign('themeHead', $themeHead);
  39. $this->assign('includeHeaderPath', $this->includePath . 'Public_header.html');
  40. $this->assign('includeFooterPath', $this->includePath . 'Public_footer.html');
  41. }
  42. public function index() {
  43. if($_GET['company']!=''){
  44. $themeDir = './tpl/Home/' . $this->hometheme . '/';
  45. if(!is_dir($_SERVER['DOCUMENT_ROOT'].$themeDir)){
  46. $this->display('default' . ':Index:' . ACTION_NAME);
  47. }
  48. else{
  49. $this->display($this->hometheme . ':Index:' . ACTION_NAME);
  50. }
  51. }
  52. else {
  53. $this->display('./tpl/Home/weportal/index.htm');
  54. }
  55. }
  56. // 用户登出
  57. public function logout()
  58. {
  59. $hometheme = session('hometheme');
  60. session('uid',null);
  61. session('gid',null);
  62. session('uname',null);
  63. session('companyCode',null);
  64. session_destroy();
  65. unset($_SESSION[uid]);
  66. unset($_SESSION[uname]);
  67. unset($_SESSION);
  68. session('hometheme',$hometheme);
  69. $this->error('已经登出!',U('Home/Index/index',array('company'=>$hometheme)));
  70. }
  71. public function verify()
  72. {
  73. Image::buildImageVerify(4, 1, 'png', 0, 28, 'verify');
  74. }
  75. public function verifyLogin()
  76. {
  77. Image::buildImageVerify(4, 1, 'png', 0, 28, 'loginverify');
  78. }
  79. public function resetpwd()
  80. {
  81. $uid = $this->_get('uid', 'intval');
  82. $code = $this->_get('code', 'trim');
  83. $rtime = $this->_get('resettime', 'intval');
  84. $info = M('Users')->find($uid);//|| $rtime < time()
  85. // print_r($info);
  86. //echo md5($info['id'] . $info['password'] . $info['email']);exit;
  87. if (md5($info['id'] . $info['password'] . $info['email']) !== $code ) {
  88. $this->error('非法操作', U('Index/index'));
  89. }
  90. $this->assign('uid', $uid);
  91. $this->display($this->home_theme . ':Index:' . ACTION_NAME);
  92. }
  93. public function help()
  94. {
  95. $this->display($this->home_theme . ':Index:' . ACTION_NAME);
  96. }
  97. public function think_encrypt($data, $key = '', $expire = 0)
  98. {
  99. $key = md5(empty($key) ? C('DATA_AUTH_KEY') : $key);
  100. $data = base64_encode($data);
  101. $x = 0;
  102. $len = strlen($data);
  103. $l = strlen($key);
  104. $char = '';
  105. for ($i = 0; $i < $len; $i++) {
  106. if ($x == $l) {
  107. $x = 0;
  108. }
  109. $char .= substr($key, $x, 1);
  110. $x++;
  111. }
  112. $str = sprintf('%010d', $expire ? $expire + time() : 0);
  113. for ($i = 0; $i < $len; $i++) {
  114. $str .= chr(ord(substr($data, $i, 1)) + ord(substr($char, $i, 1)) % 256);
  115. }
  116. return str_replace('=', '', base64_encode($str));
  117. }
  118. public function text()
  119. {
  120. $domain = $_GET['domain'];
  121. $domains = explode('.', $domain);
  122. echo '<a href="http://' . $domain . '/index.php?g=Home&m=T&a=test&n=' . $this->think_encrypt($domains[1] . '.' . $domains[2]) . '" target="_blank">http://' . $domain . '/index.php?g=Home&m=T&a=test&n=' . $this->think_encrypt($domains[1] . '.' . $domains[2]) . '</a><br>';
  123. echo '<a href="http://' . $domain . '/index.php?g=User&m=Create&a=index" target="_blank">http://' . $domain . '/index.php?g=User&m=Create&a=index</a><br>';
  124. }
  125. public function maintenance(){
  126. $maintInfo = C('OPEN_PLATFORM_MAINTENANCE');
  127. $this->assign('title', $maintInfo['title']);
  128. $this->assign('content', $maintInfo['content']);
  129. $this->assign('footer', $maintInfo['footer']);
  130. $this->display();
  131. }
  132. }
  133. ?>