Feature #545: function to deploy the index and nav templates
Should deploy the html files with its template variables replaced into the awstats root.
This commit is contained in:
@@ -98,6 +98,83 @@ function awstatsDoSingleDomain($domain, $outputdir) {
|
||||
}
|
||||
|
||||
|
||||
function awstatsGenerateIndex($domain, $outputdir) {
|
||||
|
||||
// Generation header
|
||||
$header = "<!-- GENERATED BY FROXLOR -->\n";
|
||||
|
||||
// Looking for {year}-{month} directories
|
||||
$entries = array();
|
||||
foreach (scandir($outputdir) as $a) {
|
||||
if (is_dir(makeCorrectDir($outputdir . '/' . $a)) && preg_match('/^[0-9]{4}-[0-9]{2}$/', $a)) {
|
||||
array_push($entries, '<option value="' . $a . '">' . $a . '</option>');
|
||||
}
|
||||
}
|
||||
|
||||
// These are the variables we will replace
|
||||
$regex = array(
|
||||
'/\{SITE_DOMAIN\}/',
|
||||
'/\{SELECT_ENTRIES\}/'
|
||||
);
|
||||
|
||||
$replace = array(
|
||||
$domain,
|
||||
implode($entries)
|
||||
);
|
||||
|
||||
// File names
|
||||
$index_file = FROXLOR_INSTALL_DIR.'/templates/misc/awstats/index.html';
|
||||
$index_file = makeCorrectFile($index_file);
|
||||
$nav_file = FROXLOR_INSTALL_DIR.'/templates/misc/awstats/nav.html';
|
||||
$nav_file = makeCorrectFile($nav_file);
|
||||
|
||||
// Write the index file
|
||||
{
|
||||
// 'index.html' used to be a symlink
|
||||
unlink(makeCorrectFile($outputdir . '/' . 'index.html'));
|
||||
|
||||
$awstats_index_file = fopen(makeCorrectFile($outputdir . '/' . 'index.html'), 'w');
|
||||
$awstats_index_tpl = fopen($index_file, 'r');
|
||||
|
||||
// Write the header
|
||||
fwrite($awstats_index_file, $header);
|
||||
|
||||
// Write the configuration file
|
||||
while (($line = fgets($awstats_index_tpl, 4096)) !== false) {
|
||||
if (!preg_match('/^#/', $line)
|
||||
&& trim($line) != ''
|
||||
) {
|
||||
fwrite($awstats_index_file, preg_replace($regex, $replace, $line));
|
||||
}
|
||||
}
|
||||
fclose($awstats_index_file);
|
||||
fclose($awstats_index_tpl);
|
||||
}
|
||||
|
||||
// Write the nav file
|
||||
{
|
||||
$awstats_nav_file = fopen(makeCorrectFile($outputdir . '/' . 'nav.html'), 'w');
|
||||
$awstats_nav_tpl = fopen($nav_file, 'r');
|
||||
|
||||
// Write the header
|
||||
fwrite($awstats_nav_file, $header);
|
||||
|
||||
// Write the configuration file
|
||||
while (($line = fgets($awstats_nav_tpl, 4096)) !== false) {
|
||||
if (!preg_match('/^#/', $line)
|
||||
&& trim($line) != ''
|
||||
) {
|
||||
fwrite($awstats_nav_file, preg_replace($regex, $replace, $line));
|
||||
}
|
||||
}
|
||||
fclose($awstats_nav_file);
|
||||
fclose($awstats_nav_tpl);
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
function callAwstatsGetTraffic($customerid, $outputdir, $usersdomainlist) {
|
||||
|
||||
global $cronlog;
|
||||
|
||||
Reference in New Issue
Block a user