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

    +164

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    7. 7
    function m($s, $re)
        {
            return preg_match($re, $s);
        }
    // ... чуть пониже ...
                if (!$this->m($caching_level, '/^[012]$/')) {
                    die(__CLASS__ . "::stem_caching() - Legal values are '0','1' or '2'. '$caching_level' is not a legal value");

    telnet, 25 Апреля 2011

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

    +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
    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
    $_i=1;
      $_stb = mysql_query("SELECT * FROM ".$admin_prefix."_catalog_title WHERE pub=1 ORDER BY sort, BINARY name");
      while($_rtb=mysql_fetch_assoc($_stb)){
        echo print_r($_rtb,2);
        $sql="SELECT * FROM ".$admin_prefix."_catalog_regions WHERE pub=1 AND region_id=0 AND (id IN (".implode(",",$_SESSION['terms']['toureastgroup_catalog_regions'])."))";
        $_s_reg=mysql_query($sql);
        while($_r_reg=mysql_fetch_assoc($_s_reg)){
            // определяем подрегионы региона
            $result_array=array();$all_current_regions_array=array();$all_current_regions_array_where=array();
            GetChildElements("region_id",$_r_reg['id'],$admin_prefix."_catalog_regions",$_SESSION['terms']['toureastgroup_catalog_regions']);
            $all_current_regions_array=$result_array;
            // добавляем сам регион
            
            $all_current_regions_array[]=$_r_reg['id'];
            // составляем условие региона
            foreach($all_current_regions_array as $v){									
              $all_current_regions_array_where[]="(region_id LIKE '%##".$v."##%')";									
            }
            $sql="SELECT * FROM ".$admin_prefix."_catalog_programms WHERE pub=1 AND title_id=$_rtb[id] AND (id IN (".$_SESSION['string_where_programms'].")) AND (".implode(" OR ",$all_current_regions_array_where).")";
            $_s_pr=mysql_query($sql);
            $_title_progs_id=array();
            while($_r_pr=mysql_fetch_assoc($_s_pr)){
              $_title_progs_id[]=$_r_pr['id'];
            }
            $_title_progs_where="(".implode(",",$_title_progs_id).")";
            
            $sql="SELECT * FROM ".$admin_prefix."_catalog_programs_tours WHERE price>0 AND start>=".(time()-36000)." AND pub=1 AND (programm_id IN ".$_title_progs_where.") ORDER BY start LIMIT 5";
            $_stours=mysql_query($sql);
            if(mysql_num_rows($_stours)>0){
                while($_rtours=mysql_fetch_assoc($_stours)){
                  echo '<pre>'.print_r($_rtours,2).'</pre>';
                  $_array_r=array();
                }
            }
       }
       $_i++;

    Простите не удержался, больше не могу раскапывать это...
    сайт ввв.toureastgroup.ру автор откликнись - плюну в лицо

    Sum, 25 Апреля 2011

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

    +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
    15. 15
    (function ($) {
        $.fn.tabTmpl = function (jsonArr) {
            if (jsonArr) {
                var ths = this.find('thead th').clone(); // var tds = this.find('thead td').clone();
    >          var tds = $('td');
    >          ths.each(function(){ tds.append($('td').attr('id', this.id)); alert(tds.html());});
                var bd = this.find('tbody');
                $.each(jsonArr, function (i, v) {
                    tds.each(function () { this.innerHTML = v[this.id]; alert(this.id);});
                    $('<tr>').append(tds.clone().removeAttr('id')).appendTo(bd);
                });
            }
            return this;
        };
    })(jQuery);

    Спал за ночь 2 часа, решил к вечеру поправить плагин jQuery, чтобы работал как мне надо (по стилям чтобы все срасталось).
    Как вывод: зависание Chromium и неплохая нагрузка на систему. ... Так и не понял почему )

    bit0rez, 25 Апреля 2011

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

    +156

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    function check() {
    
    if (document.login.user.value == "user" &&
    document.login.password.value == "correct_password")
        window.location.href = 'http://this.site/login.html';
    else
        window.location.href = 'http://this.site/loginfehler.html';
    
    return false;
    }

    Функция входа, хуле

    jQuery, 24 Апреля 2011

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

    +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
    15. 15
    16. 16
    17. 17
    18. 18
    19. 19
    20. 20
    21. 21
    22. 22
    23. 23
    24. 24
    25. 25
    26. 26
    $posts = $db->execAndReturnAll('select `id`, `user_id`, `theme_id`, `text` from `posts` order by `id` desc limit 5');
    
    $users = array();
    $themes = array();
    $groups = array();
    
    $l = sizeof($posts);
    for($i = 0; $i < $l; ++$i)
    {
    if(!in_array($posts[$i]['user_id']), $users)
        $users[] = $posts[$i]['user_id'];
    if(!in_array($posts[$i]['theme_id']), $themes)
        $themes[] = $posts[$i]['theme_id'];
    }
    
    $users = $db->execAndReturnAll('select `id`, `nick`, `group_id` from `users` where `id` in (0,'.implode(',', $users).')');
    $themes = $db->execAndReturnAll('select `id`, `name` from `themes` where `id` in (0,'.implode(',', $themes).')');
    
    $l = sizeof($users);
    for($i = 0; $i < $l; ++$i)
    {
    if(!in_array($users[$i]['group_id']), $groups)
        $groups[] = $users[$i]['group_id'];
    }
    
    $groups = $db->execAndReturnAll('select `id`, `name` from `groups` where `id` in (0,'.implode(',', $groups).')');

    qbasic, 24 Апреля 2011

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

    +164

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    if (is_array($custom_data)) {
    	foreach ($custom_data as $key => $val) {
    		$session[$key] = $val;
    	}
    }

    хитрый план

    DrFreez, 23 Апреля 2011

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

    +247

    1. 1
    2. 2
    mov eax, eax			;without this crap, it fucks up
      mov ecx, ecx			;don't ask me why...

    нашел в инклудах к opengl

    ragim, 23 Апреля 2011

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

    +142

    1. 1
    2. 2
    3. 3
    4. 4
    if(n==0) m[n][i][j][k+1]=1.5;
    if(n==1) m[n][i][j][k+1]=1.0;
    if(n==2) m[n][i][j][k+1]=0.0;
    if(n==3) m[n][i][j][k+1]=0.4;

    долго не мог заметить

    ragim, 23 Апреля 2011

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

    +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
    //было:
    	function query($sque){
    		$sque = mysql_real_escape_string($sque,$this->hdb);
    		$res = mysql_query($sque,$this->hdb);
    		if(!$res){
    			echo 'Invalid query: '.mysql_error().'; ';
    			return 0;
    		}
    		return $res;
    	}
    //добавил:
    //так как предыдущая функция иногда косячила запрос
    	function sensiblequery($sque,$arr){
    		for($i = 0; $i<count($arr); ++$i){
    			$arr[$i] = mysql_real_escape_string($arr[$i],$this->hdb);
    			$pattern = "/{var$i}/";
    			$sque = preg_replace($pattern, $arr[$i], $sque);	
    		}
    		$res = mysql_query($sque,$this->hdb);
    		if(!$res){
    			echo 'Invalid query: '.mysql_error().'; ';
    			return 0;
    		}
    		return $res;
    	}

    Такое ощущение что написал говно. Если это так подскажите как адекватней сделать...

    greshnik, 23 Апреля 2011

    Комментарии (24)
  10. JavaScript / Говнокод #6460

    +206

    1. 1
    ... else document.write("Ваш браузер не поддерживает JavaScript<br>");

    просто нет слов :)

    jQuery, 23 Апреля 2011

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