php 海运,海运的博客

发布时间:March 5, 2021 // 分类:PT // No Comments

--- Bencode.php.1 2021-02-24 07:30:41.677067125 +0800

+++ Bencode.php 2021-03-05 17:52:23.803081067 +0800

@@ -26,6 +26,9 @@

*/

class Bencode

{

+ public function info_hash($data, $info_hash) {

+ return sha1(substr($data, $info_hash['pos'], $info_hash['length']));

+ }

/**

* Decode bencoded data from string

*

@@ -46,7 +49,15 @@

$return = [];

while ($data[$pos] !== 'e') {

$key = self::decode($data, $pos);

+ if (!strcmp($key, "info")) {

+ //if ($key === "info") {

+ $return['info_hash']['pos'] = $pos;

+ }

$value = self::decode($data, $pos);

+ if (!strcmp($key, "info")) {

+ //if ($key === "info") {

+ $return['info_hash']['length'] = ($pos - $return['info_hash']['pos']);

+ }

if ($key === null || $value === null) {

break;

}

@@ -125,6 +136,9 @@

$return = '';

$check = -1;

$list = true;

+ if (isset($data['info_hash'])) {

+ unset($data['info_hash']);

+ }

foreach ($data as $key => $value) {

if ($key !== ++$check) {

$list = false;

解析种子torrent所包含的文件名称信息,将名称和文件大小组合排序并计算sha,sha相同则2个种子内容一样可自动辅种。<?php

require_once './Bencode.php';

require_once './ParseErrorException.php';

$bencode = new Bencode();

$str = file_get_contents($filename);

$s = $bencode->decode($str);

if (isset($s['info']["files"])) {

foreach ($s['info']["files"] as $v) {

$length = $v["length"];

$file = end($v["path"]);

$save[] = $length.$file;

}

} else {

$length = $s['info']["length"];

$file = $s['info']["name"];

$save[] = $length.$file;

}

if (isset($s["encoding"])) {

$coding = $s["encoding"];

} else {

$coding = mb_detect_encoding(implode('', $save), ['UTF-8', 'GB18030', 'GBK', 'GB2312', 'ISO-8859-1']);

echo 'detect encoding: '.$coding.PHP_EOL;

}

if (!$coding) {

$coding = 'UTF-8';

}

if ($coding != "UTF-8") {

foreach ($save as $k => $v) {

$save[$k] = mb_convert_encoding($v, "UTF-8", $coding);

}

}

sort($save);

$sha1 = sha1(implode('', $save));

发布时间:March 1, 2021 // 分类: // 3 Comments

最近斯巴达vps比较火,一机难求,写了个js脚本用于抢购,效果还不错,推荐使用chrome浏览器,安装Tampermonkey扩展使用。// ==UserScript==

// @name 自动抢购买vps

// @namespace https://www.haiyun.me

// @version 0.1

// @description buy spartanhost vps

// @author www.haiyun.me

// @match https://billing.spartanhost.net/cart.php?a=*

// @grant none

// ==/UserScript==

(function() {

var forcedReload = false;

var time = 500;

var url = document.URL;

var hostname = "www.haiyun.me";

var customfield = "website";

if (document.title == '502 Bad Gateway') {

setTimeout(function() {

window.location.reload(forcedReload);

}, time);

} else if (document.title == '504 Gateway Time-out') {

setTimeout(function() {

window.location.reload(forcedReload);

}, time);

} else if (document.title == '503 Service Temporarily Unavailable') {

setTimeout(function() {

window.location.reload(forcedReload);

}, time);

} else if (document.title == '500 Internal Server Error') {

setTimeout(function() {

window.location.reload(forcedReload);

}, time);

} else if (document.getElementsByTagName('h1')[0].innerHTML == '无法访问此网站') {

setTimeout(function() {

window.location.reload(forcedReload);

}, time);

}

if (url.indexOf("https://billing.spartanhost.net/cart.php?a=add") != -1) {

var str = document.getElementById("order-boxes").innerHTML;

if (str.indexOf("Out of Stock") != -1) {

setTimeout(function() {

window.location.reload(forcedReload);

}, time);

}

} else if (url.indexOf("https://billing.spartanhost.net/cart.php?a=confproduct") != -1) {

document.getElementById("inputHostname").value = hostname;

var element = document.querySelector('input[name^="customfield"]');

element.value = customfield;

document.getElementById("btnCompleteProductConfig").click();

} else if (url.indexOf("https://billing.spartanhost.net/cart.php?a=view") != -1) {

document.getElementById("checkout").click();

} else if (url.indexOf("https://billing.spartanhost.net/cart.php?a=checkout") != -1) {

document.getElementById("iCheck-accepttos").click();

document.getElementById("btnCompleteOrder").click();

}

})();

发布时间:February 24, 2021 // 分类: // No Comments

查看网卡名称及编号:netsh int ipv4 show int

查看当前ip地址:netsh int ipv4 show ipadd level=verbose

开启dhcp和静态ip共存:netsh int ipv4 set int "Ethernet0" dhcpstaticipcoexistence=enabled

添加ip地址,skipassource设置是否使用此ip为出口源ip,默认新添加的ip为出口ip:netsh int ipv4 add add "Ethernet0" 192.168.1.22/24 skipassource=true

已添加的ip修改skipassource参数:Get-NetIPAddress 192.168.1.22 | Set-NetIPAddress -SkipAsSource $True

Set-NetIPAddress -IPAddress "192.168.1.22" -InterfaceAlias "Ethernet0" -SkipAsSource $false

多网卡可修改路由及网卡metric跃点数指定优先网络出口:netsh int ipv4 show rou

netsh int ipv4 set int "Ethernet0" metric=2

netsh int ipv4 set rou 0.0.0.0/0 "Ethernet0" 192.168.1.1 metric=100

route change 0.0.0.0 mask 0.0.0.0 192.168.1.1 metric 100 if 4

发布时间:February 24, 2021 // 分类:N1,K2P // No Comments

k2p主路由地址:192.168.1.1

n1盒子地址:192.168.1.2

k2p添加低优先级默认路由走n1,此路由只有pppoe断开后才有效:ip rou add default via 192.168.1.2 dev br-lan metric 1000

n1盒子用netplan配置无线网络默认路由和无线热点的路由优先级,默认情况下走k2p主路由,当路由器pppoe不能连接时打开手机无线热点则自动走手机4g网络连接。network:

version: 2

renderer: networkd

ethernets:

eth0:

addresses:

- 192.168.1.2/24

dhcp4: false

dhcp6: true

accept-ra: true

#gateway4: 192.168.1.1

routes:

- to: 0.0.0.0/0

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值