1. SQL / Говнокод #4567

    −187

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    7. 7
    8. 8
    9. 9
    SELECT ....
               CASE  WHEN  [StatusChange] = 0 THEN 0
                WHEN  [StatusChange] = 1 THEN 1 -- "желтый", изменен
                WHEN [StatusChange] = 2 THEN 2-- "серый", исключенный пункт
                WHEN [StatusChange] = 3 THEN 3 -- "светло-зеленый", добавленный пункт
                WHEN [StatusChange] = 4 THEN 4-- "зеленый", добавленный и измененный пункт
                ELSE 100
          END AS 'StatusColor'
    FROM ....

    HellMaster_HaiL, 09 Ноября 2010

    Комментарии (4)
  2. Pascal / Говнокод #4566

    +95

    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
    program z1;
    
     function func (x: real): real;
     const e = 0.000000000000001; {15 знаков после запятой}
     var f: real; {переменая для расчета двойного факториала}
         i, k: integer; {счетчик проходов, i-общий, k-частный}
         d: real; {добавляемая дельта}
         y: real; {переменная искомого значения}
     begin
      y := 1.0;
      i := 1;
      repeat
        f := 1;                 {----------}
        k := i;                 {--расчет--}
        while (k >= 2) do begin {-двойного-}
          f := f * k;           {факториала}
          k := k - 2;           {----------}
        end;                    {----------}
        
        d := 1;                 {---------------------}
        for k := 1 to i do      {считаем степень числа}
          d := d * x;           {---------------------}
        
        d := d / f;             {-----------------находим d-----------------}
        if (d < e) then break;  {проверяем ее на попадание в разрядную сетку}
        
        y := y + d;
        i := i + 1;
      until (false);
      func := y;
     end;
     
    var x: real;
     
    begin
      write ('Введите x: ');
      readln (x);
      writeln ('y = ', func (x):3:15);
    end.

    maksim_ovcharik, 09 Ноября 2010

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

    +166

    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
    if (strpos($arFields['URL'],'detail.php')!==false ||
            strpos($arFields['URL'],'sea.php')!==false ||
            strpos($arFields['URL'],'add.php')!==false ||
            strpos($arFields['URL'],'form.php')!==false ||
            strpos($arFields['URL'],'/atlas-update/')!==false ||
            strpos($arFields['URL'],'auth')!==false ||
            strpos($arFields['URL'],'sect_')!==false ||
            strpos($arFields['URL'],'search')!==false ||
            strpos($arFields['URL'],'/forum1/')!==false)
            {
                    return false;
            }
            else
                    return $arFields;

    atarix12, 09 Ноября 2010

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

    +147

    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
    Мой скромный говнокод для любителей фильтрации и xss
    При записи в базу 
    $msg = stripslashes(htmlspecialchars(trim($_POST['msg']))); // Очищаем от мусора
    Вывод из базы 
     
    function post($text, $html=true, $nl2br = true, $smiles = true, $bbcode = true) 
    {
     if ($html)
     {
     $text=html_entity_decode($text, ENT_QUOTES, 'UTF-8'); // в базе в htmllenties обратная перекодировка
     }
     if($smiles)
     { 
     $text = smiles($text);
     }
     if($bbcode)
     {
     $text = bbcode($text);
     }              
     if($nl2br)
     {
     $text = nl2br($text);
     } 
     
     return $text;
    }

    Недавно нашел в своем скрипте блога )

    Danis92, 09 Ноября 2010

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

    +163

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    7. 7
    // и нафига я использовал тут исключения? :)
      try {
        if(!trim($to)) throw new Exception('aдpecaт');
        if(!trim($in['msg'])) throw new Exception('тeкcт');
        if(!trim($in['subj'])) throw new Exception('тема');
      } catch (Exception $e) {
        raise_error('Отсутствует '.$e->GetMessage().' сообщения.', 'write.php?to='.$to.'&amp;'.SID);

    да, нафига?)

    DmitryDick, 08 Ноября 2010

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

    +164

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    11. 11
    12. 12
    // Emulate register_globals on
    if (!ini_get('register_globals')) {
        $superglobals = array($_SERVER, $_ENV,
            $_FILES, $_COOKIE, $_POST, $_GET);
        if (isset($_SESSION)) {
            array_unshift($superglobals, $_SESSION);
        }
        foreach ($superglobals as $superglobal) {
            extract($superglobal, EXTR_SKIP);
        }
        ini_set('register_globals', true);
    }

    PHP-Fusion, эмулятор register_globals

    Мартин, 08 Ноября 2010

    Комментарии (23)
  7. Куча / Говнокод #4561

    +138

    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
    function StripLeadingComma(str)
      str = Ltrim(str)
      if len(str) > 0 then
        if Left(str,1) = "," then  str = Mid(str,2)
      end if
      if len(str) > 0 then
        if Left(str,1) = "," then  str = Mid(str,2)
      end if
      if len(str) > 0 then
        if Left(str,1) = "," then  str = Mid(str,2)
      end if
      if len(str) > 0 then
        if Left(str,1) = "," then  str = Mid(str,2)
      end if
      StripLeadingComma = str
    end function
    
    function StripTrailingComma(str)
      str = rtrim(str)
      if len(str) > 0 then
        if Right(str,1) = "," then  str = Left(str,len(str)-1)
      end if
      if len(str) > 0 then
        if Right(str,1) = "," then  str = Left(str,len(str)-1)
      end if
      if len(str) > 0 then
        if Right(str,1) = "," then  str = Left(str,len(str)-1)
      end if
      if len(str) > 0 then
        if Right(str,1) = "," then  str = Left(str,len(str)-1)
      end if
      if len(str) > 0 then
        if Right(str,1) = "," then  str = Left(str,len(str)-1)
      end if
      if len(str) > 0 then
        if Right(str,1) = "," then  str = Left(str,len(str)-1)
      end if
      StripTrailingComma = str
    end function

    Классика жанра на production. ASP, VBScript.

    Seth, 08 Ноября 2010

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

    +146

    1. 1
    2. 2
    3. 3
    4. 4
    logit("e", "%s No Menu! Wait 5 minutes and try again.\n", whoami);
    for(j=0;j<60;j++) {
        sleep_ew( 5000 );       /* wait around */
    }

    sgram из earthworm

    ftptrash, 08 Ноября 2010

    Комментарии (43)
  9. JavaScript / Говнокод #4559

    +166

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    function document_write($text)
    {
    	document.write($text);
    	return false;
    }

    говнокод от diary.ru

    desu, 08 Ноября 2010

    Комментарии (8)
  10. Pascal / Говнокод #4558

    +106

    1. 1
    2. 2
    3. 3
    FilterKey = 'Software'+'\'+CompanyName+'\'+ApplName+'\'+ApplVersion+'\'+SettingsKey+'\'+'FilterDD';
    OrderKey = 'Software'+'\'+CompanyName+'\'+ApplName+'\'+ApplVersion+'\'+SettingsKey+'\'+'OrderDD';
    NotepadKey = 'Software'+'\'+CompanyName+'\'+ApplName+'\'+ApplVersion+'\'+SettingsKey+'\'+'Notepad';

    повторение - мать учения

    gorsash, 08 Ноября 2010

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