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
###DMG SECURITY BEGIN### | |
<IfModule mod_rewrite.c> | |
RewriteEngine On | |
#whitelist: | |
RewriteRule ^/?wp-content/plugins/wp-spamshield/ - [QSA,L] | |
#blacklist: | |
RewriteRule ^/?xmlrpc.php$ - [F,L] | |
RewriteRule ^/?wp-admin/includes/ - [F,L] | |
RewriteRule ^/?wp-includes/[^/]+\.php$ - [F,L] | |
RewriteRule ^/?wp-includes/js/tinymce/langs/.+\.php - [F,L] |
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 | |
/** | |
* Converts anything to UTF-8. | |
* | |
* @param $string string|object|array | |
* @param $stringify_objects bool|true | |
* @param $throw_exceptions bool|true | |
* | |
* @throws InvalidArgumentException |
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 | |
/** | |
* @param DateTime $dob | |
* @param string|DateTime $end | |
* | |
* @return DatePeriod | |
*/ | |
function getBirthdays(DateTime $dob, $end = 'today 23:59:59') | |
{ |
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 | |
// https://en.wikipedia.org/wiki/Binary_prefix | |
function binairy_prefix_to_number($string, $mult = null, $exceptions = true) | |
{ | |
if (is_numeric($string)) { | |
return $string; | |
} | |
$units = array('', 'k', 'm', 'g', 't', 'p', 'e', 'z', 'y'); | |
$pattern = sprintf('@^(?<size>\d+([\.,]\d{1,2})?)(?<unit>[%s]?)(?<binary>i?)b?$@i', implode('', $units)); |
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 | |
function htmlify($text) | |
{ | |
$html = htmlspecialchars($text); | |
$html = " <p> " . preg_replace("@(\r\n|\n|\r){2,}@", " </p> <p> ", $html) . " </p> "; | |
$html = str_replace("\n", " <br> ", $html); | |
$html = preg_replace('/\s\s+/', ' ', $html); | |
$html = preg_replace_callback('/([a-z]+:\/\/)(\S+)/', function ($matches) { | |
$matches[2] = preg_replace('@^www\.@i', '', $matches[2]); |
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
jQuery(function($){ | |
$('audio,video') | |
.on('init ended pause play playing progress ratechange seeked seeking stalled suspend waiting', function () { | |
var obj = this, $obj = $(this); | |
if ($obj.is('.has-custom-controls')) { | |
$obj.removeAttr('controls'); | |
} | |
$.each(['ended', 'error', 'loop', 'muted', 'paused', 'seeking'], function (i, prop) { | |
try { | |
var bool = obj[prop]; |
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
{ | |
"config": { | |
"platform": { | |
"php": "5.3.10" | |
} | |
}, | |
"require": { | |
"doctrine/dbal": "^2.5", | |
"jdorn/sql-formatter": "^1.2" | |
} |
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 | |
$url = parse_url($_SERVER['REQUEST_URI'], PHP_URL_PATH); | |
$base = rtrim(str_replace('\\', '/', dirname($_SERVER['SCRIPT_NAME'])), '/'); | |
$len = strlen($base); | |
if (substr($url, 0, $len) == $base) { | |
$url = substr($url, $len); | |
} |
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 $sql = sprintf("SELECT GROUP_CONCAT(dc.document_category_id) as cat_ids, d.* | |
FROM %s dc | |
LEFT JOIN %s d ON(d.id = dc.document_id) | |
GROUP BY d.id | |
ORDER BY d.added", | |
DocumentCategorization::getBacktickTableName(), | |
Document::getBacktickTableName() | |
); | |
/** @var As_Database $db */ | |
$db = Document::getDb(); |
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 | |
function git_status($dir) { | |
$git_line = 'Unable to determine git hash'; | |
$git_dir = $dir . '/.git'; | |
$repo = null; | |
$submodule = null; | |
if (is_file($git_dir) && preg_match('@gitdir: (.*)@', trim(file_get_contents($git_dir)), $m)) { | |
$repo = basename($m[1]); |