1. 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)
  2. 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)
  3. 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)
  4. 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)
  5. 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)
  6. PHP / Говнокод #9479

    +141

    1. 1
    echo wp_count_comments($post->ID)->approved;

    Не знал, что так можно. Сработало, хыхы.

    varg242, 18 Февраля 2012

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

    +151

    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
    <?/*                                         
    +-------------------------------------------------------+
    |  PHPShop Enterprise 3.6                               |
    |  Все права защищены                                   |
    |  www.phpshop.ru                                       |
    +-------------------------------------------------------+
                                                             
     Внимание!                                               
     ГовноКод файлов не поддается редактированию,          
     для сохранения глюкабельности сайта, пожалуйста, не изменяйте его.      
    ---------------------------------------------------------
     Attention!                                              
     The turd-codes of the site does not give in to editing, 
     For preservation of being able to fail please do not change it!

    Хуета их скрипт.

    shithead, 18 Февраля 2012

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

    +156

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    7. 7
    8. 8
    if (strlen($arResult["AUTH"]["NEW_LOGIN"]) > 47)
    	$_POST["NEW_LOGIN"] = substr($arResult["AUTH"]["NEW_LOGIN"], 0, 47);
    
    if (strlen($arResult["AUTH"]["NEW_LOGIN"]) < 3)
    	$arResult["AUTH"]["NEW_LOGIN"] .= "_";
    
    if (strlen($arResult["AUTH"]["NEW_LOGIN"]) < 3)
    	$arResult["AUTH"]["NEW_LOGIN"] .= "_";

    битрикс, компонент sale.order.ajax

    ast, 17 Февраля 2012

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

    +176

    1. 1
    2. 2
    3. 3
    public function setPIDorSEORedirect($id, $disableVarName = '') {
            ........
    }

    отличное название метода)))

    aleksssmix, 17 Февраля 2012

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

    +145

    1. 1
    а у самих на сайте (http://govnokod.ru/) при входе если после OpenID поставить пробел, то войти нельзя!

    Nataly, 17 Февраля 2012

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