- 1
- 2
echo( TRUE ? "1" : TRUE ? "2":"3");
//2
Нашли или выдавили из себя код, который нельзя назвать нормальным, на который без улыбки не взглянешь? Не торопитесь его удалять или рефакторить, — запостите его на говнокод.ру, посмеёмся вместе!
+75
echo( TRUE ? "1" : TRUE ? "2":"3");
//2
http://ideone.com/UBg3T2
В ответ на это:
http://govnokod.ru/12268#comment163978
+50
<?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");
}
}
...
+141
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();
}
}
+53
$this->_requestUri = 0 === strpos($_SERVER['REQUEST_URI'], $_SERVER['SCRIPT_NAME'])
? substr(
$_SERVER['REQUEST_URI'], strlen($_SERVER['SCRIPT_NAME'])
)
: $_SERVER['REQUEST_URI'];
+140
Здравствуйте, господа!
Кто знает, как выяснить свободный порт виртуальной машины средствами PHP?
+49
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;
}
}
Более говнокодного я давно не писал. Кажется я схожу с ума
+142
$model->date = date('Y-m-d H:i:s',mktime(date('H'),date('i'),date('s'),date('m'),date('d'),date('Y')));
берём текущую дату...
+50
$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;
+37
<?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');
}
}
}
?>
Извержение.
+50
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 страну, в классе вот такой метод для обратного преобразования :)