forked from Keshi/ScalaWilliam.com
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathadd-analytics.php
More file actions
24 lines (23 loc) · 757 Bytes
/
add-analytics.php
File metadata and controls
24 lines (23 loc) · 757 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
<?php
define('ANALYTICS_PATH', dirname(__FILE__) . "/shared/analytics.html");
define('BODY_CLOSE', "</body>");
define('ANALYTICS_BODY', file_get_contents(ANALYTICS_PATH));
libxml_use_internal_errors(true);
function process_file($filename) {
$contents = file_get_contents($filename);
$contents = str_replace(BODY_CLOSE, ANALYTICS_BODY.BODY_CLOSE, $contents);
file_put_contents($filename, $contents);
}
$failed = false;
foreach(array_slice($argv, 1) as $filename) {
if ( strpos($filename, ".html")) {
// error_log("Adding analytics $filename");
process_file($filename);
} else {
$failed = true;
error_log("Cannot process file $filename because no .html extension.");
}
}
if ( $failed ) {
exit(1);
}