This file contains hidden or 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 | |
/** | |
* ----------------------------------------------------------------------------------------- | |
* Based on `https://github.com/mecha-cms/mecha-cms/blob/master/system/kernel/converter.php` | |
* ----------------------------------------------------------------------------------------- | |
*/ | |
// HTML Minifier | |
function minify_html($input) { |
This file contains hidden or 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
/** | |
* Javascript AlphabeticID class | |
* (based on a script by Kevin van Zonneveld <[email protected]>) | |
* | |
* Author: Even Simon <[email protected]> | |
* | |
* Description: Translates a numeric identifier into a short string and backwords. | |
* | |
* Usage: | |
* var str = AlphabeticID.encode(9007199254740989); // str = 'fE2XnNGpF' |
This file contains hidden or 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 | |
/** | |
* PseudoCrypt by KevBurns (http://blog.kevburnsjr.com/php-unique-hash) | |
* Reference/source: http://stackoverflow.com/a/1464155/933782 | |
* | |
* I want a short alphanumeric hash that’s unique and who’s sequence is difficult to deduce. | |
* I could run it out to md5 and trim the first n chars but that’s not going to be very unique. | |
* Storing a truncated checksum in a unique field means that the frequency of collisions will increase | |
* geometrically as the number of unique keys for a base 62 encoded integer approaches 62^n. | |
* I’d rather do it right than code myself a timebomb. So I came up with this. |
This file contains hidden or 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 | |
/** | |
* UUID class | |
* | |
* The following class generates VALID RFC 4122 COMPLIANT | |
* Universally Unique IDentifiers (UUID) version 3, 4 and 5. | |
* | |
* UUIDs generated validates using OSSP UUID Tool, and output | |
* for named-based UUIDs are exactly the same. This is a pure | |
* PHP implementation. |
This file contains hidden or 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 | |
/* | |
* PBKDF2 key derivation function as defined by RSA's PKCS #5: https://www.ietf.org/rfc/rfc2898.txt | |
* $algorithm - The hash algorithm to use. Recommended: SHA256 | |
* $password - The password. | |
* $salt - A salt that is unique to the password. | |
* $count - Iteration count. Higher is better, but slower. Recommended: At least 1000. | |
* $key_length - The length of the derived key in bytes. | |
* $raw_output - If true, the key is returned in raw binary format. Hex encoded otherwise. | |
* Returns: A $key_length-byte key derived from the password and salt. |
This file contains hidden or 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
// _decimal.scss | MIT License | gist.github.com/terkel/4373420 | |
// Round a number to specified digits. | |
// | |
// @param {Number} $number A number to round | |
// @param {Number} [$digits:0] Digits to output | |
// @param {String} [$mode:round] (round|ceil|floor) How to round a number | |
// @return {Number} A rounded number | |
// @example | |
// decimal-round(0.333) => 0 |
This file contains hidden or 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 | |
function rolling_curl($urls, $callback, $custom_options = null) { | |
// make sure the rolling window isn't greater than the # of urls | |
$rolling_window = 5; | |
$rolling_window = (sizeof($urls) < $rolling_window) ? sizeof($urls) : $rolling_window; | |
$master = curl_multi_init(); | |
$curl_arr = array(); | |
// add additional curl options here | |
$std_options = array(CURLOPT_RETURNTRANSFER => true, |
This file contains hidden or 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 | |
// filter html user input allowing only specifics tags and attributes | |
// XSS - You shall not pass ! ;) | |
$html = 'TEST <div>Hello PHP/SQL developers, <img src="https://foxorm.com/img/foxorm.png" height="24" width="24" on-click="alert(\'javascript injection try\');"><a href="https://foxorm.com">FoxORM</a> is <b>awesome</b> ! | |
<a href="javascript:alert(\'another javascript injection try\');"> !!! </a> | |
<script>window.location = http://xss-injection.hack; </script></div> IFY'; | |
$securisedHtml = htmlfilter($html, [ | |
'*'=>[ |