1. PHP / Говнокод #10940

    +62

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    if(isset($_GET['show_all'])){
    		set_query('show_all=','',true);
    		$show_all = true;
    		$Register->set('show_all', $show_all);
    }

    Найдено в WebAsyst Shop-Script.

    BiggestFox, 13 Июня 2012

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

    +55

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    $i = 0;
    foreach($_POST['union'] as $key=>$value) {
    	$i++;
    	if ($i == 1) {
    		$fid = $key;
    	}
    	if ($i > 1) {
    		[код поскипан]
    	}
    }

    Ну почему не используется if { } else { }?

    domaster, 13 Июня 2012

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

    +69

    1. 1
    $file[] = $_FILES[''.$key.''];

    Подобное "приведение типов (?)" для $key просто убивает. Размазано по всему проекту...

    domaster, 13 Июня 2012

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

    +52

    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
    <?if (!defined("B_PROLOG_INCLUDED") || B_PROLOG_INCLUDED!==true)die();?>
    <?if (!empty($arResult)):?>
    <ul id="horizontal-multilevel-menu">
    <?
    $previousLevel = 0;
    foreach($arResult as $arItem):?>
    	<?if ($previousLevel && $arItem["DEPTH_LEVEL"] < $previousLevel):?>
    		<?=str_repeat("</ul></li>", ($previousLevel - $arItem["DEPTH_LEVEL"]));?>
    	<?endif?>
    	<?if ($arItem["IS_PARENT"]):?>
    		<?if ($arItem["DEPTH_LEVEL"] == 1):?>
    			<li><a href="<?=$arItem["LINK"]?>" class="<?if ($arItem["SELECTED"]):?>root-item-selected<?else:?>root-item<?endif?>"><?=$arItem["TEXT"]?></a>
    				<ul>
    		<?else:?>
    			<li<?if ($arItem["SELECTED"]):?> class="item-selected"<?endif?>><a href="<?=$arItem["LINK"]?>" class="parent"><?=$arItem["TEXT"]?></a>
    				<ul>
    		<?endif?>
    	<?else:?>
    		<?if ($arItem["PERMISSION"] > "D"):?>
    			<?if ($arItem["DEPTH_LEVEL"] == 1):?>
    				<li><a href="<?=$arItem["LINK"]?>" class="<?if ($arItem["SELECTED"]):?>root-item-selected<?else:?>root-item<?endif?>"><?=$arItem["TEXT"]?></a></li>
    			<?else:?>
    				<li<?if ($arItem["SELECTED"]):?> class="item-selected"<?endif?>><a href="<?=$arItem["LINK"]?>"><?=$arItem["TEXT"]?></a></li>
    			<?endif?>
    		<?else:?>
    			<?if ($arItem["DEPTH_LEVEL"] == 1):?>
    				<li><a href="" class="<?if ($arItem["SELECTED"]):?>root-item-selected<?else:?>root-item<?endif?>" title="<?=GetMessage("MENU_ITEM_ACCESS_DENIED")?>"><?=$arItem["TEXT"]?></a></li>
    			<?else:?>
    				<li><a href="" class="denied" title="<?=GetMessage("MENU_ITEM_ACCESS_DENIED")?>"><?=$arItem["TEXT"]?></a></li>
    			<?endif?>
    		<?endif?>
    	<?endif?>
    	<?$previousLevel = $arItem["DEPTH_LEVEL"];?>
    <?endforeach?>
    <?if ($previousLevel > 1)://close last item tags?>
    	<?=str_repeat("</ul></li>", ($previousLevel-1) );?>
    <?endif?>
    </ul>
    <div class="menu-clear-left"></div>
    <?endif?>

    Очередной говнокод от битрикса. "Генерация" выпадающего горизонтального меню.

    avtorfox, 12 Июня 2012

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

    +141

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    function toArray($xml) {
                    $xml = simplexml_load_string($xml);
                    $json = json_encode($xml);
                    return json_decode($json,TRUE);                        
            }

    Но зачем?!

    mr.The, 11 Июня 2012

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

    +54

    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
    foreach($Articles as $art){
    			$id = $art['id'];
    			$count++;	
    			if(isset($_GET['str'])){
    				$str = (int)$_GET['str']; 
    				$mn = $number*($str-1)+1;
    				}else{
    					$str = 1;
    					$_GET['str'] = 1;
    				}	
    			if($count == $mn){
    				$flag = true;
    				$k=5;
    			}		
    			if($flag && $k!=0){
    				$k--;
    				$title = $art['title'];
    				$content = $art['content'];
    				$author = $art['author'];
    				$date = $art['date'];
    				printf("<h1>%s</h1><br /><h3 align='left'>%s</h3>%s  <a href='index.php?id=articles&str=%s&nomer=%s'>Далее</a><hr /><br />",$title,$date, substr($content, 0,800),$nav, $id);
    					}
    		}

    Постраничная навигация

    BrdNLSrg, 10 Июня 2012

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

    +141

    1. 1
    http://viois.ru/thread.txt

    Приходится признать, что это мой код...

    BiggestFox, 09 Июня 2012

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

    +63

    1. 1
    2. 2
    $ToName = "$user_iname";
    $ToEmail = "$user_email";

    Кавычки-то зачем?

    domaster, 09 Июня 2012

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

    +52

    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
    header( 'Content-Type: text/html; charset=utf-8' );
    
    $year  = date( 'Y' );
    
    $months = array( 1 => 'Январь', 'Фервраль', 'Март', 'Апрель', 'Май', 'Июнь', 'Июль', 'Август', 'Сентябрь', 'Октябрь', 'Ноябрь', 'Декабрь' );
    
    $infoYear = getdate( mktime( 0, 0, 0, 1, 1, $year, 0 ) );
    
    $weekDay = $infoYear['wday'] == 0 ? 7 : $infoYear['wday']; // wday - номер дня недели. 0 - Воскресение. Делаем воскресение седьмым днем.
    
    echo "<h2>$year</h2>";
    
    for ( $month = 1; $month <= 12; $month++ ) {
    	echo '<div style="float: left; padding: 2px;"><b>' . $months[$month] . '</b>';
    	echo '<table border="1">';
    	echo '<th>Пн</th><th>Вт</th><th>Ср</th><th>Чт</th><th>Пт</th><th>Сб</th><th>Вс</th>';
    	echo '<tr>';
    	
    	for ( $day = 1; $day < 31; $day++ ) {
    		
    		if ( checkdate($month, $day, $year) ) {
    			
    			if ( $day == 1 )
    				for ( $i = 1; $i < $weekDay; $i++ )
    					echo '<td> </td>';
    			
    			printf( '<td>%02d</td>', $day );
    			
    			$weekDay++;
    			if ( $weekDay > 7 ) {
    				$weekDay = 1;
    				echo '</tr><tr>';
    			}
    		}
    	}
    	
    	echo '</tr></table></div>';
    }

    Задача: Вывести календарь, для установки нужных дат админом и сохранить их в БД.
    Остается отрефракторить и добавить checkbox'ы.

    psycho-coder, 09 Июня 2012

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

    +65

    1. 1
    $new_array = explode('.sep.', implode('.sep', $old_array));

    Полезная функция с http://www.dzone.com/snippets/re-create-array-index

    Anon8yXubeVu, 08 Июня 2012

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