1. Perl / Говнокод #1530

    −117.2

    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
    my $cache_sql="SELECT `content`, `insertTime` FROM _cache WHERE `confid`='$$conf{confid}'";
    ...
        $cache_sql.=" AND `location`=".$self->{dbh}->quote($url);
    ...
        $cache_sql.=" AND `cgiparams`=".$self->{dbh}->quote($cgi_hash);
    ...
        $cache_sql.=" AND `callparams`=".$self->{dbh}->quote($callp_hash);
    ...
        $cache_sql.=" AND `userid`=".int($$params{userid});
    ...
        $cache_sql.=" AND `groupid`=".int($$params{groupid});
    
       my $replace_sql=$cache_sql;
       $replace_sql=~s/SELECT.*?FROM\s+_cache\s+WHERE/REPLACE INTO _cache SET/s;

    perl+sql

    poltora, 11 Августа 2009

    Комментарии (1)
  2. Perl / Говнокод #1529

    −101

    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
    my $iref=$self->{ditems}->_get_item({itemid=>$weather_itemid, set=>'Weather', fields=>['MinT', 'MaxT', 'Precip', 'Cloud', 'twater'], prefix=>$$p{prefix}});
        if ($$iref{$$p{prefix}.'MinT'}<0 && $$iref{$$p{prefix}.'MaxT'}<=0) {
            my $tmp=$$iref{$$p{prefix}.'MaxT'};
            $$iref{$$p{prefix}.'MaxT'}=$$iref{$$p{prefix}.'MinT'};
            $$iref{$$p{prefix}.'MaxT'}=$tmp;
        };
        #warn $$iref{$$p{prefix}.'MinT'} if !$$iref{$$p{prefix}.'MinT'}>0;
        $$iref{$$p{prefix}.'T'}=int( ($$iref{$$p{prefix}.'MinT'}+$$iref{$$p{prefix}.'MaxT'})/2 );
        $$iref{$$p{prefix}.'T'}='+'.$$iref{$$p{prefix}.'T'} if $$iref{$$p{prefix}.'T'}>0;
        #$$iref{$$p{prefix}.'T'}=~s/\-/\&\#150\;/gs;
        $$iref{$$p{prefix}.'MinT'}='+'.$$iref{$$p{prefix}.'MinT'} if ($$iref{$$p{prefix}.'MinT'}>0);
        $$iref{$$p{prefix}.'MaxT'}='+'.$$iref{$$p{prefix}.'MaxT'} if ($$iref{$$p{prefix}.'MaxT'}>0);
        $$iref{$$p{prefix}.'twater'}='+'.$$iref{$$p{prefix}.'twater'} if ($$iref{$$p{prefix}.'twater'}>0);
        
        $$iref{$$p{prefix}.'time'}=$$p{daystart}+$$p{hour}*3600;

    poltora, 11 Августа 2009

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

    +161

    1. 1
    2. 2
    if ($_GET['prot'] && !ereg("^[_a-zA-Z0-9]+$",$_GET['prot'])) 	$_GET['prot'] = "";
    if ($_GET['id']   && !ereg("^[_a-zA-Z0-9]+$",$_GET['id'])) 	$_GET['id'] = "";

    разбирал один скрипт и нашел там такую проверку
    это особенно весело смотрится, если учесть, что в этих переменных должно быть число

    dead_star, 11 Августа 2009

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

    +155

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    7. 7
    8. 8
    9. 9
    public function throwExceptions($flag = null)
        {
            if ($flag !== null) {
                $this->_throwExceptions = (bool) $flag;
                return $this;
            }
    
            return $this->_throwExceptions;
        }

    Зенд

    getme, 11 Августа 2009

    Комментарии (14)
  5. C++ / Говнокод #1526

    +34

    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
    void dump_indexes(map<int,stride_slices> picks, ofstream &f);
    {
      f<<"# full size: "<<picks.size()<<endl;
      for(map<int, stride_slices>::iterator
    	p=picks.begin(); p!=picks.end(); ++p)
        {
          f<<"## "
           <<p->first<<"'st stride slices count: "
           <<p->second.size()<<endl;
          
          for(stride_slices::iterator
    	    pp=p->second.begin(); pp!=p->second.end(); ++pp)
    	{
    	  f<<"### "
    	   << p->first<<"'st stride, "
    	   <<pp->first<<"'st slice size: "
    	   <<pp->second.size()<<endl;
    	  for(max_slice::iterator
    		ppp=pp->second.begin(); ppp!=pp->second.end(); ++ppp)
    	    {
    	      f<<"#### "
    	       <<p->first<<"'st stride, "
    	       <<pp->first<<"'st slice, "
    	       <<ppp->first<<"'st chunk size:"
    	       <<ppp->second.size()<<endl;
    	      
    	      for(max_chunk::iterator
    		    pppp=ppp->second.begin(); pppp!=ppp->second.end(); ++pppp)
    		f<<"       "
    		 <<p->first<<" "
    		 <<pp->first<<" "
    		 <<ppp->first<<" "
    		 <<pppp->first<<" : "
    		 <<pppp->second<<endl;	
    	    }
    	}
        }
    }

    а как нормально просмотреть кучу вложенных контейнеров?

    Biburath, 11 Августа 2009

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

    +144.9

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    $data=funny_parser($data);
    //модуль недобавления слов вконец
    
    $andtr=array('Андатра','Выпь','Пеликан','Пучеглаз','Хвостозуб','Декроль','Устрица','Челюстёлог','Рукоед','Йыждивение','Оторопь','Осётр','Кингура','Большой лось','Пученоска','Вомбат','Плоскогубка','');
    $data=$data.' <span style="color:#93FF4A;font-size:15px">'.$andtr[rand(0,count($andtr)-1) ].'</span>';

    кусок кода из upyachka.ru =)
    этим всё сказано

    pusher, 11 Августа 2009

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

    +155

    1. 1
    if ($id=$trips->create($user['id'], strip_tags($_POST['name']), $_POST['country'], strip_tags($_POST['city']), strip_tags($_POST['place']), $depart, $arrive, strip_tags($_POST['text']), $type)) {

    simpsonoid, 11 Августа 2009

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

    +159.3

    1. 1
    2. 2
    3. 3
    4. 4
    for ($x=5;$x<135;$x+=25){
        $cislo=mt_rand(0,9);
        $string.=$cislo;
    }

    Interfere, 11 Августа 2009

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

    +76.3

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    11. 11
    try {
        ....
    } catch (Exception ex) {
        if (ex != null) {
            try {
                ex.printStackTrace();
            } catch(Exception ex1) {
                ....
            }
        }
    }

    Rudolf_Abel, 11 Августа 2009

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

    +133.9

    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
    for (int i = 0; i < gvOrderMain.RowCount - EditIndex; i++)
                                {
                                    float tempQuantity = GetRow(i).Quantity;
                                    int partyLen = DB.PrInStOrderByPartyNum(GetRow(i).ProductId, curStockId).ToArray().Length;
                                    for (int j = 0; j < partyLen; j++)
                                    {
                                        if (DB.PrInStOrderByPartyNum(GetRow(i).ProductId, curStockId).ToArray()[j].Quantity > 0)
                                        {
                                            float CurSQuantity = DB.PrInStOrderByPartyNum(GetRow(i).ProductId, curStockId).ToArray()[j].Quantity.Value;
                                            if (tempQuantity > CurSQuantity)
                                            {
                                                Documents_Product dp = new Documents_Product();
                                                dp.PrimePriceExcVAT = DB.PrInStOrderByPartyNum(GetRow(i).ProductId, curStockId).ToArray()[j].PrimePriceExcVAT;
                                                dp.PrimePriceIncVAT = DB.PrInStOrderByPartyNum(GetRow(i).ProductId, curStockId).ToArray()[j].PrimePriceIncVAT;
                                                dp.Quantity = -1 * DB.PrInStOrderByPartyNum(GetRow(i).ProductId, curStockId).ToArray()[j].Quantity;
                                                dp.OldQuantity = DB.PrInStOrderByPartyNum(GetRow(i).ProductId, curStockId).ToArray()[j].Quantity;
                                                dp.PartyNumber = DB.PrInStOrderByPartyNum(GetRow(i).ProductId, curStockId).ToArray()[j].PartyNumber;
                                                DB.Documents_Products.InsertOnSubmit(dp);
                                                DB.SubmitChanges();
    
                                                Documents_ProductsOrder dro = new Documents_ProductsOrder();
                                                dro.PriceSum = GetRow(i).RealPrice * DB.PrInStOrderByPartyNum(GetRow(i).ProductId, curStockId).ToArray()[j].Quantity;
                                                tempQuantity = tempQuantity - DB.PrInStOrderByPartyNum(GetRow(i).ProductId, curStockId).ToArray()[j].Quantity.Value;
                                                DB.PrInStOrderByPartyNum(GetRow(i).ProductId, curStockId).ToArray()[j].Quantity = 0;
                                                DB.Documents_ProductsOrders.InsertOnSubmit(dro);
    
                                                DB.SubmitChanges();
    ..........

    Rudolf_Abel, 11 Августа 2009

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