【php源码】看小姐姐唱歌,来自52pj某网友发帖挨删了
『回复列表(44|隐藏机器人聊天)』
如果不存在一个叫
next
的cookie
,则设置一个新的。
const cookiesMap = new Map(document.cookie.split('; ').map(cookie => cookie.split('=')).map(([name, value]) => [decodeURIComponent(name), decodeURIComponent(value)]));
if (!cookiesMap.has('next')) {
const nextValue = '{"play_addr":"https://v11-cold.douyinvod.com/d63bb47ebac366828348c6ef6b914a45/6458cfe0/video/tos/cn/tos-cn-ve-15/ok3EDlbrgEW9AI1kjDUKOrejAoAtNXbcBzQfno/?a=1128&ch=0&cr=0&dr=0&cd=0%7C0%7C0%7C0&cv=1&br=1586&bt=1586&cs=0&ds=3&ft=nK5C30071u7vpihBH6xRf4pHT4BO5.DQqhdz7tG&mime_type=video_mp4&qs=0&rc=ZTo7NGU1N2lpNDw7aGRoM0BpanNlPGU6ZmdxaDMzNGkzM0AxX2IvM2BiX18xNWFiMWNeYSNzNW82cjRvL2pgLS1kLWFzcw%3D%3D&l=2023050817324680B3BA69F50CC900CB44&btag=e00090000","video_id":"v0d00fg10000cemn2drc77ub99rb8pvg","run_time":"1,024.2","new_play_addr":"blob:https://xiaojiejie.tlip.cn/aa9ca169-de30-4865-8947-b0b4bf17b9e5"}';
setCookie('next', nextValue, 60);
}
function setCookie(name, value, expireSeconds, path='/') {
const expires = new Date();
expires.setTime(expires.getTime() + expireSeconds * 1000);
const cookieValue = encodeURIComponent(name) + '=' + encodeURIComponent(value) + (expires ? '; expires=' + expires.toUTCString() : '') + '; path=' + path;
cookiesMap.set(name, cookieValue);
document.cookie = cookieValue;
}
完整代码在5楼
代码需要审核,有点麻烦,所以5楼不改了,需要你自己动手替换代码进
Joyful.php
文件中
一个是报错:Uncaught TypeError: count(): Argument #1 ($value) must be of type Countable|array, null given in.....
原因:
这个错误的意思是 count() 函数的第一个参数必须是可数的数组,但实际传递了一个 null。通常这种错误发生在尝试使用 count() 函数计算非数组变量的长度时。
为了解决这个错误,我们需要确保 count() 函数的第一个参数是一个可数的数组。为此,我们可以使用 PHP 中的 is_array() 函数和 empty() 函数进行检查。如果变量是一个空数组,那么我们可以将它视为不可数的,并将其设置为一个空数组。
解决方案:加数组判断以及非空检验。
另一个是警告:Warning: Undefined array key 0 in......
原因:服务器缓存文件Joyful.txt
里是空值。
解决:删除缓存文件,然后用户自己刷新页面就好了,服务器会重新生成一个新的缓存文件。
// 变更前
function get_video_id($Api)
{
$cache = __DIR__ . '/Joyful.txt';
if (is_file($cache)) {
$Data = unserialize(file_get_contents($cache));
if (count($Data) == 0) {
$Data = json_decode(file_get_contents($cache), true);
}
} else {
$Data = json_decode(file_get_contents($Api), true);
}
$key = rand(0, count($Data) - 1);
$video_id = $Data[$key];
unset($Data[$key]);
file_put_contents($cache, serialize(array_values($Data)));
return $video_id;
}
变更后
// 变更后
function get_video_id($Api)
{
$cache = __DIR__ . '/Joyful.txt';
if (is_file($cache)) {
$Data = unserialize(file_get_contents($cache));
if (!is_array($Data)) {
$Data = json_decode(file_get_contents($cache), true);
if (!is_array($Data)) {
$Data = array();
}
}
} else {
$Data = json_decode(file_get_contents($Api), true);
}
if (empty($Data)) {
unlink($cache); // 删除缓存文件
$Data = json_decode(file_get_contents($Api), true);
}
$key = !empty($Data) ? rand(0, count($Data) - 1) : null;
$video_id = isset($Data[$key]) ? $Data[$key] : null;
if ($key !== null && $video_id !== null) {
unset($Data[$key]);
file_put_contents($cache, serialize(array_values($Data)));
}
return $video_id;
}