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

    В номинации:
    За время:
  2. 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)
  3. 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)
  4. 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)
  5. 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)
  6. PHP / Говнокод #4574

    +146

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

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

    Somov, 09 Ноября 2010

    Комментарии (10)
  7. 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)
  8. 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)
  9. 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)
  10. 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)
  11. PHP / Говнокод #4385

    +125

    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
    <?
    # запускаем сессии
    session_start();
    # подключаем MySQL
    require "db.php";
    // Если существуют куки, то выполняем автовход!
    if(isset($_COOKIE['adminauto']))
    {$nik = $_COOKIE['adminnik'];
    $password = $_COOKIE['adminpassword'];
    $_SESSION['adminnik'] = $nik;
    $_SESSION['adminpassword'] = crc32(crypt(base64_encode(strrev(md5($password)))));
    }// Если переменные пустые, то запрещаем вход
    ....... Тут какое то говнишко 
    # если пользователь ввел данные, то проверяем их
    if(isset($go))
    {
    # принимаем данные через POST
    if (isset($_POST['nik'])) {$nik = $_POST['nik'];}
    if (isset($_POST['pass'])) {$pass = $_POST['pass'];}
    # проверяем нет ли пустых полей
    if(empty($nik) or empty($pass)) 
    {exit("<script language='javascript'>alert('Вы попытались получить доступ к Чату, но замечено, что Вы не ввели какое-то из полей, пожалуйста заполните их!');</script><head><meta http-equiv='refresh' content='0; URL=admin.php'></head>");}
    
    $result = mysql_query("SELECT nik,password FROM admin WHERE nik='$nik' and password='$pass'");
    if(mysql_num_rows($result) > 0) 
    { 
    
    $_SESSION['adminnik'] = $nik; 
    $_SESSION['adminpassword'] = crc32(crypt(base64_encode(strrev(md5($pass)))));}
    else {exit("<script language='javascript'>alert('Вы попытались получить доступ к Чату, но те данные которые Вы ввели, не совподают с правильными! Пожалуйста введите правильные!');</script><head><meta http-equiv='refresh' content='0; URL=admin.php'></head>");}}
    
    if( !isset($_SESSION['adminnik']) or !isset($_SESSION['adminpassword']) )  {
    echo "<br><br><br><br><br><br><br>
    <table bgcolor='#EAF3FF' width='300px' align='center' style='border:1px solid #000000; padding:10px;'>
    <tr><td><strong>Вход</strong></td></tr><br>
    <form method='post'><tr bgcolor='#F9F8FD'><td>
    <div style='font-size:11px; font-family:Verdana; color:#424242;'>Ваш ник:</div></td><td>
    <input style='border:1px solid #B3B9C3; font-size:12px;' type='text' name='nik'></td></tr>
    <tr bgcolor='#F9F8FD'><td>
    <div style='font-size:11px; font-family:Verdana; color:#424242;'>Ваш пароль:</div></td><td>
    <input style='border:1px solid #B3B9C3; font-size:12px;' type='password' name='pass'></td></tr><tr><td>
    <input type='checkbox' name='auto' cheked> Автовход<br>
    <input style='border:1px solid #000000; color:#3A4F6C; font-weight:700; padding:0px; background-color:#F0F5FA; margin-top:5px;' type='submit' name='go' value='Войти'></form>
    </td>
    </tr>
    </table>
    <br><table bgcolor='#EAF3FF' width='500px' align='center' style='border:1px solid #000000; padding:10px;'><tr align='center'><td><strong style='font-size:14px;'>Забыли пароль?</strong></td></tr><form method='post' action='newpass.php'><tr align='center'><td bgcolor='#F9F8FD' style='padding-bottom:7px;'><strong style='font-size:11px; font-family:Verdana;'>Введите Ваш email:   </strong><input type='text' name='email' style='border:1px solid #B3B9C3; font-size:11px; font-family:Verdana; padding:1px; margin-top:5px;'>  <input type='submit' style='border:1px solid #000000; color:#3A4F6C; font-weight:700; padding:0px; background-color:#F0F5FA; margin-top:5px;' name='newpass' value='Получить пароль!'></form></td></tr><tr><td align='center' style='font-size:11px; font-family:Verdana; color:#FF0000;'>* Вам на email будет выслан новый пароль!</td></tr></table>
    ";
    exit();
    }
    ?>

    Вот. это называется авто вход.

    Vasiliy, 18 Октября 2010

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