- 0
How to output compressed content using PHP?
Asked by
ProclaimDragon,
-
Recently Browsing 0 members
- No registered users viewing this page.
-
Posts
-
By zikalify · Posted
Microsoft Defender XDR gets TITAN-powered Security Copilot recommendations by Paul Hill Guided Response, a Copilot-powered capability in Microsoft Defender XDR that guides analysts through step-by-step investigation and response flows, is getting a big upgrade with the introduction of TITAN recommendations. With TITAN, Microsoft wants to give security analysts real-time, threat-intel-driven recommendations so they can better prepare against attacks, before they even happen. TITAN is an adaptive threat intelligence graph that uses data from first and third-party telemetry and employs guilt-by-association techniques to warn analysts about unknown IP addresses that could pose a threat, due to their association with known malicious addresses. The primary benefit of TITAN is that security analysts get faster warnings about potential threats before they even have a chance to cause a problem. TITAN is an enhancement of Security Copilot Guided Response, rather than a replacement to it. With this extra tool, security analysts will be able to better keep up with evolving threats. Understanding TITAN's AI-powered threat intelligence The Redmond giant said that TITAN “represents a new wave of innovation” built upon its threat intelligence capabilities that introduces a real-time, adaptive threat intelligence graph. It takes telemetry from first and third-party sources such as Microsoft Defender for Threat Intelligence, Microsoft Defender for Experts, and customer feedback. The graph uses guilt-by-association techniques to mark unknown devices as threats, if they’re associated with known malicious entities. This gives security analysts a window of opportunity to take action and prevent harm. To identify potential threats, Microsoft uses a semi-supervised label propagation technique that assigns reputation scores to nodes based on the score of their neighbors. These reputation scores allow Microsoft’s unified security operation platform to implement containment and remediation actions via attack disruption. Practical impact and future outlook The new TITAN suggestion now appears within Guided Response as triage and containment recommendations. When a suspicious IP is detected, a Guided Response recommendation is automatically generated. These can help security analysts deal with various threats including IP addresses, IP ranges, and email senders. Microsoft said in early testing its TITAN recommendations have shown good results. TITAN boosted Guided Response triage accuracy by 8%, it reduced the time needed to investigate and respond to incidents, and its explainable recommendations gave analysts more confidence in the actions they take. As threats become more sophisticated, Microsoft’s TITAN will help to tackle threats before they even become an issue. -
By naap51stang · Posted
China wants the tech... if they were to invade, TSMC would destroy it's fabs and other critical information first. Plus, you can bet they have backups stored NOT in Taiwan. -
By TheGhostPhantom · Posted
Malware website host in China in 3….2…1 -
By +sphbecker · Posted
You totally missed what I was saying. Yes, the DHCP server software is largely unchanged since the Windows 2000 Server version. My statement was somewhat of a joke, but I was saying that *IF* the DHCP server was written using today's Windows 11 *ERA* design philosophy, it would be a mess. Yes, even on the latest version of Windows Server it still uses the old software, but that wasn't really the point. -
By Arceles · Posted
Yeah no, they are nowhere at this same level. Whatsapp did survive a lot of time being "free" it is just meta/facebook wanting more money.
-
-
Recent Achievements
-
Motoman26 went up a rank
Enthusiast
-
M. Murcek went up a rank
Mentor
-
treker_ed went up a rank
Explorer
-
CHUNWEI went up a rank
Apprentice
-
1337ish went up a rank
Veteran
-
-
Popular Contributors
-
Tell a friend
Question
ProclaimDragon
In my latest PHP script I decided to use compression for the output, one of the reasons is that I'm using lots of JavaScript and all that code compress looks sweet. I don't have any concrete question but I need someone that already knows about the subject to enlighten me a bit on the best way to compress the output via PHP.
For instance, at first sight, I decided to go with the method I though it was best. Use an .htaccess file with the following:
This way, all the output via PHP file would be compress and this would work for everything I'm doing, including JavaScript and CSS. Anyway, this method brings some issues to the table:
1) I just tested my script on a remote server and it didn't work. It was a free PHP5 server and something tells me that the webhost has PHP ini settings modifications through .htaccess blocked. And there are many servers like this one...
2) I would like to avoid the use of .htaccess. For instance, what if someone is using ISS, this will certainly not work for them.
Another option would be to use the ini_set() function to set the PHP configuration but in all the tests I did, something didn't work and I don't understand why. All my scripts aggregate all the content to be outputed to the browser in a single variable and then I simply "echo" that variable. I tried to use ini_set to set "zlib.output_compression" to "On" and also "zlib.output_compression_level" to "9", right before echoing the content variable. But something didn't work. Maybe the syntax for ini_set() was incorrect? I mean, the dots to separate the ini setting or the underscores or double-quotes or even case sensitivity is in place? I don't know if ini_set() is sensible to all this things. Anyway, this would have been the best option for every browser, OS and server, as long as the zlib module was enabled of course.
I also found another way to do it, using the ob_start("ob_gzhandler") function, but:
1) I saw lots of code examples and I don't really know the best way to use it. I mean, I was able to use it bu, it add several lines of code that I didn't really understand what were they for and if the were really necessary. I tried to comment them and the script worked anyways with output compression but I don't really know if thoses lines would be important in the future.
2) From the PHP official documentation, they say: "Note: You cannot use both ob_gzhandler() and zlib.output_compression. Also note that using zlib.output_compression is preferred over ob_gzhandler().". And that's the reason that I would prefer to use zlib.output_compression instead of ob_gzhandler. But I would also like to understand why they recommend zlib instead of ob_gzhandler.
Now, the idea is to compress all the output done by PHP, all CSS and JavaScript files. The PHP output is very simple, all the pages in my script are accessed through index.php and by the query arguments, it will decide which page to show and then, only an echo is required to show that page. For the CSS and JavaScript, I opted to create 2 different PHP files, named scripts.php and styles.php. Both do the same exact thing. In the case of scripts.php, it will gather all the content from various .js files and output all of them. In the styles.php, the same thing is done, with the different that only one .css file is read to be outputted; but if some day I have more than one .css file (for instance, for beowser compatbility), I will gather them all in the same way I'm doing for JAvaScript. The Content-Type is correctly defined using the header() function before the output is done in both files.
Recently, a friend of mine suggested the following code:
And I want to know if there is any issue that one might not know about outputting code using this gzencode() method and that specific header. Would I have any problems using it like this or this is the way to go?
Well, I'm open to suggestions but more importantly, I would like to enlighted (if possible) about PHP output compression.
P.S: Sorry for this big testament and for the bad english, I had to translate this from a Portuguese post I did to some other f?rum and I'm kinda in a rush...
Link to comment
https://www.neowin.net/forum/topic/623470-how-to-output-compressed-content-using-php/Share on other sites
17 answers to this question
Recommended Posts