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

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

    +144

    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
    function constructor(){
    		parent::XXXModule();
    		if (!class_exists('XXXSU'))
    			require_once(join_path(dirname(__FILE__), 'classes', 'class.XXXSU.php'));
    			
    		if (!class_exists('XXXSUsRouter'))
    			require_once(join_path(dirname(__FILE__), 'classes', 'class.XXXSUsRouter.php'));
    			
    		if (!class_exists('XXXSUFingerprint'))
    			require_once(join_path(dirname(__FILE__), 'classes', 'class.XXXSUFingerprint.php'));
    			
    		if (!class_exists('XXXSUDao'))
    			require_once(join_path(dirname(__FILE__), 'classes', 'class.XXXSUDao.php'));
    			
    		if (!class_exists('XXXSUCategory'))
    			require_once(join_path(dirname(__FILE__), 'classes', 'class.XXXSUCategory.php'));
    		if (!class_exists('XXXSUsLocale'))
    			require_once(join_path(dirname(__FILE__), 'classes', 'class.XXXSUsLocale.php'));
    			
    		if (!class_exists('XXXSUsHelper'))
    			require_once(join_path(dirname(__FILE__), 'classes', 'class.XXXSUsHelper.php'));
    			
    		if (!class_exists('XXXSUsEmailTemplate'))
    			require_once(join_path(dirname(__FILE__), 'classes', 'class.XXXSUsEmailTemplate.php'));
    		if (!class_exists('XXXSUsEmailTemplatesDao'))
    			require_once(join_path(dirname(__FILE__), 'classes', 'class.XXXSUsEmailTemplatesDao.php'));
    	}

    конструктор класса - после некоторой маскировки имен(constructor,XXX,SU,join_path).

    Писал javист, волею судеб, но против своей, пересевший на ненавистный php

    функция join_path - не его, а из некоторого говновелосипеда.

    Lure Of Chaos, 23 Августа 2010

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

    +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
    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
    function lowcase($string)
    
               {
    
               $string = ereg_replace('A',"a",$string);
    
               $string = ereg_replace('B',"b",$string);
    
               $string = ereg_replace('C',"c",$string);
    
               $string = ereg_replace('D',"d",$string);
    
               $string = ereg_replace('E',"e",$string);
    
               $string = ereg_replace('F',"f",$string);
    
               $string = ereg_replace('G',"g",$string);
    
               $string = ereg_replace('H',"h",$string);
    
               $string = ereg_replace('I',"i",$string);
    
               $string = ereg_replace('J',"j",$string);
    
               $string = ereg_replace('K',"k",$string);
    
               $string = ereg_replace('L',"l",$string);
    
               $string = ereg_replace('M',"m",$string);
    
               $string = ereg_replace('N',"n",$string);
    
               $string = ereg_replace('O',"o",$string);
    
               $string = ereg_replace('P',"p",$string);
    
               $string = ereg_replace('Q',"q",$string);
    
               $string = ereg_replace('R',"r",$string);
    
               $string = ereg_replace('S',"s",$string);
    
               $string = ereg_replace('T',"t",$string);
    
               $string = ereg_replace('U',"u",$string);
    
               $string = ereg_replace('V',"v",$string);
    
               $string = ereg_replace('W',"w",$string);
    
               $string = ereg_replace('X',"x",$string);
    
               $string = ereg_replace('Y',"y",$string);
    
               $string = ereg_replace('Z',"z",$string);
    
               return ($string);
    
               }

    перевод в нижний регистр:) все в том же движке. Конечно автор не догадывался что в пхп есть функция strtolower(). Ну и работает конечно раз в 1000 быстрее его функции...

    moonie, 21 Августа 2010

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

    +167

    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
    if($pass == $pswd)
    {
    //Выполнение запросов...
    }
    else
    {
    header('location: ./index.html');
    if(empty($pass))
    {
    header('location: ./index.html');
    }
    if(empty($pswd))
    {
    header('location: ./index.html');
    }
    if(empty($pass) && empty($pswd))
    {
    header('location: ./index.html');
    }
    if(empty($login) or empty($pswd))
    {
    header('location: ./index.html');
    }
    }
    //Код вывода формы.

    MoLe-X, 16 Августа 2010

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

    +178

    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
    function filerazr ( $file )
    	{
    		$r=false;
    		$rp=false;
    		$w=false;
    		$wp=false;
    		$a=false;
    		$ap=false;
    		$b=false;
    		$x=false;
    		$xp=false;
    		$t=false;
    		//proverka kakie prava est
    		$r=@fopen($file, "r");
    		$rp=@fopen($file, "r+");
    		$w=@fopen($file, "w");
    		$wp=@fopen($file, "w+");
    		$a=@fopen($file, "a");
    		$ap=@fopen($file, "a+");
    		$b=@fopen($file, "b");
    		$x=@fopen($file, "x");
    		$xp=@fopen($file, "x+");
    		$t=@fopen($file, "t");
    		//proverka na ne false
    		if($r!=false) $r=true;
    		if($rp!=false) $rp=true;
    		if($w!=false) $w=true;
    		if($wp!=false) $wp=true;
    		if($a!=false) $a=true;
    		if($ap!=false) $ap=true;
    		if($b!=false) $b=true;
    		if($x!=false) $x=true;
    		if($xp!=false) $xp=true;
    		if($t!=false) $t=true;
    		//esli faila netu to -1
    		$file_e=file_exists($file);
    		if(!$file_e) return -1;
    		if($r&&$rp&&!$w&&!$wp&&!$a&&!$ap&&!$b&&!$t)
    		{
    		return 0;	
    		}
    		if($r&&$rp&&!$w&&!$wp&&!$a&&!$ap&&$b&&$t)
    		{
    		return 1;	
    		}
    		if($r&&$rp&&!$w&&!$wp&&$a&&$ap&&$b&&$t)
    		{
    		return 2;	
    		}
    		if($r&&$rp&&$w&&$wp&&$a&&$ap&&$b&&$t&&$x&&$xp)
    		{
    		return 3;	
    		}
    		@fclose($r);
    		@fclose($rp);
    		@fclose($w);
    		@fclose($wp);
    		@fclose($a);
    		@fclose($ap);
    		@fclose($b);
    		@fclose($x);
    		@fclose($xp);
    		@fclose($t);
    	}

    Что это? Извращённый способ узнать права на файл? Не пойму. И что такое fopen($file, "t") и fopen($file, "b") ? Что нужно выкурить для того чтобы так писать!?

    XyHb, 12 Августа 2010

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

    +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
    <h4 class="red">Security</h4>
    <p>This is to stop automated scripts completing the form at random.</p>
    <div class="applysection">
    	<table>
    		<tr>
    			<td>&nbsp;</td>
    			<td>&nbsp;</td>
    			<td width="40%">&nbsp;</td>
    		</tr>
    		<tr>
    			<th>What is the total <br />
    		    of 4 plus 4?</th>
    			<td><input type="text" id="Human" name="Human" class="required" /></td>
    			<td class="helptext">please answer numerically. i.e.: 6 or 3 etc.</td>
    		</tr>
    		<tr>
    			<td>&nbsp;</td>
    			<td>&nbsp;</td>
    			<td width="40%">&nbsp;</td>
    		</tr>
    	</table>
    </div>
    
    ......... и где-то в недрах подключаемого JS проверяем.....
    
    function isValidHuman(sHuman) { return sHuman == 8 }

    КАПЧА!!!!
    сейчас мы это уже исправили так что без ссылки, но локально осталось это произведение.

    Alfred, 12 Августа 2010

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

    +151

    1. 1
    2. 2
    3. 3
    public function GetCurrentCultureID(){
    		return 1;
    	}

    ой как лень дописывать поддержку мультиязычность в устаревшие модули....

    nur, 04 Августа 2010

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

    +144

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    7. 7
    $true = true;
    function true(){
    while($true){
    if($true)
    return "true";
    }
    }

    ДЭМАНСТРАЦИ ГАВНАКОДА

    art543484, 02 Августа 2010

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

    +63

    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
    <p>
    <strong>
    <strong><strong>
    <strong><strong><strong>
    <strong><strong><strong><strong>
    <strong>.... ещё пара сотен открывающихся <strong> ....<strong>
    <strong>24.07.2010 - <a href="http://www.korea-dpr.com/ocn"><span class="style34">OCN Articles</span></a> added !<br> </strong></strong>
    </strong></strong></strong></strong></strong></strong> 
    ... ещё пара сотен закрывающихся </strong>...
    </strong></strong></strong></strong>
    </strong></strong></strong>
    </strong></strong>
    </strong>
    </p>

    Исходный код официальной страницы КНДР - http://www.korea-dpr.com. Именования стилей "style-какие-то две цифры" прилагаются. Безумный хтмл и прочая тёмная сторона силы.

    Rsk, 29 Июля 2010

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

    +124

    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
    <?php
    //вот это наверное самый тупой вывод случаных ссылок из бд
    $zap="select * from stat";$zap=mysql_query($zap);$zap=mysql_num_rows($zap);$id=rand($zap-5,-1);
    $query="select * from stat where (id=$id)";$result=mysql_query($query);$r=mysql_fetch_array($result);$dop=$r[name];$inc=$r[inc];$inc = explode("<|>", $inc);$name=$inc[0];//первая ссылка
    $query="select * from stat where (id=$id+1)";$result=mysql_query($query);$r=mysql_fetch_array($result);$dop2=$r[name];$inc=$r[inc];$inc = explode("<|>", $inc);$name2=$inc[0];//Вторая ссылка
    $query="select * from stat where (id=$id+2)";$result=mysql_query($query);$r=mysql_fetch_array($result);$dop3=$r[name];$inc=$r[inc];$inc = explode("<|>", $inc);$name3=$inc[0];//третья ссылка
    $query="select * from stat where (id=$id+3)";$result=mysql_query($query);$r=mysql_fetch_array($result);$dop4=$r[name];$inc=$r[inc];$inc = explode("<|>", $inc);$name4=$inc[0];//четвертая  ссылка
    $query="select * from stat where (id=$id+4)";$result=mysql_query($query);$r=mysql_fetch_array($result);$dop5=$r[name];$inc=$r[inc];$inc = explode("<|>", $inc);$name5=$inc[0];//пятая ссылка
    ?>
    <a href="<?php echo ("$nhost/stat/$dop/");?>"><?php echo ("$name");?></a>
    <a href="<?php echo ("$nhost/stat/$dop2/");?>"><?php echo ("$name2");?></a>
    <a href="<?php echo ("$nhost/stat/$dop3/");?>"><?php echo ("$name3");?></a>
    <a href="<?php echo ("$nhost/stat/$dop4/");?>"><?php echo ("$name4");?></a> 
    <a href="<?php echo ("$nhost/stat/$dop5/");?>"><?php echo ("$name5");?></a>
    </b>
    <div  class="artif" ></div>

    Vasiliy, 29 Июля 2010

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

    +152

    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
    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
    #include <stdio.h>
    #include <stdlib.h>
    #include <string.h>
    template<typename T> class myVector {
    private:
    	T* data; // Указатель на массив с данными
    	int count; //Кол-во элементов в векторе
    	T maxv, minv; // Максимальный и минимальный элементы
    	void quicksort(T a[], const int& leftarg, const int& rightarg) const // Сортировочка
    	{
    		if (leftarg < rightarg) {
    			T pivotvalue = a[leftarg];
    			int left = leftarg - 1;
    			int right = rightarg + 1;
    			for(;;) {
    
    				while (a[--right] > pivotvalue);
    				while (a[++left] < pivotvalue);
    				if (left >= right) break;
    				T temp = a[right];
    				a[right] = a[left];
    				a[left] = temp;
    			}
    			int pivot = right;
    			quicksort(a, leftarg, pivot);
    			quicksort(a, pivot + 1, rightarg);
    		}
    	}
    public:
    	myVector() : count(0), data(0), maxv(0), minv(0) // Я хз какие дефолтные значения задавать maxv и minv
    	{
    	}
    	~myVector() //Деструктор
    	{
    		if (data)
    			delete [] data;
    	}
    	void operator<<(const T &Value) //Оператор для добавления элемента в вектор
    	{
    		data = (T*)realloc(data, ++count * sizeof(T));
    		data[count-1] = Value;
    		if (maxv < Value) // Чтобы не искать максимальный и минимальный элемент, чекаем значение при добавлении в массив
    			maxv = Value;
    		else 
    			if (minv > Value)
    				minv = Value;
    	}
    	T& operator[](const int &Index)//Оператор [] для доступа по индексу
    	{
    		if (Index >= count) throw 1;
    		return data[Index];
    	}
    	void orderAsc(T *result) const //Сортировка по возрастанию
    	{
    		if (!data) throw 1;
    		memcpy(result, data, sizeof(T) * count);
    		quicksort(result, 0, count - 1);
    	}
    	void orderDesc(T *result) const
    	{
    		if (!data) throw 1;
    		memcpy(result, data, sizeof(T) * count);
    		quicksort(result, 0, count - 1);
    		int swap, b = count;
    		for(int a = 0; a < --b; a++) {
    			swap = result[a];  result[a] = result[b]; result[b] = swap; 
    		}
    	}
    	T max() const
    	{
    		if (!data) throw 1;
    		return maxv;
    	}
    	T min() const
    	{
    		if (!data) throw 1;
    		return minv;
    	}
    };
    int main()
    {
    	myVector<int> v;
    	for (int i = 0; i < 10; i++)
    		v << rand() % 100; // Заполняем рандомными элементами
    	for (int i = 0; i < 10; i++)
    		printf("%d ", v[i]); // Выводим их
    	printf("\n");
    	int *arr = new int[10];
    	v.orderAsc(arr); //Сортируем по возрастанию
    	for (int i = 0; i < 10; i++)
    		printf("%d ", *(arr + i)); //Выводим результат
    	printf("\n");
    	v.orderDesc(arr); //Сортируем по убыванию
    	for (int i = 0; i < 10; i++)
    		printf("%d ", *(arr + i));//Выводим результат
    	printf("\n%d\n%d", v.max(), v.min()); //Выводим максимальный и минимальный элементы
    	delete [] arr;
    }

    Типа вот внезапно так захотелось создать простейший класс вектора. До STL-ного далеко

    JC_NVKZ, 20 Июля 2010

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