1. Java / Говнокод #5790

    +75

    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
    public static void getShops(Favorite favoriteBrands,
    			Favorite favoriteShops, StationItem station,
    			WorkingTimeFilter workTimeFilter, boolean[] filter, String keyword,
    			GeoLocationPointItem userLocation,
    			GeoLocationPointItem searchLocation, String catalogId,
    			String netId, String page, String pageSize, String api,
    			AsyncTask callback, ConnectionWatcher watcher) {
    //...
    //упаковка кучи параметров
    
    
    		boolean emptyFavBrands = false;
    		if (favoriteBrands != null) {
    			int i = 0;
    			for (FavoriteItem item : favoriteBrands) {
    				String id = item.getId();
    				Log.i(tag, "addFaforiteBrand " + id);
    				params.add(new BasicNameValuePair(PARAMS_FAVORITE_BRAND_ID
    						+ "[" + i + "]", id));
    				i++;
    			}
    			if (i == 0)
    				emptyFavBrands = true;
    		}
    
    		boolean emptyFavShops = false;
    		if (favoriteShops != null) {
    			int i = 0;
    			for (FavoriteItem item : favoriteShops) {
    				String id = item.getId();
    				Log.i(tag, "addFaforiteShop " + id);
    				params.add(new BasicNameValuePair(PARAMS_FAVORITE_SHOP_ID + "[" + i
    						+ "]", id));
    				i++;
    			}
    			if (i == 0)
    				emptyFavShops = true;
    		}
    
    		boolean error = false;
    
    		if (emptyFavBrands && emptyFavShops) {
    			if (favoriteBrands != null || favoriteShops != null)
    				error = true;
    		}
    
    		if (emptyFavShops) {
    			if (favoriteBrands == null && favoriteShops != null)
    				error = true;
    		}
    
    		if (emptyFavBrands) {
    			if (favoriteBrands != null && favoriteShops == null)
    				error = true;
    		}
    
    		if (error) {
    			callback.onError(JsonEntity.FAVORITE_ERROR, new IOException());
    			return;
    		}
    }

    Обращение к веб-сервису. Вызов этого метода при переносе IDE "растекается" на 5-6 строк.
    Самое интересное - проверка корректности параметров находится в самом конце метода (длиной 150 строк)

    rphx, 23 Февраля 2011

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

    +166

    1. 1
    2. 2
    3. 3
    4. 4
    function assign($params)
    {              
            return $params[0];
    }

    Функция с одной коммерческой cms. Можно же обойтись и без функции. Да и желательно сделать проверку на существование переменной.

    codosub, 23 Февраля 2011

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

    +171

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    if($nav_url=="blog.php")
    {
    $ahaha='2';
    eval('$code["$elementtype"] .= "' . fetch_template('navbar_link') . '";');
    $ahaha='';
    }
    else
    {
    eval('$code["$elementtype"] .= "' . fetch_template('navbar_link') . '";');
    }

    Ахаха!

    symbix, 23 Февраля 2011

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

    +162

    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
    <?php
    $t1 = microtime();
    define('CMS_LOAD', TRUE);
    
    require_once('./inc/config.inc.php');
    require_once('./inc/main_fnc.inc.php');
    
    
    cms_MysqlConnect();
    unset($cms); // попутно используемые данные скрипта
    unset($vars); // $_POST, $_COOKIE, $_GET данные
    cms_RegVars();
    
    $cms['page'] = !empty($vars['page']) ? $vars['page'] : 'main';
    $cms['md_page'] = !empty($vars['md_page']) ? $vars['md_page'] : '';
    
    $cms['ESTRING'] = !get_magic_quotes_gpc() ? TRUE : FALSE;
    $cms['strpos'] = strpos($cms['page'], '_');
    
    $cms['q_page'] = mysql_query("SELECT name, ptext FROM ".CMS_PREFIX."_pages WHERE page='".cms_MysqlEStr($cms['page'])."' LIMIT 1");
    $cms['is_page'] = mysql_num_rows($cms['q_page']);
    
    
    // если в _pages нет такой страницы, перемещаем на главную
    if($cms['is_page'] > 0)
    {
    	list($cms['page_name'], $cms['page_text']) = mysql_fetch_row($cms['q_page']);
    }
    else
    {
    	header("Location: /");
    }
    mysql_free_result($cms['q_page']);
    
    if($cms['strpos'] > 0 && !empty($cms['md_page']))
    {
    	$cms['q_md_product1'] = mysql_query("SELECT name, descript2, cost FROM ".CMS_PREFIX."_productions WHERE id=".intval($cms['md_page'])." LIMIT 1");
    	
    	if(mysql_num_rows($cms['q_md_product1']) > 0)
    	{
    		list($cms['page_name'], $cms['md_prod_descr2'], $cms['md_prod_cost']) = mysql_fetch_row($cms['q_md_product1']);
    	}
    	else
    	{
    		header("Location: /");
    	}
    	
    	mysql_free_result($cms['q_md_product1']);
    }
    
    
    //edited by DEMIS [[email protected]]
    
    $cms['page_text_header'] = $cms['page_name'];

    Index.php в самописной CMS улыбает. И это только начало +)

    be3, 23 Февраля 2011

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

    +165

    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
    function get_sel_values(index){
                    var test = eval('typeof opt_val'+index);
                    if ( test != 'undefined' ){
                      eval('var sel_values = opt_val'+index);
                      return sel_values;
                    }
        else { return false; }
    }
    //**************************************************************
    function get_sel_text(index){
                    var test = eval('typeof opt_text'+index); 
                    if ( test != 'undefined' ){
                      eval('var sel_text = opt_text'+index);
                      return sel_text;
                    }
        else { return false; }              
    }
    //**************************************************************
    function show_select(index, lev, dv){
        if ( dv == 'jdc1'){ var tr = "jdc2";}
        if ( dv == 'jdc2'){ var tr = "jdc3";}
        if ( dv == 'jdc3'){ var tr = "jdc4";}
        var curr_sel_text = get_sel_text(index);
        var curr_sel_value = get_sel_values(index);
                    if ( curr_sel_value != false && curr_sel_text != false ){
          if ( dv == 'jdc1'){
            document.getElementById('jdc1').style.visibility = "visible";
            document.getElementById('jdc2').style.visibility = "hidden";
            document.getElementById('jdc3').style.visibility = "hidden";
            document.getElementById('jdc4').style.visibility = "hidden";
                              document.forms["form1"].elements['cc2'].length = 0;
                              document.forms["form1"].elements['cc3'].length = 0;
                              document.forms["form1"].elements['cc4'].length = 0;
                      }
          if ( dv == 'jdc2'){
            document.getElementById('jdc1').style.visibility = "visible";
            document.getElementById('jdc2').style.visibility = "visible";
            document.getElementById('jdc3').style.visibility = "hidden";
            document.getElementById('jdc4').style.visibility = "hidden";
                              document.forms["form1"].elements['cc3'].length = 0;
                              document.forms["form1"].elements['cc4'].length = 0;
                      }
          if ( dv == 'jdc3'){
            document.getElementById('jdc1').style.visibility = "visible";
            document.getElementById('jdc2').style.visibility = "visible";
            document.getElementById('jdc3').style.visibility = "visible";
            document.getElementById('jdc4').style.visibility = "hidden";
                              document.forms["form1"].elements['cc4'].length = 0;
                      }
          var count_values = curr_sel_value.length;
          var category_list = document.forms["form1"].elements[lev];
          var count_category_list = category_list.options.length;
          category_list.length = 0; 
          for (i = 0; i < count_values; i++){
            if (document.createElement){
                var newCategoryListOption = document.createElement("OPTION");
                newCategoryListOption.text = curr_sel_text[i];
                newCategoryListOption.value = curr_sel_value[i];
                (category_list.options.add) ? category_list.options.add(newCategoryListOption) : category_list.add(newCategoryListOption);
            }else{
                category_list.options[i] = new Option(curr_sel_text[i], curr_sel_value[i], false, false);
            }
          }
          document.getElementById(tr).style.visibility = "visible";
              }
                    else{
          document.getElementById(tr).style.visibility = "hidden";
                    }
      }
    //-->

    qbasic, 23 Февраля 2011

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

    +169

    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
    <script type="text/javascript"> 
    opt_text13=new Array("Internet","Hardware","Mobiles","Soft","Sequrity","Networks","Interface");
    opt_val13=new Array("14","28","44","54","61","67","72");
    opt_val113=new Array("114","115","116","117","118","119","120","121");
    opt_text122=new Array("Essays","Scintific Publications","Online Lessons & Tests","Scintific Libraries","Other");
    opt_val122=new Array("123","124","125","126","127");
    opt_text128=new Array("Your Appartment","Cookery","All for Holidays","Family","Pats","Health","Fashion and Beauty","Purchases");
    opt_val128=new Array("129","138","146","155","162","170","179","189");
    opt_text129=new Array("Country Cottage","Repair","Construction","Interior Design","Landscape Design","Building Materials","Sanitary","Other");
    opt_val129=new Array("130","131","132","133","134","135","136","137");
    opt_text138=new Array("Recepies","Diet","Products","Tabacco","Bavarage","Delivery","Other");
    opt_val138=new Array("139","140","141","142","143","144","145");
    opt_text146=new Array("E-Cards","Tostes and scenaries","Gifts","Flowers Delivery","Holiday Organization","Fireworks","Holidays","Other");
    opt_val146=new Array("147","148","149","150","151","152","153","154");
    opt_text155=new Array("For Parents","For Children","Relation's Psyhology","Marrage","Marrage Agancies","Other");
    //...............
    opt_val252=new Array("253","254","255","256","257","258");opt_text259=new Array("Astrology","Fortune-telling","Esotericism","UFO","Other");
    opt_val259=new Array("260","261","262","263","264");
    opt_text268=new Array("Places","Tourism","Vocation","Hobbies");
    opt_val268=new Array("269","280","292","297");
    opt_text269=new Array("Restaurants & Bars","Clubs & Diskos","Bowling & Billiard","Casinos","Places for children","Circuses","Parks & Zoos","Theaters","Cinemas","Other");
    opt_val269=new Array("270","271","272","273","274","275","276","277","278","279");
    opt_text428=new Array("Newspapers","Magazines","Publishing Houses","Business publications","Computer publications","Motor-Car publications","Sport publications","Entertaining publications","Music/Cinema/TV","Publications for women","Publications for men","Publications for kids","Other publications");opt_val428=new Array("429","430","431","432","433","434","435","436","437","438","439","440","441");opt_text446=new Array("Metallurgy","Mechanical engineering","Equipment","Electronics","Energetics","Chemical industry","Agriculture","Food Industry","Factories","Light Industry","Heavy Industry","Other industries");opt_val446=new Array("447","451","458","469","473","479","483","484","485","486","487","488");opt_text447=new Array("Iron industry","Non-ferrous metallurgy","Other");opt_val447=new Array("448","449","450");opt_text451=new Array("Motor-car Factories","Engeenering Factories","Agricultural Factories","Sheepbuilding","Aircraft building","Other");
    //........
    opt_text529=new Array("Office equipment","Office furneture","Lock boxes","Stationery","Other");opt_val529=new Array("530","531","532","533","534");opt_text536=new Array("Encyclopedias","Transport","Maps","Addresses & Phones","Search people","Dictionaries","Weather","Other");opt_val536=new Array("537","543","552","553","554","555","556","557");opt_text537=new Array("Universal","Medical","Biographical","Subject encyclopedia","Other");opt_val537=new Array("538","539","540","541","542");opt_text543=new Array("Timetables","Air transport","Railway","Sailing","Urban transport","Taxi & Car rent","Bus transport","Other");opt_val543=new Array("544","545","546","547","548","549","550","551");opt_text558=new Array("Other");
    opt_val558=new Array("559");//**************************************************************

    qbasic, 23 Февраля 2011

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

    +128

    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
    <table border="0">
    <form name="form1">
    <tr>
      <tr><td width="200"><span id="jdc1">
          <select name="cc1" onclick="show_select(this.options[this.selectedIndex].value, 'cc2','jdc1')">
        <option value="13">Hi-Tech</option><option value="79">Job</option><option value="87">Education</option><option value="128">Home</option><option value="200">Society</option><option value="232">Enterteiments</option><option value="268">Activities</option><option value="304">Culture</option><option value="386">Sport</option><option value="427">Mass-Media</option><option value="446">Industry</option><option value="489">Business</option><option value="536">Inquries</option><option value="558">Other</option>   </select></span></td></tr>
        <tr><td><span id="jdc2" style="visibility: hidden;"><select name="cc2" onclick="show_select(this.options[this.selectedIndex].value, 'cc3','jdc2')" style="">
                    </select></span></td></tr>
        <tr><td><span id="jdc3" style="visibility: hidden;"><select name="cc3" onclick="show_select(this.options[this.selectedIndex].value, 'cc4','jdc3')" style="">
                    </select></span></td></tr> 
        <tr><td><span id="jdc4" style="visibility: hidden;"><select name="cc4" style="">
                    </select></span></td></tr>
    </table>

    qbasic, 23 Февраля 2011

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

    −91

    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
    /**
     *  @private
     *  The exponent used in the easer function for the main part of the throw animation.
     *  NOTE: if you change this, you need to re-differentiate the easer
     *  function and use the resulting derivative calculation in createThrowMotionPath. 
     */
    private static const THROW_CURVE_EXPONENT:Number = 3.0;
    
    ...
    
    // Set the velocity for the next loop iteration.  Make sure it matches the actual velocity in effect when the
    // throw reaches the end of the list.
    //
    // The easer function we use for the throw is 1-((1-x)^3), the derivative of which is 3*x^2-6*x+3.
    // (I used http://www.numberempire.com/derivatives.php to differentiate the easer function).
    // Since the slope of a curve function at any point x (i.e. f(x)) is the value of the derivative at x (i.e. f'(x)),
    // we can use this to determine the velocity of the throw at the point it reached the beginning of the bounce.
    var x:Number = partialTime / effectTime;
    var y:Number = 3 * Math.pow(x, 2) - 6 * x + 3;

    Flex 4.5 Hero.
    Благо на работу кода это не сказывается, но всё-таки...

    Разработчикам: Вообще класс и непосредственно алгоритм touch/kinetic скролла там сделан отвратительно, но с некоторыми весьма хорошими фишками (отпределение скорости, например). Советую вам покопаться.

    fljot, 23 Февраля 2011

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

    −143

    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
    IF @Detail is not null
          AND (SELECT
                COUNT(AppraisalResponseID)
                FROM AppraisalResponseHistory
                WHERE AppraisalResponseID = @AppraisalResponseID) >0
          BEGIN
                INSERT INTO AppraisalResponseHistory 
                ( AppraisalResponseID, 
                      PermissionID, 
                      AppraisalTypeQuestionPromptID, 
                      Detail, 
                      ModifiedDate, 
                      PersonID )
          
                SELECT AppraisalResponse.ID, 
                      AppraisalResponse.PermissionID,
                       AppraisalResponse.AppraisalTypeQuestionPromptID,
                       AppraisalResponse.Detail, 
                      AppraisalResponse.ModifiedDate,
                      PersonID
                FROM AppraisalResponse
                WHERE AppraisalResponse.ID=@AppraisalResponseID AND AppraisalResponse.Detail<>@Detail
          
          END
    ELSE
          IF COALESCE(@Detail, '') = ''
    --if the reviewer is inserting a blank record after having filled in a response, insert into history
    --if the blank record is the place holder, do not insert into history
          AND (SELECT
                COUNT(AppraisalResponseID)
                FROM AppraisalResponseHistory
                WHERE AppraisalResponseID = @AppraisalResponseID) >0
          BEGIN
                INSERT INTO AppraisalResponseHistory 
                ( AppraisalResponseID, 
                      PermissionID, 
                      AppraisalTypeQuestionPromptID, 
                      Detail, 
                      ModifiedDate, 
                      PersonID )
          
                SELECT AppraisalResponse.ID, 
                      AppraisalResponse.PermissionID,
                       AppraisalResponse.AppraisalTypeQuestionPromptID,
                       AppraisalResponse.Detail, 
                      AppraisalResponse.ModifiedDate,
                      PersonID
                FROM AppraisalResponse
                WHERE AppraisalResponse.ID=@AppraisalResponseID AND AppraisalResponse.Detail<>@Detail
    END

    If @Detail is not null or blank, I need to check if AppraisalResponse.Detail is blank or null (- I think this is where I am running into so much trouble). If it is blank or null then
    I need to check if there is already a record in AppraisalHistory with this ID. If there is, I need to insert the blank record to history, otherwise not.

    If @Detail is null.
    I need to check if there is already a record in Appraisal History with this ID. If there is, I need to insert the blank record to history, otherwise not.

    Даже описание скопипащено

    3.14159265, 23 Февраля 2011

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

    +179

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    $kPOST = @array_keys($_POST);
    
    for (@$i=0;$i<@count(@$kPOST);@$i++) {
    	$_POST[@$kPOST[@$i]] = @htmlspecialchars(@$_POST[@$kPOST[@$i]]);
    }
    
    $kGET = @array_keys(@$_GET);
    for (@$i=0;@$i<@count(@$kGET);@$i++) {
    	$_GET[@$kGET[@$i]] = @htmlspecialchars(@$_GET[@$kGET[@$i]]);
    }

    Ну теперь точно без ошибок!

    Sych, 23 Февраля 2011

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