+if(! function_exists('allowed_url')) {
+function allowed_url($url) {
+
+ $h = parse_url($url);
+
+ if(! $h) {
+ return false;
+ }
+
+ $str_allowed = get_config('system','allowed_sites');
+ if(! $str_allowed)
+ return true;
+
+ $found = false;
+
+ $host = strtolower($h['host']);
+
+ // always allow our own site
+
+ if($host == strtolower($_SERVER['SERVER_NAME']))
+ return true;
+
+ $fnmatch = function_exists('fnmatch');
+ $allowed = explode(',',$str_allowed);
+
+ if(count($allowed)) {
+ foreach($allowed as $a) {
+ $pat = strtolower(trim($a));
+ if(($fnmatch && fnmatch($pat,$host)) || ($pat == $host)) {
+ $found = true;
+ break;
+ }
+ }
+ }
+ return $found;
+}}
+
+if(! function_exists('format_like')) {
+function format_like($cnt,$arr,$type,$id) {
+ if($cnt == 1)
+ $o .= $arr[0] . (($type == 'like') ? t(' likes this.') : t(' doesn\'t like this.')) . EOL ;
+ else {
+ $o .= '<span class="fakelink" onclick="openClose(\'' . $type . 'list-' . $id . '\');" >'
+ . $cnt . ' ' . t('people') . '</span> ' . (($type == 'like') ? t('like this.') : t('don\'t like this.')) . EOL ;
+ $total = count($arr);
+ if($total >= 75)
+ $arr = array_slice($arr,0,74);
+ if($total < 75)
+ $arr[count($arr)-1] = t('and') . ' ' . $arr[count($arr)-1];
+ $str = implode(', ', $arr);
+ if($total >= 75)
+ $str .= t(', and ') . $total - 75 . t(' other people');
+ $str .= (($type == 'like') ? t(' like this.') : t(' don\'t like this.'));
+ $o .= '<div id="' . $type . 'list-' . $id . '" style="display: none;" >' . $str . '</div>';
+ }
+ return $o;
+}}