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

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

    +144

    1. 1
    $

    TarasGovno, 04 Января 2012

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

    +1001

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    7. 7
    8. 8
    void Object::destroy ()
    {
      evas_object_del (o);
      
      // do a suicide as the delete operator isn't public available
      // the reason is that the C design below is a suicide design :-(
      //delete (this); // TODO: why does this make problems sometimes???
    }

    source: trunk/BINDINGS/cxx/elementaryxx/src/Object.cpp @ 65926

    rat4, 04 Января 2012

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

    +166

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    7. 7
    8. 8
    9. 9
    <?php
    @fwrite($fp, "<?php
    \$config['dbhost'] = \"".str_replace("\"","\\\\\"",stripslashes(trim($_POST['dbhost'])))."\";
    \$config['dbuser'] = \"".str_replace("\"","\\\\\"",stripslashes(trim($_POST['dbuser'])))."\";
    \$config['dbpass'] = \"".str_replace("\"","\\\\\"",stripslashes(trim($_POST['dbpass'])))."\";
    \$config['dbname'] = \"".str_replace("\"","\\\\\"",stripslashes(trim($_POST['dbname'])))."\";
    \$config['dbpref'] = \"".str_replace("\"","\\\\\"",stripslashes(trim($_POST['dbprefix'])))."\";
    ?>");
    ?>

    avecms нах.

    TBoolean, 19 Декабря 2011

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

    +152

    1. 1
    2. 2
    3. 3
    4. 4
    if(!$this->result = $this->dbo->query($this->sql))
    {
       throw new Exception('Error Query: '. $this->sql);
    }

    Ооо я знаю про исключения...

    Sulik78, 19 Декабря 2011

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

    +168

    1. 1
    preg_match('/(.*?)[.,!|]/',ltrim(preg_replace('/[\n\r]+/','|',strip_tags($item[$this->tooltip])),'|'),$regs);

    жонглирование регулярками

    Lure Of Chaos, 18 Декабря 2011

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

    +145

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    this.getRgbaAtColor = function(color)
    {
    	color = (color.charAt(0)=="#") ? color.substring(1,9):color;
    	color = (color.substring(0,2)=="0x") ? color.substring(2,10):color;var r =  parseInt(color.substring(0,2),16);
    	var g = parseInt(color.substring(2,4),16);
    	var b = parseInt(color.substring(4,6),16);
    	var a = color.substring(6,8);
    	a = (a=="") ? 255:parseInt(a,16);
    	return "rgba("+r+","+g+","+b+","+(a/255)+")";
    }

    геймдев..

    KirAmp, 17 Декабря 2011

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

    +159

    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
    //так было до
    <?php
        // дневной/ночной фон
        $now=date("G");
        if (($now > 8) and ($now<21))
            {echo "странице задаётся дневной фон";}
        else
    	{echo "странице задаётся ночной фон";}
    
        //время на сервере	        
        echo date("Время на сервере H:i");
    
        //Выводятся знаменательные события в истории за этот день (ps: просто из папки events берётся фйл с названием $today
        $today=date("d_M");
        $event=file("event/$today");
        $line=count($event);
        echo "<center>",$event[rand(0,$line-1)],"</center>";
        $mon=explode("_",$today);
        $rus=array("Dec"=>"декабря");
        echo "<a href=\"http://ru.wikipedia.org/wiki/",$mon[0],"_",$rus[$mon[1]]>Подробнее о этом дне в Истории</a>";
    
        //история посещений
        $ip=$_SERVER['REMOTE_ADDR']." | ".date("d M H:i:s")."\n";
    ?>
    
    //так стало после
    <?php
        // дневной/ночной фон
        $now=date("d_M_G:i:s");
        $time=explode("_",$now);
        $hour=explode(":",$time[2]);
        if (($hour[0] > 8) and ($hour[0]<21))
            {echo "странице задаётся дневной фон";}
        else
            {echo "странице задаётся ночной фон";}
    
        //время на сервере
        echo "Время на сервере ",$hour[0],":",$hour[1];
    
        //Выводятся знаменательные события в истории за этот день (ps: просто из папки events берётся фйл с названием $today
        $today=$time[0]." ".$time[1];
        $event=file("event/$today");
        $line=count($event);
        echo "<center>",$event[rand(0,$line-1)],"</center>";
        $rus=array("Dec"=>"декабря");
        echo "<a href=\"http://ru.wikipedia.org/wiki/",$time[0],"_",$rus[$time[1]]>Подробнее о этом дне в Истории</a>"; 
    
        //история посещений
        $ip=$_SERVER['REMOTE_ADDR']." | ".$now."\n";
    ?>

    Так сказать попытка оптимизировать код. Был первый вариант, где функция date использовалась 4 раза с разными параметрами.
    Ну и я решил свести всё к одной date... уж и не знаю... был ли смысл) быстрее ли от этого всё будет работать...))

    Vladis_s, 17 Декабря 2011

    Комментарии (4)
  9. SQL / Говнокод #8817

    −109

    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
    end;
    create or replace package body "MUT_TABLE" is
    type a_table is table of number index by pls_integer;
    position a_table;
    empty a_table;
    
    procedure SET_INITIAL_STATE
    as
    begin
    position:=empty;
    end SET_INITIAL_STATE;
    
    procedure BEF_TR( ID IN NUMBER, A IN NUMBER)
    as
    
    begin
    
    position (ID):= A;
    
    end BEF_TR;
    
    procedure AFT_TR
    is
    v number;
    
    begin
    v:=position.FIRST;
    while v is not null loop
    
    update A set
    A=1,
    B='!!!!!!!!!'
    where A = 1;
    v:= position.next(v); 
    end loop;
    
    end AFT_TR;
    
    end "MUT_TABLE";

    kikis, 14 Декабря 2011

    Комментарии (4)
  10. Ruby / Говнокод #8786

    −100

    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
    module ModelHelper
      extend ActiveSupport::Concern
    
      module InstanceMethods
    
        def prepare_url
          "http://#{Banjo::Application.config.short_url_host}"
        end
    
        def adjust_comment(text, url, max_len)
          maximum_text_length = max_len - url.length - 1
          if text.length > maximum_text_length
            text = text[0, maximum_text_length - 3] + "..."
          end
          if url.present?
            message = [text, url].join(' ')
          else
            message = text
          end
          message
        end
    
        def fullname_to_first_last_initial(fullname)
          name_token = fullname.split(/ /)
          last_initial = (name_token.length > 1) ? name_token.pop.first : nil
          first = name_token.join(' ')
          return (last_initial.nil?) ? first : "#{first} #{last_initial}"
        end
    
      end
    
      module ClassMethods
    
        def adjust_comment(text, url, max_len)
          maximum_text_length = max_len - url.length - 1
          if text.length > maximum_text_length
            text = text[0, maximum_text_length - 3] + "..."
          end
          if url.present?
            message = [text, url].join(' ')
          else
            message = text
          end
          message
        end
    
        def fullname_to_first_last_initial(fullname)
          name_token = fullname.split(/ /)
          last_initial = (name_token.length > 1) ? name_token.pop.first : nil
          first = name_token.join(' ')
          return (last_initial.nil?) ? first : "#{first} #{last_initial}"
        end
    
      end
    
    end

    DRY principle in action

    sumskyi, 09 Декабря 2011

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

    +162

    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
    function url_rewriter(){
    	$rules=file_get_contents("system/static/rewrite_rules.conf");
    	$rules=explode("\n",$rules);
    	for ($i=0;$i<count($rules);$i++){
    		$z=explode(" ",$rules[$i]);
    		$r[$z[0]]=$z[1];
    	}
    	foreach ($r as $n => $v)
    	{
    		if ("si".$_GET['url']==$n or "si".$_GET['url']==$n."/") { $_GET['page']=$v; $ok=1;}
    		if ("ab".$_GET['url']==$n or "ab".$_GET['url']==$n."/") { $_GET['page']=$v; $ok=1;}
    		if ("inter".$_GET['url']==$n or "inter".$_GET['url']==$n."/") {$_GET['page']=$v;  $ok=1;}
    		if ("he".$_GET['url']==$n or "he".$_GET['url']==$n."/") {$_GET['page']=$v;  $ok=1;}
      }
      if ("inter".$_GET['url']=="internet-service/cabinet/basket/mobileterminal"||
          "inter".$_GET['url']=="internet-service/cabinet/basket/mobileterminal/"){
        $_GET['page']=14;
        $ok=1;
        $_GET['mobileterminal']="on";
        unset($_GET['url']);
      } 
    	return $ok;
    }

    Реализация ЧПУ...

    nethak, 08 Декабря 2011

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