- 1
- 2
- 3
- 4
- 5
SELECT FROM Staff
CASE Sex
WHEN 'M' THEN 'МужЫк!'
WHEN 'F' THEN 'Баба'
ELSE 'ЫЫЫыы?'
Нашли или выдавили из себя код, который нельзя назвать нормальным, на который без улыбки не взглянешь? Не торопитесь его удалять или рефакторить, — запостите его на говнокод.ру, посмеёмся вместе!
−417.7
SELECT FROM Staff
CASE Sex
WHEN 'M' THEN 'МужЫк!'
WHEN 'F' THEN 'Баба'
ELSE 'ЫЫЫыы?'
препод сказал что елсе не будет выполняться изза ограничений целостности базы
−599.6
private function _mouseDown(e:MouseEvent):void
{
stage.addEventListener(MouseEvent.MOUSE_UP, _mouseUp);
if (e.target is PCell) {
//Клик по клетке, но возможно хотят подвигать поле :)
_startDrag(e);
}
else {
//Значит двигаем поле
_startDrag(e);
}
}
+30
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;
}
−43.8
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 :)
+33.5
<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>
+30.6
$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");
// И еще примерно столько же подобного говнеца. Сюда просто не влазит...
}
Пустые ифы, куча лишних запросов.
Очень яркий пример ИНДУСтриального программирования.
+22.9
$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> ';
}
}
+50.8
$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);
Регулярные выражения =)
+46
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;
}
}
Особого внимания заслуживает деление сложением. Хотя тут еще достаточно говна :)
+24
@interface GUIColor
{
int palete,color;
}
+ (GUIColor *) initColor: (int) palete: (int) r:(int) g:(int) b;
- free;
- (int) getPalete;
- (int) get
на самом деле Objective-C добавьте в список
начал писать класс,потом задумался что же я делаю