1. 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)
  2. Perl / Говнокод #5792

    −102

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    7. 7
    8. 8
    9. 9
    ($sec,$min,$hour,$mday,$mon,$year) = localtime(time);
    if ($sec < 10) {$sec = "0$sec";}
    if ($min < 10) {$min = "0$min";}
    if ($hour < 10) {$hour = "0$hour";}
    if ($mday < 10) {$mday = "0$mday";}
    if ($mon < 10) {$mon = "0$mon";}
    $mon++;
    $year = 1900 + $year;
    print "[$mday-$mon-$year $hour:$min:$sec]\n";

    Добиваем нулями

    rohard, 24 Февраля 2011

    Комментарии (19)
  3. C# / Говнокод #5791

    +106

    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
    public static bool KeyToString(Keys key, bool shitKeyPressed,
                                                                        out char character)
            {
                bool result = false;
                character = ' ';
                CharPair charPair;
    
                if ((Keys.A <= key && key <= Keys.Z) || key == Keys.Space)
                {
                    // Use as is if it is A~Z, or Space key.
                    character = (shitKeyPressed) ? (char)key : Char.ToLower((char)key);
                    result = true;
                }
                else if (keyMap.TryGetValue(key, out charPair))
                {
                    // Otherwise, convert by key map.
                    if (!shitKeyPressed)
                    {
                        character = charPair.NormalChar;
                        result = true;
                    }
                    else if (charPair.ShiftChar.HasValue)
                    {
                        character = charPair.ShiftChar.Value;
                        result = true;
                    }
                }
    
                return result;
            }

    Разбираю код, скачанный с майкросовтовского App Hub. В коде и комментариях полно маленьких грамматический ошибок, но это...
    Код выложен на полном серьёзе и качается тут http://create.msdn.com/en-US/education/catalog/utility/performance_utility

    P.S. для тупых спойлер: вместо shift написано shit.

    Skelet0n, 23 Февраля 2011

    Комментарии (21)
  4. Java / Говнокод #5790

    +75

    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
    public static void getShops(Favorite favoriteBrands,
    			Favorite favoriteShops, StationItem station,
    			WorkingTimeFilter workTimeFilter, boolean[] filter, String keyword,
    			GeoLocationPointItem userLocation,
    			GeoLocationPointItem searchLocation, String catalogId,
    			String netId, String page, String pageSize, String api,
    			AsyncTask callback, ConnectionWatcher watcher) {
    //...
    //упаковка кучи параметров
    
    
    		boolean emptyFavBrands = false;
    		if (favoriteBrands != null) {
    			int i = 0;
    			for (FavoriteItem item : favoriteBrands) {
    				String id = item.getId();
    				Log.i(tag, "addFaforiteBrand " + id);
    				params.add(new BasicNameValuePair(PARAMS_FAVORITE_BRAND_ID
    						+ "[" + i + "]", id));
    				i++;
    			}
    			if (i == 0)
    				emptyFavBrands = true;
    		}
    
    		boolean emptyFavShops = false;
    		if (favoriteShops != null) {
    			int i = 0;
    			for (FavoriteItem item : favoriteShops) {
    				String id = item.getId();
    				Log.i(tag, "addFaforiteShop " + id);
    				params.add(new BasicNameValuePair(PARAMS_FAVORITE_SHOP_ID + "[" + i
    						+ "]", id));
    				i++;
    			}
    			if (i == 0)
    				emptyFavShops = true;
    		}
    
    		boolean error = false;
    
    		if (emptyFavBrands && emptyFavShops) {
    			if (favoriteBrands != null || favoriteShops != null)
    				error = true;
    		}
    
    		if (emptyFavShops) {
    			if (favoriteBrands == null && favoriteShops != null)
    				error = true;
    		}
    
    		if (emptyFavBrands) {
    			if (favoriteBrands != null && favoriteShops == null)
    				error = true;
    		}
    
    		if (error) {
    			callback.onError(JsonEntity.FAVORITE_ERROR, new IOException());
    			return;
    		}
    }

    Обращение к веб-сервису. Вызов этого метода при переносе IDE "растекается" на 5-6 строк.
    Самое интересное - проверка корректности параметров находится в самом конце метода (длиной 150 строк)

    rphx, 23 Февраля 2011

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

    +166

    1. 1
    2. 2
    3. 3
    4. 4
    function assign($params)
    {              
            return $params[0];
    }

    Функция с одной коммерческой cms. Можно же обойтись и без функции. Да и желательно сделать проверку на существование переменной.

    codosub, 23 Февраля 2011

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

    +171

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    if($nav_url=="blog.php")
    {
    $ahaha='2';
    eval('$code["$elementtype"] .= "' . fetch_template('navbar_link') . '";');
    $ahaha='';
    }
    else
    {
    eval('$code["$elementtype"] .= "' . fetch_template('navbar_link') . '";');
    }

    Ахаха!

    symbix, 23 Февраля 2011

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

    +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
    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
    <?php
    $t1 = microtime();
    define('CMS_LOAD', TRUE);
    
    require_once('./inc/config.inc.php');
    require_once('./inc/main_fnc.inc.php');
    
    
    cms_MysqlConnect();
    unset($cms); // попутно используемые данные скрипта
    unset($vars); // $_POST, $_COOKIE, $_GET данные
    cms_RegVars();
    
    $cms['page'] = !empty($vars['page']) ? $vars['page'] : 'main';
    $cms['md_page'] = !empty($vars['md_page']) ? $vars['md_page'] : '';
    
    $cms['ESTRING'] = !get_magic_quotes_gpc() ? TRUE : FALSE;
    $cms['strpos'] = strpos($cms['page'], '_');
    
    $cms['q_page'] = mysql_query("SELECT name, ptext FROM ".CMS_PREFIX."_pages WHERE page='".cms_MysqlEStr($cms['page'])."' LIMIT 1");
    $cms['is_page'] = mysql_num_rows($cms['q_page']);
    
    
    // если в _pages нет такой страницы, перемещаем на главную
    if($cms['is_page'] > 0)
    {
    	list($cms['page_name'], $cms['page_text']) = mysql_fetch_row($cms['q_page']);
    }
    else
    {
    	header("Location: /");
    }
    mysql_free_result($cms['q_page']);
    
    if($cms['strpos'] > 0 && !empty($cms['md_page']))
    {
    	$cms['q_md_product1'] = mysql_query("SELECT name, descript2, cost FROM ".CMS_PREFIX."_productions WHERE id=".intval($cms['md_page'])." LIMIT 1");
    	
    	if(mysql_num_rows($cms['q_md_product1']) > 0)
    	{
    		list($cms['page_name'], $cms['md_prod_descr2'], $cms['md_prod_cost']) = mysql_fetch_row($cms['q_md_product1']);
    	}
    	else
    	{
    		header("Location: /");
    	}
    	
    	mysql_free_result($cms['q_md_product1']);
    }
    
    
    //edited by DEMIS [[email protected]]
    
    $cms['page_text_header'] = $cms['page_name'];

    Index.php в самописной CMS улыбает. И это только начало +)

    be3, 23 Февраля 2011

    Комментарии (11)
  8. JavaScript / Говнокод #5786

    +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
    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
    function get_sel_values(index){
                    var test = eval('typeof opt_val'+index);
                    if ( test != 'undefined' ){
                      eval('var sel_values = opt_val'+index);
                      return sel_values;
                    }
        else { return false; }
    }
    //**************************************************************
    function get_sel_text(index){
                    var test = eval('typeof opt_text'+index); 
                    if ( test != 'undefined' ){
                      eval('var sel_text = opt_text'+index);
                      return sel_text;
                    }
        else { return false; }              
    }
    //**************************************************************
    function show_select(index, lev, dv){
        if ( dv == 'jdc1'){ var tr = "jdc2";}
        if ( dv == 'jdc2'){ var tr = "jdc3";}
        if ( dv == 'jdc3'){ var tr = "jdc4";}
        var curr_sel_text = get_sel_text(index);
        var curr_sel_value = get_sel_values(index);
                    if ( curr_sel_value != false && curr_sel_text != false ){
          if ( dv == 'jdc1'){
            document.getElementById('jdc1').style.visibility = "visible";
            document.getElementById('jdc2').style.visibility = "hidden";
            document.getElementById('jdc3').style.visibility = "hidden";
            document.getElementById('jdc4').style.visibility = "hidden";
                              document.forms["form1"].elements['cc2'].length = 0;
                              document.forms["form1"].elements['cc3'].length = 0;
                              document.forms["form1"].elements['cc4'].length = 0;
                      }
          if ( dv == 'jdc2'){
            document.getElementById('jdc1').style.visibility = "visible";
            document.getElementById('jdc2').style.visibility = "visible";
            document.getElementById('jdc3').style.visibility = "hidden";
            document.getElementById('jdc4').style.visibility = "hidden";
                              document.forms["form1"].elements['cc3'].length = 0;
                              document.forms["form1"].elements['cc4'].length = 0;
                      }
          if ( dv == 'jdc3'){
            document.getElementById('jdc1').style.visibility = "visible";
            document.getElementById('jdc2').style.visibility = "visible";
            document.getElementById('jdc3').style.visibility = "visible";
            document.getElementById('jdc4').style.visibility = "hidden";
                              document.forms["form1"].elements['cc4'].length = 0;
                      }
          var count_values = curr_sel_value.length;
          var category_list = document.forms["form1"].elements[lev];
          var count_category_list = category_list.options.length;
          category_list.length = 0; 
          for (i = 0; i < count_values; i++){
            if (document.createElement){
                var newCategoryListOption = document.createElement("OPTION");
                newCategoryListOption.text = curr_sel_text[i];
                newCategoryListOption.value = curr_sel_value[i];
                (category_list.options.add) ? category_list.options.add(newCategoryListOption) : category_list.add(newCategoryListOption);
            }else{
                category_list.options[i] = new Option(curr_sel_text[i], curr_sel_value[i], false, false);
            }
          }
          document.getElementById(tr).style.visibility = "visible";
              }
                    else{
          document.getElementById(tr).style.visibility = "hidden";
                    }
      }
    //-->

    qbasic, 23 Февраля 2011

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

    +169

    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
    <script type="text/javascript"> 
    opt_text13=new Array("Internet","Hardware","Mobiles","Soft","Sequrity","Networks","Interface");
    opt_val13=new Array("14","28","44","54","61","67","72");
    opt_val113=new Array("114","115","116","117","118","119","120","121");
    opt_text122=new Array("Essays","Scintific Publications","Online Lessons & Tests","Scintific Libraries","Other");
    opt_val122=new Array("123","124","125","126","127");
    opt_text128=new Array("Your Appartment","Cookery","All for Holidays","Family","Pats","Health","Fashion and Beauty","Purchases");
    opt_val128=new Array("129","138","146","155","162","170","179","189");
    opt_text129=new Array("Country Cottage","Repair","Construction","Interior Design","Landscape Design","Building Materials","Sanitary","Other");
    opt_val129=new Array("130","131","132","133","134","135","136","137");
    opt_text138=new Array("Recepies","Diet","Products","Tabacco","Bavarage","Delivery","Other");
    opt_val138=new Array("139","140","141","142","143","144","145");
    opt_text146=new Array("E-Cards","Tostes and scenaries","Gifts","Flowers Delivery","Holiday Organization","Fireworks","Holidays","Other");
    opt_val146=new Array("147","148","149","150","151","152","153","154");
    opt_text155=new Array("For Parents","For Children","Relation's Psyhology","Marrage","Marrage Agancies","Other");
    //...............
    opt_val252=new Array("253","254","255","256","257","258");opt_text259=new Array("Astrology","Fortune-telling","Esotericism","UFO","Other");
    opt_val259=new Array("260","261","262","263","264");
    opt_text268=new Array("Places","Tourism","Vocation","Hobbies");
    opt_val268=new Array("269","280","292","297");
    opt_text269=new Array("Restaurants & Bars","Clubs & Diskos","Bowling & Billiard","Casinos","Places for children","Circuses","Parks & Zoos","Theaters","Cinemas","Other");
    opt_val269=new Array("270","271","272","273","274","275","276","277","278","279");
    opt_text428=new Array("Newspapers","Magazines","Publishing Houses","Business publications","Computer publications","Motor-Car publications","Sport publications","Entertaining publications","Music/Cinema/TV","Publications for women","Publications for men","Publications for kids","Other publications");opt_val428=new Array("429","430","431","432","433","434","435","436","437","438","439","440","441");opt_text446=new Array("Metallurgy","Mechanical engineering","Equipment","Electronics","Energetics","Chemical industry","Agriculture","Food Industry","Factories","Light Industry","Heavy Industry","Other industries");opt_val446=new Array("447","451","458","469","473","479","483","484","485","486","487","488");opt_text447=new Array("Iron industry","Non-ferrous metallurgy","Other");opt_val447=new Array("448","449","450");opt_text451=new Array("Motor-car Factories","Engeenering Factories","Agricultural Factories","Sheepbuilding","Aircraft building","Other");
    //........
    opt_text529=new Array("Office equipment","Office furneture","Lock boxes","Stationery","Other");opt_val529=new Array("530","531","532","533","534");opt_text536=new Array("Encyclopedias","Transport","Maps","Addresses & Phones","Search people","Dictionaries","Weather","Other");opt_val536=new Array("537","543","552","553","554","555","556","557");opt_text537=new Array("Universal","Medical","Biographical","Subject encyclopedia","Other");opt_val537=new Array("538","539","540","541","542");opt_text543=new Array("Timetables","Air transport","Railway","Sailing","Urban transport","Taxi & Car rent","Bus transport","Other");opt_val543=new Array("544","545","546","547","548","549","550","551");opt_text558=new Array("Other");
    opt_val558=new Array("559");//**************************************************************

    qbasic, 23 Февраля 2011

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

    +128

    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
    <table border="0">
    <form name="form1">
    <tr>
      <tr><td width="200"><span id="jdc1">
          <select name="cc1" onclick="show_select(this.options[this.selectedIndex].value, 'cc2','jdc1')">
        <option value="13">Hi-Tech</option><option value="79">Job</option><option value="87">Education</option><option value="128">Home</option><option value="200">Society</option><option value="232">Enterteiments</option><option value="268">Activities</option><option value="304">Culture</option><option value="386">Sport</option><option value="427">Mass-Media</option><option value="446">Industry</option><option value="489">Business</option><option value="536">Inquries</option><option value="558">Other</option>   </select></span></td></tr>
        <tr><td><span id="jdc2" style="visibility: hidden;"><select name="cc2" onclick="show_select(this.options[this.selectedIndex].value, 'cc3','jdc2')" style="">
                    </select></span></td></tr>
        <tr><td><span id="jdc3" style="visibility: hidden;"><select name="cc3" onclick="show_select(this.options[this.selectedIndex].value, 'cc4','jdc3')" style="">
                    </select></span></td></tr> 
        <tr><td><span id="jdc4" style="visibility: hidden;"><select name="cc4" style="">
                    </select></span></td></tr>
    </table>

    qbasic, 23 Февраля 2011

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