1
+ − 1
<?php
+ − 2
+ − 3
/*
+ − 4
* Enano - an open-source CMS capable of wiki functions, Drupal-like sidebar blocks, and everything in between
142
ca9118d9c0f2
Rebrand as 1.0.2 (Coblynau); internal links are now parsed by RenderMan::parse_internal_links()
Dan
diff
changeset
+ − 5
* Version 1.0.2 (Coblynau)
1
+ − 6
* Copyright (C) 2006-2007 Dan Fuhry
+ − 7
* jsres.php - the Enano client-side runtime, a.k.a. AJAX on steroids
+ − 8
*
+ − 9
* This program is Free Software; you can redistribute and/or modify it under the terms of the GNU General Public License
+ − 10
* as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.
+ − 11
*
+ − 12
* This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied
+ − 13
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for details.
+ − 14
*/
+ − 15
+ − 16
if(!isset($_GET['title'])) $_GET['title'] = 'null';
+ − 17
require('../common.php');
+ − 18
+ − 19
define('ENABLE_COMPRESSION', '');
+ − 20
+ − 21
ob_start();
+ − 22
header('Content-type: text/javascript');
+ − 23
+ − 24
$file = ( isset($_GET['file']) ) ? $_GET['file'] : 'enano-lib-basic.js';
+ − 25
+ − 26
if(!preg_match('/^([a-z0-9_-]+)\.js$/i', $file))
+ − 27
die('// ERROR: Hacking attempt');
+ − 28
+ − 29
$fname = './static/' . $file;
+ − 30
if ( !file_exists($fname) )
+ − 31
die('// ERROR: File not found: ' . $file);
+ − 32
+ − 33
$everything = file_get_contents($fname);
+ − 34
+ − 35
$mtime = filemtime($fname);
+ − 36
header('Last-Modified: '.date('D, d M Y H:i:s T', $mtime));
+ − 37
header('Content-disposition: attachment; filename=' . $file);
+ − 38
+ − 39
if(defined('ENABLE_COMPRESSION'))
+ − 40
{
+ − 41
echo "/*
+ − 42
* Enano - an open-source CMS capable of wiki functions, Drupal-like sidebar blocks, and everything in between
142
ca9118d9c0f2
Rebrand as 1.0.2 (Coblynau); internal links are now parsed by RenderMan::parse_internal_links()
Dan
diff
changeset
+ − 43
* Version 1.0.2 (Coblynau)
1
+ − 44
* [Aggressively compressed] Javascript client code
+ − 45
* Copyright (C) 2006-2007 Dan Fuhry
36
+ − 46
* Enano is Free Software, licensed under the GNU General Public License; see http://enanocms.org/ for details.
1
+ − 47
*/
+ − 48
+ − 49
";
+ − 50
+ − 51
$cache_file = ENANO_ROOT . '/cache/jsres-' . $file . '.php';
+ − 52
+ − 53
if ( file_exists($cache_file) )
+ − 54
{
+ − 55
$cached = file_get_contents ( $cache_file );
+ − 56
$data = unserialize ( $cached );
+ − 57
if ( $data['md5'] == md5 ( $everything ) )
+ − 58
{
+ − 59
echo "// The code in this file was fetched from cache\n\n";
+ − 60
echo $data['code'];
+ − 61
exit;
+ − 62
}
+ − 63
}
+ − 64
+ − 65
if ( getConfig('cache_thumbs') == '1' )
+ − 66
{
+ − 67
$js_compressor = new JavascriptCompressor();
+ − 68
$packed = $js_compressor->getPacked($everything);
+ − 69
$data = Array(
+ − 70
'md5' => md5 ( $everything ),
+ − 71
'code' => $packed
+ − 72
);
+ − 73
echo "// The code in this file was fetched from the static scripts and compressed (packed code cached)\n\n";
+ − 74
echo $packed;
+ − 75
+ − 76
$fh = @fopen($cache_file, 'w');
+ − 77
if (!$fh)
+ − 78
die('// ERROR: Can\'t open cache file for writing');
+ − 79
fwrite($fh, serialize ( $data ) );
+ − 80
fclose($fh);
+ − 81
+ − 82
exit;
+ − 83
}
+ − 84
+ − 85
echo "// The code in this file was not compressed because packed-script caching is disabled\n\n";
+ − 86
echo $everything;
+ − 87
+ − 88
}
+ − 89
else
+ − 90
{
+ − 91
echo "// The code in this file was not compressed because all script compression is disabled\n\n";
+ − 92
echo $everything;
+ − 93
}
+ − 94
?>