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

    +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
    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
    <?php
     // Получение страницы напрямую или через проксю
    function getfile($GrabURL)
    {
     global $proxy_name,$proxy_port;
    
     if($proxy_name!="")
     {
      $f = urldecode($GrabURL);
      $proxy_fp = fsockopen($proxy_name, $proxy_port,$errno,$errstr);
      if (!$proxy_fp)
       return false;
      $out = "GET ".$f." HTTP/1.0\r\n\r\n";
      fwrite($proxy_fp, $out);
      $x = "";
      stream_set_timeout($OpenFile, 10);
      stream_set_blocking($OpenFile, 0);
      while (!feof($proxy_fp))
      {
       $RetrieveFile = fread($proxy_fp,8192) or last;
       $x = $x.$RetrieveFile;
      }
      fclose($proxy_fp);
     }
     else
     {
    
     $OpenFile = fopen($GrabURL, "rb");
    
     if(!$OpenFile) return "";
    
       $i = 0;
       $x = "";
       stream_set_timeout($OpenFile, 10);
       stream_set_blocking($OpenFile, 0);
       while (!feof($OpenFile))
        {
         $RetrieveFile = fread($OpenFile, 8192);
         $x=$x.$RetrieveFile;
        }
       fclose($OpenFile);
      }
     return $x;
    }
    ?>

    Аналог file_get_contents. По просьбам из #4065

    mr.The, 23 Августа 2010

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

    +165

    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
    <?php
    //...
     $GrabURL = "http://www.google.com/search?q=".$url."&sourceid=opera&num=100&ie=utf-8&oe=utf-8&start=".$page;
      $x=getfile($GrabURL); //автор сделал велосипед-аналог file_get_contents
      $handle = fopen("rip_google.txt","w+");
      fwrite($handle, $x);
      fclose($handle);
      $screen = file("rip_google.txt");
      $content = implode("",$screen);
      // вытягиваем линк
      preg_match_all("!\<h2 class=r\>\<a href=\"(http:.*?)[\"|&]!si" ,$content, $out1, PREG_PATTERN_ORDER);
    //...
    ?>

    Код из парсера гугла. Файл rip_google.txt больше реально нигде не используется. Так же порадовала комбинация строк 8-9.

    mr.The, 22 Августа 2010

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

    +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
    $submit=($a!=0)?true:false;
    if($submit==true)
    {
        redirect("index.php");
    }
    else
    {
        if($submit==false)
        {
    	  include_once("module.php");
        }
    }

    железная индусская логика

    zloiia, 22 Августа 2010

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

    +165

    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
    $adm="
    
               	   <img src='img/up.gif' onclick='priorThread($child[id],$level, 1);' style='cursor:pointer;' title='переместить вверх'>
    
               	   <img src='img/down.gif' onclick='priorThread($child[id],$level, -1);' style='cursor:pointer;' title='переместить вниз'>
    
               	   &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
    
               	   <img src='img/add.gif' title='Добавить подрубрику' style='cursor:pointer;' onclick='addThread($child[id],$level);'>
    
    	   		   <img src='img/edit.gif'title='Редактировать'  style='cursor:pointer;' onclick='editThread($child[id],\"$child[name]\",$level);'>
    
               	   <img src='img/del.gif' title='Удалить' style='cursor:pointer;' onclick='delThread($child[parent_id],$child[id],$level);'>"; 
    
               $adm="";

    Гениально:)

    moonie, 21 Августа 2010

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

    +165

    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 writelogin()
    
      {
    
      echo "<table border=0 width=100% cellspacing=0 cellpadding=0 background=design/images/layout_02.jpg height=81><tr><td>";
    
       echo "<form height=10 name=log method=post action=login.php?action=login&referrer=\>";
    
       echo " <table border=0 cellspacing=-1 cellpadding=0><tr><td> ";
    
       echo " &nbsp;&nbsp;<font size=-2>Логин:<br>";
    
       echo "&nbsp;&nbsp;<input type=textfield name=login class=textfield ><br>";
    
       echo " &nbsp;&nbsp;Пароль<br>";
    
       echo " &nbsp;&nbsp;<input type=password name=password class=textfield>";
    
       echo " <td><br><input onclick='javascript:log.submit()' type=image alt='Авторизоваться' name=go src=design/images/button.jpg></table>";
    
       echo "</form>";
    
       echo "</table>";
    
      }

    А сколько здесь надо пальцев отрубать???:)

    moonie, 21 Августа 2010

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

    +168

    1. 1
    2. 2
    3. 3
    if (isAdmin($user)) {echo "<a href=/admin.php>Администрирование</a>";}
    
       else echo "хуй! ";

    логинизация на сайте продакшн:)

    moonie, 21 Августа 2010

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

    +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
    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
    Function GetChildTree($STARTID)
    	{		
    		global $TPL_START_NOT_EMPTY;
    		$LEVEL_1_CHILD_ARRAY=nlst("Select ID, name from thread where parentID='".$STARTID."' and visibility='1' order by priority desc");
    
    		if ($LEVEL_1_CHILD_ARRAY)     // если массив не пустой
    			{
    				$i1=0;
    				$i2=0;
    				$i3=0;
    				$i4=0;
    				$i5=0;
    				$LEVEL_1_CHILD_HTML="";
    				$LEVEL_2_CHILD_HTML="";
    				$LEVEL_3_CHILD_HTML="";
    				$LEVEL_4_CHILD_HTML="";
    				$LEVEL_5_CHILD_HTML="";
    				while ($i1<count($LEVEL_1_CHILD_ARRAY))
    				{
    						$LEVEL_2_CHILD_ARRAY=nlst("Select ID, name from thread where parentID='".$LEVEL_1_CHILD_ARRAY[$i1]['ID']."' and visibility='1' order by priority desc");
    							if ($LEVEL_2_CHILD_ARRAY)
    								{
    									while ($i2<count($LEVEL_2_CHILD_ARRAY))
    										{
    												$LEVEL_3_CHILD_ARRAY=nlst("Select ID, name from thread where parentID='".$LEVEL_2_CHILD_ARRAY[$i2]['ID']."' and visibility='1' order by priority desc");
    													if ($LEVEL_3_CHILD_ARRAY)
    														{
    																while ($i3<count($LEVEL_3_CHILD_ARRAY))
    																	{
    																			$LEVEL_4_CHILD_ARRAY=nlst("Select ID, name from thread where parentID='".$LEVEL_3_CHILD_ARRAY[$i3]['ID']."' and visibility='1' order by priority desc");
    																				if ($LEVEL_4_CHILD_ARRAY)
    																					{
    																							while ($i4<count($LEVEL_4_CHILD_ARRAY))
    																									{
    																											$LEVEL_5_CHILD_ARRAY=nlst("Select ID, name from thread where parentID='".$LEVEL_4_CHILD_ARRAY[$i4]['ID']."' and visibility='1' order by priority desc");
    																												if ($LEVEL_5_CHILD_ARRAY)
    																													{
    																															while ($i5<count($LEVEL_5_CHILD_ARRAY))
    																																{
    																																																															
    																																		$ParseArray5[0]=$LEVEL_5_CHILD_ARRAY[$i5]['ID'];
    																																		$ParseArray5[1]=$LEVEL_5_CHILD_ARRAY[$i5]['name'];
    																																		$ParseArray5[2]="";
    																																	$LEVEL_5_CHILD_HTML.=ParseTPL($TPL_START_NOT_EMPTY, $ParseArray5);
    																																	$i5++;
    																																}
    																													}
    																											
    																											$ParseArray4[0]=$LEVEL_4_CHILD_ARRAY[$i4]['ID'];
    																											$ParseArray4[1]=$LEVEL_4_CHILD_ARRAY[$i4]['name'];
    																											$ParseArray4[2]=$LEVEL_5_CHILD_HTML;
    																										$LEVEL_4_CHILD_HTML.=ParseTPL($TPL_START_NOT_EMPTY, $ParseArray4);
    																										$LEVEL_5_CHILD_HTML="";
    																										$i4++;
    																									}
    																					}
    																			
    																			$ParseArray3[0]=$LEVEL_3_CHILD_ARRAY[$i3]['ID'];
    																			$ParseArray3[1]=$LEVEL_3_CHILD_ARRAY[$i3]['name'];
    																			$ParseArray3[2]=$LEVEL_4_CHILD_HTML;
    																		$LEVEL_3_CHILD_HTML.=ParseTPL($TPL_START_NOT_EMPTY, $ParseArray3);
    																		$LEVEL_4_CHILD_HTML="";
    																		$i3++;
    																	}
    														}
    												
    												$ParseArray2[0]=$LEVEL_2_CHILD_ARRAY[$i2]['ID'];
    												$ParseArray2[1]=$LEVEL_2_CHILD_ARRAY[$i2]['name'];
    												$ParseArray2[2]=$LEVEL_3_CHILD_HTML;
    											$LEVEL_2_CHILD_HTML.=ParseTPL($TPL_START_NOT_EMPTY, $ParseArray2);
    											$LEVEL_3_CHILD_HTML="";
    											$i2++;
    										}
    								}
    						
    						$ParseArray1[0]=$LEVEL_1_CHILD_ARRAY[$i1]['ID'];
    						$ParseArray1[1]=$LEVEL_1_CHILD_ARRAY[$i1]['name'];
    						$ParseArray1[2]=$LEVEL_2_CHILD_HTML;
    					$LEVEL_1_CHILD_HTML.=ParseTPL($TPL_START_NOT_EMPTY, $ParseArray1);
    					$LEVEL_2_CHILD_HTML="";
    					$i1++;
    				}
    			}
    			
    	echo $LEVEL_1_CHILD_HTML;
    	}

    Работа с базами данными сильная сторона автора:)

    moonie, 21 Августа 2010

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

    +166

    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
    function lowcase($string)
    
               {
    
               $string = ereg_replace('A',"a",$string);
    
               $string = ereg_replace('B',"b",$string);
    
               $string = ereg_replace('C',"c",$string);
    
               $string = ereg_replace('D',"d",$string);
    
               $string = ereg_replace('E',"e",$string);
    
               $string = ereg_replace('F',"f",$string);
    
               $string = ereg_replace('G',"g",$string);
    
               $string = ereg_replace('H',"h",$string);
    
               $string = ereg_replace('I',"i",$string);
    
               $string = ereg_replace('J',"j",$string);
    
               $string = ereg_replace('K',"k",$string);
    
               $string = ereg_replace('L',"l",$string);
    
               $string = ereg_replace('M',"m",$string);
    
               $string = ereg_replace('N',"n",$string);
    
               $string = ereg_replace('O',"o",$string);
    
               $string = ereg_replace('P',"p",$string);
    
               $string = ereg_replace('Q',"q",$string);
    
               $string = ereg_replace('R',"r",$string);
    
               $string = ereg_replace('S',"s",$string);
    
               $string = ereg_replace('T',"t",$string);
    
               $string = ereg_replace('U',"u",$string);
    
               $string = ereg_replace('V',"v",$string);
    
               $string = ereg_replace('W',"w",$string);
    
               $string = ereg_replace('X',"x",$string);
    
               $string = ereg_replace('Y',"y",$string);
    
               $string = ereg_replace('Z',"z",$string);
    
               return ($string);
    
               }

    перевод в нижний регистр:) все в том же движке. Конечно автор не догадывался что в пхп есть функция strtolower(). Ну и работает конечно раз в 1000 быстрее его функции...

    moonie, 21 Августа 2010

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

    +159

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    7. 7
    8. 8
    9. 9
    function redirect($location,$time)
    
    {
    
    	$time=$time*1000;
    
    	echo "<script>setTimeout(\"top.location.href='".$location."'\",".$time.");</script>";
    
    }

    Самописный движок этой фирмы http://www.newartline.ru. Это редирект там полно такого пока читал думал легкие выплюну:)

    moonie, 21 Августа 2010

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

    +162

    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
    function SentMessage($Text,$Title) {
    
    	$r=mysql_query("SELECT `id`,`login`,`email` FROM `".$this->TableUsers."` WHERE `access` = 1 and `check_email`=1");
    
    	while( $res = mysql_fetch_array($r) ){               
    		mysql_query("
    			INSERT INTO `".$this->MessTable."` ( 
    				`From` , `To` , `Date` , `Title` , `Text` 
    			) VALUES (
    				'".$this->MainUser['id']."', '".$res[id]."', NOW(), '".$Title."', '".$Text."'
    			)
    		");
    
    		$body=BuildBody("mail.message", $res);
    
    		$headers=' /*... заголовок  ...*/ ';
    		mail ( $res[email], " /*... отправитель ..*/ ", $body, $headers);
    	}
    }

    вот такое чудо враждебной техники откопалось при колупании одной cms'ки...
    (при том что выборка из $this->TableUsers с такими условиями получалась порядка ~500 т. строк )

    istem, 20 Августа 2010

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