fix: 修复文件操作和目录创建的异常问题
3 个文件变更
+12
-3
13172193298@163.com
| •MPHX/bt_api.php | +6 -1 |
| •MPHX/bt_docker.php | +3 -1 |
| •MPHX/bt_proxy.php | +3 -1 |
变更内容
diff --git a/MPHX/bt_api.php b/MPHX/bt_api.php
index a5b678c..26ccced 100644
--- a/MPHX/bt_api.php
+++ b/MPHX/bt_api.php
@@ -1403,9 +1403,14 @@ class bt_api
private function HttpPostCookie($url, $data, $timeout = 60, $connectTimeout = 10)
{
$cookie_file = ROOT . 'api/cookie/' . md5($this->BT_PANEL) . '.cookie';
+ if (!is_dir(dirname($cookie_file))) {
+ @mkdir(dirname($cookie_file), 0755, true);
+ }
if (!file_exists($cookie_file)) {
$fp = fopen($cookie_file, 'w+');
- fclose($fp);
+ if (is_resource($fp)) {
+ fclose($fp);
+ }
}
$ch = curl_init();
diff --git a/MPHX/bt_docker.php b/MPHX/bt_docker.php
index 270c149..9112d9d 100644
--- a/MPHX/bt_docker.php
+++ b/MPHX/bt_docker.php
@@ -344,7 +344,9 @@ class bt_docker
}
if (!file_exists($cookie_file)) {
$fp = fopen($cookie_file, 'w+');
- fclose($fp);
+ if (is_resource($fp)) {
+ fclose($fp);
+ }
}
$ch = curl_init();
diff --git a/MPHX/bt_proxy.php b/MPHX/bt_proxy.php
index a1053b0..bb8db22 100644
--- a/MPHX/bt_proxy.php
+++ b/MPHX/bt_proxy.php
@@ -104,7 +104,9 @@ class bt_proxy
}
if (!file_exists($cookie_file)) {
$fp = fopen($cookie_file, 'w+');
- fclose($fp);
+ if (is_resource($fp)) {
+ fclose($fp);
+ }
}
$ch = curl_init();