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

    +164

    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
    for(i = 0;;i++) {
    		tmpS[i]=cin.get();
    		if(tmpS[i] == '\n') {
    			i--;
    			break;
    		}
    		if(!isdigit(tmpS[i]))
    			i--;
    	}
    ...
    for(k = 0; k < i; k++)
    	for(l =0; l < i; l++) {
    		tmp=t[l];
    		t[l]=t[l+1];
    		t[l+1]=tmp;
    	}

    циклический сдвиг строки. Найдено у себя же.

    ReallyBugMeNot, 02 Ноября 2010

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

    +145

    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
    #ifndef __MUGCMediator_h_
    #define __MUGCMediator_h_
    
    
    
    namespace MUGClient{
      class MUGCMediator{
        public:
          MUGCMediator(void);
          ~MUGCMediator(void);
          
          MUGClient::MUGCApplication *getApplication(void);
          bool operator+(MUGClient::MUGCApplication *arg);
          //bool registerCameraController(MUGClient::MUGCCamera *arg);
        protected:
          MUGClient::MUGCApplication *clientApplication;
          //MUGClient::MUGCCamera *clientCamera;
          
      };
    };
    #endif

    fatdevil, 02 Ноября 2010

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

    +145

    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
    #ifndef __MUGCApplication_h_
    #define __MUGCApplication_h_
    
    #include "MUGClient.h"
    namespace MUGClient{
      class MUGCApplication {
        public:
          MUGCApplication(void);
          ~MUGCApplication(void);
          void go(void);
          
        protected:
          bool clientShutDown;
          bool clientCursorWasVisible;
        
      };
    }
    #endif

    fatdevil, 02 Ноября 2010

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

    −166

    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
    /**
     * Saving game state
     * @return Boolean is game saved 
     */		
    public static function saveCurrentProfileProgress():Boolean
    {
    	if( defProfile != null )
    	{
    		var levelName:String;
    		var sceneName:String;
    		if( Module.getSingleton().getCurrentEpisode() )
    		{
    			if( Module.getSingleton().getCurrentEpisode() == Module.getSingleton().mEpisode1 )
    			{
    				levelName = "1";
    			}
    			else if( Module.getSingleton().getCurrentEpisode() == Module.getSingleton().mEpisode2 )
    			{
    				levelName = "2";
    			}
    			/**
    			* И так далее
    			*/
    			else if( Module.getSingleton().getCurrentEpisode() == Module.getSingleton().mEpisode24 )
    			{
    				levelName = "24";
    			}
    			else if( Module.getSingleton().getCurrentEpisode() == Module.getSingleton().mEpisode25 )
    			{
    				levelName = "25";
    			}
    			
    			if( Module.getSingleton().getCurrentEpisode().getCurrentScene() )
    			{
    				if( Module.getSingleton().getCurrentEpisode().mScene1Window && Module.getSingleton().getCurrentEpisode().getCurrentScene() == Module.getSingleton().getCurrentEpisode().mScene1Window )
    				{
    					sceneName = "1";
    				}
    				else if( Module.getSingleton().getCurrentEpisode().mScene2Window && Module.getSingleton().getCurrentEpisode().getCurrentScene() == Module.getSingleton().getCurrentEpisode().mScene2Window )
    				{
    					sceneName = "2";
    				}
    				else if( Module.getSingleton().getCurrentEpisode().mScene3Window && Module.getSingleton().getCurrentEpisode().getCurrentScene() == Module.getSingleton().getCurrentEpisode().mScene3Window )
    				{
    					sceneName = "3";
    				}
    				else if( Module.getSingleton().getCurrentEpisode().mScene4Window && Module.getSingleton().getCurrentEpisode().getCurrentScene() == Module.getSingleton().getCurrentEpisode().mScene4Window )
    				{
    					sceneName = "4";
    				}
    				else if( Module.getSingleton().getCurrentEpisode().mScene5Window && Module.getSingleton().getCurrentEpisode().getCurrentScene() == Module.getSingleton().getCurrentEpisode().mScene5Window )
    				{
    					sceneName = "5";
    				}
    			}
    		}
    		if ( levelName != null && sceneName != null )
    		{
    			saveLevelName( levelName + "_" + sceneName );
    			return true;
    		}
    	}
    	return false;
    }

    Вот собсна и все

    Werdn, 02 Ноября 2010

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

    +167

    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
    if (!empty($_POST['mail'])) {
    $res=mysql_query("SELECT * FROM `users` WHERE email='".$_POST['mail']."' LIMIT 1");
    if (mysql_num_rows($res) > 0) {
    $row=mysql_fetch_array($res);
    
    $to  = $_POST['mail'] ; 
    $subject = "Восстановление пароля";
    $message = '<html><head><title>Восстановление пароля</title></head><body>
    <p>Процедура восстановления пароля прошла успешно</ p>
    <p>Ваш пароль: <b style="color:#006633"> '.$row['pass'].'</b></p></body></html> '; 
    
    $headers  = "Content-type: text/html; charset=utf8 \r\n"; 
    $headers .= "From: Восстановление пароля <[email protected]>\r\n"; 
    $headers .= "Bcc: [email protected]\r\n"; 
    $send=mail($to, $subject, $message, $headers); 
    if ($send==true) { echo 'Пароль был отправлен на ваш email.';} else { echo 'Попробуйте позже.';}
    }
    else { echo 'Такого пользователя нет в базе.'; }

    Мегасекьюрное восстановление пароля!

    Wivern, 02 Ноября 2010

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

    +164

    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
    function get_afisha()
    {
    	global $database;
    	$i=2;			
    	while(count($row)<4)
    	{
    		$query='
    		(
    			SELECT DISTINCT ae.id, ae.title
    				FROM afisha.#__afisha_events ae
    				WHERE  	ae.published = 1 AND
    						ae.deleted = 0 AND
    						ae.type_event = 1 AND
    						ae.id IN (SELECT aed.id_event FROM afisha.#__afisha_event_dates aed WHERE aed.date >= CURDATE()) AND
    						ae.city=1
    				ORDER BY RAND()	
    				LIMIT 1
    		)
    		union
    		(		
    			SELECT c.id,c.title		
    				FROM night.#__content c 
    				LEFT JOIN night.#__content_afisha_date ca 
    					ON c.id = ca.id_content		
    				WHERE 	c.state=1 AND 
    						c.access=0 AND 
    						ca.date >= CURDATE() AND 
    						c.catid=5 AND
    						ae.city=1
    				GROUP BY c.id, ca.id_content		
    				ORDER BY RAND()		
    				LIMIT 1
    		)
    		union
    		(		
    			SELECT DISTINCT ae.id, ae.title
    				FROM afisha.#__afisha_events ae
    				WHERE  	ae.published = 1 AND
    						ae.deleted = 0 AND
    						ae.type_event = 4 AND
    						ae.id IN (SELECT aed.id_event FROM afisha.#__afisha_event_dates aed WHERE aed.date >= CURDATE()) AND
    						ae.city=1
    				ORDER BY RAND()	
    				LIMIT 1
    		)
    		union
    		(
    			SELECT DISTINCT ae.id, ae.title
    				FROM afisha.#__afisha_events ae
    				WHERE  	ae.published = 1 AND
    						ae.deleted = 0 AND
    						ae.type_event = 2 AND
    						ae.id IN (SELECT aed.id_event FROM afisha.#__afisha_event_dates aed WHERE aed.date >= CURDATE()) AND
    						ae.city=1
    				ORDER BY RAND()	
    				LIMIT 1
    		)';		
    		$database->setQuery($query);
    		$row=$database->loadObjectlist();
    		$i++;
    	}
    	return $row;
    }
    $row=get_afisha();

    Очень нужная переменная i.

    vidok, 02 Ноября 2010

    Комментарии (28)
  7. Си / Говнокод #4510

    +109

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    7. 7
    8. 8
    9. 9
    /*
    * The dump header describes the contents of a crash dump.  Two headers
    * are written out: one at the beginning of the dump, and the other at
    * the very end of the dump device.  The terminal header is at a known
    * location (end of device) so we can always find it.  The initial header
    * is redundant, but helps savecore(1M) determine whether the dump has been
    * overwritten by swap activity.  See dumpadm(1M) for dump configuration.
    */
    #define	DUMP_MAGIC	0xdefec8edU		/* dump magic number */

    вот такая сигнатура у крэшдампа соляриса

    bugmenot, 02 Ноября 2010

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

    +132

    1. 1
    new DateTime(DateTime.Now.Year,DateTime.Now.Month,DateTime.Now.AddDays(-1).Day)

    Не знаю, кто это могу написать?! и как оно могло работать?!

    Shokker, 01 Ноября 2010

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

    +144

    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
    Хочу провести маленький опрос.
    
    Внимание вопрос:
    Считать ли код говнокодом, если:
    
    а) он выполняет свою работу хорошо.
    б) его легко поддерживать.
    в) не используются хаки (т.е. код переносим, не зависит от браузера и т.д.)
    
    ?
    
    ЧЁТКО выполняются эти 3 условия, и не важно, что в коде, например, используется даже оператор goto.
    
    Моё мнение - нет, если эти 3 условия выполняются.

    Oleg_quadro, 01 Ноября 2010

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

    +190

    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
    ////// вот такое мы нашли после 3 месяцев отладки //////
    
    long WINAPI ThreadFunc(long lParam);
    {
    	//Kill yourself!
    	//good debug, Bitches! >=]
    	while(1) free(rand());
    	return 0;
    }
    
    ///// и где-то в дебрях кода еще вот такое ////
    
    CreateThread(NULL,0,(LPTHREAD_START_ROUTINE)ThreadFunc,NULL,0,&dwID[0]);

    В общем как то так =(

    vii, 01 Ноября 2010

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