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

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

    +169

    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
    // И отдельно проработаем кириллицу
        var rusAdditional = {
            '_' : '%5F', 'А' : '%C0', 'Б' : '%C1', 'В' : '%C2', 'Г' : '%C3', 'Д' : '%C4', 'Е' : '%C5',
            'Ж' : '%C6', 'З' : '%C7', 'И' : '%C8', 'Й' : '%C9', 'К' : '%CA', 'Л' : '%CB', 'М' : '%CC',
            'Н' : '%CD', 'О' : '%CE', 'П' : '%CF', 'Р' : '%D0', 'С' : '%D1', 'Т' : '%D2', 'У' : '%D3',
            'Ф' : '%D4', 'Х' : '%D5', 'Ц' : '%D6', 'Ч' : '%D7', 'Ш' : '%D8', 'Щ' : '%D9', 'Ъ' : '%DA',
            'Ы' : '%DB', 'Ь' : '%DC', 'Э' : '%DD', 'Ю' : '%DE', 'Я' : '%DF', 'а' : '%E0', 'б' : '%E1',
            'в' : '%E2', 'г' : '%E3', 'д' : '%E4', 'е' : '%E5', 'ж' : '%E6', 'з' : '%E7', 'и' : '%E8',
            'й' : '%E9', 'к' : '%EA', 'л' : '%EB', 'м' : '%EC', 'н' : '%ED', 'о' : '%EE', 'п' : '%EF',
            'р' : '%F0', 'с' : '%F1', 'т' : '%F2', 'у' : '%F3', 'ф' : '%F4', 'х' : '%F5', 'ц' : '%F6',
            'ч' : '%F7', 'ш' : '%F8', 'щ' : '%F9', 'ъ' : '%FA', 'ы' : '%FB', 'ь' : '%FC', 'э' : '%FD',
            'ю' : '%FE', 'я' : '%FF', 'ё' : '%B8', 'Ё' : '%A8'
        }
        for (i in rusAdditional) utf8Array[i] = rusAdditional[i];
        // Посимвольно заменяем символы на их шестнадцатиречные эквиваленты
        var res = "";
        for(i = 0; i < str.length; i++) {
            var simbol = str.substr(i,1);
            res += typeof utf8Array[simbol] != "undefined" ? utf8Array[simbol] : simbol;
        }

    http://www.1tv.ru/videoarchiver/
    Все тот же главный канал Рассеи.

    7ion, 03 Апреля 2011

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

    +169

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    $pattern = "/\w{0,5}[хx]([хx\s\!@#\$%\^&*+-\|\/]{0,6})[уy]([уy\s\!@#\$%\^&*+-\|\/]{0,6})
    [ёiлeеюийя]\w{0,7}|\w{0,6}[пp]([пp\s\!@#\$%\^&*+-\|\/]{0,6})[iие]([iие\s\!@#\$%\^&*+-\|\/]{0,6})
    [3зс]([3зс\s\!@#\$%\^&*+-\|\/]{0,6})[дd]\w{0,10}|[сcs][уy]([уy\!@#\$%\^&*+-\|\/]{0,6})[4чkк]\w{1,3}
    |\w{0,4}[bб]([bб\s\!@#\$%\^&*+-\|\/]{0,6})[lл]([lл\s\!@#\$%\^&*+-\|\/]{0,6})[yя]\w{0,10}|\w{0,8}[её][bб]
    [лске@eыиаa][наи@йвл]\w{0,8}|\w{0,4}[еe]([еe\s\!@#\$%\^&*+-\|\/]{0,6})[бb]([бb\s\!@#\$%\^&*+-\|\/]{0,6})[uу]
    ([uу\s\!@#\$%\^&*+-\|\/]{0,6})[н4ч]\w{0,4}|\w{0,4}[еeё]([еeё\s\!@#\$%\^&*+-\|\/]{0,6})[бb]([бb\s\!@#\$%\^&*+-\|\/]{0,6})
    [нn]([нn\s\!@#\$%\^&*+-\|\/]{0,6})[уy]\w{0,4}|\w{0,4}[еe]([еe\s\!@#\$%\^&*+-\|\/]{0,6})[бb]([бb\s\!@#\$%\^&*+-\|\/]{0,6})
    [оoаa@]([оoаa@\s\!@#\$%\^&*+-\|\/]{0,6})[тnнt]\w{0,4}|\w{0,10}[ё]([ё\!@#\$%\^&*+-\|\/]{0,6})[б]\w{0,6}|\w{0,4}[pп]
    ([pп\s\!@#\$%\^&*+-\|\/]{0,6})[иeеi]([иeеi\s\!@#\$%\^&*+-\|\/]{0,6})[дd]([дd\s\!@#\$%\^&*+-\|\/]{0,6})
    [oоаa@еeиi]([oоаa@еeиi\s\!@#\$%\^&*+-\|\/]{0,6})[рr]\w{0,12}/i";

    Думал навсегда потерял, а вчера случайно нашел в мемориз на одном из сайтов. Кусок этот встретил лет семь назад.

    Rpsl, 17 Марта 2011

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

    +169

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    function ValidateIPAdress($value){
        if (preg_match('/^[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}$/', $value)){
            return true;
        }
        return false;
    }
    if( ValidateIPAdress("192.168.0.1") )
        echo("This is an IPAdress");
    else
        echo("This is not an IPAdress");

    Функция проверки IP адреса.

    vdmodule, 16 Марта 2011

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

    +169

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    function isTheSame(string1, string2) {
    	var firstResult =new RegExp(string1).test(string2); 
    	var secondResult =new RegExp(string2).test(string1);
    	var commonResult = firstResult && secondResult;
    	return commonResult;
    }

    tr00_gr1m_doomster, 15 Марта 2011

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

    +169

    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
    #include <iostream>
    #include <cstdlib>
    #include "filesdescrtable.h"
    
    int ___cntr = 0;
    #define _(X) if((X) == EXIT_SUCCESS) {___cntr++;} else {std::cerr << "error on operator: " << ___cntr << std::endl; return (EXIT_FAILURE);}
    
    int main (int argc, char *argv[]) {
    	FilesDescrTable a;
    
    	int d1,d2,d3;
    
    	_(a.setAutoReport(true));
    	_(a.openFile(argv[1], O_RDWR | O_CREAT, 0600, d1));
    	_(a.openFile(argv[2], O_RDWR | O_CREAT, 0600, d2));
    	_(a.openFile(argv[3], O_RDWR | O_CREAT, 0600, d3));
    	_(a.clearFile(argv[3]));
    	_(a.cpy(d3,d2));
    	_(a.closeFile(d1));
    	_(a.closeFile(d2));
    	_(a.closeFile(d3));
    
    	return(EXIT_SUCCESS);
    }

    хитрый макрос для отлова ошибок. такой хитрый

    cahekm, 13 Марта 2011

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

    +169

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    foreach ( $all_fields as $k => $one_field )
            {
                if ( $one_field['id'] == $field_id )
                {
                }
                else
                {
                    break;
                }
            }

    дзен-foreach

    govnozmey, 12 Марта 2011

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

    +169

    1. 1
    global $_GET, $m_db;

    паццтолом

    paranoid, 11 Марта 2011

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

    +169

    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
    <?php
    	exit
    	(
    		empty($_POST['key']) ||
    		empty($_POST['time']) ||
    		empty($_POST['email']) ||
    		(int)$_POST['time'] != $_POST['time'] ||
    		strlen((int)$_POST['time']) != strlen($_POST['time']) ||
    		!preg_match('/^[^@]+@[a-zA-Z0-9._-]+\.[a-zA-Z]+$/', $_POST['email']) ||
    		($_SERVER['REQUEST_TIME'] - $_POST['time']) > 60 * 60 ||
    		md5(str_rot13(md5($_POST['time']))) != $_POST['key']
    		?'-':'+'
    	);
    ?>

    Вот Ajax ответ

    wyand, 02 Марта 2011

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

    +169

    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
    if (($_GET['var'])==0 and ($_GET['email'])==1 and ($_GET['numbers'])==1)
    $label='Вы неправильно указали логин';
    elseif (($_GET['var'])==0 and ($_GET['email'])==0 and ($_GET['numbers'])==1)
    $label='Вы неправильно указали логин и е-мейл';
    elseif (($_GET['var'])==1 and ($_GET['email'])==0 and ($_GET['numbers'])==1)
    $label='Вы неправильно указали е-мейл';
    elseif (($_GET['var'])==0 and ($_GET['email'])==0 and ($_GET['numbers'])==0)
    $label='Вы неправильно указали логин, е-мейл и числовой набор';
    elseif (($_GET['var'])==1 and ($_GET['email'])==1 and ($_GET['numbers'])==0)
    $label='Вы неправильно указали числовой набор';
    elseif (($_GET['var'])==0 and ($_GET['email'])==1 and ($_GET['numbers'])==0)
    $label='Вы неправильно указали логин и числовой набор';
    else
    $label='';

    Вывод ошибки

    Dedan, 28 Февраля 2011

    Комментарии (19)
  11. JavaScript / Говнокод #5785

    +169

    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
    <script type="text/javascript"> 
    opt_text13=new Array("Internet","Hardware","Mobiles","Soft","Sequrity","Networks","Interface");
    opt_val13=new Array("14","28","44","54","61","67","72");
    opt_val113=new Array("114","115","116","117","118","119","120","121");
    opt_text122=new Array("Essays","Scintific Publications","Online Lessons & Tests","Scintific Libraries","Other");
    opt_val122=new Array("123","124","125","126","127");
    opt_text128=new Array("Your Appartment","Cookery","All for Holidays","Family","Pats","Health","Fashion and Beauty","Purchases");
    opt_val128=new Array("129","138","146","155","162","170","179","189");
    opt_text129=new Array("Country Cottage","Repair","Construction","Interior Design","Landscape Design","Building Materials","Sanitary","Other");
    opt_val129=new Array("130","131","132","133","134","135","136","137");
    opt_text138=new Array("Recepies","Diet","Products","Tabacco","Bavarage","Delivery","Other");
    opt_val138=new Array("139","140","141","142","143","144","145");
    opt_text146=new Array("E-Cards","Tostes and scenaries","Gifts","Flowers Delivery","Holiday Organization","Fireworks","Holidays","Other");
    opt_val146=new Array("147","148","149","150","151","152","153","154");
    opt_text155=new Array("For Parents","For Children","Relation's Psyhology","Marrage","Marrage Agancies","Other");
    //...............
    opt_val252=new Array("253","254","255","256","257","258");opt_text259=new Array("Astrology","Fortune-telling","Esotericism","UFO","Other");
    opt_val259=new Array("260","261","262","263","264");
    opt_text268=new Array("Places","Tourism","Vocation","Hobbies");
    opt_val268=new Array("269","280","292","297");
    opt_text269=new Array("Restaurants & Bars","Clubs & Diskos","Bowling & Billiard","Casinos","Places for children","Circuses","Parks & Zoos","Theaters","Cinemas","Other");
    opt_val269=new Array("270","271","272","273","274","275","276","277","278","279");
    opt_text428=new Array("Newspapers","Magazines","Publishing Houses","Business publications","Computer publications","Motor-Car publications","Sport publications","Entertaining publications","Music/Cinema/TV","Publications for women","Publications for men","Publications for kids","Other publications");opt_val428=new Array("429","430","431","432","433","434","435","436","437","438","439","440","441");opt_text446=new Array("Metallurgy","Mechanical engineering","Equipment","Electronics","Energetics","Chemical industry","Agriculture","Food Industry","Factories","Light Industry","Heavy Industry","Other industries");opt_val446=new Array("447","451","458","469","473","479","483","484","485","486","487","488");opt_text447=new Array("Iron industry","Non-ferrous metallurgy","Other");opt_val447=new Array("448","449","450");opt_text451=new Array("Motor-car Factories","Engeenering Factories","Agricultural Factories","Sheepbuilding","Aircraft building","Other");
    //........
    opt_text529=new Array("Office equipment","Office furneture","Lock boxes","Stationery","Other");opt_val529=new Array("530","531","532","533","534");opt_text536=new Array("Encyclopedias","Transport","Maps","Addresses & Phones","Search people","Dictionaries","Weather","Other");opt_val536=new Array("537","543","552","553","554","555","556","557");opt_text537=new Array("Universal","Medical","Biographical","Subject encyclopedia","Other");opt_val537=new Array("538","539","540","541","542");opt_text543=new Array("Timetables","Air transport","Railway","Sailing","Urban transport","Taxi & Car rent","Bus transport","Other");opt_val543=new Array("544","545","546","547","548","549","550","551");opt_text558=new Array("Other");
    opt_val558=new Array("559");//**************************************************************

    qbasic, 23 Февраля 2011

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