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

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

    +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
    function deposit(){ 
        if(document.getElementById("no_of_year").value=="1") { 
          document.getElementById("interest_rate").value="9.5" 
        } 
        if(document.getElementById("no_of_year").value=="2") { 
          document.getElementById("interest_rate").value="10" 
        } 
        if(document.getElementById("no_of_year").value=="3") { 
          document.getElementById("interest_rate").value="10.5" 
        } 
        if(document.getElementById("no_of_year").value=="4") { 
          document.getElementById("interest_rate").value="11" 
        } 
        if(document.getElementById("no_of_year").value=="5") { 
          document.getElementById("interest_rate").value="11.5" 
        } 
      }

    отсюда - http://stackoverflow.com/questions/24236980/values-not-passing-in-to-database

    zed_0xff, 16 Июня 2014

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

    +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
    case 1051: switch($page){
          case "hirurg_ob": include "surgery/hirurg_ob.php";
            break;
          case "hirurg_ap": include "surgery/hirurg_ap.php";
            break;
          case "hirurg_ap_analtresk": include "surgery/hirurg_ap_analtresk.php";
            break;
            
          case "hirurg_ap_anoskop": include "surgery/hirurg_ap_anoskop.php";
            break;
          case "hirurg_ap_gemoroy": include "surgery/hirurg_ap_gemoroy.php";
            break;
          case "hirurg_ap_paraproktit": include "surgery/hirurg_ap_paraproktit.php";
            break;                                               
          case "hirurg_ap_physical": include "surgery/hirurg_ap_physical.php";
            break;
          case "hirurg_ap_rektoscop": include "surgery/hirurg_ap_rektoscop.php";
            break;
          case "hirurg_ap_twofingers": include "surgery/hirurg_ap_twofingers.php";
            break;
        
          case "hirurg_au": include "surgery/hirurg_au.php";
            break;
          case "hirurg_au_cryptorchism": include "surgery/hirurg_au_cryptorchism.php";
            break;
          case "hirurg_au_fimoz": include "surgery/hirurg_au_fimoz.php";
            break;                                               
          case "hirurg_au_hydrocele": include "surgery/hirurg_au_hydrocele.php";
            break;
          case "hirurg_au_olegogran": include "surgery/hirurg_au_olegogran.php";
            break;
          case "hirurg_au_uzdechka": include "surgery/hirurg_au_uzdechka.php";
            break;                                            
          case "hirurg_au_varikocele": include "surgery/hirurg_au_varikocele.php";
            break;

    сайт Конекса.... заходим на сайт и нам предлагают скачать index.php.... ну а я че... скачал)) вот так вот странички инклудятся. и это лишь малая часть....

    mountpoint, 09 Июня 2014

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

    +155

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    7. 7
    8. 8
    9. 9
    /**
     * Returns the number of rows affected by the last query
     *
     * @return int
     */
    public function getAffectedRowCount($result)
    {
    	return mysqli_affected_rows($this->getDatabase());
    }

    SugarCRM. Стоит от $35/месяц на одного пользователя.

    Понимаю когда такое встречатеся в стартапах, но когда ты просишь за свой продукт деньги и деньги не малые, то выпускать такое в продакшен... Лично я бы постеснялся.

    VanSanblch, 27 Мая 2014

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

    +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
    {php}
        $this->_tpl_vars['image_set'] = array();
        $this->_tpl_vars['json_string'] = "";
    {/php}
    
    {if $pcollection}
        {foreach name=pcollection key=picture_id item=picture from=$pcollection}
            {php}
                array_push($this->_tpl_vars['image_set'], "{$this->_tpl_vars['urlprefix']}/thumb.php?file=" . str_replace("thumbs","original","media/pictures/{$this->_tpl_vars['album']->getPath()}/{$this->_tpl_vars['picture']->getPath()}")."&size=245x143");
            {/php}
        {/foreach}
    {/if}
    
    {php}
        $this->_tpl_vars['json_string'] = json_encode($this->_tpl_vars['image_set']);
    {/php}
    {$json_string}

    получение объекта в smarty, потом пара фокусов, и вуаля, выплевываем json строку

    expert, 15 Мая 2014

    Комментарии (2)
  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 / Говнокод #15762

    +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
    switch ( count($args) )
    		{
    			case 0:
    				return $obj->$method( );
    			case 1:
    				return $obj->$method( $args[0] );
    			case 2:
    				return $obj->$method( $args[0], $args[1] );
    			case 3:
    				return $obj->$method( $args[0], $args[1], $args[2] );
    			case 4:
    				return $obj->$method( $args[0], $args[1], $args[2], $args[3] );
    			case 5:
    				return $obj->$method( $args[0], $args[1], $args[2], $args[3], $args[4] );
    			case 6:
    				return $obj->$method( $args[0], $args[1], $args[2], $args[3], $args[4], $args[5] );
    			case 7:
    				return $obj->$method( $args[0], $args[1], $args[2], $args[3], $args[4], $args[5], $args[6] );
    			case 8:
    				return $obj->$method( $args[0], $args[1], $args[2], $args[3], $args[4], $args[5], $args[6], $args[7] );			
    			case 9:
    				return $obj->$method( $args[0], $args[1], $args[2], $args[3], $args[4], $args[5], $args[6], $args[7], $args[8] );			
    			case 10:
    				return $obj->$method( $args[0], $args[1], $args[2], $args[3], $args[4], $args[5], $args[6], $args[7], $args[8], $args[9] );			
    			case 11:
    				return $obj->$method( $args[0], $args[1], $args[2], $args[3], $args[4], $args[5], $args[6], $args[7], $args[8], $args[9], $args[10] );			
    			case 12:
    				return $obj->$method( $args[0], $args[1], $args[2], $args[3], $args[4], $args[5], $args[6], $args[7], $args[8], $args[9], $args[10], $args[11]   );			
    		}
    		throw new MWException( __CLASS__.": too many arguments to method called in ".__METHOD__ );

    thekiba, 16 Апреля 2014

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

    +155

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    $hlblock_id = 3;
    		$hlblock = HL\HighloadBlockTable::getById($hlblock_id)->fetch();
    		$entity = HL\HighloadBlockTable::compileEntity($hlblock);
    
    		$main_query = new Entity\Query($entity);
    		$main_query->setSelect(array('*'));
    		$main_query->setFilter(array('=UF_NAME' => $arOLDItem['material']));
    		$result = $main_query->exec();
    		$result = new CDBResult($result);
    		$row = $result->Fetch();

    Bitrix, HIGHLOAD инфоблоки, данная запись равносильна SQL запросу SELECT * FROM %таблица_название_которой_хранится_в_бд_ под_номером_3% WHERE UF_NAME = $arOLDItem['material']

    +зацените супер CamelCase от битрикса

    TBoolean, 15 Апреля 2014

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

    +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
    //выведет таблицу для отладки
    function ExecSQL_SelectTable($sql)
    {
    	if($data = ExecSQL_Select($sql)->fetchAll(PDO::FETCH_ASSOC)){
    		print '<table border=2>';
    		print '<tr>';
    		foreach(array_keys($data[0]) AS $v) print '<td>'.$v.'</td>';
    		print '</tr>';
    		foreach($data AS $row){
    			print '<tr>';
    			foreach($row AS $v) print '<td>'.$v.'</td>';
    			print '</tr>';
    		}
    		print '</table>';
    	}
    	die;
    }

    Что только люди не предумают чтобы не юзать нормальный debug и не отлаживать код нормально.

    smpl, 08 Апреля 2014

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

    +155

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    11. 11
    $title = str_replace("1", "", $title);
    	$title = str_replace("2", "", $title);
    	$title = str_replace("3", "", $title);
    	$title = str_replace("4", "", $title);
    	$title = str_replace("5", "", $title);
    	$title = str_replace("6", "", $title);
    	$title = str_replace("7", "", $title);
    	$title = str_replace("8", "", $title);
    	$title = str_replace("9", "", $title);
    	$title = str_replace("0", "", $title);
    	echo $title;

    Убираем цифры из строки!

    mrmany, 06 Апреля 2014

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

    +155

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    11. 11
    ...     
    unset($_SESSION['some_payment']);
    $_SESSION['message'] = "Your booking details have been sent to your email.";
    ?>
    <script language="javascript" type="text/javascript">
        window.location.href = "bookingdetail.php?booking_id=<?= $this->book_id ?>&booking=yes";
    </script>
    <?php
          return true;
          } else {
    ...

    Вот это поворот! Найдено постерди одной из фунций класса.

    synzrk, 02 Апреля 2014

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