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

    В номинации:
    За время:
  2. 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)
  3. 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)
  4. 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)
  5. 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)
  6. Куча / Говнокод #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)
  7. 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)
  8. 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)
  9. 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)
  10. PHP / Говнокод #13607

    +138

    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
    <?php
    header("Content-Type: text/javascript;charset=utf-8");
     
    $html='';
    #$fp = fopen('counter.txt', 'w+');
     
    if (isset($_GET)) {
        $type=$_REQUEST['type'];
     
     
        if (isset ($_REQUEST['callback'])){
            $html.=$_REQUEST['callback']."(";
        }
     
        $fils=array('ukqs','uk','regions', 'org', 'citiesarhobl', 'cities', 'omsu', 'iogv','fund_uk','standart');
     
        if (isset($_GET['cfund_uk'])) {
            $fund_file='jbase/cities_'.$_GET['cfund_uk'].'.js';
            if (file_exists($fund_file))
                $html.=file_get_contents($fund_file);
            else
                $html.='error:'.$fund_file;
        }
        else
            if (isset($_GET['rfund_uk'])) {
                $fund_file='jbase/'.$_GET['rfund_uk'].'_regions.js';
                if (file_exists($fund_file))
                    $html.=file_get_contents($fund_file);
                else
                    $html.='error';
            }
        if (isset($_REQUEST['uks'])&&($type=='cities')) {
            $fund_file='jbase2/'.$_GET['uks'].'_cities.js';
            if (file_exists($fund_file))
                $html.=file_get_contents($fund_file);
            else
                $html.='error:'.$fund_file;
        }
        else
            if (isset($_REQUEST['uks'])&&($type=='regions')) {
                $fund_file='jbase2/'.$_GET['uks'].'_regions.js';
                if (file_exists($fund_file))
                    $html.=file_get_contents($fund_file);
                else
                    $html.='error';
            }
        else
            if ($type=='standart') {
                $fund_file='standart.js';
                if (file_exists($fund_file))
                    $html.=file_get_contents($fund_file);
                else
                    $html.='error';
            }
        else
        foreach ($fils as $ty)
            if ($ty==$type)
                $html.=file_get_contents($type.".js");    
        if (isset ($_REQUEST['callback']))
        {
            $html.=")";
        }
        #$date=date("F j, Y, g:i a");
       #$test = fwrite($fp, $date."#####\n\r ".$html);
     
        print $html;
        #fclose($fp);
    }
    ?>

    этот файл отдаёт json ajax ответ, подгружая его из *.js файла

    tariel, 14 Августа 2013

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

    +145

    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
    $(function() {
    
    	// hardcore mode
    	"use strict";
    	"use paranoid";
    
    	// todo: string-to-functioName converter and more flexible injector
    	;(function() {
    
    		var ooStack = {
    			writeback: function() {
    
    				// main wrappers
    				var wrappers = $( 'html, body' );
    				var meta     = $( 'head' );
    				var root     = $( '#core' , wrappers );
    				var head     = $( '#head', root );
    				var content  = $( '#content' , root );
    				var sidebar  = $( 'aside' , root );
    				var articles = $( 'article' , content );
    
    				// it can fuck your brain
    				var footway	 = {
    					root: root,
    					head: head,
    					content: content,
    					sidebar: sidebar,
    					articles: articles,
    					wrappers: wrappers,
    
    					// paginator
    					paginator: $( '.pager' , root ),
    				};
    
    				// return stack definition
    				return footway;
    			}
    		};
    
    		// New world
    		var appInstance = new world();
    
    		// Inject selectrors and methods
    		var app = appInstance.application;
    		app.dom = ooStack.writeback();
    
    		// Execute
    		app.init();
    
    	})();
    });

    Распедаль мои копыта -- наебнись мозги козла :D В Оригинале : робоцып, робокоп head и лопата

    Stealth, 09 Августа 2013

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