ДействиеСценарий / Говнокод #73 Ссылка на оригинал

0

  1. 1
  2. 2
  3. 3
  4. 4
  5. 5
  6. 6
  7. 7
  8. 8
  9. 9
  10. 10
  11. 11
  12. 12
private function _mouseDown(e:MouseEvent):void 
{
	stage.addEventListener(MouseEvent.MOUSE_UP, _mouseUp);
	if (e.target is PCell) {
		//Клик по клетке, но возможно хотят подвигать поле :)
		_startDrag(e);
	}
	else {
		//Значит двигаем поле
		_startDrag(e);
	}
}

guest guest, (Updated )

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

Си диез / Говнокод #72 Ссылка на оригинал

0

  1. 1
  2. 2
  3. 3
  4. 4
  5. 5
  6. 6
  7. 7
  8. 8
  9. 9
  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
private static string identifier(string wmiClass, string wmiProperty)
            {
                string result = "";
                System.Management.ManagementClass mc =
            new System.Management.ManagementClass(wmiClass);
                System.Management.ManagementObjectCollection moc = mc.GetInstances();
                foreach (System.Management.ManagementObject mo in moc)
                {
                    //Only get the first one
                    if (result == "")
                    {
                        try
                        {
                            result = mo[wmiProperty].ToString();
                            break;
                        }
                        catch
                        {
                        }
                    }
                }
                return result;
            }

guest guest, (Updated )

Комментарии (2, +2)

ЙАЖА / Говнокод #71 Ссылка на оригинал

0

  1. 1
  2. 2
  3. 3
  4. 4
  5. 5
  6. 6
  7. 7
  8. 8
  9. 9
  10. 10
  11. 11
  12. 12
  13. 13
  14. 14
  15. 15
  16. 16
  17. 17
  18. 18
  19. 19
private Map<Class<?>, Map<String, String[]>> compressDependencies(
      Map<Class<?>, Map<String, List<String>>> dependencies) {
    final Map<Class<?>, Map<String, String[]>> result =
        new FastMap<Class<?>, Map<String, String[]>>(dependencies.size());
    final Set<Entry<Class<?>, Map<String, List<String>>>> entrySet = dependencies.entrySet();
    for (Entry<Class<?>, Map<String, List<String>>> entry : entrySet) {
      final Map<String, List<String>> value = entry.getValue();
      final Map<String, String[]> desc = new FastMap<String, String[]>(value.size());
      final Set<Entry<String, List<String>>> subEntries = value.entrySet();
      for (Entry<String, List<String>> valueEntry : subEntries) {
        final List<String> list = valueEntry.getValue();
        if (list != null && !list.isEmpty()) {
          desc.put(valueEntry.getKey(), list.toArray(new String[list.size()]));
        }
      }
      result.put(entry.getKey(), desc);
    }
    return result;
  }

Код от "мега разработчика", архитектора очень большого проекта.

PS Будьте осторожны в использовании java generics :)

guest guest, (Updated )

Комментарии (8, +8)

ЙажаСценарий / Говнокод #70 Ссылка на оригинал

0

  1. 1
  2. 2
  3. 3
  4. 4
  5. 5
  6. 6
  7. 7
  8. 8
<script>
function changeLogo(imgLoc){
    document.getElementById("module_logo").src = "./site/" + imgLoc + "_logo.jpg";
}
function returnLogo(imgLoc){
    document.getElementById("module_logo").src = "./site/" + imgLoc + "_logo.jpg";
}
</script>

guest guest, (Updated )

Комментарии (5, +5)

"PHP" / Говнокод #69 Ссылка на оригинал

0

  1. 1
  2. 2
  3. 3
  4. 4
  5. 5
  6. 6
  7. 7
  8. 8
  9. 9
  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
  65. 65
  66. 66
  67. 67
  68. 68
  69. 69
  70. 70
  71. 71
  72. 72
  73. 73
  74. 74
  75. 75
  76. 76
  77. 77
  78. 78
  79. 79
  80. 80
  81. 81
  82. 82
  83. 83
  84. 84
  85. 85
  86. 86
  87. 87
  88. 88
  89. 89
  90. 90
  91. 91
  92. 92
  93. 93
  94. 94
  95. 95
  96. 96
  97. 97
  98. 98
  99. 99
  100. 100
$cResult = mysql_query($cQuery) or die(mysql_error());
if (mysql_num_rows($cResult) <= 0)
{
	if ( $_GET['extra'] == "a" || $_GET['extra'] == 4 || $_GET['extra'] == 16 || $_GET['extra'] == "n" || $_GET['extra'] == "m" || $_GET['extra'] == "m_in_cat" )
		{}
	else
		{
		echo CAT_NO_WALP;
		}
} else
{
	$Row = mysql_fetch_object($cResult);
	$id = $Row->id;

	if ( $_GET['extra'] == "a" )
		{
		$result = mysql_query("SELECT * FROM `Wallpapers` WHERE `approved` = '0' ORDER BY `ID` DESC LIMIT ".$page*$picsperpage.",$picsperpage");
		$myresult = mysql_query("SELECT * FROM `Wallpapers` WHERE `approved` = '0' ORDER BY `ID` DESC LIMIT ".$page*$picsperpage.",$picsperpage");
		$countresult = mysql_query("SELECT * FROM `Wallpapers` WHERE `approved` = '0' ORDER BY `ID` DESC");
		}
	elseif ( $_GET['extra'] == 4 )
		{
		$result = mysql_query("SELECT * FROM `Wallpapers` WHERE `approved` = '0' AND `four_three` = '1' ORDER BY `ID` DESC LIMIT ".$page*$picsperpage.",$picsperpage");
		$myresult = mysql_query("SELECT * FROM `Wallpapers` WHERE `approved` = '0' AND `four_three` = '1' ORDER BY `ID` DESC LIMIT ".$page*$picsperpage.",$picsperpage");
		$countresult = mysql_query("SELECT * FROM `Wallpapers` WHERE `approved` = '0' AND `four_three` = '1' ORDER BY `ID` DESC");
		}
	elseif ( $_GET['extra'] == 16 )
		{
		$result = mysql_query("SELECT * FROM `Wallpapers` WHERE `approved` = '0' AND `sixteen_ten` = '1' ORDER BY `ID` DESC LIMIT ".$page*$picsperpage.",$picsperpage");
		$myresult = mysql_query("SELECT * FROM `Wallpapers` WHERE `approved` = '0' AND `sixteen_ten` = '1' ORDER BY `ID` DESC LIMIT ".$page*$picsperpage.",$picsperpage");
		$countresult = mysql_query("SELECT * FROM `Wallpapers` WHERE `approved` = '0' AND `sixteen_ten` = '1' ORDER BY `ID` DESC");
		}
	elseif ( $_GET['extra'] == "n" )
		{
		$result = mysql_query("SELECT * FROM `Wallpapers` WHERE `approved` = '0' AND `status_NEW` = '1' ORDER BY `ID` DESC LIMIT ".$page*$picsperpage.",$picsperpage");
		$myresult = mysql_query("SELECT * FROM `Wallpapers` WHERE `approved` = '0' AND `status_NEW` = '1' ORDER BY `ID` DESC LIMIT ".$page*$picsperpage.",$picsperpage");
		$countresult = mysql_query("SELECT * FROM `Wallpapers` WHERE `approved` = '0' AND `status_NEW` = '1' ORDER BY `ID` DESC");
		}
	elseif ( $_GET['extra'] == "m" )
		{
		$result = mysql_query("SELECT * FROM `Wallpapers` WHERE `approved` = '0' AND `poster` = '".$_SESSION['userid']."' ORDER BY `ID` DESC LIMIT ".$page*$picsperpage.",$picsperpage");
		$myresult = mysql_query("SELECT * FROM `Wallpapers` WHERE `approved` = '0' AND `poster` = '".$_SESSION['userid']."' ORDER BY `ID` DESC LIMIT ".$page*$picsperpage.",$picsperpage");
		$countresult = mysql_query("SELECT * FROM `Wallpapers` WHERE `approved` = '0' AND `poster` = '".$_SESSION['userid']."' ORDER BY `ID` DESC");
		}
	elseif ( $_GET['extra'] == "m_in_cat" )
		{
		$result = mysql_query("SELECT * FROM `Wallpapers` WHERE `approved` = '0' AND `poster` = '".$_SESSION['userid']."' AND Category = '".$result_needed['id']."' ORDER BY `ID` DESC LIMIT ".$page*$picsperpage.",$picsperpage");
		$myresult = mysql_query("SELECT * FROM `Wallpapers` WHERE `approved` = '0' AND `poster` = '".$_SESSION['userid']."' AND Category = '".$result_needed['id']."' ORDER BY `ID` DESC LIMIT ".$page*$picsperpage.",$picsperpage");
		$countresult = mysql_query("SELECT * FROM `Wallpapers` WHERE `approved` = '0' AND `poster` = '".$_SESSION['userid']."' AND Category = '".$result_needed['id']."' ORDER BY `ID` DESC");
		}
	else
		{
		$result = mysql_query("SELECT * FROM `Wallpapers` WHERE `approved` = '0' AND `Category` = '".$id."' OR `Category` IN (SELECT `id` FROM `Categories` WHERE `Parent` = '".$id."') ORDER BY `ID` DESC LIMIT ".$page*$picsperpage.",$picsperpage");   ///-------------
		$myresult = mysql_query("SELECT * FROM `Wallpapers` WHERE `approved` = '0' AND `Category` = '".$id."' OR `Category` IN (SELECT `id` FROM `Categories` WHERE `Parent` = '".$id."') ORDER BY `ID` DESC LIMIT ".$page*$picsperpage.",$picsperpage");
		$countresult = mysql_query("SELECT * FROM `Wallpapers` WHERE `approved` = '0' AND `Category` = '".$id."' OR `Category` IN (SELECT `id` FROM `Categories` WHERE `Parent` = '".$id."') ORDER BY `ID` DESC");
		}

	if ( $_GET['extra'] == "a" && $_SESSION['usergroupid'] > 3 )
		{
		$result = mysql_query("SELECT * FROM `Wallpapers` ORDER BY `ID` DESC LIMIT ".$page*$picsperpage.",$picsperpage");
		$myresult = mysql_query("SELECT * FROM `Wallpapers` ORDER BY `ID` DESC LIMIT ".$page*$picsperpage.",$picsperpage");
		$countresult = mysql_query("SELECT * FROM `Wallpapers` ORDER BY `ID` DESC");
		}
	elseif ( $_GET['extra'] == 4 && $_SESSION['usergroupid'] > 3 )
		{
		$result = mysql_query("SELECT * FROM `Wallpapers` WHERE `four_three` = '1' ORDER BY `ID` DESC LIMIT ".$page*$picsperpage.",$picsperpage");
		$myresult = mysql_query("SELECT * FROM `Wallpapers` WHERE `four_three` = '1' ORDER BY `ID` DESC LIMIT ".$page*$picsperpage.",$picsperpage");
		$countresult = mysql_query("SELECT * FROM `Wallpapers` WHERE `four_three` = '1' ORDER BY `ID` DESC");
		}
	elseif ( $_GET['extra'] == 16 && $_SESSION['usergroupid'] > 3 )
		{
		$result = mysql_query("SELECT * FROM `Wallpapers` WHERE `sixteen_ten` = '1' ORDER BY `ID` DESC LIMIT ".$page*$picsperpage.",$picsperpage");
		$myresult = mysql_query("SELECT * FROM `Wallpapers` WHERE `sixteen_ten` = '1' ORDER BY `ID` DESC LIMIT ".$page*$picsperpage.",$picsperpage");
		$countresult = mysql_query("SELECT * FROM `Wallpapers` WHERE `sixteen_ten` = '1' ORDER BY `ID` DESC");
		}
	elseif ( $_GET['extra'] == "n" && $_SESSION['usergroupid'] > 3 )
		{
		$result = mysql_query("SELECT * FROM `Wallpapers` WHERE `status_NEW` = '1' ORDER BY `ID` DESC LIMIT ".$page*$picsperpage.",$picsperpage");
		$myresult = mysql_query("SELECT * FROM `Wallpapers` WHERE `status_NEW` = '1' ORDER BY `ID` DESC LIMIT ".$page*$picsperpage.",$picsperpage");
		$countresult = mysql_query("SELECT * FROM `Wallpapers` WHERE `status_NEW` = '1' ORDER BY `ID` DESC");
		}
	elseif ( $_GET['extra'] == "m" && $_SESSION['usergroupid'] > 3 )
		{
		$result = mysql_query("SELECT * FROM `Wallpapers` WHERE `poster` = '".$_SESSION['userid']."' ORDER BY `ID` DESC LIMIT ".$page*$picsperpage.",$picsperpage");
		$myresult = mysql_query("SELECT * FROM `Wallpapers` WHERE `poster` = '".$_SESSION['userid']."' ORDER BY `ID` DESC LIMIT ".$page*$picsperpage.",$picsperpage");
		$countresult = mysql_query("SELECT * FROM `Wallpapers` WHERE `poster` = '".$_SESSION['userid']."' ORDER BY `ID` DESC");
		}
	elseif ( $_GET['extra'] == "m_in_cat" && $_SESSION['usergroupid'] > 3 )
		{
		$result = mysql_query("SELECT * FROM `Wallpapers` WHERE `poster` = '".$_SESSION['userid']."' AND Category = '".$result_needed['id']."' ORDER BY `ID` DESC LIMIT ".$page*$picsperpage.",$picsperpage");
		$myresult = mysql_query("SELECT * FROM `Wallpapers` WHERE `poster` = '".$_SESSION['userid']."' AND Category = '".$result_needed['id']."' ORDER BY `ID` DESC LIMIT ".$page*$picsperpage.",$picsperpage");
		$countresult = mysql_query("SELECT * FROM `Wallpapers` WHERE `poster` = '".$_SESSION['userid']."' AND Category = '".$result_needed['id']."' ORDER BY `ID` DESC");
		}
	elseif ( $_SESSION['usergroupid'] > 3	elseif ( $_SESSION['usergroupid'] > 3 )
		{
		$result = mysql_query("SELECT * FROM `Wallpapers` WHERE `Category` = '".$id."' OR `Category` IN (SELECT `id` FROM `Categories` WHERE `Parent` = '".$id."') ORDER BY `ID` DESC LIMIT ".$page*$picsperpage.",$picsperpage");   ///-------------
		$myresult = mysql_query("SELECT * FROM `Wallpapers` WHERE `Category` = '".$id."' OR `Category` IN (SELECT `id` FROM `Categories` WHERE `Parent` = '".$id."') ORDER BY `ID` DESC LIMIT ".$page*$picsperpage.",$picsperpage");
		$countresult = mysql_query("SELECT * FROM `Wallpapers` WHERE `Category` = '".$id."' OR `Category` IN (SELECT `id` FROM `Categories` WHERE `Parent` = '".$id."') ORDER BY `ID` DESC");
// И еще примерно столько же подобного говнеца. Сюда просто не влазит...
	}

Пустые ифы, куча лишних запросов.
Очень яркий пример ИНДУСтриального программирования.

guest guest, (Updated )

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

"PHP" / Говнокод #68 Ссылка на оригинал

0

  1. 1
  2. 2
  3. 3
  4. 4
  5. 5
  6. 6
  7. 7
  8. 8
  9. 9
  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
$result = mysql_query("SELECT * FROM `Wallpapers` WHERE `Title` = '".$Title."'");
$row = mysql_fetch_assoc($result);
$wID=$row['ID'];
$Wallpaper1=$row['Wallpaper1'];
$Wallpaper2=$row['Wallpaper2'];
$Wallpaper3=$row['Wallpaper3'];
$Wallpaper4=$row['Wallpaper4'];
$Wallpaper5=$row['Wallpaper5'];

if ( $_SESSION['userid'] )
	{ 
	if ($Wallpaper1 != NULL) {
		$size='';
		$size=getimagesize("images/wallpapers/".$Wallpaper1);
		$dHTML .= '<a class="preview" href="'.$image_path.'show/'.$Title.'/?w=1" style="text-decoration: underline;" onClick="alerts('.$wID.'); countIp();">'.$size[0].'x'.$size[1].'</a> ';
	}
	if ($Wallpaper2 != NULL) {
		$size='';
		$size=getimagesize("images/wallpapers/".$Wallpaper2);
		$dHTML .= '<a class="preview" href="'.$image_path.'show/'.$Title.'/?w=2" style="text-decoration: underline;" onClick="alerts('.$wID.'); countIp();">'.$size[0].'x'.$size[1].'</a> ';
	}
	if ($Wallpaper3 != NULL) {
		$size='';
		$size=getimagesize("images/wallpapers/".$Wallpaper3);
		$dHTML .= '<a class="preview" href="'.$image_path.'show/'.$Title.'/?w=3" style="text-decoration: underline;" onClick="alerts('.$wID.'); countIp();">'.$size[0].'x'.$size[1].'</a> ';
	}
	if ($Wallpaper4 != NULL) {
		$size='';
		$size=getimagesize("images/wallpapers/".$Wallpaper4);
		$dHTML .= '<a class="preview" href="'.$image_path.'show/'.$Title.'/?w=4" style="text-decoration: underline;" onClick="alerts('.$wID.'); countIp();">'.$size[0].'x'.$size[1].'</a> ';
	}
	if ($Wallpaper5 != NULL) {
		$size='';
		$size=getimagesize("images/wallpapers/".$Wallpaper5);
		$dHTML .= '<a class="preview" href="'.$image_path.'show/'.$Title.'/?w=5" style="text-decoration: underline;" onClick="alerts('.$wID.'); countIp();">'.$size[0].'x'.$size[1].'</a> ';
	}
	}

guest guest, (Updated )

Комментарии (4, +4)

"PHP" / Говнокод #67 Ссылка на оригинал

0

  1. 1
  2. 2
  3. 3
  4. 4
  5. 5
  6. 6
  7. 7
$find = str_replace(",", "", $find);
$find = str_replace(".", "", $find);
$find = str_replace("/", "", $find);
$find = str_replace(" ", "", $find);
$find = str_replace("-", "", $find);
$find = str_replace("+", "", $find);
$find = str_replace("#", "", $find);

Регулярные выражения =)

guest guest, (Updated )

Комментарии (24, +24)

"PHP" / Говнокод #66 Ссылка на оригинал

0

  1. 1
  2. 2
  3. 3
  4. 4
  5. 5
  6. 6
  7. 7
  8. 8
  9. 9
  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
function PagerStarter( $object_id, $object_url, $dbt, $maxwidth, $edittime, $level_step, $comments_per_page )
{
	if ( $_GET['from'] ) { $from = $_GET['from']; }
	if ( $_POST['from'] ) { $from = $_POST['from']; }
	if ( $_GET['current_page'] ) { $current_page = $_GET['current_page']; }
	if ( $_POST['current_page'] ) { $current_page = $_POST['current_page']; }
	if ( ( empty( $current_page ) == TRUE ) && ( empty( $from ) == TRUE ) )
		{
		$r = mysql_query( "SELECT * FROM ".$dbt." WHERE parent = '1' AND parent_image = '$object_id'".$e."" );
		$r_count = mysql_num_rows ( $r );
		$total_pages = 0;
		$i = 0;
		while ( $i < $r_count )
			{
			$total_pages = $total_pages + 1;
			$i = $i + $comments_per_page;
			}
		if ( $total_pages == 0 )
			{
			$total_pages = 1;
			}
		for ( $i = 1 ; $i <= $total_pages ; $i++ )
			{
			$from_q = ( $i * $comments_per_page ) - $comments_per_page + 0;
			}
		$_GET['current_page'] = $total_pages;
		$_GET['from'] = $from_q;
		}
}

Особого внимания заслуживает деление сложением. Хотя тут еще достаточно говна :)

guest guest, (Updated )

Комментарии (12, +12)

Няшная / Говнокод #65 Ссылка на оригинал

0

  1. 1
  2. 2
  3. 3
  4. 4
  5. 5
  6. 6
  7. 7
  8. 8
  9. 9
  10. 10
@interface GUIColor
{
  int palete,color;
}

+ (GUIColor *) initColor: (int) palete: (int) r:(int) g:(int) b;
- free;

- (int) getPalete;
- (int) get

на самом деле Objective-C добавьте в список
начал писать класс,потом задумался что же я делаю

guest guest, (Updated )

Комментарии (15, +15)