1. PHP / Говнокод #14563

    +159

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    class Z {
       public function __toString() { return 'zzzzzzzz'; }
    }
    
     $zz = array();
     $zz[call_user_func_array('sprintf', array('%s', new Z))] = 1;

    нахуй так жить?

    __proto__, 13 Февраля 2014

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

    +151

    1. 1
    2. 2
    3. 3
    error_reporting( 0 );
    
    unset( $x[new XSLTProcessor()][new RecursiveArrayIterator()] );

    __proto__, 13 Февраля 2014

    Комментарии (11)
  3. Perl / Говнокод #14557

    −151

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    if( my $row = &dbselectrow( $sql ) )
            {
                    if( $row -> { 'ofid' } == 9782 ) # moscow
                    {
                            if( $row -> { 'jt' } =~ /Начальник /i )
                            {
                                    &subscribe_to_management( $row -> { 'email' } );
                            }
                    }
            }

    Автоматическая подписка сотрудника руководящей должности на список рассылки для руководителей.

    kainwinterheart, 13 Февраля 2014

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

    +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
    private function toDBFields($fields){
    			$db_fields = array();
    			if ($fields){
    				foreach($fields as $field){
    					switch ($field){
    
                            case 'p_bits':
                                if (!array_search('b1',$db_fields))	$db_fields[] = 'b1';
                                break;
                            case 'n2':
                                if (!array_search('b1',$db_fields))	$db_fields[] = 'b1';
                                break;
                            case 'n1':
                                if (!array_search('b1',$db_fields))	$db_fields[] = 'b1';
                                break;
    						case 'cntdf':
    							if (!array_search('cntdf',$db_fields))	$db_fields[] = 'cntdf';
    							break;
    						case 'first_pckg':
    						
    							break;
    						case 'az':
    							if (!array_search('az',$db_fields))		$db_fields[] = 'az';
    							break;
    						case 'akb_v':
    							//if (!array_search('b2',$db_fields))		$db_fields[] = 'b2';
    							if (!array_search('b3',$db_fields))		$db_fields[] = 'b3';
    							break;
    						case 'p1code':
                            case 'ignition_ap1':
    							if (!array_search('b4',$db_fields))		$db_fields[] = 'b4';
    							if (!array_search('b6',$db_fields))		$db_fields[] = 'b6';
    							break;
    						case 'fuel_p2':
                            case 'fuel_p2_debug':
                            case 'p2code':
    							if (!array_search('b5',$db_fields))		$db_fields[] = 'b5';
    							if (!array_search('b6',$db_fields))		$db_fields[] = 'b6';
    							break;
                            case 'fuel_p3':
                            case 'fuel_p3_debug':
    						case 'p3code':
                            case 'p3code_debug':
    							if (!array_search('b7',$db_fields))		$db_fields[] = 'b7';
    							if (!array_search('b6',$db_fields))		$db_fields[] = 'b6';
    							break;
                            case 'fuel_p3p4_2drt':
                                if (!array_search('b8',$db_fields))		$db_fields[] = 'b8';
    							if (!array_search('b7',$db_fields))		$db_fields[] = 'b7';
    							if (!array_search('b6',$db_fields))		$db_fields[] = 'b6';
    							break;
                            case 'fuel_p2p3':
                                if (!array_search('b5',$db_fields))		$db_fields[] = 'b5';
    							if (!array_search('b7',$db_fields))		$db_fields[] = 'b7';
    							if (!array_search('b6',$db_fields))		$db_fields[] = 'b6';
    							break;
                            case 'fuel_p4':
                            case 'p4code_debug':
    						case 'p4code':
    							if (!array_search('b8',$db_fields))		$db_fields[] = 'b8';
    							if (!array_search('b6',$db_fields))		$db_fields[] = 'b6';
    							break;
    					}
    				}
    			}
    
    			return $db_fields;

    Вот такой кейс который используется в системе для перевода типа переменной к названию поле в таблице ....

    Deimm, 13 Февраля 2014

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

    +154

    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
    <?php
    session_start();
    include("database.php");
    include("filter.php");
    $filter = new Filter();
    isset($_GET['cat']) ? $id = $filter->Symbols($_GET['cat']) : exit("Вы зашли на страницу без параметра!");
    	
    if ( !isset($_POST['class']) && empty($_POST['class']) )
    {
    	include('header.php');
    	echo '
    		<title>Title</title>
    	';
    	include('slider.php');
    	echo '
    	<div id="Content">
    	';
    }
    
    $query_amount = $mysqli->query("SELECT COUNT(id) FROM `page_film` WHERE `genre_film`='$id' ");
    $amount_film = $query_amount->fetch_row();
    
    $query = $mysqli->query("SELECT * FROM `page_film` WHERE `genre_film`='$id' ORDER BY `id` DESC ");
    
    if ( $amount_film[0] > 0 )
    	while( $row = $query->fetch_array(MYSQLI_ASSOC) )
    		echo '
    			<div class="block-film">
    				<a class="block-link-image" href="../films/film.php?id='.$row['id'].'">
    					<img src="'.$row['poster'].'" />
    				</a>
    				<div class="block-film-text">
    					<p class="film-name">
    						<a href="../films/film.php?id='.$row['id'].'">'.$row['title'].'</a>
    					</p>
    					<p class="film-mini-name">
    						<a href="../films/film.php?id='.$row['id'].'">'.$row['desc'].'</a>
    					</p>
    					<p class="film-genre"><span>'.$row['genre'].'</span></p>
    					<p class="film-description">'.$row['description'].'</p>
    				</div>
    			</div>
    		';
    
    if ( !isset($_POST['class']) && empty($_POST['class']) )
    {
    	echo '	
    	</div>
    </body>
    </html>
    	';
    }
    ?>

    alexkor, 13 Февраля 2014

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

    +51

    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
    template <class T> class return_1_t: public std::unary_function<T, T> {
    public:
    	return_1_t(const T & Ret) : _ret(Ret) {}
    	T operator()(T Arg) const { return _ret; }
    private:
    	T _ret;
    };
    template <class Arg1, class Arg2> class project1st: public std::binary_function<Arg1, Arg2, Arg1> {
    public:
    	Arg1 operator()(const Arg1 & X, const Arg2 & Y) { return X; }
    };
    template <class Arg1, class Arg2> class project2nd: public std::binary_function<Arg1, Arg2, Arg2> {
    public:
    	Arg2 operator()(const Arg1 & X, const Arg2 & Y) { return Y; }
    };
    template <class T> class identity: public std::unary_function<T, T> {
    public:
    	T operator()(const T & Arg) const { return Arg; }
    };
    template <class To, class From> class static_cast_t: public std::unary_function<To, From> {
    public:
    	To operator()(From obj) const {	return static_cast<To>(obj); }
    };
    template <class T> class take_address: public std::unary_function<T&, T*> {
    public:
    	result_type operator()(argument_type arg) const { return &(arg); }
    };
    template <class T> class take_const_address: public std::unary_function<const T&, const T*> {
    public:
    	result_type operator()(argument_type arg) const { return &(arg); }
    };
    template <class T> class creator: public std::unary_function<void, T*> {
    public:
    	result_type operator()(void) const { return new T(); }
    };
    template <class T, class Arg1> class creator_1_par: public std::unary_function<Arg1, T*> {
    public:
    	result_type operator()(argument_type arg) const { return new T(arg); }
    };
    template <class T, class Arg1, class Arg2> class creator_2_par: public std::binary_function<Arg1, Arg2, T*> {
    public:
    	result_type operator()(first_argument_type arg1, second_argument_type arg2) const	{ return new T(arg1, arg2);	}
    };
    template <class T> class maker: public std::unary_function<void, T> {
    public:
    	result_type operator()(void) const { return T(); }
    };
    template <class T, class Arg1> class maker_1_par: public std::unary_function<Arg1, T> {
    public:
    	result_type operator()(argument_type arg) const { return T(arg); }
    };
    template <class T, class Arg1, class Arg2> class maker_2_par: public std::binary_function<Arg1, Arg2, T> {

    Вот до чего доводит людей отсутствие частичного применения и лямбд.

    laMer007, 13 Февраля 2014

    Комментарии (21)
  7. Си / Говнокод #14552

    +116

    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
    #include <stdio.h>
    #include <stdlib.h>
     
    int main() {
    	printf("%s\n", NULL);
    	return 0;
    }
    
    
    
    #include <stdio.h>
    #include <stdlib.h>
     
    int main() {
    	const char str[] = "%s\n";
    	printf(str, NULL);
    	return 0;
    }

    Эквивалентные программы такие эквивалентные. А всё из-за printf optimization в GCC.

    Стандарт, кстати, разрешает, потому что это UB.

    Вообще пора создать ub.govnokod.ru и складывать туда примеры разного поведения на каждое UB из стандарта.

    someone, 13 Февраля 2014

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

    −168

    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
    Если СтрНС <> Неопределено Цикл
    	Если СтрНС.Значение <> Справочники.Номенклатура.ПустаяСсылка() тогда
    		Тост = ОстаткиПоСкладамУпр(СтрНС.Значение);
    		Синхро = Истина;
    		Если Тост[0].Остаток <> 0 тогда
    			НаличиеНаСкладе = Истина;
    		Конецесли;
    	КонецЕсли;	
    КонецЕсли;
    
    //...
    
    Если НаличиеНаСкладе Тогда
    	// другой быдлокод
    КонецЕсли;

    Переменная НаличиеНаСкладе объявляется только один раз во всем модуле, в приведенном мною куске.
    Угадай, в каком месте выпадает ошибка?

    rull9ss, 12 Февраля 2014

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

    +133

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    string dirUp = striBuildDir + striBinaryDir + "\\" + striTempDir + "\\";
     string dirRelease = strDirBin;
     int i = 1;
     while (ConfigurationSettings.AppSettings["SettingDir" + i] != null)
      {

    и еще строк 100500 такого же стиля

    taburetka, 12 Февраля 2014

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

    +127

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    7. 7
    8. 8
    9. 9
    Переустановил я, значит, Шиндоус 7 (лицуха), ставлю VS 2012
    
    Все встало без проблем, предупреждений и криков о помощи.
    
    При запуске ВНЕЗАПНО всплыло окошко
    
    "Внимание! Данная программа имеет известные проблемы совместимости с данной версией Windows"
    
    Visual Studio  2012 несовместим с семеркой? Ну охуеть теперь.

    kegdan, 12 Февраля 2014

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