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

    +5

    1. 1
    2. 2
    3. 3
    4. 4
    function is_assoc( $array ) {
    
    	return is_array($array) && substr( json_encode($array), 0, 1 ) == '{';
    }

    bot, 26 Июля 2016

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

    −4

    1. 1
    Можно, я похерю Вам настроение?

    Можно, я похерю Вам настроение?

    CRITICAL_ERROR, 25 Июля 2016

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

    +7

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    function redirect($url)
    {
    	header('Location:'.$url);
    	echo '<script>document.location.href = \''.$url.'\';</script>';
    	exit;
    }

    eskrano, 24 Июля 2016

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

    +7

    1. 1
    github.com/natribu/natribu.org

    Исходники официального сайта нахуй, жесть

    dm_fomenok, 22 Июля 2016

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

    0

    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
    function CheckPropertyForSend(&$fields) {
        if ($fields["IBLOCK_ID"] == CATALOG_ID) {
            $arFilter = array("IBLOCK_ID" =>CATALOG_ID, "ID"=>$fields["ID"], "PROPERTY_NOT_ALLOWED" =>92);
            $res = CIBlockElement::GetList(Array(), $arFilter);
    
            if($res->SelectedRowsCount() == 1){
                $GLOBALS['NEED_CHECK'] = true;
            }else{
                $GLOBALS['NEED_CHECK'] = false;
            }
    
            $prod = LenalHelp::getProductInfo($fields["ID"]);
            $count = 0;
            $cheked = ( $fields["PROPERTY_VALUES"][580][0]["VALUE"] == 92 ) ? true : false;
            foreach ( $prod["STORES"] as $item ) {
                if ( $item["PRODUCT_AMOUNT"] ) {
                    $count += $item["PRODUCT_AMOUNT"];
                }
            }
    
            // -- убираем фдаг "нет в наличии" ---
            if ( $count > 0 && $cheked ) {
                $fields["PROPERTY_VALUES"][580] = "";
            }
            // -- устанавливаем фдаг "нет в наличии" ---
            if ( $count == 0 && !$cheked ) {
                $fields["PROPERTY_VALUES"][580][0]["VALUE"] = 92;
            }
    
        }
    }

    Платформа Битрикс, Lenal гребанные ублюдки

    lscin, 22 Июля 2016

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

    +2

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    11. 11
    <?if( $arResult['PROPERTIES']['NOT_ALLOWED']['VALUE'] == 'да' || $arItem["PROPERTIES"]["NOT_ALLOWED"]["VALUE_XML_ID"] == "Y" ) { ?>
    				<div class="alert-empty alert--licence">
    					<?$APPLICATION->IncludeComponent(
    						"bitrix:main.include",
    						"",
    						Array(
    							"AREA_FILE_SHOW" => "file",
    							"PATH" => SITE_DIR."/inc/card_not_allowed.php",
    							"EDIT_TEMPLATE" => ""
    						)
    					);?>

    Платформа Битрикс, очередное творение Lenal в шаблоне компонента.

    Сравнение значения с КИРИЛИЦЕЙ в template.php.

    lscin, 22 Июля 2016

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

    −3

    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
    89. 89
    90. 90
    91. 91
    92. 92
    93. 93
    94. 94
    <?php
    
    if(!class_exists('avia_breadcrumb'))
    {
    	class avia_breadcrumb
    	{
    		var $options;
    
    	function __construct($options = ""){
    
    		$this->options = array( 	//change this array if you want another output scheme
    		'before' => '<span class="arrow"> ',
    		'after' => ' </span>',
    		'delimiter' => '&raquo;'
    		);
    
    		if(is_array($options))
    		{
    			$this->options = array_merge($this->options, $options);
    		}
    
    
    		$markup = $this->options['before'].$this->options['delimiter'].$this->options['after'];
    
    		global $post;
    		echo '<p class="breadcrumb"><span class="breadcrumb_info">'.__('You are here:','avia_framework').'</span> <a href="'.get_bloginfo('url').'">';
    			bloginfo('name');
    			echo "</a>";
    			if(!is_front_page()){echo $markup;}
    
    			$output = $this->simple_breadcrumb_case($post);
    
    			echo "<span class='current_crumb'>";
    			if ( is_page() || is_single()) {
    			the_title();
    			}else{
    			echo $output;
    			}
    			echo " </span></p>";
    		}
    
    		function simple_breadcrumb_case($der_post)
    		{
    			global $post;
    
    			$markup = $this->options['before'].$this->options['delimiter'].$this->options['after'];
    			if (is_page()){
    				 if($der_post->post_parent) {
    					 $my_query = get_post($der_post->post_parent);
    					 $this->simple_breadcrumb_case($my_query);
    					 $link = '<a href="';
    					 $link .= get_permalink($my_query->ID);
    					 $link .= '">';
    					 $link .= ''. get_the_title($my_query->ID) . '</a>'. $markup;
    					 echo $link;
    				  }
    			return;
    			}
    
    		if(is_single())
    		{
    			$category = get_the_category();
    			if (is_attachment()){
    
    				$my_query = get_post($der_post->post_parent);
    				$category = get_the_category($my_query->ID);
    
    				if(isset($category[0]))
    				{
    					$ID = $category[0]->cat_ID;
    					$parents = get_category_parents($ID, TRUE, $markup, FALSE );
    					if(!is_object($parents)) echo $parents;
    					previous_post_link("%link $markup");
    				}
    
    			}else{
    
    				$postType = get_post_type();
    
    				if($postType == 'post')
    				{
    					$ID = $category[0]->cat_ID;
    					echo get_category_parents($ID, TRUE, $markup, FALSE );
    				}
    				else if($postType == 'portfolio')
    				{
    					$terms = get_the_term_list( $post->ID, 'portfolio_entries', '', '$$$', '' );
    					$terms = explode('$$$',$terms);
    					echo $terms[0].$markup;
    
    				}
    			}
    		return;
    		}

    Собственно вся суть, 2а раза генерируются, смотрел в функшин где написан код, все чисто, но все равно 2а раза генерируется

    Получается грубо говоря:

    You here: Home / <b>Hello world</b> / %category% / <b>Hello world</b>

    Не могли бы помочь. Или куда смотреть, был бы благодарен.

    olee444, 21 Июля 2016

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

    +2

    1. 001
    2. 002
    3. 003
    4. 004
    5. 005
    6. 006
    7. 007
    8. 008
    9. 009
    10. 010
    11. 011
    12. 012
    13. 013
    14. 014
    15. 015
    16. 016
    17. 017
    18. 018
    19. 019
    20. 020
    21. 021
    22. 022
    23. 023
    24. 024
    25. 025
    26. 026
    27. 027
    28. 028
    29. 029
    30. 030
    31. 031
    32. 032
    33. 033
    34. 034
    35. 035
    36. 036
    37. 037
    38. 038
    39. 039
    40. 040
    41. 041
    42. 042
    43. 043
    44. 044
    45. 045
    46. 046
    47. 047
    48. 048
    49. 049
    50. 050
    51. 051
    52. 052
    53. 053
    54. 054
    55. 055
    56. 056
    57. 057
    58. 058
    59. 059
    60. 060
    61. 061
    62. 062
    63. 063
    64. 064
    65. 065
    66. 066
    67. 067
    68. 068
    69. 069
    70. 070
    71. 071
    72. 072
    73. 073
    74. 074
    75. 075
    76. 076
    77. 077
    78. 078
    79. 079
    80. 080
    81. 081
    82. 082
    83. 083
    84. 084
    85. 085
    86. 086
    87. 087
    88. 088
    89. 089
    90. 090
    91. 091
    92. 092
    93. 093
    94. 094
    95. 095
    96. 096
    97. 097
    98. 098
    99. 099
    100. 100
    public function addBankAccount(
    						$firstName, $lastName, $companyName, $phone, $addressId, $bankName, $bankSwiftCode, $bankStreet,$bankCity, $bankCountry, $bankState, $bankPostalCode,
    						$bankAccountNumber, $currency, $bankRoutingCode, $accountType, $bankAccountType, $intermediaryName, $intermediaryStreet,
    						$intermediaryCountry, $intermediaryState, $intermediaryCity, $intermediaryPostalCode, $intermediarySwift, $intermediaryCodeBank, $intermediaryFurtherAccount, $intermediaryBank
    						)
    	{
    		$key = md5(sprintf("%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s",
    			$this->encryptedPassword, $firstName, $lastName, $companyName,
    			$phone, $addressId, $bankName, $bankSwiftCode, $bankStreet, $bankCity,
    			$bankState, $bankCountry, $bankPostalCode, $bankAccountNumber, 
    			$currency, $bankRoutingCode, $bankAccountType, $accountType, 
    			$intermediaryName, $intermediaryStreet, $intermediaryCountry, 
    			$intermediaryState, $intermediaryCity, $intermediaryPostalCode, 
    			$intermediarySwift, $intermediaryCodeBank, $intermediaryFurtherAccount, $intermediaryBank
    		));
    
    		// Prepare the request
    
    		$req  = sprintf("method=%s", urlencode("addBankAccount"));
    		$req .= sprintf("&fromEmail=%s", urlencode($this->fromEmail));
    		$req .= sprintf("&firstName=%s", urlencode($firstName));
    		$req .= sprintf("&lastName=%s", urlencode($lastName));
    		$req .= sprintf("&companyName=%s", urlencode($companyName));
    		$req .= sprintf("&phone=%s", urlencode($phone));
    		$req .= sprintf("&addressId=%s", urlencode($addressId));
    		$req .= sprintf("&bankName=%s", urlencode($bankName));
    		$req .= sprintf("&bankSwiftCode=%s", urlencode($bankSwiftCode));
    		$req .= sprintf("&bankStreet=%s", urlencode($bankStreet));
    		$req .= sprintf("&bankCity=%s", urlencode($bankCity));
    		$req .= sprintf("&bankCountry=%s", urlencode($bankCountry));
    		$req .= sprintf("&bankState=%s", urlencode($bankState));
    		$req .= sprintf("&bankPostalCode=%s", urlencode($bankPostalCode));
    		$req .= sprintf("&bankAccountNumber=%s", urlencode($bankAccountNumber));
    		$req .= sprintf("&currency=%s", urlencode($currency));
    		$req .= sprintf("&bankRoutingCode=%s", urlencode($bankRoutingCode));
    		$req .= sprintf("&accountType=%s", urlencode($accountType));
    		$req .= sprintf("&bankAccountType=%s", urlencode($bankAccountType));
    		$req .= sprintf("&intermediaryName=%s", urlencode($intermediaryName));
    		$req .= sprintf("&intermediaryStreet=%s", urlencode($intermediaryStreet));
    		$req .= sprintf("&intermediaryCountry=%s", urlencode($intermediaryCountry));
    		$req .= sprintf("&intermediaryState=%s", urlencode($intermediaryState));
    		$req .= sprintf("&intermediarySwift=%s", urlencode($intermediarySwift));
    		$req .= sprintf("&intermediaryCodeBank=%s", $intermediaryCodeBank);
    		$req .= sprintf("&intermediaryFurtherAccount=%s", urlencode($intermediaryFurtherAccount));
    		$req .= sprintf("&intermediaryBank=%s", $intermediaryBank);
    		$req .= sprintf("&key=%s", urlencode($key));
    
    		// the following two lines are for testing only (in production they should be commented out)
    		//$req .= sprintf("&sandbox=ON");
    		//$req .= sprintf("&return=%s", urlencode("51"));
    
    		$res = $this->process($req);
    
    		// TODO: Parse the response from server and return error code
    		printf("<textarea cols=\"60\" rows=\"10\" wrap=\"off\">\n%s\n</textarea>\n", $res);
    	}
    
    	protected function process($req)
    	{
    		$header  = "POST /payment/api/paymentAPI.php HTTP/1.0\r\n";
    		$header .= "Host: www.paxum.com\r\n";
    		$header .= "Accept: */*\r\n";
    		$header .= "User-Agent: php-agent/1.0\r\n";
    		$header .= "Content-Type: application/x-www-form-urlencoded\r\n";
    		$header .= "Connection: close\r\n";        
    		$header .= "Content-Length: " . strlen($req) . "\r\n\r\n";
    
    		// Make the request to the server
    		// If possible, securely post using HTTPS, your PHP server will need to be SSL enabled
    		$fp = fsockopen ("ssl://www.paxum.com", 443, $errno, $errstr, 30);
    
    		if (!$fp)
    		{
    			// HTTP ERROR
    			return -1;
    		}
    		
    		//echo $req;exit;
    		
    		fputs ($fp, sprintf("%s%s", $header, $req));
    
    		// Read the server response
    
    		$res = "";
    		$headerdone = false;
    		while (!feof($fp))
    		{
    			$line = fgets ($fp, 1024);
    			if (strcmp($line, "\r\n") == 0)
    			{
    				// read the header
    				$headerdone = true;
    			}
    			else if ($headerdone)
    			{
    				// header has been read. now read the contents
    				$res .= $line;
    			}
    		}
            }

    hardcode = true;

    hack3p, 20 Июля 2016

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

    −3

    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
    function formSelect($itxt, $name = '', $val = array(), $selected = 0, $data = 0, $nullF = false, $atr = '', $optatr = array()) {
    	if(is_array($selected)) { $atr .= ' multiple'; }
    	$html = '<select  name="'.$name.'" '.$atr.">\r\n";
    	if($nullF) {
    		$t = ($nullF === true) ? ' ' : $nullF;
    		$html .= '<option value="0">'.$t.'</option>'; }
    	if($data == 3) { $start = $itxt; $count = $val[0]; $step = $val[1]; }
    	else { $count = count($itxt); }
    	for($i = 0; $i < $count; $i++) {
    			// 4 - для быза данных
    		switch($data) {
    			case 1: $key = $val[$i]; $txt = $itxt[$i]; break;
    			case 2: $key = $i; $txt = $itxt[$i]; break;
    			case 3: $txt = $key = ($start + ($step*$i)); break;
    			case 4: $key = $itxt[$i][$val[0]]; $txt = $itxt[$i][$val[1]]; break;
    			default: $key = $txt = $itxt[$i]; break;
    		}
    		$sel = '';
    		if(is_array($selected)) {
    			if(in_array($key, $selected)) { $sel = 'selected'; }
    		} elseif($selected == $key) { $sel = 'selected'; }
    		if(!empty($optatr[$i])) { $opt = $optatr[$i]; } else { $opt = ''; }
    		$html .= '<option value="'.$key.'" '.$sel.$opt.'>'.$txt."</option>\r\n";
    	}
    	$html .= "</select>\r\n";
    	return $html;
    }

    Теперь бызить вореции как никогда просто!

    daniser, 19 Июля 2016

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

    0

    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
    function syn_s_lms_support_get_bl_specific_urls($bl_node) {
        $bl_specific_urls=array();
        $url = field_extract_value('node', $bl_node, 'field_business_website', 'url');
        if (isset($url[0]) && strlen($url[0]) ) {
            $bl_specific_urls[] = $url[0];
        }
        $url = field_extract_value('node', $bl_node, 'field_business_yelp', 'url');
        if (isset($url[0]) && strlen($url[0]) ) {
            $bl_specific_urls[] = $url[0];
        }
        $url = field_extract_value('node', $bl_node, 'field_business_gplus', 'url');
        if (isset($url[0]) && strlen($url[0]) ) {
            $bl_specific_urls[] = $url[0];
        }
        $url = field_extract_value('node', $bl_node, 'field_business_facebook', 'url');
        if (isset($url[0]) && strlen($url[0]) ) {
            $bl_specific_urls[] = $url[0];
        }
        $twitname = field_extract_value('node', $bl_node, 'field_business_twitter');
        if ($twitname) {
            $twit_name_clean = str_replace("@", '',  $twitname);
            $bl_specific_urls[] = 'https://twitter.com/' . $twit_name_clean;
        }
        return $bl_specific_urls;
    }

    Давай, ман не читай,
    код пиши от души.

    zima, 15 Июля 2016

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