1. Список говнокодов пользователя xcont

    Всего: 6

  2. PHP / Говнокод #11758

    +49

    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
    wordpress:
    function __( $text, $domain = 'default' ) {
    	        return translate( $text, $domain );
    }
    
    function translate( $text, $domain = 'default' ) {
    	        $translations = &get_translations_for_domain( $domain );
    	        return apply_filters( 'gettext', $translations->translate( $text ), $text, $domain );
    }
    
    PHP-manual:
    PHP reserves all function names starting with __ as magical. It is recommended that you do not use function names with __ in PHP unless you want some documented magic functionality. 
    
    wordpress:
    /*
    * Don't use translate() directly, use __()
    */

    xcont, 12 Сентября 2012

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

    +78

    1. 1
    <a href="<?php session_destroy(); ?>">Прервать сессию</a><br>

    Нарочно не придумаешь.

    xcont, 03 Сентября 2012

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

    +66

    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
    98. 98
    99. 99
    //header.php
    <div id="search-box">						
                <form action="<?=$_SERVER["REQUEST_URI"]?>" method="get" style="padding:0;margin:0;">
    <?php
    $sql="SELECT * FROM wp_gorod ORDER BY name_gorod ASC ";
    $res=mysql_query($sql);
    $g=array();if($_GET['gorod']!=""){
    	$id=$_GET['gorod'];
    	$_SESSION['gorod_id']=$id;
    	$ig=$_REQUEST['gorod_id'];}
    $ig=$_SESSION['gorod_id'];	
    echo "<select onchange='return this.form.submit()' name='gorod'>\n";	echo "<option value='0'>Выберите город</option>\n";
    while($row=mysql_fetch_array($res)){
    	if($row['id_gorod']==$_SESSION['gorod_id']){
    		echo "<option value='".$row['id_gorod']."' selected='selected'>".$row['name_gorod']."</option>\n";	}else{
    		echo "<option value='".$row['id_gorod']."'>".$row['name_gorod']."</option>\n";
    	}
    }echo "</select>     <font size=\"4\" color=\"#F46F2A\">".$_SESSION['number']."</font>\n";if(isset($_SESSION['gorod_id'])){
    	echo "<br>\n";
    	$sql1="Select * from wp_gorod where id_gorod=".$ig;
    	$r=mysql_query($sql1);
    	$rw=mysql_fetch_array($r);
    	echo "<div class=tel><b> ".$rw['telephone']. "<br /></b></div>\n";
    	echo "<div class=adres align=right>".$rw['adres']."<br/>\n";
    	echo "".$rw['email']."</div>\n";
    }
    ?>
             <noscript><input type="submit" value="View" /></noscript>
             </form></div>
    
    //index.php
    if ($_SERVER['REQUEST_URI'] == '/doneck/') {
    header("Location: /doneck/?gorod=15");
    return;
    }
    if ($_SERVER['REQUEST_URI'] == '/vinnica/') {
    header("Location: /vinnica/?gorod=13");
    return;
    }
    if ($_SERVER['REQUEST_URI'] == '/dnepropetrovsk/') {
    header("Location: /dnepropetrovsk/?gorod=14");
    return;
    }
    if ($_SERVER['REQUEST_URI'] == '/zhitomir/') {
    header("Location: /zhitomir/?gorod=17");
    return;
    }
    if ($_SERVER['REQUEST_URI'] == '/zaporozhe/') {
    header("Location: /zaporozhe/?gorod=18");
    return;
    }
    if ($_SERVER['REQUEST_URI'] == '/ivano-frankovsk/') {
    header("Location: /ivano-frankovsk/?gorod=19");
    return;
    }
    if ($_SERVER['REQUEST_URI'] == '/kiev/') {
    header("Location: /kiev/?gorod=20");
    return;
    }
    if ($_SERVER['REQUEST_URI'] == '/kirovograd/') {
    header("Location: /kirovograd/?gorod=37");
    return;
    }
    if ($_SERVER['REQUEST_URI'] == '/lugansk/') {
    header("Location: /lugansk/?gorod=21");
    return;
    }
    if ($_SERVER['REQUEST_URI'] == '/luck/') {
    header("Location: /luck/?gorod=22");
    return;
    }
    if ($_SERVER['REQUEST_URI'] == '/lvov/') {
    header("Location: /lvov/?gorod=23");
    return;
    }
    if ($_SERVER['REQUEST_URI'] == '/nikolaev/') {
    header("Location: /nikolaev/?gorod=24");
    return;
    }
    if ($_SERVER['REQUEST_URI'] == '/odessa/') {
    header("Location: /odessa/?gorod=25");
    return;
    }
    if ($_SERVER['REQUEST_URI'] == '/poltava/') {
    header("Location: /poltava/?gorod=26");
    return;
    }
    if ($_SERVER['REQUEST_URI'] == '/rovno/') {
    header("Location: /rovno/?gorod=27");
    return;
    }
    if ($_SERVER['REQUEST_URI'] == '/krym/') {
    header("Location: /krym/?gorod=28");
    return;
    }
    if ($_SERVER['REQUEST_URI'] == '/sumy/') {
    header("Location: /sumy/?gorod=29");
    return;
    }

    Чья-то модификация для wordpress.
    1. google скушал 2000 ссылок вида http://адрес-сайта/чпу/?gorod=29 (http://адрес-сайта/чпу/?gorod=26, http://адрес-сайта/чпу/?gorod=25, ...) и понизил сайт в выдаче
    2. sql-инъекций идет на ура. Странно, что никто не воспользовался.

    xcont, 26 Июля 2012

    Комментарии (6)
  5. VisualBasic / Говнокод #11421

    −98

    1. 001
    2. 002
    3. 003
    4. 004
    5. 005
    6. 006
    7. 007
    8. 008
    9. 009
    10. 010
    11. 011
    12. 012
    13. 013
    14. 014
    15. 015
    16. 016
    17. 017
    18. 018
    19. 019
    20. 020
    21. 021
    22. 022
    23. 023
    24. 024
    25. 025
    26. 026
    27. 027
    28. 028
    29. 029
    30. 030
    31. 031
    32. 032
    33. 033
    34. 034
    35. 035
    36. 036
    37. 037
    38. 038
    39. 039
    40. 040
    41. 041
    42. 042
    43. 043
    44. 044
    45. 045
    46. 046
    47. 047
    48. 048
    49. 049
    50. 050
    51. 051
    52. 052
    53. 053
    54. 054
    55. 055
    56. 056
    57. 057
    58. 058
    59. 059
    60. 060
    61. 061
    62. 062
    63. 063
    64. 064
    65. 065
    66. 066
    67. 067
    68. 068
    69. 069
    70. 070
    71. 071
    72. 072
    73. 073
    74. 074
    75. 075
    76. 076
    77. 077
    78. 078
    79. 079
    80. 080
    81. 081
    82. 082
    83. 083
    84. 084
    85. 085
    86. 086
    87. 087
    88. 088
    89. 089
    90. 090
    91. 091
    92. 092
    93. 093
    94. 094
    95. 095
    96. 096
    97. 097
    98. 098
    99. 099
    100. 100
    Private Sub Command2_Click()
    Cls
    For x = 1 To Text2 + 1
    For y = 1 To Text2 + 1
    A(x, y) = Round(Rnd(1))
    If A(x, y) = 0 Then A(x, y) = -1
    Next
    Next
    For x = 2 To Text2
    For y = 2 To Text2
    PSet (1200 + x * 15, 200 + y * 15), A(x, y)
    Next
    Next
    End Sub
    
    Private Sub Command3_Click()
    Cls
    For x = 1 To Text2 + 1
    For y = 1 To Text2 + 1
    A(x, y) = 1
    Next
    Next
    A(Text20, Text21) = -1
    A(Text22, Text23) = -1
    A(Text24, Text25) = -1
    A(Text26, Text27) = -1
    For x = 2 To Text2
    For y = 2 To Text2
    PSet (1200 + x * 15, 200 + y * 15), A(x, y)
    Next
    Next
    End Sub
    
    Private Sub Form_Load()
    
    For x = 1 To Text2 + 1
    For y = 1 To Text2 + 1
    A(x, y) = Round(Rnd(1))
    If A(x, y) = 0 Then A(x, y) = -1
    Next
    Next
    
    
    
    'For x = 1 To Text2 + 1
    'For y = 1 To Text2 + 1
    'A(x, y) = 1
    'Next
    'Next
    'A(10, 10) = -1
    
    
    
    End Sub
    
    Private Sub Command1_Click()
    Cls
    
    For k = 1 To Text1
    
    For x = 1 To Text2 + 1
    A(x, 1) = A(x, Text2)
    A(x, Text2 + 1) = A(x, 2)
    Next
    
    For y = 1 To Text2 + 1
    A(1, y) = A(Text2, y)
    A(Text2 + 1, y) = A(2, y)
    Next
    
    
    
    For x = 2 To Text2
    For y = 2 To Text2
    
    xp = A(x - 1, y - 1) + A(x, y - 1) + A(x + 1, y - 1) + A(x - 1, y) + A(x + 1, y) + A(x - 1, y + 1) + A(x, y + 1) + A(x + 1, y + 1)
    Select Case xp
    Case -8
    B(x, y) = Text3
    Case -7
    B(x, y) = Text4
    Case -6
    B(x, y) = Text5
    Case -5
    B(x, y) = Text6
    Case -4
    B(x, y) = Text7
    Case -3
    B(x, y) = Text8
    Case -2
    B(x, y) = Text9
    Case -1
    B(x, y) = Text10
    Case 0
    B(x, y) = Text11
    Case 1
    B(x, y) = Text12
    Case 2
    B(x, y) = Text13
    Case 3

    Жестокий, безумный мозг пятнадцатилетнего пацана родил клеточный автомат. Нашел свои исходники десятилетней давности.
    А ведь я себя тогда считал крутым программистом... стыдно вспоминать.

    xcont, 16 Июля 2012

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

    +56

    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
    <html>
    <head>
    <style>
       body{
        background-color: #3366CC; /* Цвет фона веб-страницы */
       }
    </style>
    </head>
    <body>
    <?php
    	/*error_reporting(E_ALL);*/
    	class Mirror{
    		public $sizeX;
    		public $sizeY;
    		public $filenameI;
    		public $filenameO;
    		public $red;
    		public $green;
    		public $blue;
    		public $alpha;
    		function __construct($f){
    			$this->filenameI=$f.".png";
    			$this->filenameO=$f."2.png";
    			$size=getimagesize($this->filenameI);
    			$this->sizeX=$size[0];
    			$this->sizeY=$size[1];
    		}
    		function saveImg(){
    			if(!file_exists($this->filenameO)){
    				$xx=$this->sizeX;
    				$yy=($this->sizeY)*2;
    				$im = imagecreatetruecolor($xx, $yy);
    				imageAlphaBlending($im, false);
    				imageSaveAlpha($im, true);
    				for($x=0;$x<$xx;$x++){
    					for($y=0;$y<$yy;$y++){
    						$r=$this->red[$x][$y];
    						$g=$this->green[$x][$y];
    						$b=$this->blue[$x][$y];
    						$alph=$this->alpha[$x][$y];
    						$color=ImageColorAllocateAlpha($im, $r, $g, $b, $alph);
    						imagesetpixel($im, $x, $y, $color);
    					}
    				}
    				imagepng($im, $this->filenameO);
    				imagedestroy($im);
    			}
    			echo "<img src=\"".$this->filenameI."\" /><hr>\n";
    			echo "<img src=\"".$this->filenameO."\" /><br>\n";
    		}
    		function loadImg(){
    			$im = imagecreatefrompng($this->filenameI);
    			for($x=0;$x<$this->sizeX;$x++){
    				for($y=0;$y<$this->sizeY;$y++){
    					$rgb = imagecolorat($im, $x, $y);
    					$color=imagecolorsforindex($im, $rgb);
    					$this->red[$x][$y]=$color['red'];
    					$this->green[$x][$y]=$color['green'];
    					$this->blue[$x][$y]=$color['blue'];
    					$this->alpha[$x][$y]=$color['alpha'];
    				}
    			}
    			imagedestroy($im);
    		}
    		function createMirror(){
    			if(!file_exists($this->filenameO)){
    				$yy=($this->sizeY*2);
    				for($x=0;$x<$this->sizeX;$x++){
    					$alph=0;
    					for($y=$this->sizeY;$y<$yy;$y++){
    						if($alph<126){
    							$alph++;
    						}
    						$this->red[$x][$y]=$this->red[$x][$this->sizeY-($y-$this->sizeY)-1];
    						$this->green[$x][$y]=$this->green[$x][$this->sizeY-($y-$this->sizeY)-1];
    						$this->blue[$x][$y]=$this->blue[$x][$this->sizeY-($y-$this->sizeY)-1];
    						$this->alpha[$x][$y]=$alph+$this->alpha[$x][$this->sizeY-($y-$this->sizeY)-1];
    						if($this->alpha[$x][$y]>127) $this->alpha[$x][$y]=127;
    					}
    				}
    			}
    		}
    	}
    	$filename="alpha";
    	$mirror=new Mirror($filename);
    	$mirror->loadImg();
    	$mirror->createMirror();
    	$mirror->saveImg();
    ?>
    </body>
    </html>

    Делал для одного сайта зеркальное отражение картинки (photoshop использовать не умеем-с). Почему-то сервер часто падал.
    Как оно работает, можно посмотреть здесь http://xcont.com/perc/newperceptron/cell/mirror.php

    xcont, 11 Июля 2012

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

    +61

    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
    function myrnd(){
    	$rnd1=rand(48,57);
    	$rnd2=rand(65,90);
    	$rnd3=rand(97,122);
    	$rnd4=rand(1,3);
    	$rnd5="rnd".$rnd4;
    	return $$rnd5;
    }
    function createReffererLink(){
    	$refferer="";
    	for($i=0;$i<12;$i++){
    		$refferer.=chr($this->myrnd());
    	}
    	return $refferer;
    }

    Нашел в своей старой партнерской программе. Угадайте, что делает этот код? ( генерирует реферальную ссылку )

    xcont, 07 Июля 2012

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