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

    +1000

    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
    void drawFigure()
    {
    	for(int i=0;i<figMaxI;i++)
    		for(int j=0;j<figMaxY;j++)
    			if(figure.space[i][j].wut==1)
    			{
    				if(figure.y+i>=2)
    					if(figureEffekt == 1)
    					{
    						engine->drawTexture2D(figure.picture.texID, gameSpace.x+((figure.x+j)*34)-effekt[0].x, gameSpace.y+((figure.y+i)*34)-effekt[0].y, 34, 34, 0.4, 0, 0);
    						engine->drawTexture2D(figure.picture.texID, gameSpace.x+((figure.x+j)*34)+effekt[0].y, gameSpace.y+((figure.y+i)*34)+effekt[0].x, 34, 34, 0.8, 0, 0);
    						engine->print(fontAlphabet,0, figure.space[i][j].letter , gameSpace.x+((figure.x+j)*34)+6+effekt[0].y,gameSpace.y+((figure.y+i)*34)+4+effekt[0].x,1,0,2);
    					}
    					else
    					{
    						engine->drawTexture2D(figure.picture.texID, gameSpace.x+((figure.x+j)*34), gameSpace.y+((figure.y+i)*34), 34, 34, 1, 0, 0);
    						engine->print(fontAlphabet,0, figure.space[i][j].letter , gameSpace.x+((figure.x+j)*34)+6,gameSpace.y+((figure.y+i)*34)+4,1,0,2);
    					}
    			}
    }

    великое и могучее ООП в действии

    -ggorky, 19 Февраля 2012

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

    +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
    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
    iconv_set_encoding("input_encoding", "UTF-8");
    iconv_set_encoding("internal_encoding", "UTF-8");
    iconv_set_encoding("output_encoding", "UTF-8");
    
    $curl = curl_init();
    $curl_set = array(
            CURLOPT_COOKIESESSION => 0,
            CURLOPT_VERBOSE => 1,
            CURLOPT_USERAGENT => 'Opera/9.60 (J2ME/MIDP; Opera Mini/4.2.14912/812; U; ru) Presto/2.4.15',
            CURLOPT_RETURNTRANSFER => 1
        );
    
    curl_setopt_array($curl, $curl_set);
    
    for($i=1;$i<50;$i++){
        $url = 'http://utemplate.ru/load/19-1-0-'.$i;
        curl_setopt($curl, CURLOPT_URL ,$url);
        $data = curl_exec($curl);
        preg_match_all('#<div class="entrytitle">(.*)</div>(.*)<hr>#isU', $data, $matches);
        $content[title] = $matches[1][0];
        $content[desc] = $matches[2][0];
        unset($matches);
        preg_match_all('#<img src\="http://utemplate.ru/_ld/0/(.*)"/>#isU', $data, $matches);
        $content[img] = $matches[1][0];
        if($content[title] AND $content[desc] AND $content[img]){
            unset($matches);
            mkdir($content[title], 0777);
            curl_setopt($curl, CURLOPT_URL ,'http://utemplate.ru/_ld/0/'.$content[img]);
            $image = curl_exec($curl);
            curl_setopt($curl, CURLOPT_URL ,'http://utemplate.ru/load/0-0-0-'.$i.'-20');
            $file_inf = curl_exec($curl);
            preg_match_all('#<A HREF="(.*)"#isU', $file_inf, $matches);
            $ext_file = substr($matches[1][0], -4);
            $ext_img = substr($content[img], -4);
            curl_setopt($curl, CURLOPT_URL , $matches[1][0]);
            $file = curl_exec($curl);
            file_put_contents($content[title].'/'.$content[title].$ext_file, $file);
            file_put_contents($content[title].'/'.$content[title].$ext_img, $image);
            file_put_contents($content[title].'/'.$content[title].'.txt', $content[title]."\n".$content[desc]);
        }
    
    };

    Злобный самописный, рабочий граббер uCoz сайта

    __construct, 19 Февраля 2012

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

    +964

    1. 1
    2. 2
    3. 3
    4. 4
    private static int CompareWidgetsByOrder(Widget x, Widget y)
    {
          return x == null ? y == null ? 0 : 1 : y == null ? 0 : x.order > y.order ? -1 : x.order < y.order ? 1 : 0;
    }

    Вот до чего доводит стремление к компактности кода.

    nomad99111, 19 Февраля 2012

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

    +158

    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
    function page($page,$total,$link) {
    			$content='';
    			if ($total > 1)	{					
    				$s=($total-$page<6)?(5-$total+$page):0; 
    				for ($i=1;$i<5+$s;$i++) if($page-$i>0) $al[$i]='<a href="'.$link.'page='.($page-$i).'" class="pag_a">'.($page-$i).'</a>';
    				$s=($page<6)?(6-$page):0; 
    				for ($i=1;$i<5+$s;$i++) if($page+$i<=$total) $ar[$i]='<a href="'.$link.'page='.($page+$i).'" class="pag_a">'.($page+$i).'</a>';
    				unset($s);
    				
    				if ($page==1) $cl='pag_an'; else $cl='pag_a';
    				$pervpage='<a href="'.$link.'page='.($page-1).'" class="'.$cl.'"> &#8592; </a>';
    				if ($page>5 && $total>10) $pervpage.='<a href="'.$link.'page=1" class="pag_a">1</a>';
    				if ($page>6 && $total>10) $pervpage.='<a class="pag_an">...</a>';
    				if ($page<$total-5 && $total>10) $nextpage='<a class="pag_an">...</a>';
    				if ($page<$total-4 && $total>10) $nextpage.='<a href="'.$link.'page='.$total.'" class="pag_a">'.$total.'</a>';
    				
    				if ($page==$total) $cl='pag_an'; else $cl='pag_a';
    				$nextpage.='<a href="'.$link.'page='.($page+1).'" class="'.$cl.'" > &#8594; </a>';
    				
    				$content='<div class="page">';
    				$content.=$pervpage.$al[9].$al[8].$al[7].$al[6].$al[5].$al[4].$al[3].$al[2].$al[1].'<a class="pag_an">'.$page.'</a>'.$ar[1].$ar[2].$ar[3].$ar[4].$ar[5].$ar[6].$ar[7].$ar[8].$ar[9].$nextpage;
    				$content.='</div>';
    			}
    			return $content;
    		}

    good_web_master, 19 Февраля 2012

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

    +160

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    public function getInfo() {
            if(!$this->id) return false;
            
            if(!isset($this->info->info_info)) $this->fetchInfoFields(array('info_info'));
            return $this->info->info_info;
        }

    Мне стыдно :(

    luethus, 18 Февраля 2012

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

    +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
    do {
    			size = ($("#textHeight").val()) + "px";
    			$("#textView")
    				.text($("#textInput").val())
    				.css({
    					"color":rs.textColor,
    					"font-color":"#" + rs.textColor,
    					"font-size":size
    				});
    			Cufon.set("fontSize", size).replace("#textView", {
    				"color":"#" + rs.textColor,
    				"fontSize":size
    			});
    			$("#textView").center("#canvasBg");
    			($("#textView canvas").length ? $("#textView canvas") : $("#textView")).center("#canvasBg");
    			if ($("#textView canvas").length && ($("#textView canvas").width() <= $("#canvasBg").width()) && ($("#textView canvas").height() <= $("#canvasBg").height())) break;
    			if (($("#textView").width() <= $("#canvasBg").width()) && ($("#textView").height() <= $("#canvasBg").height())) break;
    			$("#textHeight").val($("#textHeight").val() - 1);
    
    		} while ($("#textHeight").val() > 9);

    Было сжатие картинки в цикле, а вот вам подгонка текста в канвасе.

    kyzi007, 18 Февраля 2012

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

    +155

    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
    data = Ext.JSON.decode(resp.responseText);
                Ext.getCmp('id').setValue(id);
                Ext.getCmp('address').setValue(data.address);
                Ext.getCmp('dateImp').setValue(data.dateImp);
                Ext.getCmp('numberCompl').setValue(data.numberCompl);
                Ext.getCmp('dateReg').setValue(data.dateReg);
                Ext.getCmp('numberOut').setValue(data.numberOut);
                Ext.getCmp('dateOut').setValue(data.dateOut);
                Ext.getCmp('inResolution').setValue(data.inResolution);
                Ext.getCmp('inFio').setValue(data.inFio);
                Ext.getCmp('shortText').setValue(data.shortText);
                Ext.getCmp('dateControl').setValue(data.dateControl);
                Ext.getCmp('dateClose').setValue(data.dateClose);
                Ext.getCmp('dateChange').setValue(data.dateChange);
                //            Ext.getCmp('department').setValue(data.department);
                //            Ext.getCmp('userview').setValue(data.userName);
                Ext.getCmp('useredit').setRawValue(data.user);
                Ext.getCmp('statusCompl').setRawValue(data.statusCompl);
                Ext.getCmp('description').setValue(data.description);
                
                if (data.canAdmin) {
                    Ext.getCmp('useredit').show();
                    //                Ext.getCmp('userview').hide();
                    Ext.getCmp('removeButton').show();
                    Ext.getCmp('copyComp').show();             
                } else {
                    Ext.getCmp('useredit').hide();
                    //                Ext.getCmp('userview').show();
                    Ext.getCmp('removeButton').hide();
                    Ext.getCmp('copyComp').hide();
                }
                
                if (data.canEdit) {
                    Ext.getCmp('save').hide();
                }
            }

    проект на Ext.js4
    Много Ext.getCmp('');
    Весь код - сплошная каша, динамическая загрузка Ext.js4 не используется, прикручено require.js,
    ни одного класса.

    maxt, 18 Февраля 2012

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

    +141

    1. 1
    echo wp_count_comments($post->ID)->approved;

    Не знал, что так можно. Сработало, хыхы.

    varg242, 18 Февраля 2012

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

    +151

    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
    <?/*                                         
    +-------------------------------------------------------+
    |  PHPShop Enterprise 3.6                               |
    |  Все права защищены                                   |
    |  www.phpshop.ru                                       |
    +-------------------------------------------------------+
                                                             
     Внимание!                                               
     ГовноКод файлов не поддается редактированию,          
     для сохранения глюкабельности сайта, пожалуйста, не изменяйте его.      
    ---------------------------------------------------------
     Attention!                                              
     The turd-codes of the site does not give in to editing, 
     For preservation of being able to fail please do not change it!

    Хуета их скрипт.

    shithead, 18 Февраля 2012

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

    +142

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    7. 7
    8. 8
    void main()
    {
        int mass[6]={4,1,3,5,7,0};
        quicksort(mass,5);
        while(mass[5]<7)
            printf("%d",mass[5]);
        getch();
    }

    в общем дал препод готовую программу, задание было найти ошибки, так как программа компилируется, и вроде как ошибка не очевидна, как там виндовс выполнять это будет не знаю, у меня бы вылетело с ошибкой сегментирования, делаю предположение. Изначально проблемное место выглядело примерно так:
    while(mass[5]<5)
    printf("%d",mass[mass[5]]);
    вот это исправление одного из студентов нашего потока, так это второй курс специальности ЭВМ, (facepalm)

    maksim_ovcharik, 17 Февраля 2012

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