- 1
- 2
- 3
- 4
- 5
- 6
function getDateFromTime($dataTime){
$strDate = date('d-m-Y', $dataTime);
$arrDate = explode('-', $strDate);
return mktime(0, 0, 0, $arrDate[1], $arrDate[0], $arrDate[2]);
}
Нашли или выдавили из себя код, который нельзя назвать нормальным, на который без улыбки не взглянешь? Не торопитесь его удалять или рефакторить, — запостите его на говнокод.ру, посмеёмся вместе!
+154
function getDateFromTime($dataTime){
$strDate = date('d-m-Y', $dataTime);
$arrDate = explode('-', $strDate);
return mktime(0, 0, 0, $arrDate[1], $arrDate[0], $arrDate[2]);
}
руки-жопа-голова%)
+159
void AClass::registerApplication( int pCaller )
{
if ( mRegistry == NULL )
{
// we will be the first application in registry
mRegistry = createRegistryElement( pCaller );
}
else
{
// there are other applications already registered
// first create registry entry
Application *lApplication = NULL;
lApplication = createRegistryElement( pCaller );
// put entry in front
lApplication->mNext = mRegistry;
mRegistry = lApplication;
}
}
добавляем новый элемент в односвязный список. mRegister голова списка. кто не видит говна - идти читать матчасть.
+153
try
{
sw = gcnew StreamWriter(GetIniFileName());
}
catch(UnauthorizedAccessException^ e)
{
MessageBox::Show( "Access is denied.", "Ошибка", MessageBoxButtons::OK, MessageBoxIcon::Error );
ShowException(dynamic_cast<System::Exception^>(e));
return;
}
catch(ArgumentNullException^ e)
{
MessageBox::Show( e->ParamName + ": File path is null.", "Ошибка", MessageBoxButtons::OK, MessageBoxIcon::Error );
ShowException(dynamic_cast<System::Exception^>(e));
return;
}
catch(ArgumentException^ e)
{
MessageBox::Show( e->ParamName + ": Wrong file path.", "Ошибка", MessageBoxButtons::OK, MessageBoxIcon::Error );
ShowException(dynamic_cast<System::Exception^>(e));
return;
}
catch(DirectoryNotFoundException^ e)
{
MessageBox::Show( "The specified path is invalid, such as being on an unmapped drive.", "Ошибка", MessageBoxButtons::OK, MessageBoxIcon::Error );
ShowException(dynamic_cast<System::Exception^>(e));
return;
}
catch(PathTooLongException^ e)
{
MessageBox::Show( "The specified path, file name, or both exceed the system-defined maximum length. For example, on Windows-based platforms, paths must be less than 248 characters, and file names must be less than 260 characters. ", "Ошибка", MessageBoxButtons::OK, MessageBoxIcon::Error );
ShowException(dynamic_cast<System::Exception^>(e));
return;
}
catch(IOException^ e)
{
MessageBox::Show( "File path includes an incorrect or invalid syntax for file name, directory name, or volume label syntax. ", "Ошибка", MessageBoxButtons::OK, MessageBoxIcon::Error );
ShowException(dynamic_cast<System::Exception^>(e));
return;
}
catch(SecurityException^ e)
{
MessageBox::Show( "The caller does not have the required permission." + e->ToString(), "Ошибка", MessageBoxButtons::OK, MessageBoxIcon::Error );
ShowException(dynamic_cast<System::Exception^>(e));
return;
}
catch(System::Exception^ e)
{
ShowException(e);
return;
}
Обработка исключений.
+169
const void* const relay(const TrigClass& Overloading=*((TrigClass*)(NULpoter))){
if(&Overloading==NULpoter){
+155
$arrParams = array();
$arrParams['table'] = array();
$arrParams['limit'] = 20;
$arrParams['table']['id'] = 'cmt_summary';
$arrParams['table']['class'] = 'comments';
$arrParams['table']['rows_id'] = 'cmt_{{comment_id}}';
$arrParams['table']['columns'] = array();
$arrParams['table']['columns']['comment_id'] = array();
$arrParams['table']['columns']['comment_id']['name'] = 'Comment ID';
$arrParams['table']['columns']['comment_id']['class'] = 'a';
$arrParams['table']['columns']['comment_id']['sort'] = true;
$arrParams['table']['columns']['comment_id']['search'] = array('type'=>'int');
$arrParams['table']['columns']['comment_id']['row'] = $sRowOutput;
$arrParams['table']['columns']['user_name'] = array();
$arrParams['table']['columns']['user_name']['name'] = 'Poster Username';
$arrParams['table']['columns']['user_name']['class'] = 'a';
$arrParams['table']['columns']['user_name']['sort'] = true;
$arrParams['table']['columns']['user_name']['search'] = array('type'=>'string');
$arrParams['table']['columns']['user_name']['row'] = $sRowOutput;
$arrParams['table']['columns']['email'] = array();
$arrParams['table']['columns']['email']['name'] = 'Poster Email';
$arrParams['table']['columns']['email']['class'] = 'a';
$arrParams['table']['columns']['email']['sort'] = true;
$arrParams['table']['columns']['email']['search'] = array('type'=>'string');
$arrParams['table']['columns']['email']['row'] = $sRowOutput;
Прошло уже почти 3 месяца как я сижу на проекте, а он не перестаёт меня удивлять :)
Глядя на эти строки думается что-то подобное было в головах у кодеров:
- Зачем юзать объекты, в массивы всё нормально ложится и они легче.
- По фиг что массивы не подхватывает ни одна IDE, Notepad++ всё ещё бесплатный, а большего в PHP и не надо.
- Зачем XML и XSD? Зачем это усложнение? Ну и что Ext4Yii хороший пример того как можно это сделать? Нам не нужны слабые духом программисты! :)
+155
// Это у них такой конфиг:
//--------------------------------------------------------------------------------------
// Определение дирректорий сервера
$siteDir = '';
$DIR = array(
'root' => $_SERVER['DOCUMENT_ROOT'].$siteDir,
);
$DIR['HOST'] = 'http://'.$_SERVER['HTTP_HOST'];
$DIR['media'] = $DIR['root'].'/media/';
$DIR['theme'] = $DIR['root'].'/themes/';
$DIR['lib'] = $DIR['root'].'/lib/';
$DIR['script'] = $DIR['root'].'/scripts/script.';
// А это у них такая мвц
// при error_reporting(E_ALL) - таааакая знатная жопа
//---------------------------------------------------------------//
/* Организация простейшего MVC */
//---------------------------------------------------------------//
//Загружаем модель для формированния данных
if(file_exists($DIR['script'].$Page.'.php'))
require_once($DIR['script'].$Page.'.php');
//Загрузка шаблона для отоброжения данных
require_once($DIR['theme'].'default.php');
Ща сижу на собеседование, попросили сделать пару страничек, используя местные порядки.
Сижу в шоке.
+136
<td colspan="3" rowspan="2">
<script>
if(hsub>0){
document.write(
'<table id=tans width=669 height=109 border=0 cellpadding=0 cellspacing=0 style=position:absolute;top:'+(ah-hsub)+'px>')
}else{
document.write(
'<table id=tans width=669 height=109 border=0 cellpadding=0 cellspacing=0>')
}
</script>
<noscript>
<table id=tans width=669 height=109 border=0 cellpadding=0 cellspacing=0>
</noscript>
<tr>
Нет слов!
+119
// создаём источник для репитера
private DataTable EventsDataTable
{
get
{
DataTable dt = new DataTable();
dt.Columns.Add(
new DataColumn("ID", typeof(string)));
dt.Columns.Add(
new DataColumn("day", typeof(string)));
dt.Columns.Add(
new DataColumn("date", typeof(DateTime)));
dt.Columns.Add(
new DataColumn("title", typeof(string)));
dt.Columns.Add(
new DataColumn("url", typeof(string)));
dt.Columns.Add(
new DataColumn("description", typeof(string)));
dt.Columns.Add(
new DataColumn("location", typeof(string)));
dt.Columns.Add(
new DataColumn("place", typeof(string)));
dt.Columns.Add(
new DataColumn("FileDirRef", typeof(string)));
// Добавляем строчки
foreach (EventInfo ei in CalendarEvents)
{
DataRow dr = dt.NewRow();
dr["day"] = ei.EventDate.Date.ToString("ddMMyyyy");
dr["date"] = ei.EventDate;
dr["title"] = ei.Title;
dr["location"] = ei.Location;
dr["ID"] = ei.ID;
dr["FileDirRef"] = ei.FileDirRef;
dt.Rows.Add(dr);
}
return dt;
}
}
protected void repeaterItemDataBound(object sender, RepeaterItemEventArgs e)
{
if (e != null
&& e.Item != null
&& e.Item.DataItem != null
&& e.Item.DataItem is DataRow)
{
DataRow dataItem = (DataRow)e.Item.DataItem;
Label date = (Label)(e.Item.FindControl("date"));
date.Text =
dataItem["date"] != null
? Convert.ToDateTime(dataItem["date"].ToString()).ToString()
: Convert.ToDateTime(dataItem["Created"].ToString()).ToString();
date.Text = date.Text.Substring(0, date.Text.Length - 3);
HyperLink title = (HyperLink)(e.Item.FindControl("title"));
title.Text = dataItem["title"].ToString();
Label location = (Label)(e.Item.FindControl("location"));
location.Text = "Расположение: " + dataItem["location"].ToString();
}
}
Современный способ привязки данных в asp.net Repeater
+160
<?php
function antihack(&$var){
if(is_array($var)) array_walk($var, 'antihack');
else $var = htmlspecialchars(stripslashes(mysql_real_escape_string($var)), ENT_QUOTES, 'UTF-8');
}
foreach(array('_SERVER', '_GET', '_POST', '_COOKIE', '_REQUEST') as $v){
if(!empty(${$v})) array_walk(${$v}, 'antihack');
}
?>
http://homephp.ru/phpcode/index.php?system=bild&stat=173445591-534250613&
+151
<?php
else {
fwrite($fp,"\xFF\xFF\xFF\xFF\x54\x53\x6F\x75\x72\x63\x65\x20\x45\x6E\x67\x69\x6E\x65\x20\x51\x75\x65\x72\x79\x00".chr(10));
$start=time();
socket_set_timeout($fp,1);
$st=fread($fp,1);
$r=socket_get_status($fp);
$r=$r["unread_bytes"];
$st.=fread($fp,$r);
fclose($fp);
$st=substr($st,5);
$address=SubStr($st,0,StrPos($st,chr(0)));
$address=str_replace(chr(0),"|",$address);
$st=SubStr($st,StrPos($st,chr(0))+1);
$name=SubStr($st,0,StrPos($st,chr(0)));
$st=SubStr($st,StrPos($st,chr(0))+1);
$map=SubStr($st,0,StrPos($st,chr(0)));
$st=SubStr($st,StrPos($st,chr(0))+1);
$st=SubStr($st,StrPos($st,chr(0))+1);
$st=SubStr($st,StrPos($st,chr(0))+1);
$current=ord(SubStr($st,0,1));
$max=ord(SubStr($st,1,1));
}
if ($_GET['info'] == "map")
{
echo "document.write('$map');";
}
if ($_GET['info'] == "players")
{
if ($current == "0")
{
echo "document.write('<font color=red>$current</font>/$max');";
}
else
{
if($current == $max)
{
echo "document.write('<font color=00FF00>$current</font>/$max');";
}else{
echo "document.write('$current/$max');";
}
}
}
if ($_GET['info'] == "map-img")
{
echo "document.write('<img width=$width border=0 src=http://image.www.gametracker.com/images/maps/160x120/cs/$map.jpg>');";
}
if ($_GET['info'] == "source-map")
{
echo "document.write('$name');";
}
if ($_GET['info'] == "block1")
{
echo "document.write('<table border=0><tr><td align=center><marquee>$name</marquee><br><img width=160px height=120px style=background:url(http://www.agrank.com/images/maps/210_150/_offline.jpg); border=0 src=http://image.www.gametracker.com/images/maps/160x120/cs/$map.jpg><br>Map - $map<br>Players - <script language=JavaScript src=http://game-monitoring.tk/ucoz/cs-info.php?ip=$ip&port=$port&info=players></script><br><br><center><input value=$ip:$port readonly=readonly onclick=f2(this); class=f_linput type=text></center></td></tr></table>');";
}
if ($_GET['info'] == "block4")
{
}
?>
Мало ли того, что гавнокод, так ещё и SubStr. аха