From e40cc6d3ae58cc10c845da7c928f185c9ab32e81 Mon Sep 17 00:00:00 2001 From: filesite Date: Thu, 10 Mar 2022 22:22:16 +0800 Subject: [PATCH] add functions to get private variables --- lib/DirScanner.php | 25 +++++++++++++++++++++++++ test/DirScannerTest.php | 9 ++++++--- 2 files changed, 31 insertions(+), 3 deletions(-) diff --git a/lib/DirScanner.php b/lib/DirScanner.php index 6793687..bfd14d3 100644 --- a/lib/DirScanner.php +++ b/lib/DirScanner.php @@ -145,6 +145,11 @@ Class DirScanner { } } + //获取Nginx防盗链密钥 + public function getNginxSecret() { + return $this->nginxSecret; + } + //设置Nginx防盗链密钥 public function setUserIp($userIp) { if (!empty($userIp) && is_string($userIp)) { @@ -152,6 +157,11 @@ Class DirScanner { } } + //获取Nginx防盗链密钥 + public function getUserIp() { + return $this->userIp; + } + //设置Nginx防盗链MD5加密方式 /** * Nginx防盗链MD5加密方式参考下面网址中的示例, @@ -169,6 +179,11 @@ Class DirScanner { } } + //获取Nginx防盗链MD5加密方式 + public function getNginxSecureLinkMd5Pattern() { + return $this->nginxSecureLinkMd5Pattern; + } + //设置Nginx防盗链超时时长,单位:秒 public function setNginxSecureTimeout($timeout) { if ((int)$timeout > 0) { @@ -176,6 +191,16 @@ Class DirScanner { } } + //获取Nginx防盗链超时时长,单位:秒 + public function getNginxSecureTimeout() { + return $this->nginxSecureTimeout; + } + + //获取是否开启防盗链 + public function isSecureOn() { + return $this->nginxSecureOn; + } + //扫描目录获取目录和文件列表,支持指定目录扫描深度(目录级数) public function scan($dir, $levels = 3) { } diff --git a/test/DirScannerTest.php b/test/DirScannerTest.php index 2accff2..8db8f01 100644 --- a/test/DirScannerTest.php +++ b/test/DirScannerTest.php @@ -23,8 +23,11 @@ class DirScannerTest extends DirScanner { echo "\n"; echo "==function secureLink==\n"; - echo "secret: {$secret}\n"; - echo "user ip: {$userIp}\n"; + echo "secret: " . $this->getNginxSecret() . "\n"; + echo "user ip: " . $this->getUserIp() . "\n"; + echo "timeout: " . $this->getNginxSecureTimeout() . " seconds\n"; + echo "secure link md5: " . $this->getNginxSecureLinkMd5Pattern() . "\n"; + echo "path: {$path}\n"; $url = $this->getSecureLink($path); echo "secure link: {$url}\n"; echo "\n"; @@ -35,4 +38,4 @@ class DirScannerTest extends DirScanner { //--调用测试方法-- $scanner = new DirScannerTest(); -$scanner->secureLinkTest('/default/'); +$scanner->secureLinkTest('/default/', 'foo=bar', '127.0.0.1');