Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
pro
bpwiki
Commits
641e8a36
Commit
641e8a36
authored
Nov 12, 2015
by
Krzysztof Kutt
Browse files
refresh-cache.php script added (for use cases)
parent
f84bf93b
Changes
1
Hide whitespace changes
Inline
Side-by-side
bpwiki-cases/refresh-cache.php
0 → 100644
View file @
641e8a36
<?php
/**
* Loki Refresh Script - Script that refreshes cache (prolog cache in Loki and 'standard'
* DokuWiki cache. To achieve this, script opens every page in
* specified namespaces (each namespace is one use case). While
* page is opened, cache is automatically refreshed.
*
* @author GEIST Research Group <geist@agh.edu.pl>
*/
/****** PACKAGE SPECIFIC CONFIG ******/
$use_cases
=
array
(
"bpwiki"
);
/****** GENERAL SCRIPT FOR LOKI USE CASES ******/
if
(
!
file_exists
(
'doku.php'
)){
echo
"ERROR: Script should be placed in main DokuWiki directory!"
;
die
();
}
//specify which userewrite type is used in DokuWiki:
$dokuwiki_prefix
=
"doku.php?id="
;
require
'conf/local.php'
;
if
(
isset
(
$conf
[
'userewrite'
])){
switch
(
$conf
[
'userewrite'
])
{
case
0
:
//default "doku.php?id="
break
;
case
1
:
$dokuwiki_prefix
=
""
;
break
;
case
2
:
$dokuwiki_prefix
=
"doku.php/"
;
break
;
}
}
//absolute pages directory:
$pages_dir
=
getcwd
()
.
'/data/pages/'
;
//wiki location -- full base URI, e.g. http://loki.ia.agh.edu.pl/wiki/
$wiki_relative_uri
=
substr
(
$_SERVER
[
'REQUEST_URI'
],
0
,
strlen
(
$_SERVER
[
'REQUEST_URI'
])
-
strlen
(
strrchr
(
$_SERVER
[
'REQUEST_URI'
],
"/"
)));
$protocol
=
"http://"
;
if
(
isset
(
$_SERVER
[
'HTTPS'
]))
{
$protocol
=
"https://"
;
}
$wiki_location
=
$protocol
.
$_SERVER
[
'HTTP_HOST'
]
.
$wiki_relative_uri
.
'/'
;
//prepare and explore URLs for each page in each specified use case:
foreach
(
$use_cases
as
$case
){
echo
"Refreshing cache in
\"
$case
\"
case..."
;
$Directory
=
new
RecursiveDirectoryIterator
(
$pages_dir
.
$case
);
$Iterator
=
new
RecursiveIteratorIterator
(
$Directory
);
$Regex
=
new
RegexIterator
(
$Iterator
,
'/^.+\.txt$/i'
,
RecursiveRegexIterator
::
GET_MATCH
);
foreach
(
$Regex
as
$name
=>
$Regex
){
//get relative path for each file (and remove ".txt" at the end):
$wiki_page_uri
=
substr
(
$name
,
strlen
(
$pages_dir
),
strlen
(
$name
)
-
strlen
(
$pages_dir
)
-
4
);
//change "/" into ":"
$wiki_page_uri
=
str_replace
(
"/"
,
":"
,
$wiki_page_uri
);
//concatenate parts into final page uri:
$wiki_page_uri
=
$wiki_location
.
$wiki_page_uri
;
//open page to refresh cache (get only 1 byte to reduce transfer)
file_get_contents
(
$wiki_page_uri
,
0
,
null
,
0
,
1
);
}
echo
"DONE!<br />"
;
}
?>
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment