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

    +163

    1. 1
    2. 2
    3. 3
    //fucking designers
    	if ( $page->importantshort ) $page->short = true;
    	if ( $page->importantNOTshort ) $page->short = false;	// так то!

    bot, 29 Марта 2012

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

    +157

    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
    while(true)
    {
    	if ($i==0)
    	{
    		$new_form_name = $form_res[0]['frm_name'] . ' ( Copy )';
    	} else
    	{
    		$new_form_name = $form_res[0]['frm_name'] . ' ( Copy '.$i.' )';
    	}
    	if(!in_array($new_form_name, $formaNames))
    	{
    		break;
    	}
    	$i++;
    }

    Есть имя формы $form_res[0]['frm_name'] , напр "FORMNAME".
    нужно получить новое имя вида "FORMNAME ( Copy 1)"

    iersir, 29 Марта 2012

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

    +999

    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
    template<class TVisitedComponentList>
    	TUniqueIDOfVisitedComponentList getUniqueIDOfVisitedComponentTypeList(void)
    	{
    		static Type2Type<TVisitedComponentList> UniqueObjectForVisitedComponentTypeList;
    		return (size_t)(&UniqueObjectForVisitedComponentTypeList);
    	}
    
    	template<class TVisitedComponentList>
    	TCastWindowComponentTo* const castWindowComponentInternal(PegThing* const Window)
    	{
    		ASSERT(Window!=NULL);
    		if(Window==NULL)
    			return NULL;
    		STATIC_CHECK(!(boost::mpl::empty<TVisitedComponentList>::value), TVisitedComponentList_must_be_not_empty_and_be__boost_mpl_list_c__type);
    		const TUniqueIDOfVisitedComponentList UniqueIDOfVisitedComponentList=this->getUniqueIDOfVisitedComponentTypeList<TVisitedComponentList>();
    		const TCasterRepositorys::const_iterator NotFound=_casterRepositorys.end();
    		TCasterRepositorys::const_iterator findedCasterRepositoryForThisVisitedComponentList=_casterRepositorys.find(UniqueIDOfVisitedComponentList);
    		if(findedCasterRepositoryForThisVisitedComponentList==NotFound)
    		{
    			this->registerVisitedComponentList<TVisitedComponentList>();
    			findedCasterRepositoryForThisVisitedComponentList=_casterRepositorys.find(UniqueIDOfVisitedComponentList);
    		}
    		ASSERT(findedCasterRepositoryForThisVisitedComponentList!=NotFound);
    		const TCasterRepository::const_iterator NotFoundCaster=findedCasterRepositoryForThisVisitedComponentList->second->end();
    		const unsigned int ComponentType=const_cast<PegThing* const>(Window)->Type();
    		const TCasterRepository::const_iterator findedCaster=findedCasterRepositoryForThisVisitedComponentList->second->find(ComponentType);
    		if(findedCaster==NotFoundCaster)
    			return NULL;
    		ASSERT(findedCaster!=NotFoundCaster);
    		return (*(findedCaster->second))(Window);		
    	}
    
    	template<class TCurrentItem, class TEnd>
    	void registerVisitedComponentListItem(TCasterRepository& casterRepository, TCurrentItem CurrentItem, TEnd End)
    	{
    		using namespace boost;
    		enum {WINDOW_COMPONENT_TYPE=mpl::deref<TCurrentItem>::type::value};
    		STATIC_CHECK((mpl::has_key<TWindowComponentsTypeIdToTypeMap, mpl::int_<WINDOW_COMPONENT_TYPE> >::value!=0), WINDOW_COMPONENT_TYPE_must_be_at_TWindowComponentsTypeIdToTypeMap);
    		typedef mpl::at<TWindowComponentsTypeIdToTypeMap, mpl::int_<WINDOW_COMPONENT_TYPE> >::type TRealTypeOfWindowComponent;
    		this->checkDuplicateComponentTypeID(WINDOW_COMPONENT_TYPE, casterRepository);
    		struct _
    		{
    			static TCastWindowComponentTo* const casterForEachWindowComponent(PegThing* const Window)
    			{
    				ASSERT(Window!=NULL);
    				if(Window==NULL)
    					return NULL;
    				TRealTypeOfWindowComponent* const RealTypeComponent = static_cast<TRealTypeOfWindowComponent* const>(Window);
    				ASSERT(RealTypeComponent!=NULL);
    				TCastWindowComponentTo* const FinalCastedWindowComponent = static_cast<TCastWindowComponentTo* const >(RealTypeComponent);
    				ASSERT(FinalCastedWindowComponent!=NULL);
    				return FinalCastedWindowComponent;
    			}
    		};
    		TCasterForEachWindowComponent CasterForEachWindowComponentFunction=&(_::casterForEachWindowComponent);
    		this->checkDuplicateType(CasterForEachWindowComponentFunction, casterRepository);
    		casterRepository[WINDOW_COMPONENT_TYPE]=CasterForEachWindowComponentFunction;
    		registerVisitedComponentListItem(casterRepository, mpl::next<TCurrentItem>::type(), TEnd());
    	}
    
    	template<class TEnd>
    	void registerVisitedComponentListItem(TCasterRepository& casterRepository, TEnd CurrentItem, TEnd End)
    	{}

    Код из того же большого проекта.
    Ассерты после static_cast и "шаблонная магия" особенно доставляют.
    Мне конечно boost::mpl нравиться, но я считаю, что его негоже использовать в реальных проектах.

    Говногость, 29 Марта 2012

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

    +151

    1. 1
    $now = date(date('Y-m-d H:i:s'));

    striker, 29 Марта 2012

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

    +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
    if(
           (trim($class->antihacker($_POST['fio']))=='')or
           (trim($class->antihacker($_POST['phone']))=='')or
           (trim($class->antihacker($_POST['email']))=='')or
           (trim($class->antihacker($_POST['adress']))=='')
          ){$error="Указанные поля заполнены неверно!";}
       elseif(!$class->validate_email($_POST['email'])){$error="E-mail указан не корректно!";}
       elseif($_POST['is_company']=='1'){
         if(
           (trim($class->antihacker($_POST['company']))=='')or
           (trim($class->antihacker($_POST['fio_cmp']))=='')or
           (trim($class->antihacker($_POST['email_cmp']))=='')or
           (trim($class->antihacker($_POST['kchet']))=='')or
           (trim($class->antihacker($_POST['rchet']))=='')
          ){$error="Указанные поля заполнены неверно!";}
       }

    анти хакерз...

    Sulik78, 28 Марта 2012

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

    +73

    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
    public String XOR_Encrypt(String source, String key)
        {
            byte plain_text[] = new byte[source.length()];
            plain_text = source.getBytes();
            byte key_mas[] = new byte[key.length()];
            key_mas = key.getBytes();
            int key_len = key.length();
            int crypt_pos = 0;
            for(int i = 0; i < source.length(); i++)
            {
                plain_text[i] = (byte)(plain_text[i] ^ 0xaa);
                plain_text[i] = (byte)(plain_text[i] ^ key_mas[crypt_pos]);
                if(crypt_pos >= key_len - 1)
                    crypt_pos = 0;
                else
                    crypt_pos++;
            }
    
            String EText = ByteToHexString(plain_text);
            return EText;
        }
        public static String EncodeSimmetr(String s)
        {
            int MultKey = 62142;
            int AddKey = 11719;
            byte f1[] = new byte[s.length()];
            byte f[] = new byte[s.length()];
            f = s.getBytes();
            for(int i = 0; i < s.length(); i++)
            {
                f1[i] = (byte)(f[i] ^ MultKey);
                MultKey ^= AddKey;
            }
    
            s = new String(f1);
            return s;
        }

    Система шифрования в той-же платёжке...

    dinisoft, 28 Марта 2012

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

    +71

    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
    String url = "http://*.*.*.*:*/java/?code=" + sCode + "&request=monitor";
    String LogPass = sName + ":" + sPass;
    String sAuth = "Basic " + encodeBase64(LogPass);
    try
                {
                    con = (HttpConnection)Connector.open(url);
                    con.setRequestMethod("GET");
                    con.setRequestProperty("User-Agent", "Profile/MIDP-2.0 Confirguration/CLDC-1.0");
                    con.setRequestProperty("Accept_Language", "en-US");
                    con.setRequestProperty("Content-Type", "//text plain");
                    con.setRequestProperty("Connection", "close");
                    con.setRequestProperty("Authorization", sAuth);
                    in = con.openInputStream();
                    if(con.getResponseCode() == 200)
                    {
                        StringBuffer sb = new StringBuffer();
                        int chr;
                        while((chr = in.read()) != -1) 
                            sb.append((char)(chr < 192 || chr > 255 ? chr : chr + 848));
                        sBuff = sb.toString();
                    }
    }

    Авторизация в одной из платёжных систем

    dinisoft, 28 Марта 2012

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

    +119

    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
    string str;
            if (((str = path) != null) && (str != "basic"))
            {
                if (str == "contact")
                {
                    BindContact();
                    PageTitle = "Contact info";
                    editform.SetActiveView(vi_contact);
                    return;
                }
                if (str == "personal")
                {
                    PageTitle = "More about me";
                    BindPersonal();
                    editform.SetActiveView(vi_personal);
                    return;
                }
                if (str == "career")
                {
                    PageTitle = "Work info";
                    BindCareer();
                    editform.SetActiveView(vi_career);
                    return;
                }
                if (str == "tags")
                {
                    BindTags();
                    PageTitle = "Tags I Follow";
                    editform.SetActiveView(vi_tags);
                    return;
                }
                if (str == "biography")
                {
                    ph_page_title.Visible = false;
                    bind_biography();
                    editform.SetActiveView(vi_biography);
                    return;
                }
                if (str == "pp")
                {
                    ph_picpage_title.Visible = true;
                    ph_page_title.Visible = false;
                    PageTitle = "Edit profile photo";
                    BindProfilePhoto();
                    return;
                }
            }
    
            PageTitle = "Basic info";
            BindBasic();
            editform.SetActiveView(vi_basic);

    switch на диалекте хинди ;[ слава asp.net! убить Мартинса и Фаулера за чистокодную ересь!

    qwertylolman, 28 Марта 2012

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

    +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
    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
    ///////////////////////////////КОДИТ FIELD////////////////////////////////
    if($opt == 'bags') {
    echo "<h3>Ошибки в фильмах</h3>
    <a href='/admin/index.php?view=components&do=config&id=24&opt=bags&old=0'>Активные ошибки</a>
    <a href='/admin/index.php?view=components&do=config&id=24&opt=bags&old=1'>Исправленные ошибки</a>
    
    <table border=1><tr><td>Дата</td><td>Название фильма</td><td>Добавил ошибку</td><td>Тип ошибки</td><td>Описание</td><td>Статус</td><td>Исправил</td></tr>";
    $old = $_REQUEST['old'];
    if ($old==1) {$result=$inDB->query("SELECT * from cms_multimedia_bags WHERE `fixed`='1' ORDER by date DESC");}
    else         {$result=$inDB->query("SELECT * from cms_multimedia_bags WHERE `fixed`<>'1' ORDER by date DESC");}
    
    while($row=$inDB->fetch_assoc($result)) {
    if ($row['admin']=='') {$row['admin']="Неисправлена";}
    if ($row['fixed']==1) {$fix="<center><a href='/admin/index.php?view=components&do=config&id=24&opt=fix_bag&fixed=0&bag_id=$row[id]' title='Исправлена'><img src=/admin/images/actions/button_check.png></a>";$table_color="";$fix_date="($row[fix_date])";}
    if ($row['fixed']<>1) {$fix="<center><a href='/admin/index.php?view=components&do=config&id=24&opt=fix_bag&fixed=1&bag_id=$row[id]' title='Не исправлена'><img src=/admin/images/actions/stop.png></a>";$table_color="<font color=red>";$fix_date="";}
    
    if ($row['multimedia_group']==2) {$tip='add_films';}
    if ($row['multimedia_group']==3) {$tip='add_serials';}
    
    if ($row['type']==1) {$row['type']='Не скачивается';}
    if ($row['type']==2) {$row['type']='Не просматривается';}
    if ($row['type']==3) {$row['type']='Ошибка в описании фильма';}
    if ($row['type']==4) {$row['type']='Неверный постер';}
    if ($inUser->id==275) {$del="(<a href='/admin/index.php?view=components&do=config&id=24&opt=del_bag&bag_id=$row[id]'>x</a>)";}
    
    $result1=$inDB->query("SELECT * from cms_multimedia_names WHERE `id`='$row[film_id]'");
    $film_row=$inDB->fetch_assoc($result1);
    $result2=$inDB->query("SELECT * from cms_users WHERE `id`='$row[user_id]'");
    $user_row=$inDB->fetch_assoc($result2);
    echo "<tr><td>$table_color$row[date]</td><td><a href='/admin/index.php?view=components&do=config&id=24&opt=$tip&cat_group=$row[multimedia_group]&file_id=$row[file_id]'>" . $film_row['video_name_rus'] . "</a>(<a href='/multimedia/$row[multimedia_group]/$row[film_id]/$row[file_id]' target='_blank'>на сайте</a>)</td><td><a href='/users/$user_row[nickname]'>$user_row[nickname]</a>($row[ip])</td><td>$table_color" . $row['type'] . "</td><td>$table_color" . $row['description'] . "</td><td>$fix $del<td>$row[admin] $fix_date</td></tr>";
    }
    echo "</table>";
    
    }
    if($opt == 'fix_bag') {
    $bag_id = $_REQUEST['bag_id'];
    $fixed = $_REQUEST['fixed'];
    $date=date("Y-m-d H:i:s");
    
    if ($fixed==1) {$inDB->query("UPDATE cms_multimedia_bags SET `fixed`='$fixed', `fix_date`='$date', `admin`='$inUser->nickname' WHERE id=$bag_id");}
    else          {$inDB->query("UPDATE cms_multimedia_bags SET `fixed`='$fixed', `fix_date`='$date', `admin`='' WHERE id=$bag_id");}
    $inCore->redirect('/admin/index.php?view=components&do=config&id='.$_REQUEST['id'].'&opt=bags');
    }
    if($opt == 'del_bag') {
    $bag_id = $_REQUEST['bag_id'];
    $inDB->query("DELETE from cms_multimedia_bags WHERE id=$bag_id");
    $inCore->redirect('/admin/index.php?view=components&do=config&id='.$_REQUEST['id'].'&opt=bags');
    }
    
    ///////////////////////////////КОНЕЦ КОДА FIELD/////////////////////////

    =) Наш заказчик нанял, нового специалиста php, который якобы "помогает" нам дорабатывать проект=

    onzone, 28 Марта 2012

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

    +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
    15. 15
    16. 16
    17. 17
    switch (count($params)) {
    	case 0:
    		return $this->{$method}();
    	case 1:
    		return $this->{$method}($params[0]);
    	case 2:
    		return $this->{$method}($params[0], $params[1]);
    	case 3:
    		return $this->{$method}($params[0], $params[1], $params[2]);
    	case 4:
    		return $this->{$method}($params[0], $params[1], $params[2], $params[3]);
    	case 5:
    		return $this->{$method}($params[0], $params[1], $params[2], $params[3], $params[4]);
    	default:
    		return call_user_func_array(array(&$this, $method), $params);
    	break;
    }

    cakephp framework v 1.3

    57uff3r, 28 Марта 2012

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