set_time_limit(0);//设置永不超时 ignore_user_abort(); //设置客户端断开,继续处理 //总数 $allusercount= $this->gamedb_model->query_onerow(); $allcount = $allusercount['count']; $page = 1;//当前页 $pagesize=1000;//分页大小 $failt = 0;// 失败次数 $allpage =ceil($allcount/$pagesize);//分页总大小 while($page <= $allpage){ $erroruserl = ''; $userArr = $this->gamedb_model->query_lists("select limit ".($page-1)*$pagesize.",$pagesize"); if($userArr){ foreach ($userArr as $key => $name) { $senderrorusers .=$name['roleName'].','; $sendUserList[$name['roleID']] = $name['roleName']; } } //print_r($sendUserList); //print_r("<br />"); $sendArray['userlist']= json_encode(array_unique($sendUserList)); $jsonresult = $this->_sendreward($sendArray,$this->mailgifturl); $resultobj = json_decode($jsonresult); if($resultobj && $resultobj->result=='succ'){ $data['errordisplay']="奖品发送成功"; }else{ $erroruserl = $senderrorusers;//存取发送失败的用户 $failt++; } //日志 $this->comm_model->insert_query( 'admin_action_log',array( 'username'=>$this->session->userdata('username'), 'type'=>1,//发送邮件奖励 'content'=>'userlist='.$sendArray['userlist'].'|message='.$sendArray['message'].'|reward='.$sendArray['reward'].'|item='.$sendArray['item'].'|ger='.$sendArray['ger'], 'ip'=>$_SERVER['REMOTE_ADDR'], 'online'=>time(), 'status'=>$data['errordisplay'].'=='.$jsonresult, 'sendfailt'=>$erroruserl ) ); // print_r($sendArray); $senderrorusers=''; $page++; unset($sendArray['userlist']); unset($sendUserList); unset($userArr); }