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

    +166

    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
    function antiinjection($str) 
    {
     $words = array("\\", "'", ",", ";", "--", "-", "%20", "%27", " ", "`", "=", "%");
     $words_preg = array("|INSERT|i", "|DROP|i", "|SELECT|i", "|DELETE|i", "|UPDATE|i", "|TRUNCATE|i", "|SHUTDOWN|i");
    
     for($i=0;$i<count($words_preg);$i++){
    if(preg_match($words_preg[$i], $str)){$apina = 500;}
    }
     for($i=0;$i<count($words);$i++){
    $jopa=strpos($str, $words[$i]);
     if(is_numeric($jopa)){$apina = 500;}
    }
    if($apina==500){
    return FALSE;
    } else {
    return TRUE;
     }
    }

    Магическая цифра 500 ))). Переменная $jopa xD

    mishanon, 04 Января 2011

    Комментарии (12)
  2. Pascal / Говнокод #5142

    +100

    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
    dats:=datetostr(DateTimePicker1.Date);
    datp:=datetostr(DateTimePicker2.Date);
    datsc:=copy(dats,1,2);
    datsm:=copy(dats,4,2);
    datsg:=copy(dats,7,4);
    datpc:=copy(datp,1,2);
    datpm:=copy(datp,4,2);
    datpg:=copy(datp,7,4);
    idatsc:=strtoint(datsc);
    idatsm:=strtoint(datsm);
    idatsg:=strtoint(datsg);
    idatpc:=strtoint(datpc);
    idatpm:=strtoint(datpm);
    idatpg:=strtoint(datpg);
    tdatc:=strtoint(copy(p[i,6],1,2));
    tdatm:=strtoint(copy(p[i,6],4,2));
    tdatg:=strtoint(copy(p[i,6],7,4)); 
    if not ((idatsg>tdatg) or ((idatsg=tdatg) and (idatsm>tdatm)) or ((idatsc>tdatc) and (idatsm>=tdatm)) or (idatpg<tdatg) or ((idatpg=tdatg) and (idatpm<tdatm)) or ((idatpc<tdatc) and (idatpm<=tdatm))) then

    Проверка или дата с массива включена в диапазон дат с DateTimePicker'ов (еще и с ошибкой в условии)
    И вся эта фигня в цикле... Как это увидел, валерьянкой отпаивали меня долго

    Nikitiy_II, 04 Января 2011

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

    +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
    16. 16
    17. 17
    18. 18
    19. 19
    20. 20
    21. 21
    22. 22
    23. 23
    24. 24
    25. 25
    <?php
    /* Форма:
    <form action="report3result.php" method = "post">
    Отчет №3:<br/>
    От
    <input type="text" name="begindate" size="30">
    До
    <input type="text" name="finishdate" size="30">
    <select name = "searchtype3">
    <option value = "select cid as invnum from contract where mark='ok'">Выполненные договора (в заданном периоде времени) </option>
    </select>
    <br/>
    <input type="submit" name ="submit3" value="OK">
    </form>
    <br/>
    */
    //создание коротких имен переменных
    $searchtype3=$_POST['searchtype3'];
    $begindate=$_POST['begindate'];
    $finishdate=$_POST['finishdate'];
    // [...]
    $query = "".$searchtype3." and begindate > '".$begindate."' and finishdate<'".$finishdate."'";
    $result = mysql_query($query,$db );
    // [...]
    ?>

    Shadez, 04 Января 2011

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

    +145

    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
    private static List<Writer> getWriters(final String className, final Severity severity) {
        final List<Writer> writers = new ArrayList<Writer>();
        if ((className != null) && (severity != null)) {
          final Writer writer = Log.writers.get(className + severity);
          if ((writer != null) && !writers.contains(writer)) {
            writers.add(writer);
          }
        }
        if ((className != null)) {
          final Writer writer = Log.writers.get(className);
          if ((writer != null) && !writers.contains(writer)) {
            writers.add(writer);
          }
        }
        if ((severity != null)) {
          final Writer writer = Log.writers.get(severity.name());
          if ((writer != null) && !writers.contains(writer)) {
            writers.add(writer);
          }
        }
        {
          final Writer writer = Log.writers.get(null);
          if ((writer != null) && !writers.contains(writer)) {
            writers.add(writer);
          }
        }
        return writers;
      }
    
    
      public static void setWriter(final String className, final Severity severity, final Writer writer) {
        final Writer w = writer == null ? new OutputStreamWriter(System.err) : writer;
        if ((className != null) && (severity != null)) {
          Log.writers.put(className + severity, w);
          if (Log.writers.get(className) == null) {
            Log.writers.put(className, w);
          }
          if (Log.writers.get(severity.name()) == null) {
            Log.writers.put(className, w);
          }
        } else if (className != null) {
          Log.writers.put(className, w);
        } else if (severity != null) {
          Log.writers.put(severity.name(), w);
        } else {
          Log.writers.put(null, w);
        }
      }

    изобретаю велосипед

    Lure Of Chaos, 04 Января 2011

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

    +181

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    /**
          * Quits the script.
          *
          * @return Page
          */
         protected function quit()
         {
              exit;
              return $this;
         }

    Bydlo, 03 Января 2011

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

    +125

    1. 1
    m_PRICEURL = m_PRICEURL.Replace("{0}", "2010");

    Новый Год принёс не только подарки, но и коллекцию говнокода вроде такого

    Shokker, 03 Января 2011

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

    +129

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    7. 7
    Exception Myex;
                    int responseVal = HelperMethods.DoPost(url, postdata, "text/xml; charset=utf-8", ref xmlResponse, null, out Myex);
                    XmlDocument xmlDoc = new XmlDocument();
                    xmlDoc.Load(new StringReader(xmlResponse));
    
                    string StatusID = xmlDoc.ChildNodes[1].ChildNodes[0].FirstChild.Value;
                    if (StatusID.ToLower() != "0")

    Последняя строка не может не радовать. Никогда не знаешь каким большим может быть ноль ...

    Othello, 03 Января 2011

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

    +114

    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 new int? OperatorCode
            {
                get
                {
                    int result = 0;
                    if (!String.IsNullOrEmpty(Request.QueryString["OperatorCode"]) && Int32.TryParse(Request.QueryString["OperatorCode"].ToString(), out result) == true)
                        OPERATOR_CODE = result;
                    return OPERATOR_CODE;
                }
                set
                {
                    if (value.HasValue)
                        OPERATOR_CODE = value.Value;
                    else
                        OPERATOR_CODE = null;
                }
            }

    Вот такое свойство мне встретилось

    Othello, 03 Января 2011

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

    +152

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    class ListEl{
    public:
    int val;
    ListEl *head;
    ListEl *tail;
    }
    
    class MyList{
    public:
    ListEl *head, *tail;

    Rohanion, 03 Января 2011

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

    +153

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    11. 11
    this.exec = function(code,op){
      op = op || 0;
      for(cp=0;cp<code.length;cp++){
        if(code[cp]=='op'){this.stack.push(op)}
    	else if(code[cp].isNumber){this.stack.push(parseFloat(code[cp]))}
    	else if(this.vars[code[cp]] != undefined){this.stack.push(this.vars[code[cp]])}
    	else if(this.refs[code[cp]] != undefined){this.call(code[cp])}
    	else if(this.mathOp.oneOf(code[cp])){this.mathOp(code[cp])}
    	else if(code[cp] == '->'){cp++;this.vars[code[cp]]=this.stack.pop();}
      }
    }

    Еще один говнокод из моего известного некоторым особо внимательным личностям проекта

    art543484, 02 Января 2011

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