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

    В номинации:
    За время:
  2. PHP / Говнокод #4311

    +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
    29. 29
    30. 30
    31. 31
    32. 32
    33. 33
    34. 34
    35. 35
    function checkUserPermission($module,$act){
            #return true;
            $this->temp=array();
            $this->temp['_result']=0;
            $this->temp['_uid']=explode('::',$_COOKIE['site_hash']);
            $this->temp['_uid']=$this->temp['_uid'][0];
            $this->temp['_gid']=$this->getUserSecurityAccess($this->temp['_uid']);
            $this->temp['_conn_id']=mysql_connect('host','user','passwd');
            mysql_select_db('database');
            $this->temp['_q1']=mysql_query('SELECT perms'
                            .'FROM `secure_groups`' 
                            .'WHERE id='.$this->temp['_gid']);    
            $this->temp['_access_stamp']=mysql_fetch_assoc($this->temp['_q1']);
            $this->temp['_access_stamp']=$this->temp['_access_stamp']['perms'];
            $this->temp['_access_stamp']=explode(';',$this->temp['_access_stamp']);
            $this->temp['_access_stamp']=array_slice($this->temp['_access_stamp'],0,-1);
            foreach($this->temp['_access_stamp'] as $this->temp['v']){
                $this->temp['_mod_access']=explode(':',$this->temp['v']);
                $this->temp['_mod_indefier']=$this->temp['_mod_access'][0];
                if($this->temp['_mod_indefier']==$module){
                    $this->temp['_perms']=explode(',',$this->temp['_mod_access'][1]);
                    switch($act){
                        case 'r':
                            $this->temp['_result']=($this->temp['_perms'][0]==1)? 1:0;
                            break;
                        case 'w':
                            $this->temp['_result']=($this->temp['_perms'][1]==1)? 1:0;
                            break;
                    }
                    break;
                }
            }
            mysql_close($conn_id);
            return $this->temp['_result'];
        }

    Такой вот занятный Acl :-D

    nikelin, 08 Октября 2010

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

    +156

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    if (!$this->sCurrentEvent) {
    	/**
    	 * Показывает дефолтную страницу
    	 */
    	//а это какая страница?
    }

    И всё. Никаких else и прочих вещей. Сижу, курю, пытаюсь восстановить поток мысли авторов.
    Из того же LiveStreet.

    hybroid, 03 Сентября 2010

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

    +156

    1. 1
    2. 2
    std::pair<std::vector<char>::const_iterator, unsigned int> parsedUnit = Utils::PackedUIntHelper::Unpack<unsigned char>(it);
    parsedUnit = Utils::PackedUIntHelper::Unpack<unsigned char>(parsedUnit.first);

    Представления потока данных итератором и чтение числа.

    enikey, 03 Сентября 2010

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

    +156

    1. 1
    if($urate['time'] < $time and count($urate) > 0) { // Если в течении суток голосовали и есть записи - фиг

    Мартин, 28 Августа 2010

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

    +156

    1. 1
    2. 2
    3. 3
    4. 4
    $val = trim($val);
       for ($x = 0; $x < 20; $x++) {
       $val = str_replace('  ', ' ', $val);
    }

    Замена нескольких пробелов в строке подряд на один.

    maenwen, 17 Августа 2010

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

    +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
    //delete internal note
    
    if(is_numeric($post['nID']) && is_numeric($post['cID'])) {
    //echo $post['nID'];
    	$q = mysql_query("DELETE FROM notes WHERE notes_id='{$post['nID']}' LIMIT 1");
    	if($q) {echo "<span style='font-weight:bold;color:red'>Note deleted</span>";}
    	show_notes_2($post['cID']);
    }
    
    if(is_numeric($post['nIDD']) && is_numeric($post['cIDD'])) {
    //echo $post['nID'];
    	$q = mysql_query("DELETE FROM notes WHERE notes_id='{$post['nIDD']}' LIMIT 1");
    	if($q) {echo "<span style='font-weight:bold;color:red'>Note deleted</span>";}
    	show_notes($post['cIDD'],2);
    }

    что нам стоит срач устроить

    n0ne, 15 Августа 2010

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

    +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
    while(myBot.loop) {
                    sleep(15);
                    myBot.connect(false);
    
                    while(myBot.loop) {
                            if(myBot.client->recv( 750000 )!=ConnNoError) {
                                   	break;
                            } else {
                                    hostent * record = gethostbyname(myBot.client->server().c_str());
                                   	if(record == NULL) {
                                            break;
                                    }
                           	}
                    }
    
                    myBot.disconnect();
           	}

    Бот на gloox. В строчках с 5 по 14 проверяется, не пропал ли линк, и пытается реконнектится, если, собственно, пропал.

    kainwinterheart, 14 Августа 2010

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

    +156

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    7. 7
    8. 8
    <?php
    $result = mysql_query("SELECT ..., CURRENT_DATE() as date, ...");
    $row = mysql_fetch_assoc($result);
    while ($row = mysql_fetch_assoc($result)) {
    // Еще вывод данных
    echo 'Дата: '. $row['date'];
    // Еще вывод данных
    }

    Заказчик долго удивлялся, почему дата странная выводится. И только потом, когда меня попросили посмотреть..

    neadekvat, 07 Августа 2010

    Комментарии (6)
  10. JavaScript / Говнокод #3897

    +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
    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
    [...]
        YMaps.Events.observe(map, map.Events.Click, function (map, mEvent) {
    	if (ymap_canmark) {
    	var newtip = mapAddTip('Новая метка', '');
    	newtip.setGeoPoint(mEvent.getGeoPoint());
            newtip.openBalloon();
            newtip.closeBalloon();
    	}    
        }, map);
    [...]
    
    function mapAddTip(head, body) {
        var olay = new YMaps.Placemark(map.getCenter(), {draggable: true});
    	
        olay.isfirstlaunch = 1;
    	
        tip_links++;
        olay.edlink = tip_links;
    
        tip_dbids++;
        olay.dbid = tip_dbids;
    		
        olay.setBalloonContent("<div id='hdr-"+tip_links+"' style='font-weight:bold;'>"+head+"</div><div id='txt-"+tip_links+"'>"+
    	body+"</div><!--<div id='edit-link-"+tip_links+"'><br>[ <a href='#'>Редактировать</a> ]</div>-->");
    		
        olay.setIconContent(head);
    		
        YMaps.Events.observe(olay, olay.Events.BalloonOpen, function () {		
    	if (olay.isfirstlaunch > 0) {
        	    YMaps.jQuery('#edit-link-' + olay.edlink).bind('click', function() { EditTip(olay, this) });
    	    if (olay.isfirstlaunch == 1) { dbAddTip(olay); } 
    	    olay.isfirstlaunch = 0;
            }}, map);
    	
        YMaps.Events.observe(olay, olay.Events.BalloonClose, function () {		
    	olay.setIconContent(GetTipHead(olay));
        }, map);
    
        YMaps.Events.observe(olay, olay.Events.DragStart, function () {		
    	var ddiv = document.createElement('div');
            ddiv.style.position = 'absolute';
            var pel = document.getElementById('ui-view');
            ddiv.style.left = parseInt(pel.style.left) + parseInt(pel.style.width) - 235;
            ddiv.style.top = pel.offsetTop+5;
            ddiv.style.zIndex = '10000001';
            ddiv.style.padding = '0px';		
            ddiv.style.margin = '0px';
            ddiv.style.color = 'gray';
            ddiv.style.fontSize = '10px';
            ddiv.setAttribute('id', 'drag-coords');
            document.body.appendChild(ddiv);
        }, map);
    
        YMaps.Events.observe(olay, olay.Events.Drag, function () {		
            YMaps.jQuery('#drag-coords').html('x='+olay.getGeoPoint().getX()+'; y='+olay.getGeoPoint().getY());
        }, map);		
    
        YMaps.Events.observe(olay, olay.Events.DragEnd, function () {		
    	YMaps.jQuery('#drag-coords').remove();
            if (olay.isfirstlaunch != 1) { olay.openBalloon(); dbSaveTip(olay); olay.closeBalloon(); }
        }, map);
    
        map.addOverlay(olay);
        return olay;
    }
    
    function dbAddTip(tip) { /* [...] */
    try {
    var test = document.getElementById("m_id");
    test.setAttribute("test", "success");
    if (test.getAttribute("test") == "success") {
    
    try {
    var t_id = document.getElementById("m_id").value;
    var t_x = tip.getGeoPoint().getX();
    var t_y = tip.getGeoPoint().getY();
    var t_head = GetTipHead(tip);
    var t_body = GetTipBody(tip);
    
    var XmlHttp = newXmlHttp();
    XmlHttp.open("GET", maps_cgi+"?tip=new"+t_id+"&x="+t_x+"&y="+t_y+"&head="+t_head+"&body="+t_body, false);
    XmlHttp.send(null);
    test.parentNode.removeChild(test);
    } catch (e) {}
    
    }
    } catch (e) { }
    }
    
    function GetTipBody(tip) { return YMaps.jQuery('#txt-'+tip.edlink).html(); }
    function GetTipHead(tip) { return YMaps.jQuery('#hdr-'+tip.edlink).html(); }
    
    function dbSaveTip(tip) { 
    /*
    [...]
    */
    }

    Почти шедевральне :D http://www.virtual.donetsk.ua/serv/maps.js

    kainwinterheart, 07 Августа 2010

    Комментарии (9)
  11. C++ / Говнокод #3858

    +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
    int main() {
    	srand(time(NULL));
    	for (int k=1;k<=75;k++) {
    		char file_name[] = "input      ";
    		if (k<10) {file_name[5]='0'; file_name[6]=(k+'0'); } else
    		{
    			file_name[5]=(k/10+'0'); file_name[6]=(k%10+'0');
    		}
    		file_name[7]='.'; file_name[8]='t'; file_name[9]='x'; file_name[10]='t';
    		freopen(file_name,"wt",stdout);
    		n=rand()%500+1;
    		m=rand()%500+1;
    		cout << n << " " << m << endl;
    		for (i=0;i<n;i++) {
    			for (j=0;j<m;j++)
    				cout << rand()%10000000+1 << " ";
    			cout << endl;
    		}
    	}
    	return 0;
    }

    jfn, 03 Августа 2010

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