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

    +75

    1. 1
    2. 2
    echo( TRUE ? "1" : TRUE ? "2":"3");
    //2

    http://ideone.com/UBg3T2
    В ответ на это:
    http://govnokod.ru/12268#comment163978

    3.14159265, 11 Декабря 2012

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

    +50

    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
    <?php
    session_start();
    if(empty($_SESSION['UserLogin']) or empty($_SESSION['UserId']))
    {
      header('Location: /');
    }
    else
    {
      include("application/db.config.php");
      $GetterUser = $_POST['ForUser'];
      $SenderUser = $_SESSION['UserId'];
      $Rem = strip_tags($_POST['Rem']);
      $Text = strip_tags($_POST['Text']);
    
      if($Rem == "" or $Text == "")
      {
        header("Location: sent_mess?to=$GetterUser&status=bad");
      }
      else
      {
        $SendingMessQuery = mysql_query("INSERT INTO Dialogs(From, To, Rem, Text) VALUES($SenderUser, $GetterUser, '$Rem', '$Text')", $db) or die(mysql_error());
        mysql_close($db);
        header("Location: sent_mess?to=$GetterUser&status=good");
      }
    }
    ...

    Govnisti_Diavol, 11 Декабря 2012

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

    +141

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    7. 7
    8. 8
    9. 9
    if(is_dir('install')|| is_dir('migrate')) {
            if (!file_exists(PATH.'/includes/config.inc.php')){
                header('location:/install/');
    			die();
            } else {
                include(PATH.'/core/messages/installation.html');
                die();
            }
        }

    Govnisti_Diavol, 10 Декабря 2012

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

    +53

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    $this->_requestUri = 0 === strpos($_SERVER['REQUEST_URI'], $_SERVER['SCRIPT_NAME'])
                ? substr(
                    $_SERVER['REQUEST_URI'], strlen($_SERVER['SCRIPT_NAME'])
                )
                : $_SERVER['REQUEST_URI'];

    __proto__, 08 Декабря 2012

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

    +140

    1. 1
    2. 2
    Здравствуйте, господа!
    Кто знает, как выяснить свободный порт виртуальной машины средствами PHP?

    Govnisti_Diavol, 06 Декабря 2012

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

    +49

    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
    function preDispatch() {
            
    		
    		
    		
    		// Validate and redirect
            try {
                $this->_DB = Zend_Db_Table::getDefaultAdapter();
                $time = $this->_DB->query('SELECT time FROM `CapturesList` WHERE InnerLink = \'' . $_SERVER['REQUEST_URI'] . '\' LIMIT 0,1;')->fetchAll();
    
    
    		@$this->view->time = $time[0]['time'];
    
    
                if ($time[0]['time'] != NULL) {
                    $times = split(', ', $time[0]['time']);
                    if (strtotime(($times[1]) . '/' . ($times[2]) . '/' . $times[0] . ' ' . $times[3] . ":00") < (int) (mktime())) {
                        if (strtotime(($times[1]) . '/' . ($times[2]) . '/' . $times[0] . ' ' . $times[3] . ":00") > 1347032555) {
                            $count = $this->_DB->query('SELECT *, COUNT(time) AS counts FROM `CapturesList` WHERE time IS NOT NULL;')->fetchAll();
                            $count = $count[0]['counts'];
                            @$newdate = strftime("%G, %m, %d, %H", strtotime(($times[1]) . '/' . ($times[2]) . '/' . $times[0] . ' ' . $times[3] . ":00 +" . ((int)($count / 2) + 1) . " weeks"));
                            @$this->_DB->query('UPDATE `CapturesList` SET `time` = \'' . ($newdate) . '\' WHERE InnerLink = \'' . $_SERVER['REQUEST_URI'] . '\';');
                            @$this->view->time = $newdate;
                        }
                        else{@$this->view->time = $time[0]['time'];}
                    } else {
                        @$this->view->time = $time[0]['time'];
                    }
                } else {
                    @$this->view->time = "NULL";
                }
            } catch (Exception $exc) {
                echo $exc->getTraceAsString();
                @$this->view->time = "NULL";
            }
    
    
    
            header('Refer: ' . $this->view->linktofunnel);
            if (session_id() == '')
                session_start();
            if ($this->_getParam('action') != 'save') {
                $_SESSION["domain"] = $this->view->domain;
                $_SESSION["owner"] = $this->OwnerData;
            }
        }

    Более говнокодного я давно не писал. Кажется я схожу с ума

    Stud, 06 Декабря 2012

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

    +142

    1. 1
    $model->date = date('Y-m-d H:i:s',mktime(date('H'),date('i'),date('s'),date('m'),date('d'),date('Y')));

    берём текущую дату...

    blackray, 05 Декабря 2012

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

    +50

    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
    $sw = false;
    if($valid_from && $valid_to)
    	if( ($valid_from<=date('U')) && ($valid_to>=mktime(0,0,0,date('m'),date('d'),date('Y'))) )
    		$sw = true;
    	else
    		{
    			//Nimic
    		}
    elseif($valid_form)
    	if($valid_form<=date('U'))
    		$sw = true;
    	else
    		{
    			//Nimic
    		}
    elseif($valid_to)
    	if($valid_to>=mktime(0,0,0,date('m'),date('d'),date('Y')))
    		$sw = true;
    	else
    		{
    			//Nimic
    		}
    else
    	$sw = true;

    Edd, 04 Декабря 2012

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

    +37

    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
    71. 71
    72. 72
    73. 73
    <?php
    session_start();
    if(!empty($_SESSION['UserLogin']) or !empty($_SESSION['UserId']))
    {
      header('Location: user');
    }
    if(isset($_POST['UserName'])) 
    { 
      $UserName = $_POST['UserName']; 
      if($UserName == '') 
      {
       unset($UserName);
      } 
    }
    if(isset($_POST['UserEmail'])) 
    { 
      $UserEmail = $_POST['UserEmail']; 
      if($UserEmail == '') 
      {
       unset($UserEmail);
      } 
    } 
    if(isset($_POST['UserLogin'])) 
    { 
      $UserLogin = $_POST['UserLogin']; 
      if($UserLogin == '') 
      {
       unset($UserLogin);
      } 
    }
    if(isset($_POST['UserPassword'])) 
    { 
      $UserPassword = $_POST['UserPassword']; 
      if($UserPassword == '') 
      {
       unset($UserPassword);
      } 
    }
    if (empty($UserName) or empty($UserEmail) or empty($UserLogin) or empty($UserPassword))
    {
     header('Location: registration?error_code=1');
    }
    else
    {
      include("application/db.config.php");
      $UserLogin = stripslashes($UserLogin);
      $UserLogin = htmlspecialchars($UserLogin);
      $UserLogin = trim($UserLogin);
      $UserPassword = stripslashes($UserPassword);
      $UserPassword = htmlspecialchars($UserPassword);
      $UserPassword = trim($UserPassword);
      $SelectQuery = mysql_query("SELECT id FROM Users WHERE UserLogin ='$UserLogin'", $db);
      $QueryResult = mysql_fetch_array($SelectQuery);
      if(!empty($QueryResult['id']))
      {
        header('Location: registration?error_code=2');
      }
      else
      {
        $InsertQuery = mysql_query("INSERT INTO Users(UserName, UserSName, UserLogin, UserPassword, UserEmail, 
        UserPhone, UserStatus) VALUES('$UserName', 'Фамилия не указана', '$UserLogin', '$UserPassword', '$UserEmail', 'Телефон не указан', 'Статус не указан')");
        if($InsertQuery == true)
        {
          header("Location: action_status?reg_code=good&UserLogin=$UserLogin&UserPassword=$UserPassword");
        }
        else
        {
          header('Location: registration?error_code=3'); 
        }
      }
      
    }
    ?>

    Извержение.

    Govnisti_Diavol, 04 Декабря 2012

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

    +50

    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
    function StringForCountryInt($countryInt)
    	{
    		switch ($countryInt)
    		{
    			case "1" : return 'Afghanistan'; break;
                case "2" : return 'Albania'; break;
                case "3" : return 'Algeria'; break;
                case "4" : return 'American Samoa'; break;
                case "5" : return 'Andorra'; break;
                case "6" : return 'Angola'; break;
                case "7" : return 'Anguilla'; break;
                case "8" : return 'Antarctica'; break;
    //          ....
    //          ....
    //          ....
                 case "239" : return 'Zimbabwe'; break;
    		}
    	}

    MODx, evolution. Сниппет WebLoginPE.
    В базе сохраняет ID страну, в классе вот такой метод для обратного преобразования :)

    MaXL, 04 Декабря 2012

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