1. Куча / Говнокод #8811

    +129

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    <div class="sliderItem">
        <a class="j-fullscreen-thumbnail" href="/events/night-life/2011/12/10/568385/pictures/18257298">
            <img src="about: blank"  lazysrc="http://files2.geometria.ru/pics/thumbnail/18257298.jpg" style="visibility: hidden;"  alt="Всемирный День Футбола!" width="110" height="110"/>
            <span class="j-fullscreenLink accessConfirmed" message="Чтобы посмотреть фото на весь экран, войдите на сайт" title="На весь экран"></span>
        </a>
    </div>

    С главной страницы социалки одной. Страница - ну просто памятник культу карго. Сто сорок загружаемых скриптов. С ними - двести запросов. Триста шестьдесят вот этих чудесных, использующих lazy loading, declarative data binding и хрен пойми чего ещё шаблонов.

    PHP-шник - он как эмбрион, по мере роста повторяет весь путь развития отрасли веб-разработки.

    actuator, 13 Декабря 2011

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

    +164

    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
    class PAGING
    {
      var $sql,$records,$pages;
      var $page_no,$total,$limit,$first,$previous,$next,$last,$start,$end;
      function PAGING($sql,$records=9,$pages=5)
      {   global $mysqli;
        if($pages%2==0) $pages++;
        $res = $mysqli->query($sql);
        $sqlquery++;
        $total=mysqli_num_rows($res);
        $page_no=isset($_GET["p"])?$_GET["p"]:1;
        $limit=($page_no-1)*$records;
        $sql.=" limit $limit,$records";
        $first=1;
        $previous=$page_no>1?$page_no-1:1;
        $next=$page_no+1;
        $last=ceil($total/$records);
        if($next>$last)
          $next=$last;
        $start=$page_no;
        $end=$start+$pages-1;
        if($end>$last)
          $end=$last;
        if(($end-$start+1)<$pages)
        {
          $start-=$pages-($end-$start+1);
          if($start<1)
            $start=1;
        }
        if(($end-$start+1)==$pages)
        {
          $start=$page_no-floor($pages/2);
          $end=$page_no+floor($pages/2);
          while($start<$first)
          {
            $start++;
            $end++;
          }
          while($end>$last)
          {
            $start--;
            $end--;
          }
        }
        $this->sql=$sql;
        $this->records=$records;
        $this->pages=$pages;
        $this->page_no=$page_no;
        $this->total=$total;
        $this->limit=$limit;
        $this->first=$first;
        $this->previous=$previous;
        $this->next=$next;
        $this->last=$last;
        $this->start=$start;
        $this->end=$end;
      }
      function show_paging($url,$params=""){...}
    }

    Вот так вот товарищ пейджинг организует ООО)

    aleXoid, 13 Декабря 2011

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

    +137

    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
    function ShowRubricThread(parent_id)
    		{
     
    		myArray = new Array('menu1_child_of_0','menu2_child_of_1','menu3_child_of_2','menu4_child_of_2','menu18_child_of_2','menu21_child_of_2','menu23_child_of_21','menu25_child_of_21','menu28_child_of_21','menu200_child_of_21','menu30_child_of_21','menu32_child_of_21','menu33_child_of_2','menu180_child_of_2','menu202_child_of_2','menu46_child_of_1','menu131_child_of_46','menu132_child_of_131','menu137_child_of_131','menu138_child_of_131','menu47_child_of_46','menu48_child_of_46','menu50_child_of_46','menu51_child_of_46','menu52_child_of_51','menu53_child_of_51','menu54_child_of_51','menu55_child_of_46','menu59_child_of_1','menu61_child_of_59','menu62_child_of_59','menu17_child_of_0','menu184_child_of_17','menu185_child_of_184','menu186_child_of_184','menu187_child_of_184','menu188_child_of_184','menu189_child_of_184','menu190_child_of_184','menu191_child_of_184','menu192_child_of_184','menu197_child_of_184','menu194_child_of_184','menu63_child_of_17','menu64_child_of_63','menu65_child_of_63','menu66_child_of_63','menu67_child_of_63','menu68_child_of_63','menu69_child_of_63','menu70_child_of_63','menu71_child_of_63','menu84_child_of_63','menu73_child_of_63','menu74_child_of_17','menu77_child_of_17','menu81_child_of_17','menu124_child_of_0','menu125_child_of_124','menu126_child_of_124','menu129_child_of_124','menu130_child_of_124','menu182_child_of_124','menu198_child_of_124','menu141_child_of_0','menu142_child_of_141','menu143_child_of_141','menu144_child_of_141','menu146_child_of_141','menu177_child_of_141','menu147_child_of_141','menu148_child_of_141','menu149_child_of_141','menu150_child_of_141','menu151_child_of_141','menu152_child_of_141','menu153_child_of_141','menu154_child_of_141','menu155_child_of_141','menu156_child_of_141','menu157_child_of_141','menu201_child_of_141','menu8_child_of_0','menu160_child_of_8','menu161_child_of_8','menu162_child_of_8','menu163_child_of_8','menu164_child_of_8','menu165_child_of_8','menu166_child_of_8','menu203_child_of_0','menu204_child_of_203','menu11_child_of_0','menu105_child_of_11','menu181_child_of_11','menu108_child_of_11','menu109_child_of_11','menu110_child_of_11','menu111_child_of_11','menu12_child_of_0','menu199_child_of_12','menu168_child_of_12','menu179_child_of_12','menu115_child_of_12','menu116_child_of_12','menu117_child_of_12','menu170_child_of_117','menu167_child_of_12','menu178_child_of_12','menu13_child_of_0','menu174_child_of_13','menu14_child_of_0','menu120_child_of_14','menu121_child_of_14','menu122_child_of_14','menu123_child_of_14');
    					for(var i=0; i < myArray.length; i++)
    					{
     
    							reg_string = "_child_of_" + parent_id + "$";
    							reg = new RegExp(reg_string);
    							newArray = myArray[i].match(reg);
    							if( newArray != null)
    							{
    							document.getElementById(myArray[i]).style.display = "block";
    							}
     
    					}
     
    		ShowTread = true;
     
    		}

    http://chechnya.gov.ru/page.php?day=102&month=13&year=2222
    Формат мой.    и говнокода

    dos_, 13 Декабря 2011

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

    +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
    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
    #include<stdio.h>
    #include<conio.h>
    #include<math.h>
    #define eps 0.001
    
    float Phi1 (float x_pred[1])
    {
          return asin(1.2 + x_pred[1]) - 1;
    }
    
    float Phi2 (float x_pred[0])
    {
          return acos(2 - 2*x_pred[0]);
    }
    
    int main ()
    {
        float x_pred[1],x[1];
        float norma;
        
        x_pred[0] = 0.4;
        x_pred[1] = -0.3;
        
        do
        {
          x[0] = Phi1(x_pred[1]);
          x[1] = Phi2(x_pred[0]);
          printf("%6.2f",x[0]);
          printf("             %6.2f\n",x[1]);
          norma = (fabs(x[0] - x_pred[0])) > fabs((x[1] - x_pred[1])) ? fabs(x[0] - x_pred[0]) : fabs(x[1] - x_pred[0]);
          if (norma >= eps) break;
          else
          {
            x_pred[0] = x[0];
            x_pred[1] = x[1];
          }
        }
        while (1);
        getch();
        return 0;
    }

    govnouser, 13 Декабря 2011

    Комментарии (8)
  5. ActionScript / Говнокод #8806

    −118

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    //reassign the dataprovider in order to trigger chart update
    var tempArrayColl:ArrayCollection = new ArrayCollection();
    tempArrayColl.addAll(costChartDataProvider);
    costChartDataProvider.removeAll();
    costChartDataProvider.addAll(tempArrayColl);

    Можно было обойтись

    costChartDataProvider.refresh()
    . Но проблема глубже, флексовые биндинги которые и приводят к появлению такого кода.

    wvxvw, 13 Декабря 2011

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

    +146

    1. 1
    http://chechnya.gov.ru/page.php?day=102&month=13&year=2222

    Ещё можете год убрать, и посмотрите как вывалится ошибка mktime()
    XDDD

    Мне кажется этот сайт по бумагам стоит не менее чем 1ккк руб.

    vkontakte, 13 Декабря 2011

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

    +153

    1. 1
    'email'   => array('/^[-_a-z0-9\'+*$^&%=~!?{}]++(?:\.[-_a-z0-9\'+*$^&%=~!?{}]+)*+@(?:(?![-.])[-a-z0-9.]+(?<![-.])\.[a-z]{2,6}|\d{1,3}(?:\.\d{1,3}){3})(?::\d++)?$/iD', 'Введите правильный e-mail, пожалуйста.')

    Вот такая проверка валидности email

    Sulik78, 13 Декабря 2011

    Комментарии (7)
  8. Си / Говнокод #8803

    +139

    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
    /*
     * HttpReceiveRequestEntityBody
     */
    static ULONG __cdecl
    HttpReceiveRequestEntityBody_called(BOOL carry_on,
                                        DWORD ret_addr,
                                        HANDLE ReqQueueHandle,
                                        HTTP_REQUEST_ID RequestId,
                                        ULONG Flags,
                                        PVOID pBuffer,
                                        ULONG BufferLength,
                                        PULONG pBytesReceived,
                                        LPOVERLAPPED pOverlapped)
    {
        if (GetCurrentThreadId() != cur_thread_id && ReqQueueHandle == cur_req_queue)
        {
            carry_on = FALSE;
            return ERROR_IO_PENDING; /* evil evil */
        }
    
        return 0;
    }

    нет что бы что то путнее в комментарии написать :)

    63F45EF45RB65R6VR, 12 Декабря 2011

    Комментарии (6)
  9. Си / Говнокод #8802

    +137

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    7. 7
    8. 8
    9. 9
    #define MAKEPTR(p,o) (LPVOID) ( (DWORD)p + (DWORD)o )
    #define WRITE_OPCODE(pCode, x) \
       res = WriteProcessMemory( hProcess, pCode, &x, sizeof(x), &nWritten ); \
       if( !res ) return FALSE; \
       pCode = MAKEPTR(pCode,sizeof(x))
    #define WRITE_DWORD(pCode, x) \
       res = WriteProcessMemory( hProcess, pCode, &x, sizeof(x), &nWritten ); \
       if( !res ) return FALSE; \
       pCode = MAKEPTR(pCode,sizeof(x))

    макрос "сюрприз" хоть бы назвал яснее типа
    WRITE_OPCODE_AND_RETURN_VAL_IF_FAIL
    но чем так писать лучше уж условие не прятать

    http://ospy.googlecode.com/svn/!svn/bc/2/trunk/Agent/hooking.cpp

    63F45EF45RB65R6VR, 12 Декабря 2011

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

    +171

    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
    .............
    try {
          $good = $admin->isest ? true : false;
          if(!$good) throw new adminException('Ошибка!');
    }catch (Exception $e){
    {
          try {
            if($admin->isnet) throw new adminException('Админа нет!');
          }catch (adminException $e){
               echo $e->getMessage();
          {      
    }
    ................

    От создателя Говнокод #8761.

    Товарищи начал юзать исключения.

    Razban_Guestov, 12 Декабря 2011

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