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
function validEmail(email){ | |
return /^(([^<>()[\]\\.,;:\s@\"]+(\.[^<>()[\]\\.,;:\s@\"]+)*)|(\".+\"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/.test(email); | |
} |
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
(function addXhrProgressEvent($) { | |
var originalXhr = $.ajaxSettings.xhr; | |
$.ajaxSetup({ | |
progress: function() { console.log("standard progress callback"); }, | |
xhr: function() { | |
var req = originalXhr(), that = this; | |
if (req) { | |
if (typeof req.addEventListener == "function") { | |
req.addEventListener("progress", function(evt) { | |
that.progress(evt); |
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 cleanChar = function(str){ | |
var f = [ | |
String.fromCharCode(8220), //“ | |
String.fromCharCode(8221), //” | |
String.fromCharCode(8216), //‘ | |
String.fromCharCode(8217), //‘ | |
String.fromCharCode(8211), //– | |
String.fromCharCode(8212), //— | |
String.fromCharCode(189), //½ | |
String.fromCharCode(188), //¼ |
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
function cleanUTF($some_string){ | |
//reject overly long 2 byte sequences, as well as characters above U+10000 and replace with ? | |
$some_string = preg_replace('/[\x00-\x08\x10\x0B\x0C\x0E-\x19\x7F]'. | |
'|[\x00-\x7F][\x80-\xBF]+'. | |
'|([\xC0\xC1]|[\xF0-\xFF])[\x80-\xBF]*'. | |
'|[\xC2-\xDF]((?![\x80-\xBF])|[\x80-\xBF]{2,})'. | |
'|[\xE0-\xEF](([\x80-\xBF](?![\x80-\xBF]))|(?![\x80-\xBF]{2})|[\x80-\xBF]{3,})/S', | |
'', $some_string ); | |
//reject overly long 3 byte sequences and UTF-16 surrogates and replace with ? |
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
error_reporting(E_ALL | E_STRICT); | |
// handle all error | |
ob_start(function($out){ | |
$e = error_get_last(); | |
if(!empty($e)) { | |
return $e['message'] . ' ( ' . $e['file'] . ' [' . $e['line'] . '] )'; | |
} | |
return $out; | |
}); |
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
Options -Indexes | |
Options +FollowSymLinks | |
IndexOptions +Charset=UTF-8 | |
RewriteEngine On | |
# forced domain | |
RewriteCond %{HTTP_HOST} !=paragon.local | |
RewriteRule ^.*$ paragon.local%{REQUEST_URI} [R,L] | |
# Hotlink prevention |
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
function delRec($dirPath){ | |
foreach( | |
new RecursiveIteratorIterator( | |
new RecursiveDirectoryIterator( | |
$dirPath, FilesystemIterator::SKIP_DOTS), RecursiveIteratorIterator::CHILD_FIRST) as $path) { | |
$path->isDir() ? rmdir($path->getPathname()) : unlink($path->getPathname()); | |
} | |
//uncomment to delete $dirPath | |
//rmdir($dirPath); |
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 dateToHuman = function(ds){ | |
if(ds=='0000-00-00 00:00:00') return 'never'; | |
ds = ds.replace(/\-/g,' ').replace(/\:/g,' ').split(' '); | |
var n = new Date(); | |
var d = new Date(ds[0]*1,((ds[1]*1)-1),ds[2]*1,ds[3]*1,ds[4]*1,ds[5]*1); | |
var del = (n.valueOf() - d.valueOf())/1000; | |
if(del<60) return 'Just now'; | |
var minute = Math.floor(del/60); |
NewerOlder