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

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

    +156

    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
    <?
    function FindTag($Tag,$Page,$Offset=0) // Ищет тег $Tag в странице $Page от символа с номером $Offset
    {
    	$Tag=strtoupper($Tag);
    	$Page=strtoupper($Page);
    	$Pos=array(0,0,0,0);
    	$Pos[0]=StrPos($Page,'<'.$Tag,$Offset);
    	
    	if ($Pos[0]<$Offset) {return False;}
    	
    	if ((Empty($Pos[0])==True)and(SubStr($Page,0,StrLen('<'.$Tag))!='<'.$Tag)) {return False;}
    	$Pos[1]=StrPos($Page,'>',$Pos[0]);
    	
    	if (Empty($Pos[1])==False) {$Pos[1]=$Pos[1]+1;} else {return False;}
    	$Pos[2]=StrPos($Page,'</'.$Tag.'>',$Pos[1]);
    	$Pos[3]=$Pos[2]+StrLen('</'.$Tag.'>');
    	if ((SubStr($Page,$Pos[0]+StrLen('<'.$Tag),1)!=' ')and(SubStr($Page,$Pos[0]+StrLen('<'.$Tag),1)!='>')) {$Pos=FindTag($Tag,$Page,$Pos[1]);}
    	if ((Empty($Pos[1])==False)and($Pos[0]<$Pos[1])) {return $Pos;} else {return False;}
    }
    ?>

    Вот такой пример поиска тегов я нашел по поисковику, автор этих строк явно не знаком с регулярными выражениями...

    Android991, 01 Марта 2011

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

    −99

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    11. 11
    public function addItem(obj):void 
    {
    	if(obj is DisplayObject)
    	{
    		objectArray.push(obj);
    	}
    	else
    	{
    		throw new Error("Cannot add item: " + obj + " - item must be a Display Object.");
    	}
    }

    из http://www.coreyoneil.com/Flash/CDK/

    makc3d, 28 Февраля 2011

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

    −95

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    11. 11
    12. 12
    switch(cbChanges.selectedIndex)
    {
         case 1:
                changes = CHANGES_MODIFIED_STATUS;
                break;
         case 1:
                changes = CHANGES_JOINERS_STATUS;
                break;
         case 1:
                changes = CHANGES_LEAVERS_STATUS;
                break;
    }

    Epic Fail!

    dimas_art, 25 Февраля 2011

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

    +177

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    if(msg == "" || msg == "{}"){
    	// странный баг, форма очищается, но не прячется
    	return;
    	$("#variants_div").html('');
    	$("variants_div").hide();
    }

    Даже Джумла первая была радостным кодом по сравнению с этим.

    Shock, 24 Февраля 2011

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

    +171

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    if($nav_url=="blog.php")
    {
    $ahaha='2';
    eval('$code["$elementtype"] .= "' . fetch_template('navbar_link') . '";');
    $ahaha='';
    }
    else
    {
    eval('$code["$elementtype"] .= "' . fetch_template('navbar_link') . '";');
    }

    Ахаха!

    symbix, 23 Февраля 2011

    Комментарии (6)
  7. ActionScript / Говнокод #5783

    −91

    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
    /**
     *  @private
     *  The exponent used in the easer function for the main part of the throw animation.
     *  NOTE: if you change this, you need to re-differentiate the easer
     *  function and use the resulting derivative calculation in createThrowMotionPath. 
     */
    private static const THROW_CURVE_EXPONENT:Number = 3.0;
    
    ...
    
    // Set the velocity for the next loop iteration.  Make sure it matches the actual velocity in effect when the
    // throw reaches the end of the list.
    //
    // The easer function we use for the throw is 1-((1-x)^3), the derivative of which is 3*x^2-6*x+3.
    // (I used http://www.numberempire.com/derivatives.php to differentiate the easer function).
    // Since the slope of a curve function at any point x (i.e. f(x)) is the value of the derivative at x (i.e. f'(x)),
    // we can use this to determine the velocity of the throw at the point it reached the beginning of the bounce.
    var x:Number = partialTime / effectTime;
    var y:Number = 3 * Math.pow(x, 2) - 6 * x + 3;

    Flex 4.5 Hero.
    Благо на работу кода это не сказывается, но всё-таки...

    Разработчикам: Вообще класс и непосредственно алгоритм touch/kinetic скролла там сделан отвратительно, но с некоторыми весьма хорошими фишками (отпределение скорости, например). Советую вам покопаться.

    fljot, 23 Февраля 2011

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

    +164

    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
    function export_global_value($begin_name,$type='POST'){
    if($type=='POST')$get_array=$_POST;
    else if($type=='GET')$get_array=$_GET;
    else if($type=='FILES')$get_array=$_FILES;
    else if($type=='SESSION')$get_array=$_SESSION;
    else if($type=='COOKIE')$get_array=$_COOKIE;
    else if($type=='REQUEST')$get_array=$_REQUEST;
    else $get_array=$_POST;
    
    $name_get=array_keys($get_array);
    $len=strlen($begin_name);
    $result_array=array();
    for ($i=0;$i<=count($get_array);$i++){
    $text_key=$name_get[$i];
    if($begin_name==substr($text_key,0,$len)){
    array_push($result_array,$text_key);
    }
    }
    return $result_array;
    
    }

    Бля.

    7ion, 23 Февраля 2011

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

    +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
    if
    (
    	!(
    		(
    			strlen($chld_phone) == 10 &&
    			(
    				substr($chld_phone,0,3) == '087' ||
    				substr($chld_phone,0,3) == '088' ||
    				substr($chld_phone,0,3) == '089'
    			)
    		) ||
    		(
    			strlen($chld_phone) == 12 &&
    			(
    				substr($chld_phone,0,5) == '35987' ||
    				substr($chld_phone,0,5) == '35988' ||
    				substr($chld_phone,0,5) == '35989'
    			)
    		)
    	)
    )
    {
    	//Грешка
    }

    Телефон проверки :)

    wyand, 22 Февраля 2011

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

    −179

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    7. 7
    8. 8
    def ispalindrome(string):
    	decide=1
    	i=0
    	while i<=int(len(string)/2) and decide==1:
    		if string[i]!=string[-(i+1)]:
    			decide=0
    		i+=1
    	return decide

    Функция определяет, является ли число паниндромом =)

    SSPkrolik, 21 Февраля 2011

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

    +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
    class forms {
        //put your code here
        
        function __construct($name,$id,$method,$action) {
            echo  "<form id='$id' name='id' method='$method' action='$action'>";
        }
        
        static private function attr($param)    {
            if ($param) {
                foreach ($param as $nam_attr => $val_attr) {
                    $attribs.=$nam_attr."='".$val_attr."'";
                }
                return $attribs; 
            }
        }
        static private function label($id,$text,$attr)    {
            $key = array_search('regue', $attr, true);
            if ($key = 1) $text.="<font color='red'>*</font>";
            return "<label for='$id'>$text</label>";
        }
     
        static public function inputs($text,$type,$name,$id,$value=false,$class=false, $attr=false)    {
           
            return self::label($id,$text,$attr)."<input type='$type' name='$name' id='$id' value='$value' class='$class' ".self::attr($attr)."/>";
        }    
        
        static public function inputs_chek($text,$type,$name,$id,$value=false,$class=false, $attr=false)    {
            return  self::label($id,$text,$attr)."<input type='$type' name='$name' id='$id' class='$class' ".self::attr($attr)."/>$value";
        }   
        
        static public function area($text,$name,$id,$value=false,$class=false, $attr=false)    {
            return  self::label($id,$text,$attr)."<TEXTAREA NAME='$name' id='$id' WRAP='virtual' COLS='40' ROWS='3' ".self::attr($attr).">$value</TEXTAREA>";
        } 
        
        static public function select($text,$name,$id,$value=false,$class=false, $attr=false)    {
            $select="<select name='$name' id='$id' ".self::attr($attr).">";
            foreach($value as $value => $val_text)  {
                $select.="<option value='$value'>$val_text</option>";
            }
           $select.="</select>";
           return  self::label($id,$text,$attr).$select;
        } 
        
        function __destruct() {
            echo "<input type='submit'/><input type='reset' value='Очистить'></form>";
        }   
    }

    qbasic, 21 Февраля 2011

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