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

    −65

    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
    public function validateLabelInput(&$label) {
        if ( 
          ! ( 
            (
              $this->labeling_main->is('1.1') && $this->labeling_main->is('7.1') && $this->labeling_main->is('2') && $this->labeling_main->is('3') 
                && $this->labeling_main->is('4') && $this->labeling_main->is('5') && $this->labeling_main->is('23') 
            )
            || (
              $this->labeling_main->is('1.1') 
                && ($this->labeling_main->is('7.2') || $this->labeling_main->is('7.3') || $this->labeling_main->is('7.4') ) 
                && $this->labeling_main->is('2') && $this->labeling_main->is('3') && $this->labeling_main->is('4') && $this->labeling_main->is('5')
                && $this->labeling_main->is('25') 
            )
            || (
              $this->labeling_main->is('1.1') && $this->labeling_main->is('7.5') && $this->labeling_main->is('2') && $this->labeling_main->is('3') 
                && $this->labeling_main->is('4') && $this->labeling_main->is('5')
            )
            || (
              $this->labeling_main->is('1.1') && $this->labeling_main->is('7.6') && $this->labeling_main->is('2') && $this->labeling_main->is('3')
            )
            || (
              $this->labeling_main->is('1.2') && $this->labeling_main->is('2') && $this->labeling_main->is('3') && $this->labeling_main->is('7') 
                && $this->labeling_main->is('4') && $this->labeling_main->is('5')
            )
            || (
              $this->labeling_main->is('1.3') && $this->labeling_main->is('2') && $this->labeling_main->is('3') && $this->labeling_main->is('7') 
                && $this->labeling_main->is('4') && $this->labeling_main->is('5')
            )
            || (
              $this->labeling_main->is('1.4') && ($this->labeling_main->is('8.1') || $this->labeling_main->is('8.2')) && $this->labeling_main->is('2')
                && $this->labeling_main->is('3') && $this->labeling_main->is('17') && $this->labeling_main->is('18')
            )
            || (
              $this->labeling_main->is('1.4') && $this->labeling_main->is('19') && $this->labeling_main->is('2') && $this->labeling_main->is('3') 
            )
            || (
              $this->labeling_main->is('1.4') && $this->labeling_main->is('20') && $this->labeling_main->is('2') && $this->labeling_main->is('3') 
            )
            || (
              $this->labeling_main->is('1.5') && $this->labeling_main->is('26.2') && $this->labeling_main->is('2') && $this->labeling_main->is('3') 
                && $this->labeling_main->is('17') && $this->labeling_main->is('18')
            )
            || (
              $this->labeling_main->is('1.5') && $this->labeling_main->is('26.1') && $this->labeling_main->is('2') && $this->labeling_main->is('3')
            )
            || (
              $this->labeling_main->is('1.6') && $this->labeling_main->is('22') && $this->labeling_main->is('2') && $this->labeling_main->is('3') 
                && $this->labeling_main->is('4') && $this->labeling_main->is('5')
            )
            || (
              $this->labeling_main->is('1.7') && $this->labeling_main->is('11')
            )
            || (
              $this->labeling_main->is('1.8') && $this->labeling_main->is('2') && $this->labeling_main->is('3')
            )
            || ($this->labeling_main->is('1.9'))
            || (
              $this->labeling_main->is('1.10') && $this->labeling_main->is('2') && $this->labeling_main->is('3') && $this->labeling_main->is('4') 
                && $this->labeling_main->is('5')
            )
            || (
              $this->labeling_main->is('1.11') && $this->labeling_main->is('2') && $this->labeling_main->is('3') && $this->labeling_main->is('17') 
                && $this->labeling_main->is('18')
            )
            || ($this->labeling_main->is('13'))
          )  
        ){
          $label['data']['status'] = 3;
        }
      }

    brainstorm, 24 Декабря 2012

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

    +54

    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
    function bezpezdu_num($num)
    {
    	if(isset($num) && !empty($num) && is_numeric($num))
    		return true;
    	else
    		return false;
    }
    
    function pizdec($text)
    {
    	$showtext = htmlspecialchars($text);
    	exit($showtext);
    }

    $app->run_epta();

    kindofbear, 21 Декабря 2012

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

    +56

    1. 1
    2. 2
    3. 3
    4. 4
    function goto($url, $time = 0)
    {
    	exit('<META HTTP-EQUIV="REFRESH" CONTENT="'.$time.';URL='.$url.'">');
    }

    kindofbear, 21 Декабря 2012

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

    +43

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    function Podergatsya($i)
    {
    	$i++;
    	$i--;
    	return $i;
    }

    Индусская CMS

    kindofbear, 21 Декабря 2012

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

    +46

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    7. 7
    $week['monday'] = date("d.m.Y", $week_start);
    $week['tuesday'] = date("d.m.Y", $week_start + 1 * 86400);
    $week['wednesday'] = date("d.m.Y", $week_start + 2 * 86400);
    $week['thursday'] = date("d.m.Y", $week_start + 3 * 86400);
    $week['friday'] = date("d.m.Y", $week_start + 4 * 86400);
    $week['saturday'] = date("d.m.Y", $week_start + 5 * 86400);
    $week['sunday'] = date("d.m.Y", $week_start + 6 * 86400);

    1allen, 20 Декабря 2012

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

    +54

    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
    function validEmail($email)
    {
    	$isValid = true;
    	$atIndex = strrpos($email, "@");
    	if (is_bool($atIndex) && !$atIndex) {
    		$isValid = false;
    	} else {
    		$domain = substr($email, $atIndex + 1);
    		$local = substr($email, 0, $atIndex);
    		$localLen = strlen($local);
    		$domainLen = strlen($domain);
    		if ($localLen < 1 || $localLen > 64) {
    			// local part length exceeded
    			$isValid = false;
    		} else if ($domainLen < 1 || $domainLen > 255) {
    			// domain part length exceeded
    			$isValid = false;
    		} else if (!strrpos($domain, ".")) {
    			// domain part does not have .
    			$isValid = false;
    		} else if ($domain[0] == '.' || $domain[$domainLen - 1] == '.') {
    			// domain part starts or ends with '.'
    			$isValid = false;
    		} else if ($local[0] == '.' || $local[$localLen - 1] == '.') {
    			// local part starts or ends with '.'
    			$isValid = false;
    		} else if (preg_match('/\\.\\./', $local)) {
    			// local part has two consecutive dots
    			$isValid = false;
    		} else if (!preg_match('/^[A-Za-z0-9\\-\\.]+$/', $domain)) {
    			// character not valid in domain part
    			$isValid = false;
    		} else if (preg_match('/\\.\\./', $domain)) {
    			// domain part has two consecutive dots
    			$isValid = false;
    		} else if (!preg_match('/^(\\\\.|[A-Za-z0-9!#%&`_=\\/$\'*+?^{}|~.-])+$/', str_replace("\\\\", "", $local))) {
    			// character not valid in local part unless 
    			// local part is quoted
    			if (!preg_match('/^"(\\\\"|[^"])+"$/', str_replace("\\\\", "", $local))) {
    				$isValid = false;
    			}
    		}
    		/* if ($isValid && !(checkdnsrr($domain,"MX") || checkdnsrr($domain,"A"))) {
    		  // domain not found in DNS
    		  $isValid = false;
    		  } */
    	}
    	return $isValid;
    }

    Интересно а автор когдата слишал про filter_var?
    Это все можна заменить на filter_var($input, FILTER_VALIDATE_EMAIL);
    Товаришь программист! Не умеешь срать - не мучай жопу!

    v_anonym, 19 Декабря 2012

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

    +39

    1. 1
    2. 2
    3. 3
    4. 4
    function getTextLabel($labelName)
    {
    	return $labelName;
    }

    Зачем плодить такие фейки?

    v_anonym, 19 Декабря 2012

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

    +47

    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
    # GET /dialog([0-9]+)
    Public Static Function Dialog($senderId){
        $user = Session::Restore();
        IF($user){
            $users = Collection::Get('users', 'UserModel');
            $sender = $users->Find( Query::Equal('id', $senderId) );
            IF(sizeof($sender) > 0){
                $sender = $sender[0];
                $profile_view = self::Profile($sender->id);
                $mails = Collection::Get('mail', 'MailModel');
                $in = $mails->Find( Query::All( Query::Equal( 'tid', $user->id ), Query::Equal('fid', $sender->id) ) );
                $out = $mails->Find( Query::All( Query::Equal( 'fid', $user->id ), Query::Equal('tid', $sender->id) ) );
                $dialog = array();
    
                ForEach($in as $inMsg){
                    IF(!$inMsg->read)
                    {
                        $inMsg->read = 1;
                        $inMsg->save();
                    }
                }
    
                ForEach( $in as $message ){
                    IF(!isset($dialog[$message->time]))
                        $dialog[$message->time] = array();
                    $dialog[$message->time][] = array('type'=>'in', 'message'=>$message);
                }
    
                ForEach( $out as $message ){
                    IF(!isset($dialog[$message->time]))
                        $dialog[$message->time] = array();
                    $dialog[$message->time][] = array('type'=>'out', 'message'=>$message);
                }
    
                ksort($dialog);
    
                $profile_view->Set('ProfileContent', 'dialog.php')->Set('dialog', $dialog);
                return $profile_view;
            }
            throw new ForbiddenException( l('Sender is not found') );
        }
        throw new ForbiddenException( l('User is not authenticated') );
    }

    d3n4, 18 Декабря 2012

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

    +58

    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
    private function  _getOrderBy($orderField)
        {
            switch ($orderField)
            {
                case 'ProductID':
                    return 'ProductID';
                case 'ProductName':
                    return 'ProductName';
                case 'Per':
                    return 'Per';
                case 'Start':
                    return 'Start';
                case 'Qty':
                    return 'Qty';
                case 'OrderDetailsID':
                    return 'OrderDetailsID';
                case 'FIOUr':
                    return 'FIOUr';
                case 'AddressUr':
                    return 'AddressUr';
                case 'ZipCodeUr':
                    return 'ZipCodeUr';
                case 'OrderRealSupID':
                    return 'OrderRealSupID';
                case 'PayDate':
                    return 'PayDate';
                case 'SumPay':
                    return 'SumPay';
                case 'NumPlPor':
                    return 'NumPlPor';
                default:
                    return 'OrderID';
            }
        }
    
    //Вот еще чуть-чуть:
    
    private function  _getOrderType($orderType)
        {
            switch ($orderType)
            {
                case 'asc':
                    return 'asc';
                default:
                    return 'desc';
            }
        }

    Ну в общем, привожу пару этюдов из "коричневой" симфонии, которые используются для формирования SQL запроса. Код - прост, но говнист.

    SunnyMagadan, 17 Декабря 2012

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

    +42

    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
    function Utf2Win($s){ return Utf8($s,'w') ; }  
    function Win2Utf($s){ return Utf8($s,'u') ; }  
    function Utf8($s, $sTo = 'utf2win'){  
       $a = array();  
      for ($i=128; $i <= 191; $i++){  
       $a['utf'][] = ($i<144) ? chr(209).chr($i) : chr(208).chr($i);  
       $a['win'][] = ($i<144) ? chr($i + 112) : chr($i + 48) ;  
      }  
      $a['utf'][] = chr(208) . chr(129);  
      $a['win'][] = chr(168);  
      $a['utf'][] = chr(209) . chr(145);  
      $a['win'][] = chr(184);
    
      $a['utf'][] = chr(209) . chr(78);  
      $a['win'][] = chr(73);
    
      $a['utf'][] ='в„–';
      $a['win'][] = '№';
    
       if(in_array(strtolower($sTo), array('utf2win','w','cp1251','windows-1251')))  
         return str_replace($a['utf'], $a['win'], $s);  
       if(in_array(strtolower($sTo), array('win2utf','u','utf8','utf-8')))  
         return str_replace($a['win'], $a['utf'], $s);  
    } 
    
    function getfield_csv($string,$index)
    {
      $arr = explode(";",$string);
      return $arr[$index];
    }
    
    function read_csv($file)
    {
      $hFile = fopen($file,"r");
        $source_data_utf = fread($hFile,filesize($file));
      fclose($hFile);
      
      $source_data = Utf2Win($source_data_utf);
      
      $arr_source_data = explode("\r\n",$source_data);
      
      for($i=0;$i<count($arr_source_data);$i++)
      {
        $arr_source_data[$i] = str_replace(chr(239).chr(187).chr(191), "", $arr_source_data[$i]);
        $result[] = Array();
        $result[count($result)-1]['Ds'] = getfield_csv($arr_source_data[$i], 0);
        $result[count($result)-1]['Fkp'] = getfield_csv($arr_source_data[$i], 5);
        $result[count($result)-1]['Tgg'] = getfield_csv($arr_source_data[$i], 3);
        $result[count($result)-1]['Pol'] = getfield_csv($arr_source_data[$i], 4);
        $result[count($result)-1]['Tr'] = getfield_csv($arr_source_data[$i], 6);
      }
      return $result;
    }

    clauclauclau, 17 Декабря 2012

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