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 escapeHtml(str) { | |
escapeHtml.tmp.innerText = str; | |
var res = escapeHtml.tmp.innerHTML.replace(escapeHtml.quot, '"').replace(escapeHtml.apos, '''); | |
return res; | |
} | |
escapeHtml.tmp = document.createElement('span'); | |
escapeHtml.quot = /"/g; | |
escapeHtml.apos = /'/g; |
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 RandomIdGenerator() { | |
var self = this; | |
var lut = RandomIdGenerator.lut; | |
var myCounter = ++RandomIdGenerator.counter; | |
var idCounter = 0; | |
self.get = function() { | |
++idCounter; |
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
module.exports = deepCopy; | |
/** | |
* Deep copy an object (make copies of all its object properties, sub-properties, etc.) | |
* An improved version of http://keithdevens.com/weblog/archive/2007/Jun/07/javascript.clone | |
* that doesn't break if the constructor has required parameters | |
* | |
* It also borrows some code from http://stackoverflow.com/a/11621004/560114 | |
*/ | |
function deepCopy(src, /* INTERNAL */ _visited, _copiesVisited) { |
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 randomKey() { | |
var r='', l=0; | |
do { | |
r += Math.random().toString(16).replace(/[01]\./g, ''); | |
} while (r.length < 32 && l++ < 32); | |
return r.substr(-32, 32); | |
}; |
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 | |
/** | |
* Check if a given ip is in a network | |
* @param string $ip IP to check in IPV4 format eg. 127.0.0.1 | |
* @param string $range IP/CIDR netmask eg. 127.0.0.0/24, also 127.0.0.1 is accepted and /32 assumed. Hostnames are accepted, too. | |
* @return boolean true if the ip is in this range / false if not. | |
*/ | |
function ip_in_range( $ip, $range ) { | |
if (!preg_match('/^[0-9\.]+$/', $ip)) { |
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://de.wikipedia.org/wiki/HTTP-Statuscode | |
return array( | |
0 => 'OK', | |
100 => 'Continue', | |
101 => 'Switching Protocols', | |
102 => 'Processing', | |
200 => 'OK', | |
201 => 'Created', |
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 | |
// APR1-MD5 encryption method (windows compatible) | |
// https://gist.github.com/BlaM/f3a9d535963900d1fbddc890c66f3891 | |
// | |
// 2019-04-09 - https://github.com/BlaM - $salt | |
// 2022-03-04 - https://github.com/BlaM - fix php7 deprecation warning | |
// 2023-01-11 - https://github.com/BlaM and https://github.com/alecos71 - prepare for php8 sunset of str_shuffle | |
function crypt_apr1_md5($plainpasswd, $salt = null) { | |
if (empty($salt)) { | |
$chars = 'abcdefghijklmnopqrstuvwxyz012345689'; |
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
if (!defined('__PUBLIC__')) define('__PUBLIC__', __FILE__); | |
define('SCHEMA', (isset($_SERVER['HTTPS']) && strtolower($_SERVER['HTTPS']) == 'on' ) ? 'https' : 'http'); | |
define('ROOT_LINK', str_replace(array(str_replace($_SERVER['SCRIPT_NAME'], '', $_SERVER['SCRIPT_FILENAME']), basename(__PUBLIC__)), array('', ''), __PUBLIC__)); | |
define('ROOT_URL', SCHEMA . '://' . $_SERVER['HTTP_HOST'] . ROOT_LINK); | |
define('ROOT_URL_NO_SLASH', substr(ROOT_URL, 0, -1)); |
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 add_query($url, $params, $replace = false) { | |
$pu = parse_url($url); | |
foreach ($params as $k => $v) { | |
$np = $k . '=' . urlencode($v); | |
if ($replace && preg_match('/(^|&)' . $k . '=/', $pu['query'])) { | |
$pu['query'] = preg_replace('/(^|&)' . $k . '=([^&]*)?/', '$1' . str_replace('$', '\$', $np), $pu['query']); |
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
<?xml version="1.0" encoding="utf-8"?> | |
<phonebooks> | |
<phonebook owner="1" name="SPAM"> | |
<contact> | |
<category>0</category> | |
<person> | |
<realName>[SPAM] Adwords</realName> | |
</person> | |
<telephony nid="9"> | |
<number type="home" prio="1" id="0">023199953665</number> |
NewerOlder