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

    +134

    1. 1
    2. 2
    3. 3
    4. 4
    list($long_startIp, $long_endIp) = ip_range($value);
    $strange = long2ip($long_startIp);
    $endrange = long2ip($long_endIp);
    $addit[] = ('a.dst_ip BETWEEN ' . ip2long($strange) . ' AND ' . ip2long($endrange));

    Студенты нынче совсем тупые пошли.

    DrFreez, 15 Августа 2013

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

    +135

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    7. 7
    ....
    elseif(!strcasecmp(substr($value['type'],-4),'form'))
    {
          $class=$value['type']==='form' ? get_class($this->_form) : Yii::import($value['type']);
          $element=new $class($value,null,$this->_form);
    }
    ......

    В недрах Yii.
    Условие довольно странное ,этож надо было до этого додуматься

    xakki, 14 Августа 2013

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

    +138

    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
    <?php
    header("Content-Type: text/javascript;charset=utf-8");
     
    $html='';
    #$fp = fopen('counter.txt', 'w+');
     
    if (isset($_GET)) {
        $type=$_REQUEST['type'];
     
     
        if (isset ($_REQUEST['callback'])){
            $html.=$_REQUEST['callback']."(";
        }
     
        $fils=array('ukqs','uk','regions', 'org', 'citiesarhobl', 'cities', 'omsu', 'iogv','fund_uk','standart');
     
        if (isset($_GET['cfund_uk'])) {
            $fund_file='jbase/cities_'.$_GET['cfund_uk'].'.js';
            if (file_exists($fund_file))
                $html.=file_get_contents($fund_file);
            else
                $html.='error:'.$fund_file;
        }
        else
            if (isset($_GET['rfund_uk'])) {
                $fund_file='jbase/'.$_GET['rfund_uk'].'_regions.js';
                if (file_exists($fund_file))
                    $html.=file_get_contents($fund_file);
                else
                    $html.='error';
            }
        if (isset($_REQUEST['uks'])&&($type=='cities')) {
            $fund_file='jbase2/'.$_GET['uks'].'_cities.js';
            if (file_exists($fund_file))
                $html.=file_get_contents($fund_file);
            else
                $html.='error:'.$fund_file;
        }
        else
            if (isset($_REQUEST['uks'])&&($type=='regions')) {
                $fund_file='jbase2/'.$_GET['uks'].'_regions.js';
                if (file_exists($fund_file))
                    $html.=file_get_contents($fund_file);
                else
                    $html.='error';
            }
        else
            if ($type=='standart') {
                $fund_file='standart.js';
                if (file_exists($fund_file))
                    $html.=file_get_contents($fund_file);
                else
                    $html.='error';
            }
        else
        foreach ($fils as $ty)
            if ($ty==$type)
                $html.=file_get_contents($type.".js");    
        if (isset ($_REQUEST['callback']))
        {
            $html.=")";
        }
        #$date=date("F j, Y, g:i a");
       #$test = fwrite($fp, $date."#####\n\r ".$html);
     
        print $html;
        #fclose($fp);
    }
    ?>

    этот файл отдаёт json ajax ответ, подгружая его из *.js файла

    tariel, 14 Августа 2013

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

    +162

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    if (!isset($_SESSION['user']))
    {
    	$_SESSION['user'] = "guest";
    	$_SESSION['user_id'] = mt_rand(1000000, 99999999);
    }

    Так и представляю двух очень везучих юзеров, у которых в корзине сами собой будут появляться товары.

    Tairesh, 14 Августа 2013

    Комментарии (9)
  5. Perl / Говнокод #13605

    −139

    1. 1
    2. 2
    >> # HTML/4.01 says that line breaks are represented as "CR LF" pairs (i.e., `%0D%0A')
    >> $content =~ s/(?<!%0D)%0A/%0D%0A/g if defined($content);

    HTTP::Request::Common 6.04, строка 86
    http://cpansearch.perl.org/src/GAAS/HTTP-Message-6.04/lib/HTTP/Request/Common.pm

    Оно просто берёт и изменяет передаваемый контент. Любой. В том числе просто бинарные данные.

    kainwinterheart, 13 Августа 2013

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

    +151

    1. 1
    $idmenu = intval(strip_tags(trim($_REQUEST[idmenu])));

    UnnamedUser, 13 Августа 2013

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

    +116

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    7. 7
    8. 8
    /**
     * just to see logs...
     * @param context
     */
    public void drawPalletes(PYGraphics context){
        //log.info(elevatorSimelement.getName()+" -draw Palettes, palettes number is: "+elevatorSimelement.getPalletes().size());
        super.drawPalletes(context);
    }

    someone, 13 Августа 2013

    Комментарии (44)
  8. JavaScript / Говнокод #13602

    +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
    if (!jQuery('#email').attr('value')){
                jQuery('#email').css('border', '1px solid red');
                jQuery('div.errors').append('<p>Не указан "E-Mail"</p>');
                error=true;
            }
            else{
                email=jQuery('#email').attr('value');
                if ((email.length<8) || (email.search(/[а-яёЁ,~><|\/*#№`!"'$:;%^&?)(_=+]/i)+1) || (email.indexOf(' ')+1) || (email.indexOf('--')+1) || (email.indexOf('-.')+1) || (email.indexOf('.-')+1) || (email.indexOf('\\')+1) || (email.indexOf('..')+1) || (email.indexOf('.')==0) || (email.indexOf('-')==0) || (email.indexOf('@')==0) || (!(email.indexOf('@')+1)) || ((email.indexOf('@')!=email.lastIndexOf('@')) && (email.lastIndexOf('@')+1)) || (email.indexOf('@')>email.lastIndexOf('.')) || (!(email.lastIndexOf('.')<(email.length-2)))){
                    jQuery('#email').css('border', '1px solid red');
                    jQuery('div.errors').append('<p>E-mail указан некорректно</p>');
                    error=true;
                }
                else jQuery('#email').attr('style', null);
            }

    Функция проверки Email на валидность.

    Regexp для слабых.

    Cherrionella, 13 Августа 2013

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

    +154

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    7. 7
    8. 8
    function isError() {
            if($this->error!="") return true;
            else return false;
        }
     function isOk() {
            if($this->error=="") return true;
            else return false;
        }

    Зато мы используем ООП

    Tairesh, 13 Августа 2013

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

    +135

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    private readonly bool[] showDetails = new bool[20]
                                                      {
                                                          false, false, false, false, false, false, false, false, false, false,
                                                          false, false, false, false, false, false, false, false, false, false
                                                      };

    taburetka, 12 Августа 2013

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