Example #1
0
        $content = save_remote_img($_POST['content']);
        $wbs = $_POST['target'];
        $task = new Task();
        if ($_POST['time'] == 'on') {
            // 定时发送
            foreach ($wbs as $type) {
                $task->AddTask($type, $content, $_POST['send_time'], NULL, Task::TASK, NULL, 'blog', $_POST['title']);
            }
            $TEMPLATE['report']['time'] = array('status' => true, 'msg' => '定时发送成功!<a href="task.php">查看</a>');
        } else {
            $watch = new Stopwatch();
            $watch->Start();
            // 直接发送
            foreach ($wbs as $type) {
                $type_arr = explode('|', $type);
                $third = $thirdAccount->getByType($type_arr[0], $type_arr[1]);
                $api = Factory::CreateAPI2($type_arr[0], $type_arr[1], $third);
                $ret = $api->publish($_POST['title'], $content);
                if ($ret !== true && str_contains($ret, '已过期')) {
                    $thirdAccount->fail($third, $ret);
                }
                $TEMPLATE['report'][$type] = array('status' => $ret === true, 'msg' => $ret === true ? '发送成功!' . ($third['url'] ? '<a href="' . $third['url'] . '" target="_blank">查看</a>' : '') : '发送失败:' . $ret . ' <a href="list_err.php">重新发送</a>');
                $task->AddTask($type, $content, time(), NULL, $ret === true ? Task::OK : Task::ERROR, $ret, 'blog', $_POST['title']);
            }
            $watch->Stop();
            $TEMPLATE['report']['watch'] = array('status' => true, 'msg' => "总耗时:{$watch->getElapsedSeconds()} 秒");
        }
    }
}
$TEMPLATE['title'] = '发博客';
$TEMPLATE['login_name'] = Passport::GetLoginName();
Example #2
0
$user = new User();
$data = $user->get(Passport::GetLoginUid());
$last_exec = $data['last_exec'];
if (time() - $last_exec > 60 * 60) {
    $TEMPLATE['last_exec'] = max($last_exec, 1);
}
$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;
}
Example #3
0
 */
include_once dirname(__FILE__) . DIRECTORY_SEPARATOR . 'init.php';
Passport::RequireLogin();
if (!Passport::IsAdmin()) {
    redirect('login.php');
}
$wt_open = new WTOpen();
$thirdAccount = new ThirdAccount();
$TEMPLATE['platform_list'] = $wt_open->getPlatformList();
$pid = intval($_GET['id']);
if ($pid == 0 && count($TEMPLATE['platform_list']) > 0) {
    $ids = array_keys($TEMPLATE['platform_list']);
    redirect('?id=' . $ids[0]);
}
if ($_GET['action'] == 'unbind' && $_GET['type']) {
    $third = $thirdAccount->getByType($_GET['type'], $pid);
    $api = Factory::CreateAPI2($_GET['type'], $pid, $third);
    if (method_exists($api, 'Logout')) {
        $api->Logout();
    }
    $thirdAccount->delete(array('uid' => Passport::GetLoginUid(), 'type' => $_GET['type'], 'pid' => $pid));
    redirect("?id={$pid}");
}
if ($_POST['action'] == 'bind') {
    $fields = $_POST['f'];
    $fields['pid'] = $pid;
    $fields['uid'] = Passport::GetLoginUid();
    $fields['nick'] = $fields['token'];
    $fields['valid'] = 1;
    if ($fields['token'] && $fields['token_secret']) {
        $api = Factory::CreateAPI2($fields['type'], $pid, $fields);
Example #4
0
        }
        $wbs = $_POST['target'];
        $task = new Task();
        if ($_POST['time'] == 'on') {
            // 定时发送
            foreach ($wbs as $type) {
                $task->AddTask($type, $_POST['content'], $_POST['send_time'], $upload_file);
            }
            $TEMPLATE['report']['time'] = array('status' => true, 'msg' => '定时发送成功!<a href="task.php">查看</a>');
        } else {
            $watch = new Stopwatch();
            $watch->Start();
            // 直接发送
            foreach ($wbs as $type) {
                $arr = explode('|', $type);
                $third = $thirdAccount->getByType($arr[0], $arr[1]);
                $api = Factory::CreateAPI2($arr[0], $arr[1], $third);
                $ret = $api->upload($_POST['content'], $upload_file);
                if ($ret !== true && strpos($ret, '已过期') !== false) {
                    $thirdAccount->fail($third, $ret);
                }
                $TEMPLATE['report'][$type] = array('status' => $ret === true, 'msg' => $ret === true ? '发送成功!<a href="' . $third['url'] . '" target="_blank">查看</a>' : '发送失败:' . $ret . ' <a href="list_err.php">重新发送</a>');
                $task->AddTask($type, $_POST['content'], time(), $upload_file, $ret === true ? Task::OK : Task::ERROR, $ret);
            }
            $watch->Stop();
            $TEMPLATE['report']['watch'] = array('status' => true, 'msg' => "总耗时:{$watch->getElapsedSeconds()} 秒");
        }
    }
}
if ($_GET['testmail']) {
    $mail = Config::get_mail('token_expire');