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

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

    +158

    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
    <?PHP
    	
    	# Регистрация
    
    	if(isset($_POST["login"])){
    	
    	if(isset($_SESSION["captcha"]) AND strtolower($_SESSION["captcha"]) == strtolower($_POST["captcha"])){
    	unset($_SESSION["captcha"]);
    
    	$login = $func->IsLogin($_POST["login"]);
    	$pass = $func->IsPassword($_POST["pass"]);
    	$rules = isset($_POST["rules"]) ? true : false;
    	$time = time();
    	$ip = $func->UserIP;
    	$UserIP = $_SERVER['REMOTE_ADDR'];
    	
    	$email = $func->IsMail($_POST["email"]);
    	$referer_id = (isset($_COOKIE["i"]) AND intval($_COOKIE["i"]) > 0 AND intval($_COOKIE["i"]) < 1000000) ? intval($_COOKIE["i"]) : 1;
    	$referer_name = "";
    	if($referer_id != 1){
    		$db->Query("SELECT user FROM db_users_a WHERE id = '$referer_id' LIMIT 1");
    		if($db->NumRows() > 0){$referer_name = $db->FetchRow();}
    		else{ $referer_id = 1; $referer_name = "wolframavtor"; }
    	}else{ $referer_id = 1; $referer_name = "wolframavtor"; }
    	
    		if($rules){
    
    			if($email !== false){
    		
    			if($login !== false){
    			
    				if($pass !== false){
    			
    					if($pass == $_POST["repass"]){
    						
    						$db->Query("SELECT COUNT(*) FROM db_users_a WHERE user = '$login'");
    						if($db->FetchRow() == 0){
    						
    						# Регаем пользователя
    						$db->Query("INSERT INTO db_users_a (user, email, pass, referer, referer_id, date_reg, ip) 
    						VALUES ('$login','{$email}','$pass','$referer_name','$referer_id','$time',INET_ATON('$ip'))");
    						
    						$lid = $db->LastInsert();
    						
    						$db->Query("INSERT INTO db_users_b (id, user, a_t, last_sbor) VALUES ('$lid','$login','1', '".time()."')");
    						
    						# Вставляем статистику
    						$db->Query("UPDATE db_stats SET all_users = all_users +1 WHERE id = '1'");
    						
    						echo "<center><b><font color = 'green'>Вы успешно зарегистрировались. Используйте форму слева для входа в аккаунт</font></b></center><BR />";
    						?></div>
    						<div class="clr"></div>	
    						<?PHP
    						return;
    						}else echo "<center><b><font color = 'red'>Указанный логин уже используется</font></b></center><BR />";
    						
    					}else echo "<center><b><font color = 'red'>Пароль и повтор пароля не совпадают</font></b></center><BR />";
    			
    				}else echo "<center><b><font color = 'red'>Пароль заполнен неверно</font></b></center><BR />";
    			
    			}else echo "<center><b><font color = 'red'>Логин заполнен неверно</font></b></center><BR />";
    
    		}else echo "<center><font color = 'red'><b>Email имеет неверный формат</b></font></center>";
    
    		}else echo "<center><b><font color = 'red'>Вы не подтвердили правила</font></b></center><BR />";
    	
    		}else echo "<center><font color = 'red'><b>Символы с картинки введены неверно</b></font></center>";
    
    	}
    	
    	
    ?>

    ШЕДЕВРАЛЬНО!

    proweber1, 09 Марта 2015

    Комментарии (11)
  3. Java / Говнокод #17741

    +79

    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
    private short findHeaderLength() {
        return (short)(
            1+
            3+
            4+
            2+
            2+
            2+
            1+
            1+
            4+
            4+
            4+
            1+
            1+
            2+
            (32*fieldArray.length)+
            1
        );
    }

    DBFHeader

    bormand, 06 Марта 2015

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

    +51

    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
    #include <ppl.h>
    #include <windows.h>
    #include <ppltasks.h>
    #include <iostream>
    #include <vector>
    
    using namespace Concurrency;
    using namespace std;
    
    CRITICAL_SECTION cs6;
    
    int main(int argc, char* argv[])
    {
    	size_t concurentThreadsSupported = std::thread::hardware_concurrency();
    	cout << concurentThreadsSupported << endl;
    	//deadlock hazard increased with concurentThreadsSupported decreasing
    
    	size_t taskAmountForWasteVirtualCores = concurentThreadsSupported - 1;//must be equal to (virtual processor thread amount from Concurrency::IResourceManager) - 1
    	vector<task<void>> t;
    	for (size_t i = 0; i<taskAmountForWasteVirtualCores; ++i)
    		t.push_back(create_task([]{
    			Sleep(INFINITE);//some very long IO operation or deadlocked by EnterCriticalSection or sql transaction or other
    		}));
    	Sleep(1000);
        cout << "another way:" << endl;
        InitializeCriticalSection(&cs6);
        auto locker = create_task([]{
            cout << "locker" << endl;
            EnterCriticalSection(&cs6);//same as begin sql transaction
            cout << "locker entered cs 6" << endl;
            Concurrency::wait(500);//Deadlock by any concurrency context switching directly or indirectly by std or MFC (events, mutex, etc)
            cout << "locker played" << endl;
            LeaveCriticalSection(&cs6);//same as end sql transaction
            cout << "~locker ok" << endl;
        });
        auto locked = create_task([]{
            cout << "locked" << endl;
            EnterCriticalSection(&cs6);//same as begin sql transaction
            cout << "locked entered cs 6" << endl;
            Concurrency::wait(500);
            cout << "locked played" << endl;
            LeaveCriticalSection(&cs6);//same as end sql transaction
            cout << "~locked ok" << endl;
        });
    	Sleep(1000);
    	cout << "FAIL" << endl;
    	return 0;
    }

    Нашел дидлок)
    http://rextester.com/KHC72232
    http://rextester.com/EMG65441

    laMer007, 04 Марта 2015

    Комментарии (11)
  5. JavaScript / Говнокод #17708

    +159

    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
    <p>
                    <script>// <![CDATA[
                        if (navigator.appVersion.indexOf("Win") != -1) {
                            document.getElementById("windows").style.display = "inline";
                        } else if (navigator.appVersion.indexOf("Mac") != -1) {
                            document.getElementById("osx").style.display = "inline";
                        } else if (navigator.appVersion.indexOf("Linux") != -1) {
                            document.getElementById("linux").style.display = "inline";
                        } else {
                            document.getElementById("windows").style.display = "inline";
                            document.getElementById("osx").style.display = "inline";
                            document.getElementById("linux").style.display = "inline";
                        }
                        // ]]&gt;</script>
                </p>

    Недавно один Java-pазработчик не смог разобраться, как пофиксеть баг в WordPress и решил переписать наш корпоративный сайт на Java мотивируя это тем, что будет намного легче поддерживать и развивать новую ситсему. Что из этого получилось видно на наглядном примере js-кода в верстке.

    etual, 27 Февраля 2015

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

    +56

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    `        enum SearchFlag
             {
                 IgnoreCase = 0x00000001,    ///< Case differences are ignored
    -            WholeWorlds = 0x00000002    ///< Only whole words are matched
    +            WholeWords = 0x00000002    ///< Only whole words are matched
             };

    очепятка + копи-паста = world domination.

    http://lists.freedesktop.org/archives/poppler/2015-January/011251.html

    http://cgit.freedesktop.org/poppler/poppler/commit/?id=78abf540057181b708c546aee421f81a1dd5 8331

    Dummy00001, 22 Января 2015

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

    +155

    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
    public function actionNominate()
    	{
    		if (isset($_POST['user']) and isset($_POST['ref']))
    		{
    
    			$user = $ref = NULL;
    			$user = strip_tags(trim($_POST['user']));
    			$ref = strip_tags(trim($_POST['ref']));
    
    			$test = UserAwardsRef::model()->count(array("condition"=>"id_ref=$ref AND id_user=$user"));
    
    			if ($test==0)
    			{
    				if ($user and $ref)
    				{
    					$model = new UserAwardsRef();
    					$model->id_ref = $ref;
    					$model->id_user = $user;
    					if ($model->save())
    					{
    						echo 1;
    					} else {
    						echo 'error';
    					}
                    } else {
    
    					echo "error";
    				}
    
    			} else {
    				echo 2;
    			}
    
    		} else {
    
    			echo "error";
    		}
    
    	}

    Входящие параметры предполагаются - integer
    Необходимо один раз насрать в таблицу с ключами из поста.

    obidnov, 16 Января 2015

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

    +133

    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
    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Text;
    
    namespace nonopt
    {
        class Program
        {
            static void Main(string[] args)
            {
                string h = "h";
                string e = "e";
                string l1 = "l";
                string l2 = "l";
                string o1 = "o";
                string he = h + e;
    			string ll = l1 + l2;
                string hell = he + ll;
                string hello = hell + o1;
                string w = "w";
                string o2 = "o";
                string r = "r";
                string l3 = "l";
                string d = "d";
                string wo = w + o2;
                string rl = r + l3;
                string worl = wo + rl;
                string world = worl + d;
                string empty = " ";
                Console.WriteLine(hello + empty + world);
    			Console.ReadKey();
            }
        }
    }

    pewppy, 10 Января 2015

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

    +157

    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
    $('.file_work .left .content a.create').bind('click', function(){
            show.in_question(strings.question[2], {
                0:strings.question[2].buttons[0], 
                1:strings.question[2].buttons[1]
            }, function(action, string){
                if(action !='ok'){
                    return;
                }
                if(string.length<4){
                    show.error(strings.error[7], '');
                    return;
                }
                CreateTag(cache.current, string);
            });
        });

    хуита, 22 Декабря 2014

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

    +58

    1. 1
    int (o)(0);

    http://ideone.com/9JL6K4

    bormand, 22 Декабря 2014

    Комментарии (11)
  11. Python / Говнокод #17343

    −107

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    ****@****:~$ python
    >>> import this
    The Zen of Python, by Tim Peters
    <....>There should be one-- and preferably only one --obvious way to do it.<...>
    >>> exit
    Use exit() or Ctrl-D (i.e. EOF) to exit

    preferably only one

    heyzea1, 19 Декабря 2014

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