1. Поиск говнокода

    Этот поиск практически ничего не может найти! Но вы всё-таки попытайтесь, вдруг повезет.

    Найдено: 41

  2. JavaScript / Говнокод #17707

    +158

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    7. 7
    8. 8
    9. 9
    <p><!-- Need to do some UI cleanup --><br>
                    <script type="text/javascript">// <![CDATA[
                        document.getElementById("badge-images").style.visibility = "hidden";
                        document.getElementById("about-contact").style.visibility = "hidden";
                        document.getElementById("header-menu").style.visibility = "hidden";
                        var hideContactDetails = true;
                        // ]]&gt;</script>
                    <br>
                </p>

    Недавно один Java-pазработчик не смог разобраться, как пофиксеть баг в WordPress и решил переписать наш корпоративный сайт на Java мотивируя это тем, что будет намного легче поддерживать и развивать новую ситсему. Что из этого получилось видно на наглядном примере наложение стилей на элементы страницы(верстка).

    etual, 27 Февраля 2015

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

    +164

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    function maybe_unserialize( $original ) {
            if ( is_serialized( $original ) ) // don't attempt to unserialize data that wasn't serialized going in
                    return @unserialize( $original );
            return $original;
    }

    Wordpress <3
    is_serialized тоже блещет
    https://core.trac.wordpress.org/browser/tags/4.1/src/wp-includes/functions.php#L265

    Fike, 15 Января 2015

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

    +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
    switch($step) {
            case 0:
                    setup_config_display_header();
    ?>
    <p><?php _e( 'Welcome to WordPress. Before getting started, we need some information on the database. You will need to know the following items before proceeding.' ) ?></p>
    <ol>
            <li><?php _e( 'Database name' ); ?></li>
            <li><?php _e( 'Database username' ); ?></li>
            <li><?php _e( 'Database password' ); ?></li>
            <li><?php _e( 'Database host' ); ?></li>
            <li><?php _e( 'Table prefix (if you want to run more than one WordPress in a single database)' ); ?></li>
    </ol>
    <p><strong><?php _e( "If for any reason this automatic file creation doesn’t work, don’t worry. All this does is fill in the database information to a configuration file. You may also simply open <code>wp-config-sample.php</code> in a text editor, fill in your information, and save it as <code>wp-config.php</code>." ); ?></strong></p>
    <p><?php _e( "In all likelihood, these items were supplied to you by your Web Host. If you do not have this information, then you will need to contact them before you can continue. If you’re all ready…" ); ?></p>
    <p class="step"><a href="setup-config.php?step=1<?php if ( isset( $_GET['noapi'] ) ) echo '&noapi'; ?>" class="button button-large"><?php _e( 'Let’s go!' ); ?></a></p>
    <?php
            break;
            case 1:
                    setup_config_display_header();
    //...
            case 2:
            foreach ( array( 'dbname', 'uname', 'pwd', 'dbhost', 'prefix' ) as $key )
                    $$key = trim( wp_unslash( $_POST[ $key ] ) );
            $tryagain_link = '</p><p class="step"><a href="setup-config.php?step=1" onclick="javascript:history.go(-1);return false;" class="button button-large">' . __( 'Try again' ) . '</a>';
            if ( empty( $prefix ) )
                    wp_die( __( '<strong>ERROR</strong>: "Table Prefix" must not be empty.' . $tryagain_link ) );
            // Validate $prefix: it can only contain letters, numbers and underscores.
            if ( preg_match( '|[^a-z0-9_]|i', $prefix ) )
                    wp_die( __( '<strong>ERROR</strong>: "Table Prefix" can only contain numbers, letters, and underscores.' . $tryagain_link ) );
            // Test the db connection.
            /**#@+
             * @ignore
             */
            define('DB_NAME', $dbname);
            define('DB_USER', $uname);
            define('DB_PASSWORD', $pwd);
            define('DB_HOST', $dbhost);
            /**#@-*/
            // We'll fail here if the values are no good.
            require_wp_db();
    
    // еще двести строк свитча с html, обработкой данных прямо на лету и даже небольшим количеством инлайн-js

    Захотел я подцепиться к внутреннему api установки вордпресса, чтобы эту самую установку делать через конфиг-файлы и композер. В результате проще оказалось имитировать окружение веб-сервера, заполнять всякие $_GET-$_POST и просто подключать нужный файл. А как они сами с этим адом работают - для меня остается загадкой

    Целиком https://core.trac.wordpress.org/browser/tags/3.9.2/src/wp-admin/setup-config.php и https://core.trac.wordpress.org/browser/tags/3.9.2/src/wp-admin/install.php

    Fike, 30 Августа 2014

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

    +154

    1. 1
    2. 2
    3. 3
    foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;
    do_action("ws_plugin__s2member_before_paypal_api_response", get_defined_vars());
    unset /* Unset defined __refs, __v. */($__refs, $__v);

    И опять s2member для wordpress

    antongorodezkiy, 24 Апреля 2014

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

    +155

    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
    /**
    * Handles Registration Links.
    *
    * @package s2Member\Registrations
    * @since 3.5
    *
    * @attaches-to ``add_action("init");``
    *
    * @return null Or exits script execution after redirection.
    */
    public static function register ()
    {
    	do_action ("ws_plugin__s2member_before_register", get_defined_vars ());
    
    	if (!empty ($_GET["s2member_register"])) // If they're attempting to access the registration system.
    		{
    			while (@ob_end_clean ()); // Clean any existing output buffers.
    
    			$msg_503 = _x ('<strong>Your Link Expired:</strong><br />Please contact Support if you need assistance.', "s2member-front", "s2member");
    
    			if (is_array ($register = preg_split ("/\:\.\:\|\:\.\:/", c_ws_plugin__s2member_utils_encryption::decrypt (trim (stripslashes ((string)$_GET["s2member_register"]))))))
    				{
    					if (count ($register) === 6 && $register[0] === "subscr_gateway_subscr_id_custom_item_number_time" /* Does the checksum value match up here? */)
    						{
    							if (is_numeric ($register[5]) && $register[5] <= strtotime ("now") && $register[5] >= strtotime ("-" . apply_filters ("ws_plugin__s2member_register_link_exp_time", "2 days", get_defined_vars ())))
    								{
    									$_COOKIE["s2member_subscr_gateway"] = /* For ``reg_cookies_ok ()``. */ c_ws_plugin__s2member_utils_encryption::encrypt ($register[1]);
    									$_COOKIE["s2member_subscr_id"] = /* For ``reg_cookies_ok ()``. */ c_ws_plugin__s2member_utils_encryption::encrypt ($register[2]);
    									$_COOKIE["s2member_custom"] = /* For ``reg_cookies_ok ()``. */ c_ws_plugin__s2member_utils_encryption::encrypt ($register[3]);
    									$_COOKIE["s2member_item_number"] = /* For ``reg_cookies_ok ()``. */ c_ws_plugin__s2member_utils_encryption::encrypt ($register[4]);
    
    									if (($reg_cookies = c_ws_plugin__s2member_register_access::reg_cookies_ok ()) && extract ($reg_cookies) /* Needed? */)
    										{
    											status_header(200); // Send a 200 OK status header.
    											header("Content-Type: text/html; charset=UTF-8"); // Content-Type with UTF-8.
    
    											setcookie ("s2member_subscr_gateway", $_COOKIE["s2member_subscr_gateway"], time () + 31556926, COOKIEPATH, COOKIE_DOMAIN) . setcookie ("s2member_subscr_gateway", $_COOKIE["s2member_subscr_gateway"], time () + 31556926, SITECOOKIEPATH, COOKIE_DOMAIN);
    											setcookie ("s2member_subscr_id", $_COOKIE["s2member_subscr_id"], time () + 31556926, COOKIEPATH, COOKIE_DOMAIN) . setcookie ("s2member_subscr_id", $_COOKIE["s2member_subscr_id"], time () + 31556926, SITECOOKIEPATH, COOKIE_DOMAIN);
    											setcookie ("s2member_custom", $_COOKIE["s2member_custom"], time () + 31556926, COOKIEPATH, COOKIE_DOMAIN) . setcookie ("s2member_custom", $_COOKIE["s2member_custom"], time () + 31556926, SITECOOKIEPATH, COOKIE_DOMAIN);
    											setcookie ("s2member_item_number", $_COOKIE["s2member_item_number"], time () + 31556926, COOKIEPATH, COOKIE_DOMAIN) . setcookie ("s2member_item_number", $_COOKIE["s2member_item_number"], time () + 31556926, SITECOOKIEPATH, COOKIE_DOMAIN);
    
    											do_action ("ws_plugin__s2member_during_register", get_defined_vars ());
    
    											if (is_multisite () && c_ws_plugin__s2member_utils_conds::is_multisite_farm () && is_main_site () && ($location = c_ws_plugin__s2member_utils_urls::wp_signup_url ()))
    												{
    													echo '<script type="text/javascript">' . "\n";
    													echo "window.location = '" . c_ws_plugin__s2member_utils_strings::esc_js_sq ($location) . "';";
    													echo '</script>' . "\n";
    												}
    											else if (($location = c_ws_plugin__s2member_utils_urls::wp_register_url ()))
    												{
    													echo '<script type="text/javascript">' . "\n";
    													echo "window.location = '" . c_ws_plugin__s2member_utils_strings::esc_js_sq ($location) . "';";
    													echo '</script>' . "\n";
    												}
    											exit (); // Clean exit. The browser will now be redirected to ``$location``.
    										}
    									else
    										status_header(503) . header ("Content-Type: text/html; charset=UTF-8") . exit ($msg_503);
    								}
    							else
    								status_header(503) . header ("Content-Type: text/html; charset=UTF-8") . exit ($msg_503);
    						}
    					else
    						status_header(503) . header ("Content-Type: text/html; charset=UTF-8") . exit ($msg_503);
    				}
    			else
    				status_header(503) . header ("Content-Type: text/html; charset=UTF-8") . exit ($msg_503);
    		}
    
    	do_action ("ws_plugin__s2member_after_register", get_defined_vars ());
    }

    Концовка особенно захватывающа.

    Плагин для Wordpress - s2member, https://www.s2member.com/codex/stable/source/s2member/includes/classes/register-in.inc.php

    antongorodezkiy, 20 Апреля 2014

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

    +121

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    //if they're locked out or banned die
    if ( ( $bwpsoptions['id_enabled'] == 1 ||$bwpsoptions['ll_enabled'] == 1 ) && $this->checklock( $current_user->user_login ) ) {
    
    	wp_clear_auth_cookie();
        @header( 'HTTP/1.0 418 I\'m a teapot' );
        @header( 'Cache-Control: no-cache, must-revalidate' ); 
        @header( 'Expires: Thu, 22 Jun 1978 00:28:00 GMT' );
        die( __( 'error', $this->hook ) );
    
    }

    https://plugins.trac.wordpress.org/browser/better-wp-security/trunk/inc/secure.php#L925

    someone, 24 Января 2014

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

    +159

    1. 1
    <?php if( (!isset($post_id) ) || ( isset($post_id))  ) {	?>

    Одна платная Wordpress тема

    antongorodezkiy, 13 Июня 2013

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

    +48

    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
    $title = get_the_title();
    if ( $title == "Portfolio")  $data['sl_portfolio_style'] = "2 Columns Portfolio";
    if ( $title == "3 Columns Portfolio")  $data['sl_portfolio_style'] = "3 Columns Portfolio";
    if ( $title == "4 Columns Portfolio")  $data['sl_portfolio_style'] = "4 Columns Portfolio";
    if ( $title == "6 Columns Portfolio")  $data['sl_portfolio_style'] = "6 Columns Portfolio";
    if ( $title == "Portfolio")  query_posts( '&post_type=portfolio-type&posts_per_page=4&paged=' . $paged );
    if ( $title == "4 Columns Portfolio")  query_posts( '&post_type=portfolio-type&posts_per_page=8&paged=' . $paged );
    if ( $title == "6 Columns Portfolio")  query_posts( '&post_type=portfolio-type&posts_per_page=12&paged=' . $paged );
    if ( $title == "3 Columns Portfolio")  query_posts( '&post_type=portfolio-type&posts_per_page=6&paged=' . $paged );
    if ( $title == "Portfolio Right Sidebar")  $data['sl_portfolio_style'] = "Portfolio with Sidebar";
    if ( $title == "Portfolio Right Sidebar")  $data['portfolio_sidebar_position'] = "Right Sidebar";
    if ( $title == "Portfolio Left Sidebar")  $data['sl_portfolio_style'] = "Portfolio with Sidebar";
    if ( $title == "Portfolio Left Sidebar")  $data['portfolio_sidebar_position'] = "Left Sidebar";
    
    if ( $title == "Portfolio Left Sidebar")  query_posts( '&post_type=portfolio-type&posts_per_page=12&paged=' . $paged );
    if ( $title == "Portfolio Right Sidebar")  query_posts( '&post_type=portfolio-type&posts_per_page=12&paged=' . $paged );

    "switch - case" - Не не слышал!
    И это в покупной теме для wordpress на тимфоресте.
    Стоимость темы - 45 уе...

    tsybulskyserg, 22 Января 2013

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

    +121

    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
    #Creates an array with the frequencies from C2 to C5, 37 notes in all
    for j from 1 to 37
    	if j = 1 
    	notes [j] = 65.41 # лёгкие пути не нужны
    	endif
    	if j = 2
    	notes [j] = 69.30
    	endif
    # ...дальше понятно...
    endfor
    
    # <...>
    
    #Determining whether or not the scale contains C
    #This determines how many notes of the 37 possible must be included.
    noCList [1] = 3 # опа, а вот тут уже научились числовые индексы использовать
    noCList [2] = 5
    noCList [3] = 7
    noCList [4] = 10
    noCList [5] = 12
    noC = 0
    for n from 1 to 5
    	if 'starter' = noCList['n']
    		noC = 1
    	endif
    endfor
    #If there is a C...
    if noC = 0
    #The for loop mathematically selects the scale notes to use
    for m from 1 to 22
    	if 'm' = 1
    		noteind = 'starter'
    	endif
    	if 'm' = 2
    		noteind = 'starter' + 2
    		if 'noteind' > 37
    			noteind = 'noteind' - 36
    		endif
    	endif
    # ...ага-ага...
    	scalenotes ['m'] = notes['noteind']
    endfor
    #If there is not a C...
    else
    for m from 1 to 21
    	if 'm' = 1
    		noteind = 'starter'
    	endif
    	if 'm' = 2
    		noteind = 'starter' + 2
    		if 'noteind' > 37
    			noteind = 'noteind' - 36
    		endif
    	endif
    # ...так точно...
    	scalenotes ['m'] = notes['noteind']
    endfor
    endif
    
    # <...>
    
    #Add new pitch information
    #For each point, we move the freq to the closest scale note
    for q from 1 to 'numPoints'
    	#The original freq of pitch
    	currentfreq = pitches['q']
    	#A starting threhold for difference between original and a musical note
    	diff = 50
    	#If there is C in the scale, making 22 possible notes to tune to...
    	if 'noC' = 0
    	#For loop finds the lowest difference between original pitch and a musical note
    	for c from 1 to 22
    		diff2 = abs('currentfreq' - scalenotes['c'])
    		if 'diff2' < 'diff'
    			diff = 'diff2'
    			noteindex = 'c'
    		endif
    	endfor
    	#Otherwise if there is not a C...
    	else
    	for c from 1 to 21
    		diff2 = abs('currentfreq' - scalenotes['c'])
    		if 'diff2' < 'diff'
    			diff = 'diff2'
    			noteindex = 'c'
    		endif
    	endfor
    	endif
    	#Add point at the original time with the new pitch
    	Add point... times['q'] scalenotes['noteindex']
    endfor

    http://schyzm.wordpress.com/2012/12/05/fun-with-praat-a-script-for-auto-tune/
    Скрипт питч-коррекции для речевого анализатора Praat на встроенном языке сценариев. Не знаю, это афтар так жжот или язык располагает к черезжопию, но что-то тут воняет однозначно.

    telnet, 17 Января 2013

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

    +46

    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
    $confs = array();
    
    		$q = new WP_Query(array('post_type' => 'conference',
    					'posts_per_page' => -1,
    					'meta_key' => 'cd-conference-date-start',
    					'orderby' => 'meta_value_num',
    					'order' => 'DESC'
    					));
    
    		while($q->have_posts()): $q->the_post();
    		$confs[date("Y", get_post_meta($post->ID, 'cd-conference-date-start', true))][] = array('conf_title' => get_the_title(),
    												      'conf_date_start' => get_post_meta($post->ID, 'cd-conference-date-start', true),
    												      'conf_date_end' => get_post_meta($post->ID, 'cd-conference-date-end', true),
    												      'conf_link' => get_permalink(),
    												      'conf_city' => get_post_meta($post->ID, 'cd-conference-city', true),
    												      'conf_icon' => get_the_post_thumbnail()
    												      );
    		endwhile;
    
    		wp_reset_postdata();

    WordPress. Глубже, чем вы себе можете представить.

    varg242, 17 Сентября 2012

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