From bbdfa333681cbca165e4fdc0eec0c9c591e638e8 Mon Sep 17 00:00:00 2001 From: Weltolk <40228052+Weltolk@users.noreply.github.com> Date: Fri, 21 Oct 2022 18:03:38 +0800 Subject: [PATCH] Add files via upload --- .gitignore | 1 + cron_weltolk_sign_qq.php | 235 +++++++ websocketclass.php | 634 +++++++++++++++++ weltolk_sign_qq.php | 60 ++ weltolk_sign_qq_callback.php | 78 +++ weltolk_sign_qq_public.php | 98 +++ weltolk_sign_qq_setting.php | 48 ++ weltolk_sign_qq_show.php | 1245 ++++++++++++++++++++++++++++++++++ 8 files changed, 2399 insertions(+) create mode 100644 .gitignore create mode 100644 cron_weltolk_sign_qq.php create mode 100644 websocketclass.php create mode 100644 weltolk_sign_qq.php create mode 100644 weltolk_sign_qq_callback.php create mode 100644 weltolk_sign_qq_public.php create mode 100644 weltolk_sign_qq_setting.php create mode 100644 weltolk_sign_qq_show.php diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..1da8522 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +.idea diff --git a/cron_weltolk_sign_qq.php b/cron_weltolk_sign_qq.php new file mode 100644 index 0000000..9f973e0 --- /dev/null +++ b/cron_weltolk_sign_qq.php @@ -0,0 +1,235 @@ += 4.0) { + $zt = 'latest'; + } else { + $zt = 'lastdo'; + } + $s = unserialize(option::get('plugin_weltolk_sign_qq')); + $date = date("Y-m-j", strtotime("-1 day")); + $now = strtotime(date('Y-m-d')); + $hour = date('h'); + $y = $m->query("SELECT * FROM `" . DB_PREFIX . "weltolk_sign_qq_target` WHERE `nextdo` <= '{$now}' LIMIT {$s['limit']}"); + while ($x = $m->fetch_array($y)) { + if ($hour >= $x['hour']) { + $msg_body = ""; + $query = $m->query("SELECT * FROM `" . DB_NAME . "`.`" . DB_PREFIX . "tieba` WHERE `uid`=" . $x['uid']); + $tieba_count = 0; + while ($tieba = $m->fetch_array($query)) { + $tieba_count++; + $status = true; + if ((date("Y-m-") . $tieba[$zt] == date("Y-m-j", strtotime("-1 day"))) || empty($tieba[$zt])) { + $style_prefix = '--'; + $status_str = '还未签到'; + $msg = '该贴吧尚未签到!'; + } elseif (!empty($tieba['no'])) { + // 忽略 + $status = false; +// $style_prefix = '**'; +// $status_str = '签到忽略'; +// $msg = '您设置了忽略此贴吧的签到'; + } elseif ($tieba['status'] == 0) { + // 忽略 + $status = false; +// $style_prefix = '++'; +// $status_str = '签到成功'; +// $msg = '-'; + } else { + $style_prefix = '!!'; + $status_str = '签到失败'; + $msg = $tieba['last_error']; + } + + if ($status) { + $msg_body .= $style_prefix + . ' ' . ($i['user']['baidu'][$tieba['pid']]) + . ' 账号的 ' . $tieba['tieba'] . ' 吧: ' + . $status_str . '\n' + . $style_prefix . ' 详细信息: ' . $msg + . '\n\n'; + } + } + if (empty($tieba_count)) { + $msg_body .= "没有关注的贴吧!请添加关注贴吧后在【云签到设置和日志】中刷新贴吧列表!"; + } + if (empty($msg_body)) { + $msg_body .= "今日全部贴吧签到成功"; + } + + $msg_dict = []; + if (substr_count($msg_body, "\n\n") <= 20) { + $msg_cache = $date; + $msg_cache .= "\n\n" . $msg_body . "\n\n第1/1页"; + $msg_dict = [ + $msg_cache, + ]; + } else { + $msg_array = explode("\n\n", $msg_body); + $max_page = ceil($msg_array / 20); + $page = 1; + $msg_cache = $date; + foreach ($msg_array as $keyyy => $valueee) { + if ($keyyy % 20 == 0 && $keyyy != 0) { + $msg_cache .= + "\n\n第" . $page . "/" . $max_page . "页"; + $msg_dict[] = $msg_cache; + $page += 1; + $msg_cache = $date; + } else if ($keyyy == (count($msg_array) - 1) && $keyyy % 20 != 0) { + $msg_cache .= + "\n\n第" . $page . "/" . $max_page . "页"; + $msg_dict[] = $msg_cache; + } else { + $msg_cache .= "\n\n" . $valueee; + } + } + } + + + $y2 = $m->query("SELECT * FROM `" . DB_PREFIX . "weltolk_sign_qq_connect` WHERE `id` = '{$x['connect_id']}' LIMIT 1"); + $x2 = $m->fetch_array($y2); + $sign = "sign" . mt_rand(1000, 9999); + + if ($x2['client'] == 'go-cqhttp') { + $access_token = $x2['access_token']; + + if ($x2['connect_type'] == '正向WebSocket') { + $headers = []; + if (empty($access_token)) { + + } else { + $headers = ["Authorization: Bearer " . $access_token]; + } + + $send = [ + "action" => "send_msg", + "params" => [ + + ], + "echo" => $sign, + ]; + + if ($x['type'] == '群') { + $send["params"]["message_type"] = "group"; + $send["params"]["group_id"] = $x['type_id']; + + } else if ($x['type'] == '私聊') { + $send["params"]["message_type"] = "private"; + $send["params"]["user_id"] = $x['type_id']; + + } else { + continue; + } + + $send_status = false; + foreach ($msg_dict as $msg_dict_i) { + $send["params"]["message"] = $msg_dict_i; + + try { + $send_json = json_encode($send); + $ws = new WebSocketClient($x2["address"], $headers); +// var_dump($ws->ping()); + $ws->ping(); + $ws->send($send_json); + $frame = $ws->recv(); + // echo "收到服务器响应数据:" . $frame->playload . PHP_EOL; +// var_dump($ws->close()); + $ws->close(); + $result_json = json_decode(trim($frame->playload), true); + if ($result_json["echo"] == $sign + && $result_json["retcode"] == 0 + && $result_json["status"] == "ok") { + $send_status = true; + } else { + + } + } catch (\Exception $e) { + echo "错误: "; + var_dump($e->__toString()); + } + usleep(250000); + } + if ($send_status) { + $next = strtotime(date('Y-m-d', time())) + 86400 + $x['hour'] * 3600; + $m->query("UPDATE `" . DB_PREFIX . "weltolk_sign_qq_target` SET `nextdo` = '{$next}' WHERE `id` = '{$x['id']}'"); + } + } else if ($x2['connect_type'] == 'HTTP API') { + $url = substr($x2["address"], -1) == "/" + ? substr($x2["address"], 0, -1) + : $x2["address"]; + $url .= "/send_msg"; + + $headers = []; + if (empty($access_token)) { + + } else { + $headers = [ + "Content-Type" => "application/json", + "Authorization" => "Bearer " . $access_token, + ]; + } + + $send = [ + + // go-cqhttp HTTP API post 未支持echo +// "echo" => $sign, + ]; + + if ($x['type'] == '群') { + $send["message_type"] = "group"; + $send["group_id"] = $x['type_id']; + + } else if ($x['type'] == '私聊') { + $send["message_type"] = "private"; + $send["user_id"] = $x['type_id']; + + } else { + continue; + } + + $send_status = false; + foreach ($msg_dict as $msg_dict_i) { + $send["message"] = $msg_dict_i; + + $c = new wcurl($url, $headers); + $c->setTimeOut(5000); + + $res = $c->post($send); + $res = json_decode($res, TRUE); + if ($res['retcode'] == 0 + && $res['status'] == 'ok' + // go-cqhttp HTTP API post 未支持echo +// && $res['echo'] == $sign + ) { + $send_status = true; + } else { + + } + + usleep(250000); + } + if ($send_status) { + $next = strtotime(date('Y-m-d', time())) + 86400 + $x['hour'] * 3600; + $m->query("UPDATE `" . DB_PREFIX . "weltolk_sign_qq_target` SET `nextdo` = '{$next}' WHERE `id` = '{$x['id']}'"); + } + + } else { + continue; + } + } else { + continue; + } + + } else { + $next = strtotime(date('Y-m-d', time())) + $x['hour'] * 3600; + $m->query("UPDATE `" . DB_PREFIX . "weltolk_sign_qq_target` SET `nextdo` = '{$next}' WHERE `id` = '{$x['id']}'"); + } + } +} diff --git a/websocketclass.php b/websocketclass.php new file mode 100644 index 0000000..300707b --- /dev/null +++ b/websocketclass.php @@ -0,0 +1,634 @@ +parseUri($wsUri); + + $this->connect($connectTimeout, $rwTimeout); + + $this->handshake($header); + + $this->initReadBuf(); + } + + /** + * 解析websocket连接地址 + * @param $wsUri + * @throws BadUriException + */ + protected function parseUri($wsUri) + { + $uriData = parse_url($wsUri); + if (!$uriData) { + throw new BadUriException('不正确的ws uri格式', __LINE__); + } + if ($uriData['scheme'] != self::PROTOCOL_WS && $uriData['scheme'] != self::PROTOCOL_WSS) { + throw new BadUriException('ws的uri必须是以ws://或wss://开头', __LINE__); + } + $this->protocol = $uriData['scheme']; + $this->host = $uriData['host']; + + if ($uriData['port']) { + $this->port = (int)$uriData['port']; + } else { + if ($this->protocol == self::PROTOCOL_WSS) { + $this->port = 443; + } else { + $this->port = 80; + } + } + $this->path = $uriData['path'] ?: '/'; + if ($uriData['query']) { + $this->path .= '?' . $uriData['query']; + } + if ($uriData['fragment']) { + $this->path .= '#' . $uriData['fragment']; + } + } + + /** + * 连接websocket服务器 + * @param float $timeout 连接服务器的超时时间 + * @param float $rwTimeout 设置读写数据的超时时间 + * @throws ServerConnectException + */ + protected function connect($timeout, $rwTimeout) + { + $this->sock = stream_socket_client( + ($this->protocol == self::PROTOCOL_WSS ? 'ssl://' : 'tcp://') . $this->host . ':' . $this->port, + $errno, + $errstr, + $timeout + ); + + if (!$this->sock) { + + if ($errstr) { + throw new ServerConnectException('连接ws服务器失败:' . $errstr, $errno); + } + + throw new ServerConnectException('连接ws服务器失败: 未知错误', __LINE__); + } + + $this->setSockTimeout($rwTimeout); + } + + /** + * 设置socket的读写超时时间 + * @param float $seconds + */ + public function setSockTimeout($seconds) + { + if (strpos($seconds, '.') !== false) { + $original = $seconds; + $seconds = (int)$seconds; + $microseconds = bcmul($original, 1000000, 0) - ($seconds * 1000000); + } else { + $microseconds = 0; + } + stream_set_timeout($this->sock, (int)$seconds, $microseconds); + } + + /** + * @param $data + * @throws SocketRWException + */ + protected function writeToSock($data) + { + if ($this->closed) { + throw new SocketRWException('连接已关闭, 不允许再发送消息', __LINE__); + } + + $dataLen = strlen($data); + if ($dataLen > self::PACKET_SIZE) { + $dataPieces = str_split($data, self::PACKET_SIZE); + foreach ($dataPieces as $piece) { + $this->writeN($piece); + } + } else { + $this->writeN($data); + } + } + + /** + * 向socket写入N个字节 + * @param $str + * @throws SocketRWException + */ + protected function writeN($str) + { + if ($this->closed) { + throw new SocketRWException('连接已关闭, 不允许再发送消息', __LINE__); + } + + $len = strlen($str); + $writeLen = 0; + do { + if ($writeLen > 0) { + $str = substr($str, $writeLen); + } + $n = fwrite($this->sock, $str); + if ($n === false) { + $meta = stream_get_meta_data($this->sock); + if ($meta['timed_out']) { + throw new SocketRWException('向服务器发送数据超时', __LINE__); + } + throw new SocketRWException('无法发送数据,socket连接已断开?', __LINE__); + } + $writeLen += $n; + } while ($writeLen < $len); + } + + /** + * 随机产生一个 Sec-WebSocket-Key + * @return false|string + */ + protected static function generateWsKey() + { + return base64_encode(md5(uniqid() . mt_rand(1, 8192), true)); + } + + /** + * websocket握手 + * @throws Exception + */ + protected function handshake($headers2 = []) + { + $this->secWebSocketKey = self::generateWsKey(); + $headers = [ + 'GET ' . $this->path . ' HTTP/1.1', + 'Host: ' . $this->host . ':' . $this->port, + 'Upgrade: websocket', + 'Connection: Upgrade', + 'Sec-WebSocket-Key: ' . $this->secWebSocketKey, + 'Sec-WebSocket-Version: 13', + ]; + $headers = array_merge($headers, $headers2); + $htmlHeader = implode(self::HTTP_HEADER_SEPARATION_MARK, $headers) . self::HTTP_HEADER_END_MARK; + $this->writeToSock($htmlHeader); + $response = ''; + $end = false; + do { + $str = fread($this->sock, 8192); + if (strlen($str) == 0) { + break; + } + $response .= $str; + $end = strpos($response, self::HTTP_HEADER_END_MARK); + } while ($end === false); + + if ($end === false) { + throw new HandshakeException('握手失败:握手响应不是标准的http响应', __LINE__); + } + + $resHeader = substr($response, 0, $end); + $headers = explode(self::HTTP_HEADER_SEPARATION_MARK, $resHeader); + + if (strpos($headers[0], '101') === false) { + throw new HandshakeException('握手失败:服务器返回http状态码不是101', __LINE__); + } + for ($i = 1; $i < count($headers); $i++) { + list($key, $val) = explode(':', $headers[$i]); + if (strtolower(trim($key)) == 'sec-websocket-accept') { + $accept = base64_encode(sha1($this->secWebSocketKey . self::UUID, true)); + if (trim($val) != $accept) { + throw new HandshakeException('握手失败: sec-websocket-accept值校验失败', __LINE__); + } + $this->handshakePass = true; + break; + } + } + if (!$this->handshakePass) { + throw new HandshakeException('握手失败:缺少sec-websocket-accept http头', __LINE__); + } + } + + /** + * @param int $opCode 帧类型 + * @param string $playLoad 携带的数据 + * @param bool $isMask 是否使用掩码 + * @param int $status 关闭帧状态 + * @return false|string + */ + protected function packFrame($opCode, $playLoad = '', $isMask = true, $status = 1000) + { + $firstByte = 0x80 | $opCode; + if ($isMask) { + $secondByte = 0x80; + } else { + $secondByte = 0x00; + } + + $playLoadLen = strlen($playLoad); + if ($opCode == self::OPCODE_CLOSE) { + // 协议规定关闭帧必须使用掩码 + $isMask = true; + $playLoad = pack('CC', (($status >> 8) & 0xff), $status & 0xff) . $playLoad; + $playLoadLen += 2; + } + if ($playLoadLen <= self::FRAME_LENGTH_LEVEL_1_MAX) { + $secondByte |= $playLoadLen; + $frame = pack('CC', $firstByte, $secondByte); + } elseif ($playLoadLen <= self::FRAME_LENGTH_LEVEL_2_MAX) { + $secondByte |= 126; + $frame = pack('CCn', $firstByte, $secondByte, $playLoadLen); + } else { + $secondByte |= 127; + $frame = pack('CCJ', $firstByte, $secondByte, $playLoadLen); + } + + if ($isMask) { + $maskBytes = [mt_rand(1, 255), mt_rand(1, 255), mt_rand(1, 255), mt_rand(1, 255)]; + $frame .= pack('CCCC', $maskBytes[0], $maskBytes[1], $maskBytes[2], $maskBytes[3]); + if ($playLoadLen > 0) { + for ($i = 0; $i < $playLoadLen; $i++) { + $playLoad[$i] = chr(ord($playLoad[$i]) ^ $maskBytes[$i % 4]); + } + } + } + + $frame .= $playLoad; + + return $frame; + } + + /** + * ping服务器 + * @throws Exception + */ + public function ping() + { + try { + $frame = $this->packFrame(self::OPCODE_PING, '', true); + $this->writeToSock($frame); + do { + $pong = $this->recv(); + if ($pong->opcode == self::OPCODE_PONG) { + return true; + } + } while ($pong->opcode != self::OPCODE_PONG); + return false; + } catch (Exception $e) { + return false; + } + } + + /** + * 响应服务器的ping + * @throws Exception + */ + public function pong() + { + $frame = $this->packFrame(self::OPCODE_PONG, '', true); + $this->writeToSock($frame); + } + + /** + * 主动关闭与服务器的连接 + * @return bool + * @throws Exception + */ + public function close() + { + $frame = $this->packFrame(self::OPCODE_CLOSE, '', true, 1000); + + try { + $this->writeToSock($frame); + // 主动关闭需要再接收一次对端返回的确认消息 + $wsData = $this->recv(); + if ($wsData->opcode == self::OPCODE_CLOSE) { + return true; + } + } catch (\Throwable $e) { + } finally { + $this->closed = true; + stream_socket_shutdown($this->sock, STREAM_SHUT_RDWR); + } + return false; + } + + /** + * ping服务器失败或服务器响应异常时调用,用于关闭socket资源 + */ + public function abnormalClose() + { + if (!$this->closed && $this->sock) { + $this->closed = true; + try { + stream_socket_shutdown($this->sock, STREAM_SHUT_RDWR); + } catch (\Throwable $e) { + } + } + } + + /** + * 响应服务器的关闭消息 + * @throws SocketRWException + */ + protected function replyClosure() + { + $frame = $this->packFrame(self::OPCODE_CLOSE, '', true, 1000); + $this->writeToSock($frame); + $this->closed = true; + stream_socket_shutdown($this->sock, STREAM_SHUT_RDWR); + } + + /** + * @param string $data 要发送的数据 + * @param int $opCode 发送的数据类型 WebSocketClient::OPCODE_TEXT_FRAME 或 WebSocketClient::OPCODE_BINARY_FRAME + * @param bool $isMask 是否使用掩码,默认使用 + * @throws Exception + */ + public function send($data, $opCode = self::OPCODE_TEXT_FRAME, $isMask = true) + { + if ($opCode != self::OPCODE_TEXT_FRAME && $opCode != self::OPCODE_BINARY_FRAME) { + throw new \InvalidArgumentException('不支持的帧数据类型', __LINE__); + } + + $frame = $this->packFrame($opCode, $data, $isMask); + + $this->writeToSock($frame); + } + + /** + * 初始化收取数据缓冲区 + */ + private function initReadBuf() + { + $this->readBuf = ''; + $this->currentReadBufLen = 0; + $this->readBufPos = 0; + } + + /** + * 从读取缓冲区中当前位置返回指定长度字符串 + * @param int $len 返回长度 + * @return bool|string + * @throws SocketRWException + */ + private function fetchStrFromReadBuf($len = 1) + { + $target = $this->readBufPos + $len; + + while ($target > $this->currentReadBufLen) { + if ($this->closed) { + throw new SocketRWException('连接已关闭, 不允许再收取消息', __LINE__); + } + $read = fread($this->sock, self::PACKET_SIZE); + if (!$read) { + $meta = stream_get_meta_data($this->sock); + if ($meta['timed_out']) { + throw new SocketRWException('读取服务器数据超时', __LINE__); + } + throw new SocketRWException('无法读取服务器数据,错误未知', __LINE__); + } + $this->readBuf .= $read; + $this->currentReadBufLen += strlen($read); + } + $str = substr($this->readBuf, $this->readBufPos, $len); + $this->readBufPos += $len; + return $str; + } + + /** + * 返回读取缓冲区当前位置字符的ascii码 + * @return int + * @throws SocketRWException + */ + private function fetchCharFromReadBuf() + { + $str = $this->FetchStrFromReadBuf(1); + return ord($str[0]); + } + + /** + * 丢弃读取缓冲区已处理的指定长度数据 + * @param $len + */ + private function discardReadBuf($len) + { + // 未处理的数据不会被丢弃 + if ($len > $this->readBufPos) { + $len = $this->readBufPos; + } + if ($len > 0) { + $this->readBuf = substr($this->readBuf, $len); + $this->readBufPos -= $len; + $this->currentReadBufLen -= $len; + } + } + + /** + * @return WsDataFrame + * @throws Exception + */ + public function recv() + { + $dataFrame = $this->readFrame(); + switch ($dataFrame->opcode) { + + case self::OPCODE_PING: + $this->pong(); + break; + + case self::OPCODE_PONG: + break; + + case self::OPCODE_TEXT_FRAME: + case self::OPCODE_BINARY_FRAME: + case self::OPCODE_CLOSE: + if ($dataFrame->fin == 0) { + do { + $continueFrame = $this->readFrame(); + $dataFrame->playload .= $continueFrame->playload; + } while ($continueFrame->fin == 0); + } + + if ($dataFrame->opcode == self::OPCODE_CLOSE) { + $this->replyClosure(); + } + break; + default: + throw new BadFrameException('无法识别的frame数据', __LINE__); + break; + } + return $dataFrame; + } + + /** + * 读取一个数据帧 + * @return WsDataFrame + * @throws SocketRWException + */ + protected function readFrame() + { + $firstByte = $this->fetchCharFromReadBuf(); + $fin = ($firstByte >> 7); + $opcode = $firstByte & 0x0F; + $secondByte = $this->fetchCharFromReadBuf(); + $isMasked = ($secondByte >> 7); + $dataLen = $secondByte & 0x7F; + if ($dataLen == 126) { + // 2字节无符号整形 + $dataLen = ($this->fetchCharFromReadBuf() << 8) + $this->fetchCharFromReadBuf(); + } elseif ($dataLen == 127) { + // 8字节无符号整形 + $dataLen = $this->fetchStrFromReadBuf(8); + $res = unpack('Jlen', $dataLen); + if (isset($res['len'])) { + $dataLen = $res['len']; + } else { + $dataLen = (ord($dataLen[0]) << 56) + + (ord($dataLen[1]) << 48) + + (ord($dataLen[2]) << 40) + + (ord($dataLen[3]) << 32) + + (ord($dataLen[4]) << 24) + + (ord($dataLen[5]) << 16) + + (ord($dataLen[6]) << 8) + + ord($dataLen[7]); + } + } + + $data = ''; + $status = 0; + if ($dataLen > 0) { + if ($isMasked) { + // 4字节掩码 + $maskChars = $this->fetchStrFromReadBuf(4); + $maskSet = [ord($maskChars[0]), ord($maskChars[1]), ord($maskChars[2]), ord($maskChars[3])]; + $data = $this->fetchStrFromReadBuf($dataLen); + for ($i = 0; $i < $dataLen; $i++) { + $data[$i] = chr(ord($data[$i]) ^ $maskSet[$i % 4]); + } + } else { + $data = $this->fetchStrFromReadBuf($dataLen); + } + if ($opcode == self::OPCODE_CLOSE) { + $status = (ord($data[0]) << 8) + ord($data[1]); + $data = substr($data, 2); + } + } + + $this->discardReadBuf($this->readBufPos); + + $dataFrame = new WsDataFrame(); + $dataFrame->opcode = $opcode; + $dataFrame->fin = $fin; + $dataFrame->status = $status; + $dataFrame->playload = $data; + return $dataFrame; + } + + /** + * __destruct + */ + public function __destruct() + { + $this->abnormalClose(); + } +} + +/** + * websocket数据帧 + * Class wsDataFrame + * @package library\util + */ +class WsDataFrame +{ + /** + * @var int $opcode + */ + public $opcode; + + /** + * @var int $fin 标识数据包是否已结束 + */ + public $fin; + + /** + * @var int $status 关闭时的状态码,如果有的话 + */ + public $status; + + /** + * @var string 数据包携带的数据 + */ + public $playload; +} diff --git a/weltolk_sign_qq.php b/weltolk_sign_qq.php new file mode 100644 index 0000000..4a2ff43 --- /dev/null +++ b/weltolk_sign_qq.php @@ -0,0 +1,60 @@ + + + 每日签到qq推送 + + > 开启每日签到qq推送
+ > 关闭每日签到qq推送 + + + + 每日签到qq报告地址 + + 点击查看(有效期至) + + +
  • > 每日签到qq推送
  • + \ No newline at end of file diff --git a/weltolk_sign_qq_callback.php b/weltolk_sign_qq_callback.php new file mode 100644 index 0000000..efc1549 --- /dev/null +++ b/weltolk_sign_qq_callback.php @@ -0,0 +1,78 @@ +贴吧云签到报告

    贴吧云签到报告

    项目内容备注
    签到日期[date]当日报告已生成
    用户名称[name]您是该站云签用户
    报告地址[link]点击链接直达,次日失效
    云签站点[SYSTEM_NAME]如有疑问,进站反馈

    发自[SYSTEM_NAME]
    百度贴吧云签到作者: Kenvix&mokeyjay&FYY
    邮件扩展作者:Weltolk

    +
    '); + //create connect tab + $m->query("CREATE TABLE IF NOT EXISTS `" . DB_PREFIX . "weltolk_sign_qq_connect` ( + `id` int(255) NOT NULL AUTO_INCREMENT , + `uid` int(255) NOT NULL , + `client` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL , + `connect_type` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL , + `address` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL , + `access_token` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL , + PRIMARY KEY (`id`) + ) + ENGINE=MyISAM + DEFAULT CHARACTER SET=utf8 COLLATE=utf8_general_ci + AUTO_INCREMENT=12 + CHECKSUM=0 + ROW_FORMAT=DYNAMIC + DELAY_KEY_WRITE=0;"); + //create target tab + $m->query("CREATE TABLE IF NOT EXISTS `" . DB_PREFIX . "weltolk_sign_qq_target` ( + `id` int(255) NOT NULL AUTO_INCREMENT , + `uid` int(255) NOT NULL , + `connect_id` int(255) NOT NULL , + `hour` int(255) NOT NULL , + `type` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL , + `type_id` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL , + `nextdo` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL , + PRIMARY KEY (`id`) + ) + ENGINE=MyISAM + DEFAULT CHARACTER SET=utf8 COLLATE=utf8_general_ci + AUTO_INCREMENT=12 + CHECKSUM=0 + ROW_FORMAT=DYNAMIC + DELAY_KEY_WRITE=0;"); + // plugin_option + $set_arr = array( + 'limit' => "10", + ); + $set_str = serialize($set_arr); + option::set('plugin_weltolk_sign_qq', $set_str); + //cron_tab setting + cron::set('weltolk_sign_qq', 'plugins/weltolk_sign_qq/cron_weltolk_sign_qq.php', 0, '每日签到qq推送定时任务', 0); +} + +function callback_inactive() +{ + //cron_tab setting + cron::del('weltolk_sign_qq'); + +} + +function callback_remove() +{ + //admin setting + option::del('weltolk_sign_qq_default_open'); + option::del('weltolk_sign_qq_zone'); + option::del('weltolk_sign_qq_title'); + option::del('weltolk_sign_qq_content'); + // plugin_option + option::del('plugin_weltolk_sign_qq'); + //user setting + global $m; + $m->query("DROP TABLE IF EXISTS `" . DB_PREFIX . "weltolk_sign_qq_connect`"); + $m->query("DROP TABLE IF EXISTS `" . DB_PREFIX . "weltolk_sign_qq_target`"); +} + +?> \ No newline at end of file diff --git a/weltolk_sign_qq_public.php b/weltolk_sign_qq_public.php new file mode 100644 index 0000000..2b7315d --- /dev/null +++ b/weltolk_sign_qq_public.php @@ -0,0 +1,98 @@ +fetch_array($m->query('select * from `' . DB_NAME . '`.`' . DB_PREFIX . 'users` where `name` = "' . $user . '"')); +if (empty($userinfo['email'])) { + die('用户不存在'); +} +$system_token = md5(md5($userinfo['name'] . $userinfo['id'] . date('Y-m-d')) . md5($userinfo['id'])); +if ($token != $system_token) { + die('链接已失效!请使用当天的最新邮件中附带的链接'); +} +if ($i['opt']['core_version'] >= 4.0) { + $zt = 'latest'; +} else { + $zt = 'lastdo'; +} + +?> +

    每日签到报告

    +
    +

    】贴吧云签到结果

    +

    用户名称:

    +

    站点地址:

    + + + + + + + + + + query("SELECT * FROM `" . DB_NAME . "`.`" . DB_PREFIX . "tieba` WHERE `uid`=" . $userinfo['id']); + $tieba_count = 0; + while ($tieba = $m->fetch_array($query)) { + $tieba_count++; + if ((date("Y-m-") . $tieba[$zt] == date("Y-m-j", strtotime("-1 day"))) || empty($tieba[$zt])) { + $style_str = 'warning'; + $status_str = '还未签到'; + $status_icon = 'question-sign'; + $msg = '该贴吧尚未签到!'; + } elseif (!empty($tieba['no'])) { + $style_str = 'info'; + $status_str = '签到忽略'; + $status_icon = 'info-sign'; + $msg = '您设置了忽略此贴吧的签到'; + } elseif ($tieba['status'] == 0) { + $style_str = 'success'; + $status_str = '签到成功'; + $status_icon = 'ok-sign'; + $msg = '-'; + } else { + $style_str = 'danger'; + $status_str = '签到失败'; + $status_icon = 'remove-sign'; + $msg = $tieba['last_error']; + } + $out_put_str = ''; + echo $out_put_str; + } + if (empty($tieba_count)) { + echo ''; + } + ?> + +
    百度账号最近签到日期吧名(点击直达)状态结果
    ' . ($i['user']['baidu'][$tieba['pid']]) + . '' . (date("Y-m-") . $tieba[$zt] ? date("Y-m-") . $tieba[$zt] : '-') + . '' + . $tieba['tieba'] . '' + . ' ' . $status_str . '' + . $msg . '
     没有关注的贴吧!请添加关注贴吧后在【云签到设置和日志】中刷新贴吧列表!
    +
    + +
    + 插件作者: + D丶L & + Pisces& + quericy + Weltolk +
    +
    + 程序作者:无名智者 & + Mokeyjay & + FYY +
    diff --git a/weltolk_sign_qq_setting.php b/weltolk_sign_qq_setting.php new file mode 100644 index 0000000..f71a0d3 --- /dev/null +++ b/weltolk_sign_qq_setting.php @@ -0,0 +1,48 @@ +插件设置成功'; + break; + case 'store'://保存设置 + $set_arr = array( + 'limit' => $_POST['limit'], + ); + $set_str = serialize($set_arr); + option::set('plugin_weltolk_sign_qq', $set_str); + ReDirect(SYSTEM_URL . 'index.php?mod=admin:setplug&plug=weltolk_sign_qq&act=ok'); + die; + default: + break; +} + + +?> +

    qq推送设置


    +
    + + + + + + + + + + + + + +
    参数
    单次计划任务连续推送次数
    越小效率越低,但太大也可能导致超时
    + + +
    \ No newline at end of file diff --git a/weltolk_sign_qq_show.php b/weltolk_sign_qq_show.php new file mode 100644 index 0000000..4a13cf8 --- /dev/null +++ b/weltolk_sign_qq_show.php @@ -0,0 +1,1245 @@ +插件设置成功'; + break; + case 'addconnect'://添加推送地址 + $client = !empty($_POST['client']) ? addslashes(strip_tags($_POST['client'])) : msg('请输入客户端'); + $connect_type = !empty($_POST['connect_type']) ? addslashes(strip_tags($_POST['connect_type'])) : msg('请输入连接方式'); + $address = !empty($_POST['address']) ? addslashes(strip_tags($_POST['address'])) : msg('请输入连接地址'); + $address = explode("\n", trim($address)); + $access_token = addslashes(strip_tags($_POST['access_token'])); + $anchor = addslashes(strip_tags($_POST['anchor'])); + foreach ($address as $address_i) { + $address_i = trim($address_i); + if (!empty($address_i)) { + $m->query("INSERT INTO `" . DB_PREFIX . "weltolk_sign_qq_connect` (`uid`, `client`, `connect_type`, `address`, `access_token` )" + . " SELECT '" . UID . "', '{$client}', '{$connect_type}', '{$address_i}', '{$access_token}'" + . " WHERE NOT EXISTS ( SELECT * FROM `" . DB_PREFIX . "weltolk_sign_qq_connect`" + . " WHERE `uid` = '" . UID . "' AND `client` = '{$client}' AND `connect_type` = '{$connect_type}'" + . " AND `address` = '{$address_i}' AND `access_token` = '{$access_token}')"); + } + } + ReDirect(SYSTEM_URL . 'index.php?plugin=weltolk_sign_qq&act=ok' . '#' . $anchor); + break; + case 'batchedit'://批量/搜索 编辑推送地址 + $anchor = addslashes(strip_tags($_POST['anchor'])); + $client = !empty($_POST['client']) ? intval($_POST['client']) : ""; + $client2 = !empty($_POST['client2']) ? intval($_POST['client2']) : ""; + if ((empty($client) && !empty($client2)) || (!empty($client) && empty($client2))) { + msg('请正确输入qq客户端'); + } + $connect_type = !empty($_POST['connect_type']) ? addslashes(strip_tags($_POST['connect_type'])) : ""; + $connect_type2 = !empty($_POST['connect_type2']) ? addslashes(strip_tags($_POST['connect_type2'])) : ""; + if ((empty($connect_type) && !empty($connect_type2)) || (!empty($connect_type) && empty($connect_type2))) { + msg('请正确选择连接方式'); + } + $address = !empty($_POST['address']) ? addslashes(strip_tags($_POST['address'])) : ""; + $address2 = !empty($_POST['address2']) ? addslashes(strip_tags($_POST['address2'])) : ""; + if ((empty($address) && !empty($address2)) || (!empty($address) && empty($address2))) { + msg('请正确输入连接地址'); + } + $access_token = !empty($_POST['access_token']) ? addslashes(strip_tags($_POST['access_token'])) : ""; + $access_token2 = !empty($_POST['access_token2']) ? addslashes(strip_tags($_POST['access_token2'])) : ""; + if ((empty($access_token) && !empty($access_token2))) { + msg('请正确输入access_token'); + } + + $status = false; + $sql1 = "UPDATE `" . DB_PREFIX . "weltolk_sign_qq_connect` SET "; + $sql2 = " WHERE "; + if (!empty($client) && !empty($client2)) { + if ($status) { + $sql1 .= ", `client` = '{$client2}'"; + $sql2 .= " AND `client` = '{$client}'"; + } else { + $sql1 .= "`client` = '{$client2}'"; + $sql2 .= "`client` = '{$client}'"; + } + $status = true; + } + if (!empty($connect_type) && !empty($connect_type2)) { + if ($status) { + $sql1 .= ", `connect_type` = '{$connect_type2}'"; + $sql2 .= " AND `connect_type` = '{$connect_type}'"; + } else { + $sql1 .= "`connect_type` = '{$connect_type2}'"; + $sql2 .= "`connect_type` = '{$connect_type}'"; + } + $status = true; + } + if (!empty($address) && !empty($address2)) { + if ($status) { + $sql1 .= ", `address` = '{$address2}'"; + $sql2 .= " AND `address` = '{$address}'"; + } else { + $sql1 .= "`address` = '{$address2}'"; + $sql2 .= "`address` = '{$address}'"; + } + $status = true; + } + if (!empty($access_token)) { + if ($status) { + $sql1 .= ", `access_token` = '{$access_token2}'"; + $sql2 .= " AND `access_token` = '{$access_token}'"; + } else { + $sql1 .= "`access_token` = '{$access_token2}'"; + $sql2 .= "`access_token` = '{$access_token}'"; + } + $status = true; + } + + $sql = $sql1 . $sql2; + if ($status) { + $m->query($sql); + } + ReDirect(SYSTEM_URL . 'index.php?plugin=weltolk_sign_qq&ok' . '#' . $anchor); + break; + case 'update'://编辑单条推送地址 + $id = !empty($_POST['id']) ? addslashes(strip_tags($_POST['id'])) : msg('请输入ID'); + $client = !empty($_POST['client']) ? addslashes(strip_tags($_POST['client'])) : msg('请输入客户端'); + $connect_type = !empty($_POST['connect_type']) ? addslashes(strip_tags($_POST['connect_type'])) : msg('请输入连接方式'); + $address = !empty($_POST['address']) ? addslashes(strip_tags($_POST['address'])) : msg('请输入连接地址'); + $access_token = addslashes(strip_tags($_POST['access_token'])); + $anchor = addslashes(strip_tags($_POST['anchor'])); + $m->query("UPDATE `" . DB_PREFIX . "weltolk_sign_qq_connect` " + . "SET `client` = '{$client}', `connect_type` = '{$connect_type}'," + . " `address` = '{$address}', `access_token` = '{$access_token}'" + . " WHERE `id` = '{$id}'"); + ReDirect(SYSTEM_URL . 'index.php?plugin=weltolk_sign_qq&ok' . '#' . $anchor); + break; + case 'del'://删除推送地址 + $id = isset($_GET['id']) ? intval($_GET['id']) : msg('缺少ID'); + $anchor = addslashes(strip_tags($_GET['anchor'])); + $m->query("DELETE FROM `" . DB_PREFIX . "weltolk_sign_qq_connect` WHERE `uid` = " . UID . " AND `id` = " . $id); + ReDirect(SYSTEM_URL . 'index.php?plugin=weltolk_sign_qq&act=ok' . '#' . $anchor); + break; + default: + break; + } +} else if ($page == 'list') { + switch ($_GET['act']) { + case 'ok'://成功回显 + echo '
    插件设置成功
    '; + break; + case 'debug'://测试qq推送回显 + ob_end_clean(); + $data = json_decode($_POST['info'], true); + $cache_connect_id = ""; + if (!empty($data['connect_id'])) { + $cache_connect_id = addslashes(strip_tags($data['connect_id'])); + } + $cache_type = ""; + if (!empty($data['type'])) { + $cache_type = addslashes(strip_tags($data['type'])); + } + $cache_type_id = ""; + if (!empty($data['type_id'])) { + $cache_type_id = addslashes(strip_tags($data['type_id'])); + } + if (empty($cache_connect_id) + || empty($cache_type) + || empty($cache_type_id) + ) { + $return_arr = array('code' => 0, 'msg' => '无效请求!'); + } else { + require_once "websocketclass.php"; + global $m; + + $y2 = $m->query("SELECT * FROM `" . DB_PREFIX . "weltolk_sign_qq_connect` WHERE `id` = '{$cache_connect_id}' LIMIT 1"); + $x2 = $m->fetch_array($y2); + $sign = "sign" . mt_rand(1000, 9999); + + $date_cache = date('Y-m-d'); + + if ($x2['client'] == 'go-cqhttp') { + $access_token = $x2['access_token']; + + if ($x2['connect_type'] == '正向WebSocket') { + $headers = []; + if (empty($access_token)) { + + } else { + $headers = ["Authorization: Bearer " . $access_token]; + } + + $send = [ + "action" => "send_msg", + "params" => [ + + ], + "echo" => $sign, + ]; + + if ($cache_type == '群') { + $send["params"]["message_type"] = "group"; + $send["params"]["group_id"] = $cache_type_id; + + } else if ($cache_type == '私聊') { + $send["params"]["message_type"] = "private"; + $send["params"]["user_id"] = $cache_type_id; + + } else { + + } + + $cache_status = true; + + $send["params"]["message"] = + $date_cache + . "\n\n" . "Tieba-Cloud-Sign插件weltolk_sign_qq测试消息" + . "\n\n" . "第1/2页"; + + try { + $send_json = json_encode($send); + $ws = new WebSocketClient($x2["address"], $headers); + $ws->ping(); + $ws->send($send_json); + $frame = $ws->recv(); + // echo "收到服务器响应数据:" . $frame->playload . PHP_EOL; + $ws->close(); + $result_json = json_decode(trim($frame->playload), true); + if ($result_json["echo"] == $sign + && $result_json["retcode"] == 0 + && $result_json["status"] == "ok") { + + } else { + $cache_status = false; + } + } catch (\Exception $e) { +// echo "错误: "; +// var_dump($e->__toString()); + $e->__toString(); + } + + usleep(250000); + + $send["params"]["message"] = + $date_cache + . "\n\n" + . '!! ' + . ' ' . '测试百度账号' + . ' 账号的 ' . '测试百度贴吧' . ' 吧: ' + . '签到失败' . '\n' + . '!!' . ' 详细信息: ' . '签到超时' + . "\n\n" . "第2/2页"; + + try { + $send_json = json_encode($send); + $ws = new WebSocketClient($x2["address"], $headers); + $ws->ping(); + $ws->send($send_json); + $frame = $ws->recv(); + // echo "收到服务器响应数据:" . $frame->playload . PHP_EOL; + $ws->close(); + $result_json = json_decode(trim($frame->playload), true); + if ($result_json["echo"] == $sign + && $result_json["retcode"] == 0 + && $result_json["status"] == "ok") { + + } else { + $cache_status = false; + } + } catch (\Exception $e) { +// echo "错误: "; +// var_dump($e->__toString()); + $e->__toString(); + } + + if ($cache_status) { + $return_arr = array('code' => 1, 'msg' => '两条测试消息已经发送到' . $cache_type_id . ',请注意查看!'); + } else { + $return_arr = array('code' => 0, 'msg' => '发送给' . $cache_type_id . '的测试消息发送失败!'); + } + } else if ($x2['connect_type'] == 'HTTP API') { + $url = substr($x2["address"], -1) == "/" + ? substr($x2["address"], 0, -1) + : $x2["address"]; + $url .= "/send_msg"; + + $headers = []; + if (empty($access_token)) { + + } else { + $headers = [ + "Content-Type" => "application/json", + "Authorization" => "Bearer " . $access_token, + ]; + } + + $send = [ + + // go-cqhttp HTTP API post 未支持echo +// "echo" => $sign, + ]; + + if ($cache_type == '群') { + $send["message_type"] = "group"; + $send["group_id"] = $cache_type_id; + + } else if ($cache_type == '私聊') { + $send["message_type"] = "private"; + $send["user_id"] = $cache_type_id; + + } else { + + } + + $cache_status = true; + + $send["message"] = + $date_cache + . "\n\n" . "Tieba-Cloud-Sign插件weltolk_sign_qq测试消息" + . "\n\n" . "第1/2页"; + + $c = new wcurl($url, $headers); + $c->setTimeOut(5000); + + $res = $c->post($send); + $res = json_decode($res, TRUE); + if ($res['retcode'] == 0 + && $res['status'] == 'ok' + // go-cqhttp HTTP API post 未支持echo +// && $res['echo'] == $sign + ) { + } else { + $cache_status = false; + } + + usleep(250000); + + $send["params"]["message"] = + $date_cache + . "\n\n" + . '!! ' + . ' ' . '测试百度账号' + . ' 账号的 ' . '测试百度贴吧' . ' 吧: ' + . '签到失败' . '\n' + . '!!' . ' 详细信息: ' . '签到超时' + . "\n\n" . "第2/2页"; + + $c = new wcurl($url, $headers); + $c->setTimeOut(5000); + + $res = $c->post($send); + $res = json_decode($res, TRUE); + if ($res['retcode'] == 0 + && $res['status'] == 'ok' + // go-cqhttp HTTP API post 未支持echo +// && $res['echo'] == $sign + ) { + } else { + $cache_status = false; + } + + if ($cache_status) { + $return_arr = array('code' => 1, 'msg' => '两条测试消息已经发送到' . $cache_type_id . ',请注意查看!'); + } else { + $return_arr = array('code' => 0, 'msg' => '发送给' . $cache_type_id . '的测试消息发送失败!'); + } + + } else { + + } + } else { + + } + } + if ($return_arr['code'] == 1) { + $msg_html = '
    '; + } else { + $msg_html = '
    '; + } + $msg_html .= ' ' . $return_arr['msg'] . '
    '; + + echo json_encode(array('code' => $return_arr['code'], 'msg' => $msg_html)); + die; + break; + case 'addqq'://添加推送目标 + $connect_id = !empty($_POST['connect_id']) ? addslashes(strip_tags($_POST['connect_id'])) : msg('请输入使用的推送地址'); + $hour = $_POST['hour']; + if ($hour == '0') { + + } else if (empty($hour)) { + msg('请输入每日推送时间'); + } else { + $hour = addslashes(strip_tags($hour)); + } + if ($hour >= 0 && $hour <= 23) { + + } else { + msg("请输入正确的每日推送时间"); + } + $date_cache = strtotime(date('Y-m-d')); + $type = !empty($_POST['type']) ? addslashes(strip_tags($_POST['type'])) : msg('请输入类型'); + $type_id = !empty($_POST['type_id']) ? addslashes(strip_tags($_POST['type_id'])) : msg('请输入号'); + $type_id = explode("\n", trim($type_id)); + $anchor = addslashes(strip_tags($_POST['anchor'])); + foreach ($type_id as $type_id_i) { + $type_id_i = trim($type_id_i); + if (!empty($type_id_i)) { + $m->query("INSERT INTO `" . DB_PREFIX . "weltolk_sign_qq_target` (`uid`, `connect_id`, `hour`, `type`, `type_id`,`nextdo`)" + . " SELECT '" . UID . "', '{$connect_id}', '{$hour}', '{$type}', '{$type_id_i}', '{$date_cache}'" + . " WHERE NOT EXISTS ( SELECT * FROM `" . DB_PREFIX . "weltolk_sign_qq_target`" + . " WHERE `uid` = '" . UID . "' AND `connect_id` = '{$connect_id}' AND `hour` = '{$hour}'" + . " AND `type` = '{$type}' AND `type_id` = '{$type_id_i}')"); + } + } + ReDirect(SYSTEM_URL . 'index.php?plugin=weltolk_sign_qq&act=ok' . '#' . $anchor); + break; + case 'batchqqedit'://批量/搜索 编辑推送目标 + $anchor = addslashes(strip_tags($_POST['anchor'])); + $connect_id = !empty($_POST['connect_id']) ? addslashes(strip_tags($_POST['connect_id'])) : ""; + $connect_id2 = !empty($_POST['connect_id2']) ? addslashes(strip_tags($_POST['connect_id2'])) : ""; + if ((empty($connect_id) && !empty($connect_id2)) || (!empty($connect_id) && empty($connect_id2))) { + msg('请正确选择推送地址'); + } + $hour = (!empty($_POST['hour']) or $_POST['hour'] == 0) ? addslashes(strip_tags($_POST['hour'])) : ""; + $hour2 = (!empty($_POST['hour2']) or $_POST['hour2'] == 0) ? addslashes(strip_tags($_POST['hour2'])) : ""; + if ($hour >= 0 && $hour <= 23) { + + } else { + msg("请输入正确的每日推送时间"); + } + if ($hour2 >= 0 && $hour2 <= 23) { + + } else { + msg("请输入正确的每日推送时间"); + } + if (((empty($hour) && $hour != 0) && (!empty($hour2) || $hour2 == 0)) + || ((!empty($hour) || $hour == 0) && (empty($hour2) && $hour2 != 0))) { + msg('请正确输入每日推送时间'); + } + $type = !empty($_POST['type']) ? addslashes(strip_tags($_POST['type'])) : ""; + $type2 = !empty($_POST['type2']) ? addslashes(strip_tags($_POST['type2'])) : ""; + if ((empty($type) && !empty($type2)) || (!empty($type) && empty($type2))) { + msg('请正确选择类型'); + } + $type_id = !empty($_POST['type_id']) ? addslashes(strip_tags($_POST['type_id'])) : ""; + $type_id2 = !empty($_POST['type_id2']) ? addslashes(strip_tags($_POST['type_id2'])) : ""; + if ((empty($type_id) && !empty($type_id2)) || (!empty($type_id) && empty($type_id2))) { + msg('请正确输入号'); + } + $nextdo = !empty($_POST['nextdo']) ? addslashes(strip_tags($_POST['nextdo'])) : ""; + $nextdo2 = !empty($_POST['nextdo2']) ? addslashes(strip_tags($_POST['nextdo2'])) : ""; + if ((empty($nextdo) && !empty($nextdo2)) || (!empty($nextdo) && empty($nextdo2))) { + msg('请正确输入下次推送日期'); + } + $nextdo = strtotime($nextdo); + $nextdo2 = strtotime($nextdo2); + + $status = false; + $sql1 = "UPDATE `" . DB_PREFIX . "weltolk_sign_qq_target` SET "; + $sql2 = " WHERE "; + if (!empty($connect_id) && !empty($connect_id2)) { + if ($status) { + $sql1 .= ", `connect_id` = '{$connect_id2}'"; + $sql2 .= " AND `connect_id` = '{$connect_id}'"; + } else { + $sql1 .= "`connect_id` = '{$connect_id2}'"; + $sql2 .= "`connect_id` = '{$connect_id}'"; + } + $status = true; + } + if ((!empty($hour) or $hour == 0) + && (!empty($hour2) or $hour == 0)) { + if ($status) { + $sql1 .= ", `hour` = '{$hour2}'"; + $sql2 .= " AND `hour` = '{$hour}'"; + } else { + $sql1 .= "`hour` = '{$hour2}'"; + $sql2 .= "`hour` = '{$hour}'"; + } + $status = true; + } + if (!empty($type) && !empty($type2)) { + if ($status) { + $sql1 .= ", `type` = '{$type2}'"; + $sql2 .= " AND `type` = '{$type}'"; + } else { + $sql1 .= "`type` = '{$type2}'"; + $sql2 .= "`type` = '{$type}'"; + } + $status = true; + } + if (!empty($type_id) && !empty($type_id2)) { + if ($status) { + $sql1 .= ", `type_id` = '{$type_id2}'"; + $sql2 .= " AND `type_id` = '{$type_id}'"; + } else { + $sql1 .= "`type_id` = '{$type_id2}'"; + $sql2 .= "`type_id` = '{$type_id}'"; + } + $status = true; + } + if (!empty($nextdo) && !empty($nextdo2)) { + if ($status) { + $sql1 .= ", `nextdo` = '{$nextdo2}'"; + $sql2 .= " AND `nextdo` = '{$nextdo}'"; + } else { + $sql1 .= "`nextdo` = '{$nextdo2}'"; + $sql2 .= "`nextdo` = '{$nextdo}'"; + } + $status = true; + } + + $sql = $sql1 . $sql2; + if ($status) { + $m->query($sql); + } + ReDirect(SYSTEM_URL . 'index.php?plugin=weltolk_sign_qq&ok' . '#' . $anchor); + break; + case 'update'://编辑单条推送地址 + $id = !empty($_POST['id']) ? addslashes(strip_tags($_POST['id'])) : msg('请输入ID'); + $connect_id = !empty($_POST['connect_id']) ? addslashes(strip_tags($_POST['connect_id'])) : msg('请输入使用的推送地址'); + $hour = $_POST['hour']; + if ($hour == '0') { + + } else if (empty($hour)) { + msg('请输入每日推送时间'); + } else { + $hour = addslashes(strip_tags($hour)); + } + if ($hour >= 0 && $hour <= 23) { + + } else { + msg("请输入正确的每日推送时间"); + } + $type = !empty($_POST['type']) ? addslashes(strip_tags($_POST['type'])) : msg('请输入类型'); + $type_id = !empty($_POST['type_id']) ? addslashes(strip_tags($_POST['type_id'])) : msg('请输入号'); + $nextdo = !empty($_POST['nextdo']) ? addslashes(strip_tags($_POST['nextdo'])) : msg('请输入下次推送日期'); + $nextdo = strtotime($nextdo); + $anchor = addslashes(strip_tags($_POST['anchor'])); + $m->query("UPDATE `" . DB_PREFIX . "weltolk_sign_qq_target` " + . "SET `connect_id` = '{$connect_id}', `hour` = '{$hour}'," + . " `type` = '{$type}', `type_id` = '{$type_id}'," + . " `nextdo` = '{$nextdo}'" + . " WHERE `id` = '{$id}'"); + ReDirect(SYSTEM_URL . 'index.php?plugin=weltolk_sign_qq&ok' . '#' . $anchor); + break; + case 'del'://删除推送地址 + $id = isset($_GET['id']) ? intval($_GET['id']) : msg('缺少ID'); + $anchor = addslashes(strip_tags($_GET['anchor'])); + $m->query("DELETE FROM `" . DB_PREFIX . "weltolk_sign_qq_target` WHERE `uid` = " . UID . " AND `id` = " . $id); + ReDirect(SYSTEM_URL . 'index.php?plugin=weltolk_sign_qq&act=ok' . '#' . $anchor); + break; + default: + break; + } +} else { + +} + +?> +

    每日签到qq推送

    + +
    + + + + + + +
    + + +
    +
    + + + + + + + + + + + + + + + + + + + + query("SELECT * FROM `" . DB_PREFIX . "weltolk_sign_qq_target` WHERE `uid` = " . UID); + while ($v = $m->fetch_array($x)) { + ?> + + + + + + + + + + + + + + +
    ID使用的推送地址每日推送时间类型下次推送日期修改删除
    + + 测试推送 + 返回顶部
    +
    + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file