1. PHP / Говнокод #1909

    +170.4

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    11. 11
    12. 12
    13. 13
    14. 14
    15. 15
    16. 16
    17. 17
    18. 18
    19. 19
    20. 20
    21. 21
    22. 22
    23. 23
    24. 24
    25. 25
    26. 26
    27. 27
    28. 28
    29. 29
    30. 30
    31. 31
    32. 32
    33. 33
    34. 34
    35. 35
    36. 36
    37. 37
    38. 38
    39. 39
    40. 40
    41. 41
    42. 42
    43. 43
    44. 44
    45. 45
    46. 46
    47. 47
    48. 48
    49. 49
    50. 50
    51. 51
    52. 52
    53. 53
    54. 54
    55. 55
    56. 56
    57. 57
    58. 58
    59. 59
    60. 60
    61. 61
    62. 62
    63. 63
    64. 64
    65. 65
    66. 66
    67. 67
    68. 68
    69. 69
    70. 70
    71. 71
    72. 72
    73. 73
    74. 74
    75. 75
    76. 76
    77. 77
    78. 78
    79. 79
    80. 80
    81. 81
    82. 82
    83. 83
    84. 84
    85. 85
    86. 86
    87. 87
    88. 88
    89. 89
    90. 90
    91. 91
    92. 92
    93. 93
    94. 94
    95. 95
    96. 96
    97. 97
    98. 98
    <?php
    $mm=strlen( $titLE);
    $tit='';   
    for ($i=0;$i<=$mm;$i++)
    {
    $ss= $titLE[$i];
    switch ($ss) 
    {
    case "щ": $tit= $tit."sch";  break;
    case "ч": $tit= $tit."ch";  break;
    case "ш": $tit= $tit."sh";  break; 
    case "я": $tit= $tit."ja";  break;
    case "ю": $tit= $tit."ju";  break;
    case "ё": $tit= $tit."jo";  break;
    case "ж": $tit= $tit."zh";  break;
    case "э": $tit= $tit."e";  break;
    case "Щ": $tit= $tit."Sch";  break; 
     case "Ч": $tit= $tit."Ch";  break;
     case "Ш": $tit= $tit."Sh";  break;
     case "Я": $tit= $tit."Ja";  break;
    case "Ю": $tit= $tit."Ju";  break;
    case "Ё": $tit= $tit."Jo";  break; 
    case "Ж": $tit= $tit."Zh";  break;
    case "Э": $tit= $tit."E";  break;
    case "ь": $tit= $tit."";  break; 
    case "ъ": $tit= $tit."'";  break; 
    case "а": $tit= $tit."a";  break;
     case "б": $tit= $tit."b";  break;
    case "ц": $tit= $tit."c";  break;
    case "д": $tit= $tit."d";  break;
    case "е": $tit= $tit."e";  break; 
    case "ф": $tit= $tit."f";  break; 
    case "г": $tit= $tit."g";  break;
    case "х": $tit= $tit."h";  break; 
    case "и": $tit= $tit."i";  break; 
    case "й": $tit= $tit."j";  break;
    case "к":
         {
    
            if ($str[$i+1]=="с" ) {
            $tit= $tit."x";  
           $i=$i+1; break;}
             $tit= $tit."k";  break;
           }
    case "л": $tit= $tit."l";  break;
    case "м": $tit= $tit."m";  break;
    case "н": $tit= $tit."n";  break;
    case "о": $tit= $tit."o";  break;
    case "п": $tit= $tit."p";  break; 
    case "р": $tit= $tit."r";  break; 
    case "с": $tit= $tit."s";  break;
    case "т": $tit= $tit."t";  break;
    case "у": $tit= $tit."u";  break;
    case "в": $tit= $tit."v";  break;
    case "ы": $tit= $tit."y";  break;
    case "з": $tit= $tit."z";  break; 
    case "Ь": $tit= $tit."'";  break;
    case "Ъ": $tit= $tit."'";  break;
    case "А": $tit= $tit."A";  break;
    case "Б": $tit= $tit."B";  break; 
    case "Ц": $tit= $tit."C";  break;
    case "Д": $tit= $tit."D";  break;
     case "Е": $tit= $tit."E";  break;
    case "Ф": $tit= $tit."F";  break;
    case "Г": $tit= $tit."G";  break;
    case "Х": $tit= $tit."H";  break;
    case "И": $tit= $tit."I";  break;
    case "Й": $tit= $tit."J";  break;
    case "К":    
         {
          if ($str[$i+1]=="С" ) {
            $tit= $tit."X";  
           $i=$i+1; break;}
    
          if ($str[$i+1]=="с" ) {
            $tit= $tit."X";  
           $i=$i+1; break;}
    
           $tit= $tit."K"; break;
           }
    case "Л": $tit= $tit."L";  break;
     case "М": $tit= $tit."M";  break;
    case "Н": $tit= $tit."N";  break;
    case "О": $tit= $tit."O";  break;
    case "П": $tit= $tit."P";  break;  
    case "Р": $tit= $tit."R";  break;
    case "С": $tit= $tit."S";  break;
    case "Т": $tit= $tit."T";  break; 
     case "У": $tit= $tit."U";  break; 
     case "В": $tit= $tit."V";  break;
    case "Ы": $tit= $tit."Y";  break;
    case "З": $tit= $tit."Z";  break;
    case " ": $tit= $tit." ";  break;
    default:
            $end1= $tit;
      }
    }
    ?>

    транслитизатор!!!!!!!

    yamaha252, 29 Сентября 2009

    Комментарии (15)
  2. PHP / Говнокод #1908

    +153.5

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    11. 11
    12. 12
    13. 13
    14. 14
    15. 15
    16. 16
    17. 17
    18. 18
    19. 19
    20. 20
    21. 21
    22. 22
    23. 23
    24. 24
    25. 25
    26. 26
    27. 27
    28. 28
    29. 29
    30. 30
    31. 31
    32. 32
    33. 33
    34. 34
    35. 35
    36. 36
    37. 37
    38. 38
    39. 39
    40. 40
    41. 41
    42. 42
    43. 43
    44. 44
    45. 45
    46. 46
    47. 47
    48. 48
    49. 49
    50. 50
    51. 51
    52. 52
    53. 53
    54. 54
    55. 55
    56. 56
    57. 57
    58. 58
    59. 59
    60. 60
    61. 61
    62. 62
    63. 63
    64. 64
    65. 65
    66. 66
    67. 67
    68. 68
    /**
    	* Выполняет запрос SELECT
    	*
    	* @param string  $tables      Список таблиц, разделённый запятыми
    	* @param string  $condition   Условие для выборки (WHERE)
    	* @param string  $order       Поля для сортировки (ORDER BY)
    	* @param string  $fields      Список полей для получения
    	* @param int     $lim_rows    Максимльное количество получаемых записей
    	* @param int     $lim_offset  Начальное смещение для выборки
    	* @param string  $group       Поле для группировки
    	* @param bool    $distinct    Вернуть только уникальные записи
    	*
    	* @return array
    	*/
    	function select($tables, $condition = '', $order = '', $fields = '', $lim_rows = 0, $lim_offset = 0, $group = '', $distinct = false)
    	{
    		if (is_bool($fields) || $fields == '1' || $fields == '0' || !is_numeric($lim_rows)) {
    			# Обратная совместимость c 1.2.x
    			$desc = $fields;
    			$fields = $lim_rows ? $lim_rows : '*';
    			$lim_rows = $lim_offset;
    			$lim_offset = $group;
    			$group = $distinct;
    			$distinct = func_num_args() == 9 ? func_get_arg(8) : false;
    			$query = 'SELECT ';
    			if ($distinct) $query .= 'DISTINCT ';
    			if (!strlen($fields)) $fields = '*';
    			$tables = str_replace('`' ,'', $tables);
    			$tables = preg_replace('/([\w.]+)/i', '`'.$this->prefix.'$1`', $tables);
    			$query .= $fields." FROM ".$tables;
    			if (strlen($condition)) $query .= " WHERE $condition";
    			if (strlen($group)) $query .= " GROUP BY $group";
    			if (strlen($order)) {
    				$query .= " ORDER BY $order";
    				if ($desc) $query .= ' DESC';
    			}
    			if ($lim_rows) {
    				$query .= ' LIMIT ';
    				if ($lim_offset) $query .= "$lim_offset, ";
    				$query .= $lim_rows;
    			}
    		} else {
    			$query = 'SELECT ';
    			if ($distinct) $query .= 'DISTINCT ';
    			if (!strlen($fields)) $fields = '*';
    			$tables = str_replace('`','',$tables);
    			$tables = preg_replace('/([\w.]+)/i', '`'.$this->prefix.'$1`', $tables);
    			$query .= $fields." FROM ".$tables;
    			if (strlen($condition)) $query .= " WHERE ".$condition;
    			if (strlen($group)) $query .= " GROUP BY ".$group."";
    			if (strlen($order)) {
    				$order = explode(',', $order);
    				for($i = 0; $i < count($order); $i++) switch ($order[$i]{0}) {
    					case '+': $order[$i] = substr($order[$i], 1); break;
    					case '-': $order[$i] = substr($order[$i], 1).' DESC'; break;
    				}
    				$query .= " ORDER BY ".implode(', ',$order);
    			}
    			if ($lim_rows) {
    				$query .= ' LIMIT ';
    				if ($lim_offset) $query .= "$lim_offset, ";
    				$query .= $lim_rows;
    			}
    		}
    		$result = $this->query_array($query);
    
    		return $result;
    	}

    nbyt, 28 Сентября 2009

    Комментарии (13)
  3. PHP / Говнокод #1899

    +151

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    11. 11
    12. 12
    13. 13
    14. 14
    15. 15
    16. 16
    17. 17
    18. 18
    19. 19
    20. 20
    21. 21
    22. 22
    23. 23
    24. 24
    25. 25
    26. 26
    27. 27
    28. 28
    29. 29
    30. 30
    31. 31
    32. 32
    33. 33
    34. 34
    35. 35
    36. 36
    37. 37
    38. 38
    39. 39
    40. 40
    41. 41
    42. 42
    43. 43
    44. 44
    45. 45
    46. 46
    47. 47
    48. 48
    49. 49
    50. 50
    51. 51
    52. 52
    53. 53
    54. 54
    55. 55
    56. 56
    57. 57
    58. 58
    59. 59
    60. 60
    61. 61
    62. 62
    63. 63
    64. 64
    65. 65
    66. 66
    67. 67
    68. 68
    69. 69
    70. 70
    71. 71
    72. 72
    73. 73
    74. 74
    75. 75
    76. 76
    77. 77
    78. 78
    79. 79
    80. 80
    81. 81
    82. 82
    83. 83
    84. 84
    85. 85
    86. 86
    87. 87
    88. 88
    89. 89
    90. 90
    91. 91
    92. 92
    93. 93
    <?php
    require_once ("../inc/core.php");
    require_once ("../inc/header.php");
    //
    require_once ("../inc/classAudioFile.php");
    require_once ("../inc/func.php");
    
    
    
    
    /// Форма загрузки файла
    if (!isset ($_POST['upload'])){
    echo '<form action="upload.php" method="post" enctype="multipart/form-data">';
    echo '<input type="file" name="fname"><br>';
    echo '<input type="submit" name="upload" value="Загрузить"><br></form>';
    }
    //
    $date = DATE ("Y-m-d");
    $scriptdir = "$siteurl/mp3/";
    $dir = "files/$date/";
    $tmpfilename = $_FILES['fname']['tmp_name'];
    $filename = $_FILES['fname']['name'];
    $nfilename = trans ("MixON.mobi_".$filename);
    $ext = explode (".",$filename);
    $size = $_FILES['fname']['size'];
    $adrfile = $dir.$nfilename;
    $mp3url = $scriptdir.$adrfile;
    //////////////
    
    if (!is_dir ("files/$date")) mkdir ("files/$date", 0770);
    
    
    if (isset($_POST['upload'])){
       if (count($ext) !=2) {
            echo "Файлы с двойным расширением запрещены. <br /> Должно быть так: <br /> filename.ext";
            exit;
        }
        if ($ext[1] != 'mp3' ){
            echo 'Разрешена загрузка только mp3 файлов.';
            exit;
        }
    if (file_exists ($tmpfilename)){
    copy ($tmpfilename, $adrfile);
    //// Получаем теги файла
    echo "Название файла: $filename <br />";
    $AF = new AudioFile;
    $AF->loadFile($adrfile);
    //$AF -> printSampleInfo();
    $channels = $AF -> wave_channels;
    $framerate = $AF -> wave_framerate;
    $byterate = $AF -> wave_byterate;
    $length = $AF -> wave_length;
    $title = $AF -> id3_title;
    $title = trim(iconv('windows-1251','UTF-8',$title));
    $artist = $AF -> id3_artist;
    $artist = trim (iconv('windows-1251','UTF-8',$artist));
    $album = $AF -> id3_album;
    $album = trim (iconv('windows-1251','UTF-8',$album));
    $year = $AF -> id3_year;
    $year = trim (iconv('windows-1251','UTF-8',$year));
    $genre = $AF -> id3_genre;
    $genre = trim (iconv('windows-1251','UTF-8',$genre));
    $comment = $AF -> id3_comment;
    $comment = trim (iconv('windows-1251','UTF-8',$comment));
    ///Выводим мп3 теги
    echo "Каналы: $channels <br /> Частота: $framerate <br /> Битрейт: $byterate <br /> ";
    echo "Продолжительность: ".date('i:s', mktime(0,0,round($length))). "мин. <br /> ";
    echo "Название: $title <br />";
    echo "Исполнитель: $artist <br />";
    echo "Стиль: $genre <br />";
    if ($album != null) echo "Альбом: $album <br />";
    if ($year != null) echo "Год: $year <br />";
    }// Если файл закачалься и удачно скопирован
    
    echo "<a href=\"http://$siteurl/$scriptdir/index.php?do=add\">Все верно</a>";
    $do = isset($_GET['do']) ? $_GET['do'] : '';
    switch ($do)
    {
        case 'admview':
    
    $sql = "INSERT INTO `files` ( `id` , `title` , `artist` , `genre` , `album` , `year` , `mp3url` )
    VALUES (
    '', '$title', '$artist', '$genre', '$album', '$year', '$mp3url'
    );";
    csql ($sql);
    mysql_query($sql);
    
    echo "<a href=\"http://$siteurl/$scriptdir/index.php?do=edit\">Нужно изменить</a>";
    
    }//switch do
    }// Если нажата кнопка
    require_once ("../inc/footer.php");
    ?>

    pivasyk, 25 Сентября 2009

    Комментарии (9)
  4. PHP / Говнокод #1897

    +151.2

    1. 1
    <?=trim(base64decode(trim($_GET['zzz'])))?>

    Ну как-то вот так

    McLeod, 25 Сентября 2009

    Комментарии (2)
  5. PHP / Говнокод #1894

    +173

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    if(isset($_GET['catId'])){
    ...
    } else if($_GET['catId']>0){
    ...
    }

    CubeCart v3.0.15

    Ghost, 24 Сентября 2009

    Комментарии (6)
  6. PHP / Говнокод #1892

    +161.3

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    $proc = new XsltProcessor();
    $proc->importStylesheet($xsl);
    $html = $proc->transformToXML($xmlOut);
    
    // Добро пожаловать в реальный мир!
    // Мы не знаем XSLT, поэтому кое-что поправим прямо тут.
    // Да здравствуют регекспы и грязные хаки!
    
    $html = preg_replace("/(<a href=\"\/futures[^>]+>)(.+?)<\/a>/ims","\$2",$html);
    return $html;

    Кусок класса XSLTTransformer.
    Оригинальные комменты и час потраченого времени на поиски неработающих ссылок в xsl-шаблонах.

    VermiVermi, 24 Сентября 2009

    Комментарии (12)
  7. PHP / Говнокод #1890

    +159.6

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    11. 11
    12. 12
    13. 13
    14. 14
    15. 15
    16. 16
    17. 17
    class SomeClass {
    ...
    	public function get_stop_words(){
    	    $stem_stop_words = array();
    		....
    	    return $stem_stop_words;
    	}
    ...
    }
    
    //далее в коде:
    
    $someClass = new SomeClass();
    if($someClass->connect()){
        $someClass->stem_stop_words = $someClass->get_stop_words();
        ....
    }

    ООП не для нас. Причем $this->stem_stop_words не объявлена в классе.

    VermiVermi, 23 Сентября 2009

    Комментарии (7)
  8. PHP / Говнокод #1888

    +155.4

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    function strtolowerex($str)
    {
    	$str = strtr($str, "АБВГДЕЁЖЗИЙКЛМНОПРСТУФХЦЧШЩЪЫЬЭЮЯ", "абвгдеёжзийклмнопрстуфхцчшщъыьэюя");
    	return strtolower($str);
    }

    я может чего-то не понимаю? 0_о

    gorky, 23 Сентября 2009

    Комментарии (6)
  9. PHP / Говнокод #1887

    +158.8

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    11. 11
    12. 12
    13. 13
    14. 14
    15. 15
    16. 16
    17. 17
    18. 18
    19. 19
    20. 20
    21. 21
    22. 22
    23. 23
    24. 24
    25. 25
    26. 26
    27. 27
    28. 28
    29. 29
    30. 30
    31. 31
    32. 32
    33. 33
    34. 34
    35. 35
    36. 36
    37. 37
    38. 38
    39. 39
    40. 40
    $fStr = fgets($fp);
    if ($k==0 && $IsFirst)
    continue;
    $arLine = explode(";", $fStr);
    $type = intval($arLine[0]);
    $articul = trim($arLine[1]);
    $section_id = intval($arLine[2]);
    $model = trim($arLine[3]);
    $name = trim($arLine[4]);
    $brand = trim($arLine[5]);
    $width = trim($arLine[6]);
    $radius = trim($arLine[7]);
    $pcd = trim($arLine[8]);
    $et = trim($arLine[9]);
    $dia = trim($arLine[10]);
    $dop = trim($arLine[11]);
    $color = trim($arLine[12]);
    
    //и чуть позже
    
    $query = "INSERT INTO ".$dbCatalogElProp." VALUES (null, ".$element_id.", 38, 'S', '".$articul."', null, '')";
    $res = SQLResult($query);
    $query = "INSERT INTO ".$dbCatalogElProp." VALUES (null, ".$element_id.", 25, 'L', '', ".$type.", '')";
    $res = SQLResult($query);
    $query = "INSERT INTO ".$dbCatalogElProp." VALUES (null, ".$element_id.", 17, 'S', '".$width."', null, '')";
    $res = SQLResult($query);
    $query = "INSERT INTO ".$dbCatalogElProp." VALUES (null, ".$element_id.", 18, 'S', '".$radius."', null, '')";
    $res = SQLResult($query);
    $query = "INSERT INTO ".$dbCatalogElProp." VALUES (null, ".$element_id.", 19, 'S', '".$pcd."', null, '')";
    $res = SQLResult($query);
    $query = "INSERT INTO ".$dbCatalogElProp." VALUES (null, ".$element_id.", 20, 'S', '".$et."', null, '')";
    $res = SQLResult($query);
    $query = "INSERT INTO ".$dbCatalogElProp." VALUES (null, ".$element_id.", 45, 'S', '".$dia."', null, '')";
    $res = SQLResult($query);
    $query = "INSERT INTO ".$dbCatalogElProp." VALUES (null, ".$element_id.", 21, 'S', '".$color."', null, '')";
    $res = SQLResult($query);
    $query = "INSERT INTO ".$dbCatalogElProp." VALUES (null, ".$element_id.", 22, 'S', '0', null, '')";
    $res = SQLResult($query);
    $query = "INSERT INTO ".$dbCatalogElProp." VALUES (null, ".$element_id.", 23, 'S', '', null, '')";
    $res = SQLResult($query);

    gorky, 23 Сентября 2009

    Комментарии (14)
  10. PHP / Говнокод #1871

    +158.3

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    11. 11
    12. 12
    13. 13
    14. 14
    15. 15
    16. 16
    17. 17
    18. 18
    19. 19
    20. 20
    21. 21
    22. 22
    23. 23
    24. 24
    25. 25
    26. 26
    27. 27
    28. 28
    29. 29
    30. 30
    <?php
    
    function secure2() {
        secure();
    }
    
    function secure() {
        secure3();
    }
    
    function secure3() {
        if (!check_session()) {
            $cookie = try_cookie();
            tiny_login($cookie['login'], $cookie['pass'], 1);
            if (check_session()) {
                $ret = true;
            } else {
                $ret = false;
            }
        } else {
            $ret = true;
        }
    
        if (!$ret) {
            $_SESSION['loginerror'] = 'Ошибка авторизации';
            header('location:(ссылка)');
        }
    }
    
    ?>

    В догонку к http://govnokod.ru/1820 по просьбе в комментах
    Реальный код из реального проекта. Что самое интересное — используется secure2
    Как оно работает для меня — загадка.

    Shock, 19 Сентября 2009

    Комментарии (7)