php alert函数 403报错,functions.php

/**

* PanDownload 网页复刻版,PHP 语言版函数文件

*

* 务必要保证此文件存在,否则整个服务将会不可使用!

*

* 请勿随意修改此文件!如需更改相关配置请到 config.php !

*

* @version 1.3.6

*

* @author Yuan_Tuo

* @link https://imwcr.cn/

* @link https://space.bilibili.com/88197958

*

* @author LC

* @link https://lcwebsite.cn/

* @link https://space.bilibili.com/52618445

*/

if (!defined('init')){ // 直接访问处理程序

http_response_code(403); header('Content-Type: text/plain; charset=utf-8'); header('Refresh: 3;url=./'); define('init', true);

if (file_exists('config.php')) {

require('config.php');

die("HTTP 403 禁止访问!\r\n此文件是 PanDownload 网页复刻版 PHP 语言版项目版本 " . programVersion . " 的有关文件!\r\n禁止直接访问!");

} else {

http_response_code(503); header('Refresh: 5;url=https://github.com/yuantuo666/baiduwp-php');

die("HTTP 503 服务不可用!\r\n缺少相关配置和定义文件!无法正常运行程序!\r\n请重新 Clone 项目并配置!\r\n将在五秒内跳转到 GitHub 储存库!");

}

}

// main

function setCurl(&$ch, array $header) { // 批处理 curl

$a = curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); // 忽略证书

$b = curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0); // 不检查证书与域名是否匹配(2为检查)

$c = curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); // 以字符串返回结果而非输出

$d = curl_setopt($ch, CURLOPT_HTTPHEADER, $header); // 请求头

return($a&&$b&&$c&&$d);

}

function post(string $url, $data, array $header) { // POST 发送数据

$ch = curl_init($url);

setCurl($ch, $header);

curl_setopt($ch, CURLOPT_POST, true); // POST 方法

curl_setopt($ch, CURLOPT_POSTFIELDS, $data); // POST 的数据

$result = curl_exec($ch);

curl_close($ch);

return $result;

}

function get(string $url, array $header) { // GET 请求数据

$ch = curl_init($url);

setCurl($ch, $header);

$result = curl_exec($ch);

curl_close($ch);

return $result;

}

function head(string $url, array $header) { // 获取响应头

$ch = curl_init($url);

setCurl($ch, $header);

curl_setopt($ch, CURLOPT_HEADER, true); // 返回响应头

curl_setopt($ch, CURLOPT_NOBODY, true); // 只要响应头

curl_setopt($ch, CURLOPT_FOLLOWLOCATION, false);

$response = curl_exec($ch);

$header_size = curl_getinfo($ch, CURLINFO_HEADER_SIZE); // 获得响应头大小

$result = substr($response, 0, $header_size); // 根据头大小获取头信息

curl_close($ch);

return $result;

}

function getSubstr(string $str, string $leftStr, string $rightStr) {

$left = strpos($str, $leftStr); // echo '左边:'.$left;

$right = strpos($str, $rightStr, $left); // echo '
右边:'.$right;

if ($left < 0 or $right < $left) return '';

$left += strlen($leftStr);

return substr($str, $left, $right - $left);

}

function formatSize(float $size, int $times = 0) { // 格式化size显示 PHP版本过老会报错

if ($size > 1024) {

$size /= 1024;

return formatSize($size, $times + 1); // 递归处理

} else {

switch ($times) {

case '0':

$unit = ($size == 1) ? 'Byte' : 'Bytes'; break;

case '1':

$unit = 'KB'; break;

case '2':

$unit = 'MB'; break;

case '3':

$unit = 'GB'; break;

case '4':

$unit = 'TB'; break;

case '5':

$unit = 'PB'; break;

case '6':

$unit = 'EB'; break;

case '7':

$unit = 'ZB'; break;

default:

$unit = '单位未知';

}

return sprintf('%.3f', $size) . $unit;

}

}

function CheckPassword() { // 校验密码

if (IsCheckPassword) {

if (!isset($_POST["Password"])) {

if (isset($_SESSION["Password"])) {

if ($_SESSION["Password"] === Password) {

echo (isset($_POST["dir"]) || isset($_SESSION["ShowAlert"])) ? ''

: '';

$_SESSION['ShowAlert'] = true; return;

}

}

} else {

if ($_POST["Password"] === Password) {

$_SESSION['Password'] = $_POST["Password"];

echo (isset($_POST["dir"]) || isset($_SESSION["ShowAlert"])) ? ''

: '';

$_SESSION['ShowAlert'] = true; return;

}

}

die('

错误

密码错误!

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值