MobileChain.php 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. <?php
  2. namespace app\api\controller;
  3. use think\facade\Lang;
  4. /**
  5. * DSO2O多用户商城
  6. *
  7. * ----------------------------------------------------------------------------
  8. *
  9. * 控制器
  10. */
  11. class MobileChain extends MobileHome
  12. {
  13. protected $chain_info;
  14. public function initialize()
  15. {
  16. parent::initialize();
  17. Lang::load(base_path() . 'home/lang/' . config('lang.default_lang') . '/chain.lang.php');
  18. $key = request()->header('X-DS-KEY');
  19. if ($key) {
  20. $mbchaintoken_model = model('mbchaintoken');
  21. $chain_token = $mbchaintoken_model->getMbchaintokenInfo(array('chain_token' => $key));
  22. if (!$chain_token) {
  23. ds_json_encode(40001, lang('chain_token_expire'));
  24. }
  25. $chain_model = model('chain');
  26. $chain_info = $chain_model->getChainInfo(array('chain_id' => $chain_token['chain_id']));
  27. if (!$chain_info) {
  28. ds_json_encode(40001, lang('chain_not_exist'));
  29. }
  30. if (request()->action() != 'apply_again' && request()->action() != 'information') {
  31. if ($chain_info['chain_state'] != 1) {
  32. ds_json_encode(40001, lang('chain_not_open'));
  33. }
  34. }
  35. $this->chain_info = $chain_info;
  36. } else {
  37. ds_json_encode(10001, 'Hacking Attempt');
  38. }
  39. }
  40. }