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

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

    +156

    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
    class CLoader
    {
    	protected static $_importPaths = array(APPLICATION_PATH);
    	
    	public static function import($path)
    	{
    		self::$_importPaths[] = APPLICATION_PATH . '/' . $path;
    	}
    	
    	public function classExist($className)
    	{
    		return class_exists($className) || interface_exists($className);
    	}
    	
    	public static function autoload($className)
    	{
    		foreach(self::$_importPaths as $path)
    		{
    			if(is_file($fileName = $path . '/' . $className . '.php'))
    			{
    				include $fileName;
    				break;
    			}
    		}
    	}
    }
    
    spl_autoload_register(array('CLoader', 'autoload'));

    Гавнокод или нет? Идея в том, чтобы нормально можно было написать if(CLoader::classExist('Router'))...

    Может я чего не дочитал, но если добавлять пути с либами в include_path, а в функции autoload просто писать include $className . '.php', то class_exists('Router') выкинет ошибку, если файл Router.php не найден.

    Jetti, 09 Мая 2011

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

    +170

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    $letters = array("a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n", "o", "p", "q", "r", "s", "t", "u", "v", "w", "x", "y", "z");
        foreach($letters as $x){
              if(strpos($_POST['integers'], $x)){
                   die("No letters Please!");
        }
    }

    Проверка переменной, нет ли в ней чего-нибудь кроме цифр.
    Комментарий автора улыбнул ещё больше: "There might be a few bugs"
    Источник: http://forums.tizag.com/showthread.php?t=2939

    Axell, 08 Мая 2011

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

    +151

    1. 1
    $time_sh=date('Y-m-d H:i:s',  time());

    Stamm, 06 Мая 2011

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

    +132

    1. 1
    <span style="font-weight:bold"><span style="font-style:italic"><span style="text-decoration:underline"> Превед! </span></span></span>

    <b><i><u>? Не, не слышал

    jQuery, 04 Мая 2011

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

    +113

    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
    public bool Read_XMl_File (XDocument Xml_Document, ref game_data Game_Data) { 
                bool Is_Success=false;          /* Captures this function's result */
    
                try { 
                    this.Xml_Data = (game_data)Game_Data;
    /*              Recursively read through entire XML Document */ 
                    Xml_Document.Root.RecursivelyProcess ( 
                        Process_Child_Element,
                        Process_Parent_Element_Open,
                        Process_Parent_Element_Close);
                    Is_Success = true;
                    }
    
                catch (Exception ex) { throw ex; }
    
                Game_Data = this.Xml_Data;    /* Pass the data back to Xml_Data */
                return Is_Success;
                }
     public static void RecursivelyProcess (
                    this XElement element,
                    Action<XElement, int> childAction,
                    Action<XElement, int> parentOpenAction,
                    Action<XElement, int> parentCloseAction) {  
                if (element == null) { throw new ArgumentNullException ("element"); } 
                element.RecursivelyProcess (0, childAction, parentOpenAction, parentCloseAction);  
                }  
    
     private static void RecursivelyProcess (  
                this XElement element,  
                int depth,  
                Action<XElement, int> childAction,  
                Action<XElement, int> parentOpenAction,  
                Action<XElement, int> parentCloseAction)  { 
     
                if (element == null)  { throw new ArgumentNullException ("element"); } 
                if (!element.HasElements) {         /* Reached the deepest child */
                    if (childAction != null) { childAction (element, depth); }  
                    }  
                else  {                             /* element has children */
                    if (parentOpenAction != null)  { parentOpenAction (element, depth); }  
                    depth++;  
                   
                    foreach (XElement child in element.Elements ())  {  
                        child.RecursivelyProcess ( depth,  childAction,  parentOpenAction,  parentCloseAction );  
                        }     
                    depth--;  
                    
                    if (parentCloseAction != null)  {  parentCloseAction (element, depth);  }
                    }  
                }
            }

    Avance, 29 Апреля 2011

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

    +130

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    11. 11
    12. 12
    <table>
      ...
      <tr>
        <td class="_r13 toggler" onclick='$("td").removeClass("selected"); $("._r13").addClass("selected")'>7</td>
        <td class="_r13 toggler" onclick='$("td").removeClass("selected"); $("._r13").addClass("selected")'>1</td>
        <td class="_r13">ПУ1</td>
        <td class="_r13">схр.</td>
        <td class="_r13">При &omega;=1; АМ=СчК</td>
        <td class="_r13">2, 4, 7, 8</td>
      </tr>
      ...
    </table>

    И так много-много раз ^^

    Surendil, 26 Апреля 2011

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

    +162

    1. 1
    2. 2
    <tr{if ($key+1)=="2" OR ($key+1)=="4" OR ($key+1)=="6" OR ($key+1)=="8" OR ($key+1)=="10" OR 
    ($key+1)=="12" OR ($key+1)=="14" OR ($key+1)=="16" OR ($key+1)=="18" OR ($key+1)=="20"} class="dark"{/if}>

    код с реального, довольно серьезного проекта) прогера называют оч толковым)

    i10k, 23 Апреля 2011

    Комментарии (11)
  9. Java / Говнокод #6360

    +74

    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
    public static final int TYPE_A_OK = 0;
    public static final int TYPE_R_OPEN = 1;
    public static final int TYPE_R_STOPSID = 2;
    public static final int TYPE_A_STOPSID = 3;
    //....
    public static final int TYPE_R_ALARM = 26;
    HashMap<String, Integer> typesMap = new HashMap<String, Integer>();
    
    //в конструкторе
    
    public Data() {
    typesMap.put("A_OK", TYPE_A_OK);
    typesMap.put("R_OPEN", TYPE_R_OPEN);
    typesMap.put("R_STOPSID", TYPE_R_STOPSID);
    //...
    typesMap.put("R_ALARM", TYPE_R_ALARM);
    //...
    }
    
    
    //в одном из методов
    
    public boolean processPacket(Packet pack) {
    //...
    StringTokenizer strt = new StringTokenizer(body, "\n");
    		try {
    			id = strt.nextToken();
    			sign = strt.nextToken();
    			type = typesMap.get(strt.nextToken());
    			try {
    				commBody = strt.nextToken();
    			} catch (Exception e) {
    				// System.out.println("ERR: " + id + "; " + sign + "; " + type
    				// + "; ");
    			}
    		} catch (Exception e) {
    			System.err.println(sdf.format(Calendar.getInstance().getTime()) +"packet parsing error");
    			outBody += "A_ERR\n" + e.getMessage();
    		}
    
    switch (type) {
    		case TYPE_A_OK:
    			dontsend = true;
    			break;
    		case TYPE_R_OPEN:
    			outBody = processROpen(comm);
    			break;
    		case TYPE_R_CLOSE:
    			outBody = processRClose(comm);
    			break;
    //...
    case TYPE_R_ALARM:
    			outBody = processRAlarm(comm);
    			break;
    default:
    			outBody += "A_ERR";
    			break;
    }
    //...
    if(debug)
    System.err.println(outBody);
    //...
    return true;
    }

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

    ark, 14 Апреля 2011

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

    +134

    1. 1
    2. 2
    <span id="chap">490</span>
    <img src="ch.php" style="margin-left:-5px;"> 23  </div>

    Вебкилловская капча. Это круто.
    В действии: http://webkill.ru/news/index.php?id=1
    Кстати, дизайн нравится, видно, что парень рисовать умеет.

    7ion, 13 Апреля 2011

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

    −154

    1. 1
    <img src="http://img199.imageshack.us/img199/5446/65715023.jpg" alt="">

    без комментариев))

    cdpoma, 13 Апреля 2011

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