Skip to content

Instantly share code, notes, and snippets.

View Sommerregen's full-sized avatar

Sommerregen Sommerregen

View GitHub Profile
@Sommerregen
Sommerregen / htmlfilter.php
Created January 19, 2018 19:16
filter html user input allowing only specifics tags and attributes
<?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, [
'*'=>[
@Sommerregen
Sommerregen / _decimal.scss
Created April 28, 2016 20:30 — forked from terkel/_decimal.scss
Rounding decimals in Sass
// _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
@Sommerregen
Sommerregen / php-html-css-js-minifier.php
Created December 14, 2015 08:38 — forked from taufik-nurrohman/php-html-css-js-minifier.php
PHP Function to Minify HTML, CSS and JavaScript
<?php
/**
* -----------------------------------------------------------------------------------------
* Based on `https://github.com/mecha-cms/mecha-cms/blob/master/system/kernel/converter.php`
* -----------------------------------------------------------------------------------------
*/
// HTML Minifier
function minify_html($input) {