X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;ds=sidebyside;f=include%2Ftext.php;h=66447069e455ad6c53a9cd90a9514d14bd0361ba;hb=a3eb73ed11fb9940755b2a3e6d996232609c0e7f;hp=d53a2ceb9ae7905a554af14cabd4e3d8a14598c1;hpb=d45a66e700a62626007b05ef1b78dff8f0931210;p=friendica.git diff --git a/include/text.php b/include/text.php index d53a2ceb9a..66447069e4 100644 --- a/include/text.php +++ b/include/text.php @@ -19,11 +19,18 @@ function replace_macros($s,$r) { }} -// random hash, 64 chars +// 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() { - return(hash('sha256',uniqid(rand(),true))); +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); }} @@ -878,10 +863,10 @@ function return_bytes ($size_str) { } }} -function generate_guid() { +function generate_user_guid() { $found = true; do { - $guid = substr(random_string(),0,16); + $guid = random_string(16); $x = q("SELECT `uid` FROM `user` WHERE `guid` = '%s' LIMIT 1", dbesc($guid) ); @@ -892,20 +877,6 @@ function generate_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.') . '
'; +}