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

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

    +143

    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 RecursiveDir($in_dir) {
    
    $dir_handle = scandir($in_dir);
    
    for ($i=0; $i<count($dir_handle); $i++) {
    
    if (is_dir($dir_handle[$i])==1 && $dir_handle[$i]!=".." && $dir_handle[$i]!=".") {
    
    RecursiveDir($in_dir."/".$dir_handle[$i]);
    
    } else {
    echo $dir_handle[$i]."\n";
    } 
    
    }
    
    }
    
    RecursiveDir("/");

    заходит только в папки в названии которых содержится "tmp|temp"
    Этого быть не должно :(

    guest, 11 Июля 2009

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

    +150

    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
    <?php
    
    class db {
    
    var $MySQL_time_taken = 0;
    
    function __construct ($mysql_host,$mysql_user,$mysql_pass,$mysql_db,$mysql_charset="cp1251") {
    
    //	global $mysql_host,$mysql_user,$mysql_pass,$mysql_db;
    
    	if(!($this->link = @mysqli_connect($mysql_host,$mysql_user,$mysql_pass)))
    		{
    		echo "<font color=\"red\">Error:</font> connect to host: $mysql_host";
    		//exit();
    		}
    	if(!mysqli_select_db($this->link,$mysql_db))
    		{
    		echo "<font color=\"red\">Error:</font> select database $mysql_db";
    		exit();
    		}
    	
     	mysqli_query($this->link,"SET NAMES $mysql_charset");
    	return $this->link;
    	}
    
    function sql_query ($query,$debug=false) {
    	$time_befor = $this->get_real_time();
    	$result = mysqli_query($this->link, $query);
    		if (!$result)
    			{
    			$this->error_msg = mysqli_error($result);
    			return print($this->error_msg);
    			}
    	
    	$this->MySQL_time_taken += $this->get_real_time() - $time_before;
    	//print("<font color=\"blue\">" . $time . "</font><br>");
    	return $result;
    	}
    
    function sql_fetch_assoc ($query) {
    		$res=sql_query($query);
    		while ($rows = mysqli_fetch_assoc($res))
    			{
    			$row[]=$rows;
    			}
    		mysqli_free_result($res);
    		return $row;
    	}
    
    function sql_fetch_array ($query,$numarr=MYSQLI_BOTH) {
    		$res = $this->sql_query($query);
    		
    		while ($row = mysqli_fetch_array($res,$numarr))
    			{
    			$array[] = $row;
    			}
    		
    		mysqli_free_result($res);
    		return $array;
    	}
    
    function get_id_passkey ($passkey) {
    		$query = "SELECT id FROM users WHERE passkey='" . $passkey . "'";
    		$res=$this->sql_query($query);
    		$row = mysqli_fetch_array($res);
    		mysqli_free_result($res);
    		return $row;
    	}
    
    function get_real_time()
            {
                    list($seconds, $microSeconds) = explode(' ', microtime());
                    return ((float)$seconds + (float)$microSeconds);
            }
    
    function torrent_search ($string,$owner="",$sort="added",$cat="all",$checked="2")
    	{
    	$limit = 10;
    	$stmt = mysqli_prepare($this->link, "SELECT id,name,owner,added,cheched FROM torrents WHERE name '%?%' AND checked='?' AND owner='?'SORT BY ? LIMIT ?");
    	var_dump($stmt);
    	//mysqli_bind_param('sissi', $string,$checked,$owner,$sort,$limit);
    	mysqli_bind_param(mysqli_stmt_init($this->link),'sissi', $string,$checked,$owner,$sort,$limit);
    	mysqli_stmt_execute($stmt) or die("Ошибка:  Неудачный запрос");
    	$stmt = mysqli_stmt_bind_result($id, $name, $owner, $added, $checked);
    		while ($stmt->fetch()) { 
            		echo "|" . $id . " || " . $name . " || " . $owner . " || " . $added . " || " . $checked . "|<br>";
    		}
    	mysqli_stmt_close($stmt);
    	}
    
    function catlist() 
    	{
    	$query = "SELECT id, name FROM categories ORDER BY sort ASC";
    	$ret = $this->sql_fetch_array($query);
    	$cats_list = "";
    	foreach ($ret as $cats_list_array) 
    		{
    		$cats_list .= "<option name=\"" . $cats_list_array["id"] . "\">" . $cats_list_array["name"] . "</option>";
    		}
    	return $cats_list;

    guest, 10 Июля 2009

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

    +150

    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
    <?php
    require_once "class/db.php";
    require_once "secrets.php";
    
    ini_set("error_reporting","E_ALL");
    
    $db_obj= new db($mysql_host,$mysql_user,$mysql_pass,$mysql_db);
    
    while ($row=$object->sql_fetch_assoc("SELECT id, name FROM categories ORDER BY sort ASC"))
    	{
    	$cats[] = $row;
    	}
    
    $cats_list = "";
    
    while ($cats){
    	{
    	$cats_list .= "<options value=\"" . $cats['id'] . "\">" . $cats['name'] . "</options>";
    	}
    
    $form = <<<FORM
    	<form action='" . $PHP_SELF . "' method='post' enctype='multipart/form-data'>
    	<b>Поиск</b><br>
    	<tr>
    	<td>
    	<b>Cтрока поиска:</b><input type=\"text\" size=\"40\" name=\"string\">
    	</td>
    	<td>
    	<b>Выберете категорию</b>
    	<select name=\"cats\">
    	$cats_list
    	</select>
    	</td>
    	</tr>
    	</form>
    FORM;
    
    print ($form);
    ?>

    guest, 09 Июля 2009

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

    +146

    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
    $link="http://cert.vatsim.net/cert/vatsimnet/idstatus.php?cid=111111";
    $contents = file_get_contents($link);
    
    if ($contents!=FALSE) {
    
        $xml = simplexml_load_string($contents);
    
        $output = "<code>".$contents."</code><br>LAST NAME: ".$xml->user->name_last;
        $output.="<br>EMAIL: ".$xml->user->email;
        
        return $output;
    }
    else {
        return "FAILED";
    }
    ?>

    Парсерчег XML статов из сети ВАТСИМ

    guest, 08 Июля 2009

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

    +154

    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
    <?php
      $br="
    ";
      include "functions.php";
      mconnect();
      $result=mysql_query("TRUNCATE base");  
      $tags=file_get_contents("tag_cache");
    
      $tags=str_replace("'","\'",$tags);
      $tags=explode("songList begin",$tags);
      $j=0;
      for($i=1; $i<count($tags); $i++)
      {
        $tmp=explode("songList end",$tags[$i]);
        $tbase[$j++]=$tmp[0];
      }
      $j=0;
      for($i=0; $i<count($tbase); $i++)
      {
        $tmp=explode("key: ", $tbase[$i]);
        for($i2=1; $i2<count($tmp); $i2++)
    	$element[$j++]=$tmp[$i2];
      }
      for($i=0; $i<count($element); $i++)
      {
        $tmp=explode($br."file: ",$element[$i]);
        $track[$i]['key']=$tmp[0];
    
        $tmp=explode($br."Time: ",$tmp[1]);
        $track[$i]['file']=$tmp[0];
       
        $tmp=explode($br."Artist: ",$tmp[1]);
        $track[$i]['Time']=$tmp[0];
    
        $tmp=explode($br."Title: ", $tmp[1]);
        $track[$i]['Artist']=$tmp[0];
    
        $tmp=explode($br."Album: ", $tmp[1]);
        $track[$i]['Title']=$tmp[0];
    
        $tmp=explode($br."Track: ", $tmp[1]);
        $track[$i]['Album']=$tmp[0];
    
        $tmp=explode($br."Date: ", $tmp[1]);
        $track[$i]['Track']=$tmp[0];
    
        $tmp=explode($br."Genre: ", $tmp[1]);
        $track[$i]['Date']=$tmp[0];
    
        $tmp=explode($br."mtime: ", $tmp[1]);
        $track[$i]['Genre']=$tmp[0];
        $track[$i]['mtime']=$tmp[1];
    	$track[$i]['Size']=filesize(str_replace("\'","'", $track[$i]['file']));
      }
      for($i=0; $i<count($track); $i++)
      {
        //	echo $track[$i]['Artist']." -  ".$track[$i]['Album'].": ".$track[$i]['Title']."; " . round($track[$i]['Time']/60) . "m " .$track[$i]['Time']%60 . "s<hr>";
        $request="INSERT INTO base (file, Time, Artist, Title, Album, Track, Date, Genre, mtime, Size) VALUES ('".
    $track[$i]['file']."', '"
    .$track[$i]['Time']."', '"
    .$track[$i]['Artist']."', '"
    .$track[$i]['Title']."', '"
    .$track[$i]['Album']."', '"
    .$track[$i]['Track']."', '"
    .$track[$i]['Date']."', '"
    .$track[$i]['Genre']."', '"
    .$track[$i]['mtime']."', '"
    .$track[$i]['Size']."')";
    
      echo $request."<hr>";
      $result=mysql_query($request) or die(mysql_error().$i.";(");
      }
    ?>

    Прога, которая из базы mpd запихивает в mysql

    guest, 06 Июля 2009

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

    +152

    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
    private function isValidShowcase ($v) {
    		/*if ( empty($v->showcase_date) ) {
    			return false;
    		}
    
    		if ( empty($v->showcase_location) ) {
    			return false;
    		}
    		
    		if ( empty($v->showcase_name) ) {
    		 	return false;
    		 }*/
    		 
    		 return true;
    	}

    заебись

    guest, 02 Июля 2009

    Комментарии (1)
  8. 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)
  9. PHP / Говнокод #1292

    +158.8

    1. 1
    $col=array('red','blue','green','black','yellow','magenta','blue','gray','red','blue','green','black','yellow','blue','gray','red','blue','green','black','yellow','blue','gray');

    А какие ты знаешь цвета?

    guest, 30 Июня 2009

    Комментарии (1)
  10. Java / Говнокод #1289

    +154

    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
    /**
    	 * public static final int ARRAY 2003 public static final int BIGINT -5
    	 * public static final int BINARY -2 public static final int BIT -7 public
    	 * static final int BLOB 2004 public static final int BOOLEAN 16 public
    	 * static final int CHAR 1 public static final int CLOB 2005 public static
    	 * final int DATALINK 70 public static final int DATE 91 public static final
    	 * int DECIMAL 3 public static final int DISTINCT 2001 public static final
    	 * int DOUBLE 8 public static final int FLOAT 6 public static final int
    	 * INTEGER 4 public static final int JAVA_OBJECT 2000 public static final
    	 * int LONGVARBINARY -4 public static final int LONGVARCHAR -1 public static
    	 * final int NULL 0 public static final int NUMERIC 2 public static final
    	 * int OTHER 1111 public static final int REAL 7 public static final int REF
    	 * 2006 public static final int SMALLINT 5 public static final int STRUCT
    	 * 2002 public static final int TIME 92 public static final int TIMESTAMP 93
    	 * public static final int TINYINT -6 public static final int VARBINARY -3
    	 * public static final int VARCHAR 12
    	 */
    	public Class getColumnClass(int column) {
                ...
            }

    guest, 30 Июня 2009

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

    +150

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    11. 11
    private int style;
    public int Style
    {
       get
       {
          return style;
       }
       {
          Style = value;
       }
    }

    Вечный двигатель!

    guest, 30 Июня 2009

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