- 1
- 2
- 3
$janres = serialize(isset($_POST['janres']) ? SafeEnv($_POST['janres'], 11, int) : array());
if($tree->IdCats[$cat]['janres'] == "0") $janres = serialize(array());
Нашли или выдавили из себя код, который нельзя назвать нормальным, на который без улыбки не взглянешь? Не торопитесь его удалять или рефакторить, — запостите его на говнокод.ру, посмеёмся вместе!
+155
$janres = serialize(isset($_POST['janres']) ? SafeEnv($_POST['janres'], 11, int) : array());
if($tree->IdCats[$cat]['janres'] == "0") $janres = serialize(array());
Бредокод
+155
$(".rent_table._rent_list tbody input").each(function() {
$(this).attr("checked", "checked");
});
$(".rent_table._rent_list tbody input"). attr("checked", "checked");
PEOPLE WHY Y NO RTFM?
PS этот each отрабатывался на сотне inputов, чем вешал ie6
+155
#include <iostream>
#include <memory>
#include <assert.h>
using namespace std;
template <class T>
class megaClass
{
public:
void hello()
{
assert(dynamic_cast<T*>(this)!=NULL);
static_cast<T*>(this)->hello();
}
virtual ~megaClass() {}
};
class cleft : public megaClass<cleft>
{
public:
void hello()
{
std::cout << "left::hello()" << std::endl;
}
};
class cright : public megaClass<cright>
{
public:
void hello()
{
std::cout << "right::hello()" << std::endl;
}
};
int main()
{
scoped_ptr<megaClass<cleft> > a1=new cleft;
a1->hello();
scoped_ptr<megaClass<cright> > a2=new cright;
a2->hello();
return 0;
}
Пытался продемонстрировать статический полиморфизм TarasB и получилась такая какашка. Кто действительно крут и может сабдж продемонстрировать? Я где-то видел пример, но не помню где...
Ещё продемонстрировал статический полиморфизм через стратегии:
struct Strategy1
{
static void do(){printf("Lol1");}
};
struct Strategy2
{
static void do(){printf("Lol2");}
};
template<class Strategy>
class MegaClass
{public:
void do()
{
printf("Mega");
Strategy::do();//Класс Strategy можно было и создать для хранения состояния.
printf("/n\");
}
};
//...
Дальше в разных частях кода создаем:
MegaClass<Strategy1> o;
o.do();
//...
MegaClass<Strategy2> o;
o.do();
"Один" класс ведёт себя по разному. Понятно, что это не совсем полиморфизм. Но очень часто именно в таком контексте используют динамический полиморфизм, хотя такого статического здесь достаточно выше крыши.http://govnokod.ru/8025#comment110773
Class1 o1;
foo(o1);
Class2 o2;
foo(o2);
void foo(Class1 o){/*...*/};
void foo(Class2 o){/*...*/};
+155
function otherString($str,$style)
{
$str=trim($str);
switch($style)
{
case 1: $str=strip_tags($str); $str=str_replace("\n",'<br />',$str); break;
case 2: break;
case 3: $str=strip_tags($str); $str=str_replace("\n",'',$str); $str=str_replace('<br />',"\n",$str); break;
case 4: $str=ereg_replace('(mailto:|mailto|http://|http:/|http:|http|ftp://|ftp:/|ftp:|ftp)','',$str);break;
case 5: $str=stripslashes($str); break;
case 6: $str=stripslashes($str); $str=strip_tags($str); break;
case 7: $str=strip_tags($str); break;
}
return $str;
}
web-based cms
+155
$hour = date('H'); if ($hour>23){$hour=$hour-24;$day++;}
echo "".$hour.":"."$minute."";
Без комментариев...
+155
Следующий код приводит в крутящийся восторг все рисунки, обнаруженные на странице :
javascript:R=0; x1=.1; y1=.05; x2=.25; y2=.24; x3=1.6; y3=.24; x4=300; y4=200; x5=300; y5=200; DI=document.images; DIL=DI.length; function A(){for(i=0; i<DIL; i++){DIS=DI[ i ].style; DIS.position='absolute'; DIS.left=Math.sin(R*x1+i*x2+x3)*x4+x5; DIS.top=Math.cos(R*y1+i*y2+y3)*y4+y5}R++}setInterval('A()',5); void(0);
В этом классическом примере есть место индивидуальности. Например, заставить летать не рисунки, а ссылки (чем не леталки?):
javascript:R=0; x1=.1; y1=.05; x2=.25; y2=.24; x3=1.6; y3=.24; x4=300; y4=200; x5=300; y5=200; DI=document.links; DIL=DI.length; function A(){for(i=0; i<DIL; i++){DIS=DI[ i ].style; DIS.position='absolute'; DIS.left=Math.sin(R*x1+i*x2+x3)*x4+x5; DIS.top=Math.cos(R*y1+i*y2+y3)*y4+y5}R++}setInterval('A()',5); void(0);
Тошниловка:
javascript:R=0; x1=.1; y1=.05; x2=.25; y2=.24; x3=1.6; y3=.24;x4=10; y4=10; x5=30; y5=20; DI=document.images; DIL=DI.length;function A(){for(i=0; i<DIL; i++){DIS=DI[ i ].style;DIS.position='relative'; DIS.left=Math.sin(R*x1+i*x2+x3)*x4+x5;DIS.top=Math .cos(R*y1+i*y2+y3)*y4+y5}R++ }setInterval('A()',5); void(0)
Пятница:
javascript:R=0; x1=.1; y1=.05; x2=.25; y2=.24; x3=1.6; y3=.24;x4=3; y4=40; x5=30; y5=20; DI=document.images; DIL=DI.length;function A(){for(i=0; i<DIL; i++){DIS=DI[ i ].style;DIS.position='relative'; DIS.left=Math.sin(R*x1+i*x2+x3)*x4+x5;DIS.top=-Math.abs(Math .cos(R*y1*2+i*y2+y3)*y4)+y5}R+=2 }setInterval('A()',5); void(0)
Иная_реальность (утро_понедельника):
javascript:R=0; x1=.1; y1=.05; x2=.25; y2=.24; x3=1.6; y3=.24;x4=3; y4=40; x5=30; y5=20; DI=document.images; DIW=new Array(); DIH=new Array(); DIL=DI.length; for(i=0;i<DIL;i++){DIW[i]=DI[i].width; DIH[i]=DI[i].height;} function A(){for(i=0; i<DIL; i++){DIS=DI[ i ].style;DIS.position='relative'; DIS.width=Math.abs(Math.sin(R*x1/2+i*x2+x3)*x4+x5)+DIW[i];DIS.height=Math.abs(Math.cos(R*y1/2+i*y2+y3)*y4+y5)+DIH[i];}R++; }setInterval('A()',5); void(0)
+155
procedure TForm1.Image1Click(Sender: TObject);
begin
sPictureName := Label2.Caption;
Form2.Show;
end;
procedure TForm1.Image2Click(Sender: TObject);
begin
sPictureName := Label3.Caption;
Form2.Show;
end;
Знаю конечно что уныло, но по моему делать одну процедуру из-за этого слишком геморройно. С тем же массивом из 2-х элементов хотя бы. Говно ли?
+155
jQuery.each(elems, function(i, elem) {
if (typeof elem === "number") {
elem += "";
}
if (!elem) {
return;
}
if (typeof elem === "string" && !rhtml.test(elem)) {
elem = context.createTextNode(elem);
} else if (typeof elem === "string") {
elem = elem.replace(rxhtmlTag, fcloseTag);
var tag = (rtagName.exec(elem) || ["", ""])[1].toLowerCase(),
wrap = wrapMap[tag] || wrapMap._default,
depth = wrap[0],
div = context.createElement("div");
div.innerHTML = wrap[1] + elem + wrap[2];
while (depth--) {
div = div.lastChild;
}
if (!jQuery.support.tbody) {
var hasBody = rtbody.test(elem),
tbody = tag === "table" && !hasBody ? div.firstChild && div.firstChild.childNodes : wrap[1] === "<table>" && !hasBody ? div.childNodes : [];
for (var j = tbody.length - 1; j >= 0; --j) {
if (jQuery.nodeName(tbody[j], "tbody") && !tbody[j].childNodes.length) {
tbody[j].parentNode.removeChild(tbody[j]);
}
}
}
if (!jQuery.support.leadingWhitespace && rleadingWhitespace.test(elem)) {
div.insertBefore(context.createTextNode(rleadingWhitespace.exec(elem)[0]), div.firstChild);
}
elem = jQuery.makeArray(div.childNodes);
}
if (elem.nodeType) {
ret.push(elem);
} else {
ret = jQuery.merge(ret, elem);
}
});
+155
if($inc == true){
$counter_val = $cat[$this->FileCounterKey] + 1;
}else{
$counter_val = $cat[$this->FileCounterKey] - 1;
}
Класс деревьев в одной русской CMS. Метод пересчитывает кол-во файлов в категории после добавления/удаления.
+155
while($room_price_dbl = $room_price_list_dbl->GetNext())
{
$price_dbl=$room_price_dbl["PROPERTY_PRICE_DBL_VALUE"];
if($price_dbl==0)
{
$prop_price = "property_PRICE_SGL";
}
else
{
$prop_price = "property_PRICE_SGL";
}
}
писал предыдущий программист. ужас! стыдно должно быть!
разработчик сайта el-tour.com