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

    +164

    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
    /////////////Название ссылок (меню и тд) ////////////////
    $file=str_replace('{text_about}',$sph_messages["text_about"],$file); // О нас
    $file=str_replace('{text_main}',$sph_messages["text_main"],$file); //
    $file=str_replace('{text_news}',$sph_messages["text_news"],$file);
    $file=str_replace('{text_web}',$sph_messages["text_web"],$file);
    $file=str_replace('{text_pog_gorod}',$sph_messages["text_pog_gorod"],$file);
    $file=str_replace('{text_catigor}',$sph_messages["text_catigor"],$file);
    $file=str_replace('{text_logo}',$sph_messages["text_logo"],$file);
    $file=str_replace('{text_searc}',$sph_messages["text_searc"],$file);
    $file=str_replace('{text_img}',$sph_messages["text_img"],$file);
    $file=str_replace('{text_add}',$sph_messages["text_add"],$file);
    $file=str_replace('{text_help}',$sph_messages["text_help"],$file);
    $file=str_replace('{text_search_all}',$sph_messages["text_search_all"],$file);
    $file=str_replace('{text_feedback}',$sph_messages["text_feedback"],$file);
    $file=str_replace('{text_send}',$sph_messages["text_send"],$file);
    $file=str_replace('{text_start}',$sph_messages["text_start"],$file);
    $file=str_replace('{text_reg_mail}',$sph_messages["text_reg_mail"],$file);
    $file=str_replace('{text_kurs}',$sph_messages["text_kurs"],$file);
    $file=str_replace('{text_mail}',$sph_messages["text_mail"],$file);
    $file=str_replace('{text_pass}',$sph_messages["text_pass"],$file);
    $file=str_replace('{text_lang}',$sph_messages["text_lang"],$file);
    $file=str_replace('{text_zapomnit}',$sph_messages["text_zapomnit"],$file);
    $file=str_replace('{text_vhod}',$sph_messages["text_vhod"],$file);
    $file=str_replace('{text_pogoda}',$sph_messages["text_pogoda"],$file);
    $file=str_replace('{text_friend}',$sph_messages["text_friend"],$file);
    $file=str_replace('{text_music}',$sph_messages["text_music"],$file);
    $file=str_replace('{text_foto}',$sph_messages["text_foto"],$file);
    $file=str_replace('{text_video}',$sph_messages["text_video"],$file);
    $file=str_replace('{text_search_ras}',$sph_messages["text_search_ras"],$file);
    $file=str_replace('{text_add_code}',$sph_messages["text_add_code"],$file);
    $file=str_replace('{text_add_des}',$sph_messages["text_add_des"],$file);
    $file=str_replace('{text_add_url}',$sph_messages["text_add_url"],$file);
    $file=str_replace('{text_add_name}',$sph_messages["text_add_name"],$file);
    $file=str_replace('{text_add_ost}',$sph_messages["text_add_ost"],$file);
    $file=str_replace('{text_add_znak}',$sph_messages["text_add_znak"],$file);
    //////////КАТЕГОРИИ////////
    $file=str_replace('{cat}',$sph_messages["cat"],$file);
    $file=str_replace('{cat_all}',$sph_messages["cat_all"],$file);
    $file=str_replace('{cat_avto}',$sph_messages["cat_avto"],$file);
    $file=str_replace('{cat_web}',$sph_messages["cat_web"],$file);
    $file=str_replace('{cat_znakom}',$sph_messages["cat_znakom"],$file);
    $file=str_replace('{cat_games}',$sph_messages["cat_games"],$file);
    $file=str_replace('{cat_komp}',$sph_messages["cat_komp"],$file);
    $file=str_replace('{cat_story}',$sph_messages["cat_story"],$file);
    $file=str_replace('{cat_soft}',$sph_messages["cat_soft"],$file);
    $file=str_replace('{cat_music}',$sph_messages["cat_music"],$file);
    $file=str_replace('{cat_sport}',$sph_messages["cat_sport"],$file);
    $file=str_replace('{cat_dom}',$sph_messages["cat_dom"],$file);
    $file=str_replace('{cat_business}',$sph_messages["cat_business"],$file);
    $file=str_replace('{cat_zarabotok}',$sph_messages["cat_zarabotok"],$file);
    и так еще over9000 cтрок

    мои глаза...

    TBoolean, 10 Февраля 2012

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

    −121

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    CASE st.testmode_order_active
    WHEN NULL THEN '1'
    WHEN '1' THEN '0'
    WHEN '0' THEN '1'
    as testmode_product_active

    кусок sql запроса с реального проекта. логика в БД одна, в приложении - обратная.

    codename, 10 Февраля 2012

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

    +997

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    7. 7
    8. 8
    9. 9
    for (int z=NewArray[y-1];z<(NewArray[y]-1);z++)
                    {
                      AnsiString ts = IntToStr(z+1);
                      int inum = -1;
                      try{
                        inum = StrToInt(ts);
                      } catch(...) {}
    ..... //дальше inum не используется
                    }

    Завис надолго. Так и не понял, зачем автор преобразовывает ts обратно

    dm-ua, 10 Февраля 2012

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

    +158

    1. 1
    if( !( $users['align'] > 1 AND $users['align'] < 3 ) ) die();

    laplay, 10 Февраля 2012

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

    +154

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    foreach($files as $k => $obj){
    	foreach($obj as $key => $val){
    		$temp[$val['file_sort']]=$key;	
    	}
    	ksort($temp);
    	foreach($temp as $key => $val){
    		$temp2[$val]=$obj[$val];
    	}
    	$files[$k]=$temp2;
    }

    не осилил usort(), удаляет ключи... =((

    Zyets, 10 Февраля 2012

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

    +141

    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
    private void tlistObject_SelectedIndexChanged(object sender, EventArgs e)
    {
    	IMapObject oTarget = this.tlistObjects.SelectedItem as IMapObject;
    
    	if (oTarget != null)
    	{
    		if (this.SelectedObject != null)
    		{
    			this.SelectedObject.ObjectMode = ObjectModeElements.None;
    		}
    		this.SelectedObject = this.tlistObjects.SelectedItem as IMapObject;
    		this.SelectedObject.ObjectMode = ObjectModeElements.Selected;
    	}
    }

    (Is + Explicit приведение) или (As + проверка на Null)?
    Ход конём.
    ОБЯЗАТЕЛЬНОЕ использование this при обращении к полям, свойствам и методам текущего класса - отдельная тема. Это одна из особенностей неповторимого стиля, присущего аффтару. Весь код забит thisами под завязку.

    ICELedyanoj, 10 Февраля 2012

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

    +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
    26. 26
    27. 27
    function mydebug($arr1=array(), $narr1='', $arr2=array(), $narr2='', $arr3=array(),$narr3='',$arr4=array(),$narr4='',$arr5=array(),$narr5='',$arr6=array(),$narr6='',$arr7=array(),$narr7='' ) {
    	$var = 'arr';
    	$nvar =  'narr';
    	$quit = false;
    	for($i=1; $i<8; $i++) {
    		if(${$var.$i} == 'exit' ) {
    				$quit = true;
    				continue;
    			}
    			 
    			elseif( !is_array(${$var.$i}) || is_array(${$nvar.$i})) {
    				${$var.$i} = false;
    				${$nvar.$i} = false;
    			}
    			 
    			elseif(!empty(${$var.$i})) {
    				echo ${$nvar.$i}.'<br>';
    				var_dump(${$var.$i});
    				echo "<hr>";
    			}
    			 
    			else continue;
    	}
    	if($quit == true) {
    		exit;
    	}
    }

    breathe, 10 Февраля 2012

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

    +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
    37. 37
    38. 38
    39. 39
    40. 40
    41. 41
    42. 42
    43. 43
    44. 44
    45. 45
    46. 46
    <?php
    //Класс для получения и сохранения данных пользователя.
    class User{    
    	const TABLE = 'users';	
    	//Создаём к каждому полю в таблице users переменную (всего столбцов в базе >45)
    	var $id = 0;
    	var $user_type = 'private';
    	var $name = '';
    	var $surname = '';
    	var $pk = '';
    	//.... Тут ещё около 40 переменных	
    	var $contactMail = '';
    	var $contactPhone = '';
    		
        //....Конструктор, получение данных, сохранение данных
        
    	//Функции для получения данных пользователя
        function getId() {return $this->id;}
        function getUser_type() {return $this->user_type;}
        function getName() {return $this->name;}
        function getSurname() {return $this->surname;}
        //.... Тут ещё около 40 аналогичных функций
        function getContactMail() {return $this->contactMail;}
        function getContactPhone() {return $this->contactPhone;}
        
        //Функции для изменения данных пользователя (в конце нужно вызвать функцию для сохранения)
        function setId($data) {$this->id = $data;}
        function setUser_type($data) {$this->user_type = $data;}
        function setName($data) {$this->name = $data;}
        //.... Тут ещё около 40 аналогичных функций
        function setContactPhone($data) {$this->contactPhone = $data;}
        function setContact_type($data) {$this->contact_type = $data;}
       
    	//функция для сохранения данных
        function save(){    	        
        	$fields = Array();
        	$fields['user_type'] = $this->user_type;
    	    $fields['name'] = $this->name;
    	    //.... Тут ещё около 40 переменных	
    	    $fields['contactPhone'] = $this->contactPhone;
    	    $fields['contact_type'] = $this->contact_type;
    	       	
        	$this->id = Db::make(self::TABLE, $this->id, $fields);
        	return 1;
        }
    }

    Класс для получения и сохранения данных пользователя.

    Присутсвуют и аналогичные классы для других таблиц в которых количество переменных не меньше.

    Edd, 10 Февраля 2012

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

    +153

    1. 1
    2. 2
    3. 3
    do_site_map($result, $url_info);
    do_robots();
    htaccess_do($result, $url_info);

    jonnywalker, 10 Февраля 2012

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

    +171

    1. 1
    2. 2
    3. 3
    4. 4
    //получаем ip-аддрес
    ob_start();
    $ip=$_SERVER['REMOTE_ADDR']; echo "$ip ";
    $ipusers = ob_get_clean();

    http://alltheragefaces.com/img/faces/large/misc-jackie-chan-l.png

    TBoolean, 10 Февраля 2012

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