View Single Post
  #1  
Old 07-18-2006, 12:21 AM
Michael Morris's Avatar
Michael Morris Michael Morris is offline
 
Join Date: Nov 2003
Location: Knoxville TN
Posts: 774
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default Bork! Bork! Bork! (Help!!!!!)

As a joke I'd like to punish certain users on my boards by making their posts into Swedish Chef speak. I found this code...

PHP Code:
#########################################################
#                                                       #
#  PHP Encheferizer 0.9 (20-5-2003)                     #
#  Convert English to Mock Swedish.                     #
#  Ported to PHP by eamelink (Erik Bakker)              #
#  PHP Encheferizer website : http://bork.eamelink.nl   #
#                                                       #     
#  Based on the original chef.x from John Hagerman.     #
#  More info about the original chef.x :                #
#  http://tbrowne.best.vwh.net/chef/                    #
#                                                       #
#  Works like :                                         #
#    $chef = new encheferizer();                        #
#    $swedish = $chef->encheferize($string);            #
#                                                       #
#########################################################
class encheferizer
{
    function 
encheferizer() {}

    function 
encheferize($string)
    {
        
$delimiters " \n\t\\,<.>/?;:'\"[{]}|=+-_!@#$%^&*()~`";
        
$newline "";
        
$word "";
        for(
$i 0$i strlen($string); $i++){
            
$s substr($string$i1);
                                      
            if((
$position strstr($delimiters$s)) === false){ 

                
$word .= $s;
  
             } else {
                if(!empty(
$word)){
                    
$newline .= $this->encheferizeWord($word);
                    
$word "";
                }
                if(
$s == "." || $s == "!"){
                    if(
rand(0,3) == 1){  
                        
$newline .= ", Bork Bork Bork!";
                        
                    } else {
                        
$newline .= ".";
                    }
                } else {
                    
$newline .= $s;
                }
            }
        }
        
$newline .= $this->encheferizeWord($word);
        return 
$newline;    
    }
    
    function 
encheferizeWord($word)
    {
        if(
strtolower($word) == "bork"){
            return 
$word;
        }
        
$newword "";    

        
$i 0;
        while(
$i strlen($word)){
            
$char substr($word$i1);
            
$isLast = ($i == strlen($word) - 1) ? true false;   
            
$iSeen false;
            if(
$i == 0){ 
                switch(
$char){
                case 
"e":
                    
$newword "i";
                    
$i++;
                    continue 
2;
                    break;
                case 
"E":
                    
$newword "I";
                    
$i++;
                    continue 
2;
                    break;
                case 
"o":
                    
$newword "oo";
                    
$i++;
                    continue 
2;
                    break;
                case 
"O":
                    
$newword "Oo";
                    
$i++;
                    continue 
2;
                    break;
                }
                
            } else {
                if(
$char == "e"){
                    if(!
$isLast && substr($word$i 11) == "w"){
                        
$newword .= 'oo';
                        
                        
$i+=2
                        continue;
                    } elseif(
$isLast){
                        
$newword .= 'e-a';
                        
$i++;
                        continue;
                    }
                    
                } elseif(
$char == "f"){
                    
$newword .= "ff"
                    
$i++;
                    continue;
                } elseif(
$char == "i"){
                    if(!
$isLast && substr($word$i 11) == "r"){
                        
$newword .= "ur";
                        
$i+=2;
                        continue;
                    } elseif(!
$iSeen){
                        
$newword .= "ee";
                        
$i++;
                        
                        
$iSeen true;
                        continue;
                    }
                } elseif(
$char == "o"){
                    if(!
$isLast && substr($word$i 11) == "w"){
                        
$newword .= "oo";
                        
$i+=2;
                        continue;
                    } else {
                        
$newword .= "u";
                        
$i++;
                        continue;
                    }
                } elseif(
$i <= strlen($word 4) && $char == "t" && substr($word$i 11) == "i" 
                            
&& substr($word$i 21) == "o" && substr($word$i 31) == "n"){  // Caption -> Capshun
                    
$newword .= "shun";
                    
$i += 4;
                    continue;
                } elseif(
$char == "u"){
                    
$newword .= "oo";
                    
$i++;
                    continue;
                } elseif(
$char == "U"){
                    
$newword .= "Oo";
                    
$i++;
                    continue;
                }
            } 
// En of In-word rules
            // Things that may be replaced anywhere
            
if($char == "A"){
                if(!
$isLast && substr($word$i+11) == "n"){
                    
$newword .= "Un";
                    
$i+=2;
                    continue;
                } elseif(!
$isLast && substr($word$i+11) == "u"){
                    
$newword .= "Oo";
                    
$i+=2;
                    continue;
                } elseif(!
$isLast){
                    
$newword .= "E";
                    
$i++;
                    continue;
                } 
            } elseif(
$char == "a"){
                if(!
$isLast && substr($word$i+11) == "n"){
                    
$newword .= "un";
                    
$i+=2;
                    continue;
                } elseif(!
$isLast && substr($word$i+11) == "u"){
                    
$newword .= "oo";
                    
$i+=2;
                    continue;
                } elseif(!
$isLast){
                    
$newword .= "e";
                    
$i++;
                    continue;
                } 
            } elseif(
$char == "e"){
                if(!
$isLast && substr($word$i+11) == "n" && $i == strlen($word) - 2){
                    
$newword .= "ee";
                    
$i+=2;
                    continue;
                } elseif (
$i 0){
                    
// Do nothing
                    
                
}
            } elseif(
$char == "t"){
                if(
$i == strlen($word) -&& substr($word$i+1$i) == "h"){
                    
$newword .= "t";
                    
$i+=2;
                    continue;
                } elseif(
$i <= strlen($word) - && substr($word$i+11) == "h" && substr($word$i+21) == "e"){
                    
$newword .= "zee";
                    
$i+=3;
                    continue;
                }
            } elseif(
$char == "T" && $i<= strlen($word)-&& substr($word$i+11) == "h"
                        
&& substr($word$i+21) == "e"){
                
$newword .= "Zee";
                
$i +=3;
                continue;
                
            } elseif(
$char == "v"){
                
$newword .= "f";
                
$i++;
                continue;
            } elseif(
$char == "V"){
                
$newword .= "F";
                
$i++;
                continue;
            } elseif(
$char == "w"){
                
$newword .= "v";
                
$i++;
                continue;
            } elseif(
$char == "W"){
                
$newword .= "V";
                
$i++;
                continue;
            } 
            
            
$newword .= $char;
            
$i++;   
                
                
                
        } 
// End of FOR lus
        
        
return $newword;
    }
}

// Now init our chefspeakers

$chefspeakers = array('438'); 
Problem with this code is it alters the text appearing in the bbcodes if I call it at postbit start and it messes with the html if I use it at postbit complete. Any ideas on how I might get this thing to leave any text occuring within html tags or bbcode tags alone?
Reply With Quote
 
X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.01365 seconds
  • Memory Usage 1,965KB
  • Queries Executed 11 (?)
More Information
Template Usage:
  • (1)SHOWTHREAD_SHOWPOST
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (1)bbcode_php
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)post_thanks_box
  • (1)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (1)post_thanks_postbit_info
  • (1)postbit
  • (1)postbit_onlinestatus
  • (1)postbit_wrapper
  • (1)spacer_close
  • (1)spacer_open 

Phrase Groups Available:
  • global
  • postbit
  • reputationlevel
  • showthread
Included Files:
  • ./showpost.php
  • ./global.php
  • ./includes/init.php
  • ./includes/class_core.php
  • ./includes/config.php
  • ./includes/functions.php
  • ./includes/class_hook.php
  • ./includes/modsystem_functions.php
  • ./includes/functions_bigthree.php
  • ./includes/class_postbit.php
  • ./includes/class_bbcode.php
  • ./includes/functions_reputation.php
  • ./includes/functions_post_thanks.php 

Hooks Called:
  • init_startup
  • init_startup_session_setup_start
  • init_startup_session_setup_complete
  • cache_permissions
  • fetch_postinfo_query
  • fetch_postinfo
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • style_fetch
  • cache_templates
  • global_start
  • parse_templates
  • global_setup_complete
  • showpost_start
  • bbcode_fetch_tags
  • bbcode_create
  • postbit_factory
  • showpost_post
  • postbit_display_start
  • post_thanks_function_post_thanks_off_start
  • post_thanks_function_post_thanks_off_end
  • post_thanks_function_fetch_thanks_start
  • post_thanks_function_fetch_thanks_end
  • post_thanks_function_thanked_already_start
  • post_thanks_function_thanked_already_end
  • fetch_musername
  • postbit_imicons
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • postbit_display_complete
  • post_thanks_function_can_thank_this_post_start
  • showpost_complete