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

    +157

    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
    function convert($str,$ky=''){
      if($ky=='')return $str;
      $ky=str_replace(chr(32),'',$ky);
      if(strlen($ky)<8)exit('key error');
      $kl=strlen($ky)<32?strlen($ky):32;
      $k=array();
      for($i=0;$i<$kl;$i++){
        $k[$i]=ord($ky{$i})&0x1F;
      }
      $j=0;
      for($i=0;$i<strlen($str);$i++){
        $e=ord($str{$i});
        $str{$i}=$e&0xE0?chr($e^$k[$j]):chr($e);
        $j++;
        $j=$j==$kl?0:$j;
      }
      return $str;
    }

    PHPASTA

    bugmenot, 27 Января 2011

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

    +165

    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
    $_FILTER_MODULE = array(
    "A","a","B","b","C","c","D","d","E","e",
    "F","f","G","g","H","h","I","i","J","j",
    "K","k","L","l","M","m","N","n","O","o",
    "P","p","Q","q","R","r","S","s","T","t",
    "U","u","V","v","W","w","X","x","Y","y",
    "Z","z","-");
    
    $_FILTER_ACTION = array(
    "A","a","B","b","C","c","D","d","E","e",
    "F","f","G","g","H","h","I","i","J","j",
    "K","k","L","l","M","m","N","n","O","o",
    "P","p","Q","q","R","r","S","s","T","t",
    "U","u","V","v","W","w","X","x","Y","y",
    "Z","z","-");
    
    define("CHARS_LOGIN", "0123456789AaBbCcDdEeFfGgHhIiJjKkLlMmNnOoPpQqRrSsTtUuVvWwXxYyZzАаБбВвГгДдЕеЁёЖжЗзИиЙйКкЛлМмНнОоПпРрСсТтУуФфХхЦцЧчШшЩщЪъЫыЬьЭэЮюЯя-");
    define("CHARS_PASS", "0123456789AaBbCcDdEeFfGgHhIiJjKkLlMmNnOoPpQqRrSsTtUuVvWwXxYyZz");
    define("CHARS_FNAME", "AaBbCcDdEeFfGgHhIiJjKkLlMmNnOoPpQqRrSsTtUuVvWwXxYyZzАаБбВвГгДдЕеЁёЖжЗзИиЙйКкЛлМмНнОоПпРрСсТтУуФфХхЦцЧчШшЩщЪъЫыЬьЭэЮюЯя-");
    define("CHARS_LNAME", "AaBbCcDdEeFfGgHhIiJjKkLlMmNnOoPpQqRrSsTtUuVvWwXxYyZzАаБбВвГгДдЕеЁёЖжЗзИиЙйКкЛлМмНнОоПпРрСсТтУуФфХхЦцЧчШшЩщЪъЫыЬьЭэЮюЯя-");
    define("CHARS_EMAIL", "0123456789AaBbCcDdEeFfGgHhIiJjKkLlMmNnOoPpQqRrSsTtUuVvWwXxYyZz@-_.");
    $_FILTER_ID = array("0","1","2","3","4","5","6","7","8","9");
    $_FILTER_INT = array("0","1","2","3","4","5","6","7","8","9");
    
    function Filter($Str, $Filter) {
    	$NewStr = NULL;
    	$k = 0;
    	for($i = 0; $i<strlen($Str); $i++) {
    		for($n = 0; $n<sizeof($Filter); $n++) {
    			if($Str{$i} == $Filter[$n]) {
    				$NewStr[$k] = $Str[$i];
    				$k++;
    			}
    		}
    	}
    	return (string) @implode($NewStr);
    }
    
    function is_valid($value, $chars, $min_len, $max_len) {
    	$value_len = mb_strlen($value);
    	$chars_len = mb_strlen($chars);
    	$char_valid = false;
    	if($value_len > $max_len || $value_len < $min_len) {
    		return false;
    	}
    	for($i = 0; $i < $value_len; $i++) {
    		$char_valid = false;
    		for($k = 0; $k < $chars_len; $k++) {
    			if($value{$i} == $chars{$k}) {
    				$char_valid = true;
    			}
    		}
    		if($char_valid == false) {
    			return false;
    		}
    	}
    	return true;
    }

    Моё, октябрь 2009 =)

    Devzirom, 26 Января 2011

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

    +171

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    eval("\$f_".$fld[$i]."_year = substr(\$f_".$fld[$i].", 0, 4);");
    eval("\$f_".$fld[$i]."_month = substr(\$f_".$fld[$i].", 5, 2);");
    eval("\$f_".$fld[$i]."_day = substr(\$f_".$fld[$i].", 8, 2);");
    eval("\$f_".$fld[$i]."_hours = substr(\$f_".$fld[$i].", 11, 2);");
    eval("\$f_".$fld[$i]."_minutes = substr(\$f_".$fld[$i].", 14, 2);");
    eval("\$f_".$fld[$i]."_seconds = substr(\$f_".$fld[$i].", 17, 2);");

    Зачем нам ${"f_".$fld[$i]."_year"} ?

    nex2hex, 26 Января 2011

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

    +161

    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
    <?php
    
    function info_user($USER_UIN, $volume="all"){
            $sql=mysql_query("SELECT * FROM `users` WHERE `uin`='$USER_UIN'");
            $req=mysql_fetch_assoc($sql);
            if($req['status']!='user') $status=" <font color='blue'>({$req['status']})</font>";
            if($req['sex']!=0) {$sex="Пол: "; if($req['sex']==1) $sex.="Мужской"; elseif($req['sex']==2) $sex.="Женский"; $sex.="<br>";}
            $end.= "<b>".htmlspecialchars($req['login'], ENT_QUOTES)." ({$req['uin']}</b>) <br>
            <small>".$req['public_status']."</small>$status<br>
            $sex    <br><br><br><br><br>
            ";//это 331 строка
            
            return $end;
            }

    qbasic, 26 Января 2011

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

    +144

    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
    b1=100+(int)(255.0*rand()/(RAND_MAX+100.0));
    b2=100+(int)(255.0*rand()/(RAND_MAX+100.0));
    b3=100+(int)(255.0*rand()/(RAND_MAX+100.0));
    b4=100+(int)(255.0*rand()/(RAND_MAX+100.0)); if(b1>255)
    sprintf(b1s,"%d",b1);
    sprintf(b2s,"%d",b2);
    sprintf(b3s,"%d",b3);
    sprintf(b4s,"%d",b4);
    strcat(b1s,".");
    strcat(b2s,".");
    strcat(b3s,".");
    strcat(b1s,b2s);
    strcat(b1s,b3s);
    strcat(b1s,b4s);
    iph->ip_src.s_addr = inet_addr (b1s);

    Some firewalls, such as ZoneAlarm Pro, detect SYN Flood and block the source IP address (see Figure 1). So we need to assign our spoofed source IP address a random number as shown below:

    http://linux.sys-con.com/node/34589

    вот какой шедевр откопал

    danilissimus, 26 Января 2011

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

    +158

    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
    class Relay {
      protected $_data = array();
      protected $_devices;
      static protected $_db_fields = array();
    
      function getId() {
        return $this->_data['id'];
      }
      static function load($id) {
        if ($id) {
          $select = db_select('relay', 'r');
          $select->fields('r');
          $select->condition('r.id', $id);
          $relay = $select->execute()->fetchObject(__CLASS__);
          return $relay;
        }
      }
      function save() {
        foreach (array_diff(array_keys($this->_data), self::_getPureDbFields('relay')) as $field) {
          $this->_data['data'] = $this->_data[$field];
        }
    
        if ($this->getId()) {
          drupal_write_record('relay', $this->_data, array('id'));
        }
        else {
          drupal_write_record('relay', $this->_data);
        }
        $this->_saveDevices();
      }
      protected function _saveDevices() {
        if ($this->getId()) {
          $delete = db_delete('relay_devices');
          $delete->condition('relay_id', $this->getId());
          $delete->execute();
    
          foreach ((array)$this->_devices as $device) {
            $device = (array) $device;
            foreach (array_diff(array_keys($device), self::_getPureDbFields('relay_devices')) as $field) {
              $device['data'] = $device[$field];
            }
    
            drupal_write_record('relay_devices', $device);
          }
        }
      }
      function getDateFrom() {
        return $this->_data['date_from'];
      }
      function getDateDuration(){
        return $this->_data['date_duration'];
      }
      function getDateTo(){
        return $this->getDateFrom() + $this->getDateDuration();
      }
      function getDevices(){
        $this->_ensureDevicesLoaded();
        return $this->_devices;
      }
      protected function _ensureDevicesLoaded() {
        if (!is_array($this->_devices)) {
          $select = db_select('relay_devices', 'rd');
          $select->fields('rd');
          $select->condition('rd.relay_id', $this->getId());
          $query = $select->execute();
    
          $this->_devices = array_map('drupal_unpack', $query->fetchAll());
        }
        return is_array($this->_devices);
      }
      function __construct($data = NULL) {
        if (is_array($data)) {
          foreach ($data as $key => $value) {
            $this->_data[$key] = $value;
          }
        }
        elseif (is_string($this->_data['data']) && !empty($this->_data['data'])) {
          drupal_unpack($this);
        }
      }
      function __set($name, $value) {
        return $this->_data[$name] = $value;
      }
      function __get($name) {
        return $this->_data[$name];
      }
      static protected function _getPureDbFields($table) {
        if (!isset(self::$_db_fields[$table])) {
          $schema = drupal_get_schema($table);
          $fields = $schema['fields'];
          unset($fields['data']);
          self::$_db_fields[$table] = array_keys($fields);
        }
    
        return self::$_db_fields[$table];
      }
    }

    vectoroc, 26 Января 2011

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

    +162

    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
    QString calcFileSize( qint64 value ) 
    {  //pay attention that for size<1M "" returned
    	QString sizeStr = "";
    	if (value > 99ll * 1000ll * 1000ll * 1000ll * 1000ll)
    		sizeStr = QString::number ((((value / 1000) / 1000) / 1000) / 1000) + QObject::tr (" TB");
    	else if (value > 99ll * 1000ll * 1000ll * 1000ll)
    		sizeStr = QString::number (((value / 1000) / 1000) / 1000) + QObject::tr (" GB");
    	else if (value > 99 * 1000 * 1000)
    		sizeStr = QString::number (((value / 1000) / 1000)) + QObject::tr (" MB");
    	else if (value > 99 * 1000)
    		sizeStr = QString::number ((value / 1000) ) + QObject::tr (" KB");
    	else
    		sizeStr = QString::number (value) + QObject::tr (" Bytes");
    	return sizeStr;
    }

    Без слов.

    panter_dsd, 26 Января 2011

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

    +161

    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
    //Проверка чекбоксов
    for ($r=0; $r<1000; $r++) {
        if ($_POST["id$r"] == 'on') {
           //echo "id$r";
    
           $yppi=mysql_query("DELETE FROM joomlabd1.jos_favorit WHERE id='$r' AND fav='$Uname'")
          or die("Не поучилось");
       }
    }
    
    //Формирование формы
    //в $i хранится id записи в базе
    echo "<div align=\"right\"> Удалить запись <input type=\"checkbox\" name=\"id$i\">

    Чувак осуществляет фантастическую проверку отмеченный чекбоксов

    isergey, 26 Января 2011

    Комментарии (6)
  9. Java / Говнокод #5397

    +144

    1. 1
    bouncer1.pos.x = 1 + (int) (420D * this.rand.nextDouble());

    Random, да не тот

    Lure Of Chaos, 26 Января 2011

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

    +145

    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
    switch (this.gameState) {
        case 2: // '\002'
        case 3: // '\003'
          this.setGameState(4);
          return;
        case 6: // '\006'
          this.setGameState(4);
          return;
        case 4: // '\004'
          switch (keyevent.getKeyCode()) {
          case 80: // 'P'
            this.setGameState(6);
            return;
          case 37: // '%'
            this.changePukSpeed(-1, 0);
            return;
          case 39: // '\''
            this.changePukSpeed(1, 0);
            return;
          case 38: // '&'
            this.changePukSpeed(0, -1);
            return;
          case 40: // '('
            this.changePukSpeed(0, 1);
            return;
          }
          // fall through
        case 5: // '\005'
        default:
          return;
        }

    хитрая логика

    Lure Of Chaos, 26 Января 2011

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