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

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

    +154

    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
    // $curr_page - старница, на который сейчас находимся
    // $n_page - число страниц
    // $count - обще число записей
    // $param - site - страницы на сайте
    //        - adm - в админке
    function genNumPage($curr_page, $n_page, $count, $param=null) {
        $string = parse_url($_SERVER['REQUEST_URI']);
        $query = '?'.$string['query'];
        $num_page = ceil($count / $n_page);
        if (isset($param))  $table = new my_Page("site/site_interface.html", "num_page");
        else                $table = new my_Page("interface/interface.html", "num_page");
        
        if ($num_page < 2) return null;
        
        for ($i = 1; $i <= $num_page; $i++) {
            if ($i != $curr_page) {
                if (preg_match('/\?p\=[0-9]{1,3}/', $query))        $href = preg_replace('/\?p\=[0-9]{1,3}/', '?p='.$i, $query);
                elseif (preg_match('/\&p\=[0-9]{1,3}/', $query))    $href = preg_replace('/\&p\=[0-9]{1,3}/', '&p='.$i, $query);
                elseif ($string['query'] != '')                     $href = '?'.$string['query'].'&p='.$i;
                else                                                $href = '?p='.$i;
                
                if ((!$param) || ($param == 'adm')) $str .= " <a href=".$string['host'].$string['path'].$href.">".$i."</a> ";
                else                                $str .= " <a href=".$string['host'].$string['path'].$href.">".$i."</a> | ";
            }
            elseif ((!$param) || ($param == 'adm')) $str .= "<span>".$i."</span>";
            else                                    $str .= "<span>".$i."</span> | ";
        }
        
            if ($curr_page > 1) {
            if (preg_match('/\?p\=[0-9]{1,3}/', $query))        $prev = preg_replace('/\?p\=[0-9]{1,3}/', '?p='.($curr_page - 1), $query);
            elseif (preg_match('/\&p\=[0-9]{1,3}/', $query))    $prev = preg_replace('/\&p\=[0-9]{1,3}/', '&p='.($curr_page - 1), $query);
            elseif ($string['query'] != '')                     $prev = '?'.$string['query'].'&p='.($curr_page - 1);
            else                                                $prev = '?p='.($curr_page - 1);;
            
            if ((!$param) || ($param == 'adm')) $prev = " <a href=".$string['host'].$string['path'].$prev." id=\"PrevLink\">&larr;</a> ";
            else                                $prev = " <a href=".$string['host'].$string['path'].$prev." id=\"PrevLink\">Предыдущая</a> ";
        }
        
        if ($curr_page < $num_page) {
            if (preg_match('/\?p\=[0-9]{1,3}/', $query))        $next = preg_replace('/\?p\=[0-9]{1,3}/', '?p='.($curr_page + 1), $query);
            elseif (preg_match('/\&p\=[0-9]{1,3}/', $query))    $next = preg_replace('/\&p\=[0-9]{1,3}/', '&p='.($curr_page + 1), $query);
            elseif ($string['query'] != '')                     $next = '?'.$string['query'].'&p='.($curr_page + 1);
            else                                                $next = '?p='.($curr_page + 1);;
            
            if ((!$param) || ($param == 'adm')) $next = " <a href=".$string['host'].$string['path'].$next." id=\"NextLink\">&rarr;</a> ";
            else                                $next = " <a href=".$string['host'].$string['path'].$next." id=\"NextLink\">Следующая</a> ";
        }
        
        $table->addValueArray(array(
                                    "NUM"   => $str,
                                    "PREV"  => $prev,
                                    "NEXT"  => $next
        ));
        return $table->myReplace();
    }

    Генерирует номера страниц. Из одной CMS'ки.

    netrain, 09 Сентября 2010

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

    +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
    class microTimer {
    	function start() {
    		global $starttime;
    		$mtime = microtime();
    		$mtime = explode( ' ', $mtime );
    		$mtime = $mtime[1] + $mtime[0];
    		$starttime = $mtime;
    	}
    	function stop() {
    		global $starttime;
    		$mtime = microtime();
    		$mtime = explode( ' ', $mtime );
    		$mtime = $mtime[1] + $mtime[0];
    		$endtime = $mtime;
    		$totaltime = round( ($endtime - $starttime), 5 );
    		return $totaltime;
    	}
    }

    DLE 9.0

    Morgan, 06 Сентября 2010

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

    +163

    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
    if (document.all('text1')!=null)
      {
       obj=document.all('text1');
       obj.style.position='absolute';
       obj.style.left=785+k;
       obj.style.top=66;
      }
      if (document.all('text1')!=null)
      {
      obj=document.all('text2');
      obj.style.position='absolute';
      obj.style.left=785+k;
      obj.style.top=88;
      }
      if (document.all('text1')!=null)
      {
      obj=document.all('img1');
      obj.style.position='absolute';
      obj.style.left=730+k;
      obj.style.top=72;
      }
      if (document.all('text1')!=null)
      {
      obj=document.all('img2');
      obj.style.position='absolute';
      obj.style.left=904+k;
      obj.style.top=84;
      }
      if (document.all('text1')!=null)
      {
      obj=document.all('img3');
      obj.style.position='absolute';
      obj.style.left=785+k;
      obj.style.top=39;
      }
      if (document.all('text1')!=null)
      {
      obj=document.all('img4');
      obj.style.position='absolute';
      obj.style.left=795+k;
      obj.style.top=109;
      }

    Надеюсь, что это генерировали в цикле, а не писали руками.

    telnet, 31 Августа 2010

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

    +167

    1. 1
    $select->where('target_table.param IN (' . implode(',', array_map(create_function('$e', '{return "\'$e\'";}'), $entities)) . ')');

    Недавно наткнулся на такое :)

    ko1Rn, 27 Августа 2010

    Комментарии (4)
  6. Python / Говнокод #4113

    −101

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    #TROLOLO GENERATOR!
    def trololo(x):
        print 'tro'+('lo'*x)
        
    trololo(100)

    Если нужно потроллить!

    boltayka, 27 Августа 2010

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

    +160

    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
    if($usershow != 0) {
    				
    	$site->AddBlock('topnav', true, true, 'tn');
    				
    	$var['nav'] = '';
    				
    	$site->AddSubBlock('topnav', true, $var);
    				
    } else {
    				
    	$site->AddBlock('topnav', true, true, 'tn');
    				
    	$var['nav'] = $top_nav;
    				
    	$site->AddSubBlock('topnav', true, $var);
    				
    }

    Мартин, 23 Августа 2010

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

    +144

    1. 1
    2. 2
    //massiv[i]=C1^2*(a*i+b)+C2*(a^2*i-b)+(b-a*i)^-12.5; //почемуто не работает
                            massiv[i]=C1*C1*(a*i+b)+C2*(a*a*i-b)+1/((b-a*i)*(b-a*i)*(b-a*i)*(b-a*i)*(b-a*i)*(b-a*i)*(b-a*i)*(b-a*i)*(b-a*i)*(b-a*i)*(b-a*i)*(b-a*i)*sqrt(b-a*i));

    Нашёл проектик :)
    Универ. 1 курс. Лаба по С. Не работает - будем делать кал.
    Интересно, если бы степень была -125, то там было бы 125 умножений?

    XyHb, 23 Августа 2010

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

    +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
    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
    Draggable.prototype.move = function(event){		
    		var event = Runic.event.getEvent(event),
    			mLeft = (this.direction == 'both' || this.direction == 'horizontal') ? (Runic.event.getEventX(event) - this.mdiffX) : this.element.offsetLeft,
    			mTop = (this.direction == 'both' || this.direction == 'vertical') ? (Runic.event.getEventY(event) - this.mdiffY) : this.element.offsetTop,
    		//get cursor position
    			curx = Runic.event.getEventX(event),
    			cury = Runic.event.getEventY(event);
    		if (this.box) {
    			if (this.direction == 'horizontal' || this.direction == 'both') {
    				if (curx > this.fromX && curx < this.toX) {
    					this.element.style.left = mLeft  + 'px';
    				} else if (curx <= this.fromX && this.direction) {
    					if (this.boxCSSPosition == 'relative' || this.boxCSSPosition=='absolute') {
    						this.element.style.left = 0 + 'px'
    						this.element.style.right = 'auto'
    					} else {
    						this.element.style.left = this.box.offsetLeft + 'px'
    					}
    				} else if (curx >= this.toX) {
    					if (this.boxCSSPosition == 'relative' || this.boxCSSPosition=='absolute') {
    						this.element.style.right = 0 + 'px'
    						this.element.style.left = 'auto'
    					} else {
    						this.element.style.left = this.box.offsetLeft + this.box.clientWidth - this.element.clientWidth + 'px'
    					}
    				}
    			}
    			if (this.direction == 'vertical' || this.direction == 'both') {
    				if (cury > this.fromY && cury < this.toY) {
    					this.element.style.top = mTop + 'px';
    				} else if (cury <= this.fromY) {
    					if (this.boxCSSPosition == 'relative' || this.boxCSSPosition=='absolute') {
    						this.element.style.top = 0 + 'px';
    						this.element.style.bottom = 'auto'
    					} else {
    						this.element.style.top = this.box.offsetTop + 'px'
    					}		
    				} else if (cury >= this.toY) {
    					if (this.boxCSSPosition == 'relative' || this.boxCSSPosition=='absolute') {
    						this.element.style.bottom = 0 + 'px';
    						this.element.style.top = 'auto'
    					} else {
    						this.element.style.top = this.box.offsetTop + this.box.clientHeight - this.element.clientHeight + 'px'
    					}
    				}
    			}
    		} else {
    			this.element.style.left = mLeft  + 'px';
    			this.element.style.top = mTop + 'px';
    		}
    		//run callback funciton
    		if (this.onDrag != undefined && typeof this.onDrag.func == 'function') {
    			if (this.onDragCount < this.onDrag.count || this.onDrag.count == 0) {
    				this.onDragCount++;
    				this.onDrag.func();
    			}
    		}
    	}

    наговнокодил

    kubynek, 20 Августа 2010

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

    +116

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    </td>
    </tr>
    
      <br style="clear:both" />
      
    <tr id="rand_<?=$cc?>">

    а вдруг строки - это не совсем строки о_О

    n0ne, 15 Августа 2010

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

    +143

    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
    function changeAlign() {
    try {
    		for(var i = 0; i < document.getElementById("tariff_content").getElementsByTagName("table").length; i++) {
    			if(document.getElementById("tariff_content").getElementsByTagName("table")[i].className == "common") {
    				document.getElementById("tariff_content").getElementsByTagName("table")[i].removeAttribute("cellPadding"); 
    				document.getElementById("tariff_content").getElementsByTagName("table")[i].removeAttribute("cellSpacing");
    				if(document.getElementById("tariff_content").getElementsByTagName("table")[i].tBodies[0].rows[0].cells[0].className != "header"){
    					var firstTDCount = 0;
    					for(var z = 0; z < document.getElementById("tariff_content").getElementsByTagName("table")[i].tBodies[0].rows[0].cells.length; z++) {
    						firstTDCount = firstTDCount + (document.getElementById("tariff_content").getElementsByTagName("table")[i].tBodies[0].rows[0].cells[z].colSpan);
    					}
    					document.getElementById("tariff_content").getElementsByTagName("table")[i].tBodies[0].insertRow(0);
    					for(var j = 0; j < firstTDCount; j++) {
    						document.getElementById("tariff_content").getElementsByTagName("table")[i].tBodies[0].rows[0].insertCell(j);
    						document.getElementById("tariff_content").getElementsByTagName("table")[i].tBodies[0].rows[0].cells[j].className = "header";
    							document.getElementById("tariff_content").getElementsByTagName("table")[i].tBodies[0].rows[0].cells[j].innerText = " "; 
    					}
    				}				
    				for(var j = 0; j < document.getElementById("tariff_content").getElementsByTagName("table")[i].rows.length; j++) {
    					for(var k = 0; k < document.getElementById("tariff_content").getElementsByTagName("table")[i].rows[j].cells.length; k++) {
    						if( 
    							 (document.getElementById("tariff_content").getElementsByTagName("table")[i].rows[j].cells.length > 1) && (k != 0) 
    						   	 && (document.getElementById("tariff_content").getElementsByTagName("table")[i].rows[j].cells[k].className != "header")
    						   ) 
    						{
    							if(document.getElementById("tariff_content").getElementsByTagName("table")[i].rows[j].cells[k - 1].rowSpan == 1) {
    								document.getElementById("tariff_content").getElementsByTagName("table")[i].rows[j].cells[k].style.textAlign = "right";
    								//document.getElementById("tariff_content").getElementsByTagName("table")[i].rows[j].cells[k].style.backgroundColor = "red";
    							}
    							if(document.getElementById("tariff_content").getElementsByTagName("table")[i].rows[j].cells[k].colSpan == 2) {
    								document.getElementById("tariff_content").getElementsByTagName("table")[i].rows[j].cells[k].style.textAlign = "center";
    							}
    							if(document.getElementById("tariff_content").getElementsByTagName("table")[i].rows[j].cells[k].style.width == "60px") {
    								//document.getElementById("tariff_content").getElementsByTagName("table")[i].rows[j].style.backgroundColor = "red";
    								document.getElementById("tariff_content").getElementsByTagName("table")[i].deleteRow(j);
    								break;
    								//document.getElementById("tariff_content").getElementsByTagName("table")[i].rows[j].cells[k].style.width = "";
    							}
    						}
    					}
    				}
    			}
    		}				
    } catch(e) {}	
    return false;	
    }

    http://www.mts.ru/upload/images/script/js.js

    Lure Of Chaos, 12 Августа 2010

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