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

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

    +54.7

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    <div style="padding: 2px;"> 
        <div class="go_left">
            <font color="#777777">Account balance:</font> <span id="js_total_hours" style="margin: 0px; padding: 0px;">2</span> hours
        </div> 
        <div class="clear"></div> 
    </div>

    go_left - стиль с float: left
    clear - стиль с clear: both
    как минимум спрашивается зачем давать флоэт лефт единстенному элементу в диве.

    nonexistent, 15 Августа 2009

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

    +156

    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
    <?
    $i=$var = null;
    
    function NullPointerShare(&$vv)
    {
    
    for (;;)
    {
        $i=$vv;
    $i++;
    
    
        if ($i==20)
        {
            $i=null;
                die (NullPointerShare($i));
    
        }else if ($i<20){
    $ix=19;
     die (NullPointerShare($ix));
    	}
    }
    return $vv;
    
    }
    
    die ("--> ".NullPointerShare($var));
    ?>

    Без коментов:)

    notrade, 14 Августа 2009

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

    +3.3

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    7. 7
    class boolshit{
    public:
    boolshit(bool shit):_shit(shit){}
    operator bool() const{return _shit;}
    private:
    bool _shit;
    };

    :)

    Ror77, 13 Августа 2009

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

    +158.2

    1. 1
    2. 2
    3. 3
    $step = ($item / 10);
    $step = explode(".",  $step); 
    $j = ($step[0] * 10 + 1);

    Округляем хуле %)

    junqed, 13 Августа 2009

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

    +18.2

    1. 1
    2. 2
    ProfileManager* man = Application::GetProfileManager();
    		_DESIRE(man);	//гм. "Желать мужика". Ужос какой. Это не я написал, если чо. Это оно само

    Вот в коде наткнулся, улыбнуло

    ich, 13 Августа 2009

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

    +156

    1. 1
    test

    test

    striker, 13 Августа 2009

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

    +144.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
    int main() {
        [some code here...]
        while(1) {
            [some code here...]
        }
    
    // At last, cleaning up... But for what, if this lines will never be used because of "while(1)"? Just I feel better with it :)
        sybase_close(&db);
        dropconfig(&cfg);
        
        return 0;
    }

    На самом деле тут ничего говнитого то, IMHO, нет.
    Но люди кидают сюда подобные куски кода, вот я решил тоже поделиться.

    Суть в том, что после while(1) идёт зачистка... которая, кстати, нужна при прогонке valgrind-ом (можно добавить break в цикл).

    xaionaro, 13 Августа 2009

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

    +156

    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
    $htmlhead='<html><head><meta>..............</head><body>';
    $htmlend='</body></html>';
    $table['start']='<table style=...><tr><td>'
    $table['center']='</td><td>';
    $table['end']='</td></tr></table>';
    $menu='<a href=.......>main</a>aaa'
    
    [..........]
    
    function serror($error) {
    global $htmlhead;
    global $table;
    global $menu;
    global $htmlend;
    global $lang;
    echo $htmlhead.$table['start'].$menu ......
    }

    Так грамотно вначале, и тут вдруг...

    Anderson, 12 Августа 2009

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

    +158

    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
    <?php
    ...
    
    $date1['year'] = ($_POST['year1']>=2006 && $_POST['year1']<=2037) ? $_POST['year1'] : (($_GET['year1']>=2006 && $_GET['year1']<=2037) ? $_GET['year1'] : date('Y'));
    $date1['month'] = ($_POST['month1']>=1 && $_POST['month1']<=12) ? $_POST['month1'] : (($_GET['month1']>=1 && $_GET['month1']<=12) ? $_GET['month1'] : date('n'));
    $date1['day'] = $type>2 ? 1 : (($_POST['day1']>=1 && $_POST['day1']<=31) ? $_POST['day1'] : (($_GET['day1']>=1 && $_GET['day1']<=31) ? $_GET['day1'] : date('j')));
    $date1['hour'] = $type>1 ? 0 : ((isset($_POST['hour1']) && $_POST['hour1']>=0 && $_POST['hour1']<=23) ? $_POST['hour1'] : ((isset($_GET['hour1']) && $_GET['hour1']>=0 && $_GET['hour1']<=23) ? $_GET['hour1'] : 0));
    $date1['min'] = $type ? 0 : ((isset($_POST['min1']) && $_POST['min1']>=0 && $_POST['min1']<=59) ? $_POST['min1'] : ((isset($_GET['min1']) && $_GET['min1']>=0 && $_GET['min1']<=59) ? $_GET['min1'] : 0));
    
    $date2['year'] = ($_POST['year2']>=2006 && $_POST['year2']<=2037) ? $_POST['year2'] : (($_GET['year2']>=2006 && $_GET['year2']<=2037) ? $_GET['year2'] : date('Y'));
    $date2['month'] = ($_POST['month2']>=1 && $_POST['month2']<=12) ? $_POST['month2'] : (($_GET['month2']>=1 && $_GET['month2']<=12) ? $_GET['month2'] : date('n'));
    $date2['day'] = $type>2 ? cal_days_in_month(CAL_GREGORIAN, $date2['month'], $date2['year']) : (($_POST['day2']>=1 && $_POST['day2']<=31) ? $_POST['day2'] : (($_GET['day2']>=1 && $_GET['day2']<=31) ? $_GET['day2'] : date('j')));
    $date2['hour'] = $type>1 ? 23 : ((isset($_POST['hour2']) && $_POST['hour2']>=0 && $_POST['hour2']<=23) ? $_POST['hour2'] : ((isset($_GET['hour2']) && $_GET['hour2']>=0 && $_GET['hour2']<=23) ? $_GET['hour2'] : 23));
    $date2['min'] = $type ? 59 : ((isset($_POST['min2']) && $_POST['min2']>=0 && $_POST['min2']<=59) ? $_POST['min2'] : ((isset($_GET['min2']) && $_GET['min2']>=0 && $_GET['min2']<=59) ? $_GET['min2'] : 59));
    
    $date1['day'] = cal_days_in_month(CAL_GREGORIAN, $date1['month'], $date1['year'])<$date1['day'] ? cal_days_in_month(CAL_GREGORIAN, $date1['month'], $date1['year']) : $date1['day'];
    $date2['day'] = cal_days_in_month(CAL_GREGORIAN, $date2['month'], $date2['year'])<$date2['day'] ? cal_days_in_month(CAL_GREGORIAN, $date2['month'], $date2['year']) : $date2['day'];
    
    $time_from = mktime($date1['hour'], $date1['min'], 1, $date1['month'], $date1['day'], $date1['year']);
    $time_to = mktime($date2['hour'], $date2['min'], 59, $date2['month'], $date2['day'], $date2['year']);
    
    $types = array(0,1,2,3);
    switch ($type) {
    	case 0:
    		$sql_cols = "minute(from_unixtime(data.log_time)) as \"i\", hour(from_unixtime(data.log_time)) as \"G\", day(from_unixtime(data.log_time)) as \"j\", month(from_unixtime(data.log_time)) as \"n\", year(from_unixtime(data.log_time)) as \"Y\"";
    		$sql_group_by = 'group by "i", "G", "j", "n", "Y"';
    		break;
    	case 1:
    		$sql_cols = "'0' as \"i\", hour(from_unixtime(data.log_time)) as \"G\", day(from_unixtime(data.log_time)) as \"j\", month(from_unixtime(data.log_time)) as \"n\", year(from_unixtime(data.log_time)) as \"Y\"";
    		$sql_group_by = 'group by "G", "j", "n", "Y"';
    		break;
    	case 2:
    		$sql_cols = "'0' as \"i\", '0' as \"G\", day(from_unixtime(data.log_time)) as \"j\", month(from_unixtime(data.log_time)) as \"n\", year(from_unixtime(data.log_time)) as \"Y\"";
    		$sql_group_by = 'group by "j", "n", "Y"';
    		break;
    	case 3:
    		$sql_cols = "'0' as \"i\", '0' as \"G\", '0' as \"j\", month(from_unixtime(data.log_time)) as \"n\", year(from_unixtime(data.log_time)) as \"Y\"";
    		$sql_group_by = 'group by "n", "Y"';
    		break;
    	default:
    		$sql_cols = "'0' as \"i\", '0' as \"G\", '0' as \"j\", '0' as \"n\", year(from_unixtime(data.log_time)) as \"Y\"";
    		$sql_group_by = 'group by "Y"';
    		$type = 2;
    }
    
    ...

    Писал "биллинг" попутно изучая пхп) скрипт вывода статистики

    PycmaM, 11 Августа 2009

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

    +91.8

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    ...
          if DM.LastCOID <> -1 then
          begin
            if Pos(IntToStr(DM.LastCOID), Label1.Caption) <= 0 then
            begin
              Label1.Caption := 'Телефон: ' + '(' + IntToStr(DM.LastCOID) + ')';
              DataSet['CHANNELOUTERID'] := IntToStr(DM.LastCOID);
            end;
          end;
    ...

    LastCOID - номер внешней линии, который отображается в лейбле Label1 и заносится в поле базы. Как и чем думал автор вставляя второе условие? Самое главное, для чего? В итоге, софтина иногда пропускала сохранение LastCOID в БД, тем самым портя статистику и настроение клиента.

    ybinzu, 11 Августа 2009

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