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

    +164

    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
    $tr = "<tr>";
    $td = "<td>";
    $_tr = "</tr>";
    $_td = "</td>";
    $table = "<table>";
    $_table = "</table>";
    
    echo ("<table border='1'>");
    while ($myrow = mysql_fetch_array ($result))
    {
    printf ("%s",$tr);
    foreach ($myrow as $value)
    {
    printf ("%s%s%s",$td,$value,$_td);
    };
    printf ("%s",$_tr);
    };
    echo ("</table>");

    Uchkuma, 20 Июля 2010

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

    +173

    1. 1
    $karkas = tr(bgcolor("D9EDFB"), td(w("1%").style("").valign("top"),br()).td(valign("top"), hr(noshade().size(1).color("D9EDFB")).table(cs(0).cp(10).border(0), tr(no(), td(no(), 'текст'...

    Все знают, что хорошим стилем написанием сайта является отделение кода от дизайна. Но то, что я увидел в самописной CMS, детище прошлого PHP-кодера, повергло меня в тихий ужас.

    Каждый HTML-тег со всеми атрибутами был переопределён в отдельную функцию со своими параметрами. Нашлось место даже для замечательной функции br().

    [url]http://ithappens.ru/story/3663[/url]

    Uchkuma, 19 Июля 2010

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

    +156

    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
    $entryCommentList = $db->getCommentList(array('blog_entry_id' => $id, 'uid' => !empty($user->id) ? $user->id : 0));
                                    array_walk(
                                            $entryCommentList,
                                            create_function('&$c,$k,$d', '$c["author_image_url"] = !empty($d[$c["author_id"]]) ? $d[$c["author_id"]] : null;'),
                                            $db->getPersonImage(
                                                    array_unique(
                                                            array_map(
                                                                    create_function('$c', 'return (int) $c["author_id"];'),
                                                                    array_filter(
                                                                            $entryCommentList,
                                                                            create_function('$c', 'return (int) $c["person_type_id"] == 1 && $c["is_hero"] != 1;')
                                                                    )
                                                            )
                                                    ),
                                                    2 /*14*/
                                            ) + $db->getPersonImage(
                                                    array_unique(
                                                            array_map(
                                                                    create_function('$c', 'return (int) $c["author_id"];'),
                                                                    array_filter(
                                                                            $entryCommentList,
                                                                            create_function('$c', 'return (int) $c["person_type_id"] == 4 && $c["is_hero"] != 1;')
                                                                    )
                                                            )
                                                    ),
                                                    14
                                            ) + $db->getPersonImage(
                                                    array_unique(
                                                            array_map(
                                                                    create_function('$c', 'return (int) $c["author_id"];'),
                                                                    array_filter(
                                                                            $entryCommentList,
                                                                            create_function('$c', 'return (int) $c["is_hero"] == 1;')
                                                                    )
                                                            )
                                                    ),
                                                    70
                                            )
                                    );

    Необходимо было поправить код вывода каментов. Он весь состоит из таких вот вещей, арэй волков, криэйт фанкшенов и прочей жести. Можно конечно понять что здесь происходит, но ваще проще переписать

    gntw, 19 Июля 2010

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

    +147

    1. 1
    2. 2
    3. 3
    if(@$_GET['modul']=="logout"){
        //code
    }

    ленивый мудак

    sogekoder, 19 Июля 2010

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

    +159

    1. 1
    echo $Router->index->title->DB->select("SELECT title FROM content WHERE id = 1");

    pasha, 16 Июля 2010

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

    +161

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    $razn = mktime(0,0,0,$m,$d,$y); 
    
    $vozrast = (time() - $razn) / 31536000; 
    
    return explode(".",$vozrast);

    из кода одного крупного сайта, сделанного на заказ

    Мартин, 16 Июля 2010

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

    +157

    1. 1
    2. 2
    $wpdb->query($wpdb->prepare("INSERT INTO `".WPSC_TABLE_CART_CONTENTS."` (`prodid`, `name`, `purchaseid`, `price`, `pnp`,`tax_charged`, `gst`, `quantity`, `donation`, `no_shipping`, `custom_message`, `files`, `meta`) VALUES ('%d', '%s', '%d', '%s', '%s', '%s', '%s', '%s', '%d', '0', '%s', '%s', NULL)", $this->product_id, $this->product_name, $purchase_log_id, $this->unit_price, (float)$shipping, (float)$tax, (float)$tax_rate, $this->quantity, $this->is_donation, $this->custom_message, serialize($this->custom_file)));
    		$cart_id = $wpdb->get_var("SELECT LAST_INSERT_ID() AS `id` FROM `".WPSC_TABLE_CART_CONTENTS."` LIMIT 1");

    Это код WP-Ecommerce. Ахтунг!

    karevn, 16 Июля 2010

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

    +163

    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
    <?php  
    // Создание массива из строки 
    if($_POST['add_array']=="Получит массив") 
    { 
       // новый массив для заполнения значениями 
       $new_arr = array(); 
       $text = explode(",", htmlspecialchars($_POST['text'])); 
       for($i=0; $i<count($text); $i++) 
       { 
             $vol = "<".$text[$i].">"; 
             array_push($new_arr,$vol); 
       } 
       print_r($new_arr); 
    } 
    ?>
    <form  method="post" action="">
      Введите  текст:<br>
      <textarea name="text" cols="70" rows="5"></textarea>
      <br>
      <br>
      <input name="add_array" type="submit" value="Получит массив">
    </form>

    Нашел на одном сайте с уроками по PHP.

    Мартин, 16 Июля 2010

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

    +114

    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
    <?php
    function initiate()
    {
    
    $logged_in = false;
    if(isset($_SESSION['user_name']))
    {
    $logged_in = true;
    }
    
    // Check that cookie is set
    if(isset($_COOKIE['auth_key']))
    {
    $auth_key = safe_var($_COOKIE['auth_key']);
    
    if($logged_in === false)
    {
    // Select user from database where auth key matches (auth keys are unique)
    $auth_key_query = mysql_query("SELECT username, password FROM users WHERE auth_key = '" . $auth_key . "' LIMIT 1");
    if($auth_key_query === false)
    {
    // If auth key does not belong to a user delete the cookie
    setcookie("auth_key", "", time() - 3600);
    }
    else
    {
    while($u = mysql_fetch_array($auth_key_query))
    {
    // Go ahead and log in
    login($u['username'], $u['password'], true);
    }
    }
    }
    else
    {
    setcookie("auth_key", "", time() - 3600);
    }
    }
    
    }
    
    ?>

    Там целый сайт такого кода полный http://www.ruseller.com/lessons.php?rub=28&id=427

    Vasiliy, 16 Июля 2010

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

    +176

    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
    function NDS($poisk)
    {
    	preg_match('#БЕЗ НДС#', $poisk, $matches);
    	if(empty($matches[0]))
    	{
    		preg_match('#без НДС#', $poisk, $matches);
    	   	if(empty($matches[0]))
    		{
    			preg_match('#НДС НЕТ#', $poisk, $matches);
    		 	if(empty($matches[0]))
    			{
    			  	 preg_match('#НДС нет#', $poisk, $matches);
    		 		 if(empty($matches[0]))
    				 {
    			  		preg_match('#НДС не облагается#', $poisk, $matches);
    				 	if(empty($matches[0]))
    					{
    					   	preg_match('#НДС НЕ ОБЛАГАЕТСЯ#', $poisk, $matches);
    					 	if(empty($matches[0]))
    					 	{
    					 		preg_match('#НДС НЕ ПРЕДУСМОТРЕН#', $poisk, $matches);
    					 		if(empty($matches[0]))
    					 		{
    							   preg_match('#Без налога (НДС)#', $poisk, $matches);
    					 		   if(empty($matches[0]))
    					 		   {
    									preg_match('#НДС: БЕЗ НАЛОГА#', $poisk, $matches);
    					 				if(empty($matches[0]))
    					 				{
    					 				   preg_match('#Без НДС#', $poisk, $matches);
    					 				   if(empty($matches[0]))
    					 				   {
    					 				   	  preg_match('#без налога (НДС)#', $poisk, $matches);
    					 					  if(empty($matches[0]))
    					 					  {}
    					 					  else  return true;
    					 				   }
    					 				   else  return true;
    					 				}
    					 				else  return true;
    					 		   }
    					 		   else  return true;
    					 		}
    					 		else  return true;
    					 	}
    						else  return true;
    					}
    					else return true;
    				  }
    				  else return true;
    			}
    			else return true;
    		}
    		else return true;
    	}
    	else return true;
    }

    Обнаружено в старом проекте заказчика

    UncleRus, 16 Июля 2010

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