1. Java / Говнокод #5340

    +90

    1. 1
    2. 2
    if (name != null ? !name.equals(module.name) : module.name != null) return false;
    return true;

    Jk, 20 Января 2011

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

    +163

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    7. 7
    8. 8
    9. 9
    <?php	
    if (gc_disable()) gc_enable();
    
    $a = array();
    $a[0] = &$a;
    unset($a);
    
    if (gc_disable()) gc_collect_cycles();
    ?>

    Типа "освободил" память. )))

    dwinner, 20 Января 2011

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

    +159

    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
    <?
    mysql_connect("$db_host", "$db_user", "$db_pass") or die(mysql_error());
    mysql_selectdb($db) or die(mysql_error());
    $q = "SELECT `login`, `email`, `name`, `second_name`, `age` FROM $db.accounts WHERE login='".$_SESSION['login']."' ";
    $res = mysql_query($q) or die(mysql_error());
    $row=mysql_fetch_array($res);?>
    ...
    <?
    $name = $_POST['name'];
    $email = $_POST['email'];
    $log = $_SESSION['name'];
    $second_name = $_POST['second_name'];
    $age = $_POST['age'];
    mysql_connect("$db_host", "$db_user", "$db_pass") or die(mysql_error());
    mysql_selectdb($db) or die(mysql_error());
    $query = "UPDATE accounts SET name ='$name', second_name='$second_name', email='$email', age='$age' WHERE login = '$log'";
    mysql_query($query) or die(mysql_error());
    ?>

    http://www.php.ru/forum/viewtopic.php?t=30226
    Туча ошибок и проблемы с безопасностью

    Devzirom, 20 Января 2011

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

    +172

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    7. 7
    class tree
    {
    	tree *child;
    	tree(){
    	child=new tree[1]; //никогда так не делать!!
    	}
    };

    generall, 19 Января 2011

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

    +173

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    $file='spiski.txt';
    $handle = fopen($file, "r");
    while ( $handle == FALSE )
    {
    $handle = fopen($file, "r");
    }

    Метод назойливого открывания файла.

    basename, 19 Января 2011

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

    +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
    44. 44
    45. 45
    46. 46
    47. 47
    48. 48
    public static Cursor getListGroupCursor(Activity activity,
    			ShopListItem list, boolean marked) {
    		long state = marked ? Cells.PURCHAZED_STATE : Cells.WANT_TO_BUY_STATE;
    		String where;
    		String[] arg;
    		if (list.isAutoList()) {
    			where = Cells.STATE + " = ?";
    			arg = new String[] { Long.toString(state) };
    		} else {
    			where = Cells.LIST_ID + " = ? AND " + Cells.STATE + " = ?";
    			arg = new String[] { Long.toString(list.getId()),
    					Long.toString(state) };
    		}
    
    		Cursor c = activity.managedQuery(Cells.CONTENT_URI,
    				new String[] { Cells.CATEGORY_ID }, where, arg,
    				Cells.DISTINCT_SORT_ORDER);
    
    		ArrayList<Long> ids = new ArrayList<Long>();
    		while (c != null && c.moveToNext()) {
    			ids.add(new Long(c.getLong(c.getColumnIndex(Cells.CATEGORY_ID))));
    		}
    		if (c != null) {
    			c.close();
    		}
    		int count = ids.size();
    		String whereGroup = null;
    		String[] argGroup = null;
    		if (count > 0) {
    			whereGroup = "";
    			argGroup = new String[count];
    			for (int i = 0; i < count; i++) {
    				if (i < count - 1) {
    					whereGroup += (Categories._ID + "= ? OR ");
    				} else {
    					whereGroup += (Categories._ID + "= ?");
    				}
    
    				argGroup[i] = Long.toString(ids.get(i));
    				// Log.i(tag, "getListGroupCursor "+argGroup[i]);
    			}
    		} else {
    			whereGroup = Categories._ID + "= -1";
    		}
    		Cursor groupCursor = activity.managedQuery(Categories.CONTENT_URI,
    				null, whereGroup, argGroup, Categories.DEFAULT_SORT_ORDER);
    		return groupCursor;
    	}

    Работа с ContentProvider в android. Выборка категорий, id которых присутствуют в результатах первой выборки (по признаку)

    rphx, 19 Января 2011

    Комментарии (29)
  7. ActionScript / Говнокод #5334

    −117

    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
    private function formatCallResult(data : String) : URLVariables 
    {
    	try
    	{
    		var urlVariables 	: URLVariables  = new URLVariables(data);
    		MonsterDebugger.trace(this,[urlVariables.msgdesc,urlVariables.msgbody]);
    		var pattern			: RegExp 		= /\[s](.+)\[\/s\]/ig  //*new RegExp("\\[s\\]([\\w\\s]+)\\[/s\\]", "ig");*/
    		var msgdescReady	: String 		= urlVariables.msgdesc.replace(pattern, "<b>$1</b>");
    		var msgbodyReady	: String 		= urlVariables.msgbody.replace(pattern, "<b>$1</b>");
    		var pattern2		: RegExp 		= /\[n](.+)\[\/n\]/ig;
    		//TODO Write nice regexp instead !
    		urlVariables.msgdesc = msgdescReady;				
    		urlVariables.msgbody = msgbodyReady;
    		msgdescReady 		= urlVariables.msgdesc.replace(pattern2, "<b>$1</b>");	
    		msgbodyReady 		= urlVariables.msgbody.replace(pattern2, "<b>$1</b>");	
    		urlVariables.msgdesc = msgdescReady;				
    		urlVariables.msgbody = msgbodyReady;				
    		MonsterDebugger.trace(this,[urlVariables.msgdesc,urlVariables.msgbody]);
    	}
    	catch (e : Error)
    	{
    		
    	}
    	return urlVariables;
    }

    Я уже минут 10 силюсь понять, что же оно должно было делать...

    wvxvw, 19 Января 2011

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

    −110

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    11. 11
    NSString* rarityStr = [[APPDELEGATE daoManager] getDictName:tmpl.rarityId];
    int lengthdiff = [@"Uncommon" length] - [rarityStr length];
    if ([rarityStr isEqualToString:@"Rare"]) {
    	lengthdiff++;
    }				
    NSMutableString* spacesStr = [NSMutableString string];
    while (lengthdiff > 0) {
    	[spacesStr appendString:@" "];
    	lengthdiff--;
    }
    [rarityLabel setText:[NSString stringWithFormat:@"%@%@", spacesStr, rarityStr]];

    выравнивание текста в лейбле по правому краю =)

    GLvRzZZ, 19 Января 2011

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

    +163

    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
    <?php
    header('Access-Control-Allow-Origin: http://domain/');
    $file = file_get_contents($_GET['parse']);  
    $title = explode("<title>", $file);
    $title = explode("</title>", $title[1]);
    $title = $title[0];
    $arr = explode("</head>", $file);
    $arr = $arr[0]; 
    $arr = explode("<head>", $arr);
    $arr = $arr[1]; 
    $arr = str_replace("name", "id", $arr);
    $arr = str_replace("content", "value", $arr);
    $arr = str_replace("meta", "input", $arr);
    $arr = str_replace("link", "//", $arr);
    $arr = str_replace("script", "//", $arr);
    $arr = str_replace("type", "//", $arr);
    $arr = str_replace("charset", "//", $arr);
    $arr = str_replace("src", "//", $arr);
    $arr = str_replace("href", "//", $arr);
    $arr = str_replace("http", "//", $arr);
    $arr = str_replace("java", "//", $arr);
    $arr = str_replace("media", "//", $arr);
    $arr = str_replace("html", "//", $arr);
    print "<input id=\"title\" value=\"{$title}\">";
    print $arr;  
    ?>

    http://www.php.ru/forum/viewtopic.php?p=258765#258765

    Devzirom, 19 Января 2011

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

    +189

    1. 1
    public function renderHiddenIdentityFieldReturnsAHiddenInputFieldContainingTheObjectsUID()

    ReallyBugMeNot, 18 Января 2011

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