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

    +152

    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
    74. 74
    75. 75
    <?php
    //Скрипт расчета времени.
    foreach ($_POST as $k=>$v) $$k=$v;
    	if (!$to_month and !$to_day and !$to_year and !$to_hours and !$to_minutes and !$to_seconds) {
    		echo "<h1>Введите данные для расчета</h1>";
    	} 
    	else {
    		$to_time = mktime(intval($to_hours),intval($to_minutes),intval($to_seconds),intval($to_month),intval($to_day),intval($to_year)) ;
    		$from_time = mktime(intval($from_hours),intval($from_minutes),intval($from_seconds),intval($from_month),intval($from_day),intval($from_year)) ;
    		$time = $to_time - $from_time;
    		echo 
    		"От $from_month/$from_day/$from_year $from_hours:$from_minutes:$from_seconds
    		<br>До $to_month/$to_day/$to_year $to_hours:$to_minutes:$to_seconds
    		<br>Миллисекунд: ",$time*1000," 
    		<br>Секунд: ",$time,"
    		<br>Минут: ",$time/60,"
    		<br>Часов: ",$time/3600,"
    		<br>Дней: ",$time/86400,"
    		<br>Недель: ",$time/604800,"
    		<br>Месяцев: ",$time/2628000,"
    		<br>Лет: ",$time/31536000; //31557600 по Юлианскому.
    	}	
    ?>
    
    <!DOCTYPE html>
    <html>
    <head>
    	<title>Сколько времени пройдет от и до</title>
      <style>
       body {
    	margin-left: 38%;
    	font-family: Verdana, Arial, Helvetica, sans-serif; 
      }
       h1 { 
        font-size: 90%; 
        color: #333366;
       }
       input {
        margin: 2px;
    	padding: 2px;
    	width: 200px;
       }
        h2 { 
        font-size: 70%; 
        color: #333366;
       }
    	p {
    	font-size: 60%; 
        color: #f00;
    	}
      </style>
    </head>
    <body>
    <h2>Задайте время от:</h2>
    <form method="post" target="_blank" action="date.php">
    	<input type="text" name="from_year" value="<?=date('Y')?>">	Год<br>
    	<input type="text" name="from_month" value="<?=date('m')?>">	Месяц<br>
    	<input type="text" name="from_day" value="<?=date('d')?>">	День<br>
    	<input type="text" name="from_hours" value="<?=date('G')?>">	Час<br>
    	<input type="text" name="from_minutes" value="<?=date('i')?>">	Минут<br>
    	<input type="text" name="from_seconds" value="<?=date('s')?>">	Секунд
    
    <h2>Задайте время до:</h2>
    	<input type="text" name="to_year">	Год<br>
    	<input type="text" name="to_month">	Месяц<br>
    	<input type="text" name="to_day">	День<br>
    	<input type="text" name="to_hours">	Час<br>
    	<input type="text" name="to_minutes">	Минут<br>
    	<input type="text" name="to_seconds">	Секунд<br>
    	<input type="submit" value="Рассчитать">
    </form>
    
    <p>* Заполнять все поля не обязательно.<br>** Расчеты для лет верны если год - 365 дней.</p>
    </body>
    </html>

    Лаксори эдишен

    Arthur, 13 Марта 2014

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

    +150

    1. 1
    2. 2
    // DLE LOL, ../engine/inc/options.php
    $config['offline_reason'] = str_replace( '"', '"', $config['offline_reason'] );

    bug, 13 Марта 2014

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

    +150

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    7. 7
    8. 8
    9. 9
    public function responsive()
     {
      $month = array("1" => "Responsive", "2" => "Unresponsive");
      for ($i = 1; $i <= 2; $i++)
      {
       $data[] = array('text' => $month[$i], 'value' => $i);
      }
      echo json_encode($data);
     }

    Мне кажеться индусы пишут лучше

    texnikru, 12 Марта 2014

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

    +152

    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
    <?php
    //Скрипт рассчета времени.
    if (!empty($_POST["from_hours"])) { $from_hours = $_POST["from_hours"]; } else { unset($_POST["from_hours"]); }
    if (!empty($_POST["from_minutes"])) { $from_minutes = $_POST["from_minutes"]; } else { unset($_POST["from_minutes"]); }
    if (!empty($_POST["from_seconds"])) { $from_seconds = $_POST["from_seconds"]; } else { unset($_POST["from_seconds"]); }
    if (!empty($_POST["from_month"])) { $from_month = $_POST["from_month"]; } else { unset($_POST["from_month"]); }
    if (!empty($_POST["from_day"])) { $from_day = $_POST["from_day"]; } else { unset($_POST["from_day"]); }
    if (!empty($_POST["from_year"])) { $from_year = $_POST["from_year"]; } else { unset($_POST["from_year"]); }
    
    if (!empty($_POST["to_hours"])) { $to_hours = $_POST["to_hours"]; } else { unset($_POST["to_hours"]); }
    if (!empty($_POST["to_minutes"])) { $to_minutes = $_POST["to_minutes"]; } else { unset($_POST["to_minutes"]); }
    if (!empty($_POST["to_seconds"])) { $to_seconds = $_POST["to_seconds"]; } else { unset($_POST["to_seconds"]); }
    if (!empty($_POST["to_month"])) { $to_month = $_POST["to_month"]; } else { unset($_POST["to_month"]); }
    if (!empty($_POST["to_day"])) { $to_day = $_POST["to_day"]; } else { unset($_POST["to_day"]); }
    if (!empty($_POST["to_year"])) { $to_year = $_POST["to_year"]; } else { unset($_POST["to_year"]); }
    
    $time = mktime($to_hours,$to_minutes,$to_seconds,$to_month,$to_day,$to_year) - mktime($from_hours,$from_minutes,$from_seconds,$from_month,$from_day,$from_year);
    
    	if (!empty($time)) {
    		echo 
    		"От $from_month/$from_day/$from_year $from_hours:$from_minutes:$from_seconds
    		<br>До $to_month/$to_day/$to_year $to_hours:$to_minutes:$to_seconds
    		<br>Секунд: $time
    		<br>Минут: ",$time/60,"
    		<br>Часов: ",$time/60/60,"
    		<br>Дней: ",$time/60/60/24,"
    		<br>Недель: ",$time/60/60/24/365*12*4,"
    		<br>Месяцев: ",$time/60/60/24/365*12,"
    		<br>Лет: ",$time/60/60/24/365;
    	}
    	else {
    		echo "<h2>Введите данные для расчета</h2>";
    	}
    ?>
    
    <!DOCTYPE html>
    <html>
    <head>
    	<title>Сколько времени пройдет от и до</title>
    </head>
    <body>
    <p>Сколько времени от:</p>
    <form method="post" target="_blank" action="date.php">
    	<input type="text" name="from_year">	Год<br>
    	<input type="text" name="from_month">	Месяц<br>
    	<input type="text" name="from_day">	День<br>
    	<input type="text" name="from_hours">	Час<br>
    	<input type="text" name="from_minutes">	Минут<br>
    	<input type="text" name="from_seconds">	Секунд<br>
    <p>Сколько времени до:</p>
    	<input type="text" name="to_year">	Год<br>
    	<input type="text" name="to_month">	Месяц<br>
    	<input type="text" name="to_day">	День<br>
    	<input type="text" name="to_hours">	Час<br>
    	<input type="text" name="to_minutes">	Минут<br>
    	<input type="text" name="to_seconds">	Секунд<br>
    	<input type="submit" value="Рассчитать">
    </form>
    <p>* Заполнять все поля не объязательно.</p>
    </body>
    </html>

    Скрипт расчета времени от и до.
    Как бы улучшить этот говнокод на php?

    Arthur, 11 Марта 2014

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

    +123

    1. 1
    Mage::run();

    С этого места начинается боль и мучения.

    DrugMan, 09 Марта 2014

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

    +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
    <?php
    
     $dataProvider = new CActiveDataProvider('User', array(
                'criteria'=>array(
                    'condition' => 'id = ' . $id,
                ),
            ));
    
    $regdata = $dataProvider->getData();
    if (is_array($regdata)) $regdata = current($regdata);
    //....
    $this->redirect(Yii::app()->createUrl('user/profile'));

    Как не стоит писать на Yii

    JiLiZART, 09 Марта 2014

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

    +143

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    <?php
    function get_md5($filename){
    return md5_file($filename)
    }
    echo "get_md5($_POST)";
    ?>

    Только начал php, посоветуйте литературу Х)

    VityaPW, 08 Марта 2014

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

    +147

    1. 1
    2. 2
    3. 3
    4. 4
    if(is_array($_REQUEST[$fieldname]))
    	$value = $_REQUEST[$fieldname];
    else
    	$value = trim($_REQUEST[$fieldname]);

    Если это не массив то всеравно используем его как массив.
    Код с популярной CRM.

    slirx, 06 Марта 2014

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

    +143

    1. 1
    Хуь.

    Кто хочет глотнуть спермы?

    xyja4it, 05 Марта 2014

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

    +164

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    7. 7
    function boolConvert($value){
            if(strtolower($value)=='true')
                return 1;
            if(strtolower($value)=='false')
                return 0;
            return $value;
        }

    GoodTalkBot, 05 Марта 2014

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