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

    +150

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    $black = "eval|file_get_contents|mysql_(.*?)|include|require|readfile|show_source|highlight|import_request_variables|extract|parse_str|assert|passthru|exec|system|shell_exec|proc_open|fopen|echo";
    
    if(preg_match("#\<\?(.*?)($black)(.*?)\?\>#i", $template)){
    exit ("1");
    break;
    }

    substr, 20 Июня 2011

    Комментарии (57)
  2. C++ / Говнокод #7013

    +159

    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
    #include <math.h>
    #include <iostream>
    using namespace std;
    void main()
    { int month,day;
            cin>>month,day;
            int den=1;
            switch(month)
    {       case 1: cout<<"month: "<<month<<endl<<"day: "<<day+1;
    if(day==31){cout<<"month: "<<month+1<<endl<<den;}
    break;
            case 2: cout<<"month: "<<month<<endl<<"day: "<<day+1;
            if(day==28){cout<<"month: "<<month+1<<endl<<"day: "<<den;}
    break;
            case 3:cout<<"month: "<<month<<endl<<"day: "<<day+1;
                    if(day==31){cout<<"month: "<<month+1<<endl<<"day: "<<den;}
    break;
            case 4:cout<<"month: "<<month<<endl<<"day: "<<day+1;
                    if(day==30){cout<<"month: "<<month+1<<endl<<"day: "<<den;}
    break;
            case 5: cout<<"month: "<<month<<endl<<"day: "<<day+1;
                    if(day==31){cout<<"month: "<<month+1<<endl<<"day: "<<den;}
    break;
            case 6: cout<<"month: "<<month<<endl<<"day: "<<day+1;
                    if(day==30){cout<<"month: "<<month+1<<endl<<"day: "<<den;}
    break;
            case 7: cout<<"month: "<<month<<endl<<"day: "<<day+1;
                    if(day==31){cout<<"month: "<<month+1<<endl<<"day: "<<den;}
    break;
            case 8: cout<<"month: "<<month<<endl<<"day: "<<day+1;
                    if(day==31){cout<<"month: "<<month+1<<endl<<"day: "<<den;}
    break;
            case 9: cout<<"month: "<<month<<endl<<"day: "<<day+1;
                    if(day==30){cout<<"month: "<<month+1<<endl<<"day: "<<den;}
    break;
            case 10: cout<<"month: "<<month<<endl<<"day: "<<day+1;
                    if(day==31){cout<<"month: "<<month+1<<endl<<"day: "<<den;}
    break;
            case 11: cout<<"month: "<<month<<endl<<"day: "<<day+1;
                    if(day==30){cout<<"month: "<<month+1<<endl<<"day: "<<den;}
    break;
            case 12: cout<<"month: "<<month<<endl<<"day: "<<day+1;
                    if(day==31){cout<<"month: "<<month+1<<endl<<"day: "<<den;}
                    
                                    
    }       
     
    cin.get();
            cin.get();
    }

    Juris_Kabanis, 20 Июня 2011

    Комментарии (12)
  3. Java / Говнокод #7012

    +82

    1. 1
    2. 2
    3. 3
    /*
            todo it seems that code below will be right, when client will be changed
    */

    Вот такой емкий комментарий перед 200 закоментированными строками кода

    galak, 20 Июня 2011

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

    +147

    1. 1
    2. 2
    3. 3
    if ($a = 1) {
    	...бла-бла-бла
    }

    nislova, 20 Июня 2011

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

    +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
    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
    <?php 
    	if(isset($_GET["status"])) {
    		//Определяем переменные
    		$user_id = $_GET['user_id'];
    		$operator_id = $_GET['operator_id'];
    		$smsid = $_GET['smsid'];
    		$operator_id_str = $_GET['operator_id_str'];
    		$num = $_GET['num'];
    		$msg_trans = $_GET['msg_trans'];
    		$msg = $_GET['msg'];
    		$cost_rur = $_GET['cost_rur'];
    		$ratepoints = $cost_rur; //Рейтинг = стоимость смс
    		
    		//Подключаемся к бд
    		$dblocation = "localhost";	 // Имя сервера
    		$dbuser = "****";          // Имя пользователя
    		$dbpasswd = "******";            // Пароль
    		$dbname = "******"; //Имя бд
    		$dbcnx = @mysql_connect($dblocation,$dbuser,$dbpasswd);
    		if (!$dbcnx) {
    			  echo("Не удалось установить соеденение");
    			  exit();
    		} else  {
    						if (!@mysql_select_db($dbname, $dbcnx)) {
    							  echo  "База данных недоступна <br />" ;
    							  exit();
    						} else {
    							//Проверяем зарегестрирован ли пользователь
    							$changeuser = @mysql_query("SELECT * FROM jos_users WHERE  username='$user_id'");
    							if(@mysql_num_rows($changeuser) > 0) {
    							//Пользователь зарегестрирован
    								@mysql_query("INSERT INTO sms (operator_id, operator_id_str, user_id, smsid, num, msg_trans, msg, cost_rur) VALUES ('$operator_id','$operator_id_str','$user_id','$smsid','$num','$msg_trans','$msg','$cost_rur')"); //Добавляем смс
    								@mysql_query("UPDATE jos_users SET rate = rate +1 WHERE username='$user_id'"); //Увеличиваем рейтинг
    								@mysql_query("UPDATE jos_users SET sms = sms +1 WHERE username='$user_id'"); //Увеличиваем кол-во смс
    								$rate = @mysql_fetch_array(@mysql_query("SELECT rate FROM jos_users WHERE username='$user_id'"));
    								echo "SMS Send OK rate +1 your rate: ".$rate['rate']."";
    							} else {
    							/*Пользователь не зарегестрирован,
    							Регестрируем пользователя*/
    							$regdate = date("Y-m-d  H:i:s");
    							
    							//Генерируем пароль
    							$pass = rand(10000, 99999);
    							$sqlpass = md5($pass);
    							
    							//Добавляем пользователя
    								@mysql_query("INSERT INTO jos_users (name, username, password, usertype, gid, registerDate, lastvisitDate) VALUES ('$user_id', '$user_id', '$sqlpass', 'Registered', '18', '$regdate', '$regdate')");
    								$getnewuserid = @mysql_fetch_array(@mysql_query("SELECT id FROM jos_users WHERE username='$user_id'"));
    								@mysql_query("INSERT INTO jos_core_acl_aro (section_value, value, order_value, name, hidden) VALUES ('users', '{$getnewuserid['id']}', '0', '$user_id', '0')");
    								$getaro_id = @mysql_fetch_array(@mysql_query("SELECT id FROM jos_core_acl_aro WHERE name='$user_id'"));
    								@mysql_query("INSERT INTO jos_core_acl_groups_aro_map (group_id, aro_id) VALUES ('18', '{$getaro_id['id']}')");
    								
    								@mysql_query("INSERT INTO sms (operator_id, operator_id_str, user_id, smsid, num, msg_trans, msg, cost_rur) VALUES ('$operator_id','$operator_id_str','$user_id','$smsid','$num','$msg_trans','$msg','$cost_rur')"); 
    								@mysql_query("UPDATE jos_users SET rate = rate +1 WHERE username='$user_id'");
    								@mysql_query("UPDATE jos_users SET sms = sms +1 WHERE username='$user_id'");
    								$rate = @mysql_fetch_array(@mysql_query("SELECT rate FROM jos_users WHERE username='$user_id'"));
    								echo "SMS Register complete. Login: ".$user_id." Pass: ".$pass." Your rate: ".$rate['rate']."";
    							}
    									}
    			}
    	}
    ?>

    phplamer, 20 Июня 2011

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

    +165

    1. 1
    2. 2
    3. 3
    ASSERT(mStartSamples.size() == mFades.size() == mIsFadeIns.size() == inOutBlock->GetNumChannels());
    
    ASSERT(iGainData.size() == mSizes.size() == inStartSamples.size() != 0);

    Краткость - сестра таланта

    victor_r, 20 Июня 2011

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

    +76

    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
    public class ValueList< T > implements Cloneable
    {
        public ValueList() { }
    
        public void addValue( final T value ) {
            list.add( value );
        }
    
        @Override
        @SuppressWarnings( { "unchecked", "unchecked" } )
        public Object clone() throws CloneNotSupportedException {
            super.clone();
            ValueList< T > object = new ValueList< T >();
            List< T > objectList = object.getList();
            objectList = ( List< T > )list.clone();
            for( int index = 0; index < list.size() ; ++index ) {
                objectList.set( index, ( Object )list.get( index ).clone() );
            }
            return object;
        }
    
        public List< T > getList() {
            return list;
        }
    
        private ArrayList< T > list = new ArrayList< T >();
    }

    Человек из соседнего отдела порадовал...

    SadKo, 20 Июня 2011

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

    +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
    function retPercByAct($num,$economy) { //50% discount => economy=0 => 15%
      $t='15/5 0-49,
      16/6 50-100,
      17/7 101-200,
      18/8 201-350,
      19/9 351-500,
      20/10 601-1000,
      21/11 1001-500000,';
      $t=explode(',',$t);
      foreach($t as $k=>$v) {
        $v=trim($v);
        list($perc,$nums)=explode(' ',$v);
        $nums=explode('-',$nums);
        if($nums[0]<=$num && $nums[1]>=$num) {
          $perc=explode('/',$perc);
          if(!$economy) $percR=$perc[0]; else $percR=$perc[1];
          break;
        }
      }
      return $percR;
    }

    Вот, встретилось в поддерживаемом мной проекте.

    segoddnja, 20 Июня 2011

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

    +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
    $a=array(
    		'save'=>array(
    			'state'=>array('new'=>array(1, 1), 0=>array(0, 0), 1=>array(1, 1), 3=>array(1, 1), 4=>array(0, 0), 5=>array(0, 0), 6=>array(1, 1)),
    			'dest'=>1,
    		),
    		'save_and_back'=>array(
    			'state'=>array('new'=>array(1, 1), 0=>array(0, 0), 1=>array(1, 1), 3=>array(1, 1), 4=>array(0, 0), 5=>array(0, 0), 6=>array(1, 1)),
    			'dest'=>1,
    		),
    		'save_as_a_copy'=>array(
    			'state'=>array('new'=>array(0, 0), 0=>array(1, 1), 1=>array(1, 1), 3=>array(1, 1), 4=>array(1, 1), 5=>array(1, 1), 6=>array(1, 1)),
    			'dest'=>1,
    		),
    		'resend'=>array(
    			'state'=>array('new'=>array(0, 0), 0=>array(1, 1), 1=>array(1, 1), 3=>array(1, 1), 4=>array(1, 1), 5=>array(1, 1), 6=>array(1, 1)),
    			'dest'=>1,
    		),
    		'send'=>array(
    			'state'=>array('new'=>array(0, 1), 0=>array(0, 0), 1=>array(0, 1), 3=>array(0, 1), 4=>array(0, 0), 5=>array(0, 1), 6=>array(0, 1)),
    			'dest'=>array(1,3),
    		),
    		'testsend'=>array(
    			'state'=>array('new'=>array(0, 1), 0=>array(0, 0), 1=>array(0, 1), 3=>array(0, 1), 4=>array(0, 0), 5=>array(0, 1), 6=>array(0, 1)),
    			'dest'=>array(1,3),
    		),
    		'offer'=>array(
    			'state'=>array('new'=>array(1, 0), 0=>array(0, 0), 1=>array(1, 0), 3=>array(0, 0), 4=>array(0, 0), 5=>array(0, 0), 6=>array(1, 0)),
    			'dest'=>5,
    		),
    		'reject'=>array(
    			'state'=>array('new'=>array(0, 0), 0=>array(0, 0), 1=>array(0, 0), 3=>array(0, 0), 4=>array(0, 0), 5=>array(0, 1), 6=>array(0, 0)),
    			'dest'=>6,
    		),
    		'cancel'=>array(
    			'state'=>array('new'=>array(0, 0), 0=>array(0, 0), 1=>array(1, 1), 3=>array(0, 0), 4=>array(0, 0), 5=>array(0, 0), 6=>array(0, 0)),
    			'dest'=>1,
    		),
    	);

    Без комментариев.

    pro_co_ru, 20 Июня 2011

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

    +160

    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 function getList($sort) {
            if ($sort == 'id')
                $select = $this->select()->order('id ASC');            
            if ($sort == 'id2')
                $select = $this->select()->order('id DESC');
            if ($sort == 'username')
                $select = $this->select()->order('username ASC');
            if ($sort == 'username2')
                $select = $this->select()->order('username DESC');
            if ($sort == 'firstname')
                $select = $this->select()->order('firstname ASC');
            if ($sort == 'firstname2')
                $select = $this->select()->order('firstname DESC');
            if ($sort == 'lastname')
                $select = $this->select()->order('lastname ASC');
            if ($sort == 'lastname2')
                $select = $this->select()->order('lastname DESC');
            if ($sort == 'lastdate')
                $select = $this->select()->order('lastdate ASC');
            if ($sort == 'lastdate2')
                $select = $this->select()->order('lastdate DESC');
            if ($sort == 'regdate')
                $select = $this->select()->order('regdate ASC');
            if ($sort == 'regdate2')
                $select = $this->select()->order('regdate DESC');
            if ($sort == 'city')
                $select = $this->select()->order('city ASC');
            if ($sort == 'city2')
                $select = $this->select()->order('city DESC');
            if ($sort == 'vote')
                $select = $this->select()->order('vote ASC');
            if ($sort == 'vote2')
                $select = $this->select()->order('vote DESC');
            $result = $this->fetchAll($select);
            return $result;
        }

    Кусочек кода, написанный в классической манере "if-else" для Zend Framework

    coderov, 20 Июня 2011

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