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

    +166

    1. 1
    2. 2
    3. 3
    4. 4
    //выяснение адреса сайта
     define( "SITE_URL", "http://" . str_replace( "-", "-", preg_replace('#^(.*)/[^/]*#', '\\1', $_SERVER['HTTP_HOST']).'/admin/' ) );
     define( "SITE_EDIT_URL", str_replace( "-", "-", preg_replace('#^(.*)/[^/]*#', '\\1', $_SERVER['HTTP_HOST']) ) ); //.$_SERVER['REQUEST_URI'])."/" ) );
     define( "SITE_EDIT_URL_HTTP", "http://" . str_replace( "-", "-", preg_replace('#^(.*)/[^/]*#', '\\1', $_SERVER['HTTP_HOST'])."/" ) ); //.$_SERVER['REQUEST_URI'])."/" ) );

    xynta, 27 Апреля 2010

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

    +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
    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
    require_once(HTML2PS_DIR.'utils_array.php');
    require_once(HTML2PS_DIR.'utils_graphic.php');
    require_once(HTML2PS_DIR.'utils_url.php');
    require_once(HTML2PS_DIR.'utils_text.php');
    require_once(HTML2PS_DIR.'utils_units.php');
    require_once(HTML2PS_DIR.'utils_number.php');
    require_once(HTML2PS_DIR.'value.color.php');
    require_once(HTML2PS_DIR.'config.parse.php');
    require_once(HTML2PS_DIR.'flow_context.class.inc.php');
    require_once(HTML2PS_DIR.'flow_viewport.class.inc.php');
    require_once(HTML2PS_DIR.'output._interface.class.php');
    require_once(HTML2PS_DIR.'output._generic.class.php');
    require_once(HTML2PS_DIR.'output._generic.pdf.class.php');
    require_once(HTML2PS_DIR.'output._generic.ps.class.php');
    require_once(HTML2PS_DIR.'output.pdflib.old.class.php');
    require_once(HTML2PS_DIR.'output.pdflib.1.6.class.php');
    require_once(HTML2PS_DIR.'output.fpdf.class.php');
    require_once(HTML2PS_DIR.'output.fastps.class.php');
    require_once(HTML2PS_DIR.'output.fastps.l2.class.php');
    require_once(HTML2PS_DIR.'output.png.class.php');
    // require_once(HTML2PS_DIR.'output.pcl.class.php');
    
    require_once(HTML2PS_DIR.'stubs.common.inc.php');
    require_once(HTML2PS_DIR.'media.layout.inc.php');
    require_once(HTML2PS_DIR.'box.php');
    require_once(HTML2PS_DIR.'box.generic.php');
    require_once(HTML2PS_DIR.'box.generic.formatted.php');
    require_once(HTML2PS_DIR.'box.container.php');
    require_once(HTML2PS_DIR.'box.generic.inline.php');
    require_once(HTML2PS_DIR.'box.inline.php');
    require_once(HTML2PS_DIR.'box.inline.control.php');
    require_once(HTML2PS_DIR.'font.class.php');
    require_once(HTML2PS_DIR.'font_factory.class.php');
    
    require_once(HTML2PS_DIR.'box.br.php');
    require_once(HTML2PS_DIR.'box.block.php');
    require_once(HTML2PS_DIR.'box.page.php');
    require_once(HTML2PS_DIR.'box.page.margin.class.php');
    require_once(HTML2PS_DIR.'box.body.php');
    require_once(HTML2PS_DIR.'box.block.inline.php');
    require_once(HTML2PS_DIR.'box.button.php');
    require_once(HTML2PS_DIR.'box.button.submit.php');
    require_once(HTML2PS_DIR.'box.button.reset.php');
    require_once(HTML2PS_DIR.'box.checkbutton.php');
    require_once(HTML2PS_DIR.'box.form.php');
    require_once(HTML2PS_DIR.'box.frame.php');
    require_once(HTML2PS_DIR.'box.iframe.php');
    require_once(HTML2PS_DIR.'box.input.text.php');
    require_once(HTML2PS_DIR.'box.input.textarea.php');
    require_once(HTML2PS_DIR.'box.input.password.php');
    require_once(HTML2PS_DIR.'box.legend.php');
    require_once(HTML2PS_DIR.'box.list-item.php');
    require_once(HTML2PS_DIR.'box.null.php');
    require_once(HTML2PS_DIR.'box.radiobutton.php');
    require_once(HTML2PS_DIR.'box.select.php');
    require_once(HTML2PS_DIR.'box.table.php');
    require_once(HTML2PS_DIR.'box.table.cell.php');
    require_once(HTML2PS_DIR.'box.table.cell.fake.php');
    require_once(HTML2PS_DIR.'box.table.row.php');
    require_once(HTML2PS_DIR.'box.table.section.php');
    
    require_once(HTML2PS_DIR.'box.text.php');
    require_once(HTML2PS_DIR.'box.text.string.php');
    require_once(HTML2PS_DIR.'box.field.pageno.php');
    require_once(HTML2PS_DIR.'box.field.pages.php');
    ........
    и так до 284й строки включительно...

    в самописном модуле к Drupal нашел сий шедевр

    kemerov4anin, 27 Апреля 2010

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

    +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
    function month($n){
    	switch ($n) {
    		case  1: $m = "сiчнi"  ; break;
    		case  2: $m = "лютому"   ; break;    
    		case  3: $m = "березнi"; break;                                                            
    		case  4: $m = "квiтнi" ; break;
    		case  5: $m = "травнi" ; break;
    		case  6: $m = "червнi"  ; break;
    		case  7: $m = "липнi" ; break;
    		case  8: $m = "серпнi" ; break;
    		case  9: $m = "вереснi"; break;
    		case 10: $m = "жовтнi" ; break;
    		case 11: $m = "листопадi"; break;
    		case 12: $m = "груднi" ; break;
    	}
    return $m;
    }
    function month2($n)
    {
    switch ($n) 
    	{
    		case  1: $m = "сiчень"  ; break;
    		case  2: $m = "лютий"   ; break;    
    		case  3: $m = "березень"; break;                                                            
    		case  4: $m = "квiтень" ; break;
    		case  5: $m = "травень" ; break;
    		case  6: $m = "червень"  ; break;
    		case  7: $m = "липень" ; break;
    		case  8: $m = "серпень" ; break;
    		case  9: $m = "вересень"; break;
    		case 10: $m = "жовтень" ; break;
    		case 11: $m = "листопад"; break;
    		case 12: $m = "грудень" ; break;
    	}
    return $m;
    }
    /*... всяко разно ...*/
    if($month==1)$month="сiчнi";
    if($month==2)$month="лютому";
    if($month==3)$month="березнi";
    if($month==4)$month="квiтнi";
    if($month==5)$month="травнi";
    if($month==6)$month="червнi";
    if($month==7)$month="липнi";
    if($month==8)$month="серпнi";
    if($month==9)$month="вереснi";
    if($month==10)$month="жовтнi";
    if($month==11)$month="листопадi";
    if($month==12)$month="груднi";
    // дебажный комментарий тут был
    if($month1==1)$month1="сiчнi";
    if($month1==2)$month1="лютому";
    if($month1==3)$month1="березнi";
    if($month1==4)$month1="квiтнi";
    if($month1==5)$month1="травнi";
    if($month1==6)$month1="червнi";
    if($month1==7)$month1="липнi";
    if($month1==8)$month1="серпнi";
    if($month1==9)$month1="вереснi";
    if($month1==10)$month1="жовтнi";
    if($month1==11)$month1="листопадi";
    if($month1==12)$month1="груднi";
    /*...еще немного...*/
    if($month==1)$month1="сiчнi";
    if($month==2)$month1="лютому";
    if($month==3)$month1="березнi";
    if($month==4)$month1="квiтнi";
    if($month==5)$month1="травнi";
    if($month==6)$month1="червнi";
    if($month==7)$month1="липнi";
    if($month==8)$month1="серпнi";
    if($month==9)$month1="вереснi";
    if($month==10)$month1="жовтнi";
    if($month==11)$month1="листопадi";
    if($month==12)$month1="груднi";

    Werdn, 26 Апреля 2010

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

    +169

    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
    <div class="filterPanel" style="width:250px;">
    	<div class="filterComboBoxCaption">Диапазон времени:</div>
    	с: <select name="timeBeginFl" id="timeBeginFlId" style="width:80px;" onChange="javascript:resetTimes();">		
    		<option value="07:00:00" {if $object.timeBeginFl=="07:00:00"}selected{/if}>07:00</option>
    		<option value="07:30:00" {if $object.timeBeginFl=="07:30:00"}selected{/if}>07:30</option>
    		<option value="08:00:00" {if $object.timeBeginFl=="08:00:00"}selected{/if}>08:00</option>
    		<option value="08:30:00" {if $object.timeBeginFl=="08:30:00"}selected{/if}>08:30</option>
    		<!-- ещё N таких же строчек -->
    		<option value="05:00:00" {if $object.timeBeginFl=="05:00:00"}selected{/if}>05:00</option>
    		<option value="05:30:00" {if $object.timeBeginFl=="05:30:00"}selected{/if}>05:30</option>
    		<option value="06:00:00" {if $object.timeBeginFl=="06:00:00"}selected{/if}>06:00</option>
    		<option value="06:30:00" {if $object.timeBeginFl=="06:30:00"}selected{/if}>06:30</option>
    	</select>
    	по: <select name="timeEndFl" id="timeEndFlId" style="width:80px;">				
    		<option value="07:30:00" {if $object.timeEndFl=="07:30:00"}selected{/if}>07:30</option>
    		<option value="08:00:00" {if $object.timeEndFl=="08:00:00"}selected{/if}>08:00</option>
    		<option value="08:30:00" {if $object.timeEndFl=="08:30:00"}selected{/if}>08:30</option>
    		<option value="09:00:00" {if $object.timeEndFl=="09:00:00"}selected{/if}>09:00</option>
    		<!-- ещё N таких же строчек -->
    		<option value="05:00:00" {if $object.timeEndFl=="05:00:00"}selected{/if}>05:00</option>
    		<option value="05:30:00" {if $object.timeEndFl=="05:30:00"}selected{/if}>05:30</option>
    		<option value="06:00:00" {if $object.timeEndFl=="06:00:00"}selected{/if}>06:00</option>
    		<option value="06:30:00" {if $object.timeEndFl=="06:30:00"}selected{/if}>06:30</option>
    	</select>
    </div>

    Из шаблонов под Smarty.

    _shitCoder, 26 Апреля 2010

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

    +161

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    $q = mysql_query("select * from users where `login`='$login';") or die (
    $err = mysql_error();
    $fp = fopen ("mysql_logs/mysql_error.log", "a+"); 
    fwrite ($fp, "".$date." - ".err."");
    fclose ($fp);
    header('Location: index.php?mysql_error'));

    DmitryDick, 25 Апреля 2010

    Комментарии (13)
  6. PHP / Говнокод #3104

    +164

    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
    <?php  
    if (isset($_POST['name'])) 
    { 
    $name = $_POST['name']; 
    } 
    if(!empty($_POST['name']))  
    { 
    $name = 'Гость'; 
    } 
    else 
    { 
    header("location: ./"); 
    } 
    if (isset($_POST['message'])) 
    { 
    $message = $_POST['message']; 
    $message = preg_replace('/[^0-9a-zа-я]/i', '', $string); 
    } 
    if(!empty($_POST['message'])) 
    { 
    $message = $_POST['message']; 
    } 
    else 
    { 
    header("location: ./"); 
    } 
    $db = mysql_connect("localhost", "book", "book"); 
    mysql_select_db("book", $db); 
    $result = mysql_query("INSERT INTO book (name, message) VALUES ('$name', '$message') "); 
    if ($result == true) 
    { 
    header("location: ./"); 
    } 
    else 
    { 
    echo 'Ошибка! Сообщение не добавлено'; 
    } 
    ?>

    Шедевр, на одном форуме встретил =)

    lugaro, 24 Апреля 2010

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

    +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
    if ($list[0]["item_stat"] != 'Этот предмет не дает бонусы!') {
                            $stat = explode(", ", $list[0]["item_stat"]);
                            $numstat = explode(", ", $list[0]["item_num_stat"]);
    
                            if (isset($stat[0])) {
                                $bonus = substr($numstat[0], 1);
                                $rest = substr($numstat[0], 0, 1);
    
                                echo (''.namegamewords($stat[0]).': <span style="color:orange">'.$rest.''.$bonus.'</span>');
    
                            }
    
                            if (isset($stat[1])) {
                                $bonus1 = substr($numstat[1], 1);
                                $rest1 = substr($numstat[1], 0, 1);
                                echo (' '.namegamewords($stat[1]).': <span style="color:orange">'.$rest1.''.$bonus1.'</span>');
                            }
                        }

    Первая строка...

    WinnerWolf, 23 Апреля 2010

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

    +172

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    $pattern = "/\w{0,5}[хx]([хx\s\!@#\$%\^&*+-\|\/]{0,6})[уy]([уy\s\!@#\$%\^&*+-\|\/]{0,6})[ёiлeеюийя]\w{0,7}|\w{0,6}[пp]([пp\s\!@#\$%\^&*+-\|\/]{0,6})[iие]([iие\s\!@#\$%\^&*+-\|\/]{0,6})[3зс]([3зс\s\!@#\$%\^&*+-\|\/]{0,6})[дd]\w{0,10}|[сcs][уy]([уy\!@#\$%\^&*+-\|\/]{0,6})[4чkк]\w{1,3}|\w{0,4}[bб]([bб\s\!@#\$%\^&*+-\|\/]{0,6})[lл]([lл\s\!@#\$%\^&*+-\|\/]{0,6})[yя]\w{0,10}|\w{0,8}[её][bб][лске@eыиаa][наи@йвл]\w{0,8}|\w{0,4}[еe]([еe\s\!@#\$%\^&*+-\|\/]{0,6})[бb]([бb\s\!@#\$%\^&*+-\|\/]{0,6})[uу]([uу\s\!@#\$%\^&*+-\|\/]{0,6})[н4ч]\w{0,4}|\w{0,4}[еeё]([еeё\s\!@#\$%\^&*+-\|\/]{0,6})[бb]([бb\s\!@#\$%\^&*+-\|\/]{0,6})[нn]([нn\s\!@#\$%\^&*+-\|\/]{0,6})[уy]\w{0,4}|\w{0,4}[еe]([еe\s\!@#\$%\^&*+-\|\/]{0,6})[бb]([бb\s\!@#\$%\^&*+-\|\/]{0,6})[оoаa@]([оoаa@\s\!@#\$%\^&*+-\|\/]{0,6})[тnнt]\w{0,4}|\w{0,10}[ё]([ё\!@#\$%\^&*+-\|\/]{0,6})[б]\w{0,6}|\w{0,4}[pп]([pп\s\!@#\$%\^&*+-\|\/]{0,6})[иeеi]([иeеi\s\!@#\$%\^&*+-\|\/]{0,6})[дd]([дd\s\!@#\$%\^&*+-\|\/]{0,6})[oоаa@еeиi]([oоаa@еeиi\s\!@#\$%\^&*+-\|\/]{0,6})[рr]\w{0,12}/i";
    
                if(preg_match($pattern, $text)) {
                    $reason = 'мат';
                    unset ($text);
                    $text = '<b>пользователь был забанен, причина: ';
                    $text .= $reason;
                    $text .= '</b>';
                    $user_ban = true;
                }

    Вот такая защита от мата стоит в чате одной браузерной игрушки.

    WinnerWolf, 23 Апреля 2010

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

    +174

    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
    $monster=Base2('user', 'bot=1,bot_npc=0,map='.$userInfo[0]['user_map']);
        if ((count($monster)<1) or $monster==FALSE) {
            say('На этой терретории нет монстров');
        }
        else {
            asort($monster);
            if((rand(1,1)) == (rand(1,1)) && isset($monster[1])) {
                massMonsterBattle($monster, $userInfo);
            }else {
                //Если боты найдены - запускаем функцию начала боя с ботом
                singleFightWithTheBot($monster, $userInfo);
            }
        }

    Небольшой кусок кода из одной браузерной игрушки. Строка 7 порадовала весь наш отдел.

    WinnerWolf, 23 Апреля 2010

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

    +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
    if ($key>0)
    {
    if (strpos ($payload['from'],'conference') > 1)
    {
    if (strlen ($payload['role']) >1 )
    {
    if (strlen ($payload['jid']) >1 )
    {
    if (strpos ($payload['jid'],'@') > 1)
    {
    $this->role_st[$key] = $payload['from'];
    $this->role_st[$key+1] = $payload['jid'];
    $this->role_st[$key+2] = $payload['role'];
    }
    }
    }
    }
    }
    else
    {
    if (strpos ($payload['from'],'conference') > 1)
    {
    if (strlen ($payload['role']) >1 )
    {
    if (strlen ($payload['jid']) >1 )
    {
    if (strpos ($payload['jid'],'@') > 1)
    {
    array_push ($this->role_st, $payload['from']);
    array_push ($this->role_st, $payload['jid']);
    array_push ($this->role_st, $payload['role']);
    }
    }
    }
    }
    }

    Йа матрешко

    Безымянный, 23 Апреля 2010

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