1. JavaScript / Говнокод #6719

    +169

    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
    <!-- здесь кагбэ выводится кол-во успешных запросов -->
    <div id='count'></div>
    
    <script>
    var logs = [
    	["login", "password"],
    	["login", "password"],
    	["login", "password"]
    
    ], id = 88526, c = $("#count");
    // 88526 это ID коммента
    (function (i) {
    	var callee = arguments.callee;
    	$.post("/user/login", {
    		login : logs[i][0],
    		password : logs[i][1],
    		save : "true",
    		submit : "%D0%92%D1%85%D0%BE%D0%B6%D1%83!"
    	}, function () {
    		// on — головать за; against — голосовать против
    		$.get("/ratings/comment/" + id + "/on", function () {
    			$.get("/user/exit", function () {
    				c.html(i);
    				callee(i + 1);
    			});
    		});
    	});
    })(0);
    </script>

    Внимание! Скрипт для автоматического минусования комментов! Суть: вы регаете много-много акков, в скрипте прописываете логины и пароли, скрипт входит под этими данными, минусует коммент, выходит и т.д. Алсо, если заменить comments на code, можно будет минусовать говнокоды.

    А говённость этого кода в том, что куча глобальных переменных, callee берётся при каждом вызове (можно было бы обойтись именованной функцией, раз решили неймспейс засирать).

    dogmatic, 20 Мая 2011

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

    +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
    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
    if ( '' !== $qv['second'] ) {
              $this->is_time = true;
              $this->is_date = true;
      }
    
    if ( '' !== $qv['minute'] ) {
            $this->is_time = true;
            $this->is_date = true;
    }
    
    if ( '' !== $qv['hour'] ) {
            $this->is_time = true;
            $this->is_date = true;
    }
    
    if ( $qv['day'] ) {
            if ( ! $this->is_date ) {
                    $this->is_day = true;
                    $this->is_date = true;
            }
    }
    
    if ( $qv['monthnum'] ) {
            if ( ! $this->is_date ) {
                    $this->is_month = true;
                    $this->is_date = true;
            }
    }
    
    if ( $qv['year'] ) {
            if ( ! $this->is_date ) {
                    $this->is_year = true;
                    $this->is_date = true;
            }
    }
    
    if ( $qv['m'] ) {
            $this->is_date = true;
            if ( strlen($qv['m']) > 9 ) {
                    $this->is_time = true;
            } else if ( strlen($qv['m']) > 7 ) {
                    $this->is_day = true;
            } else if ( strlen($qv['m']) > 5 ) {
                    $this->is_month = true;
            } else {
                    $this->is_year = true;
            }
    }

    ВротПресс

    telnet, 20 Мая 2011

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

    +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
    16. 16
    17. 17
    18. 18
    19. 19
    20. 20
    switch ($size) { 
       case 'small':
        if ($crop_thumbnail == 3 || $crop_thumbnail == 5 || $crop_thumbnail == 6 || $crop_thumbnail == 7 ) {
         $crop = 1;
        }
       break;
       
       case 'medium':
        if ($crop_thumbnail == 2 || $crop_thumbnail == 4 || $crop_thumbnail == 5 || $crop_thumbnail == 7 ) {
         $crop = 1;
        }
       break;
       
       case 'large':
       Default:
        if ($crop_thumbnail == 1 || $crop_thumbnail == 4 || $crop_thumbnail == 6 || $crop_thumbnail == 7 ) {
         $crop = 1;
        }
       break;
    }

    Phocagallery module, Joomla!

    somebody, 20 Мая 2011

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

    +165

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    // создает массив с заданным кол-вом ячеек
    function array_from_int($count,$val=true,$start=0)
    {
    	$fcount = $count+$start;
    	for($i=$start;$i<$fcount;$i++)
    	{
    		$arr[$i] = $val;
    	}
    	return $arr;
    }

    _tL, 20 Мая 2011

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

    +159

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    7. 7
    if ($rightDisplayDelete == 1) {
        $images = $model->getData(1);
        $this->tmpl['pagination']	= &$model->getPagination(1);
    } else {
        $images = $model->getData(0);
        $this->tmpl['pagination']	= &$model->getPagination(0);
    }

    И снова модуль Phocagallery для Joomla!

    somebody, 20 Мая 2011

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

    +171

    1. 1
    2. 2
    3. 3
    4. 4
    function trim_and_screening(&$item, $key)
    {
    	$item = '`'.$item.'`';
    }

    _tL, 20 Мая 2011

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

    +147

    1. 1
    2. 2
    3. 3
    function index($name) {
    	return is_numeric($name)?'_'.$name:(int)substr($name,1);
    }

    универсальная функция для... угадайте, для чего?

    Lure Of Chaos, 20 Мая 2011

    Комментарии (13)
  8. Куча / Говнокод #6712

    +131

    1. 1
    http://molinos.ru/portfolio/a/1/1/

    Ждем загрузку, смотрим код. Офигеваем от 300К+ табуляций.

    ling, 20 Мая 2011

    Комментарии (13)
  9. bash / Говнокод #6711

    −134

    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
    # Fallback static file handler, now with XSendfile support.
        if not if(test -f $local_path) {
            if(! ~ $#xsendfile 0) {
                if(! ~ $#xsendfile_alternate 0)
                    XSendfileHeader='X-Accel-Redirect'
                if not
                    XSendfileHeader='X-Sendfile'
                echo $XSendfileHeader': '`{pwd}^'/'$local_path
            }
            if not
                static_file $local_path
        }
        if not if(~ $req_path /pub/* && test -f .$req_path) {
            if(! ~ $#xsendfile 0) {
                if(! ~ $#xsendfile_alternate 0)
                    XSendfileHeader='X-Accel-Redirect'
                if not
                    XSendfileHeader='X-Sendfile'
                echo $XSendfileHeader': '`{pwd}^'/'$req_path
            }
            if not
                static_file .$req_path
        }

    dukzcry, 19 Мая 2011

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

    +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
    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
    // There is an error while creating thumbnail in m or in s or in l
    						if ($creatingSError || $creatingMError || $creatingLError) {
    							// if all or two errors appear, we only display the last error message	
    							// because the errors in this case is the same
    							if ($errorMsgS != '') {
    								$creatingError = $errorMsgS;
    							}
    							if ($errorMsgM != '') {
    								$creatingError = $errorMsgM;
    							}
    							if ($errorMsgL != '') {
    								$creatingError = $errorMsgL;
    							}							// because the errors in this case is the same
    						
    							$returnFrontMessage = $creatingError;
    						} else if ($errorMsgS == '' && $errorMsgM == '' && $errorMsgL == '') {
    							$returnFrontMessage = 'Success';
    						} else if ($errorMsgS == '' && $errorMsgM == '' && $errorMsgL == 'ThumbnailExists') {
    							$returnFrontMessage = 'Success';
    						} else if ($errorMsgS == '' && $errorMsgM == 'ThumbnailExists' && $errorMsgL == 'ThumbnailExists') {
    							$returnFrontMessage = 'Success';
    						} else if ($errorMsgS == '' && $errorMsgM == 'ThumbnailExists' && $errorMsgL == '') {
    							$returnFrontMessage = 'Success';
    						} else if ($errorMsgS == 'ThumbnailExists' && $errorMsgM == 'ThumbnailExists' && $errorMsgL == '') {
    							$returnFrontMessage = 'Success';
    						} else if ($errorMsgS == 'ThumbnailExists' && $errorMsgM == '' && $errorMsgL == '') {
    							$returnFrontMessage = 'Success';
    						} else if ($errorMsgS == 'ThumbnailExists' && $errorMsgM == '' && $errorMsgL == 'ThumbnailExists') {
    							$returnFrontMessage = 'Success';
    						}

    Модуль phocagallery для joomla. Кусок кода в функции генереции превьюшек 3х разных размеров.

    somebody, 19 Мая 2011

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