X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=include%2Ftext.php;h=66447069e455ad6c53a9cd90a9514d14bd0361ba;hb=b57a01dc1418cc179ddd327af9d04a9e68e679e9;hp=adc94b4589800a1f65fba696c2438d83590e6bdb;hpb=8812b7f4caa99d01ae0e082c0b29a2ee24aed67d;p=friendica.git diff --git a/include/text.php b/include/text.php index adc94b4589..66447069e4 100644 --- a/include/text.php +++ b/include/text.php @@ -19,11 +19,18 @@ function replace_macros($s,$r) { }} -// random hex string, 64 chars max +// random string, there are 86 characters max in text mode, 128 for hex +// output is urlsafe + +define('RANDOM_STRING_HEX', 0x00 ); +define('RANDOM_STRING_TEXT', 0x01 ); if(! function_exists('random_string')) { -function random_string($size = 64) { - return(substr(hash('sha256',uniqid(rand(),true)),0,$size)); +function random_string($size = 64,$type = RANDOM_STRING_HEX) { + // generate a bit of entropy and run it through the whirlpool + $s = hash('whirlpool', (string) rand() . uniqid(rand(),true) . (string) rand(),(($type == RANDOM_STRING_TEXT) ? true : false)); + $s = (($type == RANDOM_STRING_TEXT) ? str_replace("\n","",base64url_encode($s,true)) : $s); + return(substr($s,0,$size)); }} /** @@ -140,7 +147,7 @@ if(! function_exists('xmlify')) { function xmlify($str) { $buffer = ''; - for($x = 0; $x < strlen($str); $x ++) { + for($x = 0; $x < mb_strlen($str); $x ++) { $char = $str[$x]; switch( $char ) { @@ -613,32 +620,6 @@ function valid_email($x){ }} -if(! function_exists('aes_decrypt')) { -function aes_decrypt($val,$ky) -{ - $key="\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"; - for($a=0;$a=0 and ord(substr($dec, strlen($dec)-1,1))<=16)? chr(ord( substr($dec,strlen($dec)-1,1))):null)); -}} - - -if(! function_exists('aes_encrypt')) { -function aes_encrypt($val,$ky) -{ - $key="\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"; - for($a=0;$a', '</3', @@ -688,7 +670,10 @@ function smilies($s) { ':-X', ':-D', '8-|', - '8-O' + '8-O', + '~friendika ~friendika', + 'DiasporaDiaspora*', + ), $s); }} @@ -892,20 +877,6 @@ function generate_user_guid() { } -function pkcs5_pad ($text, $blocksize) -{ - $pad = $blocksize - (strlen($text) % $blocksize); - return $text . str_repeat(chr($pad), $pad); -} - -function pkcs5_unpad($text) -{ - $pad = ord($text{strlen($text)-1}); - if ($pad > strlen($text)) return false; - if (strspn($text, chr($pad), strlen($text) - $pad) != $pad) return false; - return substr($text, 0, -1 * $pad); -} - function base64url_encode($s, $strip_padding = false) { @@ -937,3 +908,7 @@ function base64url_decode($s) { return base64_decode(strtr($s,'-_','+/')); } + +function cc_license() { +return '
' . t('Shared content is covered by the Creative Commons Attribution 3.0 license.') . '
'; +}