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

    В номинации:
    За время:
  2. Куча / Говнокод #13874

    +126

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    <link rel="stylesheet" href="/libraries/mediaelement/mediaelementplayer.min.css">
    <link href="http://code.jquery.com/ui/1.10.0/themes/base/jquery-ui.css" rel="stylesheet">
    <script type="text/javascript" src="/js/jquery/jquery-latest.js"></script>
    <script src="//ajax.googleapis.com/ajax/libs/jqueryui/1.9.2/jquery-ui.min.js"></script>
    <script type="text/javascript" src="/libraries/mediaelement/andplayer.min.js"></script>
    <script type="text/javascript" src="/js/jquery_tools.js"></script>

    Все это, пара десятков строк мутного джаваскрипта и столько же HTMLя и PHP потребовалось опытному филиппинскому сотруднику, чтобы добавить видеоролик на страницу.

    quall, 30 Сентября 2013

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

    +147

    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
    function SaveDataFromS() {
            if (window.sessionStorage) { 
                if ($('#dvFilter').html().length > 0 && $('.right_results').html().length > 0) {
                    var tourSearchForm = $('#dvFilter').html();
                    var searchResults = $('.right_results').html();
                    //sessionStorage.setItem('tourSearchForm', tourSearchForm);
                    //sessionStorage.setItem('searchResults', searchResults);
                }
            }
    
            var hotSearchFormSer = $('#hotelSearchForm').serialize();
            var unserialForm = $.unserialize(hotSearchFormSer);
    
            for (var x in unserialForm) {
                if (unserialForm[x] == ""
                    || x.toUpperCase() != "Hotel".toUpperCase()
                    || x.toUpperCase() != "Все+отели".toUpperCase()) {
                    //console.log('вот опять');
                    return false;
                }
            }
            location.hash = hotSearchFormSer;
        }

    Увидел на популярном поисковике отелей

    sladkijBubaleh, 20 Сентября 2013

    Комментарии (5)
  4. SQL / Говнокод #13824

    −160

    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
    create procedure pwqgen @length int =3 
    as 
    /* pwqgen is a t-sql implementation of passwdqc's pwqgen password generator http://www.openwall.com/passwdqc/ */
    /* inspired by https://github.com/iphoting/pwqgen.rb */
    BEGIN 
    create table #separators (id int identity, s char(1))
    insert into #separators 
           select "-" union select "_" union select "+" union select "=" union select "2" union select "3" 
    union select "4" union select "5" union select "6" union select "7" union select "8" union select "9"
    
    declare @maxsep int, @s varchar(1)
    select @maxsep=max(id) from #separators   
    declare @maxid int, @w varchar(30) , @pw varchar(31) 
    select @maxid=max(id) from words  -- =4096
    
    select @w=w from words where id=convert(int,round(rand()*@maxid,0) )
    -- capitalize 1st letter
    if rand() > 0.5 
    	select @w= UPPER(LEFT(@w,1))+SUBSTRING(@w,2,LEN(@w)) 
    set @pw=@w
    set @length = @length-1 
    
    while @length > 0  
    begin 
    	select @s=s from #separators   where id=convert(int,round(rand()*@maxsep,0) )
    	delete from #separators where s=@s
    
    	select @w=w from words where id=convert(int,round(rand()*@maxid,0) )
    	-- capitalize 1st letter
    	if (rand() > 0.5 or @s is null)
    		select @w= UPPER(LEFT(@w,1))+SUBSTRING(@w,2,LEN(@w)) 
    	set @pw=@pw+@s+@w
    set @length = @length -1 
    end 
    
    -- if no one number in @pw - append or replace last letter to random number
    if PATINDEX('%[0-9]%', @pw ) > 0 
    begin 
    	set @s=convert(char(1), 2+convert(int,round(rand()*7,0)) )
    	if len(@pw)<30 set @pw=@pw+@s
    	else 	set @pw=UPPER(RIGHT(@pw,1))+SUBSTRING(@pw,1,LEN(@pw)-1)+@s
    end 
    drop table  #separators 
    print @pw
    END 
    
    -- требует существования таблички со словами
    -- create table words (id int identity , w varchar(7))
    -- 4 тыс слов взял отсюда: https://github.com/iphoting/pwqgen.rb/blob/develop/lib/pwqgen/wordlist.rb

    паролегенератор на tsql.
    при тестах понял что возможна ситуация, когда пароль не имеет ниодной цифры, что запрещено политикой.
    наговнокодил кучу charindex-ов. впринципе то работало, но вспомнил этот сайт, условие переписал под patindex, но треш в ветке с условием if PATINDEX('%[0-9]%', @pw ) > 0 остался.

    bliznezz, 19 Сентября 2013

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

    +152

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    <div style="display:none;"><script type="text/javascript">
    (function(w, c) {
        (w[c] = w[c] || []).push(function() {
            try {
                w.yaCounter... = new Ya.Metrika({id:..., enableAll: true});
            }
            catch(e) { }
        });
    })(window, "yandex_metrika_callbacks");
    </script></div>

    Whattt????

    invision70, 16 Сентября 2013

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

    +151

    1. 1
    2. 2
    if (!preg_match_all("!<tr class=\"dark\">\s+<td>.*?</td>\s+<td class=\"cell1\">.*?>stock.zip</td>\s+<td>(.*?)</td>\s+<td>.*?</td>\s+<td><a href=\"(.*?)\    ">.*?</a></td>\s+<td>.*?</td>\s+</tr>!is", $out['body'], $res))
      exit(say("Не найден файл со стоком"));

    грузим прайсы партнёра

    heyzea1, 13 Сентября 2013

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

    +147

    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
    // Kohana 3.2
    
           // получаем учебные группы для фильтра
            $journal_training_groups = NULL;
            if (Auth::instance()->logged_in('teacher'))
            {
                $journal_training_groups = $this->user->training_groups->find_all();
                $courses = ORM::factory('educ_course')->get_teacher_courses($this->user)->published()->find_all();
            }
            // тут самое интересное >>
            elseif (Auth::instance()->logged_in('curator'))
            {
                // получаем всех учеников без учебных групп, которые изучают курсы куратора
                $journal_training_group = new stdClass();
                $journal_training_group->title = 'Ученики вне групп';
                $journal_training_group->members = ORM::factory('user')
                        ->join(array('training_group_members', 'tgm'), 'LEFT')
                        ->on('user.id', '=', 'tgm.user_id')
                        ->where('tgm.user_id', '=', NULL);
    
                $journal_training_groups = array($journal_training_group);
                $courses = ORM::factory('educ_course')->get_curator_courses($this->user)->published()->find_all();
            }
            else
            {
                $courses = $this->user->courses->published()->find_all();
            }

    Для любителей эмитировать..
    з.ы stdClass

    invision70, 13 Сентября 2013

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

    +119

    1. 1
    2. 2
    /proc/add_action(source, action, param1, param2)
    	toExecute += list(source = source, procname = ( action = "attack" ? "attack" : ( action = "move" ? "move" : ( action = "..." ? "someshit1" : ( action = "...(2)" ? "someshit2" : null ) ) ) ), params = list( ( (action = "attack") or (action = "move") ? param1 : null), (action = "..." or action = "...(2)" ? param2 : null ) )

    А я люблю обмазываться несвежим кодом в одну строку и дрочить.

    Сам код - лишь пример, но его можно расширять бесконечно.

    EditorRUS, 02 Сентября 2013

    Комментарии (5)
  9. Pascal / Говнокод #13651

    +141

    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
    function GetProcessUser(aPID: Cardinal; var aResult: string): Boolean;
    type
      PTOKEN_USER = ^TOKEN_USER; 
    
      _TOKEN_USER = record
        User: TSidAndAttributes;
      end;
    
      TOKEN_USER = _TOKEN_USER;
    var
      cbBuf: Cardinal;
      ptiUser: PTOKEN_USER;
      snu: SID_NAME_USE;
      hToken, hProcess: THandle;
      UserSize, DomainSize: Cardinal;
      bSuccess: Boolean;
      sUser, sDomain: string;
    begin
      Result := False;
      hProcess := OpenProcess(PROCESS_QUERY_INFORMATION, False, aPID);
      if hProcess <> 0 then
      begin
        if OpenProcessToken(hProcess, TOKEN_QUERY, hToken) then
        begin
          bSuccess := GetTokenInformation(hToken, TokenUser, nil, 0, cbBuf);
          ptiUser := nil;
          while (not bSuccess) and (GetLastError = ERROR_INSUFFICIENT_BUFFER) do
          begin
            ReallocMem(ptiUser, cbBuf);
            bSuccess := GetTokenInformation(hToken, TokenUser, ptiUser, cbBuf, cbBuf);
          end;
          CloseHandle(hToken);
    
          if not bSuccess then

    Убило название. Дальше можете не читать.

    http://www.programmersforum.ru/showthread.php?t=242541

    Stertor, 23 Августа 2013

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

    +135

    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
    using System;
    using System.Threading;
    using System.Threading.Tasks;
    
    namespace ConsoleApplication32
    {
        class Program
        {
            static readonly Random Random = new Random(DateTime.Now.Millisecond);
            private static int _counterTrue = 0;
            private static int _counterFalse = 0;
            private const int _MaxRand = int.MaxValue;
            private const int testLimit = 10000000;
    
            static void Main(string[] args)
            {
                Parallel.For(0, testLimit, (i) => Test());
                Console.WriteLine(_counterTrue);
                Console.WriteLine(_counterFalse);
                Console.WriteLine(_counterFalse/(float)(testLimit));
                Console.ReadKey();
    
            }
            static private void Test()
            {
                var first = Random.Next(_MaxRand);
                var second = Random.Next(_MaxRand);
                if (first == second)
                {
                    second = Random.Next(_MaxRand);
                }
                if (first == second)
                {
                    Interlocked.Increment(ref  _counterTrue);
                }
                else
                {
                    Interlocked.Increment(ref  _counterFalse);
                }
            }
        }
    }

    http://govnokod.ru/13631

    Собственно программа проверки

    vistefan 11 минут назад # 0
    С таким кодом вам тред новый надо было создавать.

    Создал, поливаем меня самодельным шоколадом

    kegdan, 21 Августа 2013

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

    +137

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    7. 7
    8. 8
    if(isset($_POST['what']) && $_POST['what']=='form6' && isset($_POST['bot'])&& empty($_POST['bot']) && isset($_POST['fio']) && !empty($_POST['fio']) && isset($_POST['phone']) && !empty($_POST['phone'])){
    
    	$_POST['phone']=htmlspecialchars(stripslashes(trim($_POST['phone'])));
    	$_POST['fio']=htmlspecialchars(stripslashes(trim($_POST['fio'])));
    	
    	$message="Отправлено:\n".date("d.m.Y H:i")."\nОткуда: http://ipgeobase.ru/?address=".$_SERVER['REMOTE_ADDR']."\n\nФорма \"Заказ звонка\" \n\nИмя:\n".$_POST['fio']."\n\nТелефон:\n".$_POST['phone']."\n\nВперед!";
    	
    	mail ('[email protected]','заявка',$message, "Content-type: text/plain; charset=utf-8");

    Пиздец... За что?

    deep, 15 Августа 2013

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