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

    +163

    1. 001
    2. 002
    3. 003
    4. 004
    5. 005
    6. 006
    7. 007
    8. 008
    9. 009
    10. 010
    11. 011
    12. 012
    13. 013
    14. 014
    15. 015
    16. 016
    17. 017
    18. 018
    19. 019
    20. 020
    21. 021
    22. 022
    23. 023
    24. 024
    25. 025
    26. 026
    27. 027
    28. 028
    29. 029
    30. 030
    31. 031
    32. 032
    33. 033
    34. 034
    35. 035
    36. 036
    37. 037
    38. 038
    39. 039
    40. 040
    41. 041
    42. 042
    43. 043
    44. 044
    45. 045
    46. 046
    47. 047
    48. 048
    49. 049
    50. 050
    51. 051
    52. 052
    53. 053
    54. 054
    55. 055
    56. 056
    57. 057
    58. 058
    59. 059
    60. 060
    61. 061
    62. 062
    63. 063
    64. 064
    65. 065
    66. 066
    67. 067
    68. 068
    69. 069
    70. 070
    71. 071
    72. 072
    73. 073
    74. 074
    75. 075
    76. 076
    77. 077
    78. 078
    79. 079
    80. 080
    81. 081
    82. 082
    83. 083
    84. 084
    85. 085
    86. 086
    87. 087
    88. 088
    89. 089
    90. 090
    91. 091
    92. 092
    93. 093
    94. 094
    95. 095
    96. 096
    97. 097
    98. 098
    99. 099
    100. 100
    <?php echo '<?xml version="1.0" encoding="utf-8"?>';?>
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="ru">
    <head>
    <title>День Победы! 66 лет со дня победы! 9 Мая!</title>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <style type="text/css">body{background:#000;}h1{color:#ff5500;}</style>
    </head>
    <body>
    <div style="text-align:center">
    <div style="padding-top:28%"><h1><?php
    class Main
    {
    var $timex;
    var $month;
    var $day;
    var $year;
    function win2uni($s)
    {
    $s = convert_cyr_string($s,'w','i');
    for ($result='', $i=0; $i<strlen ($s); $i++) {
    $charcode = ord($s[$i]);
    $result .= ($charcode>175)?"&#".(1040+($charcode-176)).";":$s[$i];
    }
    return $result;
    }
    function Main()
    {
    if ($this->GetDate())
    $this->TimeTo();
    return true;
    }
    function GetDate()
    {
    $this->month = '05';
    $this->day = '09';
    $this->year = '2011';
    return true;
    }
    function TimeTo()
    {
    $m = $this->month;
    $d = $this->day;
    $y = $this->year;
    $mn = date("m");
    $dn = date("d");
    $yn = date("y");
    $hh = date("H");
    $mm = date("i");
    $ss = date("s");
    $diff = mktime(23,59,59,$m,$d,$y)-mktime($hh,$mm,$ss,$mn,$dn,$yn);
    $days = $diff/60/60/24;
    $hours = $diff/60/60 - intval($days)*24;
    $minutes = $diff/60 - intval(intval($days*24)*60);
    $seconds = $diff - intval(intval(intval($days*24*60))*60);
    $text = "До Дня Победы (9 мая) осталось<br/>\n";
    $text.= round($days);
    $mins = round($days)."";
    if ($mins == "11" or $mins == "12" or $mins == "13" or $mins == "14") $text.= " дней "; else
    if (
    $mins[strlen($mins)-1] == "2"
    or $mins[strlen($mins)-1] == "3"
    or $mins[strlen($mins)-1] == "4")
    $text.= " дня "; else
    if($mins[strlen($mins)-1] == "1")
    $text.= " день "; else
    $text.= " дней ";
    $text.= round($hours);
    if (round($hours) == 1 or round($hours == 21)) $text.= " час "; else
    if (round($hours) == 2 or round($hours) == 3 or round($hours) == 4 or round($hours) == 22 or round($hours) == 23) $text.= " часа ";
    else $text.= " часов ";
    $text.= round($minutes);
    $mins = round($minutes)."";
    if ($mins == "11" or $mins == "12" or $mins == "13" or $mins == "14") $text.= " минут "; else
    if (
    $mins[strlen($mins)-1] == "2"
    or $mins[strlen($mins)-1] == "3"
    or $mins[strlen($mins)-1] == "4")
    $text.= " минуты "; else
    if($mins[strlen($mins)-1] == "1")
    $text.= " минута "; else
    $text.= " минут ";
    $text.= round($seconds);
    $mins = round($seconds)."";
    if ($mins == "11" or $mins == "12" or $mins == "13" or $mins == "14") $text.= " секунд "; else
    if (
    $mins[strlen($mins)-1] == "2"
    or $mins[strlen($mins)-1] == "3"
    or $mins[strlen($mins)-1] == "4")
    $text.= " секунды "; else
    if($mins[strlen($mins)-1] == "1")
    $text.= " секунда "; else
    $text.= " секунд ";
    echo $text;
    return true;
    }
    }
    $X = new Main();
    ?></h1></div>

    Заранее извиняюсь за "опять даты, опять php":)

    Отсчет времени до 9 мая
    http://dumpz.org/23155/

    rO_ot, 04 Июня 2011

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

    +147

    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
    <?php
    $this->phptal->id=$id;
    $this->phptal->returnid=$returnid;
    
    if(isset($params['catalogue']))
    {
    	if(isset($params['category']))
    	{
    		if(isset($params['news']))
    		{
    			$nid=(int)$params['news'];
    			require_once(cms_join_path($this->GetModulePath(), 'classes','dao', 'EventNewsDAO.php'));
    			$nldao=new EventNewsDAO($this);
    			$this->phptal->newsline=$nldao->get($nid);
    			echo $this->ProcessTalTemplate('admin/admin_newsline.tal.tpl');
    		}
    		else
    		{
    			$cid=(int)$params['catalogue'];
    			require_once(cms_join_path($this->GetModulePath(), 'classes','dao', 'EventCatalogueDAO.php'));
    			$cdao=new EventCatalogueDAO($this);
    			$this->phptal->catalogue=$cdao->get($cid);
    			require_once(cms_join_path($this->GetModulePath(), 'classes','dao', 'EventCategoryDAO.php'));
    			$ccdao=new EventCategoryDAO($this);
    			$this->phptal->categories=$ccdao->all($cid);
    
    			$ccid=(int)$params['category'];
    			$this->phptal->category=$ccdao->get($ccid);
    			require_once(cms_join_path($this->GetModulePath(), 'classes','dao', 'EventNewsDAO.php'));
    			$ndao=new EventNewsDAO($this);
    			$this->phptal->news=$ndao->all($ccid);
    			echo $this->ProcessTalTemplate('admin/admin_news.tal.tpl');
    		}
    	}
    	else
    	{
    		$cid=(int)$params['catalogue'];
    		require_once(cms_join_path($this->GetModulePath(), 'classes','dao', 'EventCatalogueDAO.php'));
    		$cdao=new EventCatalogueDAO($this);
    		$this->phptal->catalogue=$cdao->get($cid);
    		require_once(cms_join_path($this->GetModulePath(), 'classes','dao', 'EventCategoryDAO.php'));
    		$ccdao=new EventCategoryDAO($this);
    		$this->phptal->categories=$ccdao->all($cid);
    		echo $this->ProcessTalTemplate('admin/admin_categories.tal.tpl');
    	}
    }
    else
    {
    	require_once(cms_join_path($this->GetModulePath(), 'classes','dao', 'EventCatalogueDAO.php'));
    	$cdao=new EventCatalogueDAO($this);
    	$this->phptal->catalogues=$cdao->all();
    	echo $this->ProcessTalTemplate('admin/admin_catalogues.tal.tpl');
    }

    я молодец. наговнокодил как школьник.
    ветвистое ветвление + жуткая копипаста.
    буду это рефакторить, когда в целом закончу базовую функциональность.

    Lure Of Chaos, 04 Июня 2011

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

    +157

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    7. 7
    8. 8
    $opdirbase=opendir(H.'sys/fnc');
    while ($filebase=readdir($opdirbase))
    {
    if (eregi('\.php$',$filebase))
    {
    include_once(H.'sys/fnc/'.$filebase);
    }
    }

    Вот так вот инклюдится код в одной в вап cms.В дериктории файлы по 200-300кб.

    jQuery, 03 Июня 2011

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

    +158

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    {|if $message=="ok"|}
        <div style="text-align: center; padding:10px; margin:10px; color: white; font-weight: bold; background-color: green;">Your message has successfully been added.</div>
    {|/if|}
    {|if $message=="error"|}
        <div style="text-align: center; padding:10px; margin:10px; color: white; font-weight: bold; background-color: red;">Mistake. You filled out the wrong form.</div>
    {|/if|}

    Красивое использование CSS.

    max_wp, 03 Июня 2011

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

    +154

    1. 1
    2. 2
    3. 3
    public function assign($a, $b) {
        parent::assign($a, $b);
    }

    Из того же проекта.
    И все-таки хорошо, что программеры понимают ООП :-)

    max_wp, 03 Июня 2011

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

    +157

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    $deleteBasketElId = URLParser::GetParser()->getArgumentSecure('deleteelid');
    if ($deleteBasketElId){
        $html = 'бугога';
        print $html;
    }

    Откопано в старом проекте, который писали студийные недопрограммеры.

    max_wp, 03 Июня 2011

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

    +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
    // ...html-параша и верстка таблицей	
    <?php
    	
    	if (isset($charsetList)) {
    		echo "<tr>";
    		echo "<td class=\"inputfield\">";
    		echo __("Charset") . ":";
    		echo "</td>";
    		echo "<td>";
    		echo "<select id=\"DBCHARSET\">";
    		echo "<option></option>";
    		
    		$defaultCharSql = $conn->query("SHOW VARIABLES LIKE 'character_set_server'");
    		
    		if ($conn->isResultSet($defaultCharSql)) {
    			$defaultCharset = $conn->result($defaultCharSql, 0, "Value");
    		}
    		
    		foreach ($charsetList as $charset) {
    			echo "<option value=\"" . $charset . "\"";
    			
    			if (isset($defaultCharset) && $charset == $defaultCharset) {
    				echo ' selected="selected"';
    			}
    			
    			echo ">" . $charset . "</option>";
    		}
    		echo "</select>";
    		echo "</td>";
    		echo "</tr>";
    	}
    	
    	?>
    // ... html-параша

    Кусок кода системы управления MySQL. http://www.sqlbuddy.com/
    Посмотрел в код и потянуло блевать.

    Yurik, 03 Июня 2011

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

    +187

    1. 1
    2. 2
    3. 3
    if($query && !$query) {
        $query = null;
    }

    Оо

    jQuery, 02 Июня 2011

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

    +158

    1. 1
    2. 2
    3. 3
    {foreach from=$deal_data|array_slice:(($page_number - 1) * $deals_per_page):$deals_per_page item=deal name=deal_data}
    ...
    {/foreach}

    Зачем делать нормальный пейджинг когда и так работает? :)

    kovel, 02 Июня 2011

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

    +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
    $blocks = $this->dsp->db->select_array("select distinct B.*, BS.ALIGN_, BS.ORDER_, BS.PARAM_, BS.HTML_CLASS as HTML_CLASS, BS.HTML_TYPE as HTML_TYPE, SC.SYS_CLASS_FILE, SC.SYS_CLASS_VARNAME, SC.SYS_CLASS_CLASSNAME,BS.EXCLUSION, BS.ID
                       from BLOCKS_SECTION BS
                       inner join BLOCKS B on (BS.BLOCKS_ID=B.BLOCKS_ID and B.STATUS=1)
                       left join SYS_CLASS SC ON SC.SYS_CLASS_ID=B.SYS_CLASS_ID
                       where $add and SITE_ID=? and B.BLOCKS_ID=? order by BS.EXCLUSION desc, BS.ORDER_",$site_id,$call_id);
           $arr_block_id = array();             
           while (!empty($blocks)) {
                   foreach ($blocks as $idx => $block) {
                           if($block['EXCLUSION']){
                                           if(!in_array($block['BLOCKS_ID'],$arr_block_id)) array_push($arr_block_id,$block['BLOCKS_ID']);
                           }else{
                                           if(!in_array($block['BLOCKS_ID'],$arr_block_id) or $block['ID'])
                                                   $ret .= $this->CallPrepareBlock($VARS,$VARS_init,$block);
                           }
                           unset($blocks[$idx]);
                        } // foreach
              } // while

    Функция, кстати называется GetOneBlock )))

    a_lebedev, 02 Июня 2011

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