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

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

    +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
    <?if($addrs):?>
    	  <?$i=0?>
    	  <?foreach($addrs as $item):?>
    	  
    		  <? $f = GetFields('slon_text', 43, $item['Id']) ?>	
    		  
    		  <address class="vcard">
    			<span class='org hidd'><?=$MG['Site_name']?></span>
    			<span class="adr work">
    				<?if(!empty($f['Город'])):?><span class="locality<?if($i!=0):?> hidd<?endif?>"><?=$f['Город']?></span><br/><?endif?>
    				<?if(!empty($f['Адрес'])):?><span class="street-address"><?=$f['Адрес']?></span><?endif?>
    				<?if(!empty($f['Страна'])):?><span class="country-name hidd"><?=$f['Страна']?></span><?endif?>
    			</span><br/>
    			<?if(!empty($f['Телефон 1'])):?>
    			<span class="tel">
    				Тел.: <span title="+38044<?=str_replace('-','',$f['Телефон 1'])?>" class="value"><?=$f['Телефон 1']?></span><?if(!empty($f['Телефон 2'])):?>, <span title="+38044<?=str_replace('-','',$f['Телефон 2'])?>" class="value"><?=$f['Телефон 2']?></span><?endif?>
    			</span><br/>
    			<?endif?>
    			<?if(!empty($f['E-mail'])):?><a class="email" href="mailto:<?=$f['E-mail']?>"><?=$f['E-mail']?></a><?endif?>
    		  </address>
    		  <?$i++?>
    	  <?endforeach?>
    	  <?endif?>

    Говно-синтаксис

    dobs2005, 07 Октября 2009

    Комментарии (146)
  3. 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)
  4. PHP / Говнокод #1671

    +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
    for($i=$start; $i<$end; $i++) {
            $v=$items[$idx[$i]];
        }
        $start = 0;
        $end = count($items);
        if (is_array($idx))
        {
        }
        else 
        {
         unset($idx);
         $idx[0] = 0;
        }

    Хоть и вырвано из контекста, но общая красота от этого не теряется.

    stan, 24 Августа 2009

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

    +158

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    7. 7
    8. 8
    9. 9
    $pus=$HTTP_COOKIE_VARS["par"];
    $sqlru="select * from users where login='$pus'";
    $resultru=mysql_query($sqlru);
    $rowru=mysql_fetch_array($resultru);
    if ($pus==$rowru[1] && $pus<>"")
    {
    $sqlp="INSERT INTO partner VALUES('$pus','$r_login','$date','0.00')";
    mysql_query($sqlp);
    }

    Alexion, 18 Августа 2009

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

    +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
    45. 45
    46. 46
    <?php
    ...
    
    $date1['year'] = ($_POST['year1']>=2006 && $_POST['year1']<=2037) ? $_POST['year1'] : (($_GET['year1']>=2006 && $_GET['year1']<=2037) ? $_GET['year1'] : date('Y'));
    $date1['month'] = ($_POST['month1']>=1 && $_POST['month1']<=12) ? $_POST['month1'] : (($_GET['month1']>=1 && $_GET['month1']<=12) ? $_GET['month1'] : date('n'));
    $date1['day'] = $type>2 ? 1 : (($_POST['day1']>=1 && $_POST['day1']<=31) ? $_POST['day1'] : (($_GET['day1']>=1 && $_GET['day1']<=31) ? $_GET['day1'] : date('j')));
    $date1['hour'] = $type>1 ? 0 : ((isset($_POST['hour1']) && $_POST['hour1']>=0 && $_POST['hour1']<=23) ? $_POST['hour1'] : ((isset($_GET['hour1']) && $_GET['hour1']>=0 && $_GET['hour1']<=23) ? $_GET['hour1'] : 0));
    $date1['min'] = $type ? 0 : ((isset($_POST['min1']) && $_POST['min1']>=0 && $_POST['min1']<=59) ? $_POST['min1'] : ((isset($_GET['min1']) && $_GET['min1']>=0 && $_GET['min1']<=59) ? $_GET['min1'] : 0));
    
    $date2['year'] = ($_POST['year2']>=2006 && $_POST['year2']<=2037) ? $_POST['year2'] : (($_GET['year2']>=2006 && $_GET['year2']<=2037) ? $_GET['year2'] : date('Y'));
    $date2['month'] = ($_POST['month2']>=1 && $_POST['month2']<=12) ? $_POST['month2'] : (($_GET['month2']>=1 && $_GET['month2']<=12) ? $_GET['month2'] : date('n'));
    $date2['day'] = $type>2 ? cal_days_in_month(CAL_GREGORIAN, $date2['month'], $date2['year']) : (($_POST['day2']>=1 && $_POST['day2']<=31) ? $_POST['day2'] : (($_GET['day2']>=1 && $_GET['day2']<=31) ? $_GET['day2'] : date('j')));
    $date2['hour'] = $type>1 ? 23 : ((isset($_POST['hour2']) && $_POST['hour2']>=0 && $_POST['hour2']<=23) ? $_POST['hour2'] : ((isset($_GET['hour2']) && $_GET['hour2']>=0 && $_GET['hour2']<=23) ? $_GET['hour2'] : 23));
    $date2['min'] = $type ? 59 : ((isset($_POST['min2']) && $_POST['min2']>=0 && $_POST['min2']<=59) ? $_POST['min2'] : ((isset($_GET['min2']) && $_GET['min2']>=0 && $_GET['min2']<=59) ? $_GET['min2'] : 59));
    
    $date1['day'] = cal_days_in_month(CAL_GREGORIAN, $date1['month'], $date1['year'])<$date1['day'] ? cal_days_in_month(CAL_GREGORIAN, $date1['month'], $date1['year']) : $date1['day'];
    $date2['day'] = cal_days_in_month(CAL_GREGORIAN, $date2['month'], $date2['year'])<$date2['day'] ? cal_days_in_month(CAL_GREGORIAN, $date2['month'], $date2['year']) : $date2['day'];
    
    $time_from = mktime($date1['hour'], $date1['min'], 1, $date1['month'], $date1['day'], $date1['year']);
    $time_to = mktime($date2['hour'], $date2['min'], 59, $date2['month'], $date2['day'], $date2['year']);
    
    $types = array(0,1,2,3);
    switch ($type) {
    	case 0:
    		$sql_cols = "minute(from_unixtime(data.log_time)) as \"i\", hour(from_unixtime(data.log_time)) as \"G\", day(from_unixtime(data.log_time)) as \"j\", month(from_unixtime(data.log_time)) as \"n\", year(from_unixtime(data.log_time)) as \"Y\"";
    		$sql_group_by = 'group by "i", "G", "j", "n", "Y"';
    		break;
    	case 1:
    		$sql_cols = "'0' as \"i\", hour(from_unixtime(data.log_time)) as \"G\", day(from_unixtime(data.log_time)) as \"j\", month(from_unixtime(data.log_time)) as \"n\", year(from_unixtime(data.log_time)) as \"Y\"";
    		$sql_group_by = 'group by "G", "j", "n", "Y"';
    		break;
    	case 2:
    		$sql_cols = "'0' as \"i\", '0' as \"G\", day(from_unixtime(data.log_time)) as \"j\", month(from_unixtime(data.log_time)) as \"n\", year(from_unixtime(data.log_time)) as \"Y\"";
    		$sql_group_by = 'group by "j", "n", "Y"';
    		break;
    	case 3:
    		$sql_cols = "'0' as \"i\", '0' as \"G\", '0' as \"j\", month(from_unixtime(data.log_time)) as \"n\", year(from_unixtime(data.log_time)) as \"Y\"";
    		$sql_group_by = 'group by "n", "Y"';
    		break;
    	default:
    		$sql_cols = "'0' as \"i\", '0' as \"G\", '0' as \"j\", '0' as \"n\", year(from_unixtime(data.log_time)) as \"Y\"";
    		$sql_group_by = 'group by "Y"';
    		$type = 2;
    }
    
    ...

    Писал "биллинг" попутно изучая пхп) скрипт вывода статистики

    PycmaM, 11 Августа 2009

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

    +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
    //============================================================================================================================================
    function isadekvat($ps_user){
    	global $conn1,$zright;
    	$pb1=1;
    	$rs_2=mysql_query("select STATUS from tbl_user where CODE=".$ps_user,$conn1);
    		$rs=mysql_fetch_array($rs_2);
    		$ps1=$rs['STATUS'];
    	mysql_free_result($rs_2);
    	$rs_2=mysql_query("select * from tbl_user_status where CODE=".$ps1,$conn1);
    		$rs=mysql_fetch_array($rs_2);
    		if ($rs['DO_MODER']==1){
    			if ($zright['DO_MODERATOR']==1 || $zright['DO_SET']==1){
    				$pb1=1;
    			}else{
    				$pb1=0;
    			}
    		}
    		if ($rs['DO_MODERATOR']==1 || $rs['DO_SET']==1){
    			if ($zright['DO_SET']==1){
    				$pb1=1;
    			}else{
    				$pb1=0;
    			}
    		}
    	mysql_free_result($rs_2);
    	return $pb1;
    }
    //============================================================================================================================================

    Проверка пользователя на адекватность
    Magneto

    rzn_zippy, 11 Августа 2009

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

    +157.9

    1. 1
    2. 2
    3. 3
    4. 4
    function _checkBoth($val1, $val2, $flag = false){
    		if($flag) return $val1 && !$val2 || !$val1 && $val2 ? true : false;
    		return $val1 && $val2 ? false : true;
    	}

    Тот же проект поляцко-индусской соц. сети

    guest, 20 Марта 2009

    Комментарии (0)
  9. JavaScript / Говнокод #582

    +157.9

    1. 1
    var ext = /(\.[^.]*?)$/.exec(filename)?/(\.[^.]*?)$/.exec(filename)[1]:/[\/\\]([^\/\\]*?)$/.exec(filename)?/[\/\\]([^\/\\]*?)$/.exec(filename)[1]:filename; // I love JavaScript :)

    получаем расширение файла )

    guest, 19 Февраля 2009

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

    +157.8

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    function dayTimestamp($t=null) {
    	if (!$t) $t = time();
    	$t = explode('-',date('Y-m-d',$t));
    	$t = mktime(0,0,0,$t[1],$t[2],$t[0]);
    	return $t;
    }

    TWINc, 12 Апреля 2010

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

    +157.7

    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
    <?php 
    //fsockopen, fputs.. 
    
    $content = ""; 
    $header = "not yet"; 
    
    while( !feof( $pointer ) ) { 
        $line = fgets( $pointer, 128 ); 
        if( $line == "\r\n" && $header == "not yet" ) { 
            $header = "passed"; 
        } 
        if( $header == "passed" ) { 
            $content .= $line; 
        } 
    } 
    
    //fclose.. 
    
    echo( substr( $content, 2 ) ); 
    ?>

    По просьбе знакомого. Я в этом мало чего понимаю :)

    Cr@ZyBoY, 25 Февраля 2010

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