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

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

    +171

    1. 1
    2. 2
    3. 3
    if(in_array(strlen($_POST['password']), range(6,30))) {
    ////.....
    }

    но кода на несколько символов все равно меньше, согласитесь

    _jokz, 29 Января 2012

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

    +80

    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
    public class SQLExecutor {
     
        ..............
    
        private static class Done extends RuntimeException {}
    
        private static class Break extends RuntimeException {}
    
        ...............
    
        public boolean init(....) {
            Connection conn = null;
            try {
                ..........
            } catch (Done d) {
                return true;
            } catch (Break b) {
                return false;
            } finally {
                cleanup();
            }
            return true;
        }
    
    
    }

    Anonimous, 27 Января 2012

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

    +175

    1. 1
    2. 2
    while ($new_width>$maxwidth) { $new_width *= 0.99; $new_height *= 0.99; }	
    	  while ($new_height>$maxheight) { $new_width *= 0.99; $new_height *= 0.99; }

    Мега код из сайта написанного на InstantCMS
    Вот так там уменьшаются картинки под максимальный размер...

    3xdimon, 26 Января 2012

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

    +141

    1. 1
    <img src="http://govnokod.ru/ratings/code/MyCodeId/on" style="display:none;"/>

    Unknown, 25 Января 2012

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

    +130

    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
    BOOL CMarkup::Search(CString OprName, CString strSQL, short nType)
    {
    
    ...
    	
    	sCommandLine = sPath.Left(nPos)+ _T("\\Getorder.exe search ")+OprName+_T(" ")+strSQL+_T(" ")+strType;
    	::wcscpy(cCommandLine, sCommandLine);
    
    	BOOL ret = CreateProcess(NULL, cCommandLine, NULL, NULL, FALSE, CREATE_NO_WINDOW, NULL, NULL, &si, &pi);
    	if (ret) {
    		CloseHandle(pi.hThread );						//Close the thread handle as soon as it is no longer needed.
    		WaitForSingleObject(pi.hProcess, INFINITE);		//Suspend our execution until the child has terminated.
    		GetExitCodeProcess(pi.hProcess ,&dwExitCode);	//The child process terminated;get its exit code.
    		//if(dwExitCode == STILL_ACTIVE) TerminateProcess(pi.hProcess, 0);
    		CloseHandle(pi.hProcess);						//Close the process handle as soon as it is no longer needed.
    	}
    
    	CString ss,s;
    	ss = _T("s.txt");
    
    	CStdioFile in;
    	if(!in.Open (sPath+_T("\\")+ss,CFile::modeRead | CFile::typeBinary))
    		return TRUE;
    
    	while(in.ReadString(s))
    	{
    		s.TrimLeft();
    		s.TrimRight();
    		if(s != _T("**********")) continue;
    
    		ORDERTYPE m_OrderData;
    
    		in.ReadString(s);
    		s.TrimLeft();
    		s.TrimRight();
    		m_OrderData.OprName = s;
    
    		in.ReadString(s);
    		s.TrimLeft();
    		s.TrimRight();
    		m_OrderData.Language =s;
    
    		in.ReadString(s);
    		s.TrimLeft();
    		s.TrimRight();
    		m_OrderData.OrderNo =s;
    
    ...
    
    	}
    
    	in.Close();
    	DeleteFile(sPath+_T("\\")+ss);

    Прислали исходники приложения на C++ с MFC. Там просто один сплошной ГК от начала и до конца, но это место просто убило.

    Задача - найти заказ в базе данных MSSQL по SQL-запросу. Для этого они запускают отдельное приложение .NET, которое подключается к базе и дампит запись в текстовый файл, а приложение C++ из него читает.

    someone, 25 Января 2012

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

    +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
    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
    class BbCod{
    		
    		function BbCod(){
    				
    		} 
    		
    	 	static function BbB($text){
    			
    			if (is_array($text)) {
    				$text = '<b>'.$text[1].'</b>';
    			}
    			
    			return preg_replace_callback("~\[b]((?:[^[]|\[(?!/?b])|(?R))+)\[/b]~is", "BbCod::BbB" , $text); 
    		}
    		
    		
    		static function BbI($text){
    			
    			if (is_array($text)) {
    				$text = '<i>'.$text[1].'</i>';
    			}
    			
    			return preg_replace_callback("~\[i]((?:[^[]|\[(?!/?i])|(?R))+)\[/i]~is", "BbCod::BbI" , $text); 
    		}
    		
    		
    
    
    // ...
    
    		function Bb($text, $param = array()){
    			if(!isset($param['b']) || $param['b'] !== false) $text = $this->BbB($text);				
    			if(!isset($param['i']) || $param['i'] !== false) $text = $this->BbI($text);	
    			if(!isset($param['u']) || $param['u'] !== false) $text = $this->BbU($text);
    			if(!isset($param['ol']) || $param['ol'] !== false) $text = $this->BbOl($text);
    			if(!isset($param['ul']) || $param['ul'] !== false) $text = $this->BbUl($text);
    			if(!isset($param['li']) || $param['li'] !== false) $text = $this->BbLi($text);
    			if(!isset($param['quote']) || $param['quote'] !== false) $text = $this->BbQuote($text);
    			if(!isset($param['left']) || $param['left'] !== false) $text = $this->BbLeft($text);
    			if(!isset($param['right']) || $param['right'] !== false) $text = $this->BbRight($text);
    			if(!isset($param['center']) || $param['center'] !== false) $text = $this->BbCenter($text);
    			if(!isset($param['justify']) || $param['justify'] !== false) $text = $this->BbJustify($text);
    			if(!isset($param['size']) || $param['size'] !== false) $text = $this->BbSize($text);
    			if(!isset($param['color']) || $param['color'] !== false) $text = $this->BbColor($text);
    			if(!isset($param['fright']) || $param['fright'] !== false) $text = $this->BbFRight($text);
    			if(!isset($param['fleft']) || $param['fleft'] !== false) $text = $this->BbFLeft($text);
    			if(!isset($param['table']) || $param['table'] !== false) $text = $this->BbTable($text);
    			if(!isset($param['td']) || $param['td'] !== false) $text = $this->BbTd($text);
    			if(!isset($param['th']) || $param['th'] !== false) $text = $this->BbTh($text);
    			if(!isset($param['tr']) || $param['tr'] !== false) $text = $this->BbTr($text);
    			if(!isset($param['br']) || $param['br'] !== false) $text = $this->BbBr($text);
    			if(!isset($param['hr']) || $param['hr'] !== false) $text = $this->BbHr($text);
    			if(!isset($param['youtube']) || $param['youtube'] !== false) $text = $this->BbYoutube($text);
    			if(!isset($param['img']) || $param['img'] !== false) $text = $this->BbIms($text);
    			if(!isset($param['src']) || $param['src'] !== false) $text = $this->BbSrc($text);
    			if(!isset($param['mail']) || $param['mail'] !== false) $text = $this->BbMail($text);
    			
    			return $text;	
    		}
    		
    }
    		// end class

    Писал в само начале осваивания ООП в php. И причем такое ощущения что бухой писал)

    vir-mir, 19 Января 2012

    Комментарии (13)
  8. Си / Говнокод #9105

    +132

    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
    #include <iostream>
    #include <cstdio>
    #include <cstring>
    #include <cstdlib>
    #include <time.h>
    char a[150],c[150];
    int main(int argc, char **argv) {	
    	FILE * tmp;
    	while(1) {
    		int b=0,b1=0;
    		bool A=0;
    		tmp=fopen(".tmp.txt","r");
    		fgets(c,150,tmp);
    		fclose(tmp);
    		system("rm .tmp.txt");
    		system("xwininfo -tree -root | grep -i '\\- deadbeef-0.5.1' > .tmp.txt");
    		tmp=fopen(".tmp.txt","r");
    		fgets(a,150,tmp);
    		fclose(tmp);
    		for(int i=16;i<149;i++) {
    
    			c[i-16]=c[i];
    			a[i-16]=a[i];
    			if(a[i-16]=='-')
    				b++;
    			if(c[i-16]=='-')
    				b1++;
    			if(b==2)
    				a[i-16]=0;
    			if(b1==2)
    				c[i-16]=0;
    		}
    		for(int j=0;j<(int)strlen(c);j++) {
    			if (a[j]!=c[j])	A=true;
    		}
    		if (A) {
    			char lamp[]="/usr/bin/purple-remote \"setstatus?status=available&message=";
    			strcat(lamp,a);
    			strcat(lamp,"\"");
    			system(lamp);
    		}
    		sleep(5);
    	}
    	return 0;
    }

    Реализация аналога pidgin-musictracker для deadbeef

    Abbath, 13 Января 2012

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

    +155

    1. 1
    2. 2
    foreach ($period_range as $k=>$v) 
    	{?><option value="<?=$k?>"<?=($k==$period)?' selected':''?>><?=$v?></option><?}

    Накодил как-то...

    zima, 11 Января 2012

    Комментарии (13)
  10. PHP / Говнокод #8881

    +156

    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
    exec(" cd $dir; ls -al|grep '^d';",$file_all);
      	//die(" cd $dir; ls -al|grep '^d';");
      	$filelist_date = array();
      	
      	for($i=0;$i<count($file_all);$i++) {
      		$file_all[$i] = preg_replace('/\s+/','|',$file_all[$i]);
      		
      		$file_all[$i] = explode('|',$file_all[$i],9);
      		if(!empty($file_all[$i][8])) $file_all[$i][8] = str_replace('|',' ',$file_all[$i][8]);
      		
      		//print_r($file_all[$i]); echo "\n\n";
      		if($file_all[$i][8] == '.' || $file_all[$i][8] == '..') continue;
      		
      		$k = strtotime($file_all[$i][5]." ".$file_all[$i][6]." ".$file_all[$i][7]);
      		$filelist_date[$k] = $file_all[$i][8];
      	}
      	krsort($filelist_date);
      	
      	$filelist = array_values($filelist_date);

    этот кусок кода выполняет начитку директорий фото галерей

    kolexander, 04 Января 2012

    Комментарии (13)
  11. ActionScript / Говнокод #8826

    −120

    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
    stage.addEventListener(KeyboardEvent.KEY_DOWN, key_down);
    stage.addEventListener(KeyboardEvent.KEY_UP, key_up);
    //left - 37; up - 38; right - 39; down - 40
    
    var up:Boolean = false ;
    var down:Boolean = false;
    var left:Boolean = false;
    var right:Boolean = false;
    
    function key_down (e:KeyboardEvent):void
    {
    trace (e.keyCode);
    if (e.keyCode == 37 || e.keyCode == 65)
    {
      left = true;
    }
    if (e.keyCode == 38 || e.keyCode == 87)
    {
      up = true;
    }
    if (e.keyCode == 39 || e.keyCode == 68)
    {
      right = true;
    }
    if (e.keyCode == 40 || e.keyCode == 83)
    {
      down = true;
    }
    }
    function key_up (e:KeyboardEvent):void
    {
    trace (e.keyCode)
    if (e.keyCode == 37 || e.keyCode == 65)
    {
      left = false;
    }
    if (e.keyCode == 38 || e.keyCode == 87)
    {
      up = false;
    }
    if (e.keyCode == 39 || e.keyCode == 68)
    {
      right = false;
    }
    if (e.keyCode == 40 || e.keyCode == 83)
    {
      down = false;
    }
    }
    
    addEventListener(Event.ENTER_FRAME, moveHero);
    function moveHero (e:Event):void
    {
    if (left)
    {
      hero.x --;
    }
    if (up)
    {
      hero.y --;
    }
    if (right)
    {
      hero.x ++;
    }
    if (down)
    {
      hero.y ++;
    }
    }
    
    }

    kyzi007, 14 Декабря 2011

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