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

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

    +153

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    <SCRIPT LANGUAGE="JavaScript" TYPE="text/javascript">
    function MM_openBrWindow(theURL,winName,features) { //v2.0
    window.open(theURL,winName,features);
    }
    </SCRIPT>

    Лёгких путей не ищем. С форума.

    guest, 05 Июля 2009

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

    +153

    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
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
    <HTML>
        <HEAD>
        <title>
        </HEAD>
    <BODY>
    <?php
    include("connect.php");
    /* вводим переменную которая соединяется с бд */
            $db = @mysql_connect ($host, $user, $psw);
            mysql_query($db);
    /* выбираем бд с использованием предыдущей */
    /*переменной для соединения с бд*/
            $sdb = @mysql_select_db("zforum", $db);
    
    /* для наглядности показываем месагу результата выполнения скрипта */
    if(empty($sdb)) { $info=$info.mysql_error();
            };
    $datevar="date()";
    $usrn="select * from users where usrnick='$_POST[nick]'";
    $usrnick=mysql_query($usrn);
    $rows_usrnick=mysql_num_rows($usrnick);
    $usrm="select * from users where usrmail='$_POST[email]'";
    $usrmail=mysql_query($usrm);
    $rows_usrmail=mysql_num_rows($usrmail);
    $ins_new_usr="INSERT INTO users SET usrnick='$_POST[nick]', usrpsw='$_POST[pass]', usrmail='$_POST[email]',usrabout='$_POST[about]',regdate='$datevar'";
    ?>
    <form action=" <?php include("go_reg.php") ?>" method=post target="_self">
    <Table border="5">
    <tr><th COLSPAN=2>Registration form</th></tr>
    <tr><td>Nickname</td><td><input type="text" size=26 name="nick" maxlegth="16" size="16" value=""></td></tr>
    <tr><td>Password</td><td><input type="password" name="pass" size=26 maxlength=24 size="16" value=""></td></tr>
    <tr><td>Password again</td><td><input type="password" name="pass2" size=26 maxlength="24" size="16" value=""></td></tr>
    <tr><td>E-mail</td><td><input type="text" name="email" maxlength="50" size=26 value=""></td></tr>
    <tr><td>About</td><td><textarea name="about" maxlength="100" wrap="virtual" rows=4></textarea></tr>
    <tr><th colspan=2><input type="submit" value="enter"></th></tr>
    <h1> <?php echo("$info$error") ?> </h1>
    </table>
    
    
    2ой файл "go_reg.php"
    
    <?php
    if(isset($_POST[nick]) && isset($_POST[pass]) && isset($_POST[pass2]) && isset($_POST[email]))
       {
    if($rows_usrnick>0) {$error="Такой ник уже занят<BR>";
       }
    if($rows_usrmail>0) {$error="$error На этот е-меил уже зарегистрирован пользователь<BR>";
       }
    if($_POST[pass2]==$_POST[pass]) {;} else {$error="$error Пароль введен не верно<BR>";
    }
    };
    if(!isset($error)) {mysql_query($ins_new_usr);}
    ?>
    </body>

    guest, 01 Июля 2009

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

    +153

    1. 1
    break; break; break; // PLEASE, BREAK!!!!!!

    guest, 28 Июня 2009

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

    +153

    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
    function splitString($inS)
     {
      $k = strlen($inS);
      $res = array();
      for($i=0;$i<$k;$i++)
       {
        $res[$i] = $inS{$i};
       };
      return($res);
     };
    
    function toTranslit($text)
     {
      $outS = '';
      $data = splitString(trim($text,' -_')); //str_split($text);
      foreach($data as $ch)
       {
        switch($ch)
         {
          case 'А' : $rc = 'a'; break;
          case 'Б' : $rc = 'b'; break;
          case 'В' : $rc = 'v'; break;
    //тут очень, очень много букафф... все какие есть...
          case '8' : $rc = '8'; break;
          case '9' : $rc = '9'; break;
          case '0' : $rc = '0'; break;
          case '-' : $rc = '-'; break;
          case '_' : $rc = '_'; break;
          case ' ' : $rc = '-'; break;
          default : $rc = '';
         };
        $outS .= $rc;
       };
      $outS = str_replace('_','-',$outS);
      while(strpos('--',$outS)) { $outS = str_replace('--','-',$outS); };
      return($outS);
     };

    ещё из просеивания, пара функций преобразующая введённую пользователем строчку в транслит
    уходит корнями в 2002й год -- продержалась в ядре CMS-ки аж 7 лет, исправно при этом работая.
    ...и ведь опять я сам писал, заразу...

    guest, 27 Июня 2009

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

    +153

    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
    95. 95
    96. 96
    97. 97
    <?
    ob_start();
    session_start();
    include("includes/applicationTop.php");
    ?>
    <?
    if($_SESSION["CONTACT_ID"]=="" || $_SESSION["CONTACT_ID"]==0)
    {
    	$contact_id=$_GET['contact_id'];
    }
    else
    {
    	$contact_id = $_SESSION["CONTACT_ID"];
    }
    if($_SESSION["ORDER_ID"]=="" || $_SESSION["ORDER_ID"]==0)
    {
    	$order_id=$_GET['order_id'];
    }
    else
    {
    	$order_id = $_SESSION["ORDER_ID"];
    }
    
    $selBillingInfo = "SELECT * FROM `contact` WHERE `contact_id`='".$contact_id."'";
    $resBillingInfo = $db->select_data($selBillingInfo);
    $selOrderInfo = "SELECT * FROM `order` WHERE `order_id`='".$order_id."'";
    $resOrderInfo = $db->select_data($selOrderInfo);
    ?>
    <? $exesql=mysql_query("select * from admin_updation where id = 1"); 
    $rs=mysql_fetch_object($exesql); $to_mail=$rs->paypal_id;?> 
    <table width="100%" border="0" align="center" cellpadding="0" cellspacing="0">
      <tr>
    	<td width="30"><img src="images/spacer.gif" width="30" height="1" /></td>
    	<td><form class="formclass" method="post" action="https://www.paypal.com/cgi-bin/webscr"  id="myform" name="theForm" ><!--<form class="formclass" method="post" action="https://www.paypal.com/cgi-bin/webscr"  id="myform" name="theForm" >-->
    		<input name="validate" value="1" type="hidden">
    		<input type="hidden" name="order_id" value="<?=$order_id?>" />
    		<?
    		$paypal[site_url]="http://говносайт";
    		$paypal[success_url]="/paymentReceipt.php?success=paypal&pt=paypal&contact_id=$contact_id&order_id=$order_id";
    		$paypal[cancel_url]="/paymentReceipt.php?success=failed&pt=paypal&contact_id=$contact_id&order_id=$order_id";
    		$paypal[notify_url]="/ipn/ipn.php";
    		$paypal[return_method]="2"; //1=GET 2=POST
    		$paypal[currency_code]="USD"; //[USD,GBP,JPY,CAD,EUR]
    		$paypal[lc]="US";
    		$paypal[url]="https://www.sandbox.paypal.com/cgi-bin/webscr"; // For Test 
    		$paypal[post_method]="fso"; //fso=fsockopen(); curl=curl command line libCurl=php compiled with libCurl support
    		$paypal[curl_location]="/usr/local/bin/curl";
    		$paypal[bn]="toolkit-php";
    		$paypal[cmd]="_xclick";
    		$paypal[display_comment]="0"; //0=yes 1=no
    		$paypal[comment_header]="Comments";
    		$paypal[continue_button_text]="Continue >>";
    		$paypal[background_color]="1"; //""=white 1=black
    		$paypal[display_shipping_address]="1"; //""=yes 1=no
    		$paypal[display_comment]="1"; //""=yes 1=no
    		?>
    		<!--<input type="hidden" name="business" value="[email protected]">--><? // For Live ?>
    		
    		<input type="hidden" name="business" value="<?=$to_mail?>"><? // For Test ?>
    		<!--<input type="hidden" name="business" value="[email protected]">--><? // For Test ?>
    		<input type="hidden" name="item_name" value="Говнобрэнд">
    		<input type="hidden" name="cmd" value="<?=$paypal[cmd]?>">
    		<input type="hidden" name="redirect_cmd" value="<?=$paypal[cmd]?>">
    		<input type="hidden" name="image_url" value="">
    		<input type="hidden" name="return" value="<? echo "$paypal[site_url]$paypal[success_url]"; ?>">
    		<input type="hidden" name="cancel_return" value="<? echo "$paypal[site_url]$paypal[cancel_url]"; ?>">
    		<input type="hidden" name="notify_url" value="<? echo "$paypal[site_url]$paypal[notify_url]"; ?>">
    		<input type="hidden" name="rm" value="<?=$paypal[return_method]?>">
    		<input type="hidden" name="currency_code" value="<?=$paypal[currency_code]?>">
    		<input type="hidden" name="lc" value="<?=$paypal[lc]?>"><input type="hidden" name="bn" value="<?=$paypal[bn]?>">
    		<input type="hidden" name="cbt" value="<?=$paypal[continue_button_text]?>"><input type="hidden" name="no_shipping" value="<?=$paypal[display_shipping_address]?>">
    		<input type="hidden" name="no_note" value="<?=$paypal[display_comment]?>">
    		<input type="hidden" name="order_id" value="<?=$order_id?>"><input type="hidden" name="amount" value="<?=$resOrderInfo[0]['amount']?>">
    		<input type="hidden" name="first_name" value="<?=$resBillingInfo[0]['first_name']?>">	<input type="hidden" name="last_name" value="<?=$resBillingInfo[0]['last_name']?>">
    		<input type="hidden" name="company" value="<?=$resBillingInfo[0]['company']?>"><input type="hidden" name="address" value="<?=$resBillingInfo[0]['address']?>">
    		<input type="hidden" name="city" value="<?=$resBillingInfo[0]['city']?>"><input type="hidden" name="state" value="<?=$resBillingInfo[0]['state']?>">
    		<input type="hidden" name="zip" value="<?=$resBillingInfo[0]['zip']?>">
    		<input type="hidden" name="country" value="<?=$resBillingInfo[0]['country']?>">
    		<input type="hidden" name="phone" value="<?=$resBillingInfo[0]['phone']?>"> 	<input type="hidden" name="email " value="<?=$resBillingInfo[0]['email']?>">	<input type="hidden" name="a3" value="<?=$resOrderInfo[0]['amount']?>">
    		<input type="hidden" name="p3" value="1">	<input type="hidden" name="t3" value="M"> <input type="hidden" name="no_note" value="1">
    		<input type="hidden" name="src" value="1"><input type="hidden" name="sra" value="1">
    		<table width="100%" border="0" cellspacing="0" cellpadding="0">
    		  <tr>
    			<td class="text_body">&nbsp;</td>
    		  </tr>
    		  <tr>
    			<td align="left"></td>
    		  </tr>
    		</table>
    	  </form></td>
    	<td width="15"><img src="images/spacer.gif" width="15" height="1" /></td>
      </tr>
    </table>
    <script language="JavaScript">
    objfrm = document.getElementById("myform");
    objfrm.submit();
    </script>

    А вот занятный способ переброса посетителя на paypal.
    С помощью невидимой формы, который сама засабмитится (может быть).

    Источник тот же, что у #1244-#1245, #1248-#1250

    guest, 25 Июня 2009

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

    +153

    1. 1
    $r3['price'] = $r3['price']*1;

    вывод цены

    guest, 18 Июня 2009

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

    +153

    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
    (defun lagr-poly (lpoints)
      (lambda (x)
        (let ((prod-l nil)
    	  (sum-l nil))
          (loop for point in lpoints do
    	   (let ((x0 (x-coord point))
    		 (y0 (y-coord point)))
    	     (loop for pointn in lpoints do
    		  (let ((xn (x-coord pointn)))
    		    (if (not (eq point pointn))
    			(progn (push (/ (- x xn) (- x0 xn)) prod-l)))))
    	     (push (* (product prod-l) y0) sum-l)
    	     (setq prod-l nil)))
          (loop for l in sum-l sum l))))

    Полином Лагранжа, ёпта!
    Давно написал, сейчас даже понять не могу как работает.

    guest, 17 Июня 2009

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

    +153

    1. 1
    2. 2
    3. 3
    4. 4
    <?
    if ($arResult["MANAGE_PANEL"]["MESSAGES"] == "Y"):
    endif;
    ?>

    Ну вы поняли, какая CMS
    /bitrix/modules/forum/install/components/bitrix/forum/templates/.default/bitrix/forum.menu/.default/template.php
    Семёрка, 426 строка

    guest, 11 Июня 2009

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

    +153

    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
    $answer = "";
    $word_arr = split (" ", $text);
    $rn = mt_rand(1,sizeof($word_arr))-1;
    $word = $word_arr[$rn];echo $rn." ";echo $word."_<br>";
    $i=1;
    $r = mt_rand(6,12);
    echo "r=".$r."<br>";
    while ($i < $r) :
      $result = mysql_query("SELECT * FROM suffixes WHERE (`prfx`='$word');");
      $j = 0;
      while ($j < mysql_numrows($result)) :
      $sffxs = mysql_result($result, $j, 'sffxs');
      $j++;
      endwhile;

    Сам не понял, что написал... =\

    guest, 10 Июня 2009

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

    +153

    1. 1
    $this->template_vars['product_description'] = nl2br(str_replace('{price}', (($this->template_vars['product_old_price']) ? '<span class="old_price">$'.$this->template_vars['product_old_price'].'</span> ' : '').'$'.$this->template_vars['product_price'], $this->template_vars['product_description'])) . $fabric;

    Это не столько говнокод, сколько пример непреднамеренной обфускации.

    guest, 04 Июня 2009

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