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

    В номинации:
    За время:
  2. Куча / Говнокод #6445

    +148

    1. 1
    А может, стоит добавить категорию для лаб/уроков? А то искать искры истинных какашек среди php-datetime'ов и студенческих поделок становится действительно трудно.

    byss, 21 Апреля 2011

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

    +170

    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
    int		GetRndWithRnd(int iRnd, int iRndPlusMinus)
    {
    	if(!iRndPlusMinus) return iRnd;
    	switch((Rand())%2)
    	{
    		case 1:
    			// plus
    			return (int)(iRnd+(Rand()%iRndPlusMinus));
    			break;
    		default:
    			// minus
    			return (int)(iRnd-(Rand()%iRndPlusMinus));
    			break;
    	}
    	return 0;
    }

    Чтоб враги не догадались

    ssAVEL, 20 Апреля 2011

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

    −82

    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
    function repair_clock_Contact(objGame, mVal, sVal) -- master, slave
      -- vsyakie daNNue
      local mType = string.sub (tostring (mVal), -1, -1);
      local mi, mj = repair_clock_GetElemPos(objGame, mVal);
      local sType = string.sub (tostring (sVal), -1, -1);
      local si, sj = repair_clock_GetElemPos(objGame, sVal);
      --?????NEKYUiNYAvKVADRATE???????
    --  if (tonumber (mType) == 2) then   -- FOR MEHA TEST
    --    local a = 0;
    --  end
      if (tonumber (mType) == 9) then
        mType = 2;
      end
      --??????????????????????????????
      --!!!!!NEKYUiNYA!!!!!
      mType = 6 - mType;
      sType = 6 - sType;
      --!!!!!!!!!!!!!!!!!!
      --------------------
    
    ..........................

    Коменты жгут)))
    язык Lua

    MAGnit, 13 Апреля 2011

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

    +146

    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
    <?php 
    
    /** 
     * @class Sanitize 
     * @author Nirmit Bothra 
     * @copyright 2007 
     * @description This class sanitizes all user input which are accessed by PHP using POST, GET or REQUEST variables. Data sanitation helps in making  
     *                safe transactions with a database.  
     */ 
    
    class sanitize { 
        function sanitize() { 
            // class constructor and  
            $this->sanitizeCookie(); 
            $this->sanitizeGet(); 
            $this->sanitizeRequest(); 
            $this->sanitizePost(); 
        } 
         
        function sanitizePost() { 
            foreach($_POST as $key=>$value) { 
                $_POST[$key] = addslashes($value); 
            } 
        } 
        function sanitizeGet() { 
            foreach($_GET as $key=>$value) { 
                $_GET[$key] = addslashes($value); 
            } 
        } 
        function sanitizeRequest() { 
            foreach($_REQUEST as $key=>$value) { 
                $_REQUEST[$key] = addslashes($value); 
            } 
        } 
        function sanitizeCookie() { 
            foreach($_COOKIE as $key=>$value) { 
                $_COOKIE[$key] = addslashes($value); 
            } 
        } 
    } 
    
    $sanitizedData =& new sanitize(); 
    ?>

    http://www.phpclasses.org/browse/file/21488.html

    универсальная индусская обработка входных данных.
    юзер в безопасности!

    Lure Of Chaos, 09 Апреля 2011

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

    +149

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    7. 7
    8. 8
    // get info from db
    		$results = $this->datadb->dataForIndex();
    		$data_['mainResult'] = $results['mainResult'];
    		$data_['pics'] = $results['pics'];
    		$data_['com'] = $results['com'];
    		$data_['huuInvert'] = $results['huuInvert'];
    		$data_['dateInvert'] = $results['dateInvert'];
    		$data_['type'] = $results['type'];

    Кусок со своего CMS. Да я знаю что можно объединить массивы, но иногда не все требуется из функции.

    increazon, 26 Марта 2011

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

    +140

    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
    try
    {
    	client.SendData(xml);
    }
    catch(Exception e)
    {
    	string s = e.ToString();
    	if(s.Substring(0,80)=="System.InvalidOperationException: Operation not allowed on non-connected sockets")
    	{
    		client.tcpclient.Close();
    		clients.Remove(client.SessionId);
    	}
    	else if (s.Substring(0,71)=="System.IO.IOException: Unable to write data to the transport connection")
    	{
    		client.tcpclient.Close();
    		clients.Remove(client.SessionId);
    	}
    	else
    	{
    		client.tcpclient.Close();
    		clients.Remove(client.SessionId);
    	}
    }

    нестандартное определение типа исключения
    найдено в примерах кода кандидата на работу

    mozg_raka, 15 Марта 2011

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

    +154

    1. 1
    2. 2
    3. 3
    4. 4
    if (request->status().is_success() &&
          (request->GetResponseCode() / 100) == 2) {
          /* блаблабла */
      }

    Было случайно откопано в исходниках хромиума (http://src.chromium.org/svn/trunk/src/webkit/appcache/appcache_update_job.cc). И первый вопрос который возникает это "Ну вот нахера???".

    POPSuL, 11 Марта 2011

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

    +146

    1. 1
    2. 2
    3. 3
    var a = 4.83 + 2.54 + 4.85 + 4.83; 
    alert(a); 
    // выводит 17.049999999999997

    Что за глюк???

    istem, 10 Марта 2011

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

    +32

    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
    if (!empty($forum_actions))
    {
    
    ?>
    <div class="linksb">
    	<div class="inbox crumbsplus">
    		<p class="subscribelink clearb"><?php echo implode(' - ', $forum_actions); ?></p>
    	</div>
    </div>
    <?php
    
    }
    
    ?>
    <div id="brdstats" class="block">
    	<h2><span><?php echo $lang_index['Board info'] ?></span></h2>
    	<div class="box">
    		<div class="inbox">
    			<dl class="conr">
    				<dt><strong><?php echo $lang_index['Board stats'] ?></strong></dt>
    				<dd><span><?php printf($lang_index['No of users'], '<strong>'.forum_number_format($stats['total_users']).'</strong>') ?></span></dd>
    				<dd><span><?php printf($lang_index['No of topics'], '<strong>'.forum_number_format($stats['total_topics']).'</strong>') ?></span></dd>
    				<dd><span><?php printf($lang_index['No of posts'], '<strong>'.forum_number_format($stats['total_posts']).'</strong>') ?></span></dd>
    			</dl>
    			<dl class="conl">
    				<dt><strong><?php echo $lang_index['User info'] ?></strong></dt>
    				<dd><span><?php printf($lang_index['Newest user'], $stats['newest_user']) ?></span></dd>
    <?php
    
    if ($pun_config['o_users_online'] == '1')
    {
    	// Fetch users online info and generate strings for output
    	$num_guests = 0;
    	$users = array();
    	$result = $db->query('SELECT user_id, ident FROM '.$db->prefix.'online WHERE idle=0 ORDER BY ident', true) or error('Unable to fetch online list', __FILE__, __LINE__, $db->error());
    
    	while ($pun_user_online = $db->fetch_assoc($result))
    	{
    		if ($pun_user_online['user_id'] > 1)
    		{
    			if ($pun_user['g_view_users'] == '1')
    				$users[] = "\n\t\t\t\t".'<dd><a href="profile.php?id='.$pun_user_online['user_id'].'">'.pun_htmlspecialchars($pun_user_online['ident']).'</a>';
    			else
    				$users[] = "\n\t\t\t\t".'<dd>'.pun_htmlspecialchars($pun_user_online['ident']);
    		}
    		else
    			++$num_guests;
    	}

    главная страница форумного движка fluxbb
    moar тут по сцылке https://github.com/fluxbb/fluxbb/blob/fluxbb-1.4/index.php

    Блядь... зато скока у них там этого самого прекрасно пафоса про секурность и прочие ништяки.

    Имхо пора на написание опенсорсного говнокода давать лицензию сродни водительским правам

    brainstorm, 08 Марта 2011

    Комментарии (21)
  11. Си / Говнокод #5923

    +109

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    while(1) {
        :cycle
        goto cycleCode;
    }
    
    // ...
    
    :cycleCode
    //код
    goto cycle;

    danilissimus, 08 Марта 2011

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