d1d5 php5 config? - The FreeBSD Forums
The FreeBSD Forums  

Go Back   The FreeBSD Forums > Server & Networking > Web & Network Services

Web & Network Services Discussion related to network/web services such as apache, bind, sendmail, etc.

Reply
 
Thread Tools Display Modes
  #1  
Old September 21st, 2012, 11:39
cbrace cbrace is offline
Member
 
Join Date: Feb 2010
Location: A'dam
Posts: 144
Thanks: 50
Thanked 2 Times in 2 Posts
Default php5 config?

Hi all,

Here is a tricky one:

(disclaimer: I know nothing of PHP)

I am using a blank Joomla template to create a new template for a www/joomla25 site. This template uses a file called css/template.css.php to load the template's CSS files and send them as one long compacted string (minimized) (code below).

On my FreeBSD server (PHP 5.3.13) template.css.php returns garbage:

http://wfbrace.com:8000/templates/wf...ss.php?b=0&v=1

Wit the same template installed for test purposes on a production server running some Linux (PHP 5.3.10), hosted at Byte.nl, template.css.php returns the CSS, in MIN form:

https://www.sense-online.nl/template...ss.php?b=0&v=1

What could be going wrong on my FreeBSD server? A wrong PHP setting? A missing php5 module?

Thanks.

PHP Code:
<?php 
/*------------------------------------------------------------------------
# author    your name or company
# copyright Copyright © 2011 example.com. All rights reserved.
# @license  http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL
# Website   http://www.example.com
-------------------------------------------------------------------------*/

// parameter
$bootstrap $_GET['b'];

//initialize ob_gzhandler to send and compress data
ob_start ("ob_gzhandler");
//initialize compress function for whitespace removal
ob_start("compress");
//required header info and character set
header("Content-type:text/css; charset=UTF-8");
//header("Content-type:text/css; charset=US-ASCII");
//cache control to process
header("Cache-Control:must-revalidate");
//duration of cached content (1 hour)
$offset 60 60 ;
//expiration header format
$ExpStr "Expires: " gmdate("D, d M Y H:i:s",time() + $offset) . " GMT";
//send cache expiration header to broswer
header($ExpStr);
//Begin function compress
function compress($buffer) {
    
//remove comments
    
$buffer preg_replace('!/\*[^*]*\*+([^/][^*]*\*+)*/!'''$buffer);
    
//remove tabs, spaces, new lines, etc.        
    
$buffer str_replace(array("\r\n","\r","\n","\t",'  ','    ','    '),'',$buffer);
    
//remove unnecessary spaces        
    
$buffer str_replace('{ ''{'$buffer);
    
$buffer str_replace(' }''}'$buffer);
    
$buffer str_replace('; '';'$buffer);
    
$buffer str_replace(', '','$buffer);
    
$buffer str_replace(' {''{'$buffer);
    
$buffer str_replace('} ''}'$buffer);
    
$buffer str_replace(': '':'$buffer);
    
$buffer str_replace(' ,'','$buffer);
    
$buffer str_replace(' ;'';'$buffer);
    
$buffer str_replace(';}''}'$buffer);
    
    return 
$buffer;
}

if (
$bootstrap==1) require('bootstrap.css');
if (
$bootstrap==0) require('reset.css');
                   require(
'template.css');
if (
$bootstrap==1) require('bootstrap-responsive.css');

require(
'../../../media/system/css/system.css');
require(
'../../system/css/system.css');
require(
'../../system/css/general.css');
?>
Reply With Quote
  #2  
Old September 21st, 2012, 11:58
usdmatt usdmatt is offline
Member
 
Join Date: Mar 2009
Posts: 249
Thanks: 1
Thanked 67 Times in 56 Posts
Default

If I request the file by hand with a simple HTTP request I get it fine, but in a web browser it's messed up.

I'm wondering if you're gzipping the data twice. My handmade request had no 'Accept-Encoding' header, so the server should not have tried to gzip the content, but it would with the web browser.

Can you try removing the following line:

Code:
ob_start ("ob_gzhandler");
I have never used this, I usually just configure an output filter via the web server to compress all relevant mime types. It's possible you are passing the content through ob_gzhandler in PHP to compress the data, and then the web server is configured to compress any text/css data, so is doing it again.
Reply With Quote
The Following User Says Thank You to usdmatt For This Useful Post:
cbrace (September 21st, 2012)
  #3  
Old September 21st, 2012, 12:21
cbrace cbrace is offline
Member
 
Join Date: Feb 2010
Location: A'dam
Posts: 144
Thanks: 50
Thanked 2 Times in 2 Posts
Default

Yep, that fixed it. Thanks! I'll pass this info on to the author of the template.
Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Unable to install php5-extention (php5-zip) kyryliv Installation and Maintenance of FreeBSD Ports or Packages 1 May 18th, 2012 07:27
Relative newbie trying to upgrade my PHP5.2x to PHP5.3x EliG Installation and Maintenance of FreeBSD Ports or Packages 6 September 9th, 2011 05:30
BUG: Targets 'config-recursive' and 'config-conditional', behave same! Seeker Installation and Maintenance of FreeBSD Ports or Packages 4 June 9th, 2011 12:17
[Solved] PHP5 upgrade problems - php5-pcre Ronaldr Installation and Maintenance of FreeBSD Ports or Packages 8 November 5th, 2010 08:28
Adding Config To Port (PHP5) Humongor Installation and Maintenance of FreeBSD Ports or Packages 2 June 28th, 2010 21:57


All times are GMT +1. The time now is 14:15.


Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2013, vBulletin Solutions, Inc.
The mark FreeBSD is a registered trademark of The FreeBSD Foundation and is used by The FreeBSD Project with the permission of The FreeBSD Foundation.
Web protection and acceleration provided by CloudFlare
0