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

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

    +153

    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
    <!-- позиционирование элементов меню -->
    <script language="JavaScript">
        var pos = document.getElementById('f_g_b').offsetLeft;
        var obj = getElementsByClass('s_g_b',null,'table');
        for(i=0;i<obj.length;i++){
          obj[i].style.left = pos+"px";
        }
        var ua = navigator.userAgent;
        if ((ua.indexOf('Gecko') != -1)&&(ua.indexOf('Chrome') == -1))
        {
          obj = getElementsByClass('s_g_t',null,'table');
          for(i=0;i<obj.length;i++){
            obj[i].style.left = pos+"px";
          }
        }
    </script>

    Предыдущий пост цвяточек по сравнению, с использованияем JS вместо css хаков. ППЦ я такого еще не видел.

    enemis, 18 Июля 2011

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

    +153

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    if ($myrow9['fupload'] =='' or empty($myrow9['fupload']))
                    {
    $avachat = "../file/avatars/net-avatara.jpg";
                    }  else {
    $avachat = $myrow9['fupload'];
                    }

    Говно высшей пробы....

    invision70, 16 Июля 2011

    Комментарии (7)
  4. JavaScript / Говнокод #7263

    +153

    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
    function preview(e,id,b){
    		e.stopPropagation();
    		var post;
    		if(b!=board||!$('#post_'+id).attr('id')){
    		$.getJSON('/getpost/'+b+'/'+id,function(data,status){
    			if(data){
    				post=$.tmpl(postmpl, {post:data,lng:'',info:''});
    			}else{
    				post=$('<div id="post_'+id+'" class="reply poststyle"> 404 </div>');
    			}
    			post.css({display:'block', width: '450px', position: 'absolute', top: e.pageY, left: e.pageX})
    				.mouseleave(function(evt){
    					if(!/cloned_/i.test(evt.relatedTarget.id)||evt.relatedTarget.id>p.attr('id')){
    						post.remove();
    					}
    			})
    			.attr('id','cloned_'+id).appendTo($(doc.body))
    		});
    		}else{
    			post=$('#post_'+id).clone();
    			post.css({display:'block', width: '450px', position: 'absolute', top: e.pageY, left: e.pageX})
    				.mouseleave(function(evt){
    					if(!/cloned_/i.test(evt.relatedTarget.id)||evt.relatedTarget.id>p.attr('id')){
    						post.remove();
    					}
    			})
    			.attr('id','cloned_'+id).appendTo($(doc.body))
    		}
    	}

    хуита, 16 Июля 2011

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

    +153

    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
    $connect = $db->sql_query("SELECT `come_sid`, `come_time`, `come_ip`, `secret_type` FROM `".PREFIX."_gen[user]` WHERE `uid` = '" . $this->USER_UID . "';");
    $rowset = $db->sql_fetchrow();
    
    if( $connect == false ) {
    	$return = false;
    } else if( $rowset == false ) {
    	unset( $return );
    	$return = false;
    } else if( ( intval($rowset['come_time']) + intval($conf_safety["time_sess_adm"]) ) < time()) {
    	unset( $return );
    	$return = false;
    } else if( $rowset['come_ip'] != IPClient() ) {
    	unset( $return );
    	$return = false;
    } else if( $rowset['secret_type'] != secret_hash() ) {
    	unset( $return );
    	$return = false;
    } else if( $rowset['come_sid'] != SID ) {
    	unset( $return );
    	$return = false;
    } else {
    	unset( $return );
    	$return = true;
    }

    Бесполезные условия...

    nethak, 13 Июля 2011

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

    +153

    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 read($fields = null, $id = null) {
    	$this->validationErrors = array();
    
    	if ($id != null) {
    		$this->id = $id;
    	}
    
    	$id = $this->id;
    
    	if (is_array($this->id)) {
    		$id = $this->id[0];
    	}
    
    	if ($id !== null && $id !== false) {
    		$this->data = $this->find(array($this->alias.'.'.$this->primaryKey => $id), $fields);
    		return $this->data;
    	} else {
    		return false;
    	}
    }

    И ещё cakePHP (самый-самый фреймворк, даже в говнокоде впереди планеты всей).

    zabuhailo, 28 Июня 2011

    Комментарии (3)
  7. JavaScript / Говнокод #7088

    +153

    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
    <form method="POST" id="acceptaction" action="/">
                 <input type="submit" value="Принять участие" name="startUserEvent" />
                 <input type="hidden" value="62" name="userid" />
    </form>
    <div id="result"></div>
    
    jQuery(document).ready(function()
    {
       jQuery("#acceptaction").submit(function(event)) {
        event.preventDefault();
        var form = jQuery( this ),
            term = form.find( 'input[name="userid"]' ).val(),
            url = form.attr( 'action' );
        jQuery.post( url, { userid: term },
          function( data ) {
              var content = jQuery( data ).find( '#content' );
              jQuery( "#result" ).empty().append( content );
          };
        );
       };
    });

    maeln0r, 27 Июня 2011

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

    +153

    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
    try
    			{
    				sw = gcnew StreamWriter(GetIniFileName());
    			}
    			catch(UnauthorizedAccessException^ e)
    			{
    				MessageBox::Show( "Access is denied.", "Ошибка", MessageBoxButtons::OK, MessageBoxIcon::Error );
    				ShowException(dynamic_cast<System::Exception^>(e));
    				return;
    			}
    			catch(ArgumentNullException^ e)
    			{
    				MessageBox::Show( e->ParamName + ": File path is null.", "Ошибка", MessageBoxButtons::OK, MessageBoxIcon::Error );
    				ShowException(dynamic_cast<System::Exception^>(e));
    				return;
    			}
    			catch(ArgumentException^ e)
    			{
    				MessageBox::Show( e->ParamName + ": Wrong file path.", "Ошибка", MessageBoxButtons::OK, MessageBoxIcon::Error );
    				ShowException(dynamic_cast<System::Exception^>(e));
    				return;
    			}
    			catch(DirectoryNotFoundException^ e)
    			{
    				MessageBox::Show( "The specified path is invalid, such as being on an unmapped drive.", "Ошибка", MessageBoxButtons::OK, MessageBoxIcon::Error );
    				ShowException(dynamic_cast<System::Exception^>(e));
    				return;
    			}
    			catch(PathTooLongException^ e)
    			{
    				MessageBox::Show( "The specified path, file name, or both exceed the system-defined maximum length. For example, on Windows-based platforms, paths must be less than 248 characters, and file names must be less than 260 characters. ", "Ошибка", MessageBoxButtons::OK, MessageBoxIcon::Error );
    				ShowException(dynamic_cast<System::Exception^>(e));
    				return;
    			}
    			catch(IOException^ e)
    			{
    				MessageBox::Show( "File path includes an incorrect or invalid syntax for file name, directory name, or volume label syntax. ", "Ошибка", MessageBoxButtons::OK, MessageBoxIcon::Error );
    				ShowException(dynamic_cast<System::Exception^>(e));
    				return;
    			}
    			catch(SecurityException^ e)
    			{
    				MessageBox::Show( "The caller does not have the required permission." + e->ToString(), "Ошибка", MessageBoxButtons::OK, MessageBoxIcon::Error );
    				ShowException(dynamic_cast<System::Exception^>(e));
    				return;
    			}
    			catch(System::Exception^ e)
    			{
    				ShowException(e);
    				return;
    			}

    Обработка исключений.

    ScumCoder, 22 Июня 2011

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

    +153

    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
    if(FirstDot == 0 && LastDot == 0)
    			NoDots = true;
    		else
    			if(FirstDot != 0 && LastDot == 0)
    				throw gcnew System::Exception("Левый коррелятор начал работу, правый - нет.");
    			else
    				if(FirstDot == 0 && LastDot != 0)
    					throw gcnew System::Exception("Правый коррелятор начал работу, левый - нет.");
    				else
    					if(FirstDot != 0 && LastDot != 0)
    						if(FirstDot == LastDot)
    							NoDots = true;
    						else
    							NoDots = false;
    					else
    						throw gcnew System::Exception("WTF?");

    Нужно определить, есть на графике точки или нет. Человек решил подстраховаться и рассмотреть все возможные (и невозможные) варианты.

    ScumCoder, 19 Июня 2011

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

    +153

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    11. 11
    static $table_classes = array (
      0 => 'App',
      1 => 'Plugin',
      2 => 'AppUser',
      3 => 'Contact',
      4 => 'Email',
      5 => 'Link',
      6 => 'Mobile',
      7 => 'Session',
      8 => 'User',
    );

    VASMAN, 25 Мая 2011

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

    +153

    1. 1
    $('a ul.switcher').click(function(){

    Писал спросони, минут 5 не мог понять, почему не работает этот код :)

    Jetti, 07 Мая 2011

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