- 1
- 2
- 3
- 4
- 5
- 6
- 7
//Функция проверки закачиваемого файла
function fileNameCheck($file) {
if(preg_match("/[^a-z\d\-\._]/i", $file)) {
return true;
}
return false;
}
Нашли или выдавили из себя код, который нельзя назвать нормальным, на который без улыбки не взглянешь? Не торопитесь его удалять или рефакторить, — запостите его на говнокод.ру, посмеёмся вместе!
+48
//Функция проверки закачиваемого файла
function fileNameCheck($file) {
if(preg_match("/[^a-z\d\-\._]/i", $file)) {
return true;
}
return false;
}
Приятно удивляет соответствие названия функции с её возвращаемым значением.
+53
class MYSQL_ACTIONS
{
public $arguments = array();
public $values;
public $rows;
public $check = true;
public $list_array = array();
function __construct ()
{
$this->arguments = func_get_args();
$z = '';
foreach ($this->arguments as $value)
{
$y ="$value,";
$z .= $y;
}
$this->rows = substr("$z",0,-1);
}
function check_isset()
{
$argument = func_get_args();
for ($i = 0; $i < count($argument); $i++)
{
foreach ($argument as $value)
{
${$value} = $this->list_array[$i++];
}
}
for($i = 0; $i < count($argument); $i++)
{
$x = ${$argument[$i]};
if (empty($x))
{
$this->check = false;
break;
}
}
}
function mysql_action($table)
{
$processing = new GET_(processing);
$date = date("Y-m-d H:i:s");
for ($i = 0; $i < count($this->arguments); $i++)
{
foreach ($this->arguments as $value)
{
${$value} = $this->list_array[$i++];
}
}
$x ='';
foreach ($this->arguments as $value)
{
$y =" '${$value}',";
$x .= $y;
}
$this->values = substr("$x",0,-1);
if ($processing->variable == "add")
{
if ($this->check == true)
{
$result = mysql_query("INSERT INTO {$table} ({$this->rows}) VALUES ({$this->values})");
if ($result == true)
{
echo "";
}
else
{
echo "";
}
}
else
{
echo "";
}
}
}
}
Очередное говно с просторов интернета
+116
delegate β ƒ<α, β>(α x);
delegate α γ<α>(γ<α> f);
static ƒ<α, β> Y<α, β>(ƒ<ƒ<α, β>, ƒ<α, β>> f) {
return new γ<ƒ<α, β>>(h => F => f(h(h))(F))(h => F => f(h(h))(F));
}
static ƒ<int, int> Fact(ƒ<int, int> fact) {
return n => (n == 0) ? 1 : n * fact(n - 1);
}
...
var fact = Y<int, int>(Fact);
Console.WriteLine("fact(6) = {0}", fact(6));
+141
<select>
<option class="a2" value="0" selected="selected">любой возраст</option>
<option class="a2" value="1">0 мес - 6 мес</option>
<option class="a2" value="2">0 мес - 12 мес</option>
</select>
selected="selected" для элемента, выбираемого по дефолту - зачем?
ps. Код - кусок статичного html.
+106
function ReplaceUrl(txt: WideString): WideString;
var
i, j: integer;
tmp, Url: WideString;
begin
Result := '';
I := 1;
while I <= Length(txt) do
begin
tmp := '';
if WideSameText(tmp + txt[i]+txt[i+1]+txt[i+2]+txt[i+3]+txt[i+4]+txt[i+5]+txt[i+6], 'http://') or
WideSameText(tmp + txt[i]+txt[i+1]+txt[i+2]+txt[i+3]+txt[i+4]+txt[i+5]+txt[i+6], 'ed2k://') or
WideSameText(tmp + txt[i]+txt[i+1]+txt[i+2]+txt[i+3]+txt[i+4]+txt[i+5], 'ftp://') or
WideSameText(tmp + txt[i]+txt[i+1]+txt[i+2]+txt[i+3], 'www.') or
WideSameText(tmp + txt[i]+txt[i+1]+txt[i+2]+txt[i+3]+txt[i+4]+txt[i+5]+txt[i+6]+txt[i+7], 'https://') then
begin
Url := '';
for j := I to Length(txt) do
begin
if (txt[j] <> ' ') and (ord(txt[j]) < 255) then
Url := Url + txt[J]
else
Break;
end;
Result := Result + Format(C_HTML_URL, [Url, Url]);
I := J;
end else
begin
Result := Result + txt[I];
Inc(I);
end;
end;
end;
http://www.bvbcode.com/code/vhk2e8rb-1638045
+56
$data = $this->db->qp($q=(($type == 1 && $this->auth->demo == 0) ? '(SELECT Favorite_Name as s, CONCAT(oname,\'|\',House,\'|\',Enter) as s2, Id as id, \'1\' as t, null as m, IF(LEFT(LOWER(TRIM(Favorite_Name)), '.$c.')=\''.$sword.'\', 0, IF(LEFT(LOWER(TRIM(oname)), '.$c.')=\''.$sword.'\', 1, 2)) as od, \'1\' as t2 FROM :Cabinet_Favorite_Objects: WHERE Client_Phone=\'7'.$this->auth->phone.'\' && (lower(Favorite_Name) LIKE \'%'.$sword.'%\' || lower(oname) LIKE \'%'.$sword.'%\') ORDER BY od ASC, Favorite_Name'.$lim.')
UNION ALL
(SELECT addr as s, \'1\' as s2, id as id, \'2\' as t, null as m, IF(LEFT(LOWER(TRIM(addr)), '.$c.')=\''.$sword.'\', 0, 1) as od, \'2\' as t2 FROM :cabinet_history_objects: WHERE cid=\''.$this->auth->adata['IDClient'].'\' && lower(addr) LIKE \'%'.$sword.'%\' ORDER BY od ASC, num, addr DESC'.$lim.')
' : '').(($type == 1 && $this->auth->demo == 0 && $c > 0) ? ' UNION ALL ' : '').(($c > 0) ? '(SELECT objectName as s, objectMetaType as s2, objectID as id, \'3\' as t, objectAddress as m, IF(LEFT(LOWER(TRIM(SearchField)), '.$c.')=\''.$sword.'\', 0, 1) as od, IF(objectMetaType=\'0\', 3, IF(objectMetaType=\'100\', 4, 5)) as t2 FROM :Cabinet_Objects: WHERE lower(SearchField) LIKE \'%'.$sword.'%\' ORDER BY od ASC, objectMetaType ASC, s ASC'.$lim.')' : ''), '', 'select');
Получение списка доступных адресов для заказа такси.
+75
@Override
public boolean onTouchEvent(MotionEvent e) {
x=(int)e.getX(); y=(int)e.getY();
/* ... */
synchronized(this) {
try {this.wait(1000);}
catch (InterruptedException ex) {}
}
return true;
}
/* Gets (screen/pixel) x,y coordinates of last touch event*/
public boolean GetCoordinates(MutablePoint coordinates) {
if (x==-1) return false;
coordinates.init(x,y);
return true;
}
https://github.com/acl33/AndroidDasher/blob/master/src/dasher/android/DasherCanvas.java
+27
// до рефакторинга
if(!y) {
if(!x) {
if(grid[pos+1] || grid[pos+fieldWidth])
ret = true;
} else if(x == fieldWidth - 1) {
if(grid[pos - 1] || grid[pos+fieldWidth])
ret = true;
} else {
if(grid[pos-1] || grid[pos+1] || grid[pos+fieldWidth])
ret = true;
}
} else if(y == fieldHeigth - 1) {
if(!x) {
if(grid[pos+1] || grid[pos-fieldWidth])
ret = true;
} else if(x == fieldWidth - 1) {
if(grid[pos - 1] || grid[pos-fieldWidth])
ret = true;
} else {
if(grid[pos-1] || grid[pos+1] || grid[pos-fieldWidth])
ret = true;
}
} else {
if(!x) {
if(grid[pos+1] || grid[pos+fieldWidth] || grid[pos-fieldWidth])
ret = true;
} else if(x == fieldWidth - 1) {
if(grid[pos - 1] || grid[pos+fieldWidth] || grid[pos+fieldWidth])
ret = true;
} else {
if(grid[pos - 1] || grid[pos+fieldWidth] || grid[pos-fieldWidth] || grid[pos + 1])
ret = true;
}
}
// после рефакторинга
bool ret = getGridPoint(x-1, y) || getGridPoint(x+1, y) || getGridPoint(x, y-1) || getGridPoint(x, y+1))
Код одного из моих друзей. Проверяет закрашена ли хотя бы одна клеточка вокруг указанной...
+19
??=include <iostream>
template <typename T> class TSingleton: public T
??<
public:
static T& instance(void)
??<
static T instance;
return instance;
??>;
??>;
class TOscillStatisticko
??<
protected:
TOscillStatisticko(void):_countNewInSmallPool(0), _countDeleteInSmallPool(0) ??<??>;
friend class TSingleton <TOscillStatisticko>;
private:
int _countNewInSmallPool;
int _countDeleteInSmallPool;
public:
void addCountNewInSmallPool(void)
??<
_countNewInSmallPool++;
??>
int countNewInSmallPool(void)
??<
return _countNewInSmallPool;
??>
??>;
typedef TSingleton <TOscillStatisticko> TOscillStatistic;
int main()
??<
TOscillStatistic::instance().addCountNewInSmallPool();
std::cout<<TOscillStatistic::instance().countNewInSmallPool()<<std::endl;
std::cout<<"ko"<<std::endl;
??>
http://ideone.com/dt9L9
Ладно, раз уж я так палюсь, то придется признаться: у меня просто сломалась клавиатура, потому сегодня пришлось написать немного странно...
Так вот вопрос:, почему, если закомментировать строку
friend class TSingleton <TOscillStatisticko>;
http://ideone.com/4WBGh
+125
sed -e 's/^/;;/g;s/$/ /g' -e :a -e '1!x;1h;s/.*\(.\)$/\1/;p;x;s/\(.*\).$/\1/;h;ta' ~/src/find_world.sh | sed -e :a -e 'N;s/\n//g;ba' | sed -e 's/;;/\n/g' -e 's/^[ ]*//g'
rev