1. PHP / Говнокод #8225

    +165

    1. 1
    $idlink = rawurlencode(base64_encode($name . "||" . $email . "||" . md5( $password1 ) . "||" . $accountID_1 . "||" . $accountID_2 . "||" . $accountID_3 . "||" . $serverid_1 . "||" . $serverid_2 . "||" . $serverid_3 . "||" . md5( sha1( $name . $email . DBHOST . DBNAME . $config['key'] ) ) ) );

    Значит так, ребята. Готовьтесь воспринимать. Данные с регистрационной формы кодируются как только можно, потом с этим кодом генерируется ссылка и отправляется письмо с подтверждением регистрации. Когда новый пользователь переходит по ссылочке, данные берутся из базы, снова кодируются и сравниваются с кодом из ссылки.

    Пы.Сы. Код не мой

    kindofbear, 18 Октября 2011

    Комментарии (43)
  2. Pascal / Говнокод #8221

    +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
    program analize_methods;
    uses dos,crt;
    const amax=10000;
    type ar=array [1..amax] of integer;
    ar3=array [1..3] of ar;
    var a:ar3;b:^ar3;
    time:array [1..2,1..3] of real;
    hour,min,sec,sec100:word;
    r,r1,r2:real;
    ns,i,k:integer;
    f:text;
    
    {ЊҐв®¤ б®авЁа®ўЄЁ vyborom)}
    procedure vybor(var m:ar);
    var i,j,x,p:integer;
    begin
    for i:=1 to amax-1 do
    begin
    p:=i;
    x:=m[i];
    for j:=i+1 to amax do
    if x>m[j] then
    begin
    p:=j;
    x:=m[j];
    end;
    m[p]:=m[i];
    m[i]:=x;
    end;
    end;
    
    { б®авЁа®ўЄ  ўбв ўЄ®© }
    procedure Inser(var item:ar; count:integer);
    var
    i,x,j: integer;
    begin
    for i := 2 to count do
    begin
    x := item[i];
    j := i-1;
    while (x<item[j]) and (j>0) do
    begin
    item[j+1] := item[j];
    j := j-1;
    end;
    item[j+1] := x;
    end;
    end;  { Є®­Ґж б®авЁа®ўЄЁ ўбв ўЄ®© }

    Это человек на собеседовании написал. Задача была - реализовать асинхронный ввод в 1С

    alexoy, 17 Октября 2011

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

    +1007

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    template <typename T, typename U>
    auto operator()(T&& t, U&& u) const
    -> decltype(forward<T>(t) + forward<U>(u)) {
        return forward<T>(t) + forward<U>(u);
    }

    ohlol, 17 Октября 2011

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

    +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
    21. 21
    22. 22
    23. 23
    24. 24
    25. 25
    26. 26
    27. 27
    #include <iostream>
    #include <stdio.h>
    #include <fcntl.h>
    #include <string>
    #define print(data) cout<<data<<endl;
    #define ord(data) int(data[0])
    #define str(data) char(data)
    #define open fopen
    #define write(f, data) fputc(data, f)
    using namespace std;
    string input()
    {
            string s;
            cin>>s;
            return s;
    };
    FILE* f;
    int chr;
     
    int main() {
            print("Enter:");
            f = open("code.txt", "w");
            chr = ord(input());
            print(chr);
            write(f, str(chr));
            return 0;
    }

    Вот такую лабу сдал студент 1го курса в нашем вузе. Сказал преподавателю, что ему очень нравится питон и он старается ему подражать.
    http://ideone.com/ctkFP

    ohlol, 17 Октября 2011

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

    +968

    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
    private TList<ProductType> ProductTypeListTable
            {
                get
                {
                    ProductTypeService productTypeService = new ProductTypeService();
    
                    TList<ProductType> productTypes = productTypeService.GetAll();
                    foreach (ProductType pt in productTypes)
                    {
                        pt.Name = Server.HtmlDecode(pt.Name);
                    }
                    
                    return productTypes;
                }
            }

    Некая дорогущая АСП.НЕТ платформа. Ну и че там, будем читать базу, пока не надоест...

    MagisterCrazy, 17 Октября 2011

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

    +1007

    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
    void Image::CombineNoise(byte combineType, byte noiseType, cCol3D& maxcolor, Image* mask)
    {
    	byte *maskBf=0;
    	if(mask)
    	{
    		uint mask_pixels=mask->Width*mask->Height;
    		maskBf=(byte*)malloc(mask_pixels);
    		if(mask->Format!=ImageFormat_Luminance)
    		for(uint i=0, ic=0; i<mask_pixels; i++, ic+=mask->Components)
    			maskBf[i]=min((byte)255)((byte)(mask->Data[ic]*0.3f+mask->Data[ic+1]*0.59f+mask->Data[ic+2]*0.11f));
    		else memcpy(maskBf, mask->Data, mask_pixels);
    		if(mask->Width!=Width || mask->Height!=Height)
    		{
    			byte* maskBf2=ScaleImage(Width, Height, maskBf, mask->Width, mask->Height, 1);
    			free(maskBf);
    			maskBf=maskBf2;
    		}
    	}
    
    	uint pixels=Width*Height;
    	uint size=pixels*Components;
    	if(Data && Width>0 && Height>0)
    	{
    		if(noiseType==0 && Format!=ImageFormat_Luminance)	//Цветной шум
    		{
    			switch(combineType)
    			{
    			case 0:	//Модуляция
    				if(mask)
    				for(uint i=0, ic=0; ic<size; i++, ic+=Components)
    				{
    					if(maskBf[i]<=127) continue;
    					Data[ic]=min<byte>(Data[ic]*(rand()%maxcolor.r)/255)(255);
    					if(Components<2) continue;
    					Data[ic+1]=min<byte>(Data[ic+1]*(rand()%maxcolor.g)/255)(255);
    					if(Components<3) continue;
    					Data[ic+2]=min<byte>(Data[ic+2]*(rand()%maxcolor.b)/255)(255);
    				}
    				else
    				for(uint ic=0; ic<size; ic+=Components)
    				{
    					Data[ic]=min<byte>(Data[ic]*(rand()%maxcolor.r)/255)(255);
    					if(Components<2) continue;
    					Data[ic+1]=min<byte>(Data[ic+1]*(rand()%maxcolor.g)/255)(255);
    					if(Components<3) continue;
    					Data[ic+2]=min<byte>(Data[ic+2]*(rand()%maxcolor.b)/255)(255);
    				}
    				break;
    
    			case 1:	//Сложение
    				if(mask)
    				for(uint i=0, ic=0; ic<size; i++, ic+=Components)
    				{
    					float factor=maskBf[i]/255.0f;
    					Data[ic]=(byte)min(Data[ic]+(rand()%maxcolor.r*factor))(255);
    					if(Components<2) continue;
    					Data[ic+1]=(byte)min(Data[ic+1]+(rand()%maxcolor.g*factor))(255);
    					if(Components<3) continue;
    					Data[ic+2]=(byte)min(Data[ic+2]+(rand()%maxcolor.b*factor))(255);
    				}
    				else
    				for(uint ic=0; ic<size; ic+=Components)
    				{
    					Data[ic]=min<byte>(Data[ic]+(maxcolor.r>0? rand()%maxcolor.r: 0))(255);
    					Data[ic+1]=min<byte>(Data[ic+1]+(maxcolor.g>0? rand()%maxcolor.g: 0))(255);
    					Data[ic+2]=min<byte>(Data[ic+2]+(maxcolor.b>0? rand()%maxcolor.b: 0))(255);
    				}
    				break;
    
    			case 2:	//Вычитание
    				if(mask)
    				for(uint i=0, ic=0; ic<size; i++, ic+=Components)
    				{
    					float factor=maskBf[i]/255.0f;
    					Data[ic]=(byte)max(Data[ic]-(rand()%maxcolor.r*factor))(0);
    					if(Components<2) continue;
    					Data[ic+1]=(byte)max(Data[i+1]-(rand()%maxcolor.g*factor))(0);
    					if(Components<3) continue;
    					Data[ic+2]=(byte)max(Data[i+2]-(rand()%maxcolor.b*factor))(0);
    				}
    				else
    				for(uint ic=0; ic<size; ic+=Components)
    				{
    					Data[ic]=max<byte>(Data[ic]-rand()%maxcolor.r)(0);
    					if(Components<2) continue;
    					Data[ic+1]=max<byte>(Data[ic+1]-rand()%maxcolor.g)(0);
    					if(Components<3) continue;
    					Data[ic+2]=max<byte>(Data[ic+2]-rand()%maxcolor.b)(0);
    				}
    				break;
    				
    			case 3:	//Средний цвет
    //На говнокод не лезет больше. Такая гигантская функция.

    Одна из функций для генерации изображений. Решил не рефакторить, потому что всё равно всё буду переделывать.

    gammaker, 17 Октября 2011

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

    −115

    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
    SELECT product.entity_id as pid, 
           vTitle.value as title, vLength.value as length, vWidth.value as width, vHeight.value as height, vWeight.value as weight, vCapacity.value as capacity, vImg.value as img,
           tShort.value as short, tText.value as text,
           dPrice.value as price,
           cParent.category_id as parent
    FROM catalog_product_entity as product
    LEFT JOIN catalog_product_entity_varchar as vTitle ON vTitle.entity_id=product.entity_id AND vTitle.attribute_id=60
    LEFT JOIN catalog_product_entity_varchar as vLength ON vLength.entity_id=product.entity_id AND vLength.attribute_id=122
    LEFT JOIN catalog_product_entity_varchar as vWidth ON vWidth.entity_id=product.entity_id AND vWidth.attribute_id=123
    LEFT JOIN catalog_product_entity_varchar as vHeight ON vHeight.entity_id=product.entity_id AND vHeight.attribute_id=124
    LEFT JOIN catalog_product_entity_varchar as vWeight ON vWeight.entity_id=product.entity_id AND vWeight.attribute_id=69
    LEFT JOIN catalog_product_entity_varchar as vCapacity ON vCapacity.entity_id=product.entity_id AND vCapacity.attribute_id=125
    LEFT JOIN catalog_product_entity_varchar as vImg ON vImg.entity_id=product.entity_id AND vImg.attribute_id=74
    LEFT JOIN catalog_product_entity_text as tShort ON tShort.entity_id=product.entity_id AND tShort.attribute_id=62
    LEFT JOIN catalog_product_entity_text as tText ON tText.entity_id=product.entity_id AND tText.attribute_id=61
    LEFT JOIN catalog_product_entity_decimal as dPrice ON dPrice.entity_id=product.entity_id AND dPrice.attribute_id=64
    LEFT JOIN (SELECT c.category_id, c.product_id FROM catalog_category_product as c ORDER BY c.category_id DESC) as cParent ON cParent.product_id=product.entity_id
    GROUP BY cParent.product_id ORDER BY cParent.product_id

    Мой говнокод-неговнокод по экспорту товара из Magento в нашу CMS

    Android991, 17 Октября 2011

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

    −147

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    7. 7
    8. 8
    {if $oUserProfile->getProfileIcq()}
    	<strong>{$aLang.profile_social_contacts}</strong>
    	<ul>
    	{if $oUserProfile->getProfileIcq()}
    		<li class="icq"><a href="http://www.icq.com/people/about_me.php?uin={$oUserProfile->getProfileIcq()|escape:'html'}" target="_blank">{$oUserProfile->getProfileIcq()}</a></li>
    	{/if}					
    	</ul>
    {/if}

    Smarty-шаблон. ActionProfile/sidebar.tpl (17-я строчка в скине "new") из LiveStreet.
    Озадачивают 1-я и 4-я строки. Типа: "А вдруг?!"

    alexoy, 17 Октября 2011

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

    +103

    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
    procedure tform1.cek_setting;
    begin
     { RUTIN CEK FILE CONFIG }
      { Cek File Buzz.cfg }
     status := '';
     ceklagu('C:\Windows\buzz.cfg');
     status := cek_lagu;
     if status = 'sukses' then
     begin
      listbox2.Items.LoadFromFile('C:\Windows\buzz.cfg');
      load_setting;
      save_setting;
     end else
     begin
      default_setting;
      load_setting;
      save_setting;
     end;
      { Cek File Buzz.dat }
     status := '';
     ceklagu('C:\Windows\buzz.dat');
     status := cek_lagu;
     if status = 'sukses' then
     begin
      listbox3.Items.LoadFromFile('C:\Windows\buzz.dat');
      convert_files;
     end else
      listbox3.Items.SaveToFile('c:\Windows\buzz.dat');
     { Cek File Buzz.sld }
     status := '';
     ceklagu('C:\Windows\buzz.sld');
     status := cek_lagu;
     if status = 'sukses' then
     begin
      listbox4.Items.LoadFromFile('C:\Windows\buzz.sld');
     end else
      listbox4.Items.SaveToFile('C:\Windows\buzz.sld');
    end;

    https://github.com/achri/Buzzwave/blob/master/Unit1.pas
    Там такого завались, achriнеть можно.

    d_dev, 17 Октября 2011

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

    +165

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    11. 11
    if($this->getAmount()){
    	$pos = strpos($this->getAmount(), '.');
    	if($pos === false )
    	{
    		$request->amount = $this->getAmount().'00';
    	}
    	else
    	{
    		$request->amount = str_replace('.','',$this->getAmount());
    	}
    }

    Magento extension: Cignex/Paymenttechchase
    Преобразование прайса в центы.
    Если цена заканчивается нулем, например 12.50 на выходе будет 125, а не 1250

    vesan, 17 Октября 2011

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