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

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

    +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
    $query = "SELECT id, login, adress FROM $table";
    $res = mysql_query($query) or die('<b>Системная ошибка</b>');
    while ($row = mysql_fetch_assoc($res))  {
    $id = $row["id"]; 
    $login = $row["login"]; 
    $adress = $row["adress"]; 
    }
    /* Закрываем соединение */
    mysql_close();
    ?>
    <!DOCTYPE html PUBLIC '-//W3C//DTD XHTML 1.0 Transitional//EN' 'http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd'>
    <html xmlns='http://www.w3.org/1999/xhtml'>
    <body>
    <table> 
       <tr>
          <td><strong><?php echo $id; ?></strong></td>
          <td><center><?php echo $login; ?></center></td>
          <td><center><?php echo $adress; ?></center></td>
       </tr>
    </table>

    http://skripters.biz/forum/topic_42215

    Unknown, 14 Февраля 2012

    Комментарии (8)
  3. Java / Говнокод #9388

    +192

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    7. 7
    8. 8
    9. 9
    public Matrix3d(double m00,
                    double m01,
                    double m02,
                    double m10,
                    double m11,
                    double m12,
                    double m20,
                    double m21,
                    double m22)

    [color=blue]http://docs.oracle.com/cd/E17802_01/j2se/javase/technologies/desktop/java3d/forDevelopers/J3D_1_3_API/j3dapi/javax/vecmath/Matrix3d.html[color]

    3.14159265, 10 Февраля 2012

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

    +160

    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
    function get_image_phy_destination_path(){	
    	$today = getdate();
    	if ($today['month'] == "January"){
    	  $today['month'] = "01";
    	}elseif ($today['month'] == "February"){
    	  $today['month'] = "02";
    	}elseif  ($today['month'] == "March"){
    	  $today['month'] = "03";
    	}elseif  ($today['month'] == "April"){
    	  $today['month'] = "04";
    	}elseif  ($today['month'] == "May"){
    	  $today['month'] = "05";
    	}elseif  ($today['month'] == "June"){
    	  $today['month'] = "06";
    	}elseif  ($today['month'] == "July"){
    	  $today['month'] = "07";
    	}elseif  ($today['month'] == "August"){
    	  $today['month'] = "08";
    	}elseif  ($today['month'] == "September"){
    	  $today['month'] = "09";
    	}elseif  ($today['month'] == "October"){
    	  $today['month'] = "10";
    	}elseif  ($today['month'] == "November"){
    	  $today['month'] = "11";
    	}elseif  ($today['month'] == "December"){
    	  $today['month'] = "12";
    	}
    	
    	 $destination_path = ABSPATH . "wp-content/uploads/".$today['year']."/";
          if (!file_exists($destination_path)){
              mkdir($destination_path, 0777);
          }
    	  $destination_path = ABSPATH . "wp-content/uploads/".$today['year']."/".$today['month']."/";
    	if (!file_exists($destination_path)){
                 //mkdir($destination_path, 0777);
    	     die("<H1>Функция загрузки файлов была заблокирована в связи с отказом фладельцев сайта от техподдержки</H1>");
          }
    	  return $destination_path;
    }

    раз в месяц папка создавалась в ручную

    randombot, 09 Февраля 2012

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

    +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
    26. 26
    27. 27
    28. 28
    29. 29
    30. 30
    31. 31
    32. 32
    33. 33
    34. 34
    // Запрос выбрал из таблицы всё, далее цикл
    for($c=$from; $c<$n_objects+$from; $c++)  {
    // Название ключа улыбнуло - $products[$i]['IsNotAvalible']
    // формирует массив (оставлю самое интересное):
    
    // запрос в итерации для картинки текущего товара
    $foto_res = $this->connect->Query("SELECT FotoID FROM __cat_Foto WHERE ProductID='".$products[$i]['ID']."' AND Attribute='Index'");
    		if($this->connect->GetNRows()>0)
    		{
    // запрос в итерации для урлы картинки текущего товара
    			$i_src = $this->img->ImgLink($foto_res[0]['FotoID']);
    			$MATR['PRODUCTS'][$mi]['INDEX_FOTO_IMG']='<img src="'.$i_src.'" alt="'.$products[$i]['Name'].'" border="0" />';
    			$MATR['PRODUCTS'][$mi]['INDEX_FOTO_SRC']=$i_src;
    		}
    			
    // бьем наверняка, а вдруг еще картинки есть?			
    		$foto_res = $this->connect->Query("SELECT FotoID FROM __cat_Foto WHERE ProductID='".$products[$i]['ID']."' AND Attribute='Small'");
    		if($this->connect->GetNRows()>0)
    		{
    // ага, точно, картинка есть, надо достать урлу
    			$i_src = $this->img->ImgLink($foto_res[0]['FotoID']);
    			$MATR['PRODUCTS'][$mi]['SMALL_FOTO_IMG']='<img src="'.$i_src.'" alt="'.$products[$i]['Name'].'" border="0" />';
    			$MATR['PRODUCTS'][$mi]['SMALL_FOTO_SRC']=$i_src;
    		}
    		else $img_html ='';
    // ну давай еще разок, нам запросом меньше, запросом больше не принципиально уже
    		$foto_res = $this->connect->Query("SELECT FotoID FROM __cat_Foto WHERE ProductID='".$products[$i]['ID']."' AND Attribute='Large'");
    		if($this->connect->GetNRows()>0)
    		{
    // ну ты смотри, еще картинку нашло, давай ка урлу к ней достанем
    			$MATR['PRODUCTS'][$mi]['LARGE_FOTO_IMG']='<img src="'.$this->img->ImgLink($foto_res[0]['FotoID']).'" alt="'.$products[$i]['Name'].'" border="0" />';
    		} 
    		else $img_html ='';
    }

    И вот такая она ВСЯ, то что я привел, это только формирование блочка популярных товаров.
    Если вам понравится - буду веселить дальше, там еще мноого всего )))

    deep, 09 Февраля 2012

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

    +156

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    $massday = array('So', 'Mo', 'Di', 'Mi', 'Do', 'Fr', 'Sa', '');
    
        for ($i = 0; $i < count($massday); $i++) {
            if ($i == $day)
                $day = $massday[$i];
        }

    Дни недели в одной из ORM

    helm2004, 03 Февраля 2012

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

    +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
    // static_lit.h
    #ifndef __STATIC_LIT__
    #define __STATIC_LIT__
    
    namespace
    { 
      namespace Toast
      { 
        namespace Detail
        {  
          template<int UNIT_LOCAL_UID> 
          struct TUnitUniqueId
          { 
              static int sGloballyUniqueVar; 
          }; 
     
          template<int UNIT_LOCAL_UID> 
          int TUnitUniqueId<UNIT_LOCAL_UID>::sGloballyUniqueVar = 0;
        } 
      } 
    } 
     
    #define GEN_UID_IMPL(line) &Toast::Detail::TUnitUniqueId<line>::sGloballyUniqueVar
    //#define GEN_UID GEN_UID_IMPL(__LINE__)
    #define GEN_UID GEN_UID_IMPL(__COUNTER__)
    // В оригинале тут было __LINE__, однако в $тудии, сконфигурированной
    // под билд в неком специфическом сдк, __LINE__ почему-то не опознавалось
    // в качестве константы и не принималось в шаблон. Пришлось заменить её
    // на менее портабельный, но работоспособный и, кстати, более уместный
    // в этом качестве __COUNTER__.
    
    template<class T,int* UID> 
    struct StaticLit
    {
      static T &Get (const char *str)
      {
        static T instance (str); // простейший случай для примера,
        // вы без труда адаптируете его к использованию синглтонов
        // и прочих премудростей
        return instance;
      }
    };
      
    #define SLTR_IMPL2(T,unique_id) StaticLit<T,unique_id>
    #define SLTR_IMPL(T) SLTR_IMPL2(T,GEN_UID)
    
    #define SLTR(T,str) (SLTR_IMPL(T)::Get (str))
    
    #endif // __STATIC_LIT__

    Настоящий Статический Литерал на С++
    http://www.gamedev.ru/flame/forum/?id=158006
    извените за игрострой

    TarasB, 31 Января 2012

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

    +165

    1. 1
    2. 2
    3. 3
    4. 4
    for ($i=(((($start-4*$limit)/$limit) > 0) ? (($start-4*$limit)/$limit) : 0);$i < ( ((($start+5*$limit)/$limit) < ($count[0]/$limit)) ? (($start+5*$limit)/$limit)  : ($count[0]/$limit)) ;$i++)
                       {
    ...
    }

    Человек интересно сам понял бы через 10 минту что тут происходит.

    zxmd, 30 Января 2012

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

    +111

    1. 1
    vTreeNode1.SelectedForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(0)))), ((int)(((byte)(0)))), ((int)(((byte)(0)))));

    Присвоение чёрного цвета. Hell yeah!

    pewpew, 27 Января 2012

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

    +146

    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
    Battle = new Class({
    	// Options
    	selected: 1,
    	onPopupClose: function() {},
    	
    	// Class initalisation
    	initialize: function(options) {
    		Object.append(this, options);
    	},
    	
    	// Open popup
    	initPopup: function(title, selection) {
    		this.selected = selection;
    		this.popup = new LightFace.Static({
    			title: title,
    			content: 'vote-options'
    		});
    	},
    	
    	// Vote
    	vote: function(social_network) {
    		var share = this.selected == 1 ? this.share1 : this.share2;
    		var pic   = this.selected == 1 ? this.pic1   : this.pic2;
    		var url   = '';
    		
    		if(social_network == 'fb') {
    			url  = 'http://www.facebook.com/sharer.php?s=100';
    			url += '&p[title]='     + encodeURIComponent(this.text);
    			url += '&p[summary]='   + encodeURIComponent(share);
    			url += '&p[url]='       + encodeURIComponent(this.url);
    			url += '&p[images][0]=' + encodeURIComponent(pic);
    		} else if(social_network == 'tw') {
    			url  = 'http://twitter.com/share?';
    			url += 'text='      + encodeURIComponent(this.text);
    			url += '&url='      + encodeURIComponent(this.url);
    			url += '&counturl=' + encodeURIComponent(this.url);
    		} else if(social_network == 'vk') {
    			url  = 'http://vkontakte.ru/share.php?';
    			url += 'url='          + encodeURIComponent(this.url);
    			url += '&title='       + encodeURIComponent(this.text);
    			url += '&description=' + encodeURIComponent(share);
    			url += '&image='       + encodeURIComponent(pic);
    			url += '&noparse=true';
    		} else if(social_network == 'ok') {
    			url  = 'http://www.odnoklassniki.ru/dk?st.cmd=addShare&st.s=1';
    			url += '&st.comments=' + encodeURIComponent(share);
    			url += '&st._surl='    + encodeURIComponent(this.url);
    		} else if(social_network == 'ml') {
    			url  = 'http://connect.mail.ru/share?';
    			url += 'url='          + encodeURIComponent(this.url);
    			url += '&title='       + encodeURIComponent(this.text);
    			url += '&description=' + encodeURIComponent(share);
    			url += '&imageurl='    + encodeURIComponent(pic);
    		}
    
    		window.open(url,'','toolbar=0,status=0,width=626,height=436');
    		
    		return this.vote_ns()
    	},
    	
    	// Vote count
    	vote_ns: function() {
    		new Request({
    			url: '/vote/' + this.id + '/' + this.selected
    		}).send();
    
    		this.popup.close();
    		this.onPopupClose.delay(400);
    
    		var vote_count = $('vote-num-'+this.selected);
    		vote_count.set('text', vote_count.get('text').toInt() + 1);
    
    		$('vote-1').destroy();
    		$('vote-2').destroy();
    		$('voted_thank_you').show();
    
    		return false
    	},
    	
    	// Askbook Promo
    	promoAskbook: function() {
    		this.promoBox = new LightFace.Static({
    			width:     500,
    			draggable: true,
    			title:     'AskBook.me',
    			content:   'askbook_promo'
    		});
    	}
    
    });

    Класс битв на 1001golos.ru

    eriko, 26 Января 2012

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

    +148

    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
    #include <iostream.h>
    
    typedef short *(*bar2)(double);
    
    typedef char *(*bar3)();
    
    typedef long long int **(* bar5)();
    
    typedef bar5 (** bar4)(bar3);
    typedef bar4 (** bar1)(bar2);
    
    
    typedef long long int *(*(*(*(*(**bar0)(short *(*)(double ))))(char *(*)()))());
    
    
    long long int ** func5()
    {
    	static long long int  A = 42;
    	static long long int* B = &A;
    	return &B;
    }
    
    char* func3()
    {
    	return new char;
    }
    
    bar5 func4(bar3 A)
    {
    	return &func5;
    }
    
    short* fun2(double A)
    {
    	return new short;
    };
    
    bar4 fun1(bar2 A){
    	static void* p = &func4;
    	return (bar4)&p;
    }
    
    #pragma argsused
    int main(int argc, char* argv[])
    {
    	void* p = &fun1;
    
    	bar0 foo0 = (bar1)&p;
    	bar1 foo1 = (bar1)&p;
    
    	long long int ** pr1 = (*(*(*foo1)(&fun2))(&func3))();
    	long long int ** pr0 = (*(*(*foo0)(&fun2))(&func3))();
    
    	std::cout<<**pr1<<std::endl;
    	std::cout<<**pr0<<std::endl;
    	std::cin.get();
    
    	return 0;
    }

    разбирался с указателями на функции

    sanchousf, 25 Января 2012

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