- 1
- 2
- 3
- 4
- 5
- 6
- 7
if ($_GET['cred_sum']!=""){
$_GET['cred_sum']=$_GET['cred_sum']-$_GET['cred_sum']-$_GET['cred_sum'];
}
// simple hack
else {
$_GET['cred_sum'] = -1;
}
Нашли или выдавили из себя код, который нельзя назвать нормальным, на который без улыбки не взглянешь? Не торопитесь его удалять или рефакторить, — запостите его на говнокод.ру, посмеёмся вместе!
+157
if ($_GET['cred_sum']!=""){
$_GET['cred_sum']=$_GET['cred_sum']-$_GET['cred_sum']-$_GET['cred_sum'];
}
// simple hack
else {
$_GET['cred_sum'] = -1;
}
Делаем cred_sum отрицательным
+151
$params['monthes'] = array(
1 => 'January',
2 => 'February',
3 => 'March',
4 => 'April',
5 => 'May',
6 => 'June',
7 => 'July',
8 => 'August',
9 => 'September',
10 => 'October',
11 => 'November',
12 => 'December',
);
О существовании date() видимо никто не знает.
+152
<?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>
Лаксори эдишен
+150
// DLE LOL, ../engine/inc/options.php
$config['offline_reason'] = str_replace( '"', '"', $config['offline_reason'] );
+150
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);
}
Мне кажеться индусы пишут лучше
+152
<?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?
+123
Mage::run();
С этого места начинается боль и мучения.
+156
<?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
+143
<?php
function get_md5($filename){
return md5_file($filename)
}
echo "get_md5($_POST)";
?>
Только начал php, посоветуйте литературу Х)
+147
if(is_array($_REQUEST[$fieldname]))
$value = $_REQUEST[$fieldname];
else
$value = trim($_REQUEST[$fieldname]);
Если это не массив то всеравно используем его как массив.
Код с популярной CRM.