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

    +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
    <?php
            $gudir = opendir("../text/$book");
            $guarray = Array();
            while(false != ($gufile = readdir($gudir)))
            {
                    if(strstr($gufile, "gu@"))
                    {
                            $guarray[count($guarray)] = $gufile;
                    }
            }
            closedir($gudir);
            if(count($guarray))
            {
                    rsort($guarray);
                    foreach($guarray as $gucomment)
                    {
                            /*Здесь движок отображения комментариев*/
                            include "../text/$book/$gucomment";
                    }
            }
    ?>

    Я не знаю, что делает этот код. Никаких файлов с символами gu@ в каталогах не осталось. Лет 8 назад с другом книгу писали, решили замутить сайт. Ту книгу мы потом посчитали фигней и забросили. Про БД я тогда и не подозревал. Все хранилось в таких файлах:

    chapter#prae#prae#Предисловие#previous#0 #0#next#1#1
    chapter#1#1#Глава 1.1#previous#prae#prae#next#1#2
    chapter#1#2#Глава 1.2#previous#1#1#next#0#0

    kgm-rj, 23 Ноября 2015

    Комментарии (13)
  2. JavaScript / Говнокод #19070

    +3

    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
    function getNameBrouser()
    {
    	ua = navigator.userAgent.toLowerCase();
    	//Internet Explorer
    	if (ua.indexOf("msie") != -1 && ua.indexOf("opera") == -1 && ua.indexOf("webtv") == -1)
    	{
    		return 1;//"msie";;
    	}
    	// Opera
    	if (ua.indexOf("opera") != -1)
    	{
    		return 2;//"opera";
    	}
    	// Mozilla + Firefox + Netscape
    	if (ua.indexOf("mfn") != -1)
    	{
    		return 3;//"mfn";
    	}
    	// Safari
    	if (ua.indexOf("safari") != -1)
    	{
    		return 4;//"safari";
    	}
    	// Konqueror
    	if (ua.indexOf("konqueror") != -1)
    	{
    		return 5;//"konqueror";
    	}
    	return 6;//"unknown";
    }

    Студенческие сайтики.

    nihau, 23 Ноября 2015

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

    +3

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    7. 7
    8. 8
    public function calculateSum($products) {
            $sum = 0.0;
            array_map(function($product) use (&$sum)
            {
                    $sum += $product->hasSale() ? $product->getPriceWithSale() : $product->getPrice();
            }, $products);
            return $sum;
    }

    Человек начитался, что функциональщина это модно, но вот про её основу, immutable states, он не слышал. В общем, человек открыл для себя ещё foreach.

    Strannik1941, 23 Ноября 2015

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

    +3

    1. 1
    <image_block class="inner" interactivity="no" list_entry_id="da vi uporolis">

    Fai, 23 Ноября 2015

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

    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
    $routeAnalyze = new TaxiRouteAnalyzerLite();
    $options = array(
    	'fromLat'     => $fromLat,
    	'fromLon'     => $fromLon,
    	'toLat'       => $toLat,
    	'toLon'       => $toLon,
    	'cityPolygon' => $this->cityPolygon,
    	'costPos'     =>$costPos,
    	'costPosOut'  => $costPosOut,
    	'costKm'      => $costKm,
    	'costKmOut'   => $costKmOut,
    	'includedKm'  => $includedKm,
    	'meas'        => 'distance',
    	'costKmOutIn' => $costKmOutIn,
    );
    $this->writeLog('options', $options);
    $cost = $routeAnalyze->calcCost($fromLat, $fromLon, $toLat, $toLon, $this->cityPolygon, $costPos, $costPosOut, $costKm, $costKmOut, $includedKm, 'distance', $costKmOutIn);
    $this->writeLog('cost', $cost);
    return $cost;

    Неужели нужно создавать отдельно переменную чтобы вывести в лог, а при этом метод должен быть таким громоздким?!

    akanit, 23 Ноября 2015

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

    +7

    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
    <?php
    $a=$_POST['a'];
    $b=$_POST['b'];
    $c=$_POST['c'];
    if $_POST['a']*x*2+$_POST['b']*x+$_POST['c']
    {
    else $y=$_POST['b']*2-4*$_POST['a']*$_POST['c'];
    nl2br('</n>')
    echo $y;
    $k1=$_POST['b']+$y/2*$_POST['a'];
    nl2br('</n>')
    echo $k1;
    $k2=$_POST['b']-$y/2*$_POST['a'];
    nl2br('</n>')
    echo $k2;
    
    }
    echo $k1;
    echo $k2;
    ?>

    http://www.cyberforum.ru/php/thread1589333.html

    wiox, 22 Ноября 2015

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

    +5

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    7. 7
    <div class="map">
        <span style="color: rgb(0, 0, 0); font-family: Tahoma; font-size: 13px;"><br></span>
        <p>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
        <br>&nbsp;
        <iframe src="https://maps.google.com/maps/MYMAP"></iframe>
         </p>
    </div>

    Попросили меня разобраться в верстве, и вот как карту сдвинули направо

    kschingiz, 22 Ноября 2015

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

    +4

    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
    typedef std::map<std::string, WORD> Values;
    
    struct Less {
    	bool operator()(Values::value_type const& left
    	, Values::value_type const& right) const {
    	   if (right.second == TEMPERATURE_UNKNOWN 
    		  || left.second == TEMPERATURE_UNKNOWN) {
    			 return false;
    	   }
    	   short const signed_left = *reinterpret_cast<short const*>(&left.second);
    	   short const signed_right = *reinterpret_cast<short const*>(&right.second);
    	   bool const result = signed_left < signed_right;
    	   return result;
    	}
    };

    Строки 10 и 11.
    20+ опыта в С++ у чувачка.

    blackhearted, 21 Ноября 2015

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

    +4

    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
    template<size_t n>
    struct counterNumber {
        char data[n+1];
    };
     
    template<size_t index, size_t val>
    counterNumber<val> magic(counterNumber<index>, counterNumber<val>);
     
    #define COUNTER_READ() \
        (sizeof( \
            magic(counterNumber<1>(), \
            	magic(counterNumber<2>(), \
            		magic(counterNumber<4>(), \
            			magic(counterNumber<8>(), \
            				magic(counterNumber<16>(), \
            					magic(counterNumber<32>(), \
            						magic(counterNumber<64>(), \
            							magic(counterNumber<128>(), counterNumber<0>())))))))))-1)
     
    #define COUNTER_INC() \
        counterNumber<COUNTER_READ()+1> magic( \
            counterNumber<(COUNTER_READ()+1)&~COUNTER_READ()>, \
            counterNumber<(COUNTER_READ()+1)&COUNTER_READ()>)
     
    #include <iostream>
    using namespace std;
    #define TO_STRING(x) #x
     
     
    #define REG_FUNCTIONAL(headFunction) \
        template<> \
        constexpr auto foo< COUNTER_READ() >() \
        { \
            return TO_STRING(headFunction); \
        } \
        COUNTER_INC(); \
        headFunction
     
    template<size_t n>
    constexpr auto foo(void){return "";}
     
     
    REG_FUNCTIONAL(void function(int a)){(void)a;}
    REG_FUNCTIONAL(void function1(int a)){(void)a;}
     
     
    	// your code goes here
    template<size_t n>
    std::string callFoo()
    {
        return std::string(foo<n>())+callFoo<n-1>();
    }
     
    template<>
    std::string callFoo<0>()
    {
        return std::string(foo<0>());
    }
     
    int main() {
    	std::cout<<callFoo<COUNTER_READ()-1>();
    	return 0;
    }

    https://ideone.com/bASDDc

    IKing, 21 Ноября 2015

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

    +6

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    function fvalidate(val) {
    		if($('[name=pwidc]').val() == false) {$('[name=pwidc]').css({'background-color':'red','color':'#FFFFFF'}); return false;}else{$('[name=pwidc]').css({'background-color':'#FFFFFF','color':'#000000'});}
    	if(!$('[name=itemname]').val()) {$('[name=itemname]').css({'background-color':'red','color':'#FFFFFF'}); return false;}else{$('[name=itemname]').css({'background-color':'#FFFFFF','color':'#000000'});}
    	if(!$('[name=itemsale]').val()) {$('[name=itemsale]').css({'background-color':'red','color':'#FFFFFF'}); return false;}else{$('[name=itemsale]').css({'background-color':'#FFFFFF','color':'#000000'});}
    	if(!$('[name=salemax]').val()) {$('[name=salemax]').css({'background-color':'red','color':'#FFFFFF'}); return false;}else{$('[name=salemax]').css({'background-color':'#FFFFFF','color':'#000000'});}
    	if(!$('[name=itemid]').val()) {$('[name=itemid]').css({'background-color':'red','color':'#FFFFFF'}); return false;}else{$('[name=itemid]').css({'background-color':'#FFFFFF','color':'#000000'});}
    	if(!$('[name=itemcount]').val()) {$('[name=itemcount]').css({'background-color':'red','color':'#FFFFFF'}); return false;}else{$('[name=itemcount]').css({'background-color':'#FFFFFF','color':'#000000'});}
    	if(!$('[name=itemcountmax]').val()) {$('[name=itemcountmax]').css({'background-color':'red','color':'#FFFFFF'}); return false;}else{$('[name=itemcountmax]').css({'background-color':'#FFFFFF','color':'#000000'});}
    	if(!$('[name=itemmask]').val()) {$('[name=itemmask]').css({'background-color':'red','color':'#FFFFFF'}); return false;}else{$('[name=itemmask]').css({'background-color':'#FFFFFF','color':'#000000'});}
    }

    Номинация "Валидация года".
    Скопировано с js файлов одного из сайтов ;D

    skydev, 21 Ноября 2015

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