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

    +172

    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
    function load_that_shop_page( $modulename, $pagename) {
                global $my, $db, $perm, $ps_function, $ps_module, $ps_html, $ps_vendor_id, $page, $database,$mosConfig_absolute_path, $cart, $start, $option, $vmLogger, $vmDoCaching,
                $product_id,$VM_LANG, $PHPSHOP_LANG, $sess,$vendor_image,$vendor_country_2_code, $vendor_country_3_code , $vendor_image_url, $PSHOP_SHIPPING_MODULES,
                $_VERSION, $vendor_name, $vendor_address, $vendor_city,$vendor_country,$vendor_mail, $category_id, $mainframe, $mosConfig_list_limit, $limitstart, $limit,
                $vendor_store_name, $vendor_state, $vendor_zip, $vendor_phone, $vendor_currency, $vendor_store_desc, $vendor_freeshipping, $ps_shipping, $ps_order_status,
                $module_description, $vendor_currency_display_style, $vendor_full_image, $mosConfig_live_site, $vendor_id, $CURRENCY_DISPLAY, $keyword, $mm_action_url,
                $ps_payment_method,$ps_zone,$ps_product, $ps_product_category, $ps_order, $sess, $page, $func, $pagename, $modulename, $vars, $cmd, $ok, $mosConfig_lang, $mosConfig_useractivation,
                $auth, $ps_checkout,$error, $error_type, $func_perms, $func_list, $func_class, $func_method, $func_list, $dir_list, $mosConfig_allowUserRegistration, $mosConfig_caching;
    
                if( !stristr( $_SERVER['PHP_SELF'], "index2.php") ) {
                       $mainframe->addCustomHeadTag( "<script type=\"text/javascript\" src=\"$mosConfig_live_site/components/$option/js/sleight.js\"></script>
    <link type=\"text/css\" rel=\"stylesheet\" media=\"screen, projection\" href=\"$mosConfig_live_site/components/$option/css/shop.css\" />" );
                } else {
    				?>
    <script type="text/javascript" src="<?php echo "$mosConfig_live_site/components/$option" ?>/js/sleight.js"></script>
    <link type="text/css" rel="stylesheet" media="screen, projection" href="components/<?php echo $option ?>/css/shop.css" />
    				<?php
    			}

    небольшой отрывок из компоненты com_virtuemart движка joomla.
    ППЦ!!! и они ЭТО называют ООП? там все в перемешку, вполне в норме кучи echo в перемешку с sql запросами, про шаблонизацию и отделения логики от данных и данных от представления они видимо вообще не в курсе...

    nikll, 07 Мая 2011

    Комментарии (12)
  2. Python / Говнокод #6579

    −181

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    charref = re.compile(r'(CREATE PROCEDURE)',re.IGNORECASE)
    Str=re.sub(charref,'r(CREATE PROCEDURE', Str)
    PosStr=Str.find('CREATE PROCEDURE')
    l=len(Str)
    Proc = Str[PosStr:l]

    Вечером написал, утром посмеялся)
    Str=re.search(r'(?s)(CREATE PROCEDURE).+',Str)

    wds, 06 Мая 2011

    Комментарии (9)
  3. 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)
  4. Java / Говнокод #6577

    +68

    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
    public class Zayac {
    	public static void main(String args[]) {
        String ears="(\\_/)";
        String face="(-_-)";
        String hands="(> <)";
        String legs="(\")(\")";
        System.out.println(ears);
        System.out.println(face);
        System.out.println(hands);
        System.out.println(legs+'\n');
    	System.out.println('\t'+ears);
    	System.out.println('\t'+face);
    	System.out.println('\t'+hands);
        System.out.println('\t'+legs);
        System.out.println("\t"+"\t"+ears);
    	System.out.println("\t"+"\t"+face);
    	System.out.println("\t"+"\t"+hands);
        System.out.println("\t"+"\t"+legs);
    	}
    }

    Дело было вечером - делать было нечего.

    Akira, 06 Мая 2011

    Комментарии (16)
  5. Си / Говнокод #6576

    +137

    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
    /***   First, attempting to establish a SSL-connection   ***/
    		while(1)
    		{
    			sslConnection = sslConnect((const char *)remoteHost, port, CAFileName, CAPathName, error);
    			if(!sslConnection)
    			{
    				logger(ERR, "receiver: Can not establish SSL connection with %s [description - %s]", remoteHost, error);
    #ifndef DEBUG_MODE
    				if (WaitForSingleObject (hExitEvent, 5000) == WAIT_OBJECT_0)
    				{
    					if(logLevel == DEBUG_LOG_LEVEL)
    						logger(INFO, "receiver: Exit event was set in signaling state");
    					logger(INFO, "receiver: Exit");
    					return(0);
    				}
    #else
    				Sleep(5000);
    #endif
    				continue;
    			}
    			else
    			{
    				if(logLevel == DEBUG_LOG_LEVEL)
    				{
    					logger(INFO, "receiver: Connection with %s is established", remoteHost);
    				}
    				socketError = 0;
    				break;
    			}
    		}

    Пытаемся подключиться к серверу по SSL/TLS, отваливаемся по событию

    cepin, 06 Мая 2011

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

    +127

    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
    private void bbbut_Click(object sender, EventArgs e)
            {
                if (this.plugDescr.SelectedText.Length > 0)
                {
                    ToolStripButton button = (ToolStripButton) sender;
                    if (button.Name == "bbB")
                    {
                        this.plugDescr.SelectedText = BB_HTMLwork.WriteBBToString(this.plugDescr.SelectedText, "", "b");
                    }
                    if (button.Name == "bbI")
                    {
                        this.plugDescr.SelectedText = BB_HTMLwork.WriteBBToString(this.plugDescr.SelectedText, "", "i");
                    }
                    if (button.Name == "bbU")
                    {
                        this.plugDescr.SelectedText = BB_HTMLwork.WriteBBToString(this.plugDescr.SelectedText, "", "u");
                    }
                    if (button.Name == "bbS")
                    {
                        this.plugDescr.SelectedText = BB_HTMLwork.WriteBBToString(this.plugDescr.SelectedText, "", "s");
                    }
                    if (button.Name == "bbURL")
                    {
                        this.plugDescr.SelectedText = BB_HTMLwork.WriteBBToString(this.plugDescr.SelectedText, this.bbAddInfoContent.Text, "url");
                    }
                }
            }

    Обработчик кнопок ббкода в утилите для генерации ридми. Весь ее код выполнем в таком духе.
    Утилита: http://fullrest.ru/forum/topic/34114-generator-readme/
    Сорцы: http://depositfiles.com/files/kvi4gsajy

    Говногость, 06 Мая 2011

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

    +124

    1. 1
    litFreeMinets.Text = FreeMinutes.Count;

    uassya, 06 Мая 2011

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

    +163

    1. 1
    2. 2
    3. 3
    function paging($pageNum,$rowsPerPage)
    {
    	GLOBAL $_GET, $_POST, $_SESSION;

    На всякий случай. Чтоб точно глобальные были. А то всякое бывает ...

    _tL, 06 Мая 2011

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

    +165

    1. 1
    2. 2
    3. 3
    4. 4
    function do_it()
    {
    	return false;
    }

    _tL, 06 Мая 2011

    Комментарии (27)
  10. Java / Говнокод #6571

    +76

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    public int getCount() {
    	return mViewMap == null
    			? mChannelList == null ? 0 : mChannelList.size()
    			: mViewMap.size();
    }

    ZaDroid, 06 Мая 2011

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