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

    +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
    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
    public function getSaleDepartment()
        {
            $_linkToDepLabel = '';
    		
            switch ($this->getfs_sale_department()) {
                case '0':
                    $_linkToDepLabel = $this->getBaseUrl();
                    $_linkToDepLabel .= 'media/flash_sales/saledepartment/1.png';
                    break; //Moda
                case '1':
                    $_linkToDepLabel = $this->getBaseUrl();
                    $_linkToDepLabel .= 'media/flash_sales/saledepartment/2.png';
                    break; //Belleza
                case '2':
                    $_linkToDepLabel = $this->getBaseUrl();
                    $_linkToDepLabel .= 'media/flash_sales/saledepartment/3.png';
                    break; //Novia
                case '3':
                    $_linkToDepLabel = $this->getBaseUrl();
                    $_linkToDepLabel .= 'media/flash_sales/saledepartment/4.png';
                    break; //Ocio
                case '4':
                    $_linkToDepLabel = $this->getBaseUrl();
                    $_linkToDepLabel .= 'media/flash_sales/saledepartment/5.png';
                    break; //Deporte
                case '5':
                    $_linkToDepLabel = $this->getBaseUrl();
                    $_linkToDepLabel .= 'media/flash_sales/saledepartment/6.png';
                    break; //Familia
                case '6':
                    $_linkToDepLabel = $this->getBaseUrl();
                    $_linkToDepLabel .= 'media/flash_sales/saledepartment/7.png';
                    break; //Hogar
                case '7':
                    $_linkToDepLabel = $this->getBaseUrl();
                    $_linkToDepLabel .= 'media/flash_sales/saledepartment/8.png';
                    break; //Viaje
                case '8':
                    $_linkToDepLabel = $this->getBaseUrl();
                    $_linkToDepLabel .= 'media/flash_sales/saledepartment/9.png';
                    break; //Moda
                case '9':
                    $_linkToDepLabel = $this->getBaseUrl();
                    $_linkToDepLabel .= 'media/flash_sales/saledepartment/10.png';
                    break; //Belleza
                case '10':
                    $_linkToDepLabel = $this->getBaseUrl();
                    $_linkToDepLabel .= 'media/flash_sales/saledepartment/11.png';
                    break; //Novia
                case '11':
                    $_linkToDepLabel = $this->getBaseUrl();
                    $_linkToDepLabel .= 'media/flash_sales/saledepartment/12.png';
                    break; //Ocio
                case '12':
                    $_linkToDepLabel = $this->getBaseUrl();
                    $_linkToDepLabel .= 'media/flash_sales/saledepartment/13.png';
                    break; //Deporte
    
                default:
                    $_linkToDepLabel = '';
                    break;
            }
            return $_linkToDepLabel;
        }

    ппц

    CheshirskyCode, 21 Марта 2012

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

    +153

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    11. 11
    $sql_query_result = mysql_query("select * from Organisations
    inner join Goods on (Organisations.ID = Goods.OrgID)
    where 1");
    while($result_string = mysql_fetch_array($sql_query_result)) { array_push ($search_array, $result_string[3]); }
    for($i=0;$i<=count($search_array);$i++)
    {
     if(eregi($search_string, $search_array[$i]))
     {
      array_push($search_matches, $search_array[$i]);
     }
    }

    поиск в интернет магазине:
    13000 записей
    в строке 15 полей
    в каждом строке есть 3 BLOB
    2 с текстом и одно с картинкой товара
    а жаловались что база тормозит

    papavel, 21 Марта 2012

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

    +150

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    <div style="display: none;">
    	<input type="hidden" name="_wpcf7" value="251" />
    	<input type="hidden" name="_wpcf7_version" value="3.1.1" />
    	<input type="hidden" name="_wpcf7_unit_tag" value="wpcf7-f251-t1-o1" />
    	<input type="hidden" name="_wpnonce" value="5963830b40" />
    </div>

    Плагин Contact Form 7 для Wordpress

    glutaminefee, 20 Марта 2012

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

    −132

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    7. 7
    8. 8
    Попытка
    			Если Число(ДисконтнаяКарта.НомерКарты) >= 111065251 И Число(ДисконтнаяКарта.НомерКарты) <= 111065453 И  ПревышенаСуммаДисконта() Тогда 
    				Отказ = Истина;
    				Сообщить("Сумма дисконта превышает оставшийся лимит по карте!",СтатусСообщения.Важное);
    				Возврат
    			КонецЕсли;
    		Исключение
    		КонецПопытки;

    glavdir, 20 Марта 2012

    Комментарии (3)
  5. Си / Говнокод #9718

    +133

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    // for cdio:
    #include <cdio.h>
    #include <cdio_unconfig.h> # remove *all* symbols libcdio defines
    
    // Add back in the ones you want your program
    #include <config.h>

    But now what about the problem that there are common preprocessor symbols in config_cdio.h that an application may want to define in a different manner, like PACKAGE_NAME?
    For this, there is yet another header, <cdio/cdio_unconfig.h>.

    rat4, 20 Марта 2012

    Комментарии (1)
  6. C# / Говнокод #9717

    +109

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    11. 11
    private IEnumerable<CharacteristicValue> GetCharacteristicValues(IQueryable<CharacteristicValue> allCharacteristicValues, int characteristicId)
    {
          var characteristicValues = new CharacteristicValue[userIds.Length];
    
           for (var i = 0; i < userIds.Length; i++)
           {
               characteristicValues[i] = allCharacteristicValues.FirstOrDefault(cv => cv.UserId == userIds[i] && cv.CharacteristicId == characteristicId); // Todo: Try to replace with a single query.
           }
    
           return characteristicValues;
    }

    Драсьте, нашёл в коде такую вот какашку. Как видите параметр allCharacteristicsValues реализует интерфейс IQuarable из EF. То бишь каждый раз, когда будет вызываться метод FirstOrDefault будет делаться запрос к базе. В идеале это должно было бы выглядеть так:

    var characteristicValues = allCharacteristicValues.Where(cv => cv.CharacteristicId == characteristicId && userIds.Contains(cv.UserId));

    Но при такой реализации размер масива пользователей и значение может разниться:

    Values:
    val1
    val2
    val3

    Users:
    1
    2
    3
    4
    5

    Для первого же варианта результат будет выглядеть так:
    Values:
    val1
    val2
    val3
    null
    null

    Users:
    1
    2
    3
    4
    5


    Собственно всё )))) Надеюсь подсоветуете чего-нибудь хорошего ;)

    walash, 20 Марта 2012

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

    +158

    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
    <?php
    class User
    {
       protected $_user_id;
       protected $_user_email;
       protected $_user_password;
     
       public function __construct($user_id)
       {
          $user_record = self::_getUserRecord($user_id);
          $this->_user_id = $user_record['id'];
          $this->_user_email = $user_record['email'];
          $this->_user_password = $user_record['password'];
       }
     
       public function __get($value) {}
       public function __set($name, $value) {}
     
       private static function _getUserRecord($user_id)
       {
          $user_record = array();
          switch($user_id) {
             case 1:
                $user_record['id'] = 1;
                $user_record['email'] = '[email protected]';
                $user_record['password'] = 'i like croissants';
                break;
     
             case 2:
                $user_record['id'] = 2;
                $user_record['email'] = '[email protected]';
                $user_record['password'] = 'me too!';
                break;
     
             case 'error':
                throw new Exception('Ошибка библиотеки SQL!');
                break;
          }
     
          return $user_record;
       }
    }
    ?>

    PHP исключения...

    Govnisti_Diavol, 19 Марта 2012

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

    +113

    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
    if ((label1.Text == "O") & (label2.Text == "O") & (label3.Text == "O") | ((label1.Text == "X") & (label2.Text == "X") & (label3.Text == "X")))
                {
                    label1.ForeColor = Color.Red;
                    label2.ForeColor = Color.Red;
                    label3.ForeColor = Color.Red;
                    win = false;
                }
                if ((label4.Text == "O") & (label5.Text == "O") & (label6.Text == "O") | ((label4.Text == "X") & (label5.Text == "X") & (label6.Text == "X")))
                {
                    label4.ForeColor = Color.Red;
                    label5.ForeColor = Color.Red;
                    label6.ForeColor = Color.Red;
                    win = false;
                }
                if ((label7.Text == "O") & (label8.Text == "O") & (label9.Text == "O") | ((label7.Text == "X") & (label8.Text == "X") & (label9.Text == "X")))
                {
                    label4.ForeColor = Color.Red;
                    label5.ForeColor = Color.Red;
                    label6.ForeColor = Color.Red;
                    win = false;
                }
                if ((label1.Text == "O") & (label4.Text == "O") & (label7.Text == "O") | ((label1.Text == "X") & (label4.Text == "X") & (label7.Text == "X")))
                {
                    label1.ForeColor = Color.Red;
                    label4.ForeColor = Color.Red;
                    label7.ForeColor = Color.Red;
                    win = false;
                }
                if ((label2.Text == "O") & (label5.Text == "O") & (label8.Text == "O") | ((label2.Text == "X") & (label5.Text == "X") & (label8.Text == "X")))
                {
                    label2.ForeColor = Color.Red;
                    label5.ForeColor = Color.Red;
                    label8.ForeColor = Color.Red;
                    win = false;
                }
                if ((label3.Text == "O") & (label6.Text == "O") & (label9.Text == "O") | ((label3.Text == "X") & (label6.Text == "X") & (label9.Text == "X")))
                {
                    label3.ForeColor = Color.Red;
                    label6.ForeColor = Color.Red;
                    label9.ForeColor = Color.Red;
                    win = false;
                }
                if ((label1.Text == "O") & (label5.Text == "O") & (label9.Text == "O") | ((label1.Text == "X") & (label5.Text == "X") & (label9.Text == "X")))
                {
                    label1.ForeColor = Color.Red;
                    label5.ForeColor = Color.Red;
                    label9.ForeColor = Color.Red;
                    win = false;
                }
                if ((label3.Text == "O") & (label5.Text == "O") & (label7.Text == "O") | ((label3.Text == "X") & (label5.Text == "X") & (label7.Text == "X")))
                {
                    label3.ForeColor = Color.Red;
                    label5.ForeColor = Color.Red;
                    label7.ForeColor = Color.Red;
                    win = false;
                }
            }
    
            private void label7_MouseDown(object sender, MouseEventArgs e)
            {
                if (win)
                    for (int i = 0; i < 1; i++)
                    {
                        if (label7.Text == "")
                        {
                            label7.Text = "X";
    
                            if ((label1.Text == "O") & (label2.Text == "O") & (label3.Text == ""))
                            {
                                label3.Text = "O"; break;
                            }
                            if ((label1.Text == "O") & (label2.Text == "") & (label3.Text == "O"))
                            {
                                label2.Text = "O"; break;
                            }
                            if ((label1.Text == "") & (label2.Text == "O") & (label3.Text == "O"))
                            {
                                label1.Text = "O"; break;
                            }

    Крестики-нолики с одного форума. Полная версия: http://pastebin.com/59W3547n

    P4R4, 19 Марта 2012

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

    +150

    1. 1
    2. 2
    3. 3
    4. 4
    <?php
    if ($_GET['type']) $link = 'type='.$_GET['type'];
    if ($_GET['cat']) $link = 'cat='.$_GET['cat'];
    if ($_GET['param']) $link = 'param='.$_GET['param'];

    isset, 19 Марта 2012

    Комментарии (6)
  10. Java / Говнокод #9713

    +72

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    /**
    	 * @return node with values
    	 */
    	public FQNode getValueGetter() {
    		return data;
    	}

    accessor c повышенной энтропией, хуле

    zloizerg, 19 Марта 2012

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