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

    +145.5

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    if($record->getTitle()) {
      $request->setAttribute('title', $record->getTitle());
    }else{
      $request->setAttribute('title', $record->getName());
    }

    определение существования метода у объекта $record

    seroy, 18 Сентября 2009

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

    +156.1

    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
    function CompletesGetTableOld($clist, $mid =0)
    {
      if(strlen($clist) or $mid > 0)
      {
        $com = CatalogComplsCostsGet(0, 0, $clist, $mid);
        $csz = sizeof($com['id']);
        if($csz > 0)
        {
            $param = CatalogComplParamsGet();
            $psz = sizeof($param);
            $tds = '';
            
            $cVals = CatalogComplParamValsGet(implode(",", $com['cid']));
            
            echo '
    		<table cellpadding="4" cellspacing="0" border="0" width="700" class="table-comp">
    		 <tr><td width="50%" class="first"></td>
           	';
            for($i = 0; $i < $csz; $i++)
     	    {
     	        echo '<td align="center">'.$com['name'][$i].'</td>';
     	        $tds .= '<td> &nbsp; </td>';
     	    }
            echo '</tr>';
            
            $prgrnm = '';
            for($i = 0; $i < $psz; $i++)
     	    {
     	        $data = false;
     	        $html = '';
     	        if($i==0||$param[$i]['gr_name']!=$prgrnm)
     	        {
    				$html='
    				<tr>
    					<td class="first"><br><b>'.$param[$i]['gr_name'].'</b></td>';for($ii = 0; $ii < $csz; $ii++)$html.='<td class="second" > &nbsp; </td>';
    					$html.= $tds.'
    				</tr>';
     	        }
     	        $html.= '
     	        <tr>
     	          <td class="first">'.$param[$i]['name'].'</td>';
     	        
     	        for($ii = 0; $ii < $csz; $ii++)
         	    {
         	        @$val = $cVals[$com['cid'][$ii]][$param[$i]['id']];
         	        if(isset($val) and strlen($val))
         	        {
         	            if($param[$i]['type'] == 'CH') 
         	            {
         	                if($val == 1)
         	                {
         	                    $html.= '<td class="second" align="center"><img src="/images/tochka.gif" ></td>'; 
         	                    $data = true;
         	                }
         	                else $html.= '<td class="second"> &nbsp; </td>';
         	                
         	            }
         	            else 
         	            {
         	                $html.= '<td class="second" align="center">'.$val.'</td>';
         	                $data = true;
         	            }
         	        }
         	        else $html.= '<td class="second"> &nbsp; </td>';
         	    }
         	    $html.= '</tr>';
         	    
         	    if($data) 
         	    {
         	        $prgrnm = $param[$i]['gr_name'];
         	        echo $html;
         	    }
     	    }
     	    
     	    echo '
     	     <tr><td width="50%" class="first"><b>????</b></td>';
     	    for($i = 0; $i < $csz; $i++)
     	    {
     	    	$cost = intval($com['cost'][$i]);
     	        if($cost > 1000000) $cost = '<nobr>'.substr($cost, 0, -6)." ".substr($cost, 1, -3).". ".substr($cost, 4).'</nobr> ???';
     	        elseif($cost > 100) $cost = '<nobr>'.substr($cost, 0, -3)." ".substr($cost, strlen($cost)-3).'</nobr> ???';
     	        else $cost = '';
         	        
     	        echo '<td class="second" align="center" height="30">'.$cost.'</td>';
     	    }
                   
            echo '</tr>
            </table>';
             
            return true;
        }
      }
       
      return false;
    }

    обратите внимание на переменную $data. долго и упорно собираем из кусочков $html, и только если $data истинно тогда выводим $html (примерно 5-10% случаев)

    gorky, 18 Сентября 2009

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

    +160.6

    1. 1
    2. 2
    3. 3
    $query=mysql_query("SELECT * FROM `PS_card_list` WHERE `id_categ`='".$_GET['point']."';");
    
    while ($row=mysql_fetch_array($query)) $card_on_plan++;

    Наследие военных разработчиков

    vectart, 17 Сентября 2009

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

    +147.7

    1. 1
    $this->view->isAdmin = ($auth->getIdentity()->role_id == 1) ? true : false;

    Называется: "заработался".
    Написал и только потом дошло.

    oldfornit, 16 Сентября 2009

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

    +185.3

    1. 1
    echo "Время генерации: 0.0".rand(10,99)." сек.";

    Без комментариев))) Я под столом))

    greevex, 16 Сентября 2009

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

    +164.7

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    7. 7
    8. 8
    9. 9
    $db = new mysqli(MYSQL_HOST,MYSQL_USER,MYSQL_PASSWORD,MYSQL_DATABASE);
    $query = 'UPDATE registration SET choose_style="'.$_POST['style'].'" WHERE registration_id='.$profile_id;
    $result = $db->query($query);
    if ($result && $db->affected_rows > 0) {
    	echo 'Стиль успешно изменен. Закройте браузер и зайдите снова.';
    } else {
    	echo 'Стиль не изменен';
    	echo $db->error;
    }

    "Закройте браузер и зайдите снова" )))

    Sadie, 14 Сентября 2009

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

    +156.2

    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
    // from views_bonus: grid.inc
    function theme_og_picture_grid($result, $column_count = 5) {
      $content = '<table class="og-picture-grid">';
      $count = 0;
      $total = db_num_rows($result);
      while ($user = db_fetch_object($result)) {
        $classes = 'og-picture-grid-item';
        if ($count < $column_count) {
          $classes .= ' first';
        }
        
        $item = '';
        if ($count % $column_count == 0) { 
          $content .= '<tr>'; 
        }
        $picture = theme('user_picture', $user);
        $name = theme('username', $user);
        $group_role = $user->is_admin ? t('admin') : '&nbsp;';
        $content .= "<td class=\"$classes\">$picture<div class=\"og-name\">$name</div>";
        if ($user->is_admin) {
          $txt = t('admin');
          $content .= "<div class=\"group-role\">$txt</div>"; 
        }
        $content .= "</td>\n";
    
        $count++;
        if ($count % $column_count == 0 || $count == $total) {
          $content .= '</tr>';
        }
      }
      $content .= '</table>';
      
      if ($total) {
        return $content;
      }
    }

    Меня ДУРЬпаловские финты просто бесят.

    типа тема

    paranoid, 14 Сентября 2009

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

    +158

    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
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> 
    <html xmlns="http://www.w3.org/1999/xhtml" lang="ru" xml:lang="ru"> 
    <head> 
    ...
    <?php
    if( !isset($page['header']['links']) || empty($page['header']['links']) )
    {
    ?>
    <link rel="shortcut icon" href="/sites/all/themes/deco/favicon.ico" type="image/x-icon" /> 
    <link type="text/css" rel="stylesheet" media="all" href="/modules/node/node.css?t" /> 
    <link type="text/css" rel="stylesheet" media="all" href="/modules/poll/poll.css?t" /> 
    <link type="text/css" rel="stylesheet" media="all" href="/modules/system/defaults.css?t" /> 
    <link type="text/css" rel="stylesheet" media="all" href="/modules/system/system.css?t" /> 
    <link type="text/css" rel="stylesheet" media="all" href="/modules/system/system-menus.css?t" /> 
    <link type="text/css" rel="stylesheet" media="all" href="/modules/user/user.css?t" /> 
    <link type="text/css" rel="stylesheet" media="all" href="/sites/all/modules/cck/theme/content-module.css?t" /> 
    <link type="text/css" rel="stylesheet" media="all" href="/sites/all/modules/filefield/filefield.css?t" /> 
    <link type="text/css" rel="stylesheet" media="all" href="/sites/all/modules/geshifilter/geshifilter.css?t" /> 
    <link type="text/css" rel="stylesheet" media="all" href="/sites/all/modules/quote/quote.css?t" /> 
    <link type="text/css" rel="stylesheet" media="all" href="/sites/all/modules/tagadelic/tagadelic.css?t" /> 
    <link type="text/css" rel="stylesheet" media="all" href="/sites/all/modules/vote_up_down/vote_up_down.css?t" /> 
    <link type="text/css" rel="stylesheet" media="all" href="/modules/comment/comment.css?t" /> 
    <link type="text/css" rel="stylesheet" media="all" href="/sites/all/modules/pr_cy/pr_cy.css?t" /> 
    <link type="text/css" rel="stylesheet" media="all" href="/modules/openid/openid.css?t" /> 
    <link type="text/css" rel="stylesheet" media="all" href="/sites/all/themes/deco/style.css?t" /> 
    <link type="text/css" rel="stylesheet" media="all" href="/examples/tagnetic/tags.css?t" /> 
    <link type="text/css" rel="stylesheet" media="print" href="/sites/all/themes/deco/print.css?t" /> 
    <script type="text/javascript" src="/misc/jquery.js?t"></script> 
    <script type="text/javascript" src="/misc/drupal.js?t"></script> 
    <script type="text/javascript" src="/files/languages/ru_5530db2a4478b35f94b4da1e2062c5fb.js?t"></script> 
    <script type="text/javascript" src="/sites/all/modules/vote_up_down/ajax_vote_up_down.js?t"></script> 
    <script type="text/javascript" src="/sites/all/themes/deco/jquery.tagnetic.js?t"></script> 
    <script type="text/javascript" src="/sites/all/themes/deco/jquery.tagnetic.settings.js?t"></script> 
    <script type="text/javascript" src="/modules/comment/comment.js?t"></script> 
    <script type="text/javascript" src="/misc/textarea.js?t"></script> 
    <script type="text/javascript" src="/sites/all/modules/pr_cy/pr_cy.js?t"></script> 
    <script type="text/javascript" src="/modules/openid/openid.js?t"></script>
    <?php
    }
    else
    {
    echo $page['header']['links'];
    }
    ?>

    Я, конечно, понимаю, что это необходимо, но такие хеды у меня всегда вызывают улыбку)

    greevex, 12 Сентября 2009

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

    +157.4

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    11. 11
    12. 12
    ....
    $str = str_replace(',', ' ', $this->searchString);
    $str = str_replace(';', ' ', $str);
    $str = str_replace('.', ' ', $str);
    $str = str_replace(':', ' ', $str);
    $str = str_replace('+', ' ', $str);
    $str = str_replace('-', ' ', $str);
    $str = str_replace('"', ' ', $str);
    $str = str_replace("'", ' ', $str);
    		
    $str = trim(preg_replace('!\s{2,}!', ' ', $str));
    .....

    вот что я наклал как-то

    paranoid, 11 Сентября 2009

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

    +156.1

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    7. 7
    $_REQUEST['trigger']['event_params']['duration'] = $_REQUEST['trigger']['event_params']['duration']['hour']*60*60 + $_REQUEST['trigger']['event_params']['duration']['minute']*60 + $_REQUEST['trigger']['event_params']['duration']['seconds'];
                if (empty($_REQUEST['trigger']['event_params']['frequency_period'])) {
                    $_REQUEST['trigger']['event_params']['frequency_count'] = '';
                }
                if (empty($_REQUEST['trigger']['event_params']['frequency_count'])) {
                    $_REQUEST['trigger']['event_params']['frequency_period'] = '';
                }

    phoenix, 10 Сентября 2009

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