1. C++ / Говнокод #9414

    +148

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    7. 7
    8. 8
    9. 9
    vector<long long> fib;
    	for
    	(
    		long long a=1,b=1;
    		b=a+b,a=a+b,a>0&&b>0;
    		cout<<b<<" "<<a<<endl,
    		fib.push_back(b),
    		fib.push_back(a)
    	);

    Just outputting fibonacci numbers as pairs and storing them in a vector...

    wyand, 14 Февраля 2012

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

    +120

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    7. 7
    public class BillingService : Handles<NewDayHasComeInMoscow>
    {
            public void When(NewDayHasComeInMoscow ev)
            {
                // ...
            }
    }

    pavelhritonenko, 14 Февраля 2012

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

    +66

    1. 1
    count = indexFactory.getIndexHelper(section).getSearcher().docFreq(new Term("firm", Long.toString(firm)));

    матрешка :)

    zlob.jc, 14 Февраля 2012

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

    +159

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    # Чтобы уж точно 
    if($file == null OR $file == '') {
    
    # ......
    
    }

    T_ENGINE, 14 Февраля 2012

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

    +152

    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
    $query = "SELECT id, login, adress FROM $table";
    $res = mysql_query($query) or die('<b>Системная ошибка</b>');
    while ($row = mysql_fetch_assoc($res))  {
    $id = $row["id"]; 
    $login = $row["login"]; 
    $adress = $row["adress"]; 
    }
    /* Закрываем соединение */
    mysql_close();
    ?>
    <!DOCTYPE html PUBLIC '-//W3C//DTD XHTML 1.0 Transitional//EN' 'http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd'>
    <html xmlns='http://www.w3.org/1999/xhtml'>
    <body>
    <table> 
       <tr>
          <td><strong><?php echo $id; ?></strong></td>
          <td><center><?php echo $login; ?></center></td>
          <td><center><?php echo $adress; ?></center></td>
       </tr>
    </table>

    http://skripters.biz/forum/topic_42215

    Unknown, 14 Февраля 2012

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

    +159

    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
    function ***_helper_form_alter(&$form, &$form_state, $form_id) {
      if(substr($form_id, -9) == 'node_form') {   //  Make sure this stuff only happens for node edit forms.
      	// make helpful menus items available for editors on season types
      	if(isset($form['#node']->type) && $form['#node']->type == 'season') {
        	$form['field_menu_items'][0]['#description'] = 'Cut and paste the text in the blue box below into field above for menu items.<br />
        	(You must have created and submitted the season first, and the links below should look like "/show-name/season-#/link".)<br />
        	Delete items you don\'t wish to appear: The second section of the code is for items below the dotted line.<br />
        	<div style="margin:15px;border:1px solid #0CA2FF;padding:10px;">
        	<li><a href="/'.$form['#node']->path.'/about">About</a></li&#62<br />
        	<li><a href="/'.$form['#node']->path.'/bios">Bios</a></li><br />
        	<li><a href="/'.$form['#node']->path.'/blogs">Blogs</a></li&#62<br />
        	<li><a href="/'.$form['#node']->path.'/episodes">Episodes</a></li><br />
        	<li><a href="/'.$form['#node']->path.'/games">Games</a></li&#62<br />
        	<li><a href="/'.$form['#node']->path.'/photos">Photos</a></li><br />
        	<li><a href="/'.$form['#node']->path.'/videos">Videos</a></li&#62<br /><br />
        	<!-- Use code below for additional menu items: --><br /><br />
        	</ul><ul class="season-extras"><br />
        	<li><a href="http://games.***.com/">Full URL needed if not on www.***.com</a></li&#62<br />
        	<li><a href="/top-chef/diet-dr-pepper-challenge">Dr. Pepper Challenge</a></li&#62<br />
        	<li><a href="/foodies/recipe-finder">Recipe Finder</a></li&#62<br /><br />
        	<!-- Use code below for the "flyout" navigation: --><br /><br />
        	<li><a href="/tweettracker">Talk</a><br />
              <ul> <br />
                <div class="separator" style="float: left;"><br />
                    <li><a href="/tweettracker">Tweet Tracker</a></li&#62<br />
                    <li><a href="/tweetbattle">Tweet Battles</a></li&#62<br />
                    <li><a href="/iwanttobeahousewife">Just Saying</a></li&#62<br />
                </div><br />
              </ul><br />
          </li><br />
    
        	</div>';
    
      	  }

    Вот такой вот "код" попался на глаза в новом проекте

    Phabyd, 13 Февраля 2012

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

    +159

    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
    //1 скрипт
    $x = rand (1,3);
    if ($x==1)
    {
    echo "Выберите круг<br>";
    $n='krug';
    }
    elseif ($x==2)
    {
    echo "Выберите квадрат<br>";
    $n='Kvadr';
    }
    elseif ($x==3)
    {
    echo "Выберите треугольник<br>";
    $n='Treug';
    }
    echo '<img src="1.jpg">';
    echo '<input type=radio name="captcha" value="krug"><br>';
    echo '<img src="2.jpg">';
    echo '<input type=radio name="captcha" value="Kvadr"><br>';
    echo '<img src="3.jpg">';
    echo '<input type=radio name="captcha" value="Treug"><br>';
    
    $captcha = fopen("captcha.txt", "w+");
    $key = $n;
    fwrite($captcha,$key);
    fclose($captcha);
    ?>
    
    //2 скрипт 
    $file = file_get_contents('./captcha.txt', false);
    if ($_REQUEST["captcha"] == $file)
    {

    Недавно наговнокодил.Эдакая реализация каптчи без sql.

    Cadmium, 13 Февраля 2012

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

    +127

    1. 1
    2. 2
    <input type="checkbox" value="Зеленый" id="color_id_008000" name="color_variant"/>
    <label style="white-space: nowrap;" for="color_id_008000">Зеленый</label>

    и причем в коде больше эти id не где не используются, но самое страшное то что на одной странице такого маразма 2200 строк.

    Sulik78, 13 Февраля 2012

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

    +165

    1. 1
    2. 2
    3. 3
    4. 4
    $(".left_links li ul li.current_menu_item").parent().show();
    	$(".left_links li ul li ul li.current_menu_item").parent().parent().parent().show();
    	$(".left_links li ul li ul li ul li.current_menu_item").parent().parent().parent().parent().parent().show();
    	$(".left_links li ul li ul li ul li.current_menu_item").parent().parent().parent().parent().parent().parent().parent().show();

    Боковое меню с 5 уровней. Чудо задача показать выбранный пользователем пункт этого меню . Глупейший способ js представлен выше.

    Doodlez, 13 Февраля 2012

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

    +131

    1. 1
    2. 2
    3. 3
    $(EXTRA_SRC) :
            cp -f $(PROJ_ROOT)/src/libA/com_print.c ./com_print.cpp
            cp -f $(PROJ_ROOT)/src/libA/com_misc.c ./com_misc.cpp

    из Makefile'а. /другой/ способ подключения нужной библиотеки к модулю.

    Dummy00001, 13 Февраля 2012

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