*/ include_once dirname(__FILE__) . DIRECTORY_SEPARATOR . 'init.php'; // test curl $curl = curl_init(); curl_close($curl); // 设置执行超时时间(秒) set_time_limit(500); // 更新脚本最后执行时间 $user = new User(); $user->update(array('last_exec' => time()), array()); $watch = new Stopwatch(); $watch->Start(); $task = new Task(); $tasks = $task->GetExecTasks(); $taskIds = array_keys($tasks); $task->UpdateStatus(Task::EXECING, $taskIds); $thirdAccount = new ThirdAccount(); foreach ($tasks as $id => $item) { $type_arr = explode('|', $item['type']); if (str_contains($item['msg'], '验证码') || str_contains($item['msg'], 'valCodeError') || $type_arr[0] == 'qzone_simula') { if (time() - $item['last_send'] < 10 * 60) { continue; } } if (str_contains($item['msg'], '重复发送') || str_contains($item['msg'], '用户调用次数超过限制')) { $task->update(array('retry_count' => Task::RETRY_COUNT), array('id' => $id)); continue; } $third = $thirdAccount->getThird($item['uid'], $type_arr[0], $type_arr[1]); if ($third && $third['valid'] == 1) { $api = Factory::CreateAPI2($type_arr[0], $type_arr[1], $third);
} $("#countdown").text(countd); }, 1000); </script>'); if ($_POST['time'] != 'on') { $arr = explode('|', $item['type']); $thirdAccount = new ThirdAccount(); $third = $thirdAccount->getThird($item['uid'], $arr[0], $arr[1]); $api = Factory::CreateAPI2($arr[0], $arr[1], $third); if ($item['cat'] == 'weibo') { $ret = $api->upload($item['content'], $item['pic']); } else { $ret = $api->publish($item['title'], $item['content']); } if ($ret === true) { $task->UpdateStatus(Task::OK, $id); } else { if (strpos($ret, '已过期') !== false) { $thirdAccount->fail($third, $ret); } $task->UpdateStatus(Task::ERROR, $id, $ret); } $TEMPLATE['report'][$item['type']] = array('status' => $ret === true, 'msg' => $ret === true ? '发送成功!<a href="' . $third['url'] . '" target="_blank">查看</a>' : '发送失败:' . $ret . ' <a href="list_err.php">重新发送</a>'); } else { $TEMPLATE['report'][$item['type']] = array('status' => true, 'msg' => '将于 ' . date('Y-m-d H:i', $item['send_time']) . ' 定时发送!'); } //redirect($_POST['return_url']); } break; case '取消': if ($data['status'] == Task::TASK_EDIT) {
<?php /** * 发送成功列表 * @author 潘洪学 panliu888@gmail.com * @create_date 2011-10 */ include_once dirname(__FILE__) . DIRECTORY_SEPARATOR . 'init.php'; Passport::RequireLogin(); $task = new Task(); switch (strtolower($_GET['action'])) { case 'del': $task->UpdateStatus(Task::DELETE_OK, intval($_GET['id']), '已取消'); break; case 'clear': $task->update(array('status' => Task::DELETE_OK, 'msg' => '被清空'), array('uid' => Passport::GetLoginUid(), 'status' => Task::OK)); redirect('?'); break; } $pager = new Pager($task->GetCount(Task::OK), 20); $TEMPLATE['list'] = $task->GetList(Task::OK, $pager->offset()); $TEMPLATE['pager'] = $pager->render(); $TEMPLATE['title'] = '已发送'; $TEMPLATE['login_name'] = Passport::GetLoginName(); $TEMPLATE['nav']['list_ok'] = 'current'; $smarty = new Template(); echo $smarty->r('list_ok');
$task = new Task(); switch ($_GET['action']) { case 'send': $thirdAccount = new ThirdAccount(); $id = intval($_GET['id']); $item = $task->get($id); if ($item) { $type = $item['type']; $arr = explode('|', $type); $third = $thirdAccount->getByType($arr[0], $arr[1], $item['uid']); $api = Factory::CreateAPI2($arr[0], $arr[1], $third); if ($item['cat'] == 'weibo') { $ret = $api->upload($item['content'], $item['pic']); } else { $ret = $api->publish($item['title'], $item['content']); } $TEMPLATE['report'] = array(); $TEMPLATE['report'][$type] = array('id' => $id, 'status' => $ret === true, 'msg' => $ret === true ? '发送成功!<a href="' . $third['url'] . '" target="_blank">查看</a>' : '发送失败:' . $ret); $task->UpdateStatus($ret === true ? Task::OK : Task::ERROR, $id, $ret, time()); } break; case 'del': $task->UpdateStatus(Task::DELETE_TASK, intval($_GET['id']), '已取消'); break; } $TEMPLATE['list'] = $task->GetList(Task::TASK); $TEMPLATE['title'] = '定时发送任务'; $TEMPLATE['login_name'] = Passport::GetLoginName(); $TEMPLATE['nav']['task'] = 'current'; $smarty = new Template(); echo $smarty->r('task');