1. Pascal / Говнокод #3864

    +98

    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
    procedure TfmAllParams.NInsertParamSelebrationClick(Sender: TObject);
    var
      str: string;
    begin
      str := //Новый год
        ' if not exists (select id from sta_param_selebration ' +
        '            where date_selebration=' + #39 + '01.01.' + IntToStr(YearOf(GetServerDate)) + #39 + ')' +
        ' insert into sta_param_selebration (selebration_day, selebration_month ,selebration_state,text_selebration,selebration_year)' +
        ' values(1,1,null,null,null) ' +
            //День св. Валентина
      ' if not exists (select id from sta_param_selebration ' +
        '            where date_selebration=' + #39 + '14.02.' + IntToStr(YearOf(GetServerDate)) + #39 + ')' +
        ' insert into sta_param_selebration (selebration_day, selebration_month ,selebration_state,text_selebration,selebration_year)' +
        ' values(14,2,null,null,null) ' +
            //8 марта
      ' if not exists (select id from sta_param_selebration ' +
        '            where date_selebration=' + #39 + '08.03.' + IntToStr(YearOf(GetServerDate)) + #39 + ')' +
        ' insert into sta_param_selebration (selebration_day, selebration_month ,selebration_state,text_selebration,selebration_year)' +
        ' values(8,3,' + #39 + 'жін.' + #39 + ',null,null) ' +
            //1 мая
      ' if not exists (select id from sta_param_selebration ' +
        '            where date_selebration=' + #39 + '01.05.' + IntToStr(YearOf(GetServerDate)) + #39 + ')' +
        ' insert into sta_param_selebration (selebration_day, selebration_month ,selebration_state,text_selebration,selebration_year)' +
        ' values(1,5,null,null,null) ' +
            //Пасха
      ' if not exists (select id from sta_param_selebration ' +
        '            where date_selebration=' + #39 + '04.04.2010' + #39 + ' and text_selebration=' + #39 + 'Pasha' + #39 + ')' +
        ' insert into sta_param_selebration (selebration_day, selebration_month ,text_selebration,selebration_year)' +
        ' values(4,4,' + #39 + 'Pasha' + #39 + ',2010) ' +
    
      ' if not exists (select id from sta_param_selebration ' +
        '            where date_selebration=' + #39 + '24.04.2011' + #39 + ' and text_selebration=' + #39 + 'Pasha' + #39 + ')' +
        ' insert into sta_param_selebration (selebration_day, selebration_month ,text_selebration,selebration_year)' +
        ' values(24,4,' + #39 + 'Pasha' + #39 + ',2011) ' +
    
       // И 10 таких же запросов на каждый год!
    
      ' if not exists (select id from sta_param_selebration ' +
        '            where date_selebration=' + #39 + '24.04.2022' + #39 + ' and text_selebration=' + #39 + 'Pasha' + #39 + ')' +
        ' insert into sta_param_selebration (selebration_day, selebration_month ,text_selebration,selebration_year)' +
        ' values(24,4,' + #39 + 'Pasha' + #39 + ',2022) ' +

    stokito, 03 Августа 2010

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

    +144

    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
    if ($_FILES['file1']['tmp_name'])
    	{
    		if($_FILES['file1']['type'] == 'image/gif' or $_FILES['file1']['type'] == 'image/jpeg' or $_FILES['file1']['type'] == 'image/pjpeg' or	$_FILES['file1']['type'] == 'image/png')
    		{
    			if(move_uploaded_file($_FILES['file1']['tmp_name'], $upload_foto_new))
    			{
    				print 1;//good
    			}
    			else
    			{
    				print 2;//bad
    			}
    
    		}
    			else
    				print 3;//wrong format
    	}

    загрузка картинки

    Lure Of Chaos, 03 Августа 2010

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

    +144

    1. 1
    2. 2
    3. 3
    <?
    //тут был говнокод)
    ?>

    gerard, 03 Августа 2010

    Комментарии (4)
  4. JavaScript / Говнокод #3861

    +144

    1. 1
    $('.margin20').append(' ').append($('<button>Save</button>');

    jquery нам подарил много выдающихся личностей.

    вот так мы создаем кнопку. что за класс .margin20 можно догадаться из названия )

    Lure Of Chaos, 03 Августа 2010

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

    +166

    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
    function toup($str) {
    #перевод в верхний регистр (просто strtoupper не всегда корректно работает с русскими буквами)
    $str=strtoupper($str);
    $str=str_replace("а","А",$str);$str=str_replace("б","Б",$str);$str=str_replace("в","В",$str);
    $str=str_replace("г","Г",$str);$str=str_replace("д","Д",$str);$str=str_replace("е","Е",$str);
    $str=str_replace("ж","Ж",$str);$str=str_replace("з","З",$str);$str=str_replace("и","И",$str);$str=str_replace("й","Й",$str);
    $str=str_replace("к","К",$str);$str=str_replace("л","Л",$str);$str=str_replace("м","М",$str);
    $str=str_replace("н","Н",$str);$str=str_replace("о","О",$str);$str=str_replace("п","П",$str);
    $str=str_replace("р","Р",$str);$str=str_replace("с","С",$str);$str=str_replace("т","Т",$str);
    $str=str_replace("у","У",$str);$str=str_replace("ф","Ф",$str);$str=str_replace("х","Х",$str);
    $str=str_replace("ц","Ц",$str);$str=str_replace("ч","Ч",$str);$str=str_replace("ш","Ш",$str);
    $str=str_replace("щ","Щ",$str);$str=str_replace("ъ","Ъ",$str);$str=str_replace("ы","Ы",$str);
    $str=str_replace("ь","Ь",$str);$str=str_replace("э","Э",$str);$str=str_replace("ю","Ю",$str);
    $str=str_replace("я","Я",$str);
    return $str;}
    
    function tolower($str) {
    #перевод в нижний регистр (просто strtolower не всегда корректно работает с русскими буквами)
    $str=strtolower($str);
    $str=str_replace("А","а",$str);$str=str_replace("Б","б",$str);$str=str_replace("В","в",$str);
    $str=str_replace("Г","г",$str);$str=str_replace("Д","д",$str);$str=str_replace("Е","е",$str);
    $str=str_replace("Ж","ж",$str);$str=str_replace("З","з",$str);$str=str_replace("И","и",$str);$str=str_replace("Й","й",$str);
    $str=str_replace("К","к",$str);$str=str_replace("Л","л",$str);$str=str_replace("М","м",$str);
    $str=str_replace("Н","н",$str);$str=str_replace("О","о",$str);$str=str_replace("П","п",$str);
    $str=str_replace("Р","р",$str);$str=str_replace("С","с",$str);$str=str_replace("Т","т",$str);
    $str=str_replace("У","у",$str);$str=str_replace("Ф","ф",$str);$str=str_replace("Х","х",$str);
    $str=str_replace("Ц","ц",$str);$str=str_replace("Ч","ч",$str);$str=str_replace("Ш","ш",$str);
    $str=str_replace("Щ","щ",$str);$str=str_replace("Ъ","ъ",$str);$str=str_replace("Ы","ы",$str);
    $str=str_replace("Ь","ь",$str);$str=str_replace("Э","э",$str);$str=str_replace("Ю","ю",$str);
    $str=str_replace("Я","я",$str);
    return $str;}

    Еще 2 шикарные функции, того же автора, что и в предыдущем моем посте.
    про setlocale никто и не слыхивал.

    Mihard, 03 Августа 2010

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

    +164

    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
    if (strlen($str)>1 && substr($str,strlen($str)-2,1)=="1") {
            switch(substr($str,strlen($str)-1,1)) {
            case "0": $newstr="десять рублей";break;
            case "1": $newstr="одиннадцать рублей";break;
            case "2": $newstr="двенадцать рублей";break;
            case "3": $newstr="тринадцать рублей";break;
            case "4": $newstr="четырнадцать рублей";break;
            case "5": $newstr="пятнадцать рублей";break;
            case "6": $newstr="шестнадцать рублей";break;
            case "7": $newstr="семьнадцать рублей";break;
            case "8": $newstr="восемьнадцать рублей";break;
            case "9": $newstr="девятьнадцать рублей";break;}}
    else {
            switch(substr($str,strlen($str)-1,1)) {
            case "0": $newstr="рублей";break;
            case "1": $newstr="один рубль";break;
            case "2": $newstr="два рубля";break;
            case "3": $newstr="три рубля";break;
            case "4": $newstr="четыре рубля";break;
            case "5": $newstr="пять рублей";break;
    .......................................
            case "7": $newstr="семь миллионов ".$newstr;break;
            case "8": $newstr="восемь миллионов ".$newstr;break;
            case "9": $newstr="девять миллионов ".$newstr;break;}
        if (strlen($str)>7) {
            switch(substr($str,strlen($str)-8,1)) {
            case "2": $newstr="двадцать ".$newstr;break;
            case "3": $newstr="тридцать ".$newstr;break;
            case "4": $newstr="сорок ".$newstr;break;
            case "5": $newstr="пятьдесят ".$newstr;break;
            case "6": $newstr="шестьдесят ".$newstr;break;
            case "7": $newstr="семьдесят ".$newstr;break;
            case "8": $newstr="восемьдесят ".$newstr;break;
            case "9": $newstr="девяносто ".$newstr;break;}}}}
    if (strlen($str)>8) {
    switch(substr($str,strlen($str)-9,1)) {
    	case "0": $newstr="сто ".$newstr;break;
        case "1": $newstr="сто ".$newstr;break;
        case "2": $newstr="двести ".$newstr;break;
        case "3": $newstr="триста ".$newstr;break;
        case "4": $newstr="четыреста ".$newstr;break;
        case "5": $newstr="пятьсот ".$newstr;break;
        case "6": $newstr="шестьсот ".$newstr;break;
        case "7": $newstr="семьсот ".$newstr;break;
        case "8": $newstr="восемьсот ".$newstr;break;
        case "9": $newstr="девятьсот ".$newstr;break;}}

    Вот так делают "сумму прописью".
    Радует и форматирование, и порядок порядков чисел в if .. elseif .. else

    Mihard, 03 Августа 2010

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

    +156

    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
    int main() {
    	srand(time(NULL));
    	for (int k=1;k<=75;k++) {
    		char file_name[] = "input      ";
    		if (k<10) {file_name[5]='0'; file_name[6]=(k+'0'); } else
    		{
    			file_name[5]=(k/10+'0'); file_name[6]=(k%10+'0');
    		}
    		file_name[7]='.'; file_name[8]='t'; file_name[9]='x'; file_name[10]='t';
    		freopen(file_name,"wt",stdout);
    		n=rand()%500+1;
    		m=rand()%500+1;
    		cout << n << " " << m << endl;
    		for (i=0;i<n;i++) {
    			for (j=0;j<m;j++)
    				cout << rand()%10000000+1 << " ";
    			cout << endl;
    		}
    	}
    	return 0;
    }

    jfn, 03 Августа 2010

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

    −92

    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
    Вот так выкидывает исключение 
    (this._sliderGraphic as flash.display.DisplayObject).addEventListener(flash.events.MouseEvent.MOUSE_DOWN, function (arg1:flash.events.MouseEvent):*
                {
                    _holdPin();
                    return;
    			})
    (this._sliderGraphic as flash.display.DisplayObject).addEventListener(flash.events.MouseEvent.MOUSE_UP, function (arg1:flash.events.MouseEvent):*
                {
                    _releasePin();
                    return;
                })
    
    А вот так нет :)
                (this._sliderGraphic as flash.display.DisplayObject).addEventListener(flash.events.MouseEvent.MOUSE_DOWN, function (arg1:flash.events.MouseEvent):*
                {
                    _holdPin();
                    return;
    			})
                o=this._sliderGraphic as flash.display.DisplayObject;//добавленно мной
                (this._sliderGraphic as flash.display.DisplayObject).addEventListener(flash.events.MouseEvent.MOUSE_UP, function (arg1:flash.events.MouseEvent):*
                {
                    _releasePin();
                    return;
                })

    вот наткнулся в исходниках что мне досталось :)

    ageron, 03 Августа 2010

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

    +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
    function checkvar($array)
    {
    	$good=true;
    	for($i=0;$i<count($arr);$i++)
    	{
    		$array[$i]=stripslashes(strtolower(str_replace("\n", "<BR>", str_replace("\r", "\n", str_replace("\r\n", "\n", $arr[$i])))));
    		if(strlen($array[$i])===0) $good=false;
    	}
    	return $good;
    }
    ...
    $messagevars = array($_POST["var1"], $_POST["var2"], $_POST["var3"], $_POST["var4"], $_POST["var5"], $_POST["var6"], $_POST["var7"], $_POST["var8"], $_POST["var9"], $_POST["var10"], $_POST["var11"], $_POST["var12"], $_POST["var13"], $_POST["var14"], $_POST["var15"], $_POST["var16"], $_POST["var17"]);
    if(checkvar($messagevars)===true)
    {
    	file_put_contents(ROOT_DIR."/".$logname.".txt", $messagevars[0]."\n".$messagevars[1]."\n".$messagevars[2]."\n".$messagevars[3]."\n".$messagevars[4]."\n".$messagevars[5]."\n".$messagevars[6]."\n".$messagevars[7]."\n".$messagevars[8]."\n".$messagevars[9]."\n".$messagevars[10]."\n".$messagevars[11]."\n".$messagevars[12]."\n".$messagevars[13]."\n".$messagevars[14]."\n".$messagevars[15]."\n".$messagevars[16]);
    }

    Made in china?!

    XyHb, 02 Августа 2010

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

    +144

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    7. 7
    $true = true;
    function true(){
    while($true){
    if($true)
    return "true";
    }
    }

    ДЭМАНСТРАЦИ ГАВНАКОДА

    art543484, 02 Августа 2010

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