Пример #1
0
<?php

require_once "../config.php";
require_once "../db.php";
$db = new DB();
$db->prepare("select * from task");
$tasks = $db->listArray();
$userDict = array();
foreach ($tasks as $task) {
    echo "Handling task " . $task["id"] . "\n";
    $config = json_decode($task["config"], true);
    if (!isset($userDict[$task["name"]])) {
        $ch = curl_init();
        if (isset($config["cookieName"])) {
            curl_setopt($ch, CURLOPT_COOKIEJAR, $config["cookieName"]);
            curl_setopt($ch, CURLOPT_COOKIEFILE, $config["cookieName"]);
        } else {
            $header[] = 'Cookie: ' . $config["cookiestr"];
            $header[] = 'User-Agent: ' . $config["agent"];
            curl_setopt($ch, CURLOPT_HTTPHEADER, $header);
        }
        $url = $gConfig["baseUrl"];
        curl_setopt($ch, CURLOPT_URL, $url);
        curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
        curl_setopt($ch, CURLOPT_BINARYTRANSFER, true);
        $output = curl_exec($ch);
        preg_match("/formhash=(\\w*)/", $output, $arr);
        $formhash = trim($arr[1]);
        preg_match('/id="umenu".*\\n.*<a.*>(.*)<\\/a>/', $output, $arr);
        $username = trim($arr[1]);
        if (!$username || !$formhash) {
Пример #2
0
                        echo "用户名或参数错误";
                    }
                } else {
                    if ($args[0] == "DeleteAutoPost") {
                        $db = new DB();
                        $name = $args[2];
                        $id = intval($args[3]);
                        $db->prepare("delete from task where name = ? and id = ?");
                        $db->bind_param("si", $name, $id);
                        $res = $db->execute();
                        if ($res) {
                            echo "success";
                        } else {
                            echo "error";
                        }
                    } else {
                        if ($args[0] == "GetAutoList") {
                            $db = new DB();
                            $name = $args[2];
                            $db->prepare("select * from task where name = ?");
                            $db->bind_param("s", $name);
                            $res = $db->listArray();
                            echo json_encode($res);
                        }
                    }
                }
            }
        }
    }
}
curl_close($ch);