Skip to content

Instantly share code, notes, and snippets.

@dhaupin
dhaupin / dev_script_routing_proxy_ssl.php
Last active June 23, 2020 16:21
Function - Route reverse proxy SSL flags, rewrite REMOTE_ADDR, and add PROTOCOL index
<?php
// Rewrite client IP based on proxy headers
$ip_pool = array(
!empty($_SERVER['HTTP_CF_CONNECTING_IP']) ? $_SERVER['HTTP_CF_CONNECTING_IP'] : '',
!empty($_SERVER['HTTP_CF_PSEUDO_IPV4']) ? $_SERVER['HTTP_CF_PSEUDO_IPV4'] : '',
!empty($_SERVER['HTTP_X_FORWARDED_FOR']) ? $_SERVER['HTTP_X_FORWARDED_FOR'] : '',
!empty($_SERVER['HTTP_X_FORWARDED']) ? $_SERVER['HTTP_X_FORWARDED'] : '',
!empty($_SERVER['HTTP_FORWARDED_FOR']) ? $_SERVER['HTTP_FORWARDED_FOR'] : '',
@dhaupin
dhaupin / dev_schema_ld_organization.js
Created February 12, 2016 15:24
JSON-LD - Schema.org organization markup
<script type="application/ld+json">{
"@context":"http://schema.org",
"@type":"HomeGoodsStore",
"name":"Our Store",
"legalName":"Our Company",
"url":"https://www.ourstore.com/",
"sameAs":"http://plus.google.com/99999999999999",
"logo":"https://www.ourstore.com/image/logo.png",
"photo":"https://www.ourstore.com/image/ourstore.png",
"description":"People give us money and we give them GLORIOUS PRODUCTS.",
@dhaupin
dhaupin / dev_script_filter_char_print.php
Last active March 4, 2016 16:30
Function - Filter PDF/print rogue special characters from WYSIWYG "full-paste" or rando DB source
<?php
// @last https://3v4l.org/0LHkO
// Start sample
$str = '® ‡ ¼';
echo clean($str, false, false);
// End sample
@dhaupin
dhaupin / dev_script_filter_os_url.php
Last active March 4, 2016 16:29
Function - User input string to EN sanitized filename, directory, slug, identifier, etc
<?php
// @last https://3v4l.org/iSgi8
// @same http://stackoverflow.com/a/34908708/2418655
// Start sample
$raw_str = '.....&lt;div&gt;&lt;/div&gt;<script></script>&amp; Weiß Göbel 中文百强网File name %20 %20 %21 %2C Décor \/. /. . z \... y \...... x ./ “This name” is & 462^^ not &nbsp;&nbsp;&nbsp;&nbsp;&nbsp; = that grrrreat -][09]()1234747) საბეჭდი-და-ტიპოგრაფიული';
$fallback_str = 'generated__' . date('Y-m-d_H-m_A');
$bad_extension = '....t&+++a()r.gz[]';