1. Куча / Говнокод #7024

    +136

    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
    <td colspan="3" rowspan="2">
    	<script>
    		if(hsub>0){
    			document.write(
    	'<table id=tans width=669 height=109 border=0 cellpadding=0 cellspacing=0 style=position:absolute;top:'+(ah-hsub)+'px>')
    		}else{
    			document.write(
    	'<table id=tans width=669 height=109 border=0 cellpadding=0 cellspacing=0>')
    		}
    	</script>
    	<noscript>
    		<table id=tans width=669 height=109 border=0 cellpadding=0 cellspacing=0>
    	</noscript>
    <tr>

    Нет слов!

    Joe_MD, 22 Июня 2011

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

    +119

    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
    // создаём источник для репитера
    
    private DataTable EventsDataTable
            {
                get
                {
                    DataTable dt = new DataTable();
                    dt.Columns.Add(
                        new DataColumn("ID", typeof(string)));
                    dt.Columns.Add(
                        new DataColumn("day", typeof(string)));
                    dt.Columns.Add(
                        new DataColumn("date", typeof(DateTime)));
                    dt.Columns.Add(
                        new DataColumn("title", typeof(string)));
                    dt.Columns.Add(
                        new DataColumn("url", typeof(string)));
                    dt.Columns.Add(
                        new DataColumn("description", typeof(string)));
                    dt.Columns.Add(
                        new DataColumn("location", typeof(string)));
                    dt.Columns.Add(
                        new DataColumn("place", typeof(string)));
                    dt.Columns.Add(
                        new DataColumn("FileDirRef", typeof(string)));
                    // Добавляем строчки
                    foreach (EventInfo ei in CalendarEvents)
                    {
                        DataRow dr = dt.NewRow();
                        dr["day"] = ei.EventDate.Date.ToString("ddMMyyyy");
                        dr["date"] = ei.EventDate;
                        dr["title"] = ei.Title;
                        dr["location"] = ei.Location;
                        dr["ID"] = ei.ID;
                        dr["FileDirRef"] = ei.FileDirRef;
                        dt.Rows.Add(dr);
                    }
                    return dt;
                }
            }
    
    
    protected void repeaterItemDataBound(object sender, RepeaterItemEventArgs e)
    {
    if (e != null
                        && e.Item != null
                        && e.Item.DataItem != null
                        && e.Item.DataItem is DataRow)
                    {
                        DataRow dataItem = (DataRow)e.Item.DataItem;
    
                        Label date = (Label)(e.Item.FindControl("date"));
                        date.Text = 
                            dataItem["date"] != null
                            ? Convert.ToDateTime(dataItem["date"].ToString()).ToString()
                            : Convert.ToDateTime(dataItem["Created"].ToString()).ToString();
                        date.Text = date.Text.Substring(0, date.Text.Length - 3);
    
                        HyperLink title = (HyperLink)(e.Item.FindControl("title"));
                        title.Text = dataItem["title"].ToString();
                        Label location = (Label)(e.Item.FindControl("location"));
                        location.Text = "Расположение: " + dataItem["location"].ToString();
                    }
    }

    Современный способ привязки данных в asp.net Repeater

    Gnet, 22 Июня 2011

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

    +160

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    <?php 
    function antihack(&$var){   
    if(is_array($var)) array_walk($var, 'antihack');  
    else $var = htmlspecialchars(stripslashes(mysql_real_escape_string($var)), ENT_QUOTES, 'UTF-8');   
    }   
    
    foreach(array('_SERVER', '_GET', '_POST', '_COOKIE', '_REQUEST') as $v){   
    if(!empty(${$v})) array_walk(${$v}, 'antihack');  
    }  
    ?>

    http://homephp.ru/phpcode/index.php?system=bild&stat=173445591-534250613&

    jQuery, 21 Июня 2011

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

    +151

    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
    <?php
    else {
        fwrite($fp,"\xFF\xFF\xFF\xFF\x54\x53\x6F\x75\x72\x63\x65\x20\x45\x6E\x67\x69\x6E\x65\x20\x51\x75\x65\x72\x79\x00".chr(10));
        $start=time();
        socket_set_timeout($fp,1);
        $st=fread($fp,1);
        $r=socket_get_status($fp);
        $r=$r["unread_bytes"];
        $st.=fread($fp,$r);
        fclose($fp);
        $st=substr($st,5);
        $address=SubStr($st,0,StrPos($st,chr(0)));
        $address=str_replace(chr(0),"|",$address);
        $st=SubStr($st,StrPos($st,chr(0))+1);
        $name=SubStr($st,0,StrPos($st,chr(0)));
        $st=SubStr($st,StrPos($st,chr(0))+1);
        $map=SubStr($st,0,StrPos($st,chr(0)));
        $st=SubStr($st,StrPos($st,chr(0))+1);
        $st=SubStr($st,StrPos($st,chr(0))+1);
        $st=SubStr($st,StrPos($st,chr(0))+1);
        $current=ord(SubStr($st,0,1));
        $max=ord(SubStr($st,1,1));
        }
    if ($_GET['info'] == "map")
    {
    echo "document.write('$map');"; 
    }
    if ($_GET['info'] == "players")
    {
       if ($current == "0")
       {
          echo "document.write('<font color=red>$current</font>/$max');";
       }
       else
       {
          if($current == $max)
          {
             echo "document.write('<font color=00FF00>$current</font>/$max');";
          }else{
             echo "document.write('$current/$max');";
          }
       }
    }
    if ($_GET['info'] == "map-img")
    {
    echo "document.write('<img width=$width border=0 src=http://image.www.gametracker.com/images/maps/160x120/cs/$map.jpg>');";
    }
    if ($_GET['info'] == "source-map")
    {
    echo "document.write('$name');";
    }
    if ($_GET['info'] == "block1")
    {
    echo "document.write('<table border=0><tr><td align=center><marquee>$name</marquee><br><img width=160px height=120px style=background:url(http://www.agrank.com/images/maps/210_150/_offline.jpg); border=0 src=http://image.www.gametracker.com/images/maps/160x120/cs/$map.jpg><br>Map - $map<br>Players - <script language=JavaScript src=http://game-monitoring.tk/ucoz/cs-info.php?ip=$ip&port=$port&info=players></script><br><br><center><input value=$ip:$port readonly=readonly onclick=f2(this); class=f_linput type=text></center></td></tr></table>');";
    }
    if ($_GET['info'] == "block4")
    {
    }
    ?>

    Мало ли того, что гавнокод, так ещё и SubStr. аха

    substr, 21 Июня 2011

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

    +188

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    typedef enum
      {
        FFALSE = 0,
        TTRUE,
        MMAYBE
      } Truth_t;

    ну почти квантовое программирование.

    ЗЫ да, это из С++ программы.

    Dummy00001, 21 Июня 2011

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

    +175

    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
    class BalanceValue
    {
      /* ... */
      BalanceValue( int pFamilyGroupId,
                    int ContractId,
                    int pProfileId,
                    int pSncode,
                    long pPurchaseSeqNo,
                    int pBundledProductId,
                    time_t pCreationDate,
                    time_t pNextresetDate,
                    char pState,
                    double pAggregate,
                    double pCredit,
                    double pInitialCredit,
                    double pReservation,
                    char pColor,
                    double pProrateFactor,
                    int pCurrencyId,
                    int pUomId,
                    time_t pSnapshotDate,
                    unsigned long pSequenceNumber,
                    time_t pValidFrom,
                    time_t pValidTo,
                    int pPricingAlternative,
                    int pCocTariffId,
                    time_t pLastresetDate,
                    double pLateCallAggr );
      /* ... */
      void getAllValues( int&            pContractId,
                         int&            pProfileId,
                         int&            pSncode,
                         long&           pPurchaseSeqNo,
                         int&            pBundledProductId,
                         time_t&         pNextResetDate,
                         char&           pState,
                         double&         pAggregate,
                         double&         pCredit,
                         double&         pInitialCredit,
                         double&         pReservation,
                         char&           pColor,
                         double&         pProRateFactor,
                         int&            pCurrencyId,
                         int&            pUomId,
                         time_t&         pSnapShotDate ,
                         unsigned long&  pSequenceNumber,
                         time_t&         pValidFrom,
                         time_t&         pValidTo,
                         int&            pPricingAlternative,
                         int&            pCocTariffId,
                         time_t&         pLastResetDate,
                         double&         pLateCallAggr );
      /* ... */
    };

    чудо интерфейс. 25 параметров у конструктора, 23 параметров (рефернсы!) у геттера. кто больше?

    ЗЫ как оба реализованы можете сами догадатся. и еще несколько других методов в подобном стиле.
    ЗЗЫ да, есть и нормальные геттеры.
    ЗЗЗЫ нет, другого конструктора нету.
    ЗЗЗЗЫ нет, разнести значение по мелким структурам, более приемлимым человеческому мозгу, народ не догадывается. не наш так сказать стиль. (да, есть естественная групировка параметров по источнику откуда они берутся.)

    Dummy00001, 21 Июня 2011

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

    +154

    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
    <?php
     if (isset($_POST['update'])) {
    			 $kolcen=mysql_real_escape_string($_POST['kolcen']);
    			 $tovar=mysql_real_escape_string($_POST['tovar']);
    			 $descr=mysql_real_escape_string($_POST['descr']);
    			 $price=intval($_POST['price']);
    			 $price2=intval($_POST['price2']);
    			 $price3=intval($_POST['price3']);
    			 $id=intval($_POST['update']); 
    			 $zag1=mysql_real_escape_string($_POST['zag1']);
    			 $zag2=mysql_real_escape_string($_POST['zag2']);
    			 $zag3=mysql_real_escape_string($_POST['zag3']);
    			 
    			  switch($kolcen){ 
    		 case '3':$updatetovar = mysql_query ("UPDATE `tovar3` SET `tovar`='$tovar',`descr`='$descr',`price`='$price',`price2`='$price2',`price3`='$price3' WHERE `id`='$id' and `id`='$serv'");
    		 break; 
    		 case '2': $updatetovar = mysql_query ("UPDATE `tovar2` SET `tovar`='$tovar',`descr`='$descr',`price`='$price',`price2`='$price2' WHERE `id`='$id' and `id`='$serv'");
    		 break; 
    		 case '1':$updatetovar = mysql_query ("UPDATE `tovar` SET `tovar`='$tovar',`descr`='$descr',`price`='$price' WHERE `id`='$id' and `pizzaid`='$service'");
    		 break;
    		 case '2images': $updatetovar = mysql_query ("UPDATE `2images` SET `tovar`='$tovar',`descr`='$descr',`price`='$price',`price2`='$price2',`price3`='$price3',`img`='$img',`zag1`='$zag1',`zag2`='$zag2',`zag3`='$zag3' WHERE `id`='$id' and `id`='$serv'");
    		 break;
    		 }
    ?>

    Народ зацените мой код плиз на предмет говнокода, и если чето не так то дайте совет . Этот код для админки добавления товаров. Есть 4 типа категорий, товар с одной ценой, с двумя, с тремя, и товар с двумя картинками. В зависимости от типа категории делаем запрос к базе

    frie, 21 Июня 2011

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

    +159

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    7. 7
    protected function readConfig($configPath) {
        $ini = parse_ini_file($configPath);
        foreach ($ini as $key => $value) {
            $config[$key] = $value;
        }
        return $config;
    }

    xarper, 21 Июня 2011

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

    +120

    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
    var trimmedKey = Regex.Split(key, @"\.").Last();
                    if (_options.Any(o => o == ModelBinderOptions.ExpectUnderLineSymbolAsPrefixDelimiter))
                        trimmedKey = Regex.Split(trimmedKey, "_").Last();
    
                    if (_allRequiredParameters.Any(p => p.Key.ToLower() == trimmedKey.ToLower()))
                    {
                        var param = _allRequiredParameters.Single(p => p.Key.ToLower() == trimmedKey.ToLower());
    
                        try
                        {
                            if (param.Value != typeof(string))
                            {
                                if (Nullable.GetUnderlyingType(param.Value) != null)
                                {
                                    try
                                    {
                                        var parseMethod = Nullable.GetUnderlyingType(param.Value).GetMethods().Where(m => m.Name == "Parse").First(m => m.GetParameters().Count() == 1 && m.GetParameters().First().ParameterType == typeof(string));
                                        var value = parseMethod.Invoke(null, new object[] { form[key] });
                                        formValues.Add(param.Key, value);
                                    }
                                    catch(Exception)
                                    {
                                        formValues.Add(param.Key, null);
                                    }
                                }
                                else
                                {
                                    var parseMethod = param.Value.GetMethods().Where(m => m.Name == "Parse").First(m => m.GetParameters().Count() == 1 && m.GetParameters().First().ParameterType == typeof(string));
                                    var value = parseMethod.Invoke(null, new object[] { form[key] });
                                    formValues.Add(param.Key, value);
                                }
                                
                            }
                            else
                            {
                                formValues.Add(param.Key, form[key]);
                            }
                        }
                        catch (Exception)
                        {
                            // Если произошла ошибка парсинга - печально, но ничего не поделать
                        }
                    }

    Фееричный парсер

    dans, 21 Июня 2011

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

    +171

    1. 1
    var e=("article,aside,footer,header,nav,section").split(',');

    Найдено в дебрях одного сайта.

    lucidfox, 21 Июня 2011

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