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

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

    +1

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    7. 7
    8. 8
    WORD StrLen(PChar s)
    {
    	ASSERT(s!=NULL);
    	int i;
    	for (i=0; ( (*(s+i)!=0) && (i<=WORDMAX) ); i++) {};
    	ASSERT(i<=WORDMAX);
    	return (WORD)i;
    };

    По заявкам из http://govnokod.ru/11318

    Говногость, 29 Июня 2012

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

    +62

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    7. 7
    8. 8
    function find( &$db, $id) {
    		$statement = Contact::findStatement() . " WHERE id = $id";
    		$dbResult = ActiveRecord::abstractFind( $db, $statement);
    		foreach ($dbResult as $dbRow) {
    			return Contact::load( $db, $dbRow);
    		}
    		return null;
    	}

    shmaltorhbooks, 26 Июня 2012

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

    −155

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    override public function execute():void
    {
    	var maintainProductAttributePresenter:ITableBasedPresentrer = this.appPresenter.maintainProductAttributePresenter;
    	var maintainProductAttributeView:View = maintainProductAttributePresenter.view;
    
    	this.appView.showModuleView(maintainProductAttributeView);
    	this.appView.showModuleHeader(maintainProductAttributePresenter.getModuleTitle());
    
    	maintainProductAttributePresenter.updateData();
    }

    Сижу, копипазжу... Специально не стала выбиваться из стандарта... Может хоть на секунду мысль о том что мы занимаемся маразмом кому нибудь в голову придет?

    kyzi007, 25 Июня 2012

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

    −93

    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
    # -*- coding: utf-8 -*-
    from django.db import models
    
    # Create your models here.
    
    class SheduleItem(models.Model):
      WIKDI = (
        ('monday', 'Понедельник'),
        ('tuesday', 'Вторник'),
        ('wednesday', 'Среда'),
        ('thursday', 'Четверг'),
        ('friday', 'Пятница'),
        ('saturday', 'Суббота'),
        ('sunday', 'Воскресенье'),
      )
      TAIM = (
        ('08:00', '08:00'),
        ('09:00', '09:00'),
        ('10:00', '10:00'),
        ('11:00', '11:00'),
        ('12:00', '12:00'),
        ('13:00', '13:00'),
        ('14:00', '14:00'),
        ('15:00', '15:00'),
        ('16:00', '16:00'),
        ('17:00', '17:00'),
        ('18:00', '18:00'),
        ('19:00', '19:00'),
        ('20:00', '20:00'),
        ('21:00', '21:00'),
      )
      weekday = models.CharField(max_length=20, choices=WIKDI)
      time = models.CharField(max_length=6, choices=TAIM)
      action = models.CharField(max_length=30)
      trainer = models.ForeignKey('trainers.StrongTrainer')
    
      def __unicode__(self):
        return self.action

    Django-модель для таблицы расписания занятий. Выдавлено в 2 часа ночи под Сержа Танкяна.

    fat0troll, 24 Июня 2012

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

    +50

    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
    <?php
     require('url_to_absolute.php');
    ini_set('display_errors','On');
    error_reporting('E_ALL');
    $ext=array(
    'pictures'=>array('bmp','jpg','jpeg','pgm','rgb','tga','png','gif','ico'),
    'docs'=>array('rtf','doc','docx','pdf','txt'),
    'html'=>array('shtml','html','xml','css','htm','xhtml'),
    'audio'=>array('mp3','mp4','mpeg','flv','3gp','webm'),
    'arch'=>array('zip','rar','gz','bz2','tar','7zip','ar','tar\.gz','tar\.bz2','xz'),
    'pack'=>array('deb','rpm','jar'),
    'scripts'=>array('sh','pl','py','php','js')
    );
    $murl="";
    $sext="";
    $routh='|((?<=[" ])[^" ]+/[a-z0-9-_%.]+\.';
    foreach($ext as $sk=>$sval){
    foreach($sval as $exts){
      $routh.='(?!'.$exts.'")';
    }
    }
    $routh.='[a-z0-9]{1,5}(?=[" ]))|i';
    echo $routh."<br\ >";
    if(isset($_GET['url'])){
    $url=$_GET['url'];echo $url."<br>";
    preg_match('|(ftp)?(http)?(?:s)?://[a-z0-9-]+\.[a-z]+(\.[a-z0-9-_&+?=%]+)*(?::[0-9]+)?|i',$url,$ures);
    if(!empty($ures[0])){echo $ures[0];$murl=$ures[0];echo "<br>murl ".$murl."<br> ";}
    $html=file_get_contents($url);
    
    foreach($ext as $key=>$val){
    echo "<h2>$key</h2><br\>";
    foreach($val as $mext){
    echo "$mext<br>";
    preg_match_all('|((/[.a-z0-9_-]*)*/[a-z0-9-_.%]+\.'.$mext.'(?![a-z])(?!/))|i',$html,$result);
      if(!empty($result)){
      if(!empty($result[0])){
        $result[0]=array_unique($result[0]);
      foreach($result[0] as $vres){
        $aurl=url_to_absolute($url,$vres);
        echo("<a href=\"$aurl\">".$aurl."</a> ");}
    }
    }
    preg_match_all('|((http(?:s)?://)[a-z0-9-]+\.[a-z]+(?:\.[a-z0-9-_&+?=%]+)*(?::[0-9]+)?(?:/[a-z0-9_-.]*)/[.a-z0-9-_%]+\.'.$mext.'(?![a-z])(?!/))|i',$html,$result);
    if(!empty($result)){
    if(!empty($result[0])){
      $result[0]=array_unique($result[0]);
      foreach($result[0] as $vres){
        $aurl=url_to_absolute($url,$vres);
    echo("<a href=\"$aurl\">".$aurl."</a> ");}
    }
    }
    preg_match_all('|((?<=[" ])[^" ]+\.'.$mext.'(?=[" ]))|i',$html,$result);
    if(!empty($result)){
    if(!empty($result[0])){
    $result[0]=array_unique($result[0]);
    foreach($result[0] as $vres){
        $aurl=url_to_absolute($url,$vres);
    echo("<a href=\"$aurl\">".$aurl."</a> ");}
    }
    }
    
    }
    }
    preg_match_all($routh,$html,$result);
    if(!empty($result)){
    if(!empty($result[0])){
    $result[0]=array_unique($result[0]);
    echo "<br><h2>Other documents</h2><br>";
    foreach($result[0] as $vres){
        $aurl=url_to_absolute($url,$vres);
    echo("<a href=\"$aurl\">".$aurl."</a><br \> ");
    }
    }
    }
    } else { printf("No url\n");}
    ?>

    Вытягивает ссылки на картинки с html файла

    AliceGoth, 21 Июня 2012

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

    +110

    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
    if (M[1]<>M[2]) and (M[1]<>M[3]) and (M[1]<>M[4]) and (M[1]<>M[5]) and (M[1]<>M[6]) then
    begin
    if (M[1]<>M[7]) and (M[1]<>M[8]) and (M[1]<>M[9]) and (M[1]<>M[10]) then
    write('  ',M[1],'  ');
    end;
     
    if (M[2]<>M[1]) and (M[2]<>M[3]) and (M[2]<>M[4]) and (M[2]<>M[5]) and (M[2]<>M[6]) then
    begin
    if (M[2]<>M[7]) and (M[2]<>M[8]) and (M[2]<>M[9]) and (M[2]<>M[10]) then
    write('  ',M[2],'  ');
    end;
     
    if (M[3]<>M[1]) and (M[3]<>M[2]) and (M[3]<>M[4]) and (M[3]<>M[5]) and (M[3]<>M[6]) then
    begin
    if (M[3]<>M[7]) and (M[3]<>M[8]) and (M[3]<>M[9]) and (M[3]<>M[10]) then
    write('  ',M[3],'  ');
    end;
     
    if (M[4]<>M[1]) and (M[4]<>M[2]) and (M[4]<>M[3]) and (M[4]<>M[5]) and (M[4]<>M[6]) then
    begin
    if (M[4]<>M[7]) and (M[4]<>M[8]) and (M[4]<>M[9]) and (M[4]<>M[10]) then
    write('  ',M[4],'  ');
    end;
     
    if (M[5]<>M[1]) and (M[5]<>M[2]) and (M[5]<>M[3]) and (M[5]<>M[4]) and (M[5]<>M[6]) then
    begin
    if (M[5]<>M[7]) and (M[5]<>M[8]) and (M[5]<>M[9]) and (M[5]<>M[10]) then
    write('  ',M[5],'  ');
    end;
     
    if (M[6]<>M[1]) and (M[6]<>M[2]) and (M[6]<>M[3]) and (M[6]<>M[4]) and (M[6]<>M[5]) then
    begin
    if (M[6]<>M[7]) and (M[6]<>M[8]) and (M[6]<>M[9]) and (M[6]<>M[10]) then
    write('  ',M[6],'  ');
    end;
     
    if (M[7]<>M[1]) and (M[7]<>M[2]) and (M[7]<>M[3]) and (M[7]<>M[4]) and (M[7]<>M[5]) then
    begin
    if (M[7]<>M[6]) and (M[7]<>M[8]) and (M[7]<>M[9]) and (M[7]<>M[10]) then
    write('  ',M[7],'  ');
    end;
    readln;
     
    if (M[8]<>M[1]) and (M[8]<>M[2]) and (M[8]<>M[3]) and (M[8]<>M[4]) and (M[8]<>M[5]) then
    begin
    if (M[8]<>M[6]) and (M[8]<>M[7]) and (M[8]<>M[9]) and (M[8]<>M[10]) then
    write('  ',M[8],'  ');
    end;
     
    if (M[9]<>M[1]) and (M[9]<>M[2]) and (M[9]<>M[3]) and (M[9]<>M[4]) and (M[9]<>M[5]) then
    begin
    if (M[9]<>M[6]) and (M[9]<>M[7]) and (M[9]<>M[8]) and (M[8]<>M[10]) then
    write('  ',M[9],'  ');
    end;
     
    if (M[10]<>M[1]) and (M[10]<>M[2]) and (M[10]<>M[3]) and (M[10]<>M[4]) and (M[10]<>M[5]) then
    begin
    if (M[10]<>M[6]) and (M[10]<>M[7]) and (M[10]<>M[8]) and (M[10]<>M[9]) then
    write('  ',M[10],'  ');
    end;

    Циклы? Не, не слышал...

    HighPredator, 19 Июня 2012

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

    +67

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    7. 7
    <?if($metaid == 16 || $metaid == 44 || $metaid == 52 || $metaid == 60 || $metaid == 90 ||
     $metaid == 132 || $metaid == 136 || $metaid == 174 || $metaid == 192 || $metaid == 196 || 
    $metaid == 238 || $metaid == 388 || $metaid == 462 || $metaid == 470 || $metaid == 480 || 
    $metaid == 500 || $metaid == 530 || $metaid == 533 || $metaid == 548 || $metaid == 580 || 
    $metaid == 584 || $metaid == 662 || $metaid == 666 || $metaid == 678 || $metaid == 690 || 
    $metaid == 772 || $metaid == 780 || $metaid == 833){?>на<?} else if($metaid == 250 || 
    $metaid == 254 || $metaid == 258 || $metaid == 704){?>во<?}else{?>в<?}?>

    Одно из пятнадцати подобных условий в файле. Было написано в одну строку, поэтому тело условия увидели не сразу. Разнес по строкам для удобства чтения.

    kreksoverzum, 15 Июня 2012

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

    +124

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    7. 7
    # Some old m4's don't support m4exit.  But they provide
    # equivalent functionality by core dumping because of the
    # long macros we define.
    ifdef([__gnu__], ,
    [errprint(M4sugar requires GNU M4. Install it before installing M4sugar or
    set the M4 environment variable to its path name.)
    m4exit(2)])

    из m4 скрипта, часть autoconf.

    fyi: http://en.wikipedia.org/wiki/M4_%28computer_language%29

    Dummy00001, 15 Июня 2012

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

    −165

    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
    $sql = 'SELECT * FROM 
                        (SELECT COUNT(company.id) as cnt_company , 
                        FROM_DAYS(TO_DAYS( company.created_at )) as day 
                            FROM company
                        JOIN contact ON contact.company_id = company.id
                        JOIN issuer ON issuer.id = company.issuer_id
                        JOIN bill ON bill.company_id = company.id
                            WHERE contact.partner_id ='.$this->_partner->getId().'
                            AND company.created_at '.$query.'
                        GROUP BY day) as A 
                    LEFT JOIN
                        (SELECT COUNT(process.id) as finished, 
                        FROM_DAYS(TO_DAYS( process.finished_at )) as day2 
                            FROM process
                        JOIN bill on bill.id= process.bill_id
                        JOIN company ON bill.company_id = company.id
                        JOIN contact ON contact.company_id = company.id
                        JOIN issuer ON issuer.id = company.issuer_id
                            WHERE contact.partner_id ='.$this->_partner->getId().'
                            AND issuer.signature_article_id = bill.article_id
                        GROUP BY day2) as B ON A.day = B.day2
                    LEFT JOIN
                        (SELECT COUNT( * ) as count,
                        FROM_DAYS(TO_DAYS(click.created_at)) as day3,
                        COUNT( DISTINCT click.ip ) as uniq 
                            FROM click 
                        WHERE click.partner_id = '.$this->_partner->getId().'
                        AND click.created_at '.$query.'
                           GROUP BY day3)  as C ON A.day = C.day3
                    UNION
                    SELECT * FROM 
                        (SELECT COUNT(company.id) as cnt_company , 
                        FROM_DAYS(TO_DAYS( company.created_at )) as day 
                            FROM company
                        JOIN contact ON contact.company_id = company.id
                        JOIN issuer ON issuer.id = company.issuer_id
                        JOIN bill ON bill.company_id = company.id
                            WHERE contact.partner_id ='.$this->_partner->getId().'
                            AND DATE(company.created_at)'.$query.'
                        GROUP BY day) as A 
                    RIGHT JOIN
                        (SELECT COUNT(process.id) as finished, 
                        FROM_DAYS(TO_DAYS( process.finished_at )) as day2 
                            FROM process
                        JOIN bill on bill.id= process.bill_id
                        JOIN company ON bill.company_id = company.id
                        JOIN contact ON contact.company_id = company.id
                        JOIN issuer ON issuer.id = company.issuer_id
                            WHERE contact.partner_id ='.$this->_partner->getId().'
                        AND issuer.signature_article_id = bill.article_id
                        GROUP BY day2 ) as B ON A.day = B.day2
                    RIGHT JOIN
                        (SELECT COUNT( * ) as count,
                        FROM_DAYS(TO_DAYS(click.created_at)) as day3,
                        COUNT( DISTINCT click.ip ) as uniq 
                            FROM click 
                        WHERE click.partner_id = '.$this->_partner->getId().'
                        AND click.created_at '.$query.'
                           GROUP BY day3)  as C ON A.day = C.day3';

    T_T

    raga, 15 Июня 2012

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

    +53

    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
    function CP1251toUTF8($string) {
        $out = '';
        for ($i = 0; $i < strlen($string); ++$i) {
            $ch = ord($string{$i});
            if ($ch < 0x80)
                $out .= chr($ch);
            else
            if ($ch >= 0xC0)
                if ($ch < 0xF0)
                    $out .= "\xD0" . chr(0x90 + $ch - 0xC0); // А-Я, а-п (A-YA, a-p) 
                else
                    $out .= "\xD1" . chr(0x80 + $ch - 0xF0); // р-я (r-ya) 
                    else
                switch ($ch) {
                    case 0xA8: $out .= "\xD0\x81";
                        break; // YO 
                    case 0xB8: $out .= "\xD1\x91";
                        break; // yo 
    // ukrainian 
                    case 0xA1: $out .= "\xD0\x8E";
                        break; // Ў (U) 
                    case 0xA2: $out .= "\xD1\x9E";
                        break; // ў (u) 
                    case 0xAA: $out .= "\xD0\x84";
                        break; // Є (e) 
                    case 0xAF: $out .= "\xD0\x87";
                        break; // Ї (I..) 
                    case 0xB2: $out .= "\xD0\x86";
                        break; // I (I) 
                    case 0xB3: $out .= "\xD1\x96";
                        break; // i (i) 
                    case 0xBA: $out .= "\xD1\x94";
                        break; // є (e) 
                    case 0xBF: $out .= "\xD1\x97";
                        break; // ї (i..) 
    // chuvashian 
                    case 0x8C: $out .= "\xD3\x90";
                        break; // ? (A) 
                    case 0x8D: $out .= "\xD3\x96";
                        break; // ? (E) 
                    case 0x8E: $out .= "\xD2\xAA";
                        break; // ? (SCH) 
                    case 0x8F: $out .= "\xD3\xB2";
                        break; // ? (U) 
                    case 0x9C: $out .= "\xD3\x91";
                        break; // ? (a) 
                    case 0x9D: $out .= "\xD3\x97";
                        break; // ? (e) 
                    case 0x9E: $out .= "\xD2\xAB";
                        break; // ? (sch) 
                    case 0x9F: $out .= "\xD3\xB3";
                        break; // ? (u) 
                }
        }
        return $out;
    }

    iconv? Не, не слышал.

    7ion, 14 Июня 2012

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