1. PHP / Говнокод #7884

    +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
    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
    // Функция создания списка страниц типа << < 1 2 3 > >>
    function PageBar($adsNum, $nowPage, $currUrl){
    
    	$maxpageinHalf = intval (MAX_PAGEIN / 2);
    	$maxpagein = MAX_PAGEIN;
    	$maxresults = MAX_RESULTS;
    	$pn=($adsNum%MAX_RESULTS!=0);
    	$pageNum = intval($adsNum / $maxresults) + $pn;
    	$pageNum==0?$pageNum=1:"";
    	
    	if ($nowPage < $maxpageinHalf ){ // определение первой половины списка страниц.
    	 $minPage = 0;
    	 $maxPage = $maxpagein;
    	 ($maxPage>$pageNum)?$maxPage=$pageNum:"";
    	 $previous10Page = 0;
    	 $next10Page = $nowPage + $maxpagein;
    	}
    		elseif ($nowPage > $pageNum - $maxpageinHalf) {
    		 $maxPage = $pageNum;
    		 $minPage = $pageNum - $maxpagein;
    		 ($minPage<=0)?$minPage=0:"";
    		 $previous10Page = $nowPage - $maxpageinHalf;
    		 $next10Page = $pageNum;
    		}
    	else {
    	 $minPage = $nowPage - $maxpageinHalf;
    	 $maxPage = $nowPage + $maxpageinHalf;
    	 $previous10Page = $nowPage - $maxpagein;
    	 $next10Page = $nowPage + $maxpagein;
    	}
    	
    	$next10Page >= $pageNum? $next10Page = $pageNum-1:"";	
    
    	$listing = "<a href='p0,a,".$currUrl."' title=\"В начало\" class=\"ads-link1\">|<<</a>&nbsp;&nbsp;";
    	$listing .= "<a href='p$previous10Page,a,".$currUrl."' title=\"Предыдущие $maxpagein страниц\" class=\"ads-link1\"><</a>&nbsp;&nbsp;";
    
    	for ( $i = $minPage; $i < $maxPage; $i++) {
    		if ( $i == $nowPage )
    			$listing .= "<span style=\"font-size:16px; color:red;\">".($i+1)."</span>&nbsp;";
    		else
    			$listing .= "<a href=\"p".$i.",a,".$currUrl."\" title=\"Страница ".($i+1)."/$pageNum\" class=\"ads-link1\">".($i+1)."</a>&nbsp;";
    			
    		
    	}
    
    	$listing .= "&nbsp;&nbsp;<a href='p".($next10Page).",a,".$currUrl."' title=\"Следующие $maxpagein страниц\" class=\"ads-link1\">></a>&nbsp;&nbsp;";
    	$listing .= "<a href='p".($pageNum-1).",a,".$currUrl."' title=\"В конец\" class=\"ads-link1\">>>|</a>";
    
    return $listing;
    }

    Два дня ебался, но чувствую, что здесь что-то не то :D

    Alkonost, 17 Сентября 2011

    Комментарии (13)
  2. C# / Говнокод #7883

    +956

    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
    private void SetDisplay(string Group)
    {
           string taxInt = "144";
           switch (Group.ToLower())
           {
                  case "bond":
                         taxInt = "141";
                         ..............
                         break;
                  case "commodity":
                         taxInt = "329";
                         ..............
                         break;
                  case "emarkets":
                         taxInt = "142";
                         ..............
                         break;
                  default:
                         taxInt = "144";
                         ..............
                         break;
           }
           SetItems(taxInt);
    }
    
    public void SetItems(string taxInt)
    {
           Trace.Write(taxInt);
           int number;
           bool result = Int32.TryParse(taxInt, out number);
           if (result)
           {
                  tid = number;
           }
           else
           {
                  tid = 144;
                  this.lbHard.Style.Add("color", "#000");
           }
           Trace.Write(tid.ToString());
           if (tid > 0)
           {
                   ..............
            }
           else
           {
                   //здесь было пусто
           }
    }

    Лишний код удалён, оставлена только самая важная часть кода))

    dimon1988, 17 Сентября 2011

    Комментарии (12)
  3. C# / Говнокод #7882

    +147

    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
    private void SetDisplay(string Group)
    {
           string taxInt = "144";
           switch (Group.ToLower())
           {
                  case "bond":
                         taxInt = "141";
                         ..............
                         break;
                  case "commodity":
                         taxInt = "329";
                         ..............
                         break;
                  case "emarkets":
                         taxInt = "142";
                         ..............
                         break;
                  default:
                         taxInt = "144";
                         ..............
                         break;
           }
           SetItems(taxInt);
    }
    
    public void SetItems(string taxInt)
    {
           Trace.Write(taxInt);
           int number;
           bool result = Int32.TryParse(taxInt, out number);
           if (result)
           {
                  tid = number;
           }
           else
           {
                  tid = 144;
                  this.lbHard.Style.Add("color", "#000");
           }
           Trace.Write(tid.ToString());
           if (tid > 0)
           {
                   ..............
            }
           else
           {
                   //здесь было пусто
           }
    }

    Лишний код удалён, оставлена только самая важная часть кода))

    dimon1988, 17 Сентября 2011

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

    +145

    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
    <?php
    
    header('Content-Type: text/html; charset=utf-8');
    
    function даешь_кириллицу_блеать($оказывается_можно_и_так_0_о) {
        echo $оказывается_можно_и_так_0_о;
    }
    
    даешь_кириллицу_блеать('век живи');
    
    $хуй=' - век учись';
    echo $хуй;
    
    
    ?>

    я кирпичами сру, ОНО РАБОТАЕТ!!!!!

    jokz, 17 Сентября 2011

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

    +156

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    $c = (int)(bool)$_POST['chat'];
    
    // через сто строк
    
    $q = 'UPDATE ....., `chat`='.$c.' WHERE ....';

    интригующе

    jokz, 16 Сентября 2011

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

    +36

    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
    function utf8win ($strin)  {
    	$strin = ereg_replace("&#x0430;","а",$strin);
    	$strin = ereg_replace("&#x0431;","б",$strin);
    	$strin = ereg_replace("&#x0432;","в",$strin);
    	$strin = ereg_replace("&#x0433;","г",$strin);
    	$strin = ereg_replace("&#x0434;","д",$strin);
    	$strin = ereg_replace("&#x0435;","е",$strin);
    	$strin = ereg_replace("&#x0451;","ё",$strin);
    	$strin = ereg_replace("&#x0436;","ж",$strin);
    	$strin = ereg_replace("&#x0437;","з",$strin);
    	$strin = ereg_replace("&#x0438;","и",$strin);
    	$strin = ereg_replace("&#x0439;","й",$strin);
    	$strin = ereg_replace("&#x043A;","к",$strin);
    	$strin = ereg_replace("&#x043B;","л",$strin);
    	$strin = ereg_replace("&#x043C;","м",$strin);
    	$strin = ereg_replace("&#x043D;","н",$strin);
    	$strin = ereg_replace("&#x043E;","о",$strin);
    	$strin = ereg_replace("&#x043F;","п",$strin);
    	$strin = ereg_replace("&#x0440;","р",$strin);
    	$strin = ereg_replace("&#x0441;","с",$strin);
    	$strin = ereg_replace("&#x0442;","т",$strin);
    	$strin = ereg_replace("&#x0443;","у",$strin);
    	$strin = ereg_replace("&#x0444;","ф",$strin);
    	$strin = ereg_replace("&#x0445;","х",$strin);
    	$strin = ereg_replace("&#x0446;","ц",$strin);
    	$strin = ereg_replace("&#x0448;","ш",$strin);
    	$strin = ereg_replace("&#x0449;","щ",$strin);
    	$strin = ereg_replace("&#x044A;","ъ",$strin);
    	$strin = ereg_replace("&#x044C;","ь",$strin);
    	$strin = ereg_replace("&#x044D;","э",$strin);
    	$strin = ereg_replace("&#x044E;","ю",$strin);
    	$strin = ereg_replace("&#x044F;","я",$strin);
    	$strin = ereg_replace("&#x0447;","ч",$strin);
    	$strin = ereg_replace("&#x044B;","ы",$strin);
    	$strin = ereg_replace("&#x0410;","А",$strin);
    	$strin = ereg_replace("&#x0411;","Б",$strin);
    	$strin = ereg_replace("&#x0412;","В",$strin);
    	$strin = ereg_replace("&#x0413;","Г",$strin);
    	$strin = ereg_replace("&#x0414;","Д",$strin);
    	$strin = ereg_replace("&#x0415;","Е",$strin);
    	$strin = ereg_replace("&#x0416;","Ж",$strin);
    	$strin = ereg_replace("&#x0417;","З",$strin);
    	$strin = ereg_replace("&#x0418;","И",$strin);
    	$strin = ereg_replace("&#x0419;","Й",$strin);
    	$strin = ereg_replace("&#x041A;","К",$strin);
    	$strin = ereg_replace("&#x041B;","Л",$strin);
    	$strin = ereg_replace("&#x041C;","М",$strin);
    	$strin = ereg_replace("&#x041D;","Н",$strin);
    	$strin = ereg_replace("&#x041E;","О",$strin);
    	$strin = ereg_replace("&#x041F;","П",$strin);
    	$strin = ereg_replace("&#x0420;","Р",$strin);
    	$strin = ereg_replace("&#x0421;","С",$strin);
    	$strin = ereg_replace("&#x0422;","Т",$strin);
    	$strin = ereg_replace("&#x0423;","У",$strin);
    	$strin = ereg_replace("&#x0424;","Ф",$strin);
    	$strin = ereg_replace("&#x0425;","Х",$strin);
    	$strin = ereg_replace("&#x0426;","Ц",$strin);
    	$strin = ereg_replace("&#x0428;","Ш",$strin);
    	$strin = ereg_replace("&#x0429;","Щ",$strin);
    	$strin = ereg_replace("&#x042A;","Ъ",$strin);
    	$strin = ereg_replace("&#x042C;","Ь",$strin);
    	$strin = ereg_replace("&#x042D;","Э",$strin);
    	$strin = ereg_replace("&#x042E;","Ю",$strin);
    	$strin = ereg_replace("&#x042F;","Я",$strin);
    	$strin = ereg_replace("&#x0427;","Ч",$strin);
    	$strin = ereg_replace("&#x042B;","Ы",$strin);
    	$strin = ereg_replace("&#x041;","Ё",$strin);
    	return $strin;
    }

    brainstorm, 16 Сентября 2011

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

    +167

    1. 1
    2. 2
    3. 3
    function js(){
       Header("Location: ../www/basket.php");
    }

    temka, 16 Сентября 2011

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

    +157

    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
    class SOME_CLASS
    {
    public:
    
      struct
      {
        inline uintb operator = (uintb newValue )
        {
           (reinterpret_cast<SOME_CLASS*>(static_cast<char*>(this)-offsetof(SOME_CLASS,SOME_CLASS::i)))->_setI( newValue  );
        }
        inline operator uintb ()
        {
           return (reinterpret_cast<SOME_CLASS*>(static_cast<char*>(this)-offsetof(SOME_CLASS,SOME_CLASS::i)))->_i;
        }
        ...
        ...
      } i;
    
     ...
    private:
      void _setI( uintb newValue );
      uintb _i;
    }

    http://www.gamedev.ru/code/forum/?id=152459#m1

    >P.S. обязательно поставить + на govnokod.ru.

    CPPGovno, 16 Сентября 2011

    Комментарии (20)
  9. JavaScript / Говнокод #7876

    +170

    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
    function timeProceed() {
    	second++;
    	if (second >= 60) {
    		minute++;
    		second = 0;
    	}
    	if (minute >= 60) {
    		hour++;
    		minute = 0;
    	}
    	if (hour > 23)
    	{
    		hour = 0;
    		minute = 0;
    		second = 0;
    	}
    
    	var cHour = hour;
    	var cMinute = minute;
    	var cSecond = second;
    	var cStyleVis  = "visible";
    	// Т.к. переменные целочисленные, то в них может содержаться только по одной цифре, будет выглядеть не очень красиво (типа 1:5:3, а надо 01:05:03), проверим это.
    	// Не C++ и преобразование типов нам не нужно
    	if (second < 10) cSecond = "0" + second;
    	if (minute < 10) cMinute = "0" + minute;
    	if (hour < 10) 	 cHour 	 = "0" + hour;
    	
    	// Итоговое время
    	//time = cHour + ":" + cMinute + ":" + cSecond;
    	if(dotsShow == 1){
       		cStyleVis = "visible";
       		dotsShow  = 0;
    	}
    	else{
    		cStyleVis = "hidden";
    		dotsShow  = 1;
    	}
    	time = '<b>' + cHour + '</b> <b class="dots" style="visibility:' + cStyleVis + ';">:</b> <b>' + cMinute + '</b>';
    	//alert(time);
    	// Кроосбраузерность уже самостоятельно прописываем
    	document.getElementById('clock').innerHTML = time;
    	timeChanged = 1;
    	return true;
    }

    Борьба со временем

    dens, 16 Сентября 2011

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

    −111

    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
    if(selectedLanguage==French)
        {
    
            FinalString = [[NSString alloc] initWithFormat:@"http://www.xyz.com/api_com.php?page_id=%d",IDValue];
            url = [[NSURL alloc] initWithString:FinalString];
        }
        else if(selectedLanguage==German)
        {
    
            FinalString = [[NSString alloc] initWithFormat:@"http://www.x.com/api_com.php?page_id=%d",IDValue];
            url = [[NSURL alloc] initWithString:FinalString];
        }
        else if(selectedLanguage==Nepali)
        {
    
            FinalString = [[NSString alloc] initWithFormat:@"http://www.xy.com/api_com.php?page_id=%d",IDValue];
            url = [[NSURL alloc] initWithString:FinalString];
    
        }

    mazder, 16 Сентября 2011

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