This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** To use minify with ob_start just put at the top of your page | |
* Warning: | |
* - This function still not support to remove any comments in javascript | |
* - Minifying on buffering will take so much memory and it not recomended for high traffic | |
*/ | |
function sanitize_output($buffer) { | |
$search = array( | |
// Minify HTML | |
'/\>[^\S ]+/s', // strip whitespaces after tags, except space [^1] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
print get_file('http://www.google.com'); | |
function get_file($url) { | |
$curl = curl_init(); | |
$options = default_ops(array(CURLOPT_URL => $url)); | |
curl_setopt_array($curl, $options); | |
$output = curl_exec($curl); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Determine that url is exists or not | |
* | |
* @param $url = The url to check | |
**/ | |
function url_exists($url) { | |
$result = false; | |
$url = filter_var($url, FILTER_VALIDATE_URL); | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Stream or Download big files using php (support multipart and remote url) | |
* @param $file is the path or remote url | |
* @param $size is the filesize of the file | |
*/ | |
function streamDownload($file,$size,$mime='video/mp4') { | |
header('Content-type: ' . $mime); | |
header('Content-Disposition: attachment; filename="' . basename($file) . '"'); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
echo preg_replace('#<a.*?>([^>]*)</a>#i', '$1', $str); | |
?> | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html> | |
<head> | |
<title>Sharing memoryStorage between tabs for secure multi-tab authentication</title> | |
</head> | |
<body> | |
<h3><a href=''>memoryStorage</a></h3> | |
<h3 id="stData"></h3> | |
<button id="btnSet">Set memory storage</button> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html> | |
<head> | |
<title>Sharing sessionStorage between tabs for secure multi-tab authentication</title> | |
</head> | |
<body> | |
<h3><a href=''>sessionStorage</a></h3> | |
<h3 id="stData"></h3> | |
<button id="btnSet">Set session storage</button> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
TL;DR - jump to the challenge at the end | |
====ON BLOCKING EVIL BOTS===== | |
On a resent job interview I had for "Incapsula" a few days ago I was put to the challenge to break | |
their bot protection mechanism. Apparently node.js is not that common among bot writes and most bots | |
are not able to run javascript. | |
The challenge had two parts - | |
1. find what the code does. | |
2. implement a bot that will break the code without using js. | |
3. think how to make this code unbreakable |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var key = "SXGWLZPDOKFIVUHJYTQBNMACERxswgzldpkoifuvjhtybqmncare"; | |
// matches ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZ | |
function encodeStr(uncoded) { | |
uncoded = uncoded.toUpperCase().replace(/^\s+|\s+$/g,""); | |
var coded = ""; | |
var chr; | |
for (var i = uncoded.length - 1; i >= 0; i--) { | |
chr = uncoded.charCodeAt(i); | |
coded += (chr >= 65 && chr <= 90) ? |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/cache/ |
OlderNewer