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

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

    +147

    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
    ZeuS
    do
      {
        /*
          Тупые, притупые идусы из MS, не понимают что они тупые притупые. Дело в том, что в MSDN
          написано, что NetUserEnum может работать с уровнями 4, 23, а на практики мы получаем 
          большой индуский ХУЙ!
        */
    
        DWORD readed;
        DWORD total;
        USER_INFO_0 *buf0 = NULL;
        status = CWA(netapi32, NetUserEnum)(NULL, 0, FILTER_NORMAL_ACCOUNT, (LPBYTE *)&buf0, MAX_PREFERRED_LENGTH, &readed, &total, &handle);
    /////////////////////////////////////
    //Непонятно, может ли оно вернуть NULL. Помня фокус индусов с wsprintf, защитимся от этого.
      if(p == NULL)p = path; 
    //////////////////////////////////
    if(iSize == -1)
      {
        //Гении-индусы решили подмениь возрашаемое значение в Vista на -1, в случаи если не хватает
        //места на всю строку, однако буфер заполняется. Ума устаналивать LastError не хватило...
        iSize = _LengthW(pBuf);
      }
      else pBuf[iSize] = 0;
    ///////////////////////////////////
    //Я ибал в рот тупых уродов написавших тупой rfc и тупорлых говнокодеров,
            //Я ставлю листинг на проивзольны порт на все IP сервера, и пашел на хуй софт который не
            //сможет это прочитать. Возможно меня ввел в забулждение FlashFXP 3.6.0. Т.к. в destAddr
            //он отправляет какие то данные сервера. А по rfc, как я понел, там должны быть данные
            //сокс-сервера, где нужно ждать сединения.
            
            //Ищим свободный порт.
            ((SOCKADDR_IN6 *)destAddr)->sin6_port = 0;

    23525f567a2b456a, 12 Мая 2011

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

    +165

    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
    $nw = mysql_query("SELECT * FROM `news`");
      while ($news=mysql_fetch_array($nw))
      {
        $c1++;
      }
      $nw = mysql_query("SELECT * FROM `post`");
      while ($news=mysql_fetch_array($nw))
      {
        $c2++;
      }
      $nw = mysql_query("SELECT * FROM `ppost`");
      while ($news=mysql_fetch_array($nw))
      {
        $c3++;
      }
      $i=$c1+$c2+$c3;

    Обнаружено в мега CMS имени неизвестного разработчика

    Punk_UnDeaD, 10 Мая 2011

    Комментарии (17)
  4. Python / Говнокод #6610

    −180

    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
    #обработка формы
    if request.method == 'POST':
        form = MdatForm(request.POST)
        #проверка правильности заполнения полей формы
        if form.is_valid():
                cd = form.cleaned_data
                #переменные для проверки правильности ввода данных
                valid1 = cd['sername']+cd['name']+cd['ssername']
                valid2 = cd['get']+cd['born']+cd['adres']
                #проверка ФИО
                for i in valid1:
                    if (re.match(u"^[A-Za-z0-9]+$", i))or(i in errorfio):
                        return redirect_with_message(request, 'error', 'Корректно введите ФИО', reverse(changemet))
                #проверка адрес, дата роэждения, кем выдано
                for i in valid2:
                    if (re.match(u"^[A-Za-z]+$", i))or(i in errorvmb):
                        return redirect_with_message(request, 'error', 'Корректно введите "Место рождения", "Адрес", "Кем выдан"', reverse(changemet))
                #сохранить изменения
                changemetadd(cd, request.user)
                #запись действия в журнал
                userlogpath(request.user, 'Осуществлено редактирование метаданных')
                #вывод сообщения
                return redirect_with_message(request, 'success', 'Данные были сохранены в системе регистрации изображений', reverse('home.views.index'))
    
    
    #форма первичной регистрации
    class PhForms(forms.Form):
            email = forms.EmailField(label='Email*', error_messages={'required': 'Заполните поле'})
            sername = forms.CharField(max_length=50, label='Фамилия*', error_messages={'required': 'Заполните поле'})
            name = forms.CharField(max_length=50, label='Имя*', error_messages={'required': 'Заполните поле'})
            ssername = forms.CharField(max_length=40, label='Отчество', required=False)
            databorn = forms.DateField(label='Дата рождения:', widget=SelectDateWidget(years=range(year, year-101, -1)), required=False)#forms.DateField(label='Дата рождения:*',initial=datetime.date.today, input_formats=('%d-%m-%Y',),
    		#widget=SelectDateWidget(input_format='%d-%B-%Y', years=range(year, year-101, -1)))
            pasportserial = forms.IntegerField(max_value=9999, label='Паспорт серия', required=False)
            pasportnomer = forms.IntegerField(max_value=999999, label='Паспорт номер', required=False)
            get = forms.CharField(max_length=100, label='Кем выдан*', required=False)
            dataget = forms.DateField(label='Дата выдачи:', widget=SelectDateWidget(years=range(year, year-101, -1)), required=False)#forms.DateField(label='Дата выдачи*:', initial=datetime.date.today, input_formats=('%d-%m-%Y',),
    		#widget=SelectDateWidget(input_format='%d-%B-%Y', years=range(year, year-101, -1)))
            born = forms.CharField(max_length=200, label='Место рождения*', required=False)
            adres = forms.CharField(max_length=200, label='Адрес*', required=False)
    	#text = forms.CharField(label='Семейное положение', max_length=200)
    
    
    #изображения и мииатюры
    class Image(models.Model):
        user = models.ForeignKey('User')
        publication_date = models.DateTimeField(auto_now_add=True)
        nomersertifikata = models.IntegerField()
        imgname = models.CharField(max_length=200)
        tip_foto = models.ForeignKey('img_subj.ImageSubjects')
        public = models.BooleanField()
        img = models.ImageField(upload_to=get_upload_to)
        mini_img = models.ImageField(upload_to=mini_get_upload_to)
        #создание миниатюры
        def save(self):
            THUMBNAIL_SIZE = (100, 100)
            image = PIL.Image.open(self.img)
            if image.mode not in ('L', 'RGB'):
                image = image.convert('RGB')
            image.thumbnail(THUMBNAIL_SIZE, PIL.Image.ANTIALIAS)
    
            temp_handle = StringIO()
            image.save(temp_handle, 'png')
            temp_handle.seek(0)
    
            suf = SimpleUploadedFile(os.path.split(self.img.name)[-1],
            temp_handle.read(), content_type='image/png')
            self.mini_img.save(suf.name+'.png', suf, save=False)
    
            super(Image, self).save()

    Вот так кодят в универах.

    alex-86, 10 Мая 2011

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

    +163

    1. 1
    str_replace('-','/',date("Y-m-d",($from+(60*60*24*$i))))

    Как-то очень спешил и сам себе наговнокодил, ну куда деваться, со всеми бывает )

    stasyan, 08 Мая 2011

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

    +162

    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
    $uploadedFileNameParts = explode('.',$fileName);
    $uploadedFileExtension = array_pop($uploadedFileNameParts); //pathinfo($fileName, PATHINFO_EXTENSION);
    
    //Это наверно круче и быстрей, чем array('jpeg', 'jpg', 'gif', 'png')
    $validFileExts = explode(',', 'jpeg,jpg,png,gif');
    $extOk = false;
    
    foreach($validFileExts as $key => $value)
    {
    	if( preg_match("/$value/i", $uploadedFileExtension ) )
    	{
    		$extOk = true;
    	}
    }
     
    // if(!in_array($fileExtension, array('png', 'jpg', 'gif', 'jpeg'), false)) не катит...
    if ($extOk == false)
    {
    	echo JText::_( 'INVALID EXTENSION' );
            return;
    }
    
    //...
    
    if( !is_int($imageinfo[0]) || !is_int($imageinfo[1]) ||  !in_array($imageinfo['mime'], $validFileTypes) )
    {
            //Кто нибудь встречал картинки с размером 0 на x(где x > 0)..?
    	//....
    }

    Из туториала http://docs.joomla.org/Creating_a_file_uploader_in_your_compone nt ...

    Jetti, 07 Мая 2011

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

    +119

    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
    public static Bitmap DrawBarsChart(ChartType t, Size s)
        {
          double[] values = DataValues;
          string[] names = DataNames;
          Bitmap bmp = new Bitmap(s.Width, s.Height);
          if (t != ChartType.bars || names.Length != values.Length || names.Length < 2)
            return bmp;
          else
          {
            Graphics g = Graphics.FromImage(bmp as Image);
            g.Clear(Color.White);
            g.DrawLines(new Pen(Brushes.Black), new Point[] { new Point(20, 20), new Point(20, s.Height - 20), new Point(s.Width - 200, s.Height - 20) });
            int Columnwidth = (s.Width - 240) / values.Length;
            if (Columnwidth > 150) Columnwidth = 150;
            double maxvalue = values.Max();
            int counter = 1;
            int rangefirst;
            int rangesecond;
     
            while (true)
            {
              if (maxvalue / Math.Pow(10, counter) < 10)
              {
                rangefirst = (int)Math.Floor(maxvalue / Math.Pow(10, counter));
                rangesecond = (int)(maxvalue - rangefirst * Math.Pow(10, counter));
                break;
              }
              else
              {
                counter++;
              }
            }
            int rangepix = (s.Height - 60) / (rangefirst + 1);
            for (int i = 0; i < rangefirst + 1; i++)
            {
              g.DrawString((i * Math.Pow(10, counter)).ToString(), new Font(FontFamily.GenericSansSerif, 10, FontStyle.Regular),
                Brushes.Black, new PointF(0, s.Height - 30 - rangepix * i));
              g.DrawLine(new Pen(Brushes.Black), new Point(17, s.Height - 20 - rangepix * i), new Point(20, s.Height - 20 - rangepix * i));
            }
            Colors colors = new Colors(); //класс-контейнер цветов (99 штук)
            int startcolor = new Random(DateTime.Now.Millisecond).Next(99);
            int j = startcolor;
            int startx = 21;
            int ColumnNumber = 1;
            foreach (var value in values)
            {
              int curfirstrange = (int)Math.Floor(value / Math.Pow(10, counter));
              int cursecondrange = (int)(value - curfirstrange * Math.Pow(10, counter));
              int rangesmallpix = (int)(cursecondrange * rangepix / Math.Pow(10, counter));
              g.FillRectangle(new SolidBrush(colors.GetNextColor(j)), startx,
                s.Height - 20 - curfirstrange * rangepix - rangesmallpix, Columnwidth, curfirstrange * rangepix + rangesmallpix);
              g.DrawString(value.ToString(), new Font(FontFamily.GenericSerif, 10, FontStyle.Regular), new SolidBrush(Color.Black), new PointF(startx + Columnwidth / 2 - 10,
                s.Height - 20 - curfirstrange * rangepix - rangesmallpix - 20));
              g.DrawString(ColumnNumber.ToString(), new Font(FontFamily.GenericSerif, 10, FontStyle.Regular), new SolidBrush(Color.Black), new PointF(startx + Columnwidth / 2 - 10,
                s.Height - 10));
              ColumnNumber++;
              j++; if (j > 99) j = 0;
              startx += Columnwidth;
            }
            j = startcolor;
            int TopMargin = 20;
            foreach (string str in names)
            {
              string tmp = str;
              if (str.Length > 15)
                tmp = str.Substring(0, 15);
              g.FillRectangle(new SolidBrush(colors.GetNextColor(j)), s.Width - 200, TopMargin, 10, 10); //pucyeM LIBeTHbIe kBagpaTuku
              g.DrawString(tmp, new Font(FontFamily.GenericSerif, 12, FontStyle.Italic), Brushes.Black, new PointF(s.Width - 180, TopMargin - 6)); //pucyeM Hagnucu
              TopMargin += 20;
              j++; if (j > 99) j = 0;
            }
            return bmp;
          }
        }

    qbasic, 06 Мая 2011

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

    +170

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    7. 7
    8. 8
    9. 9
    $z = 1;
     do
     {
     $key = mt_rand( 100000000, 999999999 );
     if ( strlen( $key ) == 9 )
     {
     $z++;
     }
     } while ( $z < 1 );

    как вам это?

    rastoman, 05 Мая 2011

    Комментарии (17)
  9. Куча / Говнокод #6552

    +123

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    7. 7
    8. 8
    </tr>
    <?php endforeach;?>
    </tbody></table><br>
    
    <?php /*<ul style="margin-left:575px;" id="subnavlist">
        <li><a class="update" href="jobs-favorites.asp">update</a></li>
    </ul> */?>
    </form>

    коммент насящего php программиста

    peinguin, 05 Мая 2011

    Комментарии (17)
  10. Си / Говнокод #6540

    +102

    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
    if (nchan == 1)
      {
        fprintf(commands_ptr,(char *)"StaNoise sta=%s start_time=%14.3f chan_list=%s window_type=nutall4a sub_window_length=%5.1f main_window_length=%6.1f out_dir=%s plot=yes record=yes decon=%s\n",sta,gmttime,chan_list[0],sub_window_length,main_window_length,out_dir,decon_c);
      }
      if (nchan == 2)
      {
        fprintf(commands_ptr,(char *)"StaNoise sta=%s start_time=%14.3f chan_list=%s,%s window_type=nutall4a sub_window_length=%5.1f main_window_length=%6.1f out_dir=%s plot=yes record=yes decon=%s\n",sta,gmttime,chan_list[0],chan_list[1],sub_window_length,main_window_length,out_dir,decon_c);
      }
      if (nchan == 3)
      {
        fprintf(commands_ptr,(char *)"StaNoise sta=%s start_time=%14.3f chan_list=%s,%s,%s window_type=nutall4a sub_window_length=%5.1f main_window_length=%6.1f out_dir=%s plot=yes record=yes decon=%s\n",sta,gmttime,chan_list[0],chan_list[1],chan_list[2],sub_window_length,main_window_length,out_dir,decon_c);
      }
      if (nchan == 4)
      {
        fprintf(commands_ptr,(char *)"StaNoise sta=%s start_time=%14.3f chan_list=%s,%s,%s,%s window_type=nutall4a sub_window_length=%5.1f main_window_length=%6.1f out_dir=%s plot=yes record=yes decon=%s\n",sta,gmttime,chan_list[0],chan_list[1],chan_list[2],chan_list[3],sub_window_length,main_window_length,out_dir,decon_c);
      }
      if (nchan == 5)
      {
        fprintf(commands_ptr,(char *)"StaNoise sta=%s start_time=%14.3f chan_list=%s,%s,%s,%s,%s window_type=nutall4a sub_window_length=%5.1f main_window_length=%6.1f out_dir=%s plot=yes record=yes decon=%s\n",sta,gmttime,chan_list[0],chan_list[1],chan_list[2],chan_list[3],chan_list[4],sub_window_length,main_window_length,out_dir,decon_c);
      }
      if (nchan == 6)
      {
        fprintf(commands_ptr,(char *)"StaNoise sta=%s start_time=%14.3f chan_list=%s,%s,%s,%s,%s,%s window_type=nutall4a sub_window_length=%5.1f main_window_length=%6.1f out_dir=%s plot=yes record=yes decon=%s\n",sta,gmttime,chan_list[0],chan_list[1],chan_list[2],chan_list[3],chan_list[4],chan_list[5],sub_window_length,main_window_length,out_dir,decon_c);
      }
      if (nchan == 7)
      {
        fprintf(commands_ptr,(char *)"StaNoise sta=%s start_time=%14.3f chan_list=%s,%s,%s,%s,%s,%s,%s window_type=nutall4a sub_window_length=%5.1f main_window_length=%6.1f out_dir=%s plot=yes record=yes decon=%s\n",sta,gmttime,chan_list[0],chan_list[1],chan_list[2],chan_list[3],chan_list[4],chan_list[5],chan_list[6],sub_window_length,main_window_length,out_dir,decon_c);
      }
    ...
      }
      if (nchan >= 14)
      {
        fprintf(commands_ptr,(char *)"StaNoise sta=%s start_time=%14.3f chan_list=%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s window_type=nutall4a sub_window_length=%5.1f main_window_length=%6.1f out_dir=%s plot=yes record=yes decon=%s\n",sta,gmttime,chan_list[0],chan_list[1],chan_list[2],chan_list[3],chan_list[4],chan_list[5],chan_list[6],chan_list[7],chan_list[8],chan_list[9],chan_list[10],chan_list[11],chan_list[12],chan_list[13],sub_window_length,main_window_length,out_dir,decon_c);
      }

    Тяжело в сях работать со строками и переменным числом параметров...

    Eyeless, 04 Мая 2011

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

    +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
    72. 72
    73. 73
    74. 74
    typedef union Variant
        {
        public:
            Variant() {}
    
            Variant(signed int val) :
                v_int(val)
            {}
            operator signed int &() { return const_cast<signed int&>(this->operator const signed int &()); }
            operator const signed int&() const { return v_int; }
    
            Variant(unsigned int val) :
                v_uint(val)
            {}
            operator unsigned int &() { return const_cast<unsigned int&>(this->operator const unsigned int &()); }
            operator const unsigned int &() const { return v_uint; }
    
            Variant(char val) :
                v_char(val)
            {}
            operator char &() { return const_cast<char&>(this->operator const char &()); }
            operator const char&() const { return v_char; }
    
            Variant(double val) :
                v_float(val)
            {}
            operator double &() { return const_cast<double&>(this->operator const double &()); }
            operator const double &() const { return v_float; }
    
            Variant(void *val) :
                v_ptr(val)
            {}
            operator void*& () { return const_cast<void*&>(this->operator void *&()); }
            operator const void* const& () const { return v_ptr; }
    
            static size_t getValueSize(const Type::OfType &type)
            {
                size_t result = 0;
                switch ( type )
                {
                case Type::Pointer:
                case Type::CharPtr:
                case Type::IntPtr:
                case Type::UIntPtr:
                case Type::RealPtr:
                case Type::String:
                    result = sizeof(v_ptr);
                    break;
                case Type::Char:
                    result = sizeof(v_char);
                    break;
                case Type::Int:
                    result = sizeof(v_int);
                    break;
                case Type::UInt:
                    result = sizeof(v_uint);
                    break;
                case Type::Real:
                    result = sizeof(v_float);
                    break;
                case Type::Void:
                    result = 0;
                    break;
                }
                return result;
            }
    
        private:
            void* v_ptr;
            char v_char;
            unsigned int v_uint;
            signed int v_int;
            double v_float;
        } Variant;

    Небольшая имплементация безтиповости ;-[

    Elvenfighter, 02 Мая 2011

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