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

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

    +115

    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
    char[] splitter = { ',' };
    string types = hashtable[FlagsEnumValue].ToString();
    string[] typesStringArray = types.Split(splitter, StringSplitOptions.RemoveEmptyEntries);
    ArrayList typesArray = new ArrayList();
    
    foreach (string str in typesStringArray)
    {
       foreach (string type in Enum.GetNames(typeof(FlagsEnum)))
       {
          if (type == str.Trim())
          {
             typesArray.Add((FlagsEnum)Enum.Parse(typeof(FlagsEnum), str, true));
             break;
          }
       }
    }
    
    
    foreach (FlagsEnum type in typesArray)
    {
       if ((someObject.field & type) > 0)
       {
          typeFound = true;
       }
       else
       {
          typeFound = false;
          break;
       }
    }

    Автор хотел чтобы его любили. Точнее он хотел сконвертировать строковое представление битового енама в инам и сравнить по маске с проперти обьекта. Если бы автор прочел документацию то написал бы так:
    string types = hashtable[FlagsEnumValue].ToString();
    if (types != "")
    {
    FlagsEnum enum = (FlagsEnum)Enum.Parse(typeof(FlagsEnum), types, ignoreCase: true);
    if ((enum & someObject.field) == enum)
    typeFound = true;
    }

    piocsic, 01 Марта 2011

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

    +157

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    if($_ENV["COMPUTERNAME"]!='BX') 
    {
          CopyDirFiles($_SERVER["DOCUMENT_ROOT"]."/bitrix/modules/subscribe/install/admin", $_SERVER["DOCUMENT_ROOT"]."/bitrix/admin"); 
    // и еще куча аналогичного
    }

    шедевральная проверка
    битрикс, да :)

    elw00d, 28 Февраля 2011

    Комментарии (5)
  4. ActionScript / Говнокод #5813

    −107

    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
    public function receive(streamName:String):void
    {
    	stopReceive()
    	
    	if(!netConnection.connected)
    	{
    		receiveStreamName = streamName;
    		LogAppender.getInstance().appendLog(LogType.STREAM_LOG,"FMSStream.receive?not connected, set streamName: " + receiveStreamName);
    		return;
    	}
    	
    	nsReceive = new NetStream(netConnection);
    	nsReceive.addEventListener(NetStatusEvent.NET_STATUS, handleReceiveNetStreamStatus);
    	nsReceive.play(streamName, -2, -1, true);
    	dispatchEvent(new VRDataEvent(VRDataEvent.OPPONENT_STREAM_UPDATED));
    	// default audio sound
    	var st:SoundTransform = nsReceive.soundTransform;
    	st.volume = 0.7;
    	nsReceive.soundTransform = st;			
    	examineCallTimer.start();
    	LogAppender.getInstance().appendLog(LogType.STREAM_LOG,"FMSStream.receive?play=" + streamName);
    }

    Уже за новыми наушниками собирался идти...

    wvxvw, 27 Февраля 2011

    Комментарии (5)
  5. ActionScript / Говнокод #5793

    −110

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    7. 7
    var p2pStream:P2PStream = this
    var client:Object = new Object();
    client.onPeerConnect =  function(subscriber:NetStream):Boolean{
    	return p2pStream.onPeerConnect()}
    
    nsPublish = new NetStream(netConnection, NetStream.DIRECT_CONNECTIONS);
    nsPublish.client = client;

    Это AS3 (хотя это было бы говном в AS2 тоже, но там хоть причину можно было понять).

    wvxvw, 24 Февраля 2011

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

    +165

    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
    <?php
            function Test()
            {
                    if (isset($this->session->login) && isset($this->session->password)) {
                            if ($this->session->ip != $_SERVER["REMOTE_ADDR"]) {
                                    $this->db->Query("INSERT INTO `hackers`
                                 SET `ip` = '%s', `get` = '%s'", $_SERVER['REMOTE_ADDR'], $_SERVER["REQUEST_METHOD"]." | ".$_SERVER["REQUEST_URI"]);
                                    exit("Critical error! Stopping...");
                            } else {
                                    $this->db->Query("SELECT *
                                            FROM `users`
                                            WHERE `login` = '%s' AND password = '%s' LIMIT 1", $this->session->login, $this->session->password);
                                    if ($this->db->Num()) {
                                            return $this->db->Fetch();
                                    } else {
                                            return false;
                                    }
                            }
                    } else {
                            return false;
                    }
            }

    qbasic, 23 Февраля 2011

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

    +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
    <?
    //include('../root/start.php');
    include('start.php');
    
    
    
    
    $hotels_menu_id = GetSettingsParam('hotels_menu_id');
    
    if ($image_id = $_GET['image_id']) {
        $row = mysql_fetch_assoc(mysql_query(
                        'select co.id co_id, co.title co_title, ' .
                        'ci.id ci_id, ci.title ci_title, ' .
                        'h.id h_id, h.title h_title ' .
                        'from ' . _mysql_tbl_prefix . 'countries co ' .
                        'left join ' . _mysql_tbl_prefix . 'cities ci on co.id = ci.country_id ' .
                        'left join ' . _mysql_tbl_prefix . 'hotels h on ci.id = h.city_id ' .
                        'left join ' . _mysql_tbl_prefix . 'hotel_images hi on hi.hotel_id = h.id ' .
                        'where hi.image_id = ' . $image_id));
        echo mysql_error();
    # $src = '../../hotel_images/'.(int)($image_id/2000).'/'.$image_id.'.jpg';
        $src = './hotel_images/' . (int) ($image_id / 2000) . '/' . $image_id . '.jpg';
    }
    ?>
    <html>
        <head>
            <meta http-equiv="Content-Type" content="text/html; charset=windows-1251" />
            <title>Фото отеля "<?= $row['h_title'] ?>" (<?= $row['ci_title'] . ', ' . $row['co_title'] ?>) - Туроператор</title>
        </head>
        <link rel="stylesheet" href="../hotel_image.css">
        <body>
            <table height="100%" width="100%">
                <tr>
                    <td valign="middle" align="center">
                        <h1 class="hotel-image-title"><?=
    'Фото отеля "<a href="../index.php?menu_id=' . $hotels_menu_id . '&hotel_id=' . $row['h_id'] . '">' . $row['h_title'] . '</a>" ' .
            '(<a href="../index.php?menu_id=' . $hotels_menu_id . '&city_id=' . $row['ci_id'] . '">' . $row['ci_title'] . '</a>, ' .
            '<a href="../index.php?menu_id=' . $hotels_menu_id . '&country_id=' . $row['co_id'] . '">' . $row['co_title'] . '</a>)'
    ?></h1>
                        <a href="#" onClick="window.close()"><img src="<?= $src ?>" class="hotel-image" alt="Фото отеля "<?= $row['h_title'] ?>" (<?= $row['ci_title'] . ', ' . $row['co_title'] ?>)"></a>
                    </td>
                </tr>
            </table>
        </body>
    </html>

    Попросили так сазать исправить))
    я был ошеломлен "магическим числом" 2000

    rainerg, 22 Февраля 2011

    Комментарии (5)
  8. ActionScript / Говнокод #5747

    −241

    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
    while (i < 6) 
    {
        scene.scene["pirat" + i].shot = false;
        scene.scene["pirat" + i].num = i;
        scene.scene["pirat" + i].gotoAndStop(1);
        scene.scene["pirat" + i]._visible = false;
        scene.scene["pirat" + i].swapDepths(10 + i);
        scene.scene["pirat" + i].thisDepth = scene.scene["pirat" + i].getDepth();
        scene.scene["pirat" + i].pirat.piratFall.gotoAndStop(1);
        scene.scene["pirat" + i].pirat.piratFall._visible = false;
        scene.scene["splash" + i].splash1.gotoAndStop(1);
        scene.scene["splash" + i].splash2.gotoAndStop(1);
        scene.scene["splash" + i]._visible = false;
        ++i;
    }

    Данный кусок был найден в недрах флеш-рекламы.

    Govnocoder#0xFF, 21 Февраля 2011

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

    +163

    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
    // what version of MySQL
    	$mysql = $db->query_first("SELECT VERSION() AS version");
    	$mysql = $mysql['version'];
    
    	// Post count
    	$posts = $db->query_first("SELECT COUNT(*) AS total FROM " . TABLE_PREFIX . "post");
    	$posts = $posts['total'];
    
    	// User Count
    	$users = $db->query_first("SELECT COUNT(*) AS total FROM " . TABLE_PREFIX . "user");
    	$users = $users['total'];
    
    	// Forum Count
    	$forums = $db->query_first("SELECT COUNT(*) AS total FROM " . TABLE_PREFIX . "forum");
    	$forums = $forums['total'];
    
    	// Usergroup Count
    	$usergroups = $db->query_first("SELECT COUNT(*) AS total FROM " . TABLE_PREFIX . "usergroup");
    	$usergroups = $usergroups['total'];
    
    	// First Forum Post
    	$firstpost = $db->query_first("SELECT MIN(dateline) AS firstpost FROM " . TABLE_PREFIX . "post");
    	$firstpost = $firstpost['firstpost'];
    
    	// Last upgrade performed
    	$lastupgrade = $db->query_first("SELECT MAX(dateline) AS lastdate FROM " . TABLE_PREFIX . "upgradelog");
    	$lastupgrade = $lastupgrade['lastdate'];

    от туда же
    плять... сюда надо весь форум постить
    нахер архив сношу к еб**ям

    Sulik78, 21 Февраля 2011

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

    +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
    47. 47
    if ($_GET[action] == "avatar") {
    
    
    	if ($info = $_GET[info]) {
    
    			if ($info[avatar]) {
    				echo $info[avatar];
    			} else {
    					header("Content-type: image/png");
    
    					$im = imagecreatetruecolor(80, 80);
    					$white = imagecolorallocate($im, 255, 255, 255);
    					$grey = imagecolorallocate($im, 128, 128, 128);
    					$black = imagecolorallocate($im, 0, 0, 0);
    					imagefilledrectangle($im, 0, 0, 80, 80, $white);
    					$font = "fonts/avatar.ttf";
    
    					$text = "HET";
    					imagettftext($im, 20, 0, 15, 40, $grey, $font, $text);
    					imagettftext($im, 20, 0, 14, 39, $black, $font, $text);
    					$text = "ABATAPA";
    					imagettftext($im, 14, 0, 5, 55, $grey, $font, $text);
    					imagettftext($im, 14, 0, 4, 54, $black, $font, $text);
    					imagepng($im);
    					imagedestroy($im);
    			}
    	} else {
    					header("Content-type: image/png");
    
    					$im = imagecreatetruecolor(80, 80);
    					$white = imagecolorallocate($im, 255, 255, 255);
    					$grey = imagecolorallocate($im, 128, 128, 128);
    					$black = imagecolorallocate($im, 0, 0, 0);
    					imagefilledrectangle($im, 0, 0, 80, 80, $white);
    					$font = "fonts/avatar.ttf";
    
    					$text = "HET";
    					imagettftext($im, 20, 0, 15, 40, $grey, $font, $text);
    					imagettftext($im, 20, 0, 14, 39, $black, $font, $text);
    					$text = "ABATAPA";
    					imagettftext($im, 14, 0, 5, 55, $grey, $font, $text);
    					imagettftext($im, 14, 0, 4, 54, $black, $font, $text);
    					imagepng($im);
    					imagedestroy($im);	
    	}
    
    }

    Вот такое говнецо встретилось))

    Sulik78, 19 Февраля 2011

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

    +163

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    } elseif ($go == 4) {
    	include("function/no-cache.php");
    	include("config/config_uploads.php");
    	switch($go) {
    		default:
    		$con = explode("|", $confup[$mod]);
    		upload(2, "uploads/".$mod."", $con[0], $con[2], $mod, $con[3], $con[4]);
    		break;
    	}
    }

    http://www.slaed.net/files-view-1103.html

    111111, 18 Февраля 2011

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