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

    +166

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    // сколько сегодня зарегестрировалось по приглашению
        public function getTodayCount() {
    	$query = self::select("select * from invites where date='" . date("Y.m.d") . "'");
    	return count($query);
        }

    просто нет слов, одни эмоции :)

    CRRaD, 20 Февраля 2012

    Комментарии (13)
  2. Java / Говнокод #9489

    +86

    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
    @Override
        public boolean equals(Object o) {
            if (this == o) return true;
            if (o == null || getClass() != o.getClass()) return false;
    
            Sdbankpd sdbankpd = (Sdbankpd) o;
    
            if (bjbank != null ? !bjbank.equals(sdbankpd.bjbank) : sdbankpd.bjbank != null) return false;
            if (bjbvpd != null ? !bjbvpd.equals(sdbankpd.bjbvpd) : sdbankpd.bjbvpd != null) return false;
            if (bjcncd != null ? !bjcncd.equals(sdbankpd.bjcncd) : sdbankpd.bjcncd != null) return false;
            if (bjcust != null ? !bjcust.equals(sdbankpd.bjcust) : sdbankpd.bjcust != null) return false;
            if (bjcycd != null ? !bjcycd.equals(sdbankpd.bjcycd) : sdbankpd.bjcycd != null) return false;
            if (bjdfin != null ? !bjdfin.equals(sdbankpd.bjdfin) : sdbankpd.bjdfin != null) return false;
            if (bjdnwd != null ? !bjdnwd.equals(sdbankpd.bjdnwd) : sdbankpd.bjdnwd != null) return false;
            if (bjefmt != null ? !bjefmt.equals(sdbankpd.bjefmt) : sdbankpd.bjefmt != null) return false;
            if (bjeyd != null ? !bjeyd.equals(sdbankpd.bjeyd) : sdbankpd.bjeyd != null) return false;
            if (bjhocy != null ? !bjhocy.equals(sdbankpd.bjhocy) : sdbankpd.bjhocy != null) return false;
            if (bjlccy != null ? !bjlccy.equals(sdbankpd.bjlccy) : sdbankpd.bjlccy != null) return false;
            if (bjlcd != null ? !bjlcd.equals(sdbankpd.bjlcd) : sdbankpd.bjlcd != null) return false;
            if (bjmdel != null ? !bjmdel.equals(sdbankpd.bjmdel) : sdbankpd.bjmdel != null) return false;
            if (bjmodt != null ? !bjmodt.equals(sdbankpd.bjmodt) : sdbankpd.bjmodt != null) return false;
            if (bjmrdt != null ? !bjmrdt.equals(sdbankpd.bjmrdt) : sdbankpd.bjmrdt != null) return false;
            if (bjpcfq != null ? !bjpcfq.equals(sdbankpd.bjpcfq) : sdbankpd.bjpcfq != null) return false;
            if (bjpcfu != null ? !bjpcfu.equals(sdbankpd.bjpcfu) : sdbankpd.bjpcfu != null) return false;
            if (bjpeyd != null ? !bjpeyd.equals(sdbankpd.bjpeyd) : sdbankpd.bjpeyd != null) return false;
            if (bjrdnb != null ? !bjrdnb.equals(sdbankpd.bjrdnb) : sdbankpd.bjrdnb != null) return false;
            if (bjsbrc != null ? !bjsbrc.equals(sdbankpd.bjsbrc) : sdbankpd.bjsbrc != null) return false;
            if (bjslcd != null ? !bjslcd.equals(sdbankpd.bjslcd) : sdbankpd.bjslcd != null) return false;
            if (bjsuc != null ? !bjsuc.equals(sdbankpd.bjsuc) : sdbankpd.bjsuc != null) return false;
            if (bjtylc != null ? !bjtylc.equals(sdbankpd.bjtylc) : sdbankpd.bjtylc != null) return false;
            if (bjurpt != null ? !bjurpt.equals(sdbankpd.bjurpt) : sdbankpd.bjurpt != null) return false;
            if (bjzone != null ? !bjzone.equals(sdbankpd.bjzone) : sdbankpd.bjzone != null) return false;
    
            return true;
        }

    Обработка резальтов селекта

    timmson666, 20 Февраля 2012

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

    +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
    $textb = Db::getInstance()->ExecuteS("SELECT * FROM "._DB_PREFIX_."productotzyv WHERE `id_product` = ".$idProduct);
    		$count_otz = count($textb);
    		if ($p==0) $p = 1;
    		$limit = 99;
    		$texta = get("SELECT *, date_format(data, '%d.%m.%Y') as data_ FROM "._DB_PREFIX_."productotzyv WHERE `id_product` = ".$idProduct." LIMIT ".$limit);
    		$ed = count(Db::getInstance()->ExecuteS("SELECT * FROM "._DB_PREFIX_."productotzyv WHERE `id_product`=".intval($_GET['id_product'])." and `rating`=1"));
    		$dva = count(Db::getInstance()->ExecuteS("SELECT * FROM "._DB_PREFIX_."productotzyv WHERE `id_product`=".intval($_GET['id_product'])." and `rating`=2"));
    		$tri = count(Db::getInstance()->ExecuteS("SELECT * FROM "._DB_PREFIX_."productotzyv WHERE `id_product`=".intval($_GET['id_product'])." and `rating`=3"));
    		$four = count(Db::getInstance()->ExecuteS("SELECT * FROM "._DB_PREFIX_."productotzyv WHERE `id_product`=".intval($_GET['id_product'])." and `rating`=4"));
    		$five = count(Db::getInstance()->ExecuteS("SELECT * FROM "._DB_PREFIX_."productotzyv WHERE `id_product`=".intval($_GET['id_product'])." and `rating`=5"));
            $uri = $_SERVER['REQUEST_URI'];
            $i = strrpos($uri, "/");
            $uri1 = substr($uri, 0, $i);
            $i = strrpos($uri1, "/");
            $uri = substr($uri1, 0, $i);
            $uri = $uri."/";
            $monUrl = "http://".$_SERVER['HTTP_HOST'].$uri;
    		foreach ($textb as $s => $a){
    			$text += $a['rating'];
    		}
    
    		$smarty->assign('ed', $ed);
    		$smarty->assign('dva', $dva);
    		$smarty->assign('tri', $tri);
    		$smarty->assign('four', $four);
    		$smarty->assign('five', $five);
    		$smarty->assign('ed_proc', $ed/$count_otz*100);
    		$smarty->assign('dva_proc', $dva/$count_otz*100);
    		$smarty->assign('tri_proc', $tri/$count_otz*100);
    		$smarty->assign('four_proc', $four/$count_otz*100);
    		$smarty->assign('five_proc', $five/$count_otz*100);
    		$smarty->assign('rating2', round($text/$count_otz, 0));
    		$smarty->assign('countotz', $count_otz.' '.endingsForm($count_otz,"отзыв","отзыва","отзывов"));
    		$smarty->assign('monUrl',$monUrl);
    		$smarty->assign('text',$texta);

    Prestashop, реализация отображения отзывов и рейтига товара

    uint, 19 Февраля 2012

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

    +158

    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
    function get($sel, $od='', $show_error=1)
    {
      global $__DB_CONN;
      $select=$sel;
      //echo $select.'<br>';
      if($od=="")
      {
        $res=sql_execute($select, $show_error);
        if(!$res)
          return array();
        $mc_runtime=get_magic_quotes_runtime();
        set_magic_quotes_runtime(0);
        $mas=array();
        while($v=@mysql_fetch_assoc($res))
          array_push($mas, $v);
        set_magic_quotes_runtime($mc_runtime);
        return $mas;
      }
    ... //тоже самое еще пару раз
      if($od=="by id")
      {
        $res=sql_execute($select, $show_error);
        if(!$res)
          return array();
        $mc_runtime=get_magic_quotes_runtime();
        set_magic_quotes_runtime(0);
        $mas=array();
        while($v=mysql_fetch_assoc($res))
          $mas[$v["id"]]=$v;
        set_magic_quotes_runtime($mc_runtime);
        return $mas;
      }
      if($od=="ins")
      {
        $res=sql_execute($select, $show_error);
        return mysql_insert_id($__DB_CONN);
      }
      return;
    }
    
    function get2($sel, $od='', $show_error=1)
    {
      global $__DB_CONN2;
      $select=$sel;
      //echo $select.'<br>';
      if($od=="")
      {
        $res=sql_execute2($select, $show_error);
        if(!$res)
          return array();
        $mc_runtime=get_magic_quotes_runtime();
        set_magic_quotes_runtime(0);
        $mas=array();
        while($v=@mysql_fetch_assoc($res)) {
    	foreach($v as $ii=>$vv)
            $v[$ii] = iconv('windows-1251','utf-8' ,$vv);
       array_push($mas,$v);
      }
        set_magic_quotes_runtime($mc_runtime);
        return $mas;
      }
    ... //тоже самое еще пару раз
      if($od=="ins")
      {
        $res=sql_execute2($select, $show_error);
        return mysql_insert_id($__DB_CONN2);
      }
      return;
    }

    Функции для работы с бд!

    uint, 19 Февраля 2012

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

    +1000

    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
    void drawFigure()
    {
    	for(int i=0;i<figMaxI;i++)
    		for(int j=0;j<figMaxY;j++)
    			if(figure.space[i][j].wut==1)
    			{
    				if(figure.y+i>=2)
    					if(figureEffekt == 1)
    					{
    						engine->drawTexture2D(figure.picture.texID, gameSpace.x+((figure.x+j)*34)-effekt[0].x, gameSpace.y+((figure.y+i)*34)-effekt[0].y, 34, 34, 0.4, 0, 0);
    						engine->drawTexture2D(figure.picture.texID, gameSpace.x+((figure.x+j)*34)+effekt[0].y, gameSpace.y+((figure.y+i)*34)+effekt[0].x, 34, 34, 0.8, 0, 0);
    						engine->print(fontAlphabet,0, figure.space[i][j].letter , gameSpace.x+((figure.x+j)*34)+6+effekt[0].y,gameSpace.y+((figure.y+i)*34)+4+effekt[0].x,1,0,2);
    					}
    					else
    					{
    						engine->drawTexture2D(figure.picture.texID, gameSpace.x+((figure.x+j)*34), gameSpace.y+((figure.y+i)*34), 34, 34, 1, 0, 0);
    						engine->print(fontAlphabet,0, figure.space[i][j].letter , gameSpace.x+((figure.x+j)*34)+6,gameSpace.y+((figure.y+i)*34)+4,1,0,2);
    					}
    			}
    }

    великое и могучее ООП в действии

    -ggorky, 19 Февраля 2012

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

    +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
    <?php
    iconv_set_encoding("input_encoding", "UTF-8");
    iconv_set_encoding("internal_encoding", "UTF-8");
    iconv_set_encoding("output_encoding", "UTF-8");
    
    $curl = curl_init();
    $curl_set = array(
            CURLOPT_COOKIESESSION => 0,
            CURLOPT_VERBOSE => 1,
            CURLOPT_USERAGENT => 'Opera/9.60 (J2ME/MIDP; Opera Mini/4.2.14912/812; U; ru) Presto/2.4.15',
            CURLOPT_RETURNTRANSFER => 1
        );
    
    curl_setopt_array($curl, $curl_set);
    
    for($i=1;$i<50;$i++){
        $url = 'http://utemplate.ru/load/19-1-0-'.$i;
        curl_setopt($curl, CURLOPT_URL ,$url);
        $data = curl_exec($curl);
        preg_match_all('#<div class="entrytitle">(.*)</div>(.*)<hr>#isU', $data, $matches);
        $content[title] = $matches[1][0];
        $content[desc] = $matches[2][0];
        unset($matches);
        preg_match_all('#<img src\="http://utemplate.ru/_ld/0/(.*)"/>#isU', $data, $matches);
        $content[img] = $matches[1][0];
        if($content[title] AND $content[desc] AND $content[img]){
            unset($matches);
            mkdir($content[title], 0777);
            curl_setopt($curl, CURLOPT_URL ,'http://utemplate.ru/_ld/0/'.$content[img]);
            $image = curl_exec($curl);
            curl_setopt($curl, CURLOPT_URL ,'http://utemplate.ru/load/0-0-0-'.$i.'-20');
            $file_inf = curl_exec($curl);
            preg_match_all('#<A HREF="(.*)"#isU', $file_inf, $matches);
            $ext_file = substr($matches[1][0], -4);
            $ext_img = substr($content[img], -4);
            curl_setopt($curl, CURLOPT_URL , $matches[1][0]);
            $file = curl_exec($curl);
            file_put_contents($content[title].'/'.$content[title].$ext_file, $file);
            file_put_contents($content[title].'/'.$content[title].$ext_img, $image);
            file_put_contents($content[title].'/'.$content[title].'.txt', $content[title]."\n".$content[desc]);
        }
    
    };

    Злобный самописный, рабочий граббер uCoz сайта

    __construct, 19 Февраля 2012

    Комментарии (12)
  7. C# / Говнокод #9484

    +964

    1. 1
    2. 2
    3. 3
    4. 4
    private static int CompareWidgetsByOrder(Widget x, Widget y)
    {
          return x == null ? y == null ? 0 : 1 : y == null ? 0 : x.order > y.order ? -1 : x.order < y.order ? 1 : 0;
    }

    Вот до чего доводит стремление к компактности кода.

    nomad99111, 19 Февраля 2012

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

    +158

    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 page($page,$total,$link) {
    			$content='';
    			if ($total > 1)	{					
    				$s=($total-$page<6)?(5-$total+$page):0; 
    				for ($i=1;$i<5+$s;$i++) if($page-$i>0) $al[$i]='<a href="'.$link.'page='.($page-$i).'" class="pag_a">'.($page-$i).'</a>';
    				$s=($page<6)?(6-$page):0; 
    				for ($i=1;$i<5+$s;$i++) if($page+$i<=$total) $ar[$i]='<a href="'.$link.'page='.($page+$i).'" class="pag_a">'.($page+$i).'</a>';
    				unset($s);
    				
    				if ($page==1) $cl='pag_an'; else $cl='pag_a';
    				$pervpage='<a href="'.$link.'page='.($page-1).'" class="'.$cl.'"> &#8592; </a>';
    				if ($page>5 && $total>10) $pervpage.='<a href="'.$link.'page=1" class="pag_a">1</a>';
    				if ($page>6 && $total>10) $pervpage.='<a class="pag_an">...</a>';
    				if ($page<$total-5 && $total>10) $nextpage='<a class="pag_an">...</a>';
    				if ($page<$total-4 && $total>10) $nextpage.='<a href="'.$link.'page='.$total.'" class="pag_a">'.$total.'</a>';
    				
    				if ($page==$total) $cl='pag_an'; else $cl='pag_a';
    				$nextpage.='<a href="'.$link.'page='.($page+1).'" class="'.$cl.'" > &#8594; </a>';
    				
    				$content='<div class="page">';
    				$content.=$pervpage.$al[9].$al[8].$al[7].$al[6].$al[5].$al[4].$al[3].$al[2].$al[1].'<a class="pag_an">'.$page.'</a>'.$ar[1].$ar[2].$ar[3].$ar[4].$ar[5].$ar[6].$ar[7].$ar[8].$ar[9].$nextpage;
    				$content.='</div>';
    			}
    			return $content;
    		}

    good_web_master, 19 Февраля 2012

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

    +160

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    public function getInfo() {
            if(!$this->id) return false;
            
            if(!isset($this->info->info_info)) $this->fetchInfoFields(array('info_info'));
            return $this->info->info_info;
        }

    Мне стыдно :(

    luethus, 18 Февраля 2012

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

    +153

    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
    do {
    			size = ($("#textHeight").val()) + "px";
    			$("#textView")
    				.text($("#textInput").val())
    				.css({
    					"color":rs.textColor,
    					"font-color":"#" + rs.textColor,
    					"font-size":size
    				});
    			Cufon.set("fontSize", size).replace("#textView", {
    				"color":"#" + rs.textColor,
    				"fontSize":size
    			});
    			$("#textView").center("#canvasBg");
    			($("#textView canvas").length ? $("#textView canvas") : $("#textView")).center("#canvasBg");
    			if ($("#textView canvas").length && ($("#textView canvas").width() <= $("#canvasBg").width()) && ($("#textView canvas").height() <= $("#canvasBg").height())) break;
    			if (($("#textView").width() <= $("#canvasBg").width()) && ($("#textView").height() <= $("#canvasBg").height())) break;
    			$("#textHeight").val($("#textHeight").val() - 1);
    
    		} while ($("#textHeight").val() > 9);

    Было сжатие картинки в цикле, а вот вам подгонка текста в канвасе.

    kyzi007, 18 Февраля 2012

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