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

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

    −40.1

    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
    /* This is bad. Reaaly bad. It's a really, really bad hack. If you're an employee of 
     * Intertrode Communication, then I'm really, really sorry that you have to maintain
     * this. I was honestly planning on removing this tomorrow, but I've been known to 
     * forget things like this. It happens.
     *
     * So here's the thing. I can't seem to figure out why the AccountId variable isn't 
     * set. I've looked and looked, but I gotta leave now. Anyway, I've found that I can
     * just grab the AccountID from the debugging logs.  I suppose that to fix it, you'd
     * have to locate where it's clearing out the ID.
     *
     * Again, I'm sorry.
     */
    
    if ( (AccountId == NULL) || (AccountId == "") ||
         (ServerSesion["AccountId"] == NULL) || (ServerSesion["AccountId"] == "") )
    {
      //open session logs
      FileHandle file = f_open(LOG_PATH + "\sessionlog-" + LOG_FILE_DATE + ".log", 1);
      while (file != NULL)
      {
        
        TString line = f_readline(file);
    
        //look for IP and changereg
        if ( (sfind(line,REMOTE_ADDR) != -1) && (sfind(line,"changereg") != -1) )
        {
          //0000-00-00 00:00 /accountmaint/changereg/?AccountId=123456 255.255.255.255 ...
          //                                                    *
          AccountId = substr(line, 52, 6);
        }
    
        if (f_EOF(file)) { f_close(file); file = NULL; }
      }
    
    }

    У чувака где то перетирается AccountId, так он берет данные из логов IIS'а :) Главное, что он сожалеет об этом.
    Отсюда: http://thedailywtf.com/Articles/The_Apologetic_Coder.aspx

    guest, 18 Декабря 2008

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

    +25

    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
    var res = document.getElementById("result");
    	
    	var data = eval('(' + result + ')');
    	var text = data.status;
    	
    	while (res.firstChild)
    		res.removeChild(res.firstChild);
    	
    	res.appendChild(document.createTextNode(data.status));
    	
    	for (var i = 0; i < data.result.length; i++)
    	{
    		res.appendChild(document.createElement("br"));
    		res.appendChild(document.createTextNode(data.result[i]));
    	}

    guest, 16 Декабря 2008

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

    +27

    1. 1
    2. 2
    volumes = new List<VolumeInformation>(ServerTypedProxy.GetUnfilteredVolumeInformationList())
                    .ConvertAll<BindableVolumeInfo>(delegate(VolumeInformation vi) { return new BindableVolumeInfo(vi); });

    Из разряда попробуй отдебажь
    [Ф]

    guest, 16 Декабря 2008

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

    +28.7

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    function table_exists($table) {
               self :: query("show tables from ".DB_NAME);
               for ($i = 0; $i < self :: num(); $i++) {
                   $res = mysqli_fetch_array($this -> result);
                   if ($res[0] == DB_PREFIX . $table) {
                       return true;
                   }
               }
                   return false;
           }

    guest, 16 Декабря 2008

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

    +25

    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
    DateTime startTime = DateTime.Now;
    DateTime endTime = DateTime.Now;
    foreach (BillablePhas bi in CreateBillablePhaseForFixedPrice.Phases)
    {
      if (BillablePhase.Equals(bi))
      {
        errorLbl.Visible = true;
        savedLbl.Visible = false;   
                      
        TimeSpan spread = endTime - startTime; //пик быдлокода
        bi.RatioSpredDateTime = Math.Ceiling(Convert.ToDouble(spread.Days*bi.Ratio/100));
      }
    }

    endTime - startTime АААА!!!

    guest, 15 Декабря 2008

    Комментарии (2)
  7. Java / Говнокод #184

    −39.2

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    7. 7
    try {
    	allProviders = Stubs.create(IProviderService.class).getAllProviders();
    } catch (Exception e) {
    } finally {
    	loadData(allProviders);
    	providersInitialized = true;
    }

    надежно получаем всех поставшиков.

    guest, 15 Декабря 2008

    Комментарии (2)
  8. JavaScript / Говнокод #180

    +28

    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 check_finished_pending() {
    
    var v_wrt_id = document.getElementById('writer_id').value;
    
    if( 6 == 26 )
    {
    return confirm("Status 'finished pending' confirmation:\nAre you sure you made all needed operations on this order?");
    }
    else
    {       //var normal_writer_id = 2520;
    	if (( v_wrt_id != '2520' && v_wrt_id != 0))
    	{
    	//alert(v_wrt_id);
    	window.open('writer_add_select.php?fid=2020727&writer_id='+v_wrt_id, 'Assign writer', 'location,width=650,height=600,top=0');
    	return false;
    	}
    	else return confirm('Save?');
    }

    Правлю функции JS, тут такое чудо с мега условием попалось....

    guest, 15 Декабря 2008

    Комментарии (2)
  9. C# / Говнокод #175

    +14.3

    1. 1
    2. 2
    bool exitstatus = true;
    if (!extremalexit) { exitstatus = true; }

    На всякий случай присвоим еще раз
    [Ф]

    guest, 15 Декабря 2008

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

    +28

    1. 1
    namespace ? = boost::lambda;

    навеяно http://www.govnokod.ru/165

    guest, 14 Декабря 2008

    Комментарии (2)
  11. JavaScript / Говнокод #162

    +29

    1. 1
    <html> <head> <style type="text/css"> html, body { background-color:#000; font-family:Segoe UI, Tahoma, Arial, sans-serif; font-size:11px; color:#FFF; margin:0px; padding:0px; width:100%; height:100%; overflow:hidden; } a:link, a:visited, a:active { color:#CCC; text-decoration:underline; } a:hover { color:#F00; text-decoration:none; } #progressbar_block { width:100%; height:100%; padding-left:50%; padding-top:50%; overflow:hidden; } ul.progressbar { width:400px; height:50px; padding:0px; margin:0px; margin-left:-200px; margin-top:-25px; clear:both; list-style-type:none; } ul.progressbar li { padding:0px; margin:0px; float:left; } li.left { background-image:url(img/l_bg_n.png); background-repeat:no-repeat; width:20px; height:50px; } li.middle { background-image:url(img/m_bg_n.png); background-repeat:repeat-x; width:360px; height:50px; } li.right { background-image:url(img/r_bg_n.png); background-repeat:no-repeat; width:20px; height:50px; } </style> <script language="javascript"> function func() { var max = 400 - 16; var pixels = 400 - 16; var step = pixels/max; next(0); } function next(i) { var max = 400 - 16; var pixels = 400 - 16; var step = pixels/max; var lft = document.getElementById("left_pb"); var mid = document.getElementById("middle_pb"); var rht = document.getElementById("right_pb"); if(i < 12) lft.style.width = String(8 + i) + "px"; else lft.style.width = String(20) + "px"; if(i < pixels - 12 && i > 12) mid.style.width = String(i - 12) + "px"; else if(i > 12) mid.style.width = String(360) + "px"; else mid.style.width = String(0) + "px"; if(i > 372) rht.style.width = String(i - 372) + "px"; else if(i < 372) rht.style.width = String(0) + "px"; setTimeout("next(" + (i + step < pixels ? i + step : 0) + ")", 25); } </script> </head> <body onload="func();"> <div id="progressbar_block"> <ul class="progressbar"> <li class="left"><div id="left_pb" style="background-image:url(img/l_bg_a.png); width:8px; height:50px; overflow:hidden;">&nbsp;</div></li> <li class="middle"><div id="middle_pb" style="background-image:url(img/m_bg_a.png); width:0px; height:50px; overflow:hidden;">&nbsp;</div></li> <li class="right"><div id="right_pb" style="background-image:url(img/r_bg_a.png); width:0px; height:50px; overflow:hidden;">&nbsp;</div></li> </ul> </div> </body> </html>

    Вот так мы делаем прогресс-бары

    guest, 14 Декабря 2008

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