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

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

    +165

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    function sorti()
        {
        	if($_GET['where']=='desc'?$where='asc':$where='desc');
        	return 'where='.$where;
        }

    GoodTalkBot, 19 Апреля 2011

    Комментарии (28)
  3. JavaScript / Говнокод #6389

    +160

    1. 1
    2. 2
    3. 3
    4. 4
    <table>
         <form method="post" action="/ololo/onatole.html?step={{if $step eq '2'}}3{{else}}6{{/if}}">
         <tr><td><a id="submit">...
    ....

    фаерфокс отлично парсит такие формы внутри таблиц, jQuery(this).closest('form') тоже возвращает все превосходно

    govno, 18 Апреля 2011

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

    +176

    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
    $navChain=array();
       for($i = 0; $i < count($menu); $i++){
    		if (is_array($menu[$i]['subMenu'])) {
    			for($j = 0; $j < count($menu[$i]['subMenu']); $j++){
    				if (is_array($menu[$i]['subMenu'][$j]['subMenu'])) {
    					for($k = 0; $k < count($menu[$i]['subMenu'][$j]['subMenu']); $k++){
    						if (is_array($menu[$i]['subMenu'][$j]['subMenu'][$k]['subMenu'])) {
    							for($l = 0; $l < count($menu[$i]['subMenu'][$j]['subMenu'][$k]['subMenu']); $l++){
    								if (is_array($menu[$i]['subMenu'][$j]['subMenu'][$k]['subMenu'][$l]['subMenu'])) {
    									for($m = 0; $m < count($menu[$i]['subMenu'][$j]['subMenu'][$k]['subMenu'][$l]['subMenu']);$m++){
    										if ($menu[$i]['subMenu'][$j]['subMenu'][$k]['subMenu'][$l]['subMenu'][$m]['selected']=='1') {
    											$navChain[]=$menu[$i]['subMenu'][$j]['subMenu'][$k]['subMenu'][$l]['subMenu'][$m];
    											$menu[$i]['subMenu'][$j]['subMenu'][$k]['subMenu'][$l]['selected']=1;
    											$navChain[]=$menu[$i]['subMenu'][$j]['subMenu'][$k]['subMenu'][$l];
    											$menu[$i]['subMenu'][$j]['subMenu'][$k]['selected']=1;
    											$navChain[]=$menu[$i]['subMenu'][$j]['subMenu'][$k];
    											$menu[$i]['subMenu'][$j]['selected']=1;
    											$navChain[]=$menu[$i]['subMenu'][$j];
    											$menu[$i]['selected']=1;
    											$navChain[]=$menu[$i];
    										}
    									} // for
    								}
    								if ($menu[$i]['subMenu'][$j]['subMenu'][$k]['subMenu'][$l]['selected']=='1') {
    									$navChain[]=$menu[$i]['subMenu'][$j]['subMenu'][$k]['subMenu'][$l];
    									$menu[$i]['subMenu'][$j]['subMenu'][$k]['selected']=1;
    									$navChain[]=$menu[$i]['subMenu'][$j]['subMenu'][$k];
    									$menu[$i]['subMenu'][$j]['selected']=1;
    									$navChain[]=$menu[$i]['subMenu'][$j];
    									$menu[$i]['selected']=1;
    									$navChain[]=$menu[$i];
    								}
    							} // for
    						}
    						if ($menu[$i]['subMenu'][$j]['subMenu'][$k]['selected']=='1') {
    						$navChain[]=$menu[$i]['subMenu'][$j]['subMenu'][$k];
    							$menu[$i]['subMenu'][$j]['selected']=1;
    							$navChain[]=$menu[$i]['subMenu'][$j];
    							$menu[$i]['selected']=1;
    							$navChain[]=$menu[$i];
    						}
    					} // for
    				}
    				if ($menu[$i]['subMenu'][$j]['selected']=='1') {
    					$navChain[]=$menu[$i]['subMenu'][$j];
    					$menu[$i]['selected']=1;
    					$navChain[]=$menu[$i];
    				}
    			} // for
    		}
    		if ($menu[$i][selected] && empty($navChain)) {
    			$navChain[]=$menu[$i];
    		}
    	} // for

    volatile, 09 Апреля 2011

    Комментарии (28)
  5. C++ / Говнокод #6055

    +160

    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
    #include <iostream>
    #include <string>
    using namespace std;
    int main()
    {
    	const int hz_limit = 20000;
    	string str;
    	string str_mass[] = {"a", "b", "ais", "h", "ces", "c", "his", "cis", "des",
    		"d", "dis", "es", "e", "fes", "f", "eis", "fis", "ges", "g", "gis", "as"};
    	begin:
    	while (cin>>str)
    	{
    		for (size_t ix = 0; ix != str.size(); ++ix)
    		{
    			str[ix] = tolower(str[ix]);
    		}
    		size_t f = 0;
    		for (size_t ix = 0; ix != 21; ++ix)
    		{
    			if(str == str_mass[ix])
    			{
    				f = ix;
    			}
    		}
    		if (str != str_mass[f])
    		{
    			goto begin;
    		}
    		double mass[] = {27.500, 29.135, 29.135, 30.868, 30.868, 32.703, 32.703, 34.648, 34.648,
    		36.708, 38.891, 38.891, 41.203, 41.203, 43.654, 43.654, 46.249, 46.249, 48.999, 51.913, 51.913};
    		for (; mass[f] < hz_limit; mass[f] *= 2)
    			{
    				cout<<mass[f]<<" Hz"<<endl;
    			}
    	}
    	return 0;
    }

    Моя первая прога. Выводит частоты на которых находится введенная нота...

    Extrawelt, 21 Марта 2011

    Комментарии (28)
  6. Си / Говнокод #5887

    +105

    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
    #define C_WRONG              -2000
    
    ....
    
    int tttt_atoi(char* p_string){
    
       int result = C_WRONG;
    
       if ( *p_string < '0' || *p_string > '9' )
          return C_WRONG;
    
       result = atoi(p_string);
       return result;
    }
    
    double tttt_atof(char* p_string){
    
       double result = C_WRONG;
       result = atof(p_string);
       if (result!=0){
          return result;
       }
       else{
          if(strcmp(p_string,"0.0")==0 || strcmp(p_string,"0")==0 || strcmp(p_string,"0.")==0){
             return result;
          }
          else{
             return C_WRONG;
          }
       }
    }

    и вы посмейтесь. или facepalm'нитесь. синтакс оригинала.

    Dummy00001, 04 Марта 2011

    Комментарии (28)
  7. bash / Говнокод #5734

    −131

    1. 1
    ping -q -c 2 -i "0.$ACTN" localhost > /dev/null

    Способ заснуть менее чем на секунду, не дописывая для этого отдельную программу Сишную с использованием nanosleep().

    xaionaro, 21 Февраля 2011

    Комментарии (28)
  8. C# / Говнокод #5692

    +122

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    7. 7
    8. 8
    9. 9
    catch (TargetInvocationException ex) {
         try {
              throw ex.InnerException;
         }
         catch (EndpointNotFoundException innerEx) {
              factory.Abort();
              throw new InvalidOperationException("Service unreachable", innerEx);
         }
    }

    Обработчик исключений %)

    Guid, 16 Февраля 2011

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

    +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
    if($amount > 0) :
    	if (is_dir($directory)) {
    		if ($open_dir = opendir($directory)) {
    			$a = 0; $b = 0;
    			while (false !== ($file = readdir($open_dir))) {
    				if ($file != "." && $file != ".." && !is_dir($directory."/".$file)) {
    					$a++;
    					if($a > $min) {
    						$b++;
    						echo "<tr id=\"am-list-input\" valign=\"center\" height: 20px;><td align=\"left\" width=\"10%\">";
    						echo " <a href=\"index.php?am=mod[uploader]&delete=$file\"><img src=\"../images/mini_icons/del.png\" /></a> ";
    						if(in_array(strtolower(getExtension($file)), $gud_types)) echo "<span OnClick=\"CaricaFoto('".$directory."/".$file."')\" OnMouseOver=\"Tip('<img style="max-width: 400px" src="".$directory."/".$file."" >')\"><img style=\"cursor: help\" src=\"../images/mini_icons/display.png\" /></span>";
    						if(in_array(strtolower(getExtension($file)), explode(',', strtolower("mp3,wma,waw,amr,ape,bin,flac,m4a,mdi,ram")))) echo "<img src=\"modules/mod[uploader]/assets/type/sound.png\" />";
    						if(in_array(strtolower(getExtension($file)), explode(',', strtolower("3gp,avi,dat,flv,ifo,m4v,mkv,mov,mp4,rm,vob,wmv")))) echo "<img src=\"modules/mod[uploader]/assets/type/video.png\" />";
    						if(!in_array(strtolower(getExtension($file)), explode(',', strtolower("3gp,avi,dat,flv,ifo,m4v,mkv,mov,mp4,rm,vob,wmv,mp3,wma,waw,amr,ape,bin,flac,m4a,mdi,ram,jpg,jpeg,png,gif")))) echo "<img src=\"modules/mod[uploader]/assets/type/all.png\" />";
    						echo "</td><td width=\"70%\"><span style=\"display: block; cursor: pointer; color: #446eb8; font-weight: bold; line-height: 16px;\" onClick=\"document.getElementById('onclick').value='".str_replace("..", $conf_global["base_url"], $directory)."/".$file."'\" />".substr($file, 0, 100)."</span></td><td width=\"20%\">".formatsize(filesize($directory.DS.$file))."</td></tr>";
    						if($b == $max) : break; endif;
    					}
    				}
    			}
    		closedir($open_dir);
    		}
    	}
    endif;

    Грех не посмеятся над своими старыми проектами =)))

    nethak, 11 Февраля 2011

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

    +161

    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
    <?php
    
    //////////....................................
    
    	static function Request($module="__global",$action='__global',$route=null){
    		if(!$route && !empty(self::$route)) $route=self::$route;
            else $route=self::setRoute(APP_ModuleContext::getContext());
            $action=strtolower($action);
    		$module=strtolower($module);
    
    		$ro=array();
            if(!empty($route['allow'][$module])){
    			$ro=$route['allow'][$module];
                $dis=!empty($route['disallow'][$module])?$route['disallow'][$module]:array();
    			if(!empty($dis) && $dis['__global']===true) return new throw APP_Exceptions_PluginBox("Плагины для модуля '$module' отключены");
    			 
    			 if(empty($ro['__global'])) $ro['__global']=array();
    			 if(empty($ro[$action])) $ro[$action]=array();
    			 $ro=array_merge($ro['__global'],$ro[$action]);
                 if(!empty($ro)){
    				 $ro=array_unique($ro);
                     if(!empty($dis)){
    					 if(empty($dis['__global'])) $dis['__global']=array();
    					 if(empty($dis[$action])) $dis[$action]=array();
    					 $dis=array_merge($dis['__global'],$dis[$action]);
    					 if(!empty($dis)){
                            $dis=array_unique($dis);
    						$ro=array_diff($ro,$dis);
    					 }
    				 }
    				 if(!empty($ro)){
                        $res=array();
    		 	        foreach($ro as $plugin){
                            $res[$plugin]=self::getContents($plugin);
    			        }
    			        return $res;
    				 }else return new throw APP_Exceptions_PluginBox("Все плагины были отключены для '$module - $action'");
    			 }else return new throw APP_Exceptions_PluginBox("Нет плагинов для запроса '$module - $action'");
    		}
    		
    		return false;
    	}
    
    /////////////..........................................
    ?>

    Роутеры роутят

    Zho, 07 Февраля 2011

    Комментарии (28)
  11. C++ / Говнокод #5536

    +163

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    7. 7
    8. 8
    Engine::GetSingleton()->SetCallbacks(
    	new myname::Method<void(void),Application>(&Application::Render, boost::weak_ptr<Application>(application)),
    	new myname::Method<void(void),Application>(&Application::Update, boost::weak_ptr<Application>(application)),
    	0,
    	0,
    	new myname::Method<void(void),Application>(&Application::Init, boost::weak_ptr<Application>(application)),
    	new myname::Method<void(void),Application>(&Application::Cleanup, boost::weak_ptr<Application>(application))
    );

    Особая шаблонная магия + ООП мозга.

    CHayT, 05 Февраля 2011

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