Changeset 2253

Show
Ignore:
Timestamp:
11/26/10 15:52:57 (18 months ago)
Author:
petsagouris
Message:

[Branch 1.5] Minor edits in functions folder.

Location:
branches/1.5/functions
Files:
2 modified

Legend:

Unmodified
Added
Removed
  • branches/1.5/functions/funcs.http.php

    r2152 r2253  
    7373        return $body; 
    7474} 
    75  
    76 ?> 
  • branches/1.5/functions/funcs.strings.php

    r2079 r2253  
    2424 * @link      http://www.hotarucms.org/ 
    2525 */ 
    26   
     26 
    2727// We need to set the default internal encoding for the functions to operate properly. 
    2828mb_internal_encoding("UTF-8"); 
     
    4141        $truncated = mb_substr(strip_tags($string), 0, $chars); // strips tags to prevent broken tags 
    4242 
    43         if( $dot && ($length >= $chars) ) { 
     43        if ($dot && ($length >= $chars)) { 
    4444                $truncated .= '...'; 
    4545        } 
     
    4747        return $truncated; 
    4848} 
    49  
    5049 
    5150/** 
     
    6059        $str = (string) $str; 
    6160        $remove = (string) $remove; 
    62          
    63         if( empty($remove) ) { 
     61 
     62        if (empty($remove)) { 
    6463                return rtrim($str); 
    6564        } 
    66          
     65 
    6766        $len = mb_strlen($remove); 
    6867        $offset = mb_strlen($str) - $len; 
    69          
    70         while( $offset > 0 && $offset == mb_strpos($str, $remove, $offset) ) { 
     68 
     69        while ($offset > 0 && $offset == mb_strpos($str, $remove, $offset)) { 
    7170                $str = mb_substr($str, 0, $offset); 
    7271                $offset = mb_strlen($str) - $len; 
    7372        } 
    74          
     73 
    7574        return rtrim($str); 
    7675} 
     
    8584function make_name($string, $delim = '_', $caps = true) 
    8685{ 
    87         $dep_array = array( ); 
     86        $dep_array = array(); 
    8887        $dep_array = explode($delim, trim($string)); 
    89         if( $caps ) { 
     88        if ($caps) { 
    9089                $dep_array = array_map('ucfirst', $dep_array); 
    9190                $string = implode(' ', $dep_array); 
     
    9392                $string = ucfirst(implode(' ', $dep_array)); 
    9493        } 
    95          
     94 
    9695        return $string; 
    9796} 
    98  
    9997 
    10098/** 
     
    109107        $chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxwz0123456789"; 
    110108        $string = ''; 
    111         for( $i = 0; $i < $length; $i++ ) { 
     109        for ($i = 0; $i < $length; $i++) { 
    112110                $rand_key = mt_rand(0, strlen($chars)); 
    113111                $string .= substr($chars, $rand_key, 1); 
     
    115113        return str_shuffle($string); 
    116114} 
    117  
    118115 
    119116/** 
     
    130127{ 
    131128        // htmlentities & Strip tags 
    132         if( $santype == 'all' ) { 
    133                 if( !get_magic_quotes_gpc() ) { 
     129        if ($santype == 'all') { 
     130                if (!get_magic_quotes_gpc()) { 
    134131                        return htmlentities(strip_tags($var, $allowable_tags), ENT_QUOTES, 'UTF-8'); 
    135132                } 
    136133                return stripslashes(htmlentities(strip_tags($var, $allowable_tags), ENT_QUOTES, 'UTF-8')); 
    137134        } 
    138          
     135 
    139136        // Strip tags 
    140         if( $santype == 'tags' ) { 
    141                 if( !get_magic_quotes_gpc() ) { 
     137        if ($santype == 'tags') { 
     138                if (!get_magic_quotes_gpc()) { 
    142139                        return strip_tags($var, $allowable_tags); 
    143140                } 
    144141                return stripslashes(strip_tags($var, $allowable_tags)); 
    145142        } 
    146          
     143 
    147144        // htmlentities 
    148         if( $santype == 'ents' ) { 
    149                 if( !get_magic_quotes_gpc() ) { 
     145        if ($santype == 'ents') { 
     146                if (!get_magic_quotes_gpc()) { 
    150147                        return htmlentities($var, ENT_QUOTES, 'UTF-8'); 
    151148                } 
     
    156153} 
    157154 
    158  
    159155/** 
    160156 * Make a url friendly - a dash-separated string 
     
    167163function make_url_friendly($input) 
    168164{ 
    169         $output = replace_symbols($input);         
     165        $output = replace_symbols($input); 
    170166        $output = mb_substr($output, 0, 240); 
    171167        $output = mb_strtolower($output, 'UTF-8'); 
    172         $output = trim($output);     
     168        $output = trim($output); 
    173169        //From Wordpress and http://www.bernzilla.com/item.php?id=1007 
    174170        $output = sanitize_title_with_dashes($output); 
    175         $output = urldecode($output);  
    176          
    177         if( $output ) { 
     171        $output = urldecode($output); 
     172 
     173        if ($output) { 
    178174                return $output; 
    179175        } 
     
    195191        // IN UTF-8 CHARACTER ENCODING !!! 
    196192        // Replace spaces with hyphens 
    197         $output = preg_replace('/\s+/', '-', $input); 
    198          
    199193        // Replace other characters 
    200         $output = str_replace("--", "-", $output);       
    201         $output = str_replace("/", "", $output); 
    202         $output = str_replace("\\", "", $output); 
    203         $output = str_replace("'", "", $output);       
    204         $output = str_replace(",", "", $output);       
    205         $output = str_replace(";", "", $output);       
    206         $output = str_replace(":", "", $output);           
    207         $output = str_replace(".", "-", $output);       
    208         $output = str_replace("?", "", $output);       
    209         $output = str_replace("=", "-", $output);       
    210         $output = str_replace("+", "", $output);  
    211         $output = str_replace("$", "", $output);           
    212         $output = str_replace("&", "", $output);           
    213         $output = str_replace("!", "", $output);       
    214         $output = str_replace(">>", "-", $output);       
    215         $output = str_replace(">", "-", $output);       
    216         $output = str_replace("<<", "-", $output);       
    217         $output = str_replace("<", "-", $output);       
    218         $output = str_replace("*", "", $output);       
    219         $output = str_replace(")", "", $output);       
    220         $output = str_replace("(", "", $output); 
    221         $output = str_replace("[", "", $output); 
    222         $output = str_replace("]", "", $output); 
    223         $output = str_replace("^", "", $output);     
    224         $output = str_replace("%", "", $output); 
    225         $output = str_replace("#", "", $output); 
    226         $output = str_replace("@", "", $output); 
    227         $output = str_replace("`", "", $output); 
    228         $output = str_replace("‘", "", $output); 
    229         $output = str_replace("’", "", $output); 
    230         $output = str_replace("“", "", $output); 
    231         $output = str_replace("”", "", $output); 
    232         $output = str_replace("~", "", $output); 
    233         $output = str_replace("–", "-", $output); 
    234         $output = str_replace("\"", "", $output); 
    235         $output = str_replace("|", "", $output); 
    236         $output = str_replace("«", "", $output); 
    237         $output = str_replace("»", "", $output); 
    238         $output = str_replace("‹", "", $output); 
    239         $output = str_replace("›", "", $output); 
    240         $output = str_replace("…", "", $output); 
    241         $output = str_replace("--", "-", $output); 
    242         $output = str_replace("---", "-", $output); 
    243         $output = str_replace("—", "-", $output); 
    244          
    245         return $output; 
    246 } 
    247  
     194        return str_replace(array( 
     195                '--' => '-', 
     196                '/' => '', 
     197                '\\' => '', 
     198                '\'' => '', 
     199                ',' => '', 
     200                ';' => '', 
     201                ':' => '', 
     202                '.' => '-', 
     203                '?' => '', 
     204                '=' => '-', 
     205                '+' => '', 
     206                '$' => '', 
     207                '&' => '', 
     208                '!' => '', 
     209                '>>' => '-', 
     210                '>' => '-', 
     211                '<<' => '-', 
     212                '<' => '-', 
     213                '*' => '', 
     214                ')' => '', 
     215                '(' => '', 
     216                '[' => '', 
     217                ']' => '', 
     218                '^' => '', 
     219                '%' => '', 
     220                '#' => '', 
     221                '@' => '', 
     222                '`' => '', 
     223                '‘' => '', 
     224                '’' => '', 
     225                '“' => '', 
     226                '”' => '', 
     227                '~' => '', 
     228                '–' => '-', 
     229                '"' => '', 
     230                '|' => '', 
     231                '«' => '', 
     232                '»' => '', 
     233                '‹' => '', 
     234                '›' => '', 
     235                '…' => '', 
     236                '--' => '-', 
     237                '---' => '-', 
     238                '—' => '-'), '', preg_replace('/\s+/', '-', $input)); 
     239} 
    248240 
    249241/** 
     
    257249{ 
    258250        $title = strip_tags($title); 
    259          
     251 
    260252        // Preserve escaped octets. 
    261253        $title = preg_replace('|%([a-fA-F0-9][a-fA-F0-9])|', '---$1---', $title); 
    262          
     254 
    263255        // Remove percent signs that are not part of an octet. 
    264256        $title = str_replace('%', '', $title); 
    265          
     257 
    266258        // Restore octets. 
    267259        $title = preg_replace('|---([a-fA-F0-9][a-fA-F0-9])---|', '%$1', $title); 
    268          
     260 
    269261        $title = remove_accents($title); 
    270          
     262 
    271263        $title = mb_strtolower($title, 'UTF-8'); 
    272264 
    273         if( seems_utf8($title) ) { 
     265        if (seems_utf8($title)) { 
    274266                $title = utf8_uri_encode($title, 200); 
    275267        } 
    276          
     268 
    277269        $title = preg_replace('/&.+?;/', '', $title); // kill entities 
    278270        $title = preg_replace('/[^%a-z0-9 _-]/', '', $title); 
     
    280272        $title = preg_replace('|-+|', '-', $title); 
    281273        $title = trim($title, '-'); 
    282          
     274 
    283275        return $title; 
    284276} 
    285277 
    286  
    287278/** 
    288279 * Remove accents from characters 
     
    293284 * Note: Borrowed from Wordpress 
    294285 */ 
    295 function remove_accents($string)  
    296 { 
    297         if( !preg_match('/[\x80-\xff]/', $string) ) { 
     286function remove_accents($string) 
     287{ 
     288        if (!preg_match('/[\x80-\xff]/', $string)) { 
    298289                return $string; 
    299290        } 
    300291 
    301         if( seems_utf8($string) ) { 
     292        if (seems_utf8($string)) { 
    302293                $chars = array( 
    303                 // Decompositions for Latin-1 Supplement 
    304                 chr(195).chr(128) => 'A', chr(195).chr(129) => 'A', 
    305                 chr(195).chr(130) => 'A', chr(195).chr(131) => 'A', 
    306                 chr(195).chr(132) => 'A', chr(195).chr(133) => 'A', 
    307                 chr(195).chr(135) => 'C', chr(195).chr(136) => 'E', 
    308                 chr(195).chr(137) => 'E', chr(195).chr(138) => 'E', 
    309                 chr(195).chr(139) => 'E', chr(195).chr(140) => 'I', 
    310                 chr(195).chr(141) => 'I', chr(195).chr(142) => 'I', 
    311                 chr(195).chr(143) => 'I', chr(195).chr(145) => 'N', 
    312                 chr(195).chr(146) => 'O', chr(195).chr(147) => 'O', 
    313                 chr(195).chr(148) => 'O', chr(195).chr(149) => 'O', 
    314                 chr(195).chr(150) => 'O', chr(195).chr(153) => 'U', 
    315                 chr(195).chr(154) => 'U', chr(195).chr(155) => 'U', 
    316                 chr(195).chr(156) => 'U', chr(195).chr(157) => 'Y', 
    317                 chr(195).chr(159) => 's', chr(195).chr(160) => 'a', 
    318                 chr(195).chr(161) => 'a', chr(195).chr(162) => 'a', 
    319                 chr(195).chr(163) => 'a', chr(195).chr(164) => 'a', 
    320                 chr(195).chr(165) => 'a', chr(195).chr(167) => 'c', 
    321                 chr(195).chr(168) => 'e', chr(195).chr(169) => 'e', 
    322                 chr(195).chr(170) => 'e', chr(195).chr(171) => 'e', 
    323                 chr(195).chr(172) => 'i', chr(195).chr(173) => 'i', 
    324                 chr(195).chr(174) => 'i', chr(195).chr(175) => 'i', 
    325                 chr(195).chr(177) => 'n', chr(195).chr(178) => 'o', 
    326                 chr(195).chr(179) => 'o', chr(195).chr(180) => 'o', 
    327                 chr(195).chr(181) => 'o', chr(195).chr(182) => 'o', 
    328                 chr(195).chr(182) => 'o', chr(195).chr(185) => 'u', 
    329                 chr(195).chr(186) => 'u', chr(195).chr(187) => 'u', 
    330                 chr(195).chr(188) => 'u', chr(195).chr(189) => 'y', 
    331                 chr(195).chr(191) => 'y', 
    332                 // Decompositions for Latin Extended-A 
    333                 chr(196).chr(128) => 'A', chr(196).chr(129) => 'a', 
    334                 chr(196).chr(130) => 'A', chr(196).chr(131) => 'a', 
    335                 chr(196).chr(132) => 'A', chr(196).chr(133) => 'a', 
    336                 chr(196).chr(134) => 'C', chr(196).chr(135) => 'c', 
    337                 chr(196).chr(136) => 'C', chr(196).chr(137) => 'c', 
    338                 chr(196).chr(138) => 'C', chr(196).chr(139) => 'c', 
    339                 chr(196).chr(140) => 'C', chr(196).chr(141) => 'c', 
    340                 chr(196).chr(142) => 'D', chr(196).chr(143) => 'd', 
    341                 chr(196).chr(144) => 'D', chr(196).chr(145) => 'd', 
    342                 chr(196).chr(146) => 'E', chr(196).chr(147) => 'e', 
    343                 chr(196).chr(148) => 'E', chr(196).chr(149) => 'e', 
    344                 chr(196).chr(150) => 'E', chr(196).chr(151) => 'e', 
    345                 chr(196).chr(152) => 'E', chr(196).chr(153) => 'e', 
    346                 chr(196).chr(154) => 'E', chr(196).chr(155) => 'e', 
    347                 chr(196).chr(156) => 'G', chr(196).chr(157) => 'g', 
    348                 chr(196).chr(158) => 'G', chr(196).chr(159) => 'g', 
    349                 chr(196).chr(160) => 'G', chr(196).chr(161) => 'g', 
    350                 chr(196).chr(162) => 'G', chr(196).chr(163) => 'g', 
    351                 chr(196).chr(164) => 'H', chr(196).chr(165) => 'h', 
    352                 chr(196).chr(166) => 'H', chr(196).chr(167) => 'h', 
    353                 chr(196).chr(168) => 'I', chr(196).chr(169) => 'i', 
    354                 chr(196).chr(170) => 'I', chr(196).chr(171) => 'i', 
    355                 chr(196).chr(172) => 'I', chr(196).chr(173) => 'i', 
    356                 chr(196).chr(174) => 'I', chr(196).chr(175) => 'i', 
    357                 chr(196).chr(176) => 'I', chr(196).chr(177) => 'i', 
    358                 chr(196).chr(178) => 'IJ', chr(196).chr(179) => 'ij', 
    359                 chr(196).chr(180) => 'J', chr(196).chr(181) => 'j', 
    360                 chr(196).chr(182) => 'K', chr(196).chr(183) => 'k', 
    361                 chr(196).chr(184) => 'k', chr(196).chr(185) => 'L', 
    362                 chr(196).chr(186) => 'l', chr(196).chr(187) => 'L', 
    363                 chr(196).chr(188) => 'l', chr(196).chr(189) => 'L', 
    364                 chr(196).chr(190) => 'l', chr(196).chr(191) => 'L', 
    365                 chr(197).chr(128) => 'l', chr(197).chr(129) => 'L', 
    366                 chr(197).chr(130) => 'l', chr(197).chr(131) => 'N', 
    367                 chr(197).chr(132) => 'n', chr(197).chr(133) => 'N', 
    368                 chr(197).chr(134) => 'n', chr(197).chr(135) => 'N', 
    369                 chr(197).chr(136) => 'n', chr(197).chr(137) => 'N', 
    370                 chr(197).chr(138) => 'n', chr(197).chr(139) => 'N', 
    371                 chr(197).chr(140) => 'O', chr(197).chr(141) => 'o', 
    372                 chr(197).chr(142) => 'O', chr(197).chr(143) => 'o', 
    373                 chr(197).chr(144) => 'O', chr(197).chr(145) => 'o', 
    374                 chr(197).chr(146) => 'OE', chr(197).chr(147) => 'oe', 
    375                 chr(197).chr(148) => 'R', chr(197).chr(149) => 'r', 
    376                 chr(197).chr(150) => 'R', chr(197).chr(151) => 'r', 
    377                 chr(197).chr(152) => 'R', chr(197).chr(153) => 'r', 
    378                 chr(197).chr(154) => 'S', chr(197).chr(155) => 's', 
    379                 chr(197).chr(156) => 'S', chr(197).chr(157) => 's', 
    380                 chr(197).chr(158) => 'S', chr(197).chr(159) => 's', 
    381                 chr(197).chr(160) => 'S', chr(197).chr(161) => 's', 
    382                 chr(197).chr(162) => 'T', chr(197).chr(163) => 't', 
    383                 chr(197).chr(164) => 'T', chr(197).chr(165) => 't', 
    384                 chr(197).chr(166) => 'T', chr(197).chr(167) => 't', 
    385                 chr(197).chr(168) => 'U', chr(197).chr(169) => 'u', 
    386                 chr(197).chr(170) => 'U', chr(197).chr(171) => 'u', 
    387                 chr(197).chr(172) => 'U', chr(197).chr(173) => 'u', 
    388                 chr(197).chr(174) => 'U', chr(197).chr(175) => 'u', 
    389                 chr(197).chr(176) => 'U', chr(197).chr(177) => 'u', 
    390                 chr(197).chr(178) => 'U', chr(197).chr(179) => 'u', 
    391                 chr(197).chr(180) => 'W', chr(197).chr(181) => 'w', 
    392                 chr(197).chr(182) => 'Y', chr(197).chr(183) => 'y', 
    393                 chr(197).chr(184) => 'Y', chr(197).chr(185) => 'Z', 
    394                 chr(197).chr(186) => 'z', chr(197).chr(187) => 'Z', 
    395                 chr(197).chr(188) => 'z', chr(197).chr(189) => 'Z', 
    396                 chr(197).chr(190) => 'z', chr(197).chr(191) => 's', 
    397                 // Euro Sign 
    398                 chr(226).chr(130).chr(172) => 'E', 
    399                 // GBP (Pound) Sign 
    400                 chr(194).chr(163) => '' ); 
    401                  
     294                        // Decompositions for Latin-1 Supplement 
     295                        chr(195).chr(128) => 'A', chr(195).chr(129) => 'A', 
     296                        chr(195).chr(130) => 'A', chr(195).chr(131) => 'A', 
     297                        chr(195).chr(132) => 'A', chr(195).chr(133) => 'A', 
     298                        chr(195).chr(135) => 'C', chr(195).chr(136) => 'E', 
     299                        chr(195).chr(137) => 'E', chr(195).chr(138) => 'E', 
     300                        chr(195).chr(139) => 'E', chr(195).chr(140) => 'I', 
     301                        chr(195).chr(141) => 'I', chr(195).chr(142) => 'I', 
     302                        chr(195).chr(143) => 'I', chr(195).chr(145) => 'N', 
     303                        chr(195).chr(146) => 'O', chr(195).chr(147) => 'O', 
     304                        chr(195).chr(148) => 'O', chr(195).chr(149) => 'O', 
     305                        chr(195).chr(150) => 'O', chr(195).chr(153) => 'U', 
     306                        chr(195).chr(154) => 'U', chr(195).chr(155) => 'U', 
     307                        chr(195).chr(156) => 'U', chr(195).chr(157) => 'Y', 
     308                        chr(195).chr(159) => 's', chr(195).chr(160) => 'a', 
     309                        chr(195).chr(161) => 'a', chr(195).chr(162) => 'a', 
     310                        chr(195).chr(163) => 'a', chr(195).chr(164) => 'a', 
     311                        chr(195).chr(165) => 'a', chr(195).chr(167) => 'c', 
     312                        chr(195).chr(168) => 'e', chr(195).chr(169) => 'e', 
     313                        chr(195).chr(170) => 'e', chr(195).chr(171) => 'e', 
     314                        chr(195).chr(172) => 'i', chr(195).chr(173) => 'i', 
     315                        chr(195).chr(174) => 'i', chr(195).chr(175) => 'i', 
     316                        chr(195).chr(177) => 'n', chr(195).chr(178) => 'o', 
     317                        chr(195).chr(179) => 'o', chr(195).chr(180) => 'o', 
     318                        chr(195).chr(181) => 'o', chr(195).chr(182) => 'o', 
     319                        chr(195).chr(182) => 'o', chr(195).chr(185) => 'u', 
     320                        chr(195).chr(186) => 'u', chr(195).chr(187) => 'u', 
     321                        chr(195).chr(188) => 'u', chr(195).chr(189) => 'y', 
     322                        chr(195).chr(191) => 'y', 
     323                        // Decompositions for Latin Extended-A 
     324                        chr(196).chr(128) => 'A', chr(196).chr(129) => 'a', 
     325                        chr(196).chr(130) => 'A', chr(196).chr(131) => 'a', 
     326                        chr(196).chr(132) => 'A', chr(196).chr(133) => 'a', 
     327                        chr(196).chr(134) => 'C', chr(196).chr(135) => 'c', 
     328                        chr(196).chr(136) => 'C', chr(196).chr(137) => 'c', 
     329                        chr(196).chr(138) => 'C', chr(196).chr(139) => 'c', 
     330                        chr(196).chr(140) => 'C', chr(196).chr(141) => 'c', 
     331                        chr(196).chr(142) => 'D', chr(196).chr(143) => 'd', 
     332                        chr(196).chr(144) => 'D', chr(196).chr(145) => 'd', 
     333                        chr(196).chr(146) => 'E', chr(196).chr(147) => 'e', 
     334                        chr(196).chr(148) => 'E', chr(196).chr(149) => 'e', 
     335                        chr(196).chr(150) => 'E', chr(196).chr(151) => 'e', 
     336                        chr(196).chr(152) => 'E', chr(196).chr(153) => 'e', 
     337                        chr(196).chr(154) => 'E', chr(196).chr(155) => 'e', 
     338                        chr(196).chr(156) => 'G', chr(196).chr(157) => 'g', 
     339                        chr(196).chr(158) => 'G', chr(196).chr(159) => 'g', 
     340                        chr(196).chr(160) => 'G', chr(196).chr(161) => 'g', 
     341                        chr(196).chr(162) => 'G', chr(196).chr(163) => 'g', 
     342                        chr(196).chr(164) => 'H', chr(196).chr(165) => 'h', 
     343                        chr(196).chr(166) => 'H', chr(196).chr(167) => 'h', 
     344                        chr(196).chr(168) => 'I', chr(196).chr(169) => 'i', 
     345                        chr(196).chr(170) => 'I', chr(196).chr(171) => 'i', 
     346                        chr(196).chr(172) => 'I', chr(196).chr(173) => 'i', 
     347                        chr(196).chr(174) => 'I', chr(196).chr(175) => 'i', 
     348                        chr(196).chr(176) => 'I', chr(196).chr(177) => 'i', 
     349                        chr(196).chr(178) => 'IJ', chr(196).chr(179) => 'ij', 
     350                        chr(196).chr(180) => 'J', chr(196).chr(181) => 'j', 
     351                        chr(196).chr(182) => 'K', chr(196).chr(183) => 'k', 
     352                        chr(196).chr(184) => 'k', chr(196).chr(185) => 'L', 
     353                        chr(196).chr(186) => 'l', chr(196).chr(187) => 'L', 
     354                        chr(196).chr(188) => 'l', chr(196).chr(189) => 'L', 
     355                        chr(196).chr(190) => 'l', chr(196).chr(191) => 'L', 
     356                        chr(197).chr(128) => 'l', chr(197).chr(129) => 'L', 
     357                        chr(197).chr(130) => 'l', chr(197).chr(131) => 'N', 
     358                        chr(197).chr(132) => 'n', chr(197).chr(133) => 'N', 
     359                        chr(197).chr(134) => 'n', chr(197).chr(135) => 'N', 
     360                        chr(197).chr(136) => 'n', chr(197).chr(137) => 'N', 
     361                        chr(197).chr(138) => 'n', chr(197).chr(139) => 'N', 
     362                        chr(197).chr(140) => 'O', chr(197).chr(141) => 'o', 
     363                        chr(197).chr(142) => 'O', chr(197).chr(143) => 'o', 
     364                        chr(197).chr(144) => 'O', chr(197).chr(145) => 'o', 
     365                        chr(197).chr(146) => 'OE', chr(197).chr(147) => 'oe', 
     366                        chr(197).chr(148) => 'R', chr(197).chr(149) => 'r', 
     367                        chr(197).chr(150) => 'R', chr(197).chr(151) => 'r', 
     368                        chr(197).chr(152) => 'R', chr(197).chr(153) => 'r', 
     369                        chr(197).chr(154) => 'S', chr(197).chr(155) => 's', 
     370                        chr(197).chr(156) => 'S', chr(197).chr(157) => 's', 
     371                        chr(197).chr(158) => 'S', chr(197).chr(159) => 's', 
     372                        chr(197).chr(160) => 'S', chr(197).chr(161) => 's', 
     373                        chr(197).chr(162) => 'T', chr(197).chr(163) => 't', 
     374                        chr(197).chr(164) => 'T', chr(197).chr(165) => 't', 
     375                        chr(197).chr(166) => 'T', chr(197).chr(167) => 't', 
     376                        chr(197).chr(168) => 'U', chr(197).chr(169) => 'u', 
     377                        chr(197).chr(170) => 'U', chr(197).chr(171) => 'u', 
     378                        chr(197).chr(172) => 'U', chr(197).chr(173) => 'u', 
     379                        chr(197).chr(174) => 'U', chr(197).chr(175) => 'u', 
     380                        chr(197).chr(176) => 'U', chr(197).chr(177) => 'u', 
     381                        chr(197).chr(178) => 'U', chr(197).chr(179) => 'u', 
     382                        chr(197).chr(180) => 'W', chr(197).chr(181) => 'w', 
     383                        chr(197).chr(182) => 'Y', chr(197).chr(183) => 'y', 
     384                        chr(197).chr(184) => 'Y', chr(197).chr(185) => 'Z', 
     385                        chr(197).chr(186) => 'z', chr(197).chr(187) => 'Z', 
     386                        chr(197).chr(188) => 'z', chr(197).chr(189) => 'Z', 
     387                        chr(197).chr(190) => 'z', chr(197).chr(191) => 's', 
     388                        // Euro Sign 
     389                        chr(226).chr(130).chr(172) => 'E', 
     390                        // GBP (Pound) Sign 
     391                        chr(194).chr(163) => ''); 
     392 
    402393                $string = strtr($string, $chars); 
    403         } 
    404         else { 
     394        } else { 
    405395                // Assume ISO-8859-1 if not UTF-8 
    406396                $chars['in'] = chr(128).chr(131).chr(138).chr(142).chr(154).chr(158) 
    407                         .chr(159).chr(162).chr(165).chr(181).chr(192).chr(193).chr(194) 
    408                         .chr(195).chr(196).chr(197).chr(199).chr(200).chr(201).chr(202) 
    409                         .chr(203).chr(204).chr(205).chr(206).chr(207).chr(209).chr(210) 
    410                         .chr(211).chr(212).chr(213).chr(214).chr(216).chr(217).chr(218) 
    411                         .chr(219).chr(220).chr(221).chr(224).chr(225).chr(226).chr(227) 
    412                         .chr(228).chr(229).chr(231).chr(232).chr(233).chr(234).chr(235) 
    413                         .chr(236).chr(237).chr(238).chr(239).chr(241).chr(242).chr(243) 
    414                         .chr(244).chr(245).chr(246).chr(248).chr(249).chr(250).chr(251) 
    415                         .chr(252).chr(253).chr(255); 
     397                                .chr(159).chr(162).chr(165).chr(181).chr(192).chr(193).chr(194) 
     398                                .chr(195).chr(196).chr(197).chr(199).chr(200).chr(201).chr(202) 
     399                                .chr(203).chr(204).chr(205).chr(206).chr(207).chr(209).chr(210) 
     400                                .chr(211).chr(212).chr(213).chr(214).chr(216).chr(217).chr(218) 
     401                                .chr(219).chr(220).chr(221).chr(224).chr(225).chr(226).chr(227) 
     402                                .chr(228).chr(229).chr(231).chr(232).chr(233).chr(234).chr(235) 
     403                                .chr(236).chr(237).chr(238).chr(239).chr(241).chr(242).chr(243) 
     404                                .chr(244).chr(245).chr(246).chr(248).chr(249).chr(250).chr(251) 
     405                                .chr(252).chr(253).chr(255); 
    416406 
    417407                $chars['out'] = "EfSZszYcYuAAAAAACEEEEIIIINOOOOOOUUUUYaaaaaaceeeeiiiinoooooouuuuyy"; 
    418                  
     408 
    419409                $string = strtr($string, $chars['in'], $chars['out']); 
    420                 $double_chars['in'] = array( chr(140), chr(156), chr(198), chr(208), chr(222), chr(223), chr(230), chr(240), chr(254) ); 
    421                 $double_chars['out'] = array( 'OE', 'oe', 'AE', 'DH', 'TH', 'ss', 'ae', 'dh', 'th' ); 
     410                $double_chars['in'] = array(chr(140), chr(156), chr(198), chr(208), chr(222), chr(223), chr(230), chr(240), chr(254)); 
     411                $double_chars['out'] = array('OE', 'oe', 'AE', 'DH', 'TH', 'ss', 'ae', 'dh', 'th'); 
    422412                $string = str_replace($double_chars['in'], $double_chars['out'], $string); 
    423     } 
     413        } 
    424414 
    425415        return $string; 
    426416} 
    427  
    428417 
    429418/** 
     
    438427{ 
    439428        $length = strlen($str); 
    440         for( $i = 0; $i < $length; $i++ ) { 
    441                 if( ord($str[$i]) < 0x80 ) { 
     429        for ($i = 0; $i < $length; $i++) { 
     430                if (ord($str[$i]) < 0x80) { 
    442431                        continue; // 0bbbbbbb  
    443                 } elseif( (ord($str[$i]) & 0xE0) == 0xC0 ) { 
     432                } elseif ((ord($str[$i]) & 0xE0) == 0xC0) { 
    444433                        $n = 1; // 110bbbbb 
    445                 } elseif( (ord($str[$i]) & 0xF0) == 0xE0 ) { 
     434                } elseif ((ord($str[$i]) & 0xF0) == 0xE0) { 
    446435                        $n = 2; // 1110bbbb 
    447                 } elseif( (ord($str[$i]) & 0xF8) == 0xF0 ) { 
     436                } elseif ((ord($str[$i]) & 0xF8) == 0xF0) { 
    448437                        $n = 3; // 11110bbb 
    449                 } elseif( (ord($str[$i]) & 0xFC) == 0xF8 ) { 
     438                } elseif ((ord($str[$i]) & 0xFC) == 0xF8) { 
    450439                        $n = 4; // 111110bb 
    451                 } elseif( (ord($str[$i]) & 0xFE) == 0xFC ) { 
     440                } elseif ((ord($str[$i]) & 0xFE) == 0xFC) { 
    452441                        $n = 5; // 1111110b 
    453442                } else { 
    454443                        return false; // Does not match any model 
    455444                } 
    456                  
    457                 for( $j = 0; $j < $n; $j++ ) { 
     445 
     446                for ($j = 0; $j < $n; $j++) { 
    458447                        // n bytes matching 10bbbbbb follow ? 
    459                         if( (++$i == $length) || ((ord($str[$i]) & 0xC0) != 0x80) ) { 
     448                        if ((++$i == $length) || ((ord($str[$i]) & 0xC0) != 0x80)) { 
    460449                                return false; 
    461450                        } 
     
    465454} 
    466455 
    467  
    468456/** 
    469457 * Encodes a utf8 string 
     
    478466{ 
    479467        $unicode = ''; 
    480         $values = array( ); 
     468        $values = array(); 
    481469        $num_octets = 1; 
    482470        $unicode_length = 0; 
    483471 
    484472        $string_length = strlen($utf8_string); 
    485         for( $i = 0; $i < $string_length; $i++ ) { 
     473        for ($i = 0; $i < $string_length; $i++) { 
    486474                $value = ord($utf8_string[$i]); 
    487                  
    488                 if( $value < 128 ) { 
    489                         if( $length && ( $unicode_length >= $length ) ) { 
     475 
     476                if ($value < 128) { 
     477                        if ($length && ( $unicode_length >= $length )) { 
    490478                                break; 
    491479                        } 
     
    493481                        $unicode_length++; 
    494482                } else { 
    495                         if( count($values) == 0 ) { 
     483                        if (count($values) == 0) { 
    496484                                $num_octets = ( $value < 224 ) ? 2 : 3; 
    497485                        } 
    498                          
     486 
    499487                        $values[] = $value; 
    500                          
    501                         if( $length && ($unicode_length + ($num_octets * 3)) > $length ) { 
     488 
     489                        if ($length && ($unicode_length + ($num_octets * 3)) > $length) { 
    502490                                break; 
    503491                        } 
    504                          
    505                         if( count($values) == $num_octets ) { 
    506                                 if( $num_octets == 3 ) { 
     492 
     493                        if (count($values) == $num_octets) { 
     494                                if ($num_octets == 3) { 
    507495                                        $unicode .= '%'.dechex($values[0]).'%'.dechex($values[1]).'%'.dechex($values[2]); 
    508496                                        $unicode_length += 9; 
     
    511499                                        $unicode_length += 6; 
    512500                                } 
    513                                  
    514                                 $values = array( ); 
     501 
     502                                $values = array(); 
    515503                                $num_octets = 1; 
    516504                        } 
     
    521509} 
    522510 
    523  
    524511/** 
    525512 * Strip domain from url 
     
    531518{ 
    532519        $parsed = parse_url($url); 
    533         if( isset($parsed['scheme']) ) { 
     520        if (isset($parsed['scheme'])) { 
    534521                $domain = $parsed['scheme']."://".$parsed['host']; 
    535522                return $domain; 
    536523        } 
    537          
     524 
    538525        return false; 
    539526} 
    540527 
    541 if( !function_exists("iconv") ) { 
     528if (!function_exists("iconv")) { 
    542529 
    543530        /** 
     
    552539        function iconv($from, $to, $string) 
    553540        { 
    554                 $converted = htmlentities($string, ENT_NOQUOTES, $from);  
     541                $converted = htmlentities($string, ENT_NOQUOTES, $from); 
    555542                $converted = html_entity_decode($converted, ENT_NOQUOTES, $to); 
    556543                return $converted; 
     
    570557        $href = substr_count($text, "href"); 
    571558        $url = substr_count($text, "[url"); 
    572          
     559 
    573560        return $href + $url; 
    574561} 
     
    580567 * @return string 
    581568 */ 
    582 function make_urls_clickable($string)  
     569function make_urls_clickable($string) 
    583570{ 
    584571        $string = trim($string); 
    585572        // Super RegEx for converting urls into clickable links unless already in an anchor tag.         
    586         $string = preg_replace('|(?<!href=[\"\'])(https?://[A-Za-z0-9+\-=._/*(),@\'$:;&!?%]+)|i', '<a href="$1">$1</a>', $string);       
     573        $string = preg_replace('|(?<!href=[\"\'])(https?://[A-Za-z0-9+\-=._/*(),@\'$:;&!?%]+)|i', '<a href="$1">$1</a>', $string); 
    587574        // Add nofollow to links 
    588575        $string = preg_replace('/a[ ]+href[ ]*=[ ]*"http:\/\/(.*?)".*?/i', 'a href="http://$1" rel="nofollow"', $string); 
     
    605592        return $str; 
    606593} 
    607 ?>