$senderr = intval($_GET['senderr']); $intervaltime = intval($_GET['intervaltime']); $tempdir = QISHI_ROOT_PATH . "temp/sendsms.txt"; $content = file_get_contents($tempdir); $idarr = unserialize($content); $totalid = count($idarr); if (empty($idarr)) { $link[0]['text'] = "返回短信列队"; $link[0]['href'] = '?act=list'; adminmsg("任务执行完毕!", 2, $link); } else { $s_id = array_shift($idarr); @file_put_contents($tempdir, serialize($idarr)); $sms = $db->getone("select * from " . table('smsqueue') . " where s_id = '" . intval($s_id) . "' LIMIT 1"); // $mailconfig=get_cache('mailconfig'); if (free_send_sms($sms['s_mobile'], $sms['s_body']) != 'success') { $db->query("update " . table('smsqueue') . " SET s_type='2' WHERE s_id = '" . intval($s_id) . "' LIMIT 1"); if ($senderr == "2") { $link[0]['text'] = "返回短信列队"; $link[0]['href'] = '?act=list'; adminmsg('短信发送发生错误!' . $senderr, 0, $link); } else { $link[0]['text'] = "发送下一条"; $link[0]['href'] = "?act=send&senderr={${$senderr}}&intervaltime={$intervaltime}"; adminmsg("发生错误,准备发送下一条,剩余任务总数:" . ($totalid - 1), 0, $link, true, $intervaltime); } } else { $db->query("update " . table('smsqueue') . " SET s_type='1',s_sendtime='" . time() . "' WHERE s_id = '" . intval($s_id) . "' LIMIT 1"); $link[0]['text'] = "发送下一条"; $link[0]['href'] = "?act=send&senderr={${$senderr}}&intervaltime={$intervaltime}"; adminmsg("发送成功,准备发送下一条,剩余任务总数:" . ($totalid - 1), 2, $link, true, $intervaltime);
//发送失败 inserttable(table('smsqueue'), $setsqlarr); unset($setsqlarr); $link[0]['text'] = "返回上一页"; $link[0]['href'] = "{$url}"; adminmsg("发送失败,错误未知!", 0, $link); } } } elseif ($act == 'again_send') { $id = intval($_GET['id']); if (empty($id)) { adminmsg("请选择要发送的项目!", 1); } $result = $db->getone("SELECT * FROM " . table('smsqueue') . " WHERE s_id = {$id} limit 1"); $wheresql = " s_id={$id} "; $r = free_send_sms($result['s_mobile'], $result['s_body']); if ($r == 'success') { $setsqlarr['s_sendtime'] = time(); $setsqlarr['s_type'] = 1; //发送成功 !updatetable(table('smsqueue'), $setsqlarr, $wheresql); adminmsg('发送成功', 2); } else { $setsqlarr['s_sendtime'] = time(); $setsqlarr['s_type'] = 2; !updatetable(table('smsqueue'), $setsqlarr, $wheresql); adminmsg('发送失败', 0); } } elseif ($act == 'del') { $id = $_POST['id']; if (empty($id)) {