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

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

    +31

    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
    if(!$_SESSION["subscribe_user"]){
    
    		   $arr_subscribes = unserialize('a:94:{i:212;s:3:"212";i:228;s:3:"228";i:302;s:3:"302";i:304;s:3:"304";i:322;s:3:"322";i:354;s:3:"354";i:366;s:3:"366";i:382;s:3:"382";i:402;s:3:"402";i:406;s:3:"406";i:458;s:3:"458";i:484;s:3:"484";i:492;s:3:"492";i:548;s:3:"548";i:564;s:3:"564";i:572;s:3:"572";i:622;s:3:"622";i:646;s:3:"646";i:700;s:3:"700";i:706;s:3:"706";i:714;s:3:"714";i:716;s:3:"716";i:718;s:3:"718";i:730;s:3:"730";i:740;s:3:"740";i:746;s:3:"746";i:766;s:3:"766";i:770;s:3:"770";i:816;s:3:"816";i:826;s:3:"826";i:832;s:3:"832";i:834;s:3:"834";i:852;s:3:"852";i:884;s:3:"884";i:894;s:3:"894";i:914;s:3:"914";i:920;s:3:"920";i:982;s:3:"982";i:988;s:3:"988";i:1010;s:4:"1010";i:1194;s:4:"1194";i:1456;s:4:"1456";i:1528;s:4:"1528";i:1598;s:4:"1598";i:1644;s:4:"1644";i:1828;s:4:"1828";i:1938;s:4:"1938";i:1942;s:4:"1942";i:1990;s:4:"1990";i:2130;s:4:"2130";i:2154;s:4:"2154";i:2250;s:4:"2250";i:2272;s:4:"2272";i:2338;s:4:"2338";i:2714;s:4:"2714";i:2798;s:4:"2798";i:2892;s:4:"2892";i:3018;s:4:"3018";i:3178;s:4:"3178";i:3181;s:4:"3181";i:3182;s:4:"3182";i:43;s:2:"43";i:23;s:2:"23";i:25;s:2:"25";i:26;s:2:"26";i:27;s:2:"27";i:28;s:2:"28";i:2;s:1:"2";i:67;s:2:"67";i:74;s:2:"74";i:70;s:2:"70";i:72;s:2:"72";i:13;s:2:"13";i:14;s:2:"14";i:15;s:2:"15";i:16;s:2:"16";i:17;s:2:"17";i:18;s:2:"18";i:19;s:2:"19";i:20;s:2:"20";i:21;s:2:"21";i:22;s:2:"22";i:52;s:2:"52";i:66;s:2:"66";i:68;s:2:"68";i:36;s:2:"36";i:37;s:2:"37";i:38;s:2:"38";i:39;s:2:"39";i:40;s:2:"40";i:41;s:2:"41";i:42;s:2:"42";i:76;s:2:"76";i:78;s:2:"78";}');
    
    			$subscr=new subscribe_new();
    			$subscr->GetUserSubscr();
    
    			if(!count($subscr->user_subscribes)){
    				$subscr->user2subscr_table = 'utos';
    				$sql="select subscribe.* from subscribe LEFT JOIN enterprises ON enterprises.id=subscribe.enterprise where subscribe.visible='Y' AND (subscribe.enterprise = 0 OR enterprises.visible = 'Y') order by priority desc, week_day,id";
    				$res=@mysql_db_query($DB,$sql);
    				$all_subscribe=array();
    				while ($row=@mysql_fetch_assoc($res)):
    					$subscr->all_subscribes[$row["id"]]=$row;
    
    				endwhile;
    				
    				$q = $subscr->UpdateSubscr($arr_subscribes);
    				#print_r($arr_subscribes);
    				
    				#exit;
    			}
    
    	   }

    ну хрясь чтоле

    brainstorm, 07 Апреля 2014

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

    +152

    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
    75. 75
    76. 76
    77. 77
    78. 78
    79. 79
    80. 80
    81. 81
    82. 82
    83. 83
    84. 84
    85. 85
    86. 86
    87. 87
    88. 88
    $manufacturer_id = JRequest::getInt('manufacturer_id');
                $label_id = JRequest::getInt('label_id');
                $vendor_id = JRequest::getInt('vendor_id');
               
                $view_name = "cart";
                $view_config = array("template_path"=>JPATH_COMPONENT."/templates/".$jshopConfig->template."/".$view_name);
                $view = $this->getView($view_name, getDocumentType(), '', $view_config);
                        if ($category->category_template=="") $category->category_template="default";
                $view->setLayout("category_".$category->category_template);        
         
                $jshopConfig->count_products_to_page = $category->products_page;
         
                $context = "jshoping.list.front.product";
                $contextfilter = "jshoping.list.front.product.cat.".$category_id;
                $orderby = $mainframe->getUserStateFromRequest( $context.'orderby', 'orderby', $jshopConfig->product_sorting_direction, 'int');
                $order = $mainframe->getUserStateFromRequest( $context.'order', 'order', $jshopConfig->product_sorting, 'int');
                $limit = $mainframe->getUserStateFromRequest( $context.'limit', 'limit', $category->products_page, 'int');
                if (!$limit) $limit = $category->products_page;
                $limitstart = JRequest::getInt('limitstart');
         
                $orderbyq = getQuerySortDirection($order, $orderby);
                $image_sort_dir = getImgSortDirection($order, $orderby);
                $field_order = $jshopConfig->sorting_products_field_select[$order];
                $filters = getBuildFilterListProduct($contextfilter, array("categorys"));
                $orderfield = $jshopConfig->category_sorting==1 ? "ordering" : "name";
                $sub_categories = $category->getChildCategories($orderfield, 'asc', $publish = 1);
                $dispatcher->trigger( 'onBeforeDisplayCategory', array(&$category, &$sub_categories) );
         
                if ($category->meta_title=="") $category->meta_title = $category->name;
                setMetaData($category->meta_title, $category->meta_keyword, $category->meta_description);
               
                $total = $category->getCountProducts($filters);
                $action = xhtmlUrl($_SERVER['REQUEST_URI']);
                       
                        $dispatcher->trigger('onBeforeFixLimitstartDisplayProductList', array(&$limitstart, &$total, 'category'));
                if ($limitstart>=$total) $limitstart = 0;
         
                $products = $category->getProducts($filters, $field_order, $orderbyq, $limitstart, $limit);
                        addLinkToProducts($products, $category_id);
         
                jimport('joomla.html.pagination');
                $pagination = new JPagination($total, $limitstart, $limit);
                $pagenav = $pagination->getPagesLinks();
               
                foreach($jshopConfig->sorting_products_name_select as $key=>$value){
                    $sorts[] = JHTML::_('select.option', $key, $value, 'sort_id', 'sort_value' );
                }
         
                insertValueInArray($category->products_page, $jshopConfig->count_product_select); //insert category count
                foreach ($jshopConfig->count_product_select as $key => $value){
                    $product_count[] = JHTML::_('select.option',$key, $value, 'count_id', 'count_value' );
                }
                $sorting_sel = JHTML::_('select.genericlist', $sorts, 'order', 'class = "inputbox" size = "1" onchange = "submitListProductFilters()"','sort_id', 'sort_value', $order );
                $product_count_sel = JHTML::_('select.genericlist', $product_count, 'limit', 'class = "inputbox" size = "1" onchange = "submitListProductFilters()"','count_id', 'count_value', $limit );
               
                $_review = JTable::getInstance('review', 'jshop');
                $allow_review = $_review->getAllowReview();
               
                if (!$category->category_ordertype) $category->category_ordertype = 1;
               
                $manufacuturers_sel = '';
                if ($jshopConfig->show_product_list_filters){
                    $filter_manufactures = $category->getManufacturers();
                    $first_manufacturer = array();
                    $first_manufacturer[] = JHTML::_('select.option', 0, _JSHOP_ALL, 'id', 'name');
                    if (isset($filters['manufacturers'][0])){
                        $active_manufacturer = $filters['manufacturers'][0];            
                    }else{
                        $active_manufacturer = 0;
                    }
                    $manufacuturers_sel = JHTML::_('select.genericlist', array_merge($first_manufacturer, $filter_manufactures), 'manufacturers[]', 'class = "inputbox" onchange = "submitListProductFilters()"','id', 'name', $active_manufacturer);
                }
                $display_list_products = (count($products)>0 || willBeUseFilter($filters));
         
                $dispatcher->trigger('onBeforeDisplayProductList', array(&$products));
                $view->assign('config', $jshopConfig);
                $view->assign('template_block_list_product', "cart/list_products.php");
                $view->assign('template_block_form_filter', "cart/form_filters.php");
                $view->assign('template_block_pagination', "cart/block_pagination.php");
                $view->assign('path_image_sorting_dir', $jshopConfig->live_path.'images/'.$image_sort_dir);
                $view->assign('filter_show_category', 0);
                $view->assign('display_pagination', $pagenav!="");
                $view->assign('rows', $products);
                $view->assign('count_product_to_row', $category->products_row);
                $view->assign('filters', $filters);
                $view->assign('display_list_products', $display_list_products);
                $view->assign('shippinginfo', SEFLink($jshopConfig->shippinginfourl,1));
                $view->display();

    Все это (пришлось еще отрезать строк 30) нужно таскать за собой для вывода списка товаров в нестандартном месте. При этом оно лежит в контроллере.
    Полный код: http://pastebin.com/jTj83ZpE
    (joomshopping)

    attn, 03 Апреля 2014

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

    −403

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    11. 11
    12. 12
    - (void)setButtonVisible:(bool)buttonVisible
    {
        if(isIpad)
        {
            id(*superSuperButtonVisible)(id, SEL, ...) = [[[self superclass] superclass] instanceMethodForSelector:@selector(setButtonVisible:)];
            superSuperButtonVisible(self, _cmd, buttonVisible);
        }
        else
        {
            [super setButtonVisible:buttonVisible];
        }
    }

    Угу, нет тут множественного наследования. Приходится наследоваться по очереди, а потом вызывать функции через одного.

    tirinox, 03 Апреля 2014

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

    +156

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    if ($static['filter.date.start'] == 'NULL') {
        $static['filter.date.start'] = null;
    }
    if ($static['filter.date.end'] == 'NULL') {
        $static['filter.date.end'] = null;
    }

    В коде столкнулся таким оригинальным хранением пустого значения :D
    пришлось немного подкостылять чтобы empty() хотя бы работала :)

    smpl, 02 Апреля 2014

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

    +147

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    11. 11
    12. 12
    do
    echo $fun
    $fun = $sand + $sand
    $sand = $sand +1
    echo $sand."is not".$var
    $var = $sand + $fun
    $deer = 23
    while($deer==23)
    if($var==445)
    {
     $fun==2
    }

    Из моих наработок для BrowserFucker

    Getup1NEW, 30 Марта 2014

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

    +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
    postToAgent: function(n) {
    	var _this = this,
    	i = _this.arCache.decIndex,
    	dlgText = '......'; //тут текст убран, чтоб не злить дядек.
    
    	$('#paydataform').attr('action', _this.arPayAgentsList[n].target);
    	$('#paydataform').append('<input type="hidden" name="postdate" value="'+ _this.arDecisList[i].DatePost +'"/>');
    	$('#paydataform').append('<input type="hidden" name="postnum" value="'+ _this.arDecisList[i].NumPost +'"/>');
    	$('#paydataform').append('<input type="hidden" name="postsum" value="'+ _this.arDecisList[i].Summa +'"/>');
    	$('#paydataform').append('<input type="hidden" name="divid" value="'+ _this.arDecisList[i].Division +'"/>');
    	$('#paydataform').append('<input type="hidden" name="uin" value="'+ _this.arDecisList[i].SupplierBillID +'"/>');
    	$('#paydataform').append('<input type="hidden" name="'+_this.arPayAgentsList[n].addpnam+'" value="'+ _this.arPayAgentsList[n].addpval +'"/>');
    		
    	if(confirm(dlgText)) {
    		$('#paydataform').submit();
    		var wnd = BX.WindowManager.Get();
    		if(wnd && !wnd.unclosable)wnd.Close();
    	}
    },

    - Сериализация и jQuery.post
    - Не слышал

    n0cte, 21 Марта 2014

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

    −123

    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
    private var _index:int;
    
    [XmlAttribute]
    [Bindable(event="indexChanged")]
    public function get index():int
    {
    	return deck.slides.getItemIndex(this) + 1;
    }
    
    public function set index(value:int):void
    {
    	_index = value;
    }
    
    private function getIndex(time:Number):int
    {
    	return MathAndGeometryUtils.roundToHalf(time) * 2;
    }
    
    private function getTime(index:int):Number
    {
    	return index / 2;
    }

    Эркюль Пуаро нервно набивает трубку табаком.

    wvxvw, 19 Марта 2014

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

    +157

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    // Чистим мусор и дубликаты
    foreach ($phones as $i => $p1){
        foreach ($phones as $j => $p2){
            if ($i = $j) continue;
            ...

    Все же и я наступил на эти грабли.

    DIX315, 19 Марта 2014

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

    +154

    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
    <?php
    for($tb=0;$tb<=10;$tb++){
    switch($tb){
    case 0: $number_table=3; $cros_table=20;
    break;
    case 1:$number_table+=19; $cros_table+=20;
    break;
    case 2:$number_table+=20; $cros_table+=20;
    break;
    case 3:$number_table+=20; $cros_table+=20;
    break;
    case 4:$number_table+=20; $cros_table+=20;
    break;
    case 5:$number_table+=20; $cros_table+=20;
    break;
    case 6:$number_table+=20; $cros_table+=20;
    break;
    case 7:$number_table+=20; $cros_table+=20;
    break;
    case 8:$number_table+=20; $cros_table+=20;
    break;
    case 9:$number_table+=20; $cros_table+=20;
    break;
    case 10:$number_table+=20; $cros_table+=20;
    break;
    }
    
    for($i=$number_table; $i<=$cros_table; $i++){
    $name_detail = $data->sheets[$global_page]['cells'][$i][1];
    $option_detail = $data->sheets[$global_page]['cells'][$i][2];
    $mark_detail = $data->sheets[$global_page]['cells'][$i][3];
    $actions = $data->sheets[$global_page]['cells'][$i][4];
    $work_cost = $data->sheets[$global_page]['cells'][$i][5];
    $detail_cost = $data->sheets[$global_page]['cells'][$i][6];
    if($name_detail==null){break;}
    ?>

    Когда я это узрел я усомнился в адекватности человека...

    masashama, 19 Марта 2014

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

    +154

    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
    class Key{
    	private $chars = array('1'=>'a','2'=>'b','3'=>'c','4'=>'d','5'=>'e','6'=>'f','7'=>'g','8'=>'h','9'=>'i');
    	private $invChars = array('9'=>'a','8'=>'b','7'=>'c','6'=>'d','5'=>'e','4'=>'f','3'=>'g','2'=>'h','1'=>'i');
    	private $key = "";
    	private $numbers = array();
    
    	public function createKey(){
    		for($a=0;$a<4;$a++){
    			$this->numbers[0] = rand(1, 9);
    			$this->numbers[1] = rand(1, 9);
    			$this->key .= $this->numbers[0].$this->invChars[$this->numbers[1]].$this->numbers[1].$this->chars[$this->numbers[0]]."-";
    		}
    		return substr_replace($this->key, '', 19, 1);
    	}
    
    	public function checkKey($key){
    		if(preg_match("/^([1-9][a-iA-I][1-9][a-iA-I][\-][1-9][a-iA-I][1-9][a-iA-I][\-][1-9][a-iA-I][1-9][a-iA-I][\-][1-9][a-iA-I][1-9][a-iA-I])$/", $key)){
    			$key = str_replace('-', '', $key);
    			if($this->chars[$key[0]] == $key[3] && $this->invChars[$key[2]] == $key[1]){
    				if($this->chars[$key[4]] == $key[7] && $this->invChars[$key[6]] == $key[5]){
    					if($this->chars[$key[8]] == $key[11] && $this->invChars[$key[10]] == $key[9]){
    						if($this->chars[$key[12]] == $key[15] && $this->invChars[$key[14]] == $key[13]){
    							return true;
    						}
    						else{
    							return false;
    						}
    					}
    					else{
    						return false;
    					}
    				}
    				else{
    					return false;
    				}
    			}
    			else{
    				return false;
    			}
    		}
    		else{
    			return false;
    		}
    	}
    }

    Особенно регулярка...

    makssof, 14 Марта 2014

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