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

    +151

    1. 1
    2. 2
    3. 3
    error_reporting( 0 );
    
    unset( $x[new XSLTProcessor()][new RecursiveArrayIterator()] );

    __proto__, 13 Февраля 2014

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

    +138

    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
    private function toDBFields($fields){
    			$db_fields = array();
    			if ($fields){
    				foreach($fields as $field){
    					switch ($field){
    
                            case 'p_bits':
                                if (!array_search('b1',$db_fields))	$db_fields[] = 'b1';
                                break;
                            case 'n2':
                                if (!array_search('b1',$db_fields))	$db_fields[] = 'b1';
                                break;
                            case 'n1':
                                if (!array_search('b1',$db_fields))	$db_fields[] = 'b1';
                                break;
    						case 'cntdf':
    							if (!array_search('cntdf',$db_fields))	$db_fields[] = 'cntdf';
    							break;
    						case 'first_pckg':
    						
    							break;
    						case 'az':
    							if (!array_search('az',$db_fields))		$db_fields[] = 'az';
    							break;
    						case 'akb_v':
    							//if (!array_search('b2',$db_fields))		$db_fields[] = 'b2';
    							if (!array_search('b3',$db_fields))		$db_fields[] = 'b3';
    							break;
    						case 'p1code':
                            case 'ignition_ap1':
    							if (!array_search('b4',$db_fields))		$db_fields[] = 'b4';
    							if (!array_search('b6',$db_fields))		$db_fields[] = 'b6';
    							break;
    						case 'fuel_p2':
                            case 'fuel_p2_debug':
                            case 'p2code':
    							if (!array_search('b5',$db_fields))		$db_fields[] = 'b5';
    							if (!array_search('b6',$db_fields))		$db_fields[] = 'b6';
    							break;
                            case 'fuel_p3':
                            case 'fuel_p3_debug':
    						case 'p3code':
                            case 'p3code_debug':
    							if (!array_search('b7',$db_fields))		$db_fields[] = 'b7';
    							if (!array_search('b6',$db_fields))		$db_fields[] = 'b6';
    							break;
                            case 'fuel_p3p4_2drt':
                                if (!array_search('b8',$db_fields))		$db_fields[] = 'b8';
    							if (!array_search('b7',$db_fields))		$db_fields[] = 'b7';
    							if (!array_search('b6',$db_fields))		$db_fields[] = 'b6';
    							break;
                            case 'fuel_p2p3':
                                if (!array_search('b5',$db_fields))		$db_fields[] = 'b5';
    							if (!array_search('b7',$db_fields))		$db_fields[] = 'b7';
    							if (!array_search('b6',$db_fields))		$db_fields[] = 'b6';
    							break;
                            case 'fuel_p4':
                            case 'p4code_debug':
    						case 'p4code':
    							if (!array_search('b8',$db_fields))		$db_fields[] = 'b8';
    							if (!array_search('b6',$db_fields))		$db_fields[] = 'b6';
    							break;
    					}
    				}
    			}
    
    			return $db_fields;

    Вот такой кейс который используется в системе для перевода типа переменной к названию поле в таблице ....

    Deimm, 13 Февраля 2014

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

    +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
    46. 46
    47. 47
    48. 48
    49. 49
    50. 50
    51. 51
    52. 52
    53. 53
    <?php
    session_start();
    include("database.php");
    include("filter.php");
    $filter = new Filter();
    isset($_GET['cat']) ? $id = $filter->Symbols($_GET['cat']) : exit("Вы зашли на страницу без параметра!");
    	
    if ( !isset($_POST['class']) && empty($_POST['class']) )
    {
    	include('header.php');
    	echo '
    		<title>Title</title>
    	';
    	include('slider.php');
    	echo '
    	<div id="Content">
    	';
    }
    
    $query_amount = $mysqli->query("SELECT COUNT(id) FROM `page_film` WHERE `genre_film`='$id' ");
    $amount_film = $query_amount->fetch_row();
    
    $query = $mysqli->query("SELECT * FROM `page_film` WHERE `genre_film`='$id' ORDER BY `id` DESC ");
    
    if ( $amount_film[0] > 0 )
    	while( $row = $query->fetch_array(MYSQLI_ASSOC) )
    		echo '
    			<div class="block-film">
    				<a class="block-link-image" href="../films/film.php?id='.$row['id'].'">
    					<img src="'.$row['poster'].'" />
    				</a>
    				<div class="block-film-text">
    					<p class="film-name">
    						<a href="../films/film.php?id='.$row['id'].'">'.$row['title'].'</a>
    					</p>
    					<p class="film-mini-name">
    						<a href="../films/film.php?id='.$row['id'].'">'.$row['desc'].'</a>
    					</p>
    					<p class="film-genre"><span>'.$row['genre'].'</span></p>
    					<p class="film-description">'.$row['description'].'</p>
    				</div>
    			</div>
    		';
    
    if ( !isset($_POST['class']) && empty($_POST['class']) )
    {
    	echo '	
    	</div>
    </body>
    </html>
    	';
    }
    ?>

    alexkor, 13 Февраля 2014

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

    +160

    1. 1
    2. 2
    if ($_SESSION["spo_filter_history"]=="Y")
    		$_REQUEST["filter_history"] == "Y";

    Bitrix. sale.personal.order.list
    А я еще удивлялся "какого хуя фильтр не работает?"

    TBoolean, 12 Февраля 2014

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

    +100

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    <?php
    $a=0;
    $b=null;
     
    echo $a==$b?1:0; //1

    Разрабы пхп троллят.

    Vasiliy, 11 Февраля 2014

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

    +154

    1. 1
    /^(?!\s)[a-zA-Z0-9\x2d-\x2f\x7f-\xff_-\s]+(?!\s)$/

    Регулярочка из Modx. После обновления PCRE до последней версии перестала восприниматься как валидная. Недоумеваем, что имели в виду, задавая диапазон "_-\s" и как оно работало раньше.

    Lblss, 11 Февраля 2014

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

    +154

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    11. 11
    $this->db->insert("orders", $data);
    
            //Get order's id
            $this->db->select("orders_id");
            $this->db->where('orders_customer_tel', $data['tel']);
            $this->db->order_by("orders_id", "desc");
            $this->db->limit(1);
            $query = $this->db->get("orders");
            foreach ($query->result_array() as $res) {
                $orders_id = $res['orders_id'];
            }

    Ништяяяк!

    ragnar, 10 Февраля 2014

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

    +153

    1. 1
    2. 2
    3. 3
    <?if($_POST["is_ajax_post"] != "Y"){?>				
    					<input type="hidden" name="is_ajax_post" id="is_ajax_post" value="Y">    			        
    <? }  ?>

    Форма оформления заказа в компоненте sale.order.ajax. Bitrix. Логика.

    TBoolean, 06 Февраля 2014

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

    +140

    1. 1
    ЗА РУСЬ!!!

    Horse3, 04 Февраля 2014

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

    +142

    1. 1
    Травля "kegdan`a" объявляется открытой.

    Horse3, 04 Февраля 2014

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