1. Лучший говнокод

    В номинации:
    За время:
  2. C++ / Говнокод #9879

    +156

    1. 1
    2. 2
    bool addSomeValue;
    int percentage = 100 + addSomeValue ? 10 : 0;

    infog, 06 Апреля 2012

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

    +156

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    7. 7
    8. 8
    9. 9
    Запиши эти слова в файл (например, words.txt или slova.txt) и прочитай его с помощью функции fgetcsv().
    <?php
    $x=fopen("slova.txt","r");
    $y=fgetcsv($x,filesize($x),' ');
    foreach($y as $line)
    {
        echo $line;
    };    
    ?>

    Разбиение строки на отдельные слова с сайта hashcode.ru

    Int, 01 Апреля 2012

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

    +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
    28. 28
    29. 29
    30. 30
    31. 31
    32. 32
    33. 33
    34. 34
    <?php if(isset($_GET["fullVersion"])) $_SESSION["fullVersion"]="on"; ?><?php if($_SESSION["fullVersion"]!='on' && (substr_count($_SERVER["HTTP_USER_AGENT"],'Android') || substr_count($_SERVER["HTTP_USER_AGENT"],'iPhone'))){
         header("Location: /m/redirects/?withjs");
         exit;
      }
      else if($_SESSION["fullVersion"]!='on' && substr_count($_SERVER["HTTP_USER_AGENT"],'Opera Mini')){
         header("Location: /m/redirects/?operamini");
         exit;
      }
      ?><?php if($_GET["ClockId"] && $_GET["str"] && $_GET["frompartnerka"]==1){ header("Location: http://vip-timeclub.ru/catalog/articul/?ClockId=".(int)$_GET["ClockId"]."&str=2");} ?>
    
    <?php if(function_exists('vtPrice')==false){
        function vtPrice($price=0,$sale=0,$priceGold=0){
          if($priceGold){
            $priceOld = $price;
            $price = $priceGold;
          }
          else if($sale){
            $priceOld = $price;
            $price = ceil(intval($priceOld)-((intval($priceOld)/100)*(intval($sale))));
          }
          else{
            $priceOld = 0;
          }
          return array('price'=>$price,'priceOld'=>$priceOld);
        }
      }if(function_exists('vtPriceGood')==false){
       function vtPriceGood($price){
          if(intval(substr($price,-1)) > 0 && intval(substr($price,-1)) < 5) 
                $price = intval($price) + (5-intval(substr($price,-1))); 
          else if(intval(substr($price,-1)) > 5 && intval(substr($price,-1)) <= 9) 
                $price = intval($price) + (10-intval(substr($price,-1)));
          return $price;
        }
      } ?>

    spam, club-viptime DOT RU

    111111, 01 Апреля 2012

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

    +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
    void checkDuplicateType(TWindowCasterToWindowAdditionalInformation GetWindowAdditionalInformation)
    	{
    		const TCasterRepository::const_iterator NotFound=_casterRepository.end();
    		const TCasterRepository::const_iterator Begin=_casterRepository.begin();
    		struct _
    		{
    			static bool TestDuplicateTypeAtThisItem(const TCasterRepository::value_type& Item, TWindowCasterToWindowAdditionalInformation GetWindowAdditionalInformationFunction)
    			{
    				return Item.second==GetWindowAdditionalInformationFunction;
    			}
    		};
    		ASSERT(std::find_if(Begin, NotFound, BOOST_BIND(_::TestDuplicateTypeAtThisItem, _1, GetWindowAdditionalInformationFunction))==NotFound);
    	}

    Большой проект.

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

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

    +156

    1. 1
    2. 2
    3. 3
    4. 4
    public function session_set_lifetime($time){
      /*NOT USED with cookies, can be used with sessions*/
      return null;
    }

    тотже мастер класа что и тут:
    http://govnokod.ru/9765/
    http://govnokod.ru/9777/

    fafik91, 27 Марта 2012

    Комментарии (1)
  7. JavaScript / Говнокод #9760

    +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
    attr_sel:function(tag,cn,at,vl,inv)
    {
    	if (typeof(inv)=='undefined'){
    		inv=0;
    	}
    	var allT=document.getElementsByTagName(tag), allCN={}, i=0,j=0,a;
    	while(a=allT[i++]){
    		if (cn!='' && this.hasClass(a,cn))
    		{
    			if ((!inv && a.getAttribute(at)==vl)||(inv && a.getAttribute(at)!=vl))
    			{
    				allCN[j]=a;
    				j++;
    			}
    		}else{
    			if ((!inv && a.getAttribute(at)==vl)||(inv && a.getAttribute(at)!=vl))
    			{
    				allCN[j]=a;
    				j++;
    			}
    		}
    	}
    	return allCN;
    }

    По следам полосатого слона #9757
    Выборка по классу и значению атрибута.

    roman-kashitsyn, 25 Марта 2012

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

    +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
    28. 28
    29. 29
    30. 30
    31. 31
    32. 32
    33. 33
    34. 34
    35. 35
    36. 36
    37. 37
    function errhandler($errno,$errstr,$errfile,$errline,$errcontext)
    {
    	global $dbw,$dbr,$tid,$pid,$cheat,$http_referer;
    
    	switch ($errno) 
    	{
    		case E_NOTICE:
    		case E_USER_NOTICE:
    			return true;
    			break;
    		case E_WARNING:
    		case E_USER_WARNING:
    			$error = 'Warning';
    			if (strpos($errstr,'Deadlock')!==false)
    			{
    			cust_rollback($errline);
    			}
    			break;
    		case E_ERROR:
    		case E_USER_ERROR:
    			$error = 'Fatal Error';
    			cust_rollback($errline);
    			break;
    		default:
    			return true;
    			break;
    	}
    	switch ($errno) {
    		case E_ERROR:
    		case E_USER_ERROR:
    			exit();
    			break;
    	}
    	return TRUE;
    }
    
    set_error_handler("errhandler");

    Обрабатывай ошибки правильно

    roman-kashitsyn, 24 Марта 2012

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

    +156

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    //.....
    $post['avatar'] = @$imgpath;
    //.....
    curl_setopt($ch, CURLOPT_POSTFIELDS, $post);
    //.....

    "файлы не загружаются, не знаю в чем проблема"

    _jokz, 21 Марта 2012

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

    +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
    28. 28
    29. 29
    30. 30
    31. 31
    $data = substr($data, stripos($data,"operate(") + 50);
    $a[$i][2] = substr($data, stripos($data,'<b id="performer'));
    $a[$i][2] = substr($a[$i][2], stripos($a[$i][2],">")+1);
    $a[$i][3] = substr($a[$i][2], stripos($a[$i][2],"<"));
    $a[$i][2] = substr($a[$i][2], 0, stripos($a[$i][2],"<"));
    
    $a[$i][3] = substr($a[$i][3], stripos($a[$i][3],'<span id="title'));
    $a[$i][3] = substr($a[$i][3], stripos($a[$i][3],">")+1);
    if ($a[$i][3][0] == '<') {$a[$i][3] = substr($a[$i][3], stripos($a[$i][3],">")+1);}
    $a[$i][4] = substr($a[$i][3], stripos($a[$i][3],"<"));
    $a[$i][3] = substr($a[$i][3], 0, stripos($a[$i][3],"<"));
    $a[$i][4] = substr($a[$i][4], stripos($a[$i][4],'<div class="duration">')+22);
    $a[$i][4] = substr($a[$i][4], 0, stripos($a[$i][4],"<"));
    
    
    
    }
    $l = 52;
    
    for($i = 0; $i<=$l; $i++){
    
    $a[$i][1] = substr($a[$i][1],0,stripos($a[$i][1],")"));
    $a[$i][1] = substr($a[$i][1],stripos($a[$i][1],",")+1);
    $a1 = substr($a[$i][1],0,stripos($a[$i][1],","));
    $a[$i][1] = substr($a[$i][1],stripos($a[$i][1],",")+1);
    $a2 = substr($a[$i][1],0,stripos($a[$i][1],","));
    $a[$i][1] = substr($a[$i][1],stripos($a[$i][1],",")+1);
    $a3 = substr($a[$i][1],0,stripos($a[$i][1],","));
    $a3 = substr($a3, 1 , strlen($a3)-2);
    $name = explode(' ',$a[$i][3]);
    $name = $name[0].' '.$name[1].' '.$name[2];

    Человек совсем не знает регулярок...

    udi, 18 Марта 2012

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

    +156

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    7. 7
    8. 8
    9. 9
    class store_mod_multi_ftp extends store_mod_ftp {
        public function __construct($options) {
            //...
        }
        protected function connect($url, $login) {
            parent::__construct($url, $login);
        }
        //...
    }

    ФТП-мод, который умеет стягивать файлы с разных серверов сразу, в отличие от своего родителя. И ведь работает, зараза!

    Lowezar, 14 Марта 2012

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