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

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

    +118

    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
    if(wordApp != null)
                    {
                        try
                        {
                            if(isNewApp && wordApp.Documents.Count == 0)
                            {
                                object arg1 = Word.WdSaveOptions.
                                                wdDoNotSaveChanges;
                                object arg2 = null;
                                object arg3 = null;
                                wordApp.Quit(ref arg1, ref arg2, ref arg3);
    
                                // Wait until Word shuts down.
    
                                for(;;)
                                {
                                    Thread.Sleep(100);
                                    try
                                    {
                                        // When word shuts down this call 
    
                                        // throws an exception.
    
                                        string dummy = wordApp.Version;
                                    }
                                    catch
                                    {
                                        break;
                                    }
                                }
                            }
                        }
                        catch {}
    
                        wordApp = null;
                    }

    Вот такой вот Dispose для ворда
    http://www.codeproject.com/KB/cs/winwordloader.aspx

    Lennis, 21 Ноября 2010

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

    +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
    // the next few lines do the fiddling required to make sure the data 
    // looks right, whether it's viewed via the RSS feed or via the database
    $longpost=str_replace("<br />", "\n", $post);
    $shortpost=substr($post,0,600);
    $shortpost=str_replace("<br />", "\n", $shortpost);
    $pass=$_POST["pass"];
    if ($pass == $password) {
    	include "db.inc";
    	// this line actually inserts the data
    	mysql_query("INSERT INTO entries VALUES (NULL, '$title', '$post')");
    	$getid=mysql_query("SELECT id FROM entries WHERE title='$title'");
    	$myrow=mysql_fetch_array($getid);
    	$postid=$myrow["id"];
    	// from here on in, we're building the RSS feed.
    	$arrFp = file("rss/feed.xml");
    	$lines = count($arrFp);
    	$insertat = $lines-2;
    	for ($i=0; $i<$insertat; $i++) {
    		$rsstext=$rsstext.$arrFp[$i];
    	}
    	$rsstext=$rsstext."<item>\n";
    	$rsstext=$rsstext."<title>".stripslashes($title)."</title>\n";
    	$rsstext=$rsstext."<description>".stripslashes($shortpost);
    	if (strlen($shortpost)<strlen($longpost)) {
    		$rsstext=$rsstext."...";
    	}
    	$rsstext=$rsstext."</description>\n";
    	$rsstext=$rsstext."<link>$url/comment.php?post=$postid</link>\n";
    	$rsstext=$rsstext."</item>\n";
    	$rsstext=$rsstext."</channel>\n";
    	$rsstext=$rsstext."</rss>";
    	$fp=fopen("rss/feed.xml", "w");
    	fwrite( $fp, $rsstext );
    	fclose($fp);
    	echo "Post successfully submitted!";
    } else {
    	echo "You are not authorised to post to this server!";
    }

    Создаём RSS-ленту.

    Yurik, 20 Ноября 2010

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

    +121

    1. 1
    2. 2
    3. 3
    4. 4
    if (Convert.ToBoolean(ViewState["IsProgram"]) != null && Convert.ToBoolean(ViewState["IsProgram"]))
    {
        // do work
    }

    Это взорвало мой мозг...

    rstrg, 13 Ноября 2010

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

    +166

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    11. 11
    12. 12
    <?php
    # bla bla bla...
    public function __construct ($dbname, $host = null, $user = null, $pass = null) {
    
    	$numargs = func_num_args ();
    	if ($numargs == 1)
    		parent::__construct ($dbname);
    	else
    		parent::__construct ($dbname, $host = null, $user = null, $pass = null);
            $this->begin = time ();
      }
    # bla bla bla...

    "гениальный" вызов конструктора!

    dwinner, 12 Ноября 2010

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

    +130

    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
    if ((!(((constmonth == 1) && (Finalday > 31))
    || ((constmonth == 2) && (Finalyear % 4 == 0) && (Finalday > 29))
    || ((constmonth == 2) && (Finalyear % 4 != 0) && (Finalday> 28))
    || ((constmonth == 3) && (Finalday > 31))
    || ((constmonth == 4) && (Finalday > 30))
    || ((constmonth == 5) && (Finalday > 31))
    || ((constmonth == 6) && (Finalday > 30))
    || ((constmonth == 7) && (Finalday > 31))
    || ((constmonth == 8) && (Finalday > 31))
    || ((constmonth == 9) && (Finalday > 30))
    || ((constmonth == 10) && (Finalday > 31))
    || ((constmonth == 11) && (Finalday > 30))
    || ((constmonth == 12) && (Finalday > 31))))
    && ((((constmonth + 1 == 1) && (Finalday > 31))
    || ((constmonth + 1 == 2) && (Finalyear % 4 == 0) && (Finalday > 29))
    || ((constmonth + 1 == 2) && (Finalyear % 4 != 0) && (Finalday > 28))
    || ((constmonth + 1 == 3) && (Finalday > 31))
    || ((constmonth + 1 == 4) && (Finalday > 30))
    || ((constmonth + 1 == 5) && (Finalday > 31))
    || ((constmonth + 1 == 6) && (Finalday > 30))
    || ((constmonth + 1 == 7) && (Finalday > 31))
    || ((constmonth + 1 == 8) && (Finalday > 31))
    || ((constmonth + 1 == 9) && (Finalday > 30))
    || ((constmonth + 1 == 10) && (Finalday > 31))
    || ((constmonth + 1 == 11) && (Finalday > 30))
    || ((constmonth + 1 == 12) && (Finalday > 31)))))
    {
    if ((constmonth + 1 == 2) && (Finalyear % 4 == 0)) { Finalday = 29; }
    if ((constmonth + 1 == 2) && (Finalyear % 4 != 0)) { Finalday = 28; }
    
    switch (constmonth + 1)
    {
    case 1: Finalday = 31; break;
    case 3: Finalday = 31; break;
    case 4: Finalday = 30; break;
    case 5: Finalday = 31; break;
    case 6: Finalday = 30; break;
    case 7: Finalday = 31; break;
    case 8: Finalday = 31; break;
    case 9: Finalday = 30; break;
    case 10: Finalday = 31; break;
    case 11: Finalday = 30; break;
    case 12: Finalday = 31; break;
    }
    //constmonth++;

    GreBer, 11 Ноября 2010

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

    +146

    1. 1
    $news = new news($_GET["news"]);

    Обьект класса news. Выводит нужную новость в соответствии с get запросом.

    Somov, 09 Ноября 2010

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

    +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
    // юзер просит :
    // "Дату выводит как записано в базе к примеру 2010-10-26 15:17:01. А мне нужно вывести Только 15:17. Как так сделать не меняя записи в базе?"
    $infochat=SQLrow("select datesend, id_user, message from minichat order by datesend desc limit 0,1");
    
    // и варианты
    
    $exp=explode(" ", $date); 
    $exp=explode(":", $exp); 
    echo $exp[0].':'.$exp[1];
    
    //.........
    
    $exp=substr("$date", 11, 3); 
    echo $exp;
    
    // :D

    С одного форума

    Morgan, 26 Октября 2010

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

    +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
    protected function _defineUser()
        {
            if ($this->_getParam('controller') == 'profile')
            {
                // check for mb and sf
                if ($this->_getParam('action') == 'mb')
                {
                    $user = new Dbrow_User();
                    $this->userId = $user->getIdByMbId($this->currentId);
                }
                if ($this->_getParam('action') == 'sf')
                {
                    $user = new Dbrow_User();
                    $this->userId = $user->getIdBySfId($this->currentId);
                }
            }
            
            if ($this->userId <= 0)
            {
                $this->userId = (int)$this->_getParam('userId');
            }
            if ($this->userId <= 0)
            {
                $this->userId = (int)$this->currentId;
            }
            if ($this->userId <= 0 && Static_Auth::isLogged())
            {
                $this->user   = Static_Auth::getUser();
                $this->userId = $this->user->id;
            }
                else 
                {
                    $this->user = new Dbrow_User();
                    $this->user->loadById($this->userId, array());
                }
                
            $this->view->user = $this->user;
    
            self::$curUser = $this->user;
            //var_dump($this->user->parentEssences);
            //exit;
        }

    just piece of shit

    mykola, 25 Октября 2010

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

    +144

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    int X,Y,Z;
    X=StrToInt(Edit1->Text);
    Y=StrToInt(Edit2->Text);
    Z=X+Y;
    Edit3->Text=IntToStr(Z),

    Мартин, 23 Октября 2010

    Комментарии (10)
  11. Perl / Говнокод #4421

    −120

    1. 1
    print qq(<div id="Layer26" class="blank" style="left:170mm; top:96mm; width:95mm;">$base1[17]);

    Верстаем в миллиметрах, используем магические числа и т.п.

    hdkeeper, 22 Октября 2010

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