Просмотр файла dcsiza/conv.php

Размер файла: 6.51Kb
<?php

////////////////////////////////////////////////////////////////////////////
//                                                                        //
//         Автор скрипта: Корнилов Александр Евгеньевич aka GrOb          //
//                E-mail: [email protected]                                   //
//              WAP SAIT: http://grob.com.ru                              //
//                                                                        //
////////////////////////////////////////////////////////////////////////////

///////////////////
include("config.php");
function translit($mysting)
{

        $mysting=str_replace("jo","ё",$mysting);
        $mysting=str_replace("Jo","Ё",$mysting);
        $mysting=str_replace("JO","Ё",$mysting);
        $mysting=str_replace("zh","ж",$mysting);
        $mysting=str_replace("Zh","Ж",$mysting);
        $mysting=str_replace("ZH","Ж",$mysting);
        $mysting=str_replace("ch","ч",$mysting);
        $mysting=str_replace("Ch","Ч",$mysting);
        $mysting=str_replace("CH","Ч",$mysting);
        $mysting=str_replace("yu","ю",$mysting);
        $mysting=str_replace("Yu","Ю",$mysting);
        $mysting=str_replace("YU","Ю",$mysting);
        $mysting=str_replace("ju","ю",$mysting);
        $mysting=str_replace("Ju","Ю",$mysting);
        $mysting=str_replace("JU","Ю",$mysting);
        $mysting=str_replace("ya","я",$mysting);
        $mysting=str_replace("Ya","Я",$mysting);
        $mysting=str_replace("YA","Я",$mysting);
        $mysting=str_replace("ja","я",$mysting);
        $mysting=str_replace("Ja","Я",$mysting);
        $mysting=str_replace("JA","Я",$mysting);
        $mysting=str_replace("sh","щ",$mysting);
        $mysting=str_replace("Sh","Щ",$mysting);
        $mysting=str_replace("SH","Щ",$mysting);
        $mysting=str_replace("s_h","сх",$mysting);
        $mysting=str_replace("S_h","Сх",$mysting);
        $mysting=str_replace("S_H","СХ",$mysting);

        $mysting=str_replace("a","а",$mysting);
        $mysting=str_replace("A","А",$mysting);
        $mysting=str_replace("b","б",$mysting);
        $mysting=str_replace("B","Б",$mysting);
        $mysting=str_replace("v","в",$mysting);
        $mysting=str_replace("V","В",$mysting);
        $mysting=str_replace("g","г",$mysting);
        $mysting=str_replace("G","Г",$mysting);
        $mysting=str_replace("d","д",$mysting);
        $mysting=str_replace("D","Д",$mysting);
        $mysting=str_replace("e","е",$mysting);
        $mysting=str_replace("E","Е",$mysting);
        $mysting=str_replace("z","з",$mysting);
        $mysting=str_replace("Z","З",$mysting);
        $mysting=str_replace("i","и",$mysting);
        $mysting=str_replace("I","И",$mysting);
        $mysting=str_replace("j","й",$mysting);
        $mysting=str_replace("J","Й",$mysting);
        $mysting=str_replace("k","к",$mysting);
        $mysting=str_replace("K","К",$mysting);
        $mysting=str_replace("l","л",$mysting);
        $mysting=str_replace("L","Л",$mysting);
        $mysting=str_replace("m","м",$mysting);
        $mysting=str_replace("M","М",$mysting);
        $mysting=str_replace("n","н",$mysting);
        $mysting=str_replace("N","Н",$mysting);
        $mysting=str_replace("o","о",$mysting);
        $mysting=str_replace("O","О",$mysting);
        $mysting=str_replace("p","п",$mysting);
        $mysting=str_replace("P","П",$mysting);
        $mysting=str_replace("r","р",$mysting);
        $mysting=str_replace("R","Р",$mysting);
        $mysting=str_replace("s","с",$mysting);
        $mysting=str_replace("S","С",$mysting);
        $mysting=str_replace("t","т",$mysting);
        $mysting=str_replace("T","Т",$mysting);
        $mysting=str_replace("u","у",$mysting);
        $mysting=str_replace("U","У",$mysting);
        $mysting=str_replace("f","ф",$mysting);
        $mysting=str_replace("F","Ф",$mysting);
        $mysting=str_replace("h","х",$mysting);
        $mysting=str_replace("H","Х",$mysting);
        $mysting=str_replace("c","ц",$mysting);
        $mysting=str_replace("C","Ц",$mysting);
        $mysting=str_replace("w","ш",$mysting);
        $mysting=str_replace("W","Ш",$mysting);
        $mysting=str_replace("y","ы",$mysting);
        $mysting=str_replace("Y","Ы",$mysting);
        $mysting=str_replace("x","э",$mysting);
        $mysting=str_replace("X","Э",$mysting);

        $mysting=str_replace("\"","ъ",$mysting);
        $mysting=str_replace("\'","ь",$mysting);
        $mysting=str_replace("'","ь",$mysting);
        $mysting=str_replace("`","ь",$mysting);
        return $mysting;
}

function imgsize($mysting)
{

        $mysting=str_replace("width=\"","",$mysting);
        $mysting=str_replace("\" height=\"","X",$mysting);
        $mysting=str_replace("\"","",$mysting);
         return $mysting;
}

////////////////////////////////////////////////////////////////////////////

function conv($mysting)
{
$mysting = iconv("windows-1251", "utf-8", $mysting);
return $mysting;
        }

///////////////////////////////////////////////////////////////////////////

function u8($win,$h,$t) {
  global $w8;
  $w8[chr($h).chr($t)] = $win;
}

$c1 = chr(208);
$c2 = chr(209);

u8("й",208,185); u8("ц",209,134); u8("у",209,131);
u8("к",208,186); u8("е",208,181); u8("н",208,189);
u8("г",208,179); u8("ш",209,136); u8("щ",209,137);
u8("з",208,183); u8("х",209,133); u8("ъ",209,138);
u8("ф",209,132); u8("ы",209,139); u8("в",208,178);
u8("а",208,176); u8("п",208,191); u8("р",209,128);
u8("о",208,190); u8("л",208,187); u8("д",208,180);
u8("ж",208,182); u8("э",209,141); u8("я",209,143);
u8("ч",209,135); u8("с",209,129); u8("м",208,188);
u8("и",208,184); u8("т",209,130); u8("ь",209,140);
u8("б",208,177); u8("ю",209,142); u8("Й",208,153);
u8("Ц",208,166); u8("У",208,163); u8("К",208,154);
u8("Е",208,149); u8("Н",208,157); u8("Г",208,147);
u8("Ш",208,168); u8("Щ",208,169); u8("З",208,151);
u8("Х",208,165); u8("Ъ",208,170); u8("Ф",208,164);
u8("Ы",208,171); u8("В",208,146); u8("А",208,144);
u8("П",208,159); u8("Р",208,160); u8("О",208,158);
u8("Л",208,155); u8("Д",208,148); u8("Ж",208,150);
u8("Э",208,173); u8("Я",208,175); u8("Ч",208,167);
u8("С",208,161); u8("М",208,156); u8("И",208,152);
u8("Т",208,162); u8("Ь",208,172); u8("Б",208,145);
u8("Ю",208,174); u8("ё",209,145); u8("Ё",208,129);

function conv_rev ($text) {
  global $c1,$c2,$w8;
  $u = false;
  $temp = "";
  for($i=0,$len=strlen($text); $i<$len; $i++) {
    $c = substr($text,$i,1);
    if ($u) {
      $c = $w8[$lc.$c];
      $temp .= isset($c)?$c:"?";
      $u = false;
    }
    else if ($c==$c1 || $c==$c2) {
      $u = true;
      $lc = $c;
    }
    else
      $temp .= $c;
  }

  return $temp;
}


?>