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

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

    +157

    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
    if ($this->_hasParam('error')) {
                    if (intval(htmlentities($this->getRequest()->getParam('error'))) == -1100) {
                        $this->payment_messages->addMess($this->translate->translate('please.remember.fill'));
                    } elseif (intval(htmlentities($this->getRequest()->getParam('error'))) == -1300) {
                        $this->payment_messages->addMess($this->translate->translate('credit.card.not.accepted'));
                    } elseif (intval(htmlentities($this->getRequest()->getParam('error'))) == -1022) {
                        $this->payment_messages->addMess($this->translate->translate('transaction.declined.card.number'));
                    } elseif (intval(htmlentities($this->getRequest()->getParam('error'))) == -1018) {
                        $this->payment_messages->addMess($this->translate->translate('transaction.declined.card.number'));
                    } else {
                        $this->payment_messages->addMess($this->translate->translate('payment.system.error'));
                    }
                    $this->view->payment_messages = $this->payment_messages->getMess();
                }

    В продолжение #9742
    Это Team leader!!!

    Quetzalcoatl, 23 Марта 2012

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

    +157

    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
    class UserAPI
    {
       function GetUserName($UserId)
       {
          $SqlQuery = mysql_query("SELECT UserName FROM users WHERE id='$UserId'");
          $Response = mysql_fetch_array($SqlQuery);
          return  $Response['UserName'];
       }
         
       function GetUserSurname($UserId)
       {
          $SqlQuery = mysql_query("SELECT UserSurname FROM users WHERE id='$UserId'");
          $Response = mysql_fetch_array($SqlQuery);
          return  $Response['UserSurname'];
       }
       
       function GetUserPhoto($UserId)
       {
          $SqlQuery = mysql_query("SELECT UserPhoto FROM users WHERE id='$UserId'");
          $Response = mysql_fetch_array($SqlQuery);
          return  $Response['UserPhoto'];
       }
       
       function GetUserCountry($UserId)
       {
          $SqlQuery = mysql_query("SELECT country FROM users WHERE id='$UserId'");
          $Response = mysql_fetch_array($SqlQuery);
          return  $Response['country'];
       }
    }

    О да!

    Govnisti_Diavol, 22 Марта 2012

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

    +157

    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
    public function getSaleDepartment()
        {
            $_linkToDepLabel = '';
    		
            switch ($this->getfs_sale_department()) {
                case '0':
                    $_linkToDepLabel = $this->getBaseUrl();
                    $_linkToDepLabel .= 'media/flash_sales/saledepartment/1.png';
                    break; //Moda
                case '1':
                    $_linkToDepLabel = $this->getBaseUrl();
                    $_linkToDepLabel .= 'media/flash_sales/saledepartment/2.png';
                    break; //Belleza
                case '2':
                    $_linkToDepLabel = $this->getBaseUrl();
                    $_linkToDepLabel .= 'media/flash_sales/saledepartment/3.png';
                    break; //Novia
                case '3':
                    $_linkToDepLabel = $this->getBaseUrl();
                    $_linkToDepLabel .= 'media/flash_sales/saledepartment/4.png';
                    break; //Ocio
                case '4':
                    $_linkToDepLabel = $this->getBaseUrl();
                    $_linkToDepLabel .= 'media/flash_sales/saledepartment/5.png';
                    break; //Deporte
                case '5':
                    $_linkToDepLabel = $this->getBaseUrl();
                    $_linkToDepLabel .= 'media/flash_sales/saledepartment/6.png';
                    break; //Familia
                case '6':
                    $_linkToDepLabel = $this->getBaseUrl();
                    $_linkToDepLabel .= 'media/flash_sales/saledepartment/7.png';
                    break; //Hogar
                case '7':
                    $_linkToDepLabel = $this->getBaseUrl();
                    $_linkToDepLabel .= 'media/flash_sales/saledepartment/8.png';
                    break; //Viaje
                case '8':
                    $_linkToDepLabel = $this->getBaseUrl();
                    $_linkToDepLabel .= 'media/flash_sales/saledepartment/9.png';
                    break; //Moda
                case '9':
                    $_linkToDepLabel = $this->getBaseUrl();
                    $_linkToDepLabel .= 'media/flash_sales/saledepartment/10.png';
                    break; //Belleza
                case '10':
                    $_linkToDepLabel = $this->getBaseUrl();
                    $_linkToDepLabel .= 'media/flash_sales/saledepartment/11.png';
                    break; //Novia
                case '11':
                    $_linkToDepLabel = $this->getBaseUrl();
                    $_linkToDepLabel .= 'media/flash_sales/saledepartment/12.png';
                    break; //Ocio
                case '12':
                    $_linkToDepLabel = $this->getBaseUrl();
                    $_linkToDepLabel .= 'media/flash_sales/saledepartment/13.png';
                    break; //Deporte
    
                default:
                    $_linkToDepLabel = '';
                    break;
            }
            return $_linkToDepLabel;
        }

    ппц

    CheshirskyCode, 21 Марта 2012

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

    +157

    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
    $k=1;
    $empty=true;?>
    <?foreach($arResult["ITEMS"] as $arItem):?>
    <?$time=time();
    $delay=345600;//секунд в 4 днях
    $date_elements  = explode(".",$arItem["DATE_ACTIVE_TO"]);?>
    	<?if(((mktime(0,0,0,$date_elements[1],$date_elements[0],$date_elements[2])+$delay) < $time) or ($arItem["PROPERTIES"]["procedure"]["VALUE_XML_ID"]=="% тут айдишник %")):?>
    		<?if($k==1):?>
    			<table><tr>
    			<th>%тут оглавления%</th>
    			<th>%тут оглавления%</th>
    			<th>%тут оглавления%</th>
    			<th>%тут оглавления%</th>
    			<th>%тут оглавления%</th></tr>
    			<?$k++;
                $empty=false;?>
    		<?endif?>
    	<?$name='';?>
    	<tr>
    	% тут перебор элементов %
    	</tr>
    	<?endif?>
    <?endforeach;?>
    </table>

    кастомизированный news.list битрикса.
    1) у каждого элемента есть ключ (номер элемента), но мы-то об этом не знаем.
    2) зачем выносить table>tr>th за цикл? И так пойдет.
    3) time() в каждой итерации? А вдруг сервер слабенький, выполнение цикла занимает больше 4-ёх дней.
    4) strtotime()? не, не слышал.
    И еще куча лулзов в проекте, выложу по ходу.
    Самое интересное, что проект крупной российской фирмы, видать местные индусы делали.

    Kreeg, 15 Марта 2012

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

    +157

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    11. 11
    .....
    function init()
    {
      .......
            $this->smenu = file_get_contents('http://'.$_SERVER['HTTP_HOST'].'/sitemenu/?tb=/lombards/?type_id=1');
    	$this->smenu2 = file_get_contents('http://'.$_SERVER['HTTP_HOST'].'/sitemenu/?tb=/lombards/?type_id=2');
            $this->sform = file_get_contents('http://'.$_SERVER['HTTP_HOST'].'/searchform/?request=lombards&'.$_SERVER['QUERY_STRING']);
            $this->bottom = file_get_contents('http://'.$_SERVER['HTTP_HOST'].'/bottom/');
      .......
    }
    .....

    Чистый ООП
    P.S. Проект на zend framework

    minisot, 03 Марта 2012

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

    +157

    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
    if(intval($data[0])>0){
      $massart=explode(" ",$data[1]);
      if($massart[0]){
        $infoarticle=mysql_query("SELECT `Message_ID`, `ExternalData` FROM `Message114` where `Article`='".mysql_escape_string($massart[0])."';");
        if(mysql_num_rows($infoarticle)){
          while($infoarticlerow=mysql_fetch_array($infoarticle)){ 
            $arrowitem["".$massart[0]]['name']=$data[1];
            $arrowitem["".$massart[0]]['id']=$infoarticlerow['Message_ID'];
            $arrowitem["".$massart[0]]['info']=$infoarticlerow['ExternalData'];
            for ($c=5; $c < $num; $c++) {
              if(intval($data[$c])>0){
                $arrowitem["".$massart[0]]['size'][$mssize[$c]]=$data[$c];    
              }
            }   
            if(floatval($arrowitem["".$massart[0]]['price'])==0){
              $arrowitem["".$massart[0]]['price']=floatval($data[3]);
            }else{
              if(floatval($arrowitem["".$massart[0]]['price'])>floatval($data[3])){
                $arrowitem["".$massart[0]]['price']=floatval($data[3]); 
              }
            }           
          } 
        }else{
          $notnetcat[]=$data[1];  
        }
      }
    }

    От нехватки рабочих рук отдали одну правку на фриланс. Рвусь между желанием всё переписать по-человечески и со спокойной совестью отчитаться перед заказчиком либо же забить (парню заплатили, блеать!), но потом краснеть за глюки этого чудо-кода, которые, жопой чую, обязательно возникнут.

    telnet, 25 Февраля 2012

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

    +157

    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
    <?php
    function getRusMonth($month)
    {
      if($month > 12 || $month < 1) return FALSE;
      $aMonth = array('январь',
    		  'февраль',
    		  'март',
    		  'апрель',
    		  'май',
    		  'июнь',
    		  'июль',
    		  'август',
    		  'сентябрь',
    		  'октябрь',
    		  'ноябрь',
    		  'декабрь');
      return $aMonth[$month - 1];
    }
    
    function gen_months_list()
    {
    	global $monthnum;
    	$year = date("Y");
    	
    	for($month = 1; $month <= 12; $month++)
    	{
    		if($month <= 9)
    		{
    			if("0".$month == $monthnum) $mn_active = " class=\"active\"";
    			$month_list .= "<li><a href=\"/".$year."/0".$month."/\"".$mn_active.">".getRusMonth($month)."</a></li>\n";
    		}
    		else
    		{
    			if($month == $monthnum) $mn_active = " class=\"active\"";
    			$month_list .= "<li><a href=\"/".$year."/".$month."/\"".$mn_active.">".getRusMonth($month)."</a></li>\n";
    		}
    		$mn_active = "";
    	}
    	
    	return $month_list;
    }
    ?>

    V 2.0

    varg242, 25 Февраля 2012

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

    +157

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    $comment_msg=$row['comm'];
    $comment_msg=cuthtml($comment_msg);
    $comment_msg=cutbb($comment_msg);
    $comment_msg=wordwrap($comment_msg, 10, " ", 1);
    $comment_msg=viewworld($comment_msg,4).$massparam['lastend'];

    Один фрагмент из кучки говнокода, относительно популярного скрипта комментариев commentit

    dayw, 23 Февраля 2012

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

    +157

    1. 1
    2. 2
    3. 3
    4. 4
    //*****************************************************************************
    //************** ВНИМАНИЕ! ДАЛЬШЕ ИДЕТ СТРАШНЫЙ СТАРЫЙ КОД! *****************
    //**************** ОДЕНЬТЕ СКАФАНДР ПРИ ВХОДЕ В ЭТУ ЗОНУ! *******************
    //*****************************************************************************

    http://habrahabr.ru/js/1329490138/system.js

    kafeman, 20 Февраля 2012

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

    +157

    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
    function othercomplaints () 
    {
            if (window.document.Profiles.OtherComplaints !== undefined)
            if (window.document.Profiles.OtherComplaints.checked) {        
                    for (i=1;i<=20;i++) {
                            eval("document.getElementById('otherc"+i+"').style.display = 'block';");
                    }
            } else {
                    for (i=1;i<=20;i++) {                                           
                            eval("document.getElementById('otherc"+i+"').style.display = 'none';");
                    }
            }
    }

    Hits, 16 Февраля 2012

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