1. PHP / Говнокод #23402

    +2

    1. 1
    2. 2
    $DB->Query("UPDATE b_search_content SET TITLE ='".$name."' WHERE URL='".$URL."' AND PARAM1='USER'" );
    $DB->Query("UPDATE b_search_content SET TITLE = CONCAT(TITLE,' тел.' '". $phone ." ' '  ' '". $email."' ) WHERE URL='".$URL."' AND PARAM1='USER'" );

    Перед одним сотрудником встала задача изменить содержимое поля индексной таблицы в Bitrix...

    omar, 12 Октября 2017

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

    +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
    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
    <?php
    $page = $_GET['page'];
    $do = $_GET['do'];
    $todo = $_GET['todo'];
    
    //sponsor
    $s = $_GET['s'];
    
    //stupen
    $st = $_GET['st'];
    
    //sponsor
    $u = $_GET['u'];
    
    $email = $_POST['email'];
    $password = $_POST['password'];
    
    $name = $_POST['name'];
    $message = $_POST['message'];
    
    
    $surname = $_POST['surname'];
    $username = $_POST['username'];
    $passrepeat = $_POST['passrepeat'];
    $sponsor = $_POST['sponsor'];
    $skype = $_POST['skype'];
    $perfectmoney = $_POST['perfectmoney'];
    $payeer = $_POST['payeer'];
    $advcash = $_POST['advcash'];
    $bitcoin = $_POST['bitcoin'];
    
    $status = $_POST['status'];
    
    $uac = $_GET['uac'];
    
    $nowis = time();
    
    if ($do == 'login') {
        //id 	name 	email 	username 	password
        $querylogin = "SELECT * FROM `users`";
        $datalogin = mysql_query($querylogin);
        while ($rowlogin = mysql_fetch_array($datalogin)) {
            $usercheck_id = $rowlogin['id'];
            $usercheck_mail = $rowlogin['email'];
            $usercheck_pass = $rowlogin['password'];
            $usercheck_name = $rowlogin['name'];
            $usercheck_username = $rowlogin['username'];
    
            if ($usercheck_username == $username) {
                if ($usercheck_pass == $password) {
                    $_SESSION['user'] = $usercheck_id;
                    $inmsg = 'Привет ' . $usercheck_name . '!';
                    $page = 'cabinet';
                } else {
                    $err_msg = 'Неправильные пароль или аккаунт!';
                }
            } else {
                $err_msg = 'Неправильные пароль или аккаунт!';
            }
        }
    }

    Такого дилетанского кода я еще не видел

    kissarat, 12 Октября 2017

    Комментарии (189)
  3. Си / Говнокод #23400

    +6

    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
    #include<stdio.h>
    #include<stdlib.h>	
    #include<string.h>	
    	int main(void){
    	void run_func(char *map[], char *fnt  , char *km , float *x ,  float *y , int line , int row , int lift    );
    				char *long_met[3][8] = {{"mile","0.621371"  ,  "yard","1093.61" , "fut","3280.84" , "duim","39370.1" } ,
    							{ "mile" ,"1.60934" , "yard","0.0009144" ,  "fut","0.0003048" ,  "duim","0.0000254"},
     			   				{"kilometer","1"  , "meter","1000"  ,   "stmeter","100000" ,   "mmeter","1000000" } }; 
    				char *amount[3][4] = { { "gallon" , "0.264172" ,       "quarta" , "1.05669"     } , 
    						{"gallon" , " 3.78541"  ,     "quarta" , "0.946353"   },
    						{"litr" , "1"  , "mililitr" , "1000"   }};
    				char *mass[3][8] = {   {"eng.tonna","0.984207"  ,  "amer.tonna","1.10231" , "stone","157.473" , "funt","2204.62" } ,
       						{ "eng.tonna" , "1.01605" , "amer.tonna", "0.907185" ,  "stone","0.00635029" ,  "funt","0.000453592"},
    						{"tonna","1" ,         "kilogram" , "1000"  , "miligram","100000"   , "microgram","1000000"  }}; 
    				char **cp;
    				char *buf_data;
    				char *fnt_sys;
    				char *mtr_sys;
    				char *word[100];
    	while(1){
    	int bg  = 0,convert_ch = 3,y = 0, d = 0, numb = 0;
      	float mn =0  , xm = 0 ;
    	printf("%s", "enter data for converter: ");
    		fgets( (char *) word, 99 ,stdin);
    		buf_data = strtok((char *) word, " ");
    		if( ! strcmp(buf_data, "funt.sys"   )     ){
    		convert_ch = 0;	
    		}
    		else	if( ! strcmp(buf_data, "metric.sys"    )     ){
    			convert_ch = 1;	
    		}
    		for( bg = 0 ;  buf_data != NULL;  buf_data = strtok(NULL, " ")  , bg++ ) {
    			switch(bg){
    				case 1:
    					if( !strcmp("long_met" , buf_data  )  ){
    			  			 y	=   sizeof(*long_met) / sizeof(long_met[0][0]); 
    	          	      	                 d	=   sizeof(long_met) /   sizeof(long_met[0][0]); 
    			  		        cp  = &long_met[convert_ch][0]  ;
    					}
    			   		else if(!strcmp("amount" , buf_data  ) ){
    			  			 y	= sizeof(*amount) /  sizeof(amount [0][0]); 
    		            	                 d	= sizeof(amount) /  sizeof(amount[0][0]); 
    				    	        cp = &amount[convert_ch][0] ;
    					}
    				 	else if(!strcmp("mass" , buf_data  ) ){
    				  		 y	= sizeof(*mass ) /  sizeof(mass[0][0]); 
    		         		         d	= sizeof(mass ) /  sizeof(mass[0][0]); 
    				 		 cp = &mass[convert_ch][0] ; 
    					}
    					break;
    				case 2:
    				fnt_sys = buf_data;
    					break;
    				case 3:
    				mtr_sys = buf_data;
    					break;
    				case 4:
    				numb =   atoi(buf_data);
    					break;
    			}
    		}
    		if( !y || !d || !cp || convert_ch == 3 || !numb ){
    	
    			puts("error");
    		}
    		else{
    			run_func( cp,   fnt_sys ,  mtr_sys , &mn ,  &xm , y  , d , convert_ch );
    			if( !mn || !xm  ){
    		puts("error");
    				} else{
    			printf("%f\n" , !convert_ch  ?    (mn  /  xm ) * numb :  (  mn  *  xm   ) * numb         );	
    			}
    		}
    	}
    	return 0;
    	}
    	void run_func(char *map[], char *fnt  , char *km , float *x ,  float *y , int line , int row  , int lift    ){
    		int m ;
    	if(  ( lift )   ){
    			row    -= line;	
    		}
    	for(  m = 0 ; m <= line   ; m++){
    		if(!strcmp(fnt,map[m])){
    			*x = atof(map[m  + 1] )  ;
    			break;
    			}
    		}
    	for( m =   (row  - line) ; m <=  row - 1  ; m++){
    		if( !strcmp( km   ,  map[m] ) ){
    			*y = atof(map[m  + 1 ] );
    			break;
    				}
    			}
    		}

    gne4do, 11 Октября 2017

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

    +4

    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
    <?php
    namespace LoadBalance\Sensors;
    class CPUSensor extends Sensor
        {
    	/**
    	 * Calculate pause to sleep machine
    	 *
    	 * @retutn int Seconds to sleep
    	 */
    	public static function calculate():int
    	    {
    		$load    = sys_getloadavg();
    		$current = $load[0];
    		if ($current <= 15)
    		    {
    			$sleeptime = 0;
    		    }
    		else if ($current > 15 && $current <= 30)
    		    {
    			$sleeptime = 5;
    		    }
    		else if ($current > 30 && $current <= 50)
    		    {
    			$sleeptime = 10;
    		    }
    		else
    		    {
    			$sleeptime = 60;
    		    } //end if
    		return $sleeptime;
    	    } //end calculate()
        } //end class
    ?>

    Чем больше ядер, тем крепче спишь (с)
    Оригинал в исполнении пыхокачка: https://github.com/AndreyMashukov/throttler

    Stallman, 10 Октября 2017

    Комментарии (12)
  5. Ruby / Говнокод #23398

    +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
    def with_batched_ids(count, ids)
      if ids.is_a? Array
        if ids.length > 1
          ids.each_slice(count) do |ids|
            yield(ids)
          end
        else
          yield(ids)
        end
      else
        yield(ids)
      end
    end

    Заshitное программирование и просто красивая портянка из yield - end - else. Как на ровном месте придумать целый метод.

    strax, 10 Октября 2017

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

    +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
    if ((region.indexOf('Москва') != -1 && (city.indexOf('Троицк') != -1 || city.indexOf('Зеленоград') != -1 || city.indexOf('Щербинка') != -1)) || (region.indexOf('Санкт-Петербург') != -1 && (city.indexOf('Зеленогорск') != -1 || city.indexOf('Колпино') != -1 || city.indexOf('Пушкин') != -1 || city.indexOf('Сестрорецк') != -1 || city.indexOf('Ломоносов') != -1 || city.indexOf('Павловск') != -1 || city.indexOf('Красное Село') != -1 || city.indexOf('Петергоф') != -1 || city.indexOf('Кронштадт') != -1))) {
        addressComponents.add({
            addressComponents.add({
                prefix: "",
                value: region
            });
        });
    } else if (region.indexOf('Москва') == -1 && region.indexOf('Санкт-Петербург') == -1 && region.indexOf('Севастополь') == -1 && region.indexOf('Байконур') == -1) {} else if (region.indexOf('Москва') == -1 && region.indexOf('Санкт-Петербург') == -1 && region.indexOf('Севастополь') == -1 && region.indexOf('Байконур') == -1) {
        addressComponents.add({
            addressComponents.add({
                prefix: "",
                value: region
            });
        });
    }

    GaryFreeman, 10 Октября 2017

    Комментарии (3)
  7. Си / Говнокод #23396

    +9

    1. 1
    gist.github.com/superhackkiller1997/c479a4216b3ab15171db

    d_fomenok, 09 Октября 2017

    Комментарии (37)
  8. C++ / Говнокод #23395

    +2

    1. 1
    https://twitter.com/meetingcpp/status/917350967091310598

    Приключения крестобляди и мнимой единицы. Зато метушню умеет.

    subaru, 09 Октября 2017

    Комментарии (32)
  9. Assembler / Говнокод #23394

    +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
    tms     код DSP   пример MMACF32
    
          msubf32      MR1,MR1,MR2        ;
       || mmov32  @point14,mr0            ;
          mmov32  @point15,mr1            ;
    ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
          mmov32       mr2,@point01         ;     01
          msubf32      mr2,mr2,mr1          ;     01-15
       || mmov32       mr1,@_cos2           ;           B
    ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
          mmpyf32      mr2,mr2,mr1          ;mr2=(01-15)B
       || mmov32       mr1,@point02         ;     02
          msubf32      mr0,mr1,mr0          ;mr0=(02-14)
       || mmov32       mr1,@_cos4           ;           C
          mmov32       mr3,@point00         ;     00
    ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
          mmacf32      mr3,mr2,mr2,mr1,mr0  ;mr3=00+(01-15)B mr2=(02-14)C
       || mmov32       mr0,@point03         ;
          mmov32       mr1,@point13         ;
          msubf32      mr0,mr0,mr1          ;
       || mmov32       mr1,@_cos6           ;
    ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
          mmacf32      mr3,mr2,mr2,mr1,mr0  ;mr3=00+(01-15)B+(02-14)C mr2=(03-13)D
       || mmov32       mr0,@point05         ;
          mmov32       mr1,@point11         ;
          msubf32      mr0,mr0,mr1          ;
       || mmov32       mr1,@_cos10          ;
    ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
     ...............

    maxxx, 09 Октября 2017

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

    +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
    #include <iostream>
    #include <algorithm>
    
    using namespace std;
    
    int main() {
        std::string s = "";
        std::getline(std::cin, s);
        int max = 0;
        long max_n = 0;
        string curr = "";
        s += ' ';
        for(char& c : s) {
            if(c == '0' || c == '1' || c == '2' || c == '3' || c == '4' || c == '5' || c == '6' || c == '7' || c == '8' || c == '9')
                curr += c;
            else {
                max_n = std::atoi(curr.c_str());
                if (max_n >= max) {
                    max = max_n;
                }
                curr.erase(curr.begin(), curr.end());
            }
        }
        cout << max << endl;
        return 0;
    }

    Ну что, парень, костыльнём?

    Caladrius, 09 Октября 2017

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