Browse Source

add functions to get private variables

master
filesite 3 years ago
parent
commit
e40cc6d3ae
  1. 25
      lib/DirScanner.php
  2. 9
      test/DirScannerTest.php

25
lib/DirScanner.php

@ -145,6 +145,11 @@ Class DirScanner { @@ -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 { @@ -152,6 +157,11 @@ Class DirScanner {
}
}
//获取Nginx防盗链密钥
public function getUserIp() {
return $this->userIp;
}
//设置Nginx防盗链MD5加密方式
/**
* Nginx防盗链MD5加密方式参考下面网址中的示例,
@ -169,6 +179,11 @@ Class DirScanner { @@ -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 { @@ -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) {
}

9
test/DirScannerTest.php

@ -23,8 +23,11 @@ class DirScannerTest extends DirScanner { @@ -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 { @@ -35,4 +38,4 @@ class DirScannerTest extends DirScanner {
//--调用测试方法--
$scanner = new DirScannerTest();
$scanner->secureLinkTest('/default/');
$scanner->secureLinkTest('/default/', 'foo=bar', '127.0.0.1');

Loading…
Cancel
Save