-
Notifications
You must be signed in to change notification settings - Fork 1
/
restylegc-js.php
executable file
·46 lines (42 loc) · 1.59 KB
/
restylegc-js.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
<?php header("Content-type: application/x-javascript");
/*******************************************************************************
* FILE: restylegc-js.php
*
* DESCRIPTION:
* Companion file for restylegc.php to edit the javascript file that
* generates the Google Calendar.
*
* USAGE:
* There are no user-editable parameters.
*
* MIT LICENSE:
* Copyright (c) 2009 Brian Gibson (http://www.restylegc.com/)
* Full text in restylegc.php
******************************************************************************/
// URL for the javascript
$url = "";
if(count($_GET) > 0) {
$url = "http://www.google.com/calendar/" . $_SERVER['QUERY_STRING'];
}
/* If you would like to freeze the calendar version, download the Javascript
* file using the same method for downloading the CSS file, as described in
* the main script. You can find some previous versions in the archive folder.
* NOTE: You should use the corresponding CSS file as well.
*
* Edit and uncomment the following line to freeze the calendar version.
*/
//$url = "http://myserver.tld/path/to/archive/371be1f592b0b5f982952f457d82fd40embedcompiled__en.js";
// Request the javascript
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
$buffer = curl_exec($ch);
curl_close($ch);
// Fix URLs in the javascript
$pattern = '/this\.[a-zA-Z]{1,2}\+"calendar/';
$replacement = '"http://www.google.com/calendar';
$buffer = preg_replace($pattern, $replacement, $buffer);
// Display the javascript
print $buffer;
?>