diff options
author | Nicolas LÅ“uillet <nicolas@loeuillet.org> | 2015-08-03 13:21:11 +0200 |
---|---|---|
committer | Nicolas LÅ“uillet <nicolas@loeuillet.org> | 2015-08-03 13:21:11 +0200 |
commit | c766284d522206578e7ec154961e0fce456f70c8 (patch) | |
tree | a5246151bf8278a0e8053b9dd1ce9d770073c50b /inc/poche/Tools.class.php | |
parent | c0cb52c07439c974075c302a190a034a8cce4f92 (diff) | |
parent | e968ec6c2244aee600358b3c87648b2409c97945 (diff) | |
download | wallabag-c766284d522206578e7ec154961e0fce456f70c8.tar.gz wallabag-c766284d522206578e7ec154961e0fce456f70c8.tar.zst wallabag-c766284d522206578e7ec154961e0fce456f70c8.zip |
Merge pull request #1267 from wallabag/dev1.9.1
1.9.1
Diffstat (limited to 'inc/poche/Tools.class.php')
-rwxr-xr-x | inc/poche/Tools.class.php | 39 |
1 files changed, 35 insertions, 4 deletions
diff --git a/inc/poche/Tools.class.php b/inc/poche/Tools.class.php index d0b31d4f..9c748391 100755 --- a/inc/poche/Tools.class.php +++ b/inc/poche/Tools.class.php | |||
@@ -40,6 +40,8 @@ final class Tools | |||
40 | */ | 40 | */ |
41 | public static function getPocheUrl() | 41 | public static function getPocheUrl() |
42 | { | 42 | { |
43 | $baseUrl = ""; | ||
44 | |||
43 | $https = (!empty($_SERVER['HTTPS']) | 45 | $https = (!empty($_SERVER['HTTPS']) |
44 | && (strtolower($_SERVER['HTTPS']) == 'on')) | 46 | && (strtolower($_SERVER['HTTPS']) == 'on')) |
45 | || (isset($_SERVER["SERVER_PORT"]) | 47 | || (isset($_SERVER["SERVER_PORT"]) |
@@ -72,8 +74,15 @@ final class Tools | |||
72 | $serverport = ''; | 74 | $serverport = ''; |
73 | } | 75 | } |
74 | 76 | ||
75 | return 'http' . ($https ? 's' : '') . '://' | 77 | // check if BASE_URL is configured |
76 | . $host . $serverport . $scriptname; | 78 | if(BASE_URL) { |
79 | $baseUrl = BASE_URL; | ||
80 | } else { | ||
81 | $baseUrl = 'http' . ($https ? 's' : '') . '://' . $host . $serverport; | ||
82 | } | ||
83 | |||
84 | return $baseUrl . $scriptname; | ||
85 | |||
77 | } | 86 | } |
78 | 87 | ||
79 | /** | 88 | /** |
@@ -392,8 +401,11 @@ final class Tools | |||
392 | ); | 401 | ); |
393 | 402 | ||
394 | foreach ($files as $fileInfo) { | 403 | foreach ($files as $fileInfo) { |
395 | $todo = ($fileInfo->isDir() ? 'rmdir' : 'unlink'); | 404 | $filename = $fileInfo->getFilename(); |
396 | $todo($fileInfo->getRealPath()); | 405 | if (!$filename[0] == '.') { |
406 | $todo = ($fileInfo->isDir() ? 'rmdir' : 'unlink'); | ||
407 | $todo($fileInfo->getRealPath()); | ||
408 | } | ||
397 | } | 409 | } |
398 | 410 | ||
399 | Tools::logm('empty cache'); | 411 | Tools::logm('empty cache'); |
@@ -417,4 +429,23 @@ final class Tools | |||
417 | return str_replace('+', '', $token); | 429 | return str_replace('+', '', $token); |
418 | } | 430 | } |
419 | 431 | ||
432 | /** | ||
433 | * | ||
434 | * Returns the doctype for an HTML document (used for Mozilla Bookmarks) | ||
435 | * @param simple_html_dom $doc | ||
436 | * @return doctype $el | ||
437 | * | ||
438 | */ | ||
439 | |||
440 | public static function get_doctype($doc) | ||
441 | { | ||
442 | $els = $doc->find('unknown'); | ||
443 | |||
444 | foreach ($els as $e => $el) | ||
445 | if ($el->parent()->tag == 'root') | ||
446 | return $el; | ||
447 | |||
448 | return NULL; | ||
449 | } | ||
450 | |||
420 | } | 451 | } |