mirror of
https://github.com/ledccn/IYUUPlus.git
synced 2024-09-20 07:05:28 +00:00
修复:SSL证书错误
This commit is contained in:
parent
3b7a63e678
commit
e4579555ed
|
@ -93,15 +93,16 @@ class Curl
|
|||
* 简易POST
|
||||
* @param string $url
|
||||
* @param array|object|string $data
|
||||
* @param bool $asJson
|
||||
* @return false|string
|
||||
*/
|
||||
public static function http_post(string $url, $data)
|
||||
public static function http_post(string $url, $data, bool $asJson = false)
|
||||
{
|
||||
$opts = array(
|
||||
'http' => array(
|
||||
'method' => 'POST',
|
||||
'header' => 'Content-type: ' . static::CONTENT_TYPE_DEFAULT,
|
||||
'content' => (is_array($data) || is_object($data)) ? http_build_query($data) : $data,
|
||||
'header' => 'Content-type: ' . ($asJson ? static::CONTENT_TYPE_JSON : static::CONTENT_TYPE_DEFAULT),
|
||||
'content' => (is_array($data) || is_object($data)) ? ($asJson ? json_encode($data, JSON_UNESCAPED_UNICODE) : http_build_query($data)) : $data,
|
||||
'timeout' => 5
|
||||
),
|
||||
// 解决SSL证书验证失败的问题
|
||||
|
|
|
@ -135,33 +135,3 @@ function dataSize($bytes, string $delimiter = '', int $decimals = 2):string
|
|||
|
||||
return number_format($bytes, $decimals) . $delimiter . $type[$i];
|
||||
}
|
||||
|
||||
/**
|
||||
* 大写 PP 调试函数(CLI使用)
|
||||
* @param mixed $data
|
||||
* @param bool $echo
|
||||
* @return string
|
||||
*/
|
||||
function PP($data, bool $echo = false)
|
||||
{
|
||||
$hr = PHP_EOL.'******************************'.\date('Y-m-d H:i:s').PHP_EOL;
|
||||
$str = $hr;
|
||||
switch (true) {
|
||||
case is_bool($data):
|
||||
$show_data = $data ? 'true' : 'false';
|
||||
break;
|
||||
case is_null($data):
|
||||
$show_data = 'null';
|
||||
break;
|
||||
default:
|
||||
$show_data = print_r($data, true);
|
||||
break;
|
||||
}
|
||||
$str .= $show_data;
|
||||
$str .= $hr;
|
||||
if ($echo) {
|
||||
echo $str;
|
||||
return '';
|
||||
}
|
||||
return $str;
|
||||
}
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
<?php
|
||||
require_once dirname(__DIR__) . '/init.php';
|
||||
require_once ROOT_PATH . '/app/functions.php';
|
||||
require_once ROOT_PATH . '/src/helper.php';
|
||||
echo microtime(true).' 当前脚本路径:'.__FILE__.PHP_EOL;
|
||||
use IYUU\Reseed\AutoReseed;
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
<?php
|
||||
require_once dirname(__DIR__) . '/init.php';
|
||||
require_once ROOT_PATH . '/app/functions.php';
|
||||
require_once ROOT_PATH . '/src/helper.php';
|
||||
echo microtime(true).' 当前脚本路径:'.__FILE__.PHP_EOL;
|
||||
use IYUU\Reseed\MoveTorrent;
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
<?php
|
||||
require_once dirname(__DIR__) . '/init.php';
|
||||
require_once ROOT_PATH . '/app/functions.php';
|
||||
require_once ROOT_PATH . '/src/helper.php';
|
||||
echo microtime(true).' 当前脚本路径:'.__FILE__.PHP_EOL;
|
||||
|
||||
|
|
|
@ -6,6 +6,7 @@ use Exception;
|
|||
use IYUU\Client\AbstractClient;
|
||||
use IYUU\Library\IFile;
|
||||
use IYUU\Library\Table;
|
||||
use app\common\components\Curl as ICurl;
|
||||
use app\common\Constant;
|
||||
use app\domain\ConfigParser\Reseed as domainReseed;
|
||||
use app\domain\Crontab as domainCrontab;
|
||||
|
@ -1090,17 +1091,10 @@ class AutoReseed
|
|||
{
|
||||
$token = static::$conf['iyuu.cn'];
|
||||
$desp = empty($desp) ? date("Y-m-d H:i:s") : $desp;
|
||||
$postdata = http_build_query(array(
|
||||
$data = array(
|
||||
'text' => $text,
|
||||
'desp' => $desp
|
||||
));
|
||||
$opts = array('http' => array(
|
||||
'method' => 'POST',
|
||||
'header' => 'Content-type: application/x-www-form-urlencoded',
|
||||
'content' => $postdata
|
||||
));
|
||||
$context = stream_context_create($opts);
|
||||
$result = file_get_contents('https://iyuu.cn/'.$token.'.send', false, $context);
|
||||
return $result;
|
||||
);
|
||||
return ICurl::http_post('https://iyuu.cn/'.$token.'.send', $data);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -221,7 +221,7 @@ abstract class AbstractRss
|
|||
$torrent['filename'] = $id.'.torrent';
|
||||
$torrent['type'] = 0; // 免费0
|
||||
$torrent['time'] = date("Y-m-d H:i:s", $time);
|
||||
$torrent['size'] = getFilesize($length);
|
||||
$torrent['size'] = dataSize($length);
|
||||
$torrent['length'] = $length;
|
||||
$torrent['guid'] = $guid;
|
||||
$items[] = $torrent;
|
||||
|
|
|
@ -69,29 +69,30 @@ function download($url, $cookies='', $useragent='', $method = 'GET')
|
|||
"Content-Type:application/x-www-form-urlencoded",
|
||||
'User-Agent: '.$useragent);
|
||||
$ch = curl_init();
|
||||
curl_setopt($ch, CURLOPT_URL, $url);
|
||||
if ($method === 'POST') {
|
||||
curl_setopt($ch, CURLOPT_POST, true);
|
||||
}
|
||||
if (stripos($url, 'https://') === 0) {
|
||||
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
|
||||
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);
|
||||
curl_setopt($ch, CURLOPT_SSLVERSION, 1);
|
||||
//curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);
|
||||
//curl_setopt($ch, CURLOPT_SSLVERSION, 1);
|
||||
}
|
||||
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
|
||||
curl_setopt($ch, CURLOPT_HTTPHEADER, $header);
|
||||
curl_setopt($ch, CURLOPT_COOKIE, $cookies);
|
||||
curl_setopt($ch, CURLOPT_URL, $url);
|
||||
if (!empty($cookies)) {
|
||||
curl_setopt($ch, CURLOPT_COOKIE, $cookies);
|
||||
}
|
||||
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 60);
|
||||
curl_setopt($ch, CURLOPT_TIMEOUT, 600);
|
||||
// 2021年7月2日02:04:22
|
||||
#curl_setopt($ch, CURLOPT_HEADER, false);
|
||||
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1); // 自动跳转,跟随请求Location
|
||||
curl_setopt($ch, CURLOPT_MAXREDIRS, 2); // 递归次数
|
||||
|
||||
$data = curl_exec($ch);
|
||||
$status = curl_getinfo($ch);
|
||||
curl_close($ch);
|
||||
if (isset($status['http_code']) && $status['http_code'] == 200) {
|
||||
return $data;
|
||||
}
|
||||
if (isset($status['http_code']) && $status['http_code'] == 302) {
|
||||
return download($status['redirect_url'], $cookies, $useragent);
|
||||
}
|
||||
return $data;
|
||||
}
|
||||
|
||||
|
@ -120,38 +121,6 @@ function convertToMB($from)
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 字节数Byte转换为KB、MB、GB、TB
|
||||
* @param $num
|
||||
* @return string
|
||||
*/
|
||||
function getFilesize($num)
|
||||
{
|
||||
$p = 0;
|
||||
$format='bytes';
|
||||
if ($num>0 && $num<1024) {
|
||||
return number_format($num).' '.$format;
|
||||
}
|
||||
if ($num>=1024 && $num<pow(1024, 2)) {
|
||||
$p = 1;
|
||||
$format = 'KB';
|
||||
}
|
||||
if ($num>=pow(1024, 2) && $num<pow(1024, 3)) {
|
||||
$p = 2;
|
||||
$format = 'MB';
|
||||
}
|
||||
if ($num>=pow(1024, 3) && $num<pow(1024, 4)) {
|
||||
$p = 3;
|
||||
$format = 'GB';
|
||||
}
|
||||
if ($num>=pow(1024, 4) && $num<pow(1024, 5)) {
|
||||
$p = 3;
|
||||
$format = 'TB';
|
||||
}
|
||||
$num /= pow(1024, $p);
|
||||
return number_format($num, 2).$format;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief 种子过滤器
|
||||
* @param array $filter 站点标识
|
||||
|
@ -336,8 +305,8 @@ function ShowTableSites($dir = 'Protocols', $filter = array())
|
|||
{
|
||||
// 过滤的文件
|
||||
switch ($dir) {
|
||||
case 'Protocols':
|
||||
$filter = ['axxxx','decodeBase'];
|
||||
case 'Spiders':
|
||||
$filter = ['SitesBase'];
|
||||
break;
|
||||
case 'Rss':
|
||||
$filter = ['AbstractRss'];
|
||||
|
|
|
@ -276,7 +276,7 @@ function cpu_count() {
|
|||
* CLI打印调试
|
||||
* @param $data
|
||||
* @param bool $echo
|
||||
* @return string|null
|
||||
* @return string
|
||||
*/
|
||||
function cli($data, $echo = true)
|
||||
{
|
||||
|
@ -292,7 +292,7 @@ function cli($data, $echo = true)
|
|||
$str .= PHP_EOL.'----------------------------------------memory_get_usage:'.memory_get_usage(true).PHP_EOL.PHP_EOL;
|
||||
if ($echo) {
|
||||
echo $str;
|
||||
return null;
|
||||
return '';
|
||||
}
|
||||
return $str;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user