1. Лучший говнокод

    В номинации:
    За время:
  2. JavaScript / Говнокод #6401

    +156

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    11. 11
    12. 12
    try {
        document.domain = "wolframalpha.com";
        context = parent ? parent : document;
        } catch(e){}
        try { 
            if (typeof(context.$) == "undefined") {
                context = window;
            } else {
                $=context.$;
            }
        }
        catch(e){ context = window; }

    Если с первого раза не получилось...

    RaZeR, 19 Апреля 2011

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

    +156

    1. 1
    2. 2
    3. 3
    list($year, $month, $day) = split('[/.-]', $r['data']);
    //$month = $man[(int)$month];
    $date = "$day.$month.$year";

    DATE_FORMAT

    De-Luxis, 19 Апреля 2011

    Комментарии (13)
  4. JavaScript / Говнокод #6345

    +156

    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
    this.resetFunctions = function() {
      		this.onLoading = function() { };
      		this.onLoaded = function() { };
      		this.onInteractive = function() { };
      		this.onCompletion = function() { };
      		this.onError = function() { };
    		this.onFail = function() { };
    	};
    
    	this.reset = function() {
    		this.resetFunctions();
    		this.resetData();
    	};
    
    	this.createAJAX = function() {
    		try {
    			this.xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
    		} catch (e1) {
    			try {
    				this.xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
    			} catch (e2) {
    				this.xmlhttp = null;
    			}
    		}

    =)нашел с другом на сайте россдневник http://****/FrontPage.aspx можете сами поскать в JS

    BlackMonolit, 14 Апреля 2011

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

    +156

    1. 1
    2. 2
    3. 3
    4. 4
    var index = this.pics.indexOf(e);
    if (index != this.pics.indexOf(this.pics[0])) {
       var left = '<span class="'+this.clName+'_wrapper_pager '+this.clName+'_wrapper_pager_Left" onclick="bigpic.pager(e);" title="Предыдушая">&larr; + Ctrl </span>';
    }

    4Eki, 06 Апреля 2011

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

    +156

    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
    if (licenseImageAvailable) {
        QPoint p1, p2, p3;
        p1.setX (top->getUIntSeq ("X1",licenseImageAvailable));
        p1.setY (top->getUIntSeq ("Y1",licenseImageAvailable));
        p2.setX (top->getUIntSeq ("X2",licenseImageAvailable));
        p2.setY (top->getUIntSeq ("Y2",licenseImageAvailable));
        p3.setX (top->getUIntSeq ("X3",licenseImageAvailable));
        p3.setY (top->getUIntSeq ("Y3",licenseImageAvailable));
    
        if (licenseImageAvailable)
          seq = seq && imageElement->getNeedJPEG (targetSize.width (),
                                                  targetSize.height (), &targetImg, top, &licenseImage, p1, p2, p3);
        else
          seq = seq && imageElement->getNeedJPEG (targetSize.width (), targetSize.height (), &targetImg, top);
      } else {
    
        seq = seq && imageElement->getNeedJPEG (targetSize.width (), targetSize.height (), &targetImg, top);
      }

    panter_dsd, 04 Апреля 2011

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

    +156

    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
    class QueryWhereGroup {
      public $groupOp = 'AND';
      public $args = array();
      public $conditions = array();
    
      function cond($field, $value = NULL, $op = '=') {
        if ($value === NULL) {
          $this->conditions[] = $field;
          if (is_object($field) && isset($field->args)) {
            $this->args = array_merge($this->args, $field->args);
          }
        }
        else {
          if (is_numeric($value)) {
            $this->conditions[] = "$field $op %d";
            $this->args[]  = $value;
          }
          elseif (is_array($value)) {
            $placeholders  = db_placeholders($value, is_numeric(current($value)) ? 'int' : 'text');
            $this->conditions[] = "$field  IN ($placeholders)";
            $this->args = array_merge($this->args, $value);
          }
          else {
            $this->conditions[] = "$field $op '%s'";
            $this->args[]  = $value;
          }
        }
    
        return $this;
      }
    
      function compile($wrap = FALSE) {
        $result = join(" $this->groupOp ", $this->conditions);
        if ($wrap && !empty($result)) {
          $result = "(\n$result\n)";
        }
    
        return $result;
      }
    
      function __toString() {
        return $this->compile();
      }
    }

    см. след говнокод

    vectoroc, 23 Марта 2011

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

    +156

    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
    if (!isset($_SERVER['PHP_AUTH_USER']))
     
    {
            Header ("WWW-Authenticate: Basic realm=\"Admin Page\"");
            Header ("HTTP/1.0 401 Unauthorized");
            exit();
    }
     
    else {
            if (!get_magic_quotes_gpc()) {
                    $_SERVER['PHP_AUTH_USER'] = mysql_escape_string($_SERVER['PHP_AUTH_USER']);
                    $_SERVER['PHP_AUTH_PW'] = mysql_escape_string($_SERVER['PHP_AUTH_PW']);
            }
     
            $query = "SELECT pass FROM userlist WHERE user='".$_SERVER['PHP_AUTH_USER']."'";
            $lst = @mysql_query($query);
     
            if (!$lst)
            {
                Header ("WWW-Authenticate: Basic realm=\"Admin Page\"");
            Header ("HTTP/1.0 401 Unauthorized");
            exit();
            }
     
            if (mysql_num_rows($lst) == 0)
            {
               Header ("WWW-Authenticate: Basic realm=\"Admin Page\"");
               Header ("HTTP/1.0 401 Unauthorized");
               exit();
            }
     
            $pass =  @mysql_fetch_array($lst);
            if ($_SERVER['PHP_AUTH_PW']!= $pass['pass'])
            {
                Header ("WWW-Authenticate: Basic realm=\"Admin Page\"");
               Header ("HTTP/1.0 401 Unauthorized");
               exit();
            }
     
     
    }

    Авторизация

    nepster, 20 Марта 2011

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

    +156

    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
    $properties_array = array_keys($this->values);
                array_unshift($properties_array, $properties_array[0]);
                unset($properties_array[0]);
                $properties_values_array = array_values($properties_array);
                $values_array = array_values($this->values);
                $properties = implode('` ,`', $properties_values_array);
                $values = implode(', ', array_fill(0, count($this->values), '?'));
                $result = self::$orm->db->prepare('INSERT INTO `' . $this->table . '`  (`' . $properties . '`) values (' . $values . ')');
                foreach ($values_array as $key => $value) {
                    $fieldinfo = $this->fields[$properties_values_array[$key]];
                    $result->bindParam($key + 1, $values_array[$key], $this->correctDataType($fieldinfo['native_type'], $fieldinfo['pdo_type']), $fieldinfo['len']);
                }
                $result->execute();

    Чувствую код плохо пахнет, надо разбирать)) Высоко нагруженный проект ;)

    PANACEA, 15 Марта 2011

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

    +156

    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
    <?
    function FindTag($Tag,$Page,$Offset=0) // Ищет тег $Tag в странице $Page от символа с номером $Offset
    {
    	$Tag=strtoupper($Tag);
    	$Page=strtoupper($Page);
    	$Pos=array(0,0,0,0);
    	$Pos[0]=StrPos($Page,'<'.$Tag,$Offset);
    	
    	if ($Pos[0]<$Offset) {return False;}
    	
    	if ((Empty($Pos[0])==True)and(SubStr($Page,0,StrLen('<'.$Tag))!='<'.$Tag)) {return False;}
    	$Pos[1]=StrPos($Page,'>',$Pos[0]);
    	
    	if (Empty($Pos[1])==False) {$Pos[1]=$Pos[1]+1;} else {return False;}
    	$Pos[2]=StrPos($Page,'</'.$Tag.'>',$Pos[1]);
    	$Pos[3]=$Pos[2]+StrLen('</'.$Tag.'>');
    	if ((SubStr($Page,$Pos[0]+StrLen('<'.$Tag),1)!=' ')and(SubStr($Page,$Pos[0]+StrLen('<'.$Tag),1)!='>')) {$Pos=FindTag($Tag,$Page,$Pos[1]);}
    	if ((Empty($Pos[1])==False)and($Pos[0]<$Pos[1])) {return $Pos;} else {return False;}
    }
    ?>

    Вот такой пример поиска тегов я нашел по поисковику, автор этих строк явно не знаком с регулярными выражениями...

    Android991, 01 Марта 2011

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

    +156

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    11. 11
    # Преоброзование расширения в MIME тип
    function replace_type_in_mime($type) {
    	$type = strtolower($type);
    	$res = array("323" => "text/h323", "acx" => "application/internet-property-stream", "ai" => "application/postscript", "aif" => "audio/x-aiff", "aifc" => "audio/x-aiff", "aiff" => "audio/x-aiff", "asf" => "video/x-ms-asf", "asr" => "video/x-ms-asf", "asx" => "video/x-ms-asf", "au" => "audio/basic", "avi" => "video/x-msvideo", "axs" => "application/olescript", "bas" => "text/plain", "bcpio" => "application/x-bcpio", "bin" => "application/octet-stream", "bmp" => "image/bmp", "c" => "text/plain", "cat" => "application/vnd.ms-pkiseccat", "cdf" => "application/x-cdf", "cer" => "application/x-x509-ca-cert", "class" => "application/octet-stream", "clp" => "application/x-msclip", "cmx" => "image/x-cmx", "cod" => "image/cis-cod", "cpio" => "application/x-cpio", "crd" => "application/x-mscardfile", "crl" => "application/pkix-crl", "crt" => "application/x-x509-ca-cert", "csh" => "application/x-csh", "css" => "text/css", "dcr" => "application/x-director", "der" => "application/x-x509-ca-cert", "dir" => "application/x-director", "dll" => "application/x-msdownload", "dms" => "application/octet-stream", "doc" => "application/msword", "dot" => "application/msword", "dvi" => "application/x-dvi", "dxr" => "application/x-director", "eps" => "application/postscript", "etx" => "text/x-setext", "evy" => "application/envoy", "exe" => "application/octet-stream", "fif" => "application/fractals", "flr" => "x-world/x-vrml", "gif" => "image/gif", "gtar" => "application/x-gtar", "gz" => "application/x-gzip", "h" => "text/plain", "hdf" => "application/x-hdf", "hlp" => "application/winhlp", "hqx" => "application/mac-binhex40", "hta" => "application/hta", "htc" => "text/x-component", "htm" => "text/html", "html" => "text/html", "htt" => "text/webviewhtml", "ico" => "image/x-icon", "ief" => "image/ief", "iii" => "application/x-iphone", "ins" => "application/x-internet-signup", "isp" => "application/x-internet-signup", "jfif" => "image/pipeg", "jpe" => "image/jpeg", "jpeg" => "image/jpeg", "jpg" => "image/jpeg", "js" => "application/x-javascript", "latex" => "application/x-latex", "lha" => "application/octet-stream", "lsf" => "video/x-la-asf", "lsx" => "video/x-la-asf", "lzh" => "application/octet-stream", "m13" => "application/x-msmediaview", "m14" => "application/x-msmediaview", "m3u" => "audio/x-mpegurl", "man" => "application/x-troff-man", "mdb" => "application/x-msaccess", "me" => "application/x-troff-me", "mht" => "message/rfc822", "mhtml" => "message/rfc822", "mid" => "audio/mid", "mny" => "application/x-msmoney", "mov" => "video/quicktime", "movie" => "video/x-sgi-movie", "mp2" => "video/mpeg", "mp3" => "audio/mpeg", "mpa" => "video/mpeg", "mpe" => "video/mpeg", "mpeg" => "video/mpeg", "mpg" => "video/mpeg", "mpp" => "application/vnd.ms-project", "mpv2" => "video/mpeg", "ms" => "application/x-troff-ms", "mvb" => "application/x-msmediaview", "nws" => "message/rfc822", "oda" => "application/oda", "p10" => "application/pkcs10", "p12" => "application/x-pkcs12", "p7b" => "application/x-pkcs7-certificates", "p7c" => "application/x-pkcs7-mime", "p7m" => "application/x-pkcs7-mime", "p7r" => "application/x-pkcs7-certreqresp", "p7s" => "application/x-pkcs7-signature", "pbm" => "image/x-portable-bitmap", "pdf" => "application/pdf", "pfx" => "application/x-pkcs12", "pgm" => "image/x-portable-graymap", "pko" => "application/ynd.ms-pkipko", "pma" => "application/x-perfmon", "pmc" => "application/x-perfmon", "pml" => "application/x-perfmon", "pmr" => "application/x-perfmon", "pmw" => "application/x-perfmon", "pnm" => "image/x-portable-anymap");
    	if($ret == null) {
    		$ret = "application/x-unknown-content-type";
    	} else {
    		$ret = $res[$type];
    	}
    	return $ret;
    }

    Не знаю смешно ли это или нет, но разобраться в одной километровой строке будет ооочень интересно))))
    Я вас огорчу, пришлось урезать на несколько тысяч символов эту дистанцию))

    nethak, 11 Февраля 2011

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