Allowip.php 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. <?php
  2. namespace App\Models;
  3. use Illuminate\Database\Eloquent\Model;
  4. class Allowip extends BaseModel
  5. {
  6. protected $table='dc_allowip';
  7. function getCode(){
  8. $data=$this->orderby('time','desc')->get();
  9. if(!$data){
  10. return -6010000122;
  11. }
  12. return $data->toArray();
  13. }
  14. function getRole($id){
  15. $data=$this->where('id',$id)->first();
  16. if(!$data){
  17. return -7050001204;
  18. }
  19. return $data->toArray();
  20. }
  21. protected function checkIp(){
  22. $ip=GETIP();
  23. if(\App\Models\Setinfo::getIPlimit()<0){
  24. return 1;
  25. }
  26. if(S('IPLIST')<0)
  27. {
  28. $ip_list=$this->getCode();
  29. if($ip_list<0){
  30. return 1;
  31. }
  32. $ips=array();
  33. if(is_array($ip_list) && count($ip_list)>0){
  34. foreach($ip_list as $k=>$v){
  35. $ips[]=trim($v['ip']);
  36. }
  37. }
  38. S('IPLIST',$ips);
  39. }
  40. if(!is_array(S('IPLIST'))){
  41. return 1;
  42. }
  43. if(in_array($ip,S('IPLIST'))){
  44. return 1;
  45. }
  46. return -33333;
  47. }
  48. }