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

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

    +116

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    11. 11
    protected void chxPeriodCostDeviationGreater_CheckedChanged(object sender, EventArgs e)
            {
                foreach (Pair lstPair in lstPairs)
                {
                    if (lstPair.First.Equals(sender))
                    {
                        (lstPair.Second as TextBox).Enabled = (lstPair.First as CheckBox).Checked;
                        return;
                    }
                }
            }

    задаем видимость контролов :)

    _vinka, 05 Апреля 2012

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

    +163

    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
    <!--/** Блог Алексея отключен
    
    
    <div class="rightadd"><a rel="dofollow" href="/blog_alex.html"><h3>Блог Алексея Сафиоллина</h3></a>
     <div class="txt">
    <?
            	foreach ($a_news_1 as $key => $val) {        	
            	?>
            	<div class="item">
    			<table width="100%" cellpadding="0" cellspacing="0" border="0">
    			<tr>
    				<td style="vertical-align:top;width:70px">
    				<div class="pic"><a rel="nofollow" href="<?=$val['url']?>"><img src="<?=$val['photo_70']?>" width="70" height="70" alt="" /></a></div>
    				</td>
    				<td style="vertical-align:top;">
                <a rel="nofollow" href="<?=$val['url']?>"><?=$val['cap']?></a> <?=util::getDotWord($val['s_body'], 110)?>       
    				</td>
    			</tr>
    			</table>   
    			</div>
                <?}?>
                  </div>
                </div> 
     */-->

    Отключили блог...
    P.S. И вот такое, люди называют "системой".

    nethak, 02 Апреля 2012

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

    +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
    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
    <?php if(isset($_GET["fullVersion"])) $_SESSION["fullVersion"]="on"; ?><?php if($_SESSION["fullVersion"]!='on' && (substr_count($_SERVER["HTTP_USER_AGENT"],'Android') || substr_count($_SERVER["HTTP_USER_AGENT"],'iPhone'))){
         header("Location: /m/redirects/?withjs");
         exit;
      }
      else if($_SESSION["fullVersion"]!='on' && substr_count($_SERVER["HTTP_USER_AGENT"],'Opera Mini')){
         header("Location: /m/redirects/?operamini");
         exit;
      }
      ?><?php if($_GET["ClockId"] && $_GET["str"] && $_GET["frompartnerka"]==1){ header("Location: http://vip-timeclub.ru/catalog/articul/?ClockId=".(int)$_GET["ClockId"]."&str=2");} ?>
    
    <?php if(function_exists('vtPrice')==false){
        function vtPrice($price=0,$sale=0,$priceGold=0){
          if($priceGold){
            $priceOld = $price;
            $price = $priceGold;
          }
          else if($sale){
            $priceOld = $price;
            $price = ceil(intval($priceOld)-((intval($priceOld)/100)*(intval($sale))));
          }
          else{
            $priceOld = 0;
          }
          return array('price'=>$price,'priceOld'=>$priceOld);
        }
      }if(function_exists('vtPriceGood')==false){
       function vtPriceGood($price){
          if(intval(substr($price,-1)) > 0 && intval(substr($price,-1)) < 5) 
                $price = intval($price) + (5-intval(substr($price,-1))); 
          else if(intval(substr($price,-1)) > 5 && intval(substr($price,-1)) <= 9) 
                $price = intval($price) + (10-intval(substr($price,-1)));
          return $price;
        }
      } ?>

    spam, club-viptime DOT RU

    111111, 01 Апреля 2012

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

    −90

    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
    def runRidor():
    	isDirty = 0
    	#Except (DebugSize <= 14) and (ImageVersion <= 760) and (VirtualSize2 > 992) and (ExportSize <= 80.5) => isDirty = 1  (1702.0/16.0) [855.0/5.0]
    	if input.DebugSize <= 14 and input.ImageVersion <= 760 and input.VirtualSize2 > 992 and input.ExportSize <= 80.5:
    		isDirty = 1
    #Except (DebugSize <= 14) and (ImageVersion <= 4525) and (ExportSize <= 198.5) and (ResourceSize <= 37532) and (VirtualSize2 <= 6) and (ResourceSize <= 7348) and (ResourceSize > 1773) => isDirty = 1  (106.0/0.0) [48.0/0.0]
    	elif input.DebugSize <= 14 and input.ImageVersion <= 4525  and input.ExportSize <= 198.5 and input.ResourceSize <= 7348 and input.VirtualSize2 <=6 and input.ResourceSize > 1773:
    		isDirty = 1
    #Except (DebugSize <= 14) and (ImageVersion <= 4950) and (ExportSize <= 192) and (IatRVA > 256) and (VirtualSize2 > 42) and (ExportSize <= 56) and (NumberOfSections > 3.5) => isDirty = 1  (193.0/0.0) [91.0/0.0]
    	elif input.DebugSize <= 14 and input.ImageVersion <= 4950 and input.ExportSize <= 56 and input.IatRVA > 256 and input.VirtualSize2 > 42 and input.NumberOfSections > 3.5:
    		isDirty = 1
    #Except (DebugSize <= 14) and (ImageVersion <= 4950) and (VirtualSize2 <= 6) and (ResourceSize <= 37532) and (ResourceSize <= 17302) => isDirty = 1  (388.0/0.0) [216.0/7.0]
    	elif input.DebugSize <= 14 and input.ImageVersion <= 4950 and input.VirtualSize2 <= 6 and input.ResourceSize > 17302:
    		isDirty = 1
    #Except (DebugSize <= 14) and (NumberOfSections > 2.5) and (ResourceSize > 1776) and (IatRVA <= 6144) and (ExportSize <= 219.5) and (VirtualSize2 > 2410) and (VirtualSize2 <= 61224) => isDirty = 1  (238.0/0.0) [116.0/0.0]
    	elif input.DebugSize <= 14 and input.NumberOfSections >= 2.5 and input.ResourceSize <= 1776 and input.IatRVA <= 6144 and input.ExportSize <= 219.5 and input.VirtualSize2 > 2410 and input.VirtualSize2 <= 61224:
    		isDirty = 1

    Пример того, как не надо писать на питоне, показывает Adobe. Полная версия: http://voxel.dl.sourceforge.net/project/malclassifier.adobe/AdobeMalwareClassifier.py

    SvartalF, 30 Марта 2012

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

    +153

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    7. 7
    8. 8
    9. 9
    do
      {
       $firstDate = ConvertTimeStamp($firstDateSt, "SHORT");
       $lastDate = ConvertTimeStamp($lastDateSt, "SHORT");
       
       $arPeriod = Array(
        "TITLE" => CSchool::GetDiaryPeriod($firstDate, $lastDate),
        "HREF" => $APPLICATION->GetCurPageParam('START_WEEK='.$firstDate.'&END_WEEK='.$lastDate, array("START_WEEK", "END_WEEK"))
       );

    Битрикс...
    do без while? лаконично

    nicksevenfold, 29 Марта 2012

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

    +163

    1. 1
    2. 2
    3. 3
    //fucking designers
    	if ( $page->importantshort ) $page->short = true;
    	if ( $page->importantNOTshort ) $page->short = false;	// так то!

    bot, 29 Марта 2012

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

    +76

    1. 1
    2. 2
    3. 3
    4. 4
    } catch (IllegalArgumentException e) {
        // checked exceptions are stupid
        throw new UnexpectedException(e);
    }

    https://github.com/lmcalpin/Play--Paginate/blob/master/src/play/modules/paginate/strategy/JPARecordLocatorStrategy.java#L149

    Well...

    public class IllegalArgumentException extends RuntimeException

    roman-kashitsyn, 28 Марта 2012

    Комментарии (4)
  9. Java / Говнокод #9783

    +75

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    7. 7
    8. 8
    boolean retval = serviceCategory.equalsIgnoreCase("transportation");
    if (retval) {
        String serviceLocation = bp.getParameterValueObjectFromAnyComponent("ReqTDQuestions", "svcLocation") + "";
        if(serviceLocation.equalsIgnoreCase("GreaterChina")) {
            retval=true;
         }
    }
    return retval;

    После деобфускации получаем:
    return serviceCategory.equalsIgnoreCase("transp ortation");

    zloizerg, 27 Марта 2012

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

    +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
    17. 17
    18. 18
    19. 19
    /* добавленный код: */
    public function preDispatch() {
       $id = (int) $this->_request->id;
       if ($id > 0) {
            $this->_item = doctrine("Item")->findOneById($id);
            if (!is_object($this->_item)) {
                throw new PageException_NotFound;
            }
        }
    }
    
    /* выброшенный код: */
    public function indexAction() {
        $itemId = (int) $this->_request->id;
        $item = doctrine("item")->findOneBy(array("id" => $itemId, "owner" => $this->_owner->getId()));
        if (is_object($item)) {
        /* ... */
        }
    }

    Вот такой рефакторинг. Теперь кто хочет - может редактировать все, что не лень подставить в запрос.

    Wivern, 27 Марта 2012

    Комментарии (4)
  11. Pascal / Говнокод #9773

    +89

    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
    procedure TRashetDate_Form.Button1Click(Sender: TObject);
      var a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p, aa, ee: real;
      res1: real;
      res2: real;
      res3: real;
      res4: real;
      res5: real;
      res6: real;
      res7: real;
      res8: real;
      res9: real;
      res10: real;
      res11: real;
      res12: real;
      res13: real;
      res14: real;
      res15: real;
      res16: real;
      res17: real;
      res18: real;
      res19: real;
      res20: real;
      res21: real;
      res22: real;
      res23: real;
      Field: real;
    <...>

    Брал отсюда и рыдал...
    http://www.cyberforum.ru/delphi-beginners/thread527956.html#post2835591

    Psilon, 26 Марта 2012

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