1. C# / Говнокод #5093

    +122

    1. 1
    2. 2
    3. 3
    int valu=...;
    ...
    string vals=""+valu;

    Говногость, 28 Декабря 2010

    Комментарии (37)
  2. PHP / Говнокод #5092

    +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
    $mazovia[18];
    	$iso[18];
    
    	$mazovia[0]  = chr(134);$iso[0]=chr(177);		//a~
    	$mazovia[1]  = chr(143);$iso[1]=chr(161);		//A~
    	$mazovia[2]  = chr(141);$iso[2]=chr(230);		//c~
    	$mazovia[3]  = chr(149);$iso[3]=chr(198);		//C~
    	$mazovia[4]  = chr(145);$iso[4]=chr(234);		//e~
    	$mazovia[5]  = chr(144);$iso[5]=chr(202);		//E~
    	$mazovia[6]  = chr(146);$iso[6]=chr(179);		//l~
    	$mazovia[7]  = chr(156);$iso[7]=chr(163);		//L~
    	$mazovia[8]  = chr(164);$iso[8]=chr(241);		//n~
    	$mazovia[9]  = chr(165);$iso[9]=chr(209);		//N~
    	$mazovia[10] = chr(162);$iso[10]=chr(243);		//o~
    	$mazovia[11] = chr(163);$iso[11]=chr(211);		//O~
    	$mazovia[12] = chr(158);$iso[12]=chr(182);		//s~
    	$mazovia[13] = chr(152);$iso[13]=chr(166);		//S~
    	$mazovia[14] = chr(166);$iso[14]=chr(188);		//z~
    	$mazovia[15] = chr(160);$iso[15]=chr(172);		//Z~
    	$mazovia[16] = chr(167);$iso[16]=chr(191);		//z|
    	$mazovia[17] = chr(161);$iso[17]=chr(175);		//Z|
           
            $strmazovia="";
    	$strIso="";
    	for ($i=0;$i<=17;$i++){
    		$strmazovia=$strmazovia."\\".$mazovia[$i];
    		$strIso= $strIso."\\".$iso[$i];
    	}
    
    
    	function convert($str){
    		global $strmazovia;
    		global $strIso;
    	        return StrTr($str,$strmazovia,$strIso);
    	}

    xaoc, 28 Декабря 2010

    Комментарии (20)
  3. Assembler / Говнокод #5091

    +225

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    ; Program entry point
    00401000:  push 0070F001
    00401005:  call 0040100B
    0040100A:  ret
    0040100B:  ret

    Суровый старт зашифрованного самораспаковывающегося архива. Так хитро передаётся управление на 0070F001 (за сегмент кода).

    TarasB, 28 Декабря 2010

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

    +173

    1. 1
    2. 2
    3. 3
    function int2float($i) {
        return (string) $i . '.00';
    }

    Vyacheslav, 28 Декабря 2010

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

    +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
    <?php
                                                                                          //из статьи 	"Запись и чтение из mysql Часть 1"
    <?php
                                                                                  //это якобы первый файл cfg
    $host = "localhost"; // Сервер подключения
    $login = "examples"; // Пользовать БД
    $password = "examples"; // Пароль для пользователя
    $database = "examples"; // Название БД
    // Кодировка:
    $charset = "cp1251";
    $collation = "cp1251_general_ci";
    $link = @mysql_connect("".$host."", "".$login."", "".$password."")
            or die ("Система не смогла подключиться к MySQL-серверу.");
        mysql_query ("set character_set_client='".$charset."'");
        mysql_query ("set character_set_results='".$charset."'");
        mysql_query ("set collation_connection='".$collation."'");
        @mysql_select_db ("".$database."")
            or die ("Система не может взять данные из базы. Возможно, такой БД не существует.");
    
           //Тут какой то текст статьи описывающий действия первого файла и заставляющий совершать действия по подключению 2 файла
    
    require "cfg.php";//подключаем конфиг
    $result=mysql_query('SELECT * FROM `url`');
    while($row=mysql_fetch_array($result))// берем результаты из каждой строки
    { 
    echo <<<base
    $row[url] --- $row[сategory]
    base;
    }
    
    
    ////////////////////////////Первый комментарий к статье
    25 декабря 2010 23:23   *** написал →
    Сообщение #1
    
     что за нахуй?
    //echo <<<base
    //$row[url] --- $row[сategory]
    //base;
    
    ///////////////////////////Убила реакция на комментатора
    // Сегодня, 14:28   *** написал →
    //Сообщение #--
    
    //ты че дибил? это ECHO!
    
    ?>

    )жестко - мир не без интересных людей

    Aios, 28 Декабря 2010

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

    +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
    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
    74. 74
    75. 75
    76. 76
    77. 77
    78. 78
    79. 79
    80. 80
    81. 81
    82. 82
    83. 83
    84. 84
    85. 85
    86. 86
    87. 87
    88. 88
    89. 89
    90. 90
    91. 91
    92. 92
    93. 93
    94. 94
    95. 95
    96. 96
    #!/usr/bin/php5
     
    <?php
    set_time_limit(0);
    //include("crypt.php");
     
    exec("rm jtv.zip");
    exec("wget http://www.teleguide.info/download/new3/jtv.zip"); //скачать архив телепрограммы в формате itv.zip//
    exec("rm list/*.* "); //очистить каталог "list"//
    exec("unzip -x jtv.zip -d list "); //извлеч файлы из архива в папку "list"//
    sleep(3);
     
    $dir = "/home/tt/wwwplaylist/list/";
     
    exec("ls list | grep '.ndx'", $tmplist);
    $ch = array(
    1=>1,2=>2,3=>3,250=>195,241=>196,209=>197,177=>168,
    //170=>198,186=>199,191=>200,174=>201,172=>202,189=>203,188=>204,
    //161=>205,171=>206,187=>207,211=>208,223=>209,212=>210,210=>211,
    //245=>212,213=>213,181=>214,254=>215,222=>216,218=>217,219=>218,
    //217=>219,253=>220,221=>221,175=>222,180=>223,199=>192,252=>193,
    //233=>194,226=>195,228=>196,224=>197,173=>168,229=>198,231=>199,
    //234=>200,235=>201,232=>202,239=>203,238=>204,236=>205,196=>206,
    //197=>207,201=>208,230=>209,198=>210,244=>211,246=>212,242=>213,
    //251=>214,249=>215,214=>216,220=>217,248=>218,163=>219,216=>220,
    //251=>214,249=>215,214=>216,220=>217,248=>218,163=>219,216=>221,
    215=>222,131=>223,0=>220);
      
    $serveraddress="localhost";
    $mysqluser="root";
    $mysqlpassword="12345";
    $mysqldatabase="pl";
     
    $descriptor = mysql_connect($serveraddress,$mysqluser,$mysqlpassword);
    mysql_select_db($mysqldatabase,$descriptor);
    mysql_query("SET NAMES CP1251");
     
    mysql_query("truncate table TV_epg");
     
    function int2float($i) {
          $x32 = 4294967296;
          $i = (float)$i;
          if ($i < 0) return $i + $x32 + 1; else return $i; /* signed int32 overflow */
    }
     
    function FILETIMEtoUNIXtime($FILETIME) {
      $x32 = 4294967296;
      $sec_btw_epoch = (float)(116444736 * 100);
      $low  =        (ord($FILETIME[0])) | (ord($FILETIME[1]) << 8) | (ord($FILETIME[2]) << 16) | (ord($FILETIME[3]) << 24);
      $high =        (ord($FILETIME[4])) | (ord($FILETIME[5]) << 8) | (ord($FILETIME[6]) << 16) | (ord($FILETIME[7]) << 24);
      $f64 = (int2float($high) * $x32 + int2float($low)) / 10000000;
      return (int)($f64 - $sec_btw_epoch);
    }
     
    foreach ($tmplist as $key=>$value) {
        $f=substr($value, 0, -4);
        $res=$f;
     
        for($i=0; $i<strlen($res); $i++) $res[$i]=(array_key_exists(ord($res[$i]),$ch)) ? chr($ch[ord($res[$i])]) : $res[$i];
     
        $f1=fopen("list/".$f.".ndx", "rb");
        $f2=fopen("list/".$f.".pdt", "rb");
     
        $test1 = bin2hex(fread($f1, 1));
        $test2 = bin2hex(fread($f1, 1));
        $countpr = hexdec($test2.$test1);
     
    for ($i=0; $i<$countpr; $i++ )
    {
        $tmp=0;
        $ft='';
        $tmp = fread($f1, 2);
        for ($j=0; $j<8; $j++)
        $ft.= (fread($f1, 1));//.$ft;
     
        $dates= date("Y-m-d H:i:s", FILETIMEtoUNIXtime($ft));
     
    //////////////index f2////////////
        $offset=0;
        $str = bin2hex(fread($f1, 1));
        $str2 = bin2hex(fread($f1, 1));
        $offset = hexdec($str2.$str);
    ///////////////name////////////////
        $len=0;
        fseek($f2, $offset);
        $str = bin2hex(fread($f2, 1));
        $str2 = bin2hex(fread($f2, 1));
        $len = hexdec($str2.$str);
        $name = fread($f2, $len);
     
        mysql_query("insert into `TV_epg` set `epg_ch`='$res',`epg_date`='$dates',`epg_name`='$name' ");
        }
    }
            #mysql_quuery("update TV_epg set epg_date=epg_date-interval 4 hour;");
            mysql_query("update TV_epg set epg_date=epg_date-interval 1 hour;");
    ?>

    qbasic, 28 Декабря 2010

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

    +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
    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
    function get_file_info($glob, $freq = 0)
    {
      static $cache = array();
    
      if (isset($cache[$glob])) {
    
        return $cache[$glob];
    
      } else {
    
        $ret = new stdClass;
    
        $g = glob($glob);
    
        $test = trim(`ls $glob`);
        $g = split( "\n", $test );
        if (!is_array($g)) {
          return $ret;
        }
    
        $g = array_reverse($g);
    
        $ret->files = array();
        $now = time();
        $first = true;
    
        foreach($g as $filename) {
    
          $f = new stdClass;
    
          $f->name = $filename;
          $f->size = @filesize($f->name);
          $f->size_str = sprintf("%.1f",$f->size/1024/1024);
    
          if (preg_match("((\\d{12}))", $f->name, $m)) {
        $t = strtotime($m[1]);
        $f->time = $t;
        $f->time_str = str_replace(" ", " ", date("M d, Y H:i T", $f->time));
    
        if ($freq) {
          
          $to = $t + $freq - $now;
    
          if ($to < 0) {
            if ($to > -600) {
              $res = '<em>any moment now.</em>';
            } else {
              $res = '<em>please consult /dev/urandom</em>';
            }
          } else {
            $h = floor($to/3600);
            $m = floor(($to - $h * 3600) / 60);
            
            if ($h) {
              $res = $h . ' hour'.($h==1?'':'s').' and ' . $m . ' minute'.($m==1?'':'s');
            } else {
              $res = $m . ' minute'.($m==1?'':'s');        
            }
          }
    
          $f->next = $res;
        }
    
          }
    
          $ret->files[] = $f;
        }
    
        return $ret;
      }
    }

    Говнокод на сайте php.net :)
    Исходник: http://snaps.php.net/?source

    P.S. это еще цветочки, после обеда будет зачетный с http://www.php.net/source.php?url=/index.php

    wmmorgun, 28 Декабря 2010

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

    +166

    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
    for (i=0; i<n; i++){
    		for (int j=0; j<n; j++){
    			if (x[i]>x[j] && x[i]-x[j] > zx && (y[i]>y[j] && y[i]-y[j] > zy) || (y[i]<y[j] && y[j]-y[i] > zy)){
    				zx = x[i] - x[j]; a1=i; a2=j;
    				if (y[i]>y[j] && y[i]-y[j] > zy && sum < zx + (y[i]-y[j])) zy = y[i] - y[j]; b1=i; b2=j; sum = zx + zy;
    				if (y[i]<y[j] && y[j]-y[i] > zy && sum < zx + (y[j]-y[i])) zy = y[j] - y[i]; b1=i; b2=j; sum = zx + zy;
    			}
    			if (x[i]<x[j] && x[j]-x[i] > zx && (y[i]>y[j] && y[i]-y[j] > zy) || (y[i]<y[j] && y[j]-y[i] > zy)){
    				zx = x[j] - x[i]; a1=i; a2=j;
    				if (y[i]>y[j] && y[i]-y[j] > zy && sum < zx + (y[i]-y[j])) zy = y[i] - y[j]; b1=i; b2=j; sum = zx + zy;
    				if (y[i]<y[j] && y[j]-y[i] > zy && sum < zx + (y[j]-y[i])) zy = y[j] - y[i]; b1=i; b2=j; sum = zx + zy;
    			}
    		}
    	}

    нахождение координат двух наиболее отдаленных точек среди заданных=)

    ALIVE-SpiriT, 28 Декабря 2010

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

    +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
    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
    /** Связанный JavaScript **/
    /*	
    	var script = new Array();
    	var s = 0;
    	
    
    
    	linked = e.match(/<script type=("|')text\/javascript("|') src=("|').*?("|')><\/script>/gi);
    	
    	if (linked != null)
    	{
    		src_link = new Array();
    		j = 0;
    		
    		for (i = 0; i < linked.length; i++)
    		{
    			e = e.replace(linked[i], '');
    			
    			new_link = linked[i].match(/src=("|').*?("|')>/gi);
    			
    			if (new_link != null)
    			{
    				script[s] = document.createElement('script');
    				script[s].setAttribute('type', 'text/javascript');		
    				script[s].id = 'JavaScript_' + hist.length + '_' + j;
    		
    				script[s].setAttribute('src', new_link[0].substr(5, (new_link[0].length - (5 + 2))));
    				
    				s++; j++;
    			}	
    		}
    	}
    	*/
    	/** Внедрённый JavaScript **/
    /*
    	e = e.replace(/[\r\n]/g, ' ');
    	intruded = e.match(/<script type=("|')text\/javascript("|')>.*?<\/script>/gi);
    		
    	if (intruded != null)
    	{			
    		for (i = 0; i < intruded.length; i++)
    		{
    			inner = '';
    		
    			e = e.replace(intruded[i], '');
    			inner = intruded[i].replace(/<script type=("|')text\/javascript("|')>/, '').replace(/<\/script>/, '');
    			
    			if (navigator.appName == 'Microsoft Internet Explorer')
    			{
    				script[s] = inner;
    			}
    			else
    			{
    				script[s] = document.createElement('script');
    				script[s].setAttribute('type', 'text/javascript');
    				script[s].id = 'JavaScript_' + hist.length + '_' + i;
    			
    				script[s].innerHTML = inner;
    			}
    			
    			s++;
    		}
    	}
    	*/

    А вставить в элемент и найти через getElementsByTagName("script") слишком просто :D

    Genka, 28 Декабря 2010

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

    +159

    1. 1
    2. 2
    3. 3
    function is_int_string ($str) {
    	return ((string)(int)($str) == $str);
    }

    Уже даже не помню зачем оно было нужно.

    byss, 27 Декабря 2010

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