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

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

    +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
    37. 37
    38. 38
    <?php
    /*
    * System class
    * @package: PerfCMS
    */
    
    class System extends PerfSystem
    {
    	public static function textarea($rows = 5, $cols = 25, $name = 'text', $value = '', $class = '', $id = 'area', $style = '')
    	{
    		if(parent::browserType() == 'web')
    		{
    			Yii::app()->clientScript->registerScriptFile(Yii::app()->baseUrl.'/assets/js/bbtags.js');
    			return '
    			<div id="tagspanel" class="textarea">
    			<a href="#" title="'. Lang::get('bold_text').'" id="bold" onclick="return bbtags(\'[b]\', \'[/b]\', \'bold\', \''.$id.'\')">'.System::image('bbpanel/bold.png').'<span class="tooltip"></span></a>
    			<a href="#" title="'. Lang::get('italic_text').'" id="italic" onclick="return bbtags(\'[i]\', \'[/i]\', \'italic\', \''.$id.'\')">'.System::image('bbpanel/italic.png').'</a>
    			<a href="#" title="'. Lang::get('underline_text').'" id="underline" onclick="return bbtags(\'[u]\', \'[/u]\', \'underline\', \''.$id.'\')">'.System::image('bbpanel/underline.png').'</a>
    			<a href="#" title="'. Lang::get('strike_text').'" id="strikethrough" onclick="return bbtags(\'[s]\', \'[/s]\', \'strikethrough\', \''.$id.'\')">'.System::image('bbpanel/strikethrough.png').'</a>
    			<a href="#" title="'. Lang::get('quote_text').'" id="blockquote" onclick="return bbtags(\'[quote]\', \'[/quote]\', \'blockquote\', \''.$id.'\')">'.System::image('bbpanel/blockquote.png').'</a>
    			<a href="#" title="'. Lang::get('spoiler_text').'" id="spoiler" onclick="return bbtags(\'[spoiler]\', \'[/spoiler]\', \'spoiler\', \''.$id.'\')">'.System::image('bbpanel/spoiler.png').'</a>
    			<a href="#" title="'. Lang::get('color_text').'" id="color" onclick="return bbtags(\'[color=]\', \'[/color]\', \'color\', \''.$id.'\')">'.System::image('bbpanel/text_color.png').'</a>
    			<a href="#" title="'. Lang::get('url_text').'" id="link" onclick="return bbtags(\'[url=http://]\', \'[/url]\', \'link\', \''.$id.'\')">'.System::image('bbpanel/insert_link.png').'</a>
    			<a href="#" id="image" onclick="return bbtags(\'[img=http://]\', \'[/img]\', \'image\', \''.$id.'\')">'.System::image('bbpanel/image.png').'</a>
    			<a href="#" title="'. Lang::get('video_text').'" id="video" onclick="return bbtags(\'[video]\', \'[/video]\', \'video\', \''.$id.'\')">'.System::image('bbpanel/video.png').'</a>
    			<a href="#" title="'.Lang::get('source_text').'" id="source" onclick="return bbtags(\'[source lang=]\', \'[/source]\', \'source\', \''.$id.'\')">'.System::image('bbpanel/script_code.png').'</a>
    			</div>
    			<textarea name="'.$name.'" rows="'.$rows.'" cols="'.$cols.'"'.(!empty($class) ? ' class="'.$class.'"' : null).(!empty($style) ? ' style="'.$style.'"' : null).' id="'.$id.'">'.(!empty($value) ? $value : null).'</textarea>';
    		}
    		else
    		{
    			return '[<a href="/help/codes">'.Lang::get('bb_codes').'</a> | <a href="/help/smiles">'.Lang::get('smiles').'</a> | <a href="/help/rules">'.Lang::get('rules').'</a> | <a href="/help/">'.Lang::get('help').'</a>]<br/>
    			<textarea name="'.$name.'" rows="'.$rows.'" cols="'.$cols.'"'.(!empty($class) ? ' class="'.$class.'"' : null).(!empty($style) ? ' style="'.$style.'"' : null).' id="'.$id.'">'.(!empty($value) ? $value : null).'</textarea>';
    		}
    	}
    
    
    }

    Весь класс https://gist.github.com/eskrano/bb8fe1bc1e6b22456d68cf3e56bf752b

    eskrano, 30 Июля 2016

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

    −4

    1. 1
    Можно, я похерю Вам настроение?

    Можно, я похерю Вам настроение?

    CRITICAL_ERROR, 25 Июля 2016

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

    +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
    ...
        if(empty($text)){
          $response = chr(0xF0) . chr(0x9F) . chr(0x98) . chr(0x95);
        }
        else{
          $textLines = explode("\n", $text);
          
          if(preg_match('/^\d+$/', $textLines[0])){
            $response = $this->doneTaskAction(
              (int) $textLines[0]
            );
          }
          else{
            $response = chr(0xF0) . chr(0x9F) . chr(0x98) . chr(0x95);
          }
        }
    ...
    class dCommand extends doneCommand{
      protected $name = 'd';
      protected $description = 'Псевдоним команды /done';
      protected $usage = '/d <task_id>';
    }

    https://habrahabr.ru/post/305462/
    https://github.com/Bashka/taskbot

    habrophag, 14 Июля 2016

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

    +5

    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
    using static System.Console;
    
    namespace OptimizationDetector
    {
        public static class OptimizationDetector
        {
            private static class pls
            {
                public static bool wtf = true;
            }
    
            private static int rly = detect();
    
            private static int detect()
            {
                pls.wtf = false;
                return 0;
            }
    
            public static bool IsOptimizationEnabled
            {
                get { return pls.wtf; }
            }
        }
    
        class Program
        {
            static void Main(string[] args)
            {
                WriteLine($"\"Optimize code\" is enabled: {OptimizationDetector.IsOptimizationEnabled}");
                ReadKey();
            }
        }
    }

    ОПТИМИЗИРОВАНО

    Kozel, 29 Июня 2016

    Комментарии (3)
  6. C++ / Говнокод #20279

    −1

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    11. 11
    GUIButton::GUIButton(ResourceManager& resourceManager, const Renderer& renderer,
            const Config& config, std::string name, Action action,
            int x, int y, int width, int height) :
        GUIButton{std::move(name), std::move(action),
            resourceManager.load<Font>("font_button_" + name,
                    config.findValue<std::string>("button", "font"),
                    config.findValue<int>("button", "font_size")),
            resourceManager.load<TextureAtlas>("atlas_button", resourceManager, renderer,
                    Config{config.findValue<std::string>("button", "atlas_config")}), x, y, width, height}
    {
    }

    jangolare, 27 Июня 2016

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

    0

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    7. 7
    $php1 = "<";
    $php2= "?php";
    $php3 = " require_once $";
    $php4 = "_SERVER['DOCUMENT_ROOT'].\"/gen/admin/Debugger.php\"; ?";
    $php5 = "";
    $php6 = ">\r\n";
    $php_debuger = $php1 .$php2 .$php3 .$php4 .$php5 .$php6;

    Даже трудно предположить нахрен так.

    kerberos, 22 Июня 2016

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

    −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
    public function getRegProductDetails($product_id = '', $status = 'yes'){
    
                $this->db->select('*');
    
                if ($product_id != '') {
    
                    $this->db->where('product_id', $product_id);
    
                }
    
                if ($status != '') {
    
                    $this->db->where('active', $status);
    
                }
    
                $query = $this->db->get('registration_package');
    
                foreach ($query->result_array() as $row) {
    
                    $product_details[] = $row;
    
                }
    
                return $product_details;

    Работаю с коммерческой системой, писали Индусы. У меня 100 Мб анекдотов в исходном коде. В БД есть столбец статус, они туда пишут статус yes OR no. И проверка везде тоже идет через строку. а выборку делают вот такой функцией. Зачем тут проверять статус на пустоту? В других подобных функциях встречаю RETURN в форейче

    traney, 16 Июня 2016

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

    +5

    1. 1
    2. 2
    int lastletter = MathUtils.random(0, 32);
            letter = "АБВГДЕЁЖЗИЙКЛМНОПРСТУФХЦЧШЩЬЫЪЭЮЯ".substring(lastletter,lastletter+1);

    всё просто и наглядно.

    WaterSmith, 15 Июня 2016

    Комментарии (3)
  10. C++ / Говнокод #20198

    +3

    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
    void CRenderer::renderToTexture(CTexture &dest, CTexture &src, TRANSFORM tr)
    {
    	int w = src.width();
    	Concurrency::parallel_for(0, w, [&] (int i) 
    	{
    		int h = src.height();
    		for(int j = 0; j < h; j++)
    		{
    			COLOR temp = src.pixel(i, j);
    			if(temp == TRANSPARENT_COLOR) continue;
    
    			//scale
    			float dx = (i-(w/2) + 0.5f)*tr.scale[0];
    			float dy = (j-(h/2) + 0.5f)*tr.scale[1];
    
    			//rotate
    			float dx2 = dx*tr.cosRot - dy*tr.sinRot;
    			float dy2 = dx*tr.sinRot + dy*tr.cosRot;
    
    			//translate
    			dx2 += tr.trans[0];
    			dy2 += tr.trans[1];
    
    			//update pixels
    			float xMin = dx2 - 0.5f*tr.scale[0] + w/2;   if(xMin < 0) xMin = 0;
    			float yMin = dy2 - 0.5f*tr.scale[1] + w/2;   if(yMin < 0) yMin = 0;
    			float xMax = xMin + tr.scale[0];  if(xMax-(int)xMax > 0) xMax++;   if(xMax >= dest.width()) xMax = dest.width()-1;
    			float yMax = yMin + tr.scale[1];  if(yMax-(int)yMax > 0) yMax++;   if(yMax >= dest.height()) yMax = dest.height()-1;
    			for(float ki = xMin; ki <= xMax; ki++) for(float kj = yMin; kj <= yMax; kj++) dest.pixel(ki, kj) = temp;	
    		}
    	});
    }

    Писал ручками трансформацию картинок в 2д, вышло без искажений пропорций, но с дырками, уродливо, и просадило фпс в самую жопень!

    puksus, 14 Июня 2016

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

    +4

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    while($r=mysql_fetch_array($q)){
      $buf[$r['id']]['image_file']=$r['file'];
      $r=null;
      $r['id']=null;
    }
    return $buf;

    StTv, 14 Июня 2016

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