Advertisement
Guest User

Untitled

a guest
Jul 26th, 2017
101
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 4.29 KB | None | 0 0
  1. function replaceAll($text, $smile)
  2. {          
  3.     global $pageLang;
  4.     switch ($pageLang) {
  5.         case 'pl':
  6.             $clang = "lang_pl";
  7.             $langs = array('en' => 'lang_en', 'br' => 'lang_br', 'se' => 'lang_se');
  8.             break;
  9.         case 'en':
  10.             $clang = "lang_en";
  11.             $langs = array('pl' => 'lang_pl', 'br' => 'lang_br', 'se' => 'lang_se');
  12.             break;
  13.         case 'br':
  14.             $clang = "lang_br";
  15.             $langs = array('pl' => 'lang_pl', 'en' => 'lang_en', 'se' => 'lang_se');
  16.             break;
  17.         case 'se':
  18.             $clang = "lang_se";
  19.             $langs = array('pl' => 'lang_pl', 'en' => 'lang_en', 'br' => 'lang_br');
  20.             break;
  21.         default:
  22.             exit("Lang system error. Report this to administrator.");
  23.             break;
  24.     }
  25.  
  26.     $text = str_ireplace('['.$clang.']', '', $text);
  27.     $text = str_ireplace('[/'.$clang.']', '', $text);
  28.     foreach ($langs as $k => $v) {
  29.         $rows = 0;
  30.         while(stripos($text, '['.$v.']') !== false && stripos($text, '[/'.$v.']') !== false )
  31.         {
  32.             $lang = substr($text, stripos($text, '['.$v.']')+9, stripos($text, '[/'.$v.']') - stripos($text, '['.$v.']') - 9);
  33.             $text = str_ireplace('['.$v.']'.$lang.'[/'.$v.']', '', $text);
  34.         }
  35.     }
  36.     $rows = 0;
  37.     while(stripos($text, '[code]') !== false && stripos($text, '[/code]') !== false )
  38.     {
  39.         $code = substr($text, stripos($text, '[code]')+6, stripos($text, '[/code]') - stripos($text, '[code]') - 6);
  40.         if(!is_int($rows / 2)) { $bgcolor = 'ABED25'; } else { $bgcolor = '23ED25'; } $rows++;
  41.         $text = str_ireplace('[code]'.$code.'[/code]', '<i>Code:</i><br /><table cellpadding="0" style="background-color: #'.$bgcolor.'; width: 480px; border-style: dotted; border-color: #CCCCCC; border-width: 2px"><tr><td>'.$code.'</td></tr></table>', $text);
  42.     }
  43.     $rows = 0;
  44.     while(stripos($text, '[quote]') !== false && stripos($text, '[/quote]') !== false )
  45.     {
  46.         $quote = substr($text, stripos($text, '[quote]')+7, stripos($text, '[/quote]') - stripos($text, '[quote]') - 7);
  47.         if(!is_int($rows / 2)) { $bgcolor = 'AAAAAA'; } else { $bgcolor = 'CCCCCC'; } $rows++;
  48.         $text = str_ireplace('[quote]'.$quote.'[/quote]', '<table cellpadding="0" style="background-color: #'.$bgcolor.'; width: 480px; border-style: dotted; border-color: #007900; border-width: 2px"><tr><td>'.$quote.'</td></tr></table>', $text);
  49.     }
  50.     $rows = 0;
  51.     while(stripos($text, '[url]') !== false && stripos($text, '[/url]') !== false )
  52.     {
  53.         $url = substr($text, stripos($text, '[url]')+5, stripos($text, '[/url]') - stripos($text, '[url]') - 5);
  54.         $text = str_ireplace('[url]'.$url.'[/url]', '<a href="'.$url.'" target="_blank">'.$url.'</a>', $text);
  55.     }
  56.     while(stripos($text, '[player]') !== false && stripos($text, '[/player]') !== false )
  57.     {
  58.         $player = substr($text, stripos($text, '[player]')+8, stripos($text, '[/player]') - stripos($text, '[player]') - 8);
  59.         $text = str_ireplace('[player]'.$player.'[/player]', '<a href="?subtopic=characters&name='.urlencode($player).'">'.$player.'</a>', $text);
  60.     }
  61.     while(stripos($text, '[img]') !== false && stripos($text, '[/img]') !== false )
  62.     {
  63.         $img = substr($text, stripos($text, '[img]')+5, stripos($text, '[/img]') - stripos($text, '[img]') - 5);
  64.         $text = str_ireplace('[img]'.$img.'[/img]', '<img src="'.$img.'">', $text);
  65.     }
  66.     while(stripos($text, '[b]') !== false && stripos($text, '[/b]') !== false )
  67.     {
  68.         $b = substr($text, stripos($text, '[b]')+3, stripos($text, '[/b]') - stripos($text, '[b]') - 3);
  69.         $text = str_ireplace('[b]'.$b.'[/b]', '<b>'.$b.'</b>', $text);
  70.     }
  71.     while(stripos($text, '[i]') !== false && stripos($text, '[/i]') !== false )
  72.     {
  73.         $i = substr($text, stripos($text, '[i]')+3, stripos($text, '[/i]') - stripos($text, '[i]') - 3);
  74.         $text = str_ireplace('[i]'.$i.'[/i]', '<i>'.$i.'</i>', $text);
  75.     }
  76.     while(stripos($text, '[u]') !== false && stripos($text, '[/u]') !== false )
  77.     {
  78.         $u = substr($text, stripos($text, '[u]')+3, stripos($text, '[/u]') - stripos($text, '[u]') - 3);
  79.         $text = str_ireplace('[u]'.$u.'[/u]', '<u>'.$u.'</u>', $text);
  80.     }
  81.     return replaceSmile($text, $smile);
  82. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement