mirror of
https://github.com/e107inc/e107.git
synced 2025-08-03 13:17:24 +02:00
e_jslib - fixed future troubles on some server configs
This commit is contained in:
@@ -1,16 +1,29 @@
|
|||||||
<?php
|
<?php
|
||||||
/* $Id: e_jslib.php,v 1.1 2008-11-09 20:31:10 secretr Exp $ */
|
/*
|
||||||
|
* e107 website system
|
||||||
|
*
|
||||||
|
* Copyright (c) 2001-2008 e107 Developers (e107.org)
|
||||||
|
* Released under the terms and conditions of the
|
||||||
|
* GNU General Public License (http://gnu.org).
|
||||||
|
*
|
||||||
|
* e107 Javascript API
|
||||||
|
*
|
||||||
|
* $Source: /cvs_backup/e107_0.8/e107_files/e_jslib.php,v $
|
||||||
|
* $Revision: 1.2 $
|
||||||
|
* $Date: 2008-11-19 12:52:22 $
|
||||||
|
* $Author: secretr $
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
/*
|
/*
|
||||||
called from header_default.php - just after e_header processing
|
called from header_default.php - just after e_header processing
|
||||||
*/
|
*/
|
||||||
|
|
||||||
error_reporting(0);
|
error_reporting(0);
|
||||||
|
|
||||||
//output cache if available before calling the api
|
//output cache if available before calling the api
|
||||||
e_jslib_cache_out();
|
e_jslib_cache_out();
|
||||||
|
|
||||||
//v0.8 - we need THEME defines here
|
//v0.8 - we need THEME defines here (do we?)
|
||||||
$_E107 = array('no_forceuserupdate' => 1, 'no_online' => 1,'no_menus' => 1,'no_prunetmp' => 1);
|
$_E107 = array('no_forceuserupdate' => 1, 'no_online' => 1,'no_menus' => 1,'no_prunetmp' => 1);
|
||||||
|
|
||||||
//admin or front-end call
|
//admin or front-end call
|
||||||
@@ -44,7 +57,9 @@
|
|||||||
if($encoding)
|
if($encoding)
|
||||||
header('Content-Encoding: '.$encoding);
|
header('Content-Encoding: '.$encoding);
|
||||||
|
|
||||||
echo @file_get_contents($cacheFile);
|
$tmp = @file_get_contents($cacheFile);
|
||||||
|
header('Content-Length: '.strlen($tmp));
|
||||||
|
echo $tmp;
|
||||||
//TODO - log
|
//TODO - log
|
||||||
//@file_put_contents('cache/e_jslib_log', "----------\ncache used - ".$cacheFile."\n\n", FILE_APPEND);
|
//@file_put_contents('cache/e_jslib_log', "----------\ncache used - ".$cacheFile."\n\n", FILE_APPEND);
|
||||||
exit;
|
exit;
|
||||||
@@ -82,7 +97,8 @@
|
|||||||
*/
|
*/
|
||||||
function e_jslib_browser_enc() {
|
function e_jslib_browser_enc() {
|
||||||
|
|
||||||
if( headers_sent() ){
|
//double-compression fix - thanks Topper
|
||||||
|
if( headers_sent() || ini_get('zlib.output_compression') || !isset($_SERVER["HTTP_ACCEPT_ENCODING"]) ){
|
||||||
|
|
||||||
$encoding = '';
|
$encoding = '';
|
||||||
} elseif ( strpos($_SERVER["HTTP_ACCEPT_ENCODING"], 'x-gzip') !== false ){
|
} elseif ( strpos($_SERVER["HTTP_ACCEPT_ENCODING"], 'x-gzip') !== false ){
|
||||||
@@ -107,7 +123,7 @@
|
|||||||
*/
|
*/
|
||||||
function e_jslib_cache_file($encoding='') {
|
function e_jslib_cache_file($encoding='') {
|
||||||
|
|
||||||
$cacheDir = 'cache/';
|
$cacheDir = './cache/';
|
||||||
$hash = $_SERVER['QUERY_STRING'] ? md5($_SERVER['QUERY_STRING']) : 'nomd5';
|
$hash = $_SERVER['QUERY_STRING'] ? md5($_SERVER['QUERY_STRING']) : 'nomd5';
|
||||||
$cacheFile = $cacheDir.'S_e_jslib'.($encoding ? '_'.$encoding : '').'_'.$hash.'.cache.php';
|
$cacheFile = $cacheDir.'S_e_jslib'.($encoding ? '_'.$encoding : '').'_'.$hash.'.cache.php';
|
||||||
|
|
||||||
|
@@ -8,8 +8,8 @@
|
|||||||
* e107 Javascript API
|
* e107 Javascript API
|
||||||
*
|
*
|
||||||
* $Source: /cvs_backup/e107_0.8/e107_files/jslib/e107.js.php,v $
|
* $Source: /cvs_backup/e107_0.8/e107_files/jslib/e107.js.php,v $
|
||||||
* $Revision: 1.5 $
|
* $Revision: 1.6 $
|
||||||
* $Date: 2008-11-19 12:19:51 $
|
* $Date: 2008-11-19 12:52:22 $
|
||||||
* $Author: secretr $
|
* $Author: secretr $
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
@@ -783,11 +783,11 @@ Object.extend(e107Helper, {
|
|||||||
if(false === Object.isString(el) || (
|
if(false === Object.isString(el) || (
|
||||||
($(el) && $(el).nodeName.toLowerCase() == 'a' && $(el).readAttribute('href'))
|
($(el) && $(el).nodeName.toLowerCase() == 'a' && $(el).readAttribute('href'))
|
||||||
||
|
||
|
||||||
($(el) && $(el).readAttribute('type') && $(el).readAttribute('type').toLowerCase() == 'input')
|
($(el) && $(el).readAttribute('type') && $(el).readAttribute('type').toLowerCase() == 'input') /* deprecated */
|
||||||
)) {
|
)) {
|
||||||
eltoggle = (function(el) {
|
eltoggle = (function(el) {
|
||||||
return Try.these(
|
return Try.these(
|
||||||
function() { var ret= $(el.readAttribute('href').match(/#(\w.+)$/)[1]); if(ret) { return ret; } throw 'Error';}, //This will be the only valid case in the near future
|
function() { var ret= $(el.readAttribute('href').hash.substr(1)); if(ret) { return ret; } throw 'Error';}, //This will be the only valid case in the near future
|
||||||
function() { var ret=el.next('.e-expandme'); if(ret) { return ret; } throw 'Error';},
|
function() { var ret=el.next('.e-expandme'); if(ret) { return ret; } throw 'Error';},
|
||||||
function() { var ret=el.next('div'); if(ret) { return ret; } throw 'Error'; }, //backward compatibality - DEPRECATED
|
function() { var ret=el.next('div'); if(ret) { return ret; } throw 'Error'; }, //backward compatibality - DEPRECATED
|
||||||
function() { return null; } //break
|
function() { return null; } //break
|
||||||
@@ -823,10 +823,8 @@ Object.extend(e107Helper, {
|
|||||||
toggleObserver: function(event) {
|
toggleObserver: function(event) {
|
||||||
var expandthem = event.memo.element ? $(event.memo.element) : $$('body')[0];
|
var expandthem = event.memo.element ? $(event.memo.element) : $$('body')[0];
|
||||||
expandthem.select('.e-expandit').invoke('observe', 'click', function(e) {
|
expandthem.select('.e-expandit').invoke('observe', 'click', function(e) {
|
||||||
var relval = e.element().getAttribute('rel') ? '{' + String(e.element().getAttribute('rel').toJSON()) + '}' : '{}';
|
|
||||||
e.stop();
|
e.stop();
|
||||||
//security - evalJSON(true)
|
this.toggle(e.element(), {});
|
||||||
this.toggle(e.element(), relval.evalJSON(true) || {});
|
|
||||||
}.bindAsEventListener(e107Helper));
|
}.bindAsEventListener(e107Helper));
|
||||||
},
|
},
|
||||||
|
|
||||||
|
@@ -1,15 +1,14 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* e107 website system
|
* e107 website system
|
||||||
*
|
*
|
||||||
* Copyright (c) 2001-2008 Steve Dunstan (e107.org)
|
* Copyright (c) 2001-2008 e107 Developers (e107.org)
|
||||||
* Released under the terms and conditions of the
|
* Released under the terms and conditions of the
|
||||||
* GNU General Public License (http://gnu.org).
|
* GNU General Public License (http://gnu.org).
|
||||||
*
|
*
|
||||||
* $Source: /cvs_backup/e107_0.8/e107_handlers/jslib_handler.php,v $
|
* $Source: /cvs_backup/e107_0.8/e107_handlers/jslib_handler.php,v $
|
||||||
* $Revision: 1.2 $
|
* $Revision: 1.3 $
|
||||||
* $Date: 2008-11-11 13:17:18 $
|
* $Date: 2008-11-19 12:52:22 $
|
||||||
* $Author: secretr $
|
* $Author: secretr $
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
@@ -25,7 +24,15 @@ class e_jslib
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Collect & output all available JS libraries (requires e107 API)
|
* Collect & output all available JS libraries (requires e107 API)
|
||||||
*
|
* FIXME
|
||||||
|
* - cache jslib in a pref on plugin/theme install only (plugin.xml, theme.xml)
|
||||||
|
* - the structure of the cached pref array?
|
||||||
|
* - kill all dupps
|
||||||
|
* - jslib settings - Administration area (compression on/off, admin log on/off
|
||||||
|
* manual control for included JS - really not sure about this,
|
||||||
|
* Force Browser Cache refresh - timestamp added to the url hash)
|
||||||
|
* - how and when to add JS lans for core libraries?
|
||||||
|
* - separate methods for collecting & storing JS files (to be used in install/update routines) and output the JS content
|
||||||
*/
|
*/
|
||||||
function core_run()
|
function core_run()
|
||||||
{
|
{
|
||||||
@@ -140,7 +147,7 @@ class e_jslib
|
|||||||
*/
|
*/
|
||||||
function content_out()
|
function content_out()
|
||||||
{
|
{
|
||||||
global $pref;
|
global $pref, $admin_log;
|
||||||
|
|
||||||
$encoding = $this->browser_enc();
|
$encoding = $this->browser_enc();
|
||||||
|
|
||||||
@@ -161,17 +168,18 @@ class e_jslib
|
|||||||
$this->set_cache($gzdata, $encoding);
|
$this->set_cache($gzdata, $encoding);
|
||||||
|
|
||||||
header('Content-Encoding: ' . $encoding);
|
header('Content-Encoding: ' . $encoding);
|
||||||
//header('Content-Length: '.$gsize);
|
header('Content-Length: '.$gsize);
|
||||||
header('X-Content-size: ' . $size);
|
header('X-Content-size: ' . $size);
|
||||||
print($gzdata);
|
print($gzdata);
|
||||||
//TODO - log
|
//TODO - log/debug
|
||||||
//@file_put_contents('cache/e_jslib_log', "----------\n cache used - ".$encoding."\nOld size - $size, New compressed size - $gsize\nCache hash: ".($_SERVER['QUERY_STRING'] ? md5($_SERVER['QUERY_STRING']) : 'nomd5')."\n\n", FILE_APPEND);
|
//@file_put_contents('cache/e_jslib_log', "----------\n cache used - ".$encoding."\nOld size - $size, New compressed size - $gsize\nCache hash: ".($_SERVER['QUERY_STRING'] ? md5($_SERVER['QUERY_STRING']) : 'nomd5')."\n\n", FILE_APPEND);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
header('Content-Length: '.strlen($contents));
|
||||||
$this->set_cache($contents);
|
$this->set_cache($contents);
|
||||||
print($contents);
|
print($contents);
|
||||||
//TODO - log
|
//TODO - log/debug
|
||||||
//@file_put_contents('cache/e_jslib_log', "----------\nno cache used - raw\n\n", FILE_APPEND);
|
//@file_put_contents('cache/e_jslib_log', "----------\nno cache used - raw\n\n", FILE_APPEND);
|
||||||
}
|
}
|
||||||
exit();
|
exit();
|
||||||
@@ -204,7 +212,8 @@ class e_jslib
|
|||||||
*/
|
*/
|
||||||
function browser_enc()
|
function browser_enc()
|
||||||
{
|
{
|
||||||
if (headers_sent())
|
//double-compression fix (thanks Topper), remove possible php warning
|
||||||
|
if ( headers_sent() || ini_get('zlib.output_compression') || !isset($_SERVER["HTTP_ACCEPT_ENCODING"]) )
|
||||||
{
|
{
|
||||||
$encoding = '';
|
$encoding = '';
|
||||||
}
|
}
|
||||||
@@ -227,13 +236,14 @@ class e_jslib
|
|||||||
* Create cache filename (doesn't require e107 API)
|
* Create cache filename (doesn't require e107 API)
|
||||||
*
|
*
|
||||||
* @param string $encoding
|
* @param string $encoding
|
||||||
|
* @param string $cacheStr
|
||||||
* @return string cache filename
|
* @return string cache filename
|
||||||
*/
|
*/
|
||||||
function cache_file($encoding = '')
|
function cache_file($encoding = '', $cacheStr = 'S_e_jslib')
|
||||||
{
|
{
|
||||||
$cacheDir = 'cache/';
|
$cacheDir = 'cache/';
|
||||||
$hash = $_SERVER['QUERY_STRING'] ? md5($_SERVER['QUERY_STRING']) : 'nomd5';
|
$hash = $_SERVER['QUERY_STRING'] ? md5($_SERVER['QUERY_STRING']) : 'nomd5';
|
||||||
$cacheFile = $cacheDir . 'S_e_jslib' . ($encoding ? '_' . $encoding : '') . '_' . $hash . '.cache.php';
|
$cacheFile = $cacheDir . $cacheStr . ($encoding ? '_' . $encoding : '') . '_' . $hash . '.cache.php';
|
||||||
|
|
||||||
return $cacheFile;
|
return $cacheFile;
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user