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

    +151.5

    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
    70. 70
    71. 71
    72. 72
    73. 73
    74. 74
    function custom_print ($custom_category, $custom_template, $aviable, $custom_from, $custom_limit, $custom_cache, $do){
      global $db, $is_logged, $member_id, $xf_inited, $cat_info, $config, $user_group, $category_id, $_TIME, $lang;
    
    
      $do = $do ? $do : "main";
      $aviable = explode ('|', $aviable);
    
      if(!(in_array($do, $aviable)) AND ($aviable[0] != "global")) return "";
    
      $custom_category  = $db->safesql(str_replace(',', '|', $custom_category));
      $custom_from = intval($custom_from);
      $custom_limit = intval($custom_limit);
      $thisdate = date ("Y-m-d H:i:s", (time()+ $config['date_adjust']*60));
    
      if (intval($config['no_date'])) $where_date = " AND date < '".$thisdate."'"; else $where_date = "";
    
      $tpl = new dle_template;
      $tpl->dir = TEMPLATE_DIR;
    
      //if ($custom_cache == "yes") $config['allow_cache'] = "yes"; else $config['allow_cache'] = false;
      if ($is_logged AND ($user_group[$member_id['user_group']]['allow_edit'] AND !$user_group[$member_id['user_group']]['allow_all_edit'])) $config['allow_cache'] = false;
    
      $content = dle_cache("custom", "cat_".$custom_category."template_".$custom_template."from_".$custom_from."limit_".$custom_limit, true);
    
      if ($content) { return $content; }
      else {
    
      $allow_list = explode (',', $user_group[$member_id['user_group']]['allow_cats']);
    
      if ($allow_list[0] != "all") {
    
        if ($config['allow_multi_category']) {
    
          $stop_list = "category regexp '[[:<:]](".implode ('|', $allow_list).")[[:>:]]' AND ";
    
        } else {
    
          $stop_list = "category IN ('".implode ("','", $allow_list)."') AND ";
    
        }
    
      } else $stop_list = "";
    
      if ($user_group[$member_id['user_group']]['allow_short']) $stop_list = "";
    
      if ($cat_info[$custom_category]['news_sort'] != "") $config['news_sort'] = $cat_info[$custom_category]['news_sort'];
      if ($cat_info[$custom_category]['news_msort'] != "") $config['news_msort'] = $cat_info[$custom_category]['news_msort'];
    
        if ($config['allow_multi_category']) {
    
          $where_category = "category regexp '[[:<:]](".$custom_category.")[[:>:]]'";
    
        } else {
    
          $custom_category = str_replace ("|", "','", $custom_category);
          $where_category = "category IN ('".$custom_category."')";
    
        }
    
        $sql_select = "SELECT " . PREFIX . "_post.id, gallery, autor, date," . PREFIX . "_post.image," . PREFIX . "_post.imgtype, short_story, full_story, " . PREFIX . "_post.xfields, title, category, alt_name, " . PREFIX . "_post.comm_num, " . PREFIX . "_post.allow_comm, allow_rate, " . PREFIX . "_post.rating, " . PREFIX . "_post.vote_num, news_read, " . PREFIX . "_post.flag, " . PREFIX . "_users.fullname FROM " . PREFIX . "_post , " . PREFIX . "_users WHERE " . PREFIX . "_post.autor=" . PREFIX . "_users.name and ".$stop_list.$where_category." AND approve = '1'".$where_date." ORDER BY ".$config['news_sort']." ".$config['news_msort']." LIMIT ".$custom_from.",".$custom_limit;
    //echo $sql_select;
      include (ENGINE_DIR.'/modules/show.custom.php');
    
        if ($config['files_allow'] == "yes")
          if ( strpos( $tpl->result['content'], "[attachment=" ) !== false)
          {
            $tpl->result['content'] = show_attach($tpl->result['content'], $attachments);
          }
    
        create_cache("custom", $tpl->result['content'], "cat_".$custom_category."template_".$custom_template."from_".$custom_from."limit_".$custom_limit, true);
    
      }
      return $tpl->result['content'];
    }

    Не пишите так функции, пожалейте того, кто будет ее поддерживать после вас.

    guest, 26 Февраля 2009

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

    +158.5

    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
    switch($cms->type)
      {
          case 1:{
                 } break;
          case 2:{
                 } break;
          case 4:{
                     $cms->assign('content', array('title' => $cms->title, 'meta' => $cms->meta, 'mt' => $cms->mt));
                 } break;
          case 6:{
                     $cms->assign('content', array('title' => $cms->title, 'meta' => $cms->meta, 'mt' => $cms->mt));
                 } break;
      }

    Брутальное использование switch и дублирования кода :D

    guest, 26 Февраля 2009

    Комментарии (0)
  3. VisualBasic / Говнокод #616

    −435.7

    1. 1
    2. 2
    Function fixProblems()
    Exit Function

    Никаких проблем , чувак.

    guest, 26 Февраля 2009

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

    +146

    1. 1
    2. 2
    <table width="100%" cellspacing="0" cellpadding="0" border="0">
    <tr height="100" width="100%">

    Вот чтоб уже наверняка...

    guest, 26 Февраля 2009

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

    +147.9

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    typedef enSceneObjectsManager::tObjects::const_iterator It;
    if (objects.size() != 0)
        for (It it1(objects.begin()); it1 != objects.end() - 1; ++it1)
            if ((*it1)->GetObjectType() == enSceneObject3D::GetClassType())
                for (It it2(it1 + 1); it2 != objects.end(); ++it2)
                    if (((enSceneObject3D*)(enSceneObject*)(*it1))->GetResource().asInt() == 
                        ((enSceneObject3D*)(enSceneObject*)(*it2))->GetResource().asInt())
                        if ((*it1)->GetTransform() == (*it2)->GetTransform())
                            if (FindObject(theList, (*it2)) == -1)
                                InsertObject(theList, (*it2));

    Ответ на http://www.govnokod.ru/613
    Сурова Java, но C++ суровее.

    guest, 26 Февраля 2009

    Комментарии (1)
  6. Java / Говнокод #613

    +140.6

    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
    public String find(String request) {
        String result = "";
        status.setState(Status.STATUS_IN_PROGRESS);
        status.setMessage("search start");   
        buildTokens(request);
        if (buildWords()) {
            if (buildSynonyms()) {
                if (buildValues()) {
                    if (buildProperties()) {
                        if (buildParameters()) {
                            result = buildCondition();
                            status.setParameters(new ArrayList(parameters));
                            status.setState(Status.STATUS_SUCCESS);
                            status.setMessage("search done successfully");
                        } else {
                            status.setState(Status.STATUS_FAIL);
                            status.setMessage("can't build parameters");
                        }
                    } else {
                        status.setState(Status.STATUS_FAIL);
                        status.setMessage("can't build properties");
                    }
                } else {
                    status.setState(Status.STATUS_FAIL);
                    status.setMessage("can't build values");
                }
            } else {
                status.setState(Status.STATUS_FAIL);
                status.setMessage("can't build synonyms");
            }
        } else {
            status.setState(Status.STATUS_FAIL);
            status.setMessage("can't build words");
        }
        return result;
    }

    По мотивам http://www.govnokod.ru/593
    Ява суровей :)

    guest, 26 Февраля 2009

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

    +142.5

    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 ($search_keywords[$i]) {
          				case '(':
          				case ')':
          				case 'and':
          				case 'or':
          					
                    $Search->Where($search_keywords[$i]);
          					
          					break;
          				default:
          					$keyword = tep_db_prepare_input($search_keywords[$i]);
          					
                    $Search->Where("(pd.products_name LIKE '%" . tep_db_input($keyword) . "%' OR p.products_model LIKE '%" . tep_db_input($keyword) . "%' OR m.manufacturers_name LIKE '%" . tep_db_input($keyword) . "%'");               
                    if  ( isset($get->search_in_description) && ($get->search_in_description == 1) ) {
          					      $Search->Where("OR pd.products_description LIKE '%" . tep_db_input($keyword) . "%'");
          					}
          					
          					$Search->Where(")");					
          					break;
        			}

    Князь логики

    guest, 25 Февраля 2009

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

    +139.1

    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
    if (isset($_GET["ADD"]))                        {$ADD=$_GET["ADD"];}
    /* вырезано http://govnokod.ru/610 */
    
    if (!isset($ADD))   {$ADD=0;}
    
    if ($ADD=="1")                  {$hh='users';           echo "Add New User";}
    if ($ADD=="1A")                 {$hh='users';           echo "Copy User";}
    if ($ADD==11)                   {$hh='campaigns';       $sh='basic';    echo "Add New Campaign";}
    if ($ADD==12)                   {$hh='campaigns';       $sh='basic';    echo "Copy Campaign";}
    if ($ADD==111)                  {$hh='lists';           echo "Add New List";}
    if ($ADD==121)                  {$hh='lists';           echo "Add New DNC";}
    if ($ADD==1111)                 {$hh='ingroups';        echo "Add New In-Group";}
    if ($ADD==1211)                 {$hh='ingroups';        echo "Copy In-Group";}
    if ($ADD==11111)                {$hh='remoteagent';     echo "Add New Remote Agents";}
    if ($ADD==111111)               {$hh='usergroups';      echo "Add New Users Group";}
    if ($ADD==1111111)              {$hh='scripts';         echo "Add New Script";}
    /* вырезано 200 строк аналогичного содержания */
    
    /* теперь внимание */
    
    if ( ($ADD>9) && ($ADD < 99998) )
            {
            ##### get scripts listing for dynamic pulldown
            $stmt="SELECT script_id,script_name from vicidial_scripts order by script_id";
            $rslt=mysql_query($stmt, $link);
            /* censored ~ 400 lines  */
    }
    if ( ( (strlen($ADD)>4) && ($ADD < 99998) ) or ($ADD==3) or (($ADD>20) and ($ADD<70)) or ($ADD=="4A")  or ($ADD=="4B") or (strlen($ADD)==12) )
            {
            ##### get server listing for dynamic pulldown
            $stmt="SELECT server_ip,server_description from servers order by server_ip";
            /* censored  ~ 1000 lines */
    }
    ######################
    # ADD=99999 display the HELP SCREENS
    ######################
    
    if ($ADD==99999)
    {
    echo "</title>\n";
    echo "</head>\n";
    echo "<BODY BGCOLOR=white marginheight=0 marginwidth=0 leftmargin=0 topmargin=0>\n";
    echo "<CENTER>\n";
    echo "<TABLE WIDTH=98% BGCOLOR=#E6E6E6 cellpadding=2 cellspacing=0><TR><TD ALIGN=LEFT><FONT FACE=\"ARIAL,HELVETICA\" COLOR=BLACK SIZE=4><B>VICIDIAL ADMIN: HELP<BR></B></FONT><FONT FACE=\"ARIAL,HELVETICA\" COLOR=BLACK SIZE=2><BR><BR>\n";
    
    
    ?>
    <B><FONT SIZE=3>VICIDIAL_USERS TABLE</FONT></B><BR><BR>
     <!-- 22Kb help screen here -->

    vicidial. Новый революционный паттерн. МВЦ это прошлый век.
    Читаем каменты, принцип будет понятен.

    guest, 25 Февраля 2009

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

    +144.7

    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
    if (isset($_GET["DB"]))                         {$DB=$_GET["DB"];}
            elseif (isset($_POST["DB"]))    {$DB=$_POST["DB"];}
    if (isset($_GET["active"]))     {$active=$_GET["active"];}
            elseif (isset($_POST["active"]))        {$active=$_POST["active"];}
    if (isset($_GET["adaptive_dl_diff_target"]))    {$adaptive_dl_diff_target=$_GET["adaptive_dl_diff_target"];}
            elseif (isset($_POST["adaptive_dl_diff_target"]))       {$adaptive_dl_diff_target=$_POST["adaptive_dl_diff_target"];}
    if (isset($_GET["adaptive_dropped_percentage"]))        {$adaptive_dropped_percentage=$_GET["adaptive_dropped_percentage"];}
            elseif (isset($_POST["adaptive_dropped_percentage"])){$adaptive_dropped_percentage=$_POST["adaptive_dropped_percentage"];}
    if (isset($_GET["adaptive_intensity"])) {$adaptive_intensity=$_GET["adaptive_intensity"];}
            elseif (isset($_POST["adaptive_intensity"]))    {$adaptive_intensity=$_POST["adaptive_intensity"];}
    if (isset($_GET["adaptive_latest_server_time"]))        {$adaptive_latest_server_time=$_GET["adaptive_latest_server_time"];}
            elseif (isset($_POST["adaptive_latest_server_time"])){$adaptive_latest_server_time=$_POST["adaptive_latest_server_time"];}
    if (isset($_GET["adaptive_maximum_level"]))     {$adaptive_maximum_level=$_GET["adaptive_maximum_level"];}
            elseif (isset($_POST["adaptive_maximum_level"]))        {$adaptive_maximum_level=$_POST["adaptive_maximum_level"];}
    if (isset($_GET["SUB"]))                        {$SUB=$_GET["SUB"];}
            elseif (isset($_POST["SUB"]))   {$SUB=$_POST["SUB"];}
    if (isset($_GET["ADD"]))                        {$ADD=$_GET["ADD"];}
            elseif (isset($_POST["ADD"]))   {$ADD=$_POST["ADD"];}
    if (isset($_GET["admin_hangup_enabled"]))       {$admin_hangup_enabled=$_GET["admin_hangup_enabled"];}
            elseif (isset($_POST["admin_hangup_enabled"]))  {$admin_hangup_enabled=$_POST["admin_hangup_enabled"];}  
    /* и дальше еще 560  строк аналогичного содержания :) */

    vicidial. admin.php. небольшой кусочек... Общая длина вот таких вот ифов - 581 строка.

    guest, 25 Февраля 2009

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

    +140

    1. 1
    2. 2
    3. 3
    function CheckProgramInfoForm($info){
            return 1;
        }

    guest, 25 Февраля 2009

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