1. Си / Говнокод #23139

    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
    29. 29
    30. 30
    31. 31
    32. 32
    int r_k ( char *text, char *point, int d, int q ){
    
    	int n = strlen( text);
    	int m = strlen(point );
    	int h = (int) pow(d , m - 1   )  % q ;
    	int i;
    	int p = 0;
    	int t = 0;	
            int j ;
    	
    	for(i = 0  ;i  < m ; i++  ){
    			p = (  (d*p)  + point[i]) % q;
    			t = (  (d*t) +  text[i])  % q;
    		}
    	
    	for(i = 0;  i   <=  (n - m) ; i++   ){
    	
    		if(p  == t  ){
    	
    			for(j = 0 ; j < m  ; j++)
    	
    				if(  text[i + j]  !=  point[j]) 
    					break;
    	
    				if ( j == m  )
    						return i;
    					}
    	
    			t =   ( (  (d * (t - text[i] * h)   ) + (text[i + m])) % q )   + q ;
    		} 
    	return 0;
    	}

    Даже " Касперский" сказал что это говно и молча удалил.

    tyrin, 20 Июня 2017

    Комментарии (0)
  2. C# / Говнокод #23138

    −2

    1. 1
    2. 2
    3. 3
    4. 4
    for (int i = 0; i < components.Length; i++) 
    { 
              if (components[i]) components[i].GetComponent<ComponentScript>().ChangeComponent(CalculateCircuitScript.ComponentDataArray[components[i].GetComponent<ComponentScript>().lineNumber, components[i].GetComponent<ComponentScript>().elementNumber]); 
    }

    Конструктор трёхфазных цепей на Unity3D

    Super_Indus_coding, 19 Июня 2017

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

    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
    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
    57. 57
    58. 58
    59. 59
    60. 60
    61. 61
    62. 62
    63. 63
    64. 64
    65. 65
    66. 66
    67. 67
    68. 68
    69. 69
    70. 70
    71. 71
    72. 72
    73. 73
    74. 74
    75. 75
    76. 76
    77. 77
    78. 78
    79. 79
    80. 80
    81. 81
    82. 82
    83. 83
    84. 84
    85. 85
    86. 86
    87. 87
    88. 88
    89. 89
    90. 90
    91. 91
    92. 92
    93. 93
    94. 94
    95. 95
    procedure TForm1.ProcListAdvancedCustomDrawItem(Sender: TCustomListView;
      Item: TListItem; State: TCustomDrawState; Stage: TCustomDrawStage;
      var DefaultDraw: Boolean);
    var
      TP:TprocessInfo;
      xColor: TColor;
      xRect: TRect;
      xBitmap: TBitmap;
      I, L, R: Integer;
    begin
      DefaultDraw:=False;
      TP:=TProcessInfo(Item.SubItems.Objects[0]);
      if (Item.Selected) then
      begin
        if Sender.Focused then
        begin
          if (FItemAtCursor <> -1) and (Item.Index = FItemAtCursor) then
            xColor:=clNavy
          else
            xColor:=$00C56A31;
        end
        else
          xColor:=$00D8E9EC
      end
      else
      begin
        if (TP.New<2) or (TP.Terminated<2) or (TP.Hidden) then
        begin
    
          if ShowDangerousProcesses then
          if TP.Hidden then
          xColor:=$00DBDBDB;
    
          if ShowNewProcesses then
          if TP.New <2 then
          xColor:=$001DEB2D;
    
          if ShowTerminatedProcesses then
          if TP.Terminated < 2 then
          xColor:=$001D2DEB;
        end
        else
    
        if (Item.Index mod 2 = 1) then
        xColor:=RGB(245,245,255)
        else
        xColor:=clWindow;
      end;
      Sender.Canvas.Brush.Color:=xColor;
      DefaultDraw:=True;
    
      if (Item.Selected) and Sender.Focused
      then Sender.Canvas.Font.Color:=clWindow
      else Sender.Canvas.Font.Color:=clWindowText;
      Sender.Canvas.FillRect(Item.DisplayRect(drLabel));
      DefaultDraw:=True;
    
      Exit; 
    
      xRect:=Item.DisplayRect(drLabel);
      Sender.Canvas.TextRect(xRect,xRect.Left+2,xRect.Top,Item.Caption);
    
      for I:=0 to TListView(Sender).Columns.Count-1 do
      begin
        if TListView(Sender).Columns[TListView(Sender).Columns[I].ID].Width<=0 then Continue;
        if (I=0) and (TListView(Sender).Columns[I].ID <> 0) then
        begin
          xRect.Left:=0;
          xRect.Right:=xRect.Left+TListView(Sender).Columns.Items[TListView(Sender).Columns[I].ID].Width-1;
          Sender.Canvas.FillRect(xRect);
          Sender.Canvas.TextRect(xRect,xRect.Left+2,xRect.Top,Item.SubItems[TListView(Sender).Columns[I].ID-1]);
        end
        else
        begin
        if I>0 then
        begin
          xRect.Left:=xRect.Right+1;
          xRect.Right:=xRect.Left+TListView(Sender).Columns.Items[TListView(Sender).Columns[I].ID].Width-1;
          Sender.Canvas.FillRect(xRect);
          if TListView(Sender).Columns[I].ID >0 then
          Sender.Canvas.TextRect(xRect,xRect.Left+5,xRect.Top,Item.SubItems[Pred(TListView(Sender).Columns[I].ID)])
          else
          begin
            L:=(Item.DisplayRect(drIcon).Right-Item.DisplayRect(drIcon).Left)+6;
          Sender.Canvas.TextRect(xRect,xRect.Left+L,xRect.Top, Item.Caption)
        end;
        end;
    
        end;
      end;
      Sender.Canvas.Brush.Color:=clWindow;
      Sender.Canvas.FillRect(Item.DisplayRect(drIcon));
      if Item.ImageIndex=-1 then Exit;
      xBitmap:=TBitmap.Create;
      TListView(Sender).SmallImages.GetBitmap(Item.ImageIndex,xBitmap);

    ListView - великий и ужасный! - в режиме OwnerDraw.
    Писал диспетчер процессов. Когда я разрешил прятать столбцы и включил свойство FullDrag, моя жизнь круто изменилась.

    antipattern, 19 Июня 2017

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

    +2

    1. 1
    return ( empty( $syndication_meta ) ? false : true );

    ldv_a, 16 Июня 2017

    Комментарии (0)
  5. Java / Говнокод #23132

    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
    29. 29
    30. 30
    31. 31
    32. 32
    33. 33
    import java.util.*;
    
    
    public class Main
    {
    	public static void main(String[] args) throws InterruptedException
    	{
    		StringBuilder s = new StringBuilder("#");
    		byte a=1;
    		boolean t=false;
    		while(true)
    		{
    			if(!t)
    			{
    				s.append("#");
    				a++;
    			}
    			if(a==40)
    			{
    				t=true;
    			}
    			if(a==0)
    			    t=false;
    			if(t)
    			{
    				s.deleteCharAt(s.length()-1);
    				a--;
    			}
    			System.out.println(s);
    			Thread.sleep(100);
    		}
    	}
    }

    Красиво зато вышло

    Anineshnica, 15 Июня 2017

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

    +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
    public function sql ($sql) {
    	$r = array(
    		"'" => "", //ору с этого
    		'"' => '',
    		'DROP' => '',
    		'TRUNCATE' => '',
    		'SELECT' => '',
    		'UPDATE' => '',
    		'INSERT' => '',
    		'DELETE' => '',
    		'INSERT' => '',
    		'UNION' => ''
    	);
    
    	if($this->strposa(strtoupper($sql), array_keys($r))){
    		mail('[email protected]', 'Внимание!', 'Обнаружена попытка SQL инъекции: "'.$sql.'" с IP адреса: '.$_SERVER['REMOTE_ADDR']);
    	}
    
    	$sql = str_ireplace(array_keys($r), $r, $sql);
    	$sql = htmlspecialchars($sql);
    	$sql = strip_tags($sql);
    	$sql = stripslashes($sql);
    
    	return $sql;
    }

    enly1, 14 Июня 2017

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

    −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
    public function sendChat ($msg) {
    	if($this->isLogged()){
    		if($this->checkAd($this->sql($msg)) !== '' || $this->checkAd($this->sql($msg))[0] !== ' '){
    			$q = $this->db->row("SELECT * FROM `chat` WHERE `user` = '".intval($_SESSION['steamid'])."' ORDER BY `id` DESC LIMIT 1");
    			if($q->time+1 <= time()){
    				if($q->text != $this->checkAd($this->sql($msg))) {
    					$r = $this->db->query("INSERT INTO `chat` (`user`,`text`,`time`) VALUES ('".intval($_SESSION['steamid'])."', '".$this->sql($this->checkAd($msg))."', ".time().")");
    					return json_encode(array("success" => true,));
    				} else {
    					return json_encode(array("success" => false, "msg" => "flood"));
    				}
    			} else {
    				return json_encode(array("success" => false, "msg" => "flood"));
    			}
    		} else {
    			json_encode(array("success" => false, "msg" => "null_msg"));
    		}
    	} else {
    		return json_encode(array("success" => false, "msg" => "not_auth"));
    	}
    }

    enly1, 14 Июня 2017

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

    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
    29. 29
    30. 30
    31. 31
    32. 32
    33. 33
    34. 34
    /* Технические работы */
    		if($_SERVER['REMOTE_ADDR'] !== '87.103.101.202') die($tpl->get('tech', TPL, $language));
    
    	/* Авторизованным */
    		if($api->isLogged()){
    			$login = $tpl->get('nologon', TPL, $language);
    			/* Список заменяемых слов */
    				$replace = array(
    					""
    				);
    			/* Показывание авторизированному юзеру */
    				$login = str_replace(array_keys($replace), $replace, $login);
    		} else {
    			$login = $tpl->get('logon', TPL, $language);
    		}
    
    	/* Запуск шапки сайта */
    		$header = $tpl->get('header', TPL,  $language);
    		/* Список заменяемых слов */
    			$replace = array(
    				"%login%" => $login
    			);
    		/* Показывание шапки */
    			echo str_replace(array_keys($replace), $replace, $header);
    
    	/* Переключение по адресам */
    		switch ($uri[0]) {
    
    			/* Главная страница */
    			default:
    				echo $tpl->get('home', TPL,  $language);
    				break;
    			
    		}

    enly1, 14 Июня 2017

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

    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
    /* Регистрация */
    	public function register ($log, $pass, $pass2, $email) {
    		/* Стандартная проверка */
    			if(isset($_SESSION['userid'])) return "already_auth";
    			if(!preg_match("/^[a-zA-Z0-9]+$/", $log)) return "rus_or_eng";
    			if(strlen($log) < 5 or strlen($log) > 31) return "log_min_5";
    			if($pass != $pass2) return "pass1_not_equal_pass2";
    			if(strlen($pass) < 8 or strlen($pass) > 31) return "pass_min_8";
    		/* Генерация хэша */
    			$hash = md5('davay'.rand().'ebatsa');
    		/* Проверка на существование ника */
    			$q = $this->db->row("SELECT * FROM `users` WHERE `user` = '".$this->sql($log)."'");
    			if($q != null) return "change_nick";
    		/* Занос в базу данных нового пользователя */
    			$q = $this->db->query("INSERT INTO `users` (`user`, `password`, `hash`) VALUES (:login, :password, :hash)",
    				array("login" => $log, "password" => $pass, "hash" => $hash));
    		/* Возвращаем положительный ответ */
    			return true;
    	}

    Хэш не трогал)

    enly1, 14 Июня 2017

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

    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
    /* Проверка текста на рекламу */
    	public function checkAd ($text) {
    		$r = array('.ru','.com','.xyz',
    			'.net','.blue','.red',
    			'.su','.org','.biz','.tk',
    			 '.pro','.pw','.me',
    			 '.eu','.pl','.be',
    			'.us','.in'
    		);
    
    		return str_replace($r, '', $text);
    
    }

    enly1, 14 Июня 2017

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