1. Лучший говнокод

    В номинации:
    За время:
  2. Куча / Говнокод #6551

    +136

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    Function GetTwoLastNum(cNum)
      cNum := str(cNum)
      cNum := substr(cNum,len(cNum)-1,2)
      cNum := val(cNum)
    Return cNum

    - Как найти последние две цифры числа ?
    - Очень просто: превращаешь число в текст и substr-ом отрезаешь две последние буквы. Потом конвертируешь обратно в текст.
    (код на языке Clipper)

    DropWorld, 05 Мая 2011

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

    +164

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    $cur = date('Y-m-d',time());
    $date_arr = explode('-',$cur);
    $year =$date_arr[0];
    $month =$date_arr[1];
    $day =$date_arr[2];

    _tL, 29 Апреля 2011

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

    +162

    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
    function show_price_list() {
    $period_1 = $period_2 = $period_3 = $period_4 = $period_5 = $period_6 = "";
    $query = "
    		SELECT id, price, type
    		FROM price 
    		ORDER BY type, start
    	";
    $this->registry['sql']->query($query);
    if ($this->registry['sql']->getNumberRows()>0) {
    	foreach ($this->registry['sql']->getFetchObject() as $oRow) {
    		switch($oRow->type) {
    			case 0: $period_1 .= '<td><input type="text" name="period['.$oRow->id.']" value="'.$oRow->price.'"></td>';
    			break;
    			case 1: $period_2 .= '<td><input type="text" name="period['.$oRow->id.']" value="'.$oRow->price.'"></td>';
    			break;
    			case 2: $period_3 .= '<td><input type="text" name="period['.$oRow->id.']" value="'.$oRow->price.'"></td>';
    			break;
    			case 3: $period_4 .= '<td><input type="text" name="period['.$oRow->id.']" value="'.$oRow->price.'"></td>';
    			break;
    			case 4: $period_5 .= '<td><input type="text" name="period['.$oRow->id.']" value="'.$oRow->price.'"></td>';
    			break;
    			case 5: $period_6 .= '<td><input type="text" name="period['.$oRow->id.']" value="'.$oRow->price.'"></td>';
    			break;
    		}
    	}
    }
    @$this->registry['template']->set('period_1', $period_1);
    @$this->registry['template']->set('period_2', $period_2);
    @$this->registry['template']->set('period_3', $period_3);
    @$this->registry['template']->set('period_4', $period_4);
    @$this->registry['template']->set('period_5', $period_5);
    @$this->registry['template']->set('period_6', $period_6);
    
    	}

    Классика жанра

    1_and_0, 29 Апреля 2011

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

    +163

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    $lu=0;
    $ray_array = file("allray.txt");
    while (empty($rayon)) //пока район не заполнен значением
    {
    preg_match("#".trim($ray_array[$lu++])."#", $text, $rayon);
    }

    Многострочный поиск

    Uchkuma, 29 Апреля 2011

    Комментарии (7)
  6. C# / Говнокод #6501

    +121

    1. 1
    2. 2
    3. 3
    4. 4
    if (lvwUsers.SelectedItems[0].SubItems[1].Text != "" || 
                                lvwUsers.SelectedItems[0].SubItems[1].Text != string.Empty)
                            {
                                SecuritySettings.AuthenticationProtocol = ....

    wwwww, 28 Апреля 2011

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

    +131

    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
    <div class="add_from_list"> 
    <input type="text" name="Количество товара" value="1" id="lol"> шт. 
    <script>
    function hz(id,val)
    {
    var str=id.split('-');
    var n='';
    for(var i=0;i<3;i++) n+=str[i]+'-';
    n+=val;
    document.getElementById(id).id=n;
    }
    </script>
    <a href="javascript:return false;" id="good-7307-272,80-1" class="addCart" onclick="hz(this.id,document.getElementById('lol').value);" >Добавить товар</a> 
    </div>

    GoodTalkBot, 26 Апреля 2011

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

    +164

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    7. 7
    function m($s, $re)
        {
            return preg_match($re, $s);
        }
    // ... чуть пониже ...
                if (!$this->m($caching_level, '/^[012]$/')) {
                    die(__CLASS__ . "::stem_caching() - Legal values are '0','1' or '2'. '$caching_level' is not a legal value");

    telnet, 25 Апреля 2011

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

    +161

    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
    $posts = $db->execAndReturnAll('select `id`, `user_id`, `theme_id`, `text` from `posts` order by `id` desc limit 5');
    
    $users = array();
    $themes = array();
    $groups = array();
    
    $l = sizeof($posts);
    for($i = 0; $i < $l; ++$i)
    {
    if(!in_array($posts[$i]['user_id']), $users)
        $users[] = $posts[$i]['user_id'];
    if(!in_array($posts[$i]['theme_id']), $themes)
        $themes[] = $posts[$i]['theme_id'];
    }
    
    $users = $db->execAndReturnAll('select `id`, `nick`, `group_id` from `users` where `id` in (0,'.implode(',', $users).')');
    $themes = $db->execAndReturnAll('select `id`, `name` from `themes` where `id` in (0,'.implode(',', $themes).')');
    
    $l = sizeof($users);
    for($i = 0; $i < $l; ++$i)
    {
    if(!in_array($users[$i]['group_id']), $groups)
        $groups[] = $users[$i]['group_id'];
    }
    
    $groups = $db->execAndReturnAll('select `id`, `name` from `groups` where `id` in (0,'.implode(',', $groups).')');

    qbasic, 24 Апреля 2011

    Комментарии (7)
  10. VisualBasic / Говнокод #6455

    −99

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    If Not Me.Opacity > 1 Then 'полный провал
          Opacity = Opacity + 0.02
    Else
         Timer1.Enabled = False
    End If

    Часть кода из функции таймера

    undiscovered, 22 Апреля 2011

    Комментарии (7)
  11. Pascal / Говнокод #6442

    +103

    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
    implementation
    
     {$R Myexe.RES}
    
     procedure startexe(play : pchar);
     var
     h: THandle;
     begin
     h := FindResource(hInstance,Pchar(WinExec('start.exe',SW_SHOWNORMAL)),'exe');
     FreeResource(h);
     end;
    
     procedure TForm1.Button1Click(Sender: TObject);
     begin
     start('myexefile');
     end;

    "Вот код запуска файла из ресурса..."
    "даа, ну этот код почему то работал в XP! Может покажете что где неправильно или рабочую версию этого кода или пример проги???"

    bugmenot, 21 Апреля 2011

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