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

    +173

    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
    $z="select team,r1,ochko from gametable order by pos ";$q=mysql_query($z); //присваиваю переменной данные из таблтцы
    $i=0;
    while($inf=mysql_fetch_array($q,MYSQL_ASSOC)){
    $i++;
    if($inf['team']=="ManchesterUnited"){$inf['team']="<b>ManchesterUnited</b>";
    }
    
    $row=array("class=\"row-2\"","class=\"row-3\"","class=\"row-4\"","class=\"row-5\"","class=\"row-6\"","class=\"row-1\"");//массив из стилей
    if ($i==1) {echo "$row[0]";};
    elseif($i==2) {echo "$row[1]";}
    elseif($i==3) {echo "$row[2]";}
    elseif($i==4) {echo "$row[3]";}
    elseif($i==5) {echo "$row[3]";}
    elseif($i==6) {echo "$row[4]";}
    elseif($i==7,12){echo "$row[5]";}
    else {$row="class=\"row-2\"";}
    
    echo"
     <tr $row>// вставка стиля
    <td class=\"column-1\">$i </td>
       <td class=\"column-2\">$inf[team]</td>
       <td class=\"column-3\">$inf[r1]</td>
       <td class=\"column-3\">$inf[ochko]</td>
                <td class=\"column-3\"></td>        
           <td class=\"column-3\"></td>
           <td class=\"column-4\"></td>
           <td class=\"column-3\"></td>
    </tr>";
    }

    Свежачок!
    Я насчитал 9 какашек, а вы?

    Uchkuma, 01 Ноября 2010

    Комментарии (15)
  2. Си / Говнокод #4500

    +105

    1. 1
    2. 2
    3. 3
    int run_zero[] = {0xfffffffe,0xfffffffd,0xfffffffb,0xfffffff7,0xffffffef,0xffffffdf,0xffffffbf,0xffffff7f,0xfffffeff,0xfffffdff,0xfffffbff,0xfffff7ff,0xfffefff,0xffffdfff,0xffffbfff,0xffff7fff,0xfffeffff,0xfffdffff,0xfffbffff,0xfff7ffff,0xffeffff,0xffdfffff,0xffbfffff,0xff7fffff,0xfeffffff,0xfdffffff,0xfbffffff,0xf7ffffff,0xefffffff,0xdfffffff,0xbfffffff,0x7fffffff};
    int run_one[] = {0x1,0x2,0x4,0x8,0x10,0x20,0x40,0x80,0x100,0x200,0x400,0x800,0x1000,0x2000,0x4000,0x8000,0x10000,0x20000,0x40000,0x80000,0x100000,0x200000,0x400000,0x800000,0x1000000,0x2000000,0x4000000,0x8000000,0x10000000,0x20000000,0x40000000,0x80000000};
    int chess_code[] = {0xa5,0x5a};

    Первые строки теста регистров некоего контроллера. Хорошо, что регистры не 64-разрядные, а то задолбался бы паренёк. А уж про chess_code вообще молчу. Вот так суровые российские программеры, не боящиеся лишней работы, тестируют авиационное бортовое оборудование.

    whiskey, 01 Ноября 2010

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

    +145

    1. 1
    2. 2
    class Partner extends SqlQuery {
    ...

    Партнер - это тот, кто привел юзера. Т.е. по факту, другой юзер.

    ReallyBugMeNot, 01 Ноября 2010

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

    +166

    1. 1
    echo $tpl->ParseTemplate2('client_pardon', $client_pardon,  $CFG['root']['template_basket']);

    Самописный интернет-магазин, кусок кода "если обломилось создание заказа".

    ReallyBugMeNot, 01 Ноября 2010

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

    +161

    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
    // Функция отметки входящих сообщений как прочитанных
    	function CheckReadPM() {	
    		global $user, $site, $db;
    		$pm_ids = SafeDB($_POST['mod'], 11, int);
    		$where = '(`id` = '.$pm_ids[0];
    		$i = 1;
    		while($i < count($pm_ids)) {
    			$where .= ' or `id` = '.$pm_ids[$i];	
    			$i++;	
    		}
    		$where .= ") and `to` = ".$user->Get('u_id')." and `black` = 0";
    		$db->Update('private', "`read` = 1", $where);	
    	}

    Мартин, 31 Октября 2010

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

    +168

    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
    <?php
    Class Draw
    {
    // вырисовка графика баланса
    	function Graph($y1,$y2,$y3,$y4,$y5,$y6,$y7,$firstday) {
    		header ("Content-type: image/png");
    		$im = imagecreatefrompng("graph.png");
    		$text_color = imagecolorallocate($im, 233, 14, 91);
    		$color = imagecolorallocate($im, 0, 0, 0);
    		$bg = imagecolorallocate($im, 180, 180, 200);
    		#--------------------------------------------------------
    		imagefill ($im, 0, 0, $bg);
    		#---------------------------------------------------------
    		imageline($im, 50, 0, 1000, 0, $color);
    // в это же духе еще ~10 строк
    		imageline($im, 50, 900, 1000, 900, $color);
    		#---------------------------------------------------------
    		imageline($im, 100, 950, 100, 0, $color);
    // аналогично
    		imageline($im, 700, 950, 700, 0, $color);
    		#---------------------------------------------------------
    		imageline($im, 100, 1000-$y1, 200, 1000-$y2, $text_color);
    		imagefilledellipse ($im, 100, 1000-$y1, 10, 10, $color);
    		imagestring($im, 3, 115, 1000-$y1, $y1 . " RUB", $text_color);
    		imagestring($im, 5, 90, 960, $firstday, $text_color);
    		#-----------------------------------------------------------
    		imageline($im, 200, 1000-$y2, 300, 1000-$y3, $text_color);
    		imagefilledellipse ($im, 200, 1000-$y2, 10, 10, $color);
    		imagestring($im, 3, 215, 1000-$y2, $y2 . " RUB", $text_color);
    		imagestring($im, 5, 190, 960, $firstday+1, $text_color);
    		#-------------------------------------------------------------
    		imageline($im, 300, 1000-$y3, 400, 1000-$y4, $text_color);
    		imagefilledellipse ($im, 300, 1000-$y3, 10, 10, $color);
    		imagestring($im, 3, 315, 1000-$y3, $y3 . " RUB", $text_color);
    		imagestring($im, 5, 290, 960, $firstday+2, $text_color);
    		#------------------------------------------------------------
    		imageline($im, 400, 1000-$y4, 500, 1000-$y5, $text_color);
    		imagefilledellipse ($im, 400, 1000-$y4, 10, 10, $color);
    		imagestring($im, 3, 415, 1000-$y4, $y4 . " RUB", $text_color);
    		imagestring($im, 5, 390, 960, $firstday+3, $text_color);
    		#-----------------------------------------------------------
    		imageline($im, 500, 1000-$y5, 600, 1000-$y6, $text_color);
    		imagefilledellipse ($im, 500, 1000-$y5, 10, 10, $color);
    		imagestring($im, 3, 515, 1000-$y5, $y5 . " RUB", $text_color);
    		imagestring($im, 5, 490, 960, $firstday+4, $text_color);
    		#------------------------------------------------------------
    		imageline($im, 600, 1000-$y6, 700, 1000-$y7, $text_color);
    		imagefilledellipse ($im, 600, 1000-$y6, 10, 10, $color);
    		imagestring($im, 3, 615, 1000-$y6, $y6 . " RUB", $text_color);
    		imagestring($im, 5, 590, 960, $firstday+5, $text_color);
    		#------------------------------------------------------------
    		imagefilledellipse ($im, 700, 1000-$y7, 10, 10, $color);
    		imagestring($im, 3, 715, 1000-$y7, $y7 . " RUB", $text_color);
    		imagestring($im, 5, 690, 960, $firstday+6, $text_color);
    		#---------------------------------------------------------
    		imagestring($im, 5, 0, 900, 100, $text_color);
    		imagestring($im, 5, 0, 800, 200, $text_color);
    		imagestring($im, 5, 0, 700, 300, $text_color);
    		imagestring($im, 5, 0, 600, 400, $text_color);
    		imagestring($im, 5, 0, 500, 500, $text_color);
    		imagestring($im, 5, 0, 400, 600, $text_color);
    		imagestring($im, 5, 0, 300, 700, $text_color);
    		imagestring($im, 5, 0, 200, 800, $text_color);
    		imagestring($im, 5, 0, 100, 900, $text_color);
    		imagestring($im, 5, 0, 0, 1000, $text_color);
    		#---------------------------------------------------------
    		imagepng($im);
    		imagedestroy($im);
    	}
    }
    ?>

    той же 3х летней давности.....комментарии излишни

    Steel2010, 31 Октября 2010

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

    +164

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    11. 11
    function CheckDBInsert($str)
    {
    $arr = array("INSERT","SELECT","UPDATE","DELETE","FLUSH","UNION","CONCAT","SET","GRANT","--",";","..","'","-","%","(",")");
    foreach ($arr as $v) {
    $pos = strpos($str, $v);
    if ($pos === false) {
    	} else {
    return "ОШИБКО";
    die();
    }
    }

    код мой 3-летней давности....я плакалЬ(но он работал!)

    Steel2010, 31 Октября 2010

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

    +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
    // Итак, определим класс Namer.
    class Namer {
       var $name;
       var $surname;
       function getName() { return $this->name; }
       function getSurname() { return $this->surname; }
    }
    
    
    
    // Как видим, интерфейсная часть полностью определена. Осталось реализовать два механизма обработки входной строки. Сделаем это мы в двух классах-наследниках SpaceNamer и CommaNamer.
    
    
    //// класс для обработки строки в формате "имя фамилия"
    class SpaceNamer extends Namer {
       function SpaceNamer($full_name) {
          $splitter_pos = strpos($full_name, ' '); // находим пробел
          $this->name = substr($full_name, 0, $splitter_pos); // все, что до пробела - это имя
          $this->surname = substr($full_name, $splitter_pos+1); // после пробела - фамилия
       }
    }
    
    //// класс для обработки строки в формате "фамилия,имя"
    class CommaNamer extends Namer {
       function CommaNamer($full_name) {
          $splitter_pos = strpos($full_name, ','); // находим запятую
          $this->name = substr($full_name, $splitter_pos+1); // все, что до запятой - это фамилия
          $this->surname = substr($full_name, 0, $splitter_pos); // после запятой - имя
       }
    }

    и интерфейсы не нужны!

    Morgan, 31 Октября 2010

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

    −83

    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
    Public Class Form1...
    
    Dim isClicked as Integer = false
    
    End class
    
    if isClicked = true then
    me.left = mouseposition.x - Me.width / 2
    me.top = mouseposition.y - me.height / 2
    end if
    
    if isClicked = false Then
    isClicked = true
    else
    isClicked = false
    end if...

    Код не мой... Но integer в виде false очень улыбнул ))) да собственно говоря и не только он )))

    psyhco1219, 31 Октября 2010

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

    +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
    #include "stdafx.h"
    #include <iostream>
    #include <locale>
    #include <conio.h>
    typedef unsigned short int g;
    int main()
    {
            g b=0;g m=1;
            std::wcout.imbue(std::locale(".866"));
            for(g i=0;m==1;i++)
            {
            try
            {
            std::wcout<<L"Введите столбец по которому надо сортировать(меньше 10)";
            std::cin>>b;m=0;
            }
            catch(...){m=1;}
            }
            return EXIT_SUCCESS;
    }

    http://www.cyberforum.ru/cpp/thread550.html
    "Здравствуйте! мне надо чтобы если юзер вводит неверные данные ему было предложено вновь ввести данные заново.Почему этого не происходит"

    OverOverMind, 31 Октября 2010

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