1. PHP / Говнокод #18808

    −10

    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
    $textbody="<form name=\"form1\" method=\"post\" enctype=\"multipart/form-data\" action=\"foto_groups.php?do=add\">
                    <center>Добавление пункта меню:</center>
                    <table cellspacing=1 cellpadding=2 width=\"100%\" border=0 bgcolor=\"#CCCCCC\">
    	<tr bgcolor=\"#FFFFFF\"><td width=\"150\">Название:</td><td><input name=\"group_name\" type=\"text\" size=\"70\" maxlength=\"255\" class=\"input\" ></td></tr>
    	<tr bgcolor=\"#FFFFFF\"><td colspan=\"2\">Описание:<br /><textarea name=\"wp1\" id=\"elm2\" rows=\"40\" style=\"width:100%;\"></textarea></td></tr>
                    <tr bgcolor=\"#FFFFFF\"><td width=\"150\">&nbsp;</td><td><input type=\"Submit\" name=\"Submit\" value=\"Добавить группу\" class=\"input\"></td></tr>
                    </table></form>";
            } 
    
    if(!Isset($do)) {
            $textbody="<table cellspacing=1 cellpadding=2 width=\"100%\" border=0 bgcolor=\"#CCCCCC\">
    <tr bgcolor=\"#EFEFEF\"><td width=\"20\">ID</td><td width=\"300\">Название группы</td><td>Описание</td><td width=\"20\">&nbsp;</td><td width=\"20\">&nbsp;</td></tr>\r\n";
            $query = "SELECT * from foto_cat_eng ORDER BY id ASC;";
            $result = MYSQL_QUERY($query) or die("Ошибка в строке запроса:<br><textarea cols=60 rows=10>$query</textarea>");
            while ($row = mysql_fetch_array($result)) {
                $textbody .= "<tr bgcolor=\"#FFFFFF\"><td valign=\"middle\" width=\"20\">".$row["id"]."</td><td valign=\"middle\" width=\"300\">".$row["name"]."</td><td valign=\"middle\">".substr(strip_tags($row["description"]), 0, 100)."</td><td><a href=\"foto_groups.php?do=edit&id=".$row["id"]."\" alt=\"Редактировать...\" title=\"Редактировать...\"><img src=\"img/edit.gif\" width=18 height=18 border=0></a></td><td><a href=\"foto_groups.php?do=delete&id=".$row["id"]."\" onclick=\"return confirm(' Удалить ".$row["name"]."?');\"><img src=\"img/del.gif\" border=0 title=\"Удалить\" alt=\"Удалить\"></a></td></tr>\r\n";
            }
            $textbody.="</table>"; 
    }
    
    include('templates/header.php');
    write_top_panel('goods.gif');

    дино. продолжение)

    progsmile, 02 Октября 2015

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

    +1

    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
    using DocsTaskInfo = System.Collections.Generic.KeyValuePair<int, bool>;
    using DocAndContentType = System.Collections.Generic.KeyValuePair<int, string>;
    using DocAndContentTypeToCount = System.Collections.Generic.Dictionary<System.Collections.Generic.KeyValuePair<int, string>, System.Collections.Generic.KeyValuePair<int, bool>>;
    //...
    private void DocsCountInternal(RefNetDbContainerDirect db, int docType, string contentType,  int status, int count, bool Checked = true){/*...*/}
    //...
    private DocAndContentTypeToCount[] _docCheckTasks;
    private RefNetDbContainerDirect _dbForCheck;
    private void ClearAllDocCounts(RefNetDbContainerDirect dbForCheck)
            {
                _dbForCheck = dbForCheck;
                _docCheckTasks = Enumerable.Repeat(new DocAndContentTypeToCount(), 2).ToArray();
                    //new DocAndContentTypeToCount[2] { new DocAndContentTypeToCount(), new DocAndContentTypeToCount() };
            }
    private void DocsCount(RefNetDbContainerDirect db, int docType, string contentType, int status, int count, bool Checked = true)
            {
                var taskHistory = _docCheckTasks[status];
                var taskKey = new DocAndContentType(docType, contentType);
                var taskInfo = new DocsTaskInfo(count, Checked);
                if(taskHistory.ContainsKey(taskKey))
                    _exceptions.Add(new Exception(string.Format(
                                     "CheckDocsTask with (_.idDocType == {0}) && (_.contentType == \"{1}\") && (_.status == {2}) ) already contained",
                                     docType, contentType, status)));
                taskHistory.Add(taskKey, taskInfo);
            }
    private void CheckAllDocCounts()
            {
                if (AllDocumentsMadeByServer)
                {
                    //1
                    var taskKeys = _docCheckTasks.SelectMany(_ => _.Keys)/*.Distinct()*/.ToArray();
                    foreach (var taskKey in taskKeys)
                    {
                        DocAndContentType key = taskKey;
                        foreach (var statusedTask in _docCheckTasks.Where(statusedTask => !statusedTask.ContainsKey(key)))
                            statusedTask.Add(taskKey, new DocsTaskInfo(0, true));
                    }
                    taskKeys.Select(_ => new
                    {
                        docAndContentType = _,
                        count = _docCheckTasks[0][_].Key + _docCheckTasks[1][_].Key,
                        Checked = _docCheckTasks[0][_].Value && _docCheckTasks[1][_].Value
                    }).ForEach(_ => DocsCountInternal(_dbForCheck, _.docAndContentType.Key, _.docAndContentType.Value, 1, _.count, _.Checked));
            }
                else
                    //0 и 1
                    foreach(var statusedTask in _docCheckTasks.Select((tasks, status) => new {tasks, status}))
                        foreach (var task in statusedTask.tasks)
                            DocsCountInternal(_dbForCheck, task.Key.Key, task.Key.Value, statusedTask.status, task.Value.Key, task.Value.Value);
                _docCheckTasks = null;
                _dbForCheck = null;
            }

    Автору я бы посоветовал утопиться, но как посоветуете отрефакторить?
    Планировалось, что чувак вызывает ClearAllDocCounts, затем много раз метод DocsCount, а потом CheckAllDocCounts.

    USB, 02 Октября 2015

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

    +5

    1. 1
    2. 2
    std::string cmd = "some command";
    Socket.Write( cmd.c_str(), strlen( cmd.c_str() ) );

    сишные плюсЫ

    absolut, 02 Октября 2015

    Комментарии (94)
  4. JavaScript / Говнокод #18803

    +2

    1. 1
    entry.number = $('.info', this).text().split(';')[1].slice($('.info', this).text().split(';')[1].search(':'), $('.info', this).text().split(';')[1].search('/')).trim()

    Регэкспы не нужны.

    thepotato, 02 Октября 2015

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

    −94

    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
    Функция ПолучитьДоговорКонтрагента(Организация,Подразделение,Контрагент) Экспорт
    	
    	 ЗапросДоговор = Новый Запрос;
    		ЗапросДоговор.Текст = "ВЫБРАТЬ
    		               |	ДоговорыКонтрагентов.Ссылка
    		               |ИЗ
    		               |	Справочник.ДоговорыКонтрагентов КАК ДоговорыКонтрагентов
    		               |ГДЕ
    		               |	ДоговорыКонтрагентов.Организация = &Организация
    		               |	И ДоговорыКонтрагентов.Подразделение = &Подразделение
    		               |	И ДоговорыКонтрагентов.Владелец = &Владелец
    		               |
    		               |СГРУППИРОВАТЬ ПО
    		               |	ДоговорыКонтрагентов.Ссылка";
    		ЗапросДоговор.УстановитьПараметр("Организация",Организация);
    		ЗапросДоговор.УстановитьПараметр("Подразделение",Подразделение);
    		ЗапросДоговор.УстановитьПараметр("Владелец",Контрагент);
    		Результат = ЗапросДоговор.Выполнить();
    		Если НЕ Результат.Пустой() Тогда
    			Возврат Результат.Выбрать().Следующий();
    		Иначе
    			
    			Возврат Справочники.ДоговорыКонтрагентов.ПустаяСсылка();
    			
    		КонецЕсли;
    	
    КонецФункции

    Вот вроде функция общего модуля называется ПолучитьДоговорКонтрагента, и ты, не заглядывая в неё, конечно же, ждёшь возврата ссылки на спр-к ДоговорыКонтрагентов, но нет!!

    SkyHunter, 02 Октября 2015

    Комментарии (16)
  6. Си / Говнокод #18801

    −3

    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
    enum test_result {
        TEST_FAILED = -1,
        TEST_SKIPPED,
        TEST_OK
    }
    
    struct test_node {
        const char *name;
        const char *descr;
        enum test_result (*measurement_test_handler)(void* params);
        void *params;
        enum test_result meas_result;
        enum test_result init_result;
    }

    О духи говнакода наставьте агнца вашего на путь истинный. Написал сие я, запустил и всё пошло по п*изде, по причине невыравненых данных. #pragma pack не помог. Помогло лишь изменение типа enum test_result на uint8_t. Подскажите, дабы не наступать на подобные грабли болей, как кто себя проверяет при работе со структурами?

    MiD, 02 Октября 2015

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

    +5

    1. 1
    params['query[accountable_of_' + usersRole.charAt(0).toUpperCase() + usersRole.slice(1) + '_type_super_user_id_eq]'] = vm.superUser.id;

    Пацаны, нормальный же код?

    t540, 02 Октября 2015

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

    +1

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    7. 7
    8. 8
    .selection-href {
      height: inherit !important;
      font-size: 1em !important;
      font-weight: inherit !important;
      box-sizing: inherit !important;
      width: inherit !important;
      text-transform: none !important;
    }

    BeatC, 01 Октября 2015

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

    +1

    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
    {header}
    
    <p style="font-weight: bold; text-decoration: underline">{$orgName}</p>
    
    <p style="font-weight: bold">Адреса: {$orgBillingAddress}, тел.: {$orgPhone}</p>
    
    <div style="font-weight: bold; text-align: center">Зразок заповенння платіжного доручення</div>
    
    <table border="1" cellpadding="2">
    <tr>
      <td width="140">ЄДРПО {$orgInn}</td><td width="140">ІДПРС {$orgKpp}</td><td rowspan="2" width="50"><br/><br/>Рахунок. №</td><td rowspan="2" width="200"><br/><br/>{$orgBankAccount}</td>
    </tr>
    <tr>
    <td colspan="2" width="280"><span style="font-size: 8pt">Одержувач</span><br/>{$orgName}</td>
    </tr>
    <tr>
    <td colspan="2" rowspan="2" width="280"><span style="font-size: 8pt">Банк отримувача</span><br/>{$orgBankName}</td>
    <td width="50">БІК</td>
    <td rowspan="2" width="200">{$orgBankId}<br/>{$orgCorrAccount}</td>
    </tr>
    <tr>
    <td width="50">Рахунок. №</td>
    </tr>
    </table>
    <br/>
    <h1 style="text-align: center">Рахунок № {$invoice_no} від {$invoice_invoicedate}</h1>
    <br/><br/>
    <table border="0">
    <tr>
    <td width="100">Платник:</td><td width="450"><span style="font-weight: bold">{$account_accountname}</span></td>
    </tr>
    <tr>
    <td width="100">Одержувач:</td><td width="450"><span style="font-weight: bold">{$orgName}</span></td>
    </tr>
    </table>
    
    {/header}
    
    {table_head}
    <table border="1" style="font-size: 8pt" cellpadding="2">
        <tr style="text-align: center; font-weight: bold">
    	<td width="30">№</td>
          <td width="260">Назва<br/>товару</td>
          <td width="65">Одиниця<br/>вимір-<br/>рювання</td>
          <td width="35">Кіль-<br/>кість</td>
    	<td width="70">Ціна</td>
    	<td width="70">Сумма</td>
    	</tr>
    {/table_head}
    
    {table_row}
        <tr>
    	<td width="30">{$productNumber}</td>
          <td width="260">{$productName} {$productComment}</td>
    	<td width="65" style="text-align: center">{$productUnits}</td>
    	<td width="35" style="text-align: right">{$productQuantityInt}</td>
    	<td width="70" style="text-align: right">{$productPrice}</td>
    	<td width="70" style="text-align: right">{$productNetTotal}</td>
        </tr>
    {/table_row}
    
    {summary}
    </table>
    <table border="0" style="font-size: 8pt;font-weight: bold">
        <tr>
          <td width="460">
            <table border="0" cellpadding="2">
              <tr><td width="460" style="text-align: right">Разом:</td></tr>
              <tr><td width="460" style="text-align: right">Сумма ПРД:</td></tr>
              <tr><td width="460" style="text-align: right">Всього до сплати:</td></tr>
            </table>
          </td>
          <td width="70">
            <table border="1" cellpadding="2">
              <tr><td width="70" style="text-align: right">{$summaryNetTotal}</td></tr>
              <tr><td width="70" style="text-align: right">{$summaryTax}</td></tr>
              <tr><td width="70" style="text-align: right">{$summaryGrandTotal}</td></tr>
            </table>
          </td>
      </tr>
    </table>
    
    <p>
    Всього найменувань {$summaryTotalItems}, на сумму {$summaryGrandTotal} грн.<br/>
    <span style="font-weight: bold">{$summaryGrandTotalLiteral}</span>
    </p>
    
    {/summary}
    
    {ending}
    <br/>
        <p>Крівник підприємства  __________________ ( {$orgDirector} ) <br/>
        <br/>
        Головний бухгалтер  __________________ ( {$orgBookkeeper} )
        </p>
    {/ending}

    генератор пдф

    igorko, 01 Октября 2015

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

    +3

    1. 1
    2. 2
    3. 3
    4. 4
    /* удивляюсь логике человека, написавшего это */
    
    //echo $a;
    print($a);

    Smoren, 01 Октября 2015

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