1. Список говнокодов пользователя kropotor

    Всего: 9

  2. JavaScript / Говнокод #27342

    0

    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 validateUSDate( strValue ) 
    {
    	  var objRegExp = /^\d{1,2}(\-|\/|\.)\d{1,2}\1\d{4}$/;
    	  if(!objRegExp.test(strValue))
    	    return false; //doesn't match pattern, bad date
    	  else
    	  {
    	    var strSeparator = strValue.substring(2,3); //find date separator
    	    var arrayDate = strValue.split(strSeparator); //split date into month, day, year
    	    //create a lookup for months not equal to Feb.
    	    var arrayLookup = { '01' : 31,'03' : 31, '04' : 30,'05' : 31,'06' : 30,'07' : 31,
    	                        '08' : 31,'09' : 30,'10' : 31,'11' : 30,'12' : 31};
    	    var intDay = (arrayDate[1]);
    	
    	    //check if month value and day value agree
    	    if(arrayLookup[arrayDate[0]] != null) 
    	    {
    	      if(intDay <= arrayLookup[arrayDate[0]] && intDay != 0)
    	        return true; //found in lookup table, good date
    	    }
    	    //check for February
    	    var intYear = parseInt(arrayDate[2]);
    	    var intMonth = parseInt(arrayDate[0]);
    	    if( ((intYear % 4 == 0 && intDay <= 29) || (intYear % 4 != 0 && intDay <=28)) && intDay !=0)
    	      return true; //Feb. had valid number of days
    	  }
    	  return false; //any other values, bad date
    }

    А вот этот шедевр ещё и работает...

    kropotor, 08 Апреля 2021

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

    0

    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
    function isNumeric(str)      //for non-numeric fields
    {
    	var FlagS=0, FlagN=0;
    	var str1=new Array();
    	
    	for(var i=0;i<str.length;i++) //convert string to a char array
    	{
    		str1[i]=str.charAt(i);
    	}	
    	for(i=0;i<str1.length;i++)   //check for digits
    	{
    		if(str1[i]>='0'&&str1[i]<='9' ) 
    		{
    			FlagN=1;
    		}
    	}
    	if(FlagS==1||FlagN==1) 		//give a final decision
    	{ 
    		FlagS=FlagN=0;
    		return true;
    	}
    }

    Красота по-индийски. FlagS не понадобился, ну и хер с ним :)

    kropotor, 08 Апреля 2021

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

    +3

    1. 1
    session_decode(session_encode());

    что это вообще такое и зачем оно?

    kropotor, 27 Июня 2016

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

    +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
    /**
    	* Gibt ein Array mit den Fehlermeldungen zurück
    	*
    	* @todo Test
    	* @param void
    	* @return bool|array True = Keine Fehler, Array = Fehler-Array
    	* @access public
    	* @since version 4.0
    	*/
    public function get_meldung()
    	{
    		if($fehler_meldung == null)
    		{
    			return true;
    		}
    		else
    		{
    			for($errori=0;$fehleri<count($this->fehler_meldung);$fehleri++)
    			{
    				echo $this->fehler_meldung[$fehleri]."<br>\n";
    			}	
    			return false;
    		}
    	}

    Ещё немного немецкого говнокода.
    По описанию ЭТО возвращает true когда ошибок нет или array с ошибками.

    kropotor, 09 Июня 2016

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

    +11

    1. 1
    2. 2
    3. 3
    4. 4
    for ($i = 0; $i < 11; $i++) {
        if ($i < 5) continue;
        //остальной код
    }

    первые 5 не нужны

    kropotor, 16 Сентября 2015

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

    +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
    if($row198['verein_id']==$row511['verein_1'])
    {
    				$row198['neu_tore']=$row198['last_tore']+$row511['tore_1'];
    				$row198['neu_gegentore']=$row198['last_gegentore']+$row511['tore_2'];
    				$row198['neu_tordiff']=$row198['neu_tore']-$row198['neu_gegentore'];
    				$row198['neu_siege']=$row198['last_siege']+($row511['tore_1']>$row511['tore_2']);
    				$row198['neu_niederlagen']=$row198['last_niederlagen']+($row511['tore_1']<$row511['tore_2']);
    				$row198['neu_unentschieden']=$row198['last_unentschieden']+($row511['tore_1']==$row511['tore_2']);
    				$row198['neu_spiele']=$row198['last_spiele']+1;
    				$row198['last_punkte']=$row198['last_siege']*3+$row198['last_unentschieden']*1;
    				$row198['neu_punkte']=$row198['neu_siege']*3+$row198['neu_unentschieden']*1;
    }
    else if($row198['verein_id']==$row511['verein_2'])
    {
    				$row198['neu_tore']=$row198['last_tore']+$row511['tore_2'];
    				$row198['neu_gegentore']=$row198['last_gegentore']+$row511['tore_1'];
    				$row198['neu_tordiff']=$row198['neu_tore']-$row198['neu_gegentore'];
    				$row198['neu_siege']=$row198['last_siege']+($row511['tore_1']<$row511['tore_2']);
    				$row198['neu_niederlagen']=$row198['last_niederlagen']+($row511['tore_1']>$row511['tore_2']);
    				$row198['neu_unentschieden']=$row198['last_unentschieden']+($row511['tore_1']==$row511['tore_2']);
    				$row198['neu_spiele']=$row198['last_spiele']+1;
    				$row198['last_punkte']=$row198['last_siege']*3+$row198['last_unentschieden']*1;
    				$row198['neu_punkte']=$row198['neu_siege']*3+$row198['neu_unentschieden']*1;
    }

    через 5 минут заметил разницу.

    kropotor, 31 Июля 2015

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

    +3

    1. 1
    2. 2
    if(strpos($imagefilename,'.jpg')) $imagefile=copy($imagefilename,$imagepath.'teaser'.$this->feed_id.'.jpg');
    else if(strpos($imagefilename,'.jpeg')) $imagefile=copy($imagefilename,$imagepath.'teaser'.$this->feed_id.'.jpg');

    или? Нет, не слышал.

    kropotor, 31 Июля 2015

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

    +143

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    11. 11
    12. 12
    function menu_config($tree,$parent)
    	{
    		$row=$this->phoenixDatabase->executeQuery("select * from ".$this->tableName."menu_config where website_menu_config_tree=$tree",$tree);
    		while ($row=$this->phoenixDatabase->getNextResult($tree))
    		{
    			$this -> content_menu_string_off[$tree][$row["website_menu_config_level"]]=stripslashes($this->phoenixDatabase->getResultAsStream("website_menu_config_off","from ".$this->tableName."menu_config where website_menu_config_tree=$tree and website_menu_config_id=".$row["website_menu_config_id"]));
    			$this -> content_menu_string_on[$tree][$row["website_menu_config_level"]]=stripslashes($this->phoenixDatabase->getResultAsStream("website_menu_config_on","from ".$this->tableName."menu_config where website_menu_config_tree=$tree and website_menu_config_id=".$row["website_menu_config_id"]));
    			$this -> content_menu_string_start[$tree][$row["website_menu_config_level"]]=stripslashes($this->phoenixDatabase->getResultAsStream("website_menu_config_start","from ".$this->tableName."menu_config where website_menu_config_tree=$tree and website_menu_config_id=".$row["website_menu_config_id"]));
    			$this -> content_menu_string_space[$tree][$row["website_menu_config_level"]]=stripslashes($this->phoenixDatabase->getResultAsStream("website_menu_config_space","from ".$this->tableName."menu_config where website_menu_config_tree=$tree and website_menu_config_id=".$row["website_menu_config_id"]));
    			$this -> content_menu_string_end[$tree][$row["website_menu_config_level"]]=stripslashes($this->phoenixDatabase->getResultAsStream("website_menu_config_end","from ".$this->tableName."menu_config where website_menu_config_tree=$tree and website_menu_config_id=".$row["website_menu_config_id"]));
    		}
    	}

    Какие-то манипуляции с меню сайта.

    kropotor, 17 Июля 2015

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

    −163

    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
    SELECT     top 20 *,
    		CAST(DATEPART(yy, rs_message_sendtime) AS varchar(4)) + '-' + (CASE WHEN len(CAST(DATEPART(m, 
                          rs_message_sendtime) AS varchar(4))) = 1 THEN '0' + CAST(DATEPART(m, rs_message_sendtime) AS varchar(4)) ELSE CAST(DATEPART(m, 
                          rs_message_sendtime) AS varchar(4)) END) + '-' + (CASE WHEN (len(CAST(DATEPART(d, rs_message_sendtime) AS varchar(4)))) 
                          = 1 THEN '0' + CAST(DATEPART(d, rs_message_sendtime) AS varchar(4)) ELSE CAST(DATEPART(d, rs_message_sendtime) AS varchar(4)) END) 
                          + 'T' + (CASE WHEN len(CAST(DATEPART(hh, rs_message_sendtime) AS varchar(4))) = 1 THEN '0' + CAST(DATEPART(hh, rs_message_sendtime) 
                          AS varchar(4)) ELSE CAST(DATEPART(hh, rs_message_sendtime) AS varchar(4)) END) + ':' + (CASE WHEN len(CAST(DATEPART(mi, 
                          rs_message_sendtime) AS varchar(4))) = 1 THEN '0' + CAST(DATEPART(mi, rs_message_sendtime) AS varchar(4)) ELSE CAST(DATEPART(mi, 
                          rs_message_sendtime) AS varchar(4)) END) + ':' + (CASE WHEN len(CAST(DATEPART(ss, rs_message_sendtime) AS varchar(4))) 
                          = 1 THEN '0' + CAST(DATEPART(ss, rs_message_sendtime) AS varchar(4)) ELSE CAST(DATEPART(ss, rs_message_sendtime) AS varchar(4)) END) 
                          AS sendtime, 
    					  CAST(DATEPART(yy, rs_message_valid_from) AS varchar(4)) + '-' + (CASE WHEN len(CAST(DATEPART(m, rs_message_valid_from) 
                          AS varchar(4))) = 1 THEN '0' + CAST(DATEPART(m, rs_message_valid_from) AS varchar(4)) ELSE CAST(DATEPART(m, rs_message_valid_from) 
                          AS varchar(4)) END) + '-' + (CASE WHEN (len(CAST(DATEPART(d, rs_message_valid_from) AS varchar(4)))) = 1 THEN '0' + CAST(DATEPART(d, 
                          rs_message_valid_from) AS varchar(4)) ELSE CAST(DATEPART(d, rs_message_valid_from) AS varchar(4)) END) 
                          + 'T' + (CASE WHEN len(CAST(DATEPART(hh, rs_message_valid_from) AS varchar(4))) = 1 THEN '0' + CAST(DATEPART(hh, rs_message_valid_from) 
                          AS varchar(4)) ELSE CAST(DATEPART(hh, rs_message_valid_from) AS varchar(4)) END) + ':' + (CASE WHEN len(CAST(DATEPART(mi, 
                          rs_message_valid_from) AS varchar(4))) = 1 THEN '0' + CAST(DATEPART(mi, rs_message_valid_from) AS varchar(4)) ELSE CAST(DATEPART(mi, 
                          rs_message_valid_from) AS varchar(4)) END) + ':' + (CASE WHEN len(CAST(DATEPART(ss, rs_message_valid_from) AS varchar(4))) 
                          = 1 THEN '0' + CAST(DATEPART(ss, rs_message_valid_from) AS varchar(4)) ELSE CAST(DATEPART(ss, rs_message_valid_from) AS varchar(4)) END) 
                          AS validfrom, 
    					  CAST(DATEPART(yy, rs_message_valid_to) AS varchar(4)) + '-' + (CASE WHEN len(CAST(DATEPART(m, rs_message_valid_to) 
                          AS varchar(4))) = 1 THEN '0' + CAST(DATEPART(m, rs_message_valid_to) AS varchar(4)) ELSE CAST(DATEPART(m, rs_message_valid_to) AS varchar(4)) 
                          END) + '-' + (CASE WHEN (len(CAST(DATEPART(d, rs_message_valid_to) AS varchar(4)))) = 1 THEN '0' + CAST(DATEPART(d, rs_message_valid_to) 
                          AS varchar(4)) ELSE CAST(DATEPART(d, rs_message_valid_to) AS varchar(4)) END) + 'T' + (CASE WHEN len(CAST(DATEPART(hh, rs_message_valid_to) 
                          AS varchar(4))) = 1 THEN '0' + CAST(DATEPART(hh, rs_message_valid_to) AS varchar(4)) ELSE CAST(DATEPART(hh, rs_message_valid_to) 
                          AS varchar(4)) END) + ':' + (CASE WHEN len(CAST(DATEPART(mi, rs_message_valid_to) AS varchar(4))) = 1 THEN '0' + CAST(DATEPART(mi, 
                          rs_message_valid_to) AS varchar(4)) ELSE CAST(DATEPART(mi, rs_message_valid_to) AS varchar(4)) END) 
                          + ':' + (CASE WHEN len(CAST(DATEPART(ss, rs_message_valid_to) AS varchar(4))) = 1 THEN '0' + CAST(DATEPART(ss, rs_message_valid_to) 
                          AS varchar(4)) ELSE CAST(DATEPART(ss, rs_message_valid_to) AS varchar(4)) END) AS validto
    					  
    FROM         rs_message_outbox_ready INNER JOIN
                          rs_customer_feed ON rs_customer_feed.rs_customer_feed_id = rs_message_outbox_ready.rs_customer_feed_id INNER JOIN
                          rs_customer ON rs_message_outbox_ready.rs_customer_id = rs_customer.rs_customer_id
    	WHERE     
    	(rs_message_outbox_ready.rs_message_sendtime <= GETDATE()) AND
    	(rs_message_outbox_ready.rs_message_type = 2) AND 
    	(rs_customer_feed.rs_customer_feed_status = 1) AND 
    	(rs_customer.rs_customer_status = 1) AND 
    	(rs_customer_feed.rs_customer_feed_category = 2) AND 
    	(rs_message_outbox_ready.rs_message_status = 5) AND
    	(rs_customer_feed.rs_customer_feed_xml=1)

    Переводим дату из одного формата в другой :)

    kropotor, 17 Июля 2015

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