1. C++ / Говнокод #8293

    +161

    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
    QString str[5][5] = {"a", "b", "c", "d", "e",
                             "f", "g", "h", "i", "k",
                             "l", "m", "n", "o", "p",
                             "q", "r", "s", "t", "u",
                             "v", "w", "x", "y", "z"};
        QString enc, text = ui->lineEdit->text();
        int l = text.length();
        QString tmp[1][8] = {"s", "o", "m", "e", "t", "e", "x", "t"};
        for (int i = 0; i < 1; i++)
        {
            for (int j = 0; j < 9; j++)
            {
                for (int ix = 0; ix < 6; ix++)
                {
                    for (int jx = 0; jx < 6; jx++)
                    {
                        if(tmp[i][j] == str[ix][jx])
                            enc = str[ix][jx + 1];
                        ui->lineEdit_2->setText(enc);
                    }
                }
            }
        }
    }

    Такой-то квадрат Полибия!

    Mindless, 25 Октября 2011

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

    +147

    1. 1
    2. 2
    3. 3
    4. 4
    QT project:
    
    t=x1; x1=x2; x2=t;
    t=y1; x1=y2; y2=t;

    И еще 90 говнопятнышек!
    Налетай: http://www.viva64.com/ru/a/0077/

    Andrey_Karpov, 25 Октября 2011

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

    +70

    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
    for (AllResponseCache actionResponse : allResponses) {
                    if (null != actionResponse.getResponseStatus() && actionResponse.getResponseStatus().length() > 0) {
                        for (ResponseSubjectCache subj : actionResponse.getSubjects()) {
                            // find needed element
                            if (subj.getClaims() != null) {
                                for (ClaimCache claimCache : subj.getClaims()) {
                                    Seller seller = getSellerByPersonMatched(pool, claimCache);
                                    if (seller != null) {
                                        if (mapToSyncronize.get(seller) == null) {
                                            mapToSyncronize.put((SellerrEntity) seller, new LinkedList<ReportResponseCache>());
                                        }
                                        mapToSyncronize.get(seller).add(actionResponse);
                                    }
                                }
                            }
                        }
                    }
                }

    Индусы и "for-if"-ы.

    Я уж думал будет хронология как в России с "президентами" - "лысый, волосатый, лысый, волосатый" и так далее.
    А тут "for, if, for, if" но в конце всё-таки 2 иф-а!

    Dimedrol, 25 Октября 2011

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

    +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
    $bError=true;
    do { 
    	$logistType = $_REQUEST['logistType'];
    	if (!preg_match("|^\d+$|", $logistType)) { break; }
    	if ($_SESSION['cartaddon']['***'] and $logistType>=1 and $logistType<=5) {
    	} elseif (!$_SESSION['cartaddon']['***'] and $logistType>=3 and $logistType<=5) {
    	} else {
    		break;
    	}
    	$_SESSION['cartaddon']['logistType'] = $logistType;
    	$bError = false;
    	$text = $_REQUEST['text'];
    	$text = trim(strip_tags($text));
    	$_SESSION['cartaddon']['pozhelania'] = $text;
    } while (0);

    Проверка если ли ошибки при оформлении заказа
    На месте звездочек - палевное название, так что зацензурил

    ПыСы: код не мой. И спасибо богам за это

    kindofbear, 25 Октября 2011

    Комментарии (23)
  5. C# / Говнокод #8289

    +128

    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
    public class BusinessUnitDetail
    {
        public string Description { get; set; }
    }
    
    ...
    
    [TestMethod]
    public void DescriptionTest()
    {
        BusinessUnitDetail target = new BusinessUnitDetail(); 
        string expected = "test test test\n test"; 
        string actual;
        target.Description = expected;
        actual = target.Description;
        Assert.AreEqual(expected, actual);
    }

    беспощадная проверка всего и вся

    Eugene, 25 Октября 2011

    Комментарии (26)
  6. Java / Говнокод #8288

    +83

    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
    public static long getDifference(Date date1, Date date2, int unit) {
    	if (date1 == null || date2 == null) {
    		throw new IllegalArgumentException("Date cannot be null!");
    	}
    
    	if (date1.after(date2)) {
    		Date swap = date1;
    		date1 = date2;
    		date2 = swap;
    	}
    		
    	long result = 0;
    	
    	long diff = date2.getTime() - date1.getTime() + (60 * 60 * 1000L);
    		
    	switch (unit) {
    	case Calendar.YEAR:
    		result = diff / (60 * 60 * 24 * 365 * 1000L);
    		break;
    	case Calendar.MONTH:
    		result = diff / (60 * 60 * 24 * 30 * 1000L);
    		break;
    	case Calendar.DAY_OF_YEAR:
    		result = diff / (60 * 60 * 24 * 1000L);
    		break;
    	default:
    		throw new UnsupportedOperationException("Impossible to get time difference in coerced unit.");
    	}
    		
    	return result;
    }

    Опять даты, опять.... Java?
    Удивительно, но этот код использовался в вычислениях, связанных с начислением выплат. Разумеется, считалось всё неправильно, в связи с чем было обнаружено ЭТО.

    roman-kashitsyn, 25 Октября 2011

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

    +146

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    vec->elements = realloc(vec->elements, sizeof(struct _vector_element)*newcapacity);
                if(vec->elements == NULL) {
                    // Lol. All your data is lost.
                    vc_set_error("Unable to allocate space for elements.");
                    return 1;
                }

    Автор не догадался сохранить старый указатель.

    danilissimus, 24 Октября 2011

    Комментарии (45)
  8. Java / Говнокод #8286

    +75

    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
    /**
     * Workaround ObjectInputStream for maintaining backward compatibility with serialization.
     * 
     * In the future, please, please, PLEASE assign each serializable class an explicit serialVersionUID.
     * 
     */
    public final class DecompressibleInputStream extends ObjectInputStream {
    	private static final Logger logger = Logger.getLogger(DecompressibleInputStream.class);
    
        public DecompressibleInputStream(InputStream in) throws IOException {
            super(in);
        }
    
        protected ObjectStreamClass readClassDescriptor() throws IOException, ClassNotFoundException {
            ObjectStreamClass resultClassDescriptor = super.readClassDescriptor();
            Class<?> localClass;
            
            try {
                localClass = Class.forName(resultClassDescriptor.getName()); 
            } catch (ClassNotFoundException e) {
                logger.error("No local class for " + resultClassDescriptor.getName(), e);
                return resultClassDescriptor;
            }
            
            ObjectStreamClass localClassDescriptor = ObjectStreamClass.lookup(localClass);
            
            if (localClassDescriptor != null) { // only if class implements serializable
                final long localSUID = localClassDescriptor.getSerialVersionUID();
                final long streamSUID = resultClassDescriptor.getSerialVersionUID();
                
                if (streamSUID != localSUID &&
                		(localClass == ByteArraySerial.class || localClass == Vector2D.class)) {
                	// Workaround: check for serialVersionUID mismatch with two specific classes
                    logger.error(String.format("Overriding serialized class version mismatch for %s: " +
                    		"local serialVersionUID = %s, stream serialVersionUID = %s",
                    		localClass.getName(), localSUID, streamSUID));
                    resultClassDescriptor = localClassDescriptor; // Use local class descriptor for deserialization
                }
            }
            
            return resultClassDescriptor;
        }
    }

    Продукт использует в качестве бинарного формата сохранённых файлов встроенную сериализацию. При этом ранние версии полагались на встроенный serialVersionUID.

    Вот теперь приходится расхлёбывать. Наши воркэраунды - самые воркэраундные воркэраунды в мире.

    lucidfox, 24 Октября 2011

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

    +122

    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
    <html>
    <head>  <title> PROEKT</title> </head>
    <body>
            <body background="images/фон.JPeG" TEXT="crimson">
            <h1 align="center">LIVE IN MUSIC</H1>
            <br><img src="images/music.gif"><img src="images/music.gif">
                   <br><form action="avtor.php" method="get">
                   Логин:  <input name="login" type="text">
                   Пароль: <input name="pass" type="text">
                   <a href="indexator.html">Войти</a>
                   </form>
          
            <br><img src="images/Lights.gif"><img src="images/Lights.gif"><img src="images/Lights.gif"><img src="images/Lights.gif"><img src="images/Lights.gif">
    
    </body>
    </html>

    <br><img src="images/Lights.gif"><img src="images/Lights.gif"><img src="images/Lights.gif"><img src="images/Lights.gif"><img src="images/Lights.gif">

    qwe, 24 Октября 2011

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

    +176

    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
    if (strpos($_SERVER[HTTP_REFERER], "chocobo.us")) {
    	echo("Go away kids.");
    	exit;
    }
    
    
    if (strpos($_SERVER[REMOTE_HOST], "midmich.net")) { echo("Dry your eyes son, not everyone can be funny."); }
    if (strpos($_SERVER[REMOTE_HOST], "rima-tde.net")) { echo("spam == permban"); }
    #if ($REMOTE_ADDR == "12.227.136.202") {echo("Cheap sluts need not apply.");exit;}
    if ($REMOTE_ADDR == "129.252.177.248") {die(0);}
    if ($REMOTE_ADDR == "80.190.209.170") {die(0); }
    if ($REMOTE_ADDR == "62.163.74.167") {die(0);}
    if ($REMOTE_ADDR == "69.10.120.117") {echo("bye bye");exit;}
    if ($REMOTE_ADDR == "24.10.146.28") {echo("flooding the queue with nonsense == ban");exit;}
    if ($REMOTE_ADDR == "80.202.184.96") {echo("there is but one qdb.  ripoff artists need not apply.");exit;}
    if ($REMOTE_ADDR == "216.24.104.36") {echo("Blaxthos: yeah so, however many quotes us bash mods reject is how many cocks we suck -- take it easy");exit;}
    if ($REMOTE_ADDR == "217.230.240.250") die("No.");
    if ($REMOTE_ADDR == "134.102.2.100") {exit;}
    if ($REMOTE_ADDR == "217.64.202.205") {echo("you == idiot");exit;}
    if ($REMOTE_ADDR == "64.237.52.210") {exit;}
    if ($REMOTE_ADDR == "155.143.208.237") {exit;}
    if ($REMOTE_ADDR == "82.165.144.86") {exit;}
    if ($REMOTE_ADDR == "141.157.35.222") {echo("Go away.");exit;}
    if ($REMOTE_ADDR == "80.198.19.122") {echo("Fuck off.");exit;}
    if ($REMOTE_ADDR == "192.93.2.12") {echo("Fuck off.");exit;}
    if ($REMOTE_ADDR == "24.235.181.61") {echo("*fuckx* bash.org is for niggers.");exit;}
    if ($REMOTE_ADDR == "213.202.130.44") {echo("Fuck off.");exit;}
    if ($REMOTE_ADDR == "130.194.13.106") {echo("Fuck off.");exit;}
    if ($REMOTE_ADDR == "144.132.68.119") {echo("Fuck off.");exit;}
    if ($REMOTE_ADDR == "81.1.73.247") {echo("your access has been revoked");exit;}
    if ($REMOTE_ADDR == "68.13.143.147") {exit;}
    if ($REMOTE_ADDR == "217.8.141.230") {exit;}
    if ($REMOTE_ADDR == "62.101.198.25") {exit;}
    if ($REMOTE_ADDR == "80.96.109.170") {exit;}
    if ($REMOTE_ADDR == "80.60.182.139") {exit;}
    if ($REMOTE_ADDR == "4.21.108.175") {echo("Flooding the submission queue.  (Banned)");exit;}
    if ($REMOTE_ADDR == "151.188.16.17") {echo("Thanks for your letter.  --Blaxthos (you can all thank Lunch Box Prime (some fuckchop on AIM)");exit;}
    if ($REMOTE_ADDR == "203.217.65.231") {echo("No more.");exit;}
    if ($REMOTE_ADDR == "68.111.156.240") {echo("No more.");exit;}
    if ($REMOTE_ADDR == "82.149.227.249") {echo("No more.");exit;}

    http://webcache.googleusercontent.com/search?q=cache%3Abash.org%2Findex.bak

    Crazy_penguin, 24 Октября 2011

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