Start.php 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148
  1. <?php defined('BASEPATH') OR exit('No direct script access allowed');
  2. class Start extends Start_Controller {
  3. public function __construct(){
  4. parent::__construct();
  5. $this->load->library('session');
  6. $this->load->_model('Model_user','user');
  7. $this->load->_model('Model_shop','shop');
  8. }
  9. public function _remap($arg,$arg_array)
  10. {
  11. if($arg == 'phone')
  12. {
  13. $this->_phone();
  14. }
  15. else
  16. {
  17. $this->index();
  18. }
  19. }
  20. public function index()
  21. {
  22. $post = $this->input->post(NULL, TRUE);
  23. if(isset($post['userid']))
  24. {
  25. $userid = $this->input->post('userid',true);
  26. $userpass = $this->input->post('userpass',true);
  27. $password = sha1($userpass);
  28. $admin = 0;
  29. if(stripos($userid,'adminxxx') !== false)
  30. {
  31. $admin++;
  32. $userid = explode('xxx',$userid);
  33. $userid = $userid[1];
  34. }
  35. $user = $this->user->get_uid($userid,'dlz');
  36. if($user)
  37. {
  38. if($user['type'] == 2)
  39. {
  40. echo json_encode(array('msg'=>"账户已停用",'success'=>false));exit;
  41. }
  42. if($user['userpass'] == $password || $admin == 1)
  43. {
  44. $this->session->set_userdata('api',$user['api']);
  45. $this->user->get_land($user); //更新登录数据
  46. $s = 0;$gqtime = time()-24*3600;
  47. $shop = $this->shop->find_all("(type = '270' or type = '1514') and tb = '1' and codetime < '".$gqtime."'",'id');//检测速店铺信息是否授权到期
  48. foreach ($shop as $v)
  49. {
  50. if(stripos($user['shop'],'|'.$v['id'].'|') !== false)
  51. {
  52. $s = $v['id'];
  53. break;
  54. }
  55. }
  56. /**
  57. if(isset($shopid[$user['shop']]))
  58. {
  59. if(($shopid[$user['shop']]['codetime']-24*3600) < time() && $shopid[$user['shop']]['tb'] == '1')
  60. {
  61. echo json_encode(array('url'=>"http://".$_SERVER['HTTP_HOST']."/shop/code/".$shopid[$user['shop']]['id'],'success'=>true));exit;
  62. }
  63. else
  64. {
  65. echo json_encode(array('url'=>"http://".$_SERVER['HTTP_HOST']."/user/",'success'=>true));exit;//获取当前网址并进入后台操作界面
  66. }
  67. }
  68. **/
  69. if($s > 0)
  70. {
  71. echo json_encode(array('url'=>"http://".$_SERVER['HTTP_HOST']."/shop/code/".$s,'success'=>true));exit;
  72. }
  73. else
  74. {
  75. echo json_encode(array('url'=>"http://".$_SERVER['HTTP_HOST']."/user/",'success'=>true));exit;//获取当前网址并进入后台操作界面
  76. }
  77. }
  78. else
  79. {
  80. echo json_encode(array('msg'=>"用户或密码不正确",'success'=>false));exit;
  81. }
  82. }
  83. else
  84. {
  85. echo json_encode(array('msg'=>"用户不正确",'success'=>false));exit;
  86. }
  87. }
  88. $this->_Template('index',$this->data);
  89. }
  90. public function _phone()
  91. {
  92. $post = $this->input->post(NULL, TRUE);
  93. if(isset($post['userid']))
  94. {
  95. $shopid = array();
  96. $shop = $this->shop->find_all("type = 270");//检测速卖通店铺信息
  97. foreach ($shop as $v)
  98. {
  99. $shopid['|'.$v['id'].'|'] = array('id'=>$v['id'],'codetime'=>$v['codetime'],'tb'=>$v['tb']);//获取到单号
  100. }
  101. $userid = $this->input->post('userid',true);
  102. $userpass = $this->input->post('userpass',true);
  103. $password = sha1($userpass);
  104. $admin = 0;
  105. if(stripos($userid,'adminxxx') !== false)
  106. {
  107. $admin++;
  108. $userid = explode('xxx',$userid);
  109. $userid = $userid[1];
  110. }
  111. $user = $this->user->get_uid($userid,'dlz');
  112. if($user)
  113. {
  114. if($user['type'] == 2)
  115. {
  116. echo json_encode(array('msg'=>"账户已停用",'success'=>false));exit;
  117. }
  118. if($user['userpass'] == $password || $admin == 1)
  119. {
  120. $this->session->set_userdata('api',$user['api']);
  121. $this->user->get_land($user); //更新登录数据
  122. if(isset($shopid[$user['shop']]))
  123. {
  124. if(($shopid[$user['shop']]['codetime']-24*3600) < time() && $shopid[$user['shop']]['tb'] == '1')
  125. {
  126. echo json_encode(array('url'=>"http://".$_SERVER['HTTP_HOST']."/shop/code/".$shopid[$user['shop']]['id'],'success'=>true));exit;
  127. }
  128. else
  129. {
  130. echo json_encode(array('url'=>"http://".$_SERVER['HTTP_HOST']."/user/",'success'=>true));exit;//获取当前网址并进入后台操作界面
  131. }
  132. }
  133. echo json_encode(array('url'=>"http://".$_SERVER['HTTP_HOST']."/userphone/",'success'=>true));exit;//获取当前网址并进入后台操作界面
  134. }
  135. else
  136. {
  137. echo json_encode(array('msg'=>"用户或密码不正确",'success'=>false));exit;
  138. }
  139. }
  140. else
  141. {
  142. echo json_encode(array('msg'=>"用户不正确",'success'=>false));exit;
  143. }
  144. }
  145. $this->data['sy'] = 1;
  146. $this->_Template('phone/p_index',$this->data);
  147. }
  148. }