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

    В номинации:
    За время:
  2. Куча / Говнокод #4983

    +16

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    div.field.field-type-filefield.field-field-videofile,
    div.field.field-type-filefield.field-field-videoftp,
    .content .field-field-videofile div.field-items, 
    .content .field-field-videoftp div.field-items,
    .content .field-field-videofile div.field-item, 
    .content .field-field-videoftp div.field-item{clear:both;overflow:hidden;display:block;}
    .field-field-videofile div.field-label-inline-first, 
    .field-field-videofile div.field-label-inline,
    .field-field-videoftp div.field-label-inline-first,
    .field-field-videoftp div.field-label-inline{clear:both;overflow:hidden;display:block;visibility:visible;}

    Вот такой вот css родил. кстате где CSS разметко здеся?

    brainstorm, 19 Декабря 2010

    Комментарии (22)
  3. Си / Говнокод #4905

    +137

    1. 1
    2. 2
    3. 3
    4. 4
    if (MACaddress == 0)
    		MACaddress = pAdapterInfo->Address [5] + pAdapterInfo->Address [4] * 256 + 
    					pAdapterInfo->Address [3] * 256 * 256 + 
    					pAdapterInfo->Address [2] * 256 * 256 * 256;

    xynta, 12 Декабря 2010

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

    −121

    1. 1
    2. 2
    3. 3
    4. 4
    ВнутреннийКодДокумента=Лев(ФайлКаталога.Имя,Найти(ФайлКаталога.Имя,"_")-1);
    ВнутреннийКодДокумента=Формат(Число(ВнутреннийКодДокумента),"ЧЦ=9;ЧВН=");
    ВнутреннийКодДокумента=СтрЗаменить(ВнутреннийКодДокумента," ","");
    СсылкаНаВходящийДокумент=Справочники.ВходящиеДокументы.НайтиПоКоду(ВнутреннийКодДокумента);

    получает имя файла например 122341_20101207201000.pdf и ищет по коду в справочники с лидирующими нулями, если кто то может предложить лучше предложение, то я буду только рад)

    cdpoma, 07 Декабря 2010

    Комментарии (22)
  5. Java / Говнокод #4842

    +85

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    7. 7
    8. 8
    if( str.substring(0,3).equals("110")){
                   //restarting client
                   c.close();
                   Thread.sleep(100);
                   main(args);
                   System.gc();
                   System.exit(1);
               }

    Brutal restart

    maltozzi, 07 Декабря 2010

    Комментарии (22)
  6. PHP / Говнокод #4716

    +161

    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
    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
    $extentions = array('1','2','3','6'); # определяем типы разрешенных файлов
    $Filedatasize = $_FILES['Filedata']['size']; 
    $width = 200; # Максимальная ширина миниатюры
    $height = 160;	# Максимальная высота миниатюры
    $file_type = exif_imagetype($_FILES['Filedata']['tmp_name']); # определяем тип файла
    if (in_array($file_type, $extentions) && ($maxfilesize >= $Filedatasize)){
    	switch ($file_type) {
    		case '2': $file_type = '.jpg'; break;
    		case '3': $file_type = '.png'; break;
    		case '1': $file_type = '.gif'; break;			
    		case '6': $file_type = '.bmp'; break;
    	}
    	if ($_POST['select_catalog'] > 0){
    		mysql_query("INSERT INTO `images` (`id_catalog`) VALUES ('".$_POST['select_catalog']."');") or die("MySQL Error: " . mysql_error());
    	} else {
    		 mysql_query("INSERT INTO `images` (`image_title`) VALUES (' ');") or die("MySQL Error: " . mysql_error());
    	}
    	$image_id = mysql_insert_id();
    	mysql_query("UPDATE `images` SET `image_name_d` = '".$image_id.$file_type."', `image_name_s` = '".$image_id."_m".$file_type."' WHERE `images`.`id_images` = ".$image_id.";") or die("MySQL Error: " . mysql_error());
    	$image_mini = $image_id.'_m'.$file_type;
    	$image_normal = $image_id.$file_type;
    	
    	$ext = $file_type; # Получаем формат уменьшаемого изображения
    	list($width_orig, $height_orig) = getimagesize($_FILES['Filedata']['tmp_name']); # получаем размеры изображения
    	
    	#высчитываем 
    	$ratio_orig = $width_orig/$height_orig;		
    	if ($width/$height > $ratio_orig) {
    		$width = $height*$ratio_orig;
    	} else {
    		$height = $width/$ratio_orig;
    	}
    	$image_p = imagecreatetruecolor($width, $height);
    	switch ($ext) {
    		case '.jpg': $source = imagecreatefromjpeg($_FILES['Filedata']['tmp_name']); break;
    		case '.gif': $source = imagecreatefromgif($_FILES['Filedata']['tmp_name']); break;
    		case '.png': $source = imagecreatefrompng($_FILES['Filedata']['tmp_name']); break;			
    		case '.bmp': $source = imagecreatefromwbmp($_FILES['Filedata']['tmp_name']); break;
    	}
    	imagecopyresampled($image_p, $source, 0, 0, 0, 0, $width, $height, $width_orig, $height_orig);
    	switch ($ext) {
    		case '.jpg': imagejpeg($image_p, 'gallery/'.$image_mini, 100); break;                
    		case '.gif': imagegif($image_p, 'gallery/'.$image_mini);  break;                
    		case '.png': imagepng($image_p, 'gallery/'.$image_mini); break;                
    		case '.bmp': imagewbmp($image_p, 'gallery/'.$image_mini); break;
    	}
    	
    	# освобождаем память
    	imagedestroy($image_p);
    	imagedestroy($source);	
    	if (($width_orig >= 1600) or ($height_orig >= 1200)) {
    		$width = 1600; # Максимальная ширина
    		$height = 1200;	# Максимальная высота
    		$ratio_orig = $width_orig/$height_orig;		
    		if ($width/$height > $ratio_orig) {
    			$width = $height*$ratio_orig;
    		} else {
    			$height = $width/$ratio_orig;
    		}
    		$image_p = imagecreatetruecolor($width, $height);
    		switch ($ext) {
    			case '.jpg': $source = imagecreatefromjpeg($_FILES['Filedata']['tmp_name']); break;
    			case '.gif': $source = imagecreatefromgif($_FILES['Filedata']['tmp_name']); break;
    			case '.png': $source = imagecreatefrompng($_FILES['Filedata']['tmp_name']); break;			
    			case '.bmp': $source = imagecreatefromwbmp($_FILES['Filedata']['tmp_name']); break;
    			}
    		imagecopyresampled($image_p, $source, 0, 0, 0, 0, $width, $height, $width_orig, $height_orig);
    			switch ($ext) {
    				case '.jpg': imagejpeg($image_p, 'gallery/'.$image_normal, 100); break;                
    				case '.gif': imagegif($image_p, 'gallery/'.$image_normal);  break;                
    				case '.png': imagepng($image_p, 'gallery/'.$image_normal); break;                
    				case '.bmp': imagewbmp($image_p, 'gallery/'.$image_normal); break;
    			}
    		
    		# освобождаем память
    		imagedestroy($image_p);
    		imagedestroy($source);
    			
    	} else {
    		move_uploaded_file($_FILES['Filedata']['tmp_name'], 'gallery/'.$image_normal);
    	}
    }	
    chmod('gallery/' . $image_normal, 0777);
    $return['src'] = 'gallery/' . $image_normal;

    ZekMan, 23 Ноября 2010

    Комментарии (22)
  7. PHP / Говнокод #4469

    +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
    // Обторное, свежее, сочнейшие гавнище. Давно такого не встречал.
    
    
    curl_setopt($ch, 42, 1);
    curl_setopt($ch, 47, 1);
    curl_setopt($ch, 43, 1);
    curl_setopt($ch, 41, 0);
    curl_setopt($ch, 52, 0);
    curl_setopt($ch, 81, 0);
    curl_setopt($ch, 64, 0);
    
    if($this->binary) {
           curl_setopt($ch, 19914, 1);
    }

    Вот так нужно задавать настройки cURL. И никакой обфуксации не надо. Суть гавна поймут только истиные ценители.

    j0kz, 27 Октября 2010

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

    +174

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    7. 7
    8. 8
    9. 9
    //коллаж картинок
    $total = 7;
    $i = 1;
    while ($i <= $total)
     {				
    	echo '<div><img src="'.$path.'picture/collage/'.$i.'.jpg" alt="Промышленное оборудование: трубогибы, пресс механический" title="Промышленное оборудование: трубогибы, пресс механический" /></div>'."\n";
    	$i++;
    	if($i > $total) break;
    }

    по моему простенько, но со вкусом :)

    t0xy, 20 Сентября 2010

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

    +167

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    7. 7
    8. 8
    /**
    	* Получение длины строки для utf-8
    	*/
    	public static function strlen($str) {
        	$rus=array('й','ц','у','к','е','н','г','ш','щ','з','х','ъ','ф','ы','в','а','п','р','о','л','д','ж','э','я','ч','с','м','и','т','ь','б','ю',
                   'Й','Ц','У','К','Е','Н','Г','Ш','Щ','З','Х','Ъ','Ф','Ы','В','А','П','Р','О','Л','Д','Ж','Э','Я','Ч','С','М','И','Т','Ь','Б','Ю');
        	return strlen(str_replace($rus,'0',$str));
    	}

    зачем нам всякие (iconv|mb)_strlen ?
    хотя при отсутствии этих библиотек метод интересный

    Morgan, 13 Сентября 2010

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

    +148

    1. 1
    2. 2
    3. 3
    4. 4
    if( !$this->dirsmodel->isExist(array('alias' => $_POST['alias']))) {
        $this->messages[] = 'Такой алиас уже существует';
        return $this->redirect("admin/dirs/#" . $cat_id);
    }

    Говнокод тонкий особый. Кто найдёт получит пиченьку

    DrFreez, 11 Сентября 2010

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

    +150

    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
    <?session_start();
    
    require_once "../Source/connect.php";
    
    require_once "../Models/Comment(class).php"?>
    
    <link rel="stylesheet" href="../Source/style.css" type="text/css" />
    
    <a href="../Forms/Register_form.php">Регистрация</a> <br/><br/>
    
    <form name="login" action="../Controller/Controller.php" method="post">
    
    <input name="login" type="text" value=""> Логин <br/>
    
    <input name="password" type="password" value=""> Пароль <br/>
    
    Введите данные:<br/><br/>
    
    <input name="do" type="submit" value="Войти">
    
    <?session_destroy();?>
    
    </form>
    
    
    
    <?
    
    $comment = new Comm();
    
    	
    
    	$comment->Menu();
    
    	$comment->Coments();
    
    ?>

    Хочется назвать сие творение: "Очень быстрая сессия".
    Это весь код главной страницы простенького сайта-блога. Автор даже не подозревает о существовании тегов <html>, <head> и <body>. Вначале можно было подумать, что он засунул их в один из подключаемых файлов, а нет. Просто не нужны они ему и все.

    SunnyMagadan, 25 Августа 2010

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