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

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

    +1

    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
    public Object [][] getResults (String query){
    		Object oArray [][] = {};
    		try (Connection con = Connector.getNewConnection()) {
    			Statement st = con.createStatement(ResultSet.TYPE_FORWARD_ONLY, ResultSet.CONCUR_READ_ONLY);
    			try (ResultSet rs = st.executeQuery(query)){
    				int rows = 0;
    				int cells = 0;
    				List<Object> lstObjX = new ArrayList<Object> (64);
    				while (rs.next()){
    					rows ++;
    					int x = 1;
    					while (true){
    						try {
    							lstObjX.add(rs.getObject(x));
    							x++;
    						}catch (Exception e) {
    							cells = (x != 1) ? x-1 : 0;
    							break;
    						}
    					}
    
    					for (; x-1 < cells; x++){
    						lstObjX.add(rs.getObject(x));
    					}
    
    				}
    				oArray = new Object [rows][cells];
    				int z = 0;
    				for (int y = 0; y < rows; y++){
    					for (int x = 0; x < cells; x++){
    						oArray[y][x] = lstObjX.get(z);
    						z++;
    					}
    				}
    			}
    		}
    		catch (SQLException e) {
    			System.err.println(e.getMessage());
    		}
    		return oArray;
    	}

    Превращаем Resultset в 2-мерную таблицу [y][x], где [y] - индекс строки, а [x] - индекс значений полей

    bydlan228, 03 Августа 2016

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

    +12

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    return isValidYear(args[4]) ? 
    		  (isValidMonth(args[3]) ? 
    			  (isValidDayOfMonth(args[2]) ? 
    				  (isValidDayOfWeek(args[1]) ? 
    					  (isValidTime(args[0]) ? true 
    					  : false)
    				  : false) 
    			  : false) 
    		  : false) 
    	   : false;

    Не знал, что последовательность && выполняется до первого false, хотел избежать вызова лишних методов при первом ложном результате.

    carapuz, 21 Июля 2016

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

    −90

    1. 1
    Если ВРЕГ(ДанныеСчета.УсловияЗаполнения)<>"ЛОЖЬ" Тогда

    УПП 1.3 (1.3.75.2)
    ОбщиеМодули.СчетаУчетаВДокументах

    Подскажите если изменятся языковые настройки конфигурации как себя поведет данный код?

    znsoft, 23 Июня 2016

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

    +5

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    7. 7
    $(document).on('click', 'a.switcher_link', function(e) {
        e.preventDefault();
        var btn = $(this);
        $.getJSON(btn.attr('href'), {type: 'json'}, function(data) {
          btn.parent().parent().parent().parent().parent().parent().parent().parent().replaceWith(data.data);
        });
      });

    Нашел и ахуел....

    gerasim13, 11 Мая 2016

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

    −1

    1. 001
    2. 002
    3. 003
    4. 004
    5. 005
    6. 006
    7. 007
    8. 008
    9. 009
    10. 010
    11. 011
    12. 012
    13. 013
    14. 014
    15. 015
    16. 016
    17. 017
    18. 018
    19. 019
    20. 020
    21. 021
    22. 022
    23. 023
    24. 024
    25. 025
    26. 026
    27. 027
    28. 028
    29. 029
    30. 030
    31. 031
    32. 032
    33. 033
    34. 034
    35. 035
    36. 036
    37. 037
    38. 038
    39. 039
    40. 040
    41. 041
    42. 042
    43. 043
    44. 044
    45. 045
    46. 046
    47. 047
    48. 048
    49. 049
    50. 050
    51. 051
    52. 052
    53. 053
    54. 054
    55. 055
    56. 056
    57. 057
    58. 058
    59. 059
    60. 060
    61. 061
    62. 062
    63. 063
    64. 064
    65. 065
    66. 066
    67. 067
    68. 068
    69. 069
    70. 070
    71. 071
    72. 072
    73. 073
    74. 074
    75. 075
    76. 076
    77. 077
    78. 078
    79. 079
    80. 080
    81. 081
    82. 082
    83. 083
    84. 084
    85. 085
    86. 086
    87. 087
    88. 088
    89. 089
    90. 090
    91. 091
    92. 092
    93. 093
    94. 094
    95. 095
    96. 096
    97. 097
    98. 098
    99. 099
    100. 100
    <?php
    /**
     * Provides URL shortening functionality, like tinyurl.com, bit.ly, ow.ly and other popular services.
     * (c) 2011, it-in, http://it-in.ru
     * @author Sergey Kovalev <[email protected]>
     * @version 1.0
     */
    /**
    * Basic URL path, to which short code will be added.
    */
    define("BASE_SHORT_PATH", "http://it-in.ru/~");
    /**
    * ID of the infoblock which holds information about shortned URLs.
    */
    define("TINYURL_IBLOCK_ID", 11);
    Class TinyURL
    {
    	/**
    	* Converts decimal number to any base
    	* @param integer $num Your decimal integer
    	* @param integer $base Base to which you wish to convert $num (leave it 0 if you are providing $index or omit if you're using default (62))
    	* @param string $index If you wish to use the default list of digits (0-1a-zA-Z), omit this option, otherwise provide a string (ex.: "zyxwvu")
    	* @return string
    	* @link http://www.php.net/manual/ru/function.base-convert.php#52450
    	*/
    	private static function dec2any( $num, $base=62, $index=false ) {
    		if (! $base ) {
    			$base = strlen( $index );
    		} else if (! $index ) {
    			$index = substr( "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ" ,0 ,$base );
    		}
    		$out = "";
    		for ( $t = floor( log10( $num ) / log10( $base ) ); $t >= 0; $t-- ) {
    			$a = floor( $num / pow( $base, $t ) );
    			$out = $out . substr( $index, $a, 1 );
    			$num = $num - ( $a * pow( $base, $t ) );
    		}
    		return $out;
    	}
    	/**
    	* Converts number in any base to decimal
    	* @param integer $num Your custom-based number (string) (ex.: "11011101")
    	* @param integer $base Base with which $num was encoded (leave it 0 if you are providing $index or omit if you're using default (62))
    	* @param string $index If you wish to use the default list of digits (0-1a-zA-Z), omit this option, otherwise provide a string (ex.: "abcdef")
    	* @return integer
    	* @link http://www.php.net/manual/ru/function.base-convert.php#52450
    	*/
    	private static function any2dec( $num, $base=62, $index=false ) {
    		if (! $base ) {
    			$base = strlen( $index );
    		} else if (! $index ) {
    			$index = substr( "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ", 0, $base );
    		}
    		$out = 0;
    		$len = strlen( $num ) - 1;
    		for ( $t = 0; $t <= $len; $t++ ) {
    			$out = $out + strpos( $index, substr( $num, $t, 1 ) ) * pow( $base, $len - $t );
    		}
    		return $out;
    	}
    	/**
    	* Shortens URL.
    	* @param string $url Absolute URL to be shortened, like http://www.yandex.ru.
    	* @return string
    	*/
    	public static function shorten($url)
    	{
    		CModule::IncludeModule("iblock") || die("Couldn't load one of the required modules. Error fe51e037.");
    		// Check if there is already shortened version of the required URL.
    		$res = CIBlockElement::GetList(
    			array(),
    			array('IBLOCK_ID' => TINYURL_IBLOCK_ID, 'PREVIEW_TEXT' => $url),
    			false,
    			false,
    			array('ID')
    		);
    		if($ob = $res->GetNextElement())
    		{
    			$arFields = $ob->GetFields();
    			return BASE_SHORT_PATH . self::dec2any($arFields['ID']);
    		}
    		
    		// Shorten new URL and create a record in database.
    		$el = new CIBlockElement;
    		$ELEMENT_ID = $el->Add(array(
    			'IBLOCK_ID' => TINYURL_IBLOCK_ID,
    			'NAME' => $url,
    			'PREVIEW_TEXT' => $url,
    			'PREVIEW_TEXT_TYPE' => 'html',
    		));
    		if($ELEMENT_ID)
    		  return BASE_SHORT_PATH . self::dec2any($ELEMENT_ID);
    		else
    		  die($el->LAST_ERROR);
    	}
    	
    	/**
    	* Converts short code to full URL, e.g. 8UdA -> http://yandex.ru.
    	* @param string $short_code
    	* @return string Full URL.

    Продолжаем копаться в недрах гитхаба в поисках изумрудов от bitrix.
    Данное творение некого адепта битрикса (из it-in, http://it-in.ru) для создания tinyurl

    Keeper, 04 Мая 2016

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

    0

    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
    if (empty($_GET['mms']) and empty($_GET['mass']) and empty($_GET['showuser']) and empty($_GET['user']) and empty($_GET['rate'])) {
    $db = mysql_connect ( "mysql.hostinger.ru", "u391920429_gala", "kirill1998" );
    mysql_select_db ( "u391920429_gala", $db );
    $pas = $_POST['pas'];
    $pass1 = $_POST['pass1'];
    $pass2 = $_POST['pass2'];
    $lop = addcslashes($pass1, '?%');
    $jjj = mysql_real_escape_string ($lop);
    $pol = addcslashes($pass2, '?%');
    $kkk = mysql_real_escape_string ($pol);
    $i = $_GET['edit'];
    $mail = $_POST['mail'];
    $stat = $_POST['stat'];
    $ava = $_POST['ava'];
    $ie = addcslashes($i, '?%');
    $ieq = mysql_real_escape_string ($ie);
    $id = preg_replace('~[^a-z0-9 \x80-\xFF]~i', "",$ieq);
    $lol = addcslashes($mail, '?%');
    $ooo = mysql_real_escape_string ($lol);
    $per = addcslashes($stat, '?%');
    $adr = mysql_real_escape_string ($per);
    $po = addcslashes($ava, '?%');
    $popa = mysql_real_escape_string ($po);
    $re=mysql_query("SELECT * FROM users WHERE id='$id'", $db);
    $user = $_SESSION["id"];
    if (mb_strlen($_POST['mail']) >= 4) {
    $up=mysql_query("UPDATE users SET email='$ooo' WHERE id='$user'", $db);
    }
    if (mb_strlen($_POST['stat']) >= 5) {
    $up=mysql_query("UPDATE users SET stat='$adr' WHERE id='$user'", $db);
    }
    if (mb_strlen($_POST['ava']) >= 4) {
    $up=mysql_query("UPDATE users SET ava='$popa' WHERE id='$user'", $db);
    }
    $name = $_SESSION["name"];
    $result=mysql_query("SELECT * FROM users WHERE name='$name'", $db);
    $myrow=mysql_fetch_array($result);
    $passs = md5($pas);
    if ($passs == $myrow["pass"]) {
    if ($jjj == $kkk) {
    if (mb_strlen($jjj) >=5) {
    $mdpass = md5($jjj);
    $up=mysql_query("UPDATE users SET pass='$mdpass' WHERE id='$user'", $db);
    }
    }
    }
    $res=mysql_fetch_array($re);
    if ($_SESSION["id"] == $id) {
    	if ($res['ban'] == 1) {
    		echo '<div class="user_prof">
    		<div class="name_prof_block">Профиль</div>
    				<form name="set" action="/prof.php?edit='.($res['id']).'" method="post">
    				<div class="name_prof_b">Почта</div>
    					<input class="form_mail" value="'.$res['email'].'" name="mail" type="text"/>
    				<div class="name_prof_b">Аватар</div>
    					<input class="form_ava" value="'.$res['ava'].'" name="ava" type="text"/>
    				<div class="name_prof_b">Статус</div>
    					<div class="bb_code_div">'.BB_PANEL('set','stat').'</div>
    					<textarea class="form_status" name="stat" type="text">'.$res['stat'].'</textarea>
    					<input class="add_news" value="Сохранить" type="submit"/>
    				</form>
    		</div>';
    		echo '<div class="stat_prof">
    		<div class="name_prof_block">Пароль</div>
    				<form action="" method="post">
    					<input class="form_mail" placeholder="Старый пароль" name="pas" type="text"/>
    					<input class="form_mail" placeholder="Новый пароль" name="pass1" type="text"/>
    					<input class="form_ava" placeholder="Повторите новый пароль" name="pass2" type="text"/>
    					<input class="add_news" value="Сменить пароль" type="submit"/>
    				</form>
    		</div>';
    	}
    	if ($res['ban'] == 0) {
    	echo '<div class="user_prof">Ваш аккаунт заблокирован<a class="logout_prof" href="/?step=exit">Выход</a></div>';
    	}
    }
    else {
    		echo 'Доступ запрещен';
    }
    }

    slowpoke59rus, 27 Апреля 2016

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

    +2

    1. 001
    2. 002
    3. 003
    4. 004
    5. 005
    6. 006
    7. 007
    8. 008
    9. 009
    10. 010
    11. 011
    12. 012
    13. 013
    14. 014
    15. 015
    16. 016
    17. 017
    18. 018
    19. 019
    20. 020
    21. 021
    22. 022
    23. 023
    24. 024
    25. 025
    26. 026
    27. 027
    28. 028
    29. 029
    30. 030
    31. 031
    32. 032
    33. 033
    34. 034
    35. 035
    36. 036
    37. 037
    38. 038
    39. 039
    40. 040
    41. 041
    42. 042
    43. 043
    44. 044
    45. 045
    46. 046
    47. 047
    48. 048
    49. 049
    50. 050
    51. 051
    52. 052
    53. 053
    54. 054
    55. 055
    56. 056
    57. 057
    58. 058
    59. 059
    60. 060
    61. 061
    62. 062
    63. 063
    64. 064
    65. 065
    66. 066
    67. 067
    68. 068
    69. 069
    70. 070
    71. 071
    72. 072
    73. 073
    74. 074
    75. 075
    76. 076
    77. 077
    78. 078
    79. 079
    80. 080
    81. 081
    82. 082
    83. 083
    84. 084
    85. 085
    86. 086
    87. 087
    88. 088
    89. 089
    90. 090
    91. 091
    92. 092
    93. 093
    94. 094
    95. 095
    96. 096
    97. 097
    98. 098
    99. 099
    100. 100
    function plays(){
    var snd = new Audio("http://boobooka.com/wp-content/uploads/2013/02/33bells33.mp3");   
    snd.preload = "auto";   
    snd.play();
    }
    
    function showTime()
    {
    var dat = new Date();
    var ch = dat.getDate();
    var montha = new Array();
    montha[0] = "января";
    montha[1] = "февраля";
    montha[2] = "марта";
    montha[3] = "апреля";
    montha[4] = "мая";
    montha[5] = "июня";
    montha[6] = "июля";
    montha[7] = "августа";
    montha[8] = "сентября";
    montha[9] = "октября";
    montha[10] = "ноября";
    montha[11] = "декабря";
    var mon = montha[dat.getMonth()];
    var ye = dat.getYear()+ 1900;
    var ned = dat.getDay();
    var day = new Array();
    day[1] = "Понедельник";
    day[2] = "Вторник";
    day[3] = "Среда";
    day[4] = "Четверг";
    day[5] = "Пятница";
    day[6] = "Суббота";
    day[0] = "Воскресенье";
    var nedel = day[dat.getDay()];
    var H = '' + dat.getHours();
    H = H.length<2 ? '0' + H:H;
    var M = '' + dat.getMinutes();
    M = M.length<2 ? '0' + M:M;
    var S = '' + dat.getSeconds();
    S =S.length<2 ? '0' + S:S;
    var clock = H + ':' + M + ':' + S;
    var cl = H + M + S;
    var chislo = ch+" "+mon;
    var chisl = ye+" года";
    document.getElementById('time_div').innerHTML=clock;
    document.getElementById('ned_div').innerHTML=nedel;
    document.getElementById('chi_div').innerHTML=chislo;
    document.getElementById('chis_div').innerHTML=chisl;
    if(clock == '09:00:00'){if(1<=ned && ned<=6){plays();}}
    if(clock == '09:40:00'){if(1<=ned && ned<=6){plays();}}
    if(clock == '09:50:00'){if(1<=ned && ned<=6){plays();}}
    if(clock == '10:30:00'){if(1<=ned && ned<=6){plays();}}
    if(clock == '10:40:00'){if(1<=ned && ned<=6){plays();}}
    if(clock == '11:20:00'){if(1<=ned && ned<=6){plays();}}
    if(clock == '11:40:00'){if(1<=ned && ned<=6){plays();}}
    if(clock == '12:20:00'){if(1<=ned && ned<=6){plays();}}
    if(clock == '12:30:00'){if(1<=ned && ned<=6){plays();}}
    if(clock == '13:10:00'){if(1<=ned && ned<=6){plays();}}
    if(clock == '13:20:00'){if(1<=ned && ned<=6){plays();}}
    if(clock == '14:00:00'){if(1<=ned && ned<=6){plays();}}
    if(clock == '14:20:00'){if(1<=ned && ned<=6){plays();}}
    if(clock == '15:00:00'){if(1<=ned && ned<=6){plays();}}
    if(clock == '15:10:00'){if(1<=ned && ned<=6){plays();}}
    if(clock == '15:50:00'){if(1<=ned && ned<=6){plays();}}
    if(clock == '16:00:00'){if(1<=ned && ned<=6){plays();}}
    if(clock == '16:40:00'){if(1<=ned && ned<=6){plays();}}
    if(clock == '16:45:00'){if(1<=ned && ned<=6){plays();}}
    if(clock == '17:25:00'){if(1<=ned && ned<=6){plays();}}
    if(clock == '17:30:00'){if(1<=ned && ned<=6){plays();}}
    if(clock == '18:10:00'){if(1<=ned && ned<=6){plays();}}
    if(clock == '18:15:00'){if(1<=ned && ned<=6){plays();}}
    if(clock == '18:55:00'){if(1<=ned && ned<=6){plays();}}
    setTimeout(showTime,1000);
    if(1<=ned && ned<=6)
    {
        if(cl >= 090000 && cl < 094000) {document.getElementById('mes_div').innerHTML="Идет 1-й урок (09:00-09:40)";}
        if(cl >= 094000 && cl < 095000) {document.getElementById('mes_div').innerHTML="ПЕРЕМЕНА!!! (09:40-09:50)";}
        if(cl >= 095000 && cl < 103000) {document.getElementById('mes_div').innerHTML="Идет 2-й урок (09:50-10:30)";}
        if(cl >= 103000 && cl < 104000) {document.getElementById('mes_div').innerHTML="ПЕРЕМЕНА!!! (10:30-10:40)";}
        if(cl >= 104000 && cl < 112000) {document.getElementById('mes_div').innerHTML="Идет 3-й урок (10:40-11:20)";}
        if(cl >= 112000 && cl < 114000) {document.getElementById('mes_div').innerHTML="ПЕРЕМЕНА!!! (11:20-11:40)";}
        if(cl >= 114000 && cl < 122000) {document.getElementById('mes_div').innerHTML="Идет 4-й урок (11:40-12:20)";}
        if(cl >= 122000 && cl < 123000) {document.getElementById('mes_div').innerHTML="ПЕРЕМЕНА!!! (12:20-12:30)";}
        if(cl >= 123000 && cl < 131000) {document.getElementById('mes_div').innerHTML="Идет 5-й урок (12:30-13:10)";}
        if(cl >= 131000 && cl < 132000) {document.getElementById('mes_div').innerHTML="ПЕРЕМЕНА!!! (13:10-13:20)";}
        if(cl >= 132000 && cl < 140000) {document.getElementById('mes_div').innerHTML="Идет 6-й урок (13:20-14:00)";}
        if(cl >= 140000 && cl < 142000) {document.getElementById('mes_div').innerHTML="ПЕРЕМЕНА!!! (14:00-14:20)";}
        if(cl >= 142000 && cl < 150000) {document.getElementById('mes_div').innerHTML="Идет 7-й урок (14:20-15:00)";}
        if(cl >= 150000 && cl < 151000) {document.getElementById('mes_div').innerHTML="ПЕРЕМЕНА!!! (15:00-15:10)";}
        if(cl >= 151000 && cl < 155000) {document.getElementById('mes_div').innerHTML="Идет 8-й урок (15:10-15:50)";}
        if(cl >= 155000 && cl < 160000) {document.getElementById('mes_div').innerHTML="ПЕРЕМЕНА!!! (15:50-16:00)";}
        if(cl >= 160000 && cl < 164000) {document.getElementById('mes_div').innerHTML="Идет 9-й урок (16:00-16:40)";}
        if(cl >= 164000 && cl < 164500) {document.getElementById('mes_div').innerHTML="ПЕРЕМЕНА!!! (16:40-16:45)";}
        if(cl >= 164500 && cl < 172500) {document.getElementById('mes_div').innerHTML="Идет 10-й урок (16:45-17:25)";}
        if(cl >= 172500 && cl < 173000) {document.getElementById('mes_div').innerHTML="ПЕРЕМЕНА!!! (17:25-17:30)";}
        if(cl >= 173000 && cl < 181000) {document.getElementById('mes_div').innerHTML="Идет 11-й урок (17:30-18:10)";}
        if(cl >= 181000 && cl < 181500) {document.getElementById('mes_div').innerHTML="ПЕРЕМЕНА!!! (18:10-18:15)";}
        if(cl >= 181500 && cl < 185500) {document.getElementById('mes_div').innerHTML="Идет 12-й урок (18:15-18:55)";}
    if(cl >= 185500 && cl < 235959) {document.getElementById('mes_div').innerHTML="  ";}

    Исходный код из "научно-практической" работы школьника.
    Прихватил с конференции. (Не всё влезло)

    RigFox, 27 Апреля 2016

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

    +5

    1. 1
    2. 2
    Результат работы нашего бывшего верстальщика.
    http://pastebin.com/sDndiz9Q

    Результат работы нашего бывшего верстальщика.
    http://pastebin.com/sDndiz9Q

    infolevelru, 26 Апреля 2016

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

    +1

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    <p class="name">
                    {% if (file.url) { %}
                        <a href="{%=file.url%}" title="{%=file.name%}" download="{%=file.name%}" {%=file.thumbnailUrl?'data-gallery':''%}>{%=file.name%}</a>
                    {% } else { %}
                        <span>{%=file.name%}</span>
                    {% } %}
                </p>
                {% if (file.error!="SyntaxError: Unexpected token <") { %}
                    <div><span class="label label-danger">Error</span> {%=file.error%}</div>
                {% } %}

    Шедевральный человек! Оригинал http://www.yiiframework.ru/forum/viewtopic.php?t=15956#p119944

    dimka3210, 23 Апреля 2016

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

    +1

    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
    97. 97
    98. 98
    99. 99
    void CScene::IncludeObjects()
    {
    // Reset All.
    	ExcludeObjects();
    
    // fill Vershiny of piramid...
    	point3d versh[4];
    	point3d eye = {IniSet.ptCamPos.x, IniSet.ptCamPos.y, IniSet.ptCamPos.z};
    	Screen2World(0, 0, versh[0]);
    	Screen2World(nScreenSzX, 0, versh[1]);
    	Screen2World(nScreenSzX, nScreenSzY, versh[2]);
    	Screen2World(0, nScreenSzY, versh[3]);
    
    // Increase before OO...
    	
    	int ix, sz = parrObjs.Size();
    	point3d vect;
    	for(ix = 0; ix < 4; ix++){
    		sub_vectors(&vect.x, &versh[ix].x, &eye.x);
    		norm_vect(&vect.x);
    		scale_vect(&vect.x, 200.f);
    		versh[ix] = vect;
    	}
    
    // Create faces of piramid and search collision with it...
    	point3d Piramid[4][3];
    	Piramid[0][0] = eye;
    	Piramid[1][0] = eye;
    	Piramid[2][0] = eye;
    	Piramid[3][0] = eye;
    	Piramid[0][1] = versh[0];
    	Piramid[0][2] = versh[1];
    	Piramid[1][1] = versh[1];
    	Piramid[1][2] = versh[2];
    	Piramid[2][1] = versh[2];
    	Piramid[2][2] = versh[3];
    	Piramid[3][1] = versh[3];
    	Piramid[3][2] = versh[0];
    	
    // Dyadya WALERA!!!!
    	for(ix = nObjOff; ix < sz; ix++){
    		CObj3d *pObj = parrObjs.e(ix);
    		pObj->Transform(FALSE);
    		point3d ptPos = pObj->GetPosition();
    
    		if(IniSet.nIncludeObjectMode == WS_INCLUDE_BARYCENTER){
    			point3d ptCentr = IniSet.ptCamTarget;
    			point3d vtVect;
    			
    			sub_vectors(&vtVect.x, &ptPos.x, &ptCentr.x);
    
    			plane plGran;
    			point3d ptCross;
    			for(int jx = 0; jx < 4; jx++){
    				comp_plane_eqn(&plGran.a, &Piramid[jx][0].x, &Piramid[jx][1].x, &Piramid[jx][2].x);
    				cross_line_plane(vtVect, &plGran.a, ptCentr, ptCross);
    				float f1, f2;
    				f1 = plGran.a * ptPos.x + plGran.b * ptPos.y + plGran.c * ptPos.z + plGran.d;
    				f2 = plGran.a * ptCentr.x + plGran.b * ptCentr.y + plGran.c * ptCentr.z + plGran.d;
    				if(f1 * f2 < 0.f){
    					if(point_in_triangle(Piramid[jx][0], Piramid[jx][1], Piramid[jx][2], ptCross)){
    						ptCross = ConvertPos3D(ptCross);
    						if(IniSet.bMirrorH){ ptCross.y = -ptCross.y; }
    						if(IniSet.bMirrorV){ ptCross.x = -ptCross.x; }
    						if(IniSet.bMirrorD){ ptCross.z = -ptCross.z; }
    
    						transform_back_point(&ptCross, &ptCross, &IniSet.mtMatr);
    						pObj->ptSavedPos = ptCross;
    						break;
    					}
    				}
    			}
    		}else{ // XYZ Axes.
    			point3d vtXYZ[3] = {{1.f, 0.f, 0.f},
    								{0.f, 1.f, 0.f},
    								{0.f, 0.f, 1.f}};
    
    			BOOL bFound = FALSE;
    			for(int ax = 0; ax < 3; ax++){
    
    				point3d vtVect;
    				transform_point(&vtVect, &vtXYZ[ax], &IniSet.mtMatr);
    				
    				for(int jx = 0; jx < 4; jx++){
    					plane plGran;
    					comp_plane_eqn(&plGran.a, &Piramid[jx][0].x, &Piramid[jx][1].x, &Piramid[jx][2].x);
    					
    					point3d ptCentr = IniSet.ptCamTarget;
    
    					point3d ptCross;
    					cross_line_plane(vtVect, &plGran.a, ptPos, ptCross);
    					float f1, f2;
    
    					f1 = plGran.a * ptPos.x + plGran.b * ptPos.y + plGran.c * ptPos.z + plGran.d;
    					f2 = plGran.a * ptCentr.x + plGran.b * ptCentr.y + plGran.c * ptCentr.z + plGran.d;
    
    					point3d vtDif;
    					sub_vectors(&vtDif.x, &ptCross.x, &IniSet.ptCamPos.x);
    					if(vec_length(&vtDif.x) < 0.01f){ continue; } // avoid crossing with eye.

    Гавнокод: включить все 3Д объекты в экран.

    falcoware, 21 Апреля 2016

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