diff options
author | friendica <info@friendica.com> | 2012-07-30 21:51:25 -0700 |
---|---|---|
committer | friendica <info@friendica.com> | 2012-07-30 21:51:25 -0700 |
commit | 65160ffd12500260ffd723bcffe721a3cc38d7da (patch) | |
tree | 334d60dccab197ebf64f1092222f65ba42ae8c75 /include | |
parent | 02cc436ec7cf0cfca5fc9b5166cc537bbee53671 (diff) | |
download | volse-hubzilla-65160ffd12500260ffd723bcffe721a3cc38d7da.tar.gz volse-hubzilla-65160ffd12500260ffd723bcffe721a3cc38d7da.tar.bz2 volse-hubzilla-65160ffd12500260ffd723bcffe721a3cc38d7da.zip |
functions to generate and check webbies interactively
Diffstat (limited to 'include')
-rw-r--r-- | include/text.php | 45 |
1 files changed, 45 insertions, 0 deletions
diff --git a/include/text.php b/include/text.php index 9d52fd076..3e4817898 100644 --- a/include/text.php +++ b/include/text.php @@ -1655,3 +1655,48 @@ function is_a_date_arg($s) { } return false; } + +function legal_webbie($s) { + if(! strlen($s)) + return ''; + + $x = $s; + do { + $s = $x; + $x = preg_replace('/^([^a-z])(.*?)/',"$2",$s); + } while($x != $s); + + return preg_replace('/([^a-z0-9\-\_])/','',$x); +} + + +function check_webbie($arr) { + + $str = ''; + $taken = array(); + if(count($arr)) { + foreach($arr as $x) { + $y = legal_webbie($x); + if(strlen($y)) { + if($str) + $str .= ','; + $str .= "'" . dbesc($y) . "'"; + } + } + if(strlen($str)) { + $r = q("select entity_address from entity where entity_address in ( $str ) "); + if(count($r)) { + foreach($r as $rr) { + $taken[] = $rr['entity_address']; + } + } + foreach($arr as $x) { + if(! in_array($x,$taken)) { + return $x; + } + } + } + } + return ''; +} +
\ No newline at end of file |