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

    +159

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    7. 7
    protected function readConfig($configPath) {
        $ini = parse_ini_file($configPath);
        foreach ($ini as $key => $value) {
            $config[$key] = $value;
        }
        return $config;
    }

    xarper, 21 Июня 2011

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

    +120

    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
    var trimmedKey = Regex.Split(key, @"\.").Last();
                    if (_options.Any(o => o == ModelBinderOptions.ExpectUnderLineSymbolAsPrefixDelimiter))
                        trimmedKey = Regex.Split(trimmedKey, "_").Last();
    
                    if (_allRequiredParameters.Any(p => p.Key.ToLower() == trimmedKey.ToLower()))
                    {
                        var param = _allRequiredParameters.Single(p => p.Key.ToLower() == trimmedKey.ToLower());
    
                        try
                        {
                            if (param.Value != typeof(string))
                            {
                                if (Nullable.GetUnderlyingType(param.Value) != null)
                                {
                                    try
                                    {
                                        var parseMethod = Nullable.GetUnderlyingType(param.Value).GetMethods().Where(m => m.Name == "Parse").First(m => m.GetParameters().Count() == 1 && m.GetParameters().First().ParameterType == typeof(string));
                                        var value = parseMethod.Invoke(null, new object[] { form[key] });
                                        formValues.Add(param.Key, value);
                                    }
                                    catch(Exception)
                                    {
                                        formValues.Add(param.Key, null);
                                    }
                                }
                                else
                                {
                                    var parseMethod = param.Value.GetMethods().Where(m => m.Name == "Parse").First(m => m.GetParameters().Count() == 1 && m.GetParameters().First().ParameterType == typeof(string));
                                    var value = parseMethod.Invoke(null, new object[] { form[key] });
                                    formValues.Add(param.Key, value);
                                }
                                
                            }
                            else
                            {
                                formValues.Add(param.Key, form[key]);
                            }
                        }
                        catch (Exception)
                        {
                            // Если произошла ошибка парсинга - печально, но ничего не поделать
                        }
                    }

    Фееричный парсер

    dans, 21 Июня 2011

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

    +171

    1. 1
    var e=("article,aside,footer,header,nav,section").split(',');

    Найдено в дебрях одного сайта.

    lucidfox, 21 Июня 2011

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

    +150

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    $black = "eval|file_get_contents|mysql_(.*?)|include|require|readfile|show_source|highlight|import_request_variables|extract|parse_str|assert|passthru|exec|system|shell_exec|proc_open|fopen|echo";
    
    if(preg_match("#\<\?(.*?)($black)(.*?)\?\>#i", $template)){
    exit ("1");
    break;
    }

    substr, 20 Июня 2011

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

    +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
    #include <math.h>
    #include <iostream>
    using namespace std;
    void main()
    { int month,day;
            cin>>month,day;
            int den=1;
            switch(month)
    {       case 1: cout<<"month: "<<month<<endl<<"day: "<<day+1;
    if(day==31){cout<<"month: "<<month+1<<endl<<den;}
    break;
            case 2: cout<<"month: "<<month<<endl<<"day: "<<day+1;
            if(day==28){cout<<"month: "<<month+1<<endl<<"day: "<<den;}
    break;
            case 3:cout<<"month: "<<month<<endl<<"day: "<<day+1;
                    if(day==31){cout<<"month: "<<month+1<<endl<<"day: "<<den;}
    break;
            case 4:cout<<"month: "<<month<<endl<<"day: "<<day+1;
                    if(day==30){cout<<"month: "<<month+1<<endl<<"day: "<<den;}
    break;
            case 5: cout<<"month: "<<month<<endl<<"day: "<<day+1;
                    if(day==31){cout<<"month: "<<month+1<<endl<<"day: "<<den;}
    break;
            case 6: cout<<"month: "<<month<<endl<<"day: "<<day+1;
                    if(day==30){cout<<"month: "<<month+1<<endl<<"day: "<<den;}
    break;
            case 7: cout<<"month: "<<month<<endl<<"day: "<<day+1;
                    if(day==31){cout<<"month: "<<month+1<<endl<<"day: "<<den;}
    break;
            case 8: cout<<"month: "<<month<<endl<<"day: "<<day+1;
                    if(day==31){cout<<"month: "<<month+1<<endl<<"day: "<<den;}
    break;
            case 9: cout<<"month: "<<month<<endl<<"day: "<<day+1;
                    if(day==30){cout<<"month: "<<month+1<<endl<<"day: "<<den;}
    break;
            case 10: cout<<"month: "<<month<<endl<<"day: "<<day+1;
                    if(day==31){cout<<"month: "<<month+1<<endl<<"day: "<<den;}
    break;
            case 11: cout<<"month: "<<month<<endl<<"day: "<<day+1;
                    if(day==30){cout<<"month: "<<month+1<<endl<<"day: "<<den;}
    break;
            case 12: cout<<"month: "<<month<<endl<<"day: "<<day+1;
                    if(day==31){cout<<"month: "<<month+1<<endl<<"day: "<<den;}
                    
                                    
    }       
     
    cin.get();
            cin.get();
    }

    Juris_Kabanis, 20 Июня 2011

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

    +82

    1. 1
    2. 2
    3. 3
    /*
            todo it seems that code below will be right, when client will be changed
    */

    Вот такой емкий комментарий перед 200 закоментированными строками кода

    galak, 20 Июня 2011

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

    +147

    1. 1
    2. 2
    3. 3
    if ($a = 1) {
    	...бла-бла-бла
    }

    nislova, 20 Июня 2011

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

    +156

    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
    <?php 
    	if(isset($_GET["status"])) {
    		//Определяем переменные
    		$user_id = $_GET['user_id'];
    		$operator_id = $_GET['operator_id'];
    		$smsid = $_GET['smsid'];
    		$operator_id_str = $_GET['operator_id_str'];
    		$num = $_GET['num'];
    		$msg_trans = $_GET['msg_trans'];
    		$msg = $_GET['msg'];
    		$cost_rur = $_GET['cost_rur'];
    		$ratepoints = $cost_rur; //Рейтинг = стоимость смс
    		
    		//Подключаемся к бд
    		$dblocation = "localhost";	 // Имя сервера
    		$dbuser = "****";          // Имя пользователя
    		$dbpasswd = "******";            // Пароль
    		$dbname = "******"; //Имя бд
    		$dbcnx = @mysql_connect($dblocation,$dbuser,$dbpasswd);
    		if (!$dbcnx) {
    			  echo("Не удалось установить соеденение");
    			  exit();
    		} else  {
    						if (!@mysql_select_db($dbname, $dbcnx)) {
    							  echo  "База данных недоступна <br />" ;
    							  exit();
    						} else {
    							//Проверяем зарегестрирован ли пользователь
    							$changeuser = @mysql_query("SELECT * FROM jos_users WHERE  username='$user_id'");
    							if(@mysql_num_rows($changeuser) > 0) {
    							//Пользователь зарегестрирован
    								@mysql_query("INSERT INTO sms (operator_id, operator_id_str, user_id, smsid, num, msg_trans, msg, cost_rur) VALUES ('$operator_id','$operator_id_str','$user_id','$smsid','$num','$msg_trans','$msg','$cost_rur')"); //Добавляем смс
    								@mysql_query("UPDATE jos_users SET rate = rate +1 WHERE username='$user_id'"); //Увеличиваем рейтинг
    								@mysql_query("UPDATE jos_users SET sms = sms +1 WHERE username='$user_id'"); //Увеличиваем кол-во смс
    								$rate = @mysql_fetch_array(@mysql_query("SELECT rate FROM jos_users WHERE username='$user_id'"));
    								echo "SMS Send OK rate +1 your rate: ".$rate['rate']."";
    							} else {
    							/*Пользователь не зарегестрирован,
    							Регестрируем пользователя*/
    							$regdate = date("Y-m-d  H:i:s");
    							
    							//Генерируем пароль
    							$pass = rand(10000, 99999);
    							$sqlpass = md5($pass);
    							
    							//Добавляем пользователя
    								@mysql_query("INSERT INTO jos_users (name, username, password, usertype, gid, registerDate, lastvisitDate) VALUES ('$user_id', '$user_id', '$sqlpass', 'Registered', '18', '$regdate', '$regdate')");
    								$getnewuserid = @mysql_fetch_array(@mysql_query("SELECT id FROM jos_users WHERE username='$user_id'"));
    								@mysql_query("INSERT INTO jos_core_acl_aro (section_value, value, order_value, name, hidden) VALUES ('users', '{$getnewuserid['id']}', '0', '$user_id', '0')");
    								$getaro_id = @mysql_fetch_array(@mysql_query("SELECT id FROM jos_core_acl_aro WHERE name='$user_id'"));
    								@mysql_query("INSERT INTO jos_core_acl_groups_aro_map (group_id, aro_id) VALUES ('18', '{$getaro_id['id']}')");
    								
    								@mysql_query("INSERT INTO sms (operator_id, operator_id_str, user_id, smsid, num, msg_trans, msg, cost_rur) VALUES ('$operator_id','$operator_id_str','$user_id','$smsid','$num','$msg_trans','$msg','$cost_rur')"); 
    								@mysql_query("UPDATE jos_users SET rate = rate +1 WHERE username='$user_id'");
    								@mysql_query("UPDATE jos_users SET sms = sms +1 WHERE username='$user_id'");
    								$rate = @mysql_fetch_array(@mysql_query("SELECT rate FROM jos_users WHERE username='$user_id'"));
    								echo "SMS Register complete. Login: ".$user_id." Pass: ".$pass." Your rate: ".$rate['rate']."";
    							}
    									}
    			}
    	}
    ?>

    phplamer, 20 Июня 2011

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

    +165

    1. 1
    2. 2
    3. 3
    ASSERT(mStartSamples.size() == mFades.size() == mIsFadeIns.size() == inOutBlock->GetNumChannels());
    
    ASSERT(iGainData.size() == mSizes.size() == inStartSamples.size() != 0);

    Краткость - сестра таланта

    victor_r, 20 Июня 2011

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

    +76

    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
    public class ValueList< T > implements Cloneable
    {
        public ValueList() { }
    
        public void addValue( final T value ) {
            list.add( value );
        }
    
        @Override
        @SuppressWarnings( { "unchecked", "unchecked" } )
        public Object clone() throws CloneNotSupportedException {
            super.clone();
            ValueList< T > object = new ValueList< T >();
            List< T > objectList = object.getList();
            objectList = ( List< T > )list.clone();
            for( int index = 0; index < list.size() ; ++index ) {
                objectList.set( index, ( Object )list.get( index ).clone() );
            }
            return object;
        }
    
        public List< T > getList() {
            return list;
        }
    
        private ArrayList< T > list = new ArrayList< T >();
    }

    Человек из соседнего отдела порадовал...

    SadKo, 20 Июня 2011

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