- 1
- 2
- 3
//fucking designers
if ( $page->importantshort ) $page->short = true;
if ( $page->importantNOTshort ) $page->short = false; // так то!
Нашли или выдавили из себя код, который нельзя назвать нормальным, на который без улыбки не взглянешь? Не торопитесь его удалять или рефакторить, — запостите его на говнокод.ру, посмеёмся вместе!
+163
//fucking designers
if ( $page->importantshort ) $page->short = true;
if ( $page->importantNOTshort ) $page->short = false; // так то!
+157
while(true)
{
if ($i==0)
{
$new_form_name = $form_res[0]['frm_name'] . ' ( Copy )';
} else
{
$new_form_name = $form_res[0]['frm_name'] . ' ( Copy '.$i.' )';
}
if(!in_array($new_form_name, $formaNames))
{
break;
}
$i++;
}
Есть имя формы $form_res[0]['frm_name'] , напр "FORMNAME".
нужно получить новое имя вида "FORMNAME ( Copy 1)"
+999
template<class TVisitedComponentList>
TUniqueIDOfVisitedComponentList getUniqueIDOfVisitedComponentTypeList(void)
{
static Type2Type<TVisitedComponentList> UniqueObjectForVisitedComponentTypeList;
return (size_t)(&UniqueObjectForVisitedComponentTypeList);
}
template<class TVisitedComponentList>
TCastWindowComponentTo* const castWindowComponentInternal(PegThing* const Window)
{
ASSERT(Window!=NULL);
if(Window==NULL)
return NULL;
STATIC_CHECK(!(boost::mpl::empty<TVisitedComponentList>::value), TVisitedComponentList_must_be_not_empty_and_be__boost_mpl_list_c__type);
const TUniqueIDOfVisitedComponentList UniqueIDOfVisitedComponentList=this->getUniqueIDOfVisitedComponentTypeList<TVisitedComponentList>();
const TCasterRepositorys::const_iterator NotFound=_casterRepositorys.end();
TCasterRepositorys::const_iterator findedCasterRepositoryForThisVisitedComponentList=_casterRepositorys.find(UniqueIDOfVisitedComponentList);
if(findedCasterRepositoryForThisVisitedComponentList==NotFound)
{
this->registerVisitedComponentList<TVisitedComponentList>();
findedCasterRepositoryForThisVisitedComponentList=_casterRepositorys.find(UniqueIDOfVisitedComponentList);
}
ASSERT(findedCasterRepositoryForThisVisitedComponentList!=NotFound);
const TCasterRepository::const_iterator NotFoundCaster=findedCasterRepositoryForThisVisitedComponentList->second->end();
const unsigned int ComponentType=const_cast<PegThing* const>(Window)->Type();
const TCasterRepository::const_iterator findedCaster=findedCasterRepositoryForThisVisitedComponentList->second->find(ComponentType);
if(findedCaster==NotFoundCaster)
return NULL;
ASSERT(findedCaster!=NotFoundCaster);
return (*(findedCaster->second))(Window);
}
template<class TCurrentItem, class TEnd>
void registerVisitedComponentListItem(TCasterRepository& casterRepository, TCurrentItem CurrentItem, TEnd End)
{
using namespace boost;
enum {WINDOW_COMPONENT_TYPE=mpl::deref<TCurrentItem>::type::value};
STATIC_CHECK((mpl::has_key<TWindowComponentsTypeIdToTypeMap, mpl::int_<WINDOW_COMPONENT_TYPE> >::value!=0), WINDOW_COMPONENT_TYPE_must_be_at_TWindowComponentsTypeIdToTypeMap);
typedef mpl::at<TWindowComponentsTypeIdToTypeMap, mpl::int_<WINDOW_COMPONENT_TYPE> >::type TRealTypeOfWindowComponent;
this->checkDuplicateComponentTypeID(WINDOW_COMPONENT_TYPE, casterRepository);
struct _
{
static TCastWindowComponentTo* const casterForEachWindowComponent(PegThing* const Window)
{
ASSERT(Window!=NULL);
if(Window==NULL)
return NULL;
TRealTypeOfWindowComponent* const RealTypeComponent = static_cast<TRealTypeOfWindowComponent* const>(Window);
ASSERT(RealTypeComponent!=NULL);
TCastWindowComponentTo* const FinalCastedWindowComponent = static_cast<TCastWindowComponentTo* const >(RealTypeComponent);
ASSERT(FinalCastedWindowComponent!=NULL);
return FinalCastedWindowComponent;
}
};
TCasterForEachWindowComponent CasterForEachWindowComponentFunction=&(_::casterForEachWindowComponent);
this->checkDuplicateType(CasterForEachWindowComponentFunction, casterRepository);
casterRepository[WINDOW_COMPONENT_TYPE]=CasterForEachWindowComponentFunction;
registerVisitedComponentListItem(casterRepository, mpl::next<TCurrentItem>::type(), TEnd());
}
template<class TEnd>
void registerVisitedComponentListItem(TCasterRepository& casterRepository, TEnd CurrentItem, TEnd End)
{}
Код из того же большого проекта.
Ассерты после static_cast и "шаблонная магия" особенно доставляют.
Мне конечно boost::mpl нравиться, но я считаю, что его негоже использовать в реальных проектах.
+151
$now = date(date('Y-m-d H:i:s'));
+162
if(
(trim($class->antihacker($_POST['fio']))=='')or
(trim($class->antihacker($_POST['phone']))=='')or
(trim($class->antihacker($_POST['email']))=='')or
(trim($class->antihacker($_POST['adress']))=='')
){$error="Указанные поля заполнены неверно!";}
elseif(!$class->validate_email($_POST['email'])){$error="E-mail указан не корректно!";}
elseif($_POST['is_company']=='1'){
if(
(trim($class->antihacker($_POST['company']))=='')or
(trim($class->antihacker($_POST['fio_cmp']))=='')or
(trim($class->antihacker($_POST['email_cmp']))=='')or
(trim($class->antihacker($_POST['kchet']))=='')or
(trim($class->antihacker($_POST['rchet']))=='')
){$error="Указанные поля заполнены неверно!";}
}
анти хакерз...
+73
public String XOR_Encrypt(String source, String key)
{
byte plain_text[] = new byte[source.length()];
plain_text = source.getBytes();
byte key_mas[] = new byte[key.length()];
key_mas = key.getBytes();
int key_len = key.length();
int crypt_pos = 0;
for(int i = 0; i < source.length(); i++)
{
plain_text[i] = (byte)(plain_text[i] ^ 0xaa);
plain_text[i] = (byte)(plain_text[i] ^ key_mas[crypt_pos]);
if(crypt_pos >= key_len - 1)
crypt_pos = 0;
else
crypt_pos++;
}
String EText = ByteToHexString(plain_text);
return EText;
}
public static String EncodeSimmetr(String s)
{
int MultKey = 62142;
int AddKey = 11719;
byte f1[] = new byte[s.length()];
byte f[] = new byte[s.length()];
f = s.getBytes();
for(int i = 0; i < s.length(); i++)
{
f1[i] = (byte)(f[i] ^ MultKey);
MultKey ^= AddKey;
}
s = new String(f1);
return s;
}
Система шифрования в той-же платёжке...
+71
String url = "http://*.*.*.*:*/java/?code=" + sCode + "&request=monitor";
String LogPass = sName + ":" + sPass;
String sAuth = "Basic " + encodeBase64(LogPass);
try
{
con = (HttpConnection)Connector.open(url);
con.setRequestMethod("GET");
con.setRequestProperty("User-Agent", "Profile/MIDP-2.0 Confirguration/CLDC-1.0");
con.setRequestProperty("Accept_Language", "en-US");
con.setRequestProperty("Content-Type", "//text plain");
con.setRequestProperty("Connection", "close");
con.setRequestProperty("Authorization", sAuth);
in = con.openInputStream();
if(con.getResponseCode() == 200)
{
StringBuffer sb = new StringBuffer();
int chr;
while((chr = in.read()) != -1)
sb.append((char)(chr < 192 || chr > 255 ? chr : chr + 848));
sBuff = sb.toString();
}
}
Авторизация в одной из платёжных систем
+119
string str;
if (((str = path) != null) && (str != "basic"))
{
if (str == "contact")
{
BindContact();
PageTitle = "Contact info";
editform.SetActiveView(vi_contact);
return;
}
if (str == "personal")
{
PageTitle = "More about me";
BindPersonal();
editform.SetActiveView(vi_personal);
return;
}
if (str == "career")
{
PageTitle = "Work info";
BindCareer();
editform.SetActiveView(vi_career);
return;
}
if (str == "tags")
{
BindTags();
PageTitle = "Tags I Follow";
editform.SetActiveView(vi_tags);
return;
}
if (str == "biography")
{
ph_page_title.Visible = false;
bind_biography();
editform.SetActiveView(vi_biography);
return;
}
if (str == "pp")
{
ph_picpage_title.Visible = true;
ph_page_title.Visible = false;
PageTitle = "Edit profile photo";
BindProfilePhoto();
return;
}
}
PageTitle = "Basic info";
BindBasic();
editform.SetActiveView(vi_basic);
switch на диалекте хинди ;[ слава asp.net! убить Мартинса и Фаулера за чистокодную ересь!
+152
///////////////////////////////КОДИТ FIELD////////////////////////////////
if($opt == 'bags') {
echo "<h3>Ошибки в фильмах</h3>
<a href='/admin/index.php?view=components&do=config&id=24&opt=bags&old=0'>Активные ошибки</a>
<a href='/admin/index.php?view=components&do=config&id=24&opt=bags&old=1'>Исправленные ошибки</a>
<table border=1><tr><td>Дата</td><td>Название фильма</td><td>Добавил ошибку</td><td>Тип ошибки</td><td>Описание</td><td>Статус</td><td>Исправил</td></tr>";
$old = $_REQUEST['old'];
if ($old==1) {$result=$inDB->query("SELECT * from cms_multimedia_bags WHERE `fixed`='1' ORDER by date DESC");}
else {$result=$inDB->query("SELECT * from cms_multimedia_bags WHERE `fixed`<>'1' ORDER by date DESC");}
while($row=$inDB->fetch_assoc($result)) {
if ($row['admin']=='') {$row['admin']="Неисправлена";}
if ($row['fixed']==1) {$fix="<center><a href='/admin/index.php?view=components&do=config&id=24&opt=fix_bag&fixed=0&bag_id=$row[id]' title='Исправлена'><img src=/admin/images/actions/button_check.png></a>";$table_color="";$fix_date="($row[fix_date])";}
if ($row['fixed']<>1) {$fix="<center><a href='/admin/index.php?view=components&do=config&id=24&opt=fix_bag&fixed=1&bag_id=$row[id]' title='Не исправлена'><img src=/admin/images/actions/stop.png></a>";$table_color="<font color=red>";$fix_date="";}
if ($row['multimedia_group']==2) {$tip='add_films';}
if ($row['multimedia_group']==3) {$tip='add_serials';}
if ($row['type']==1) {$row['type']='Не скачивается';}
if ($row['type']==2) {$row['type']='Не просматривается';}
if ($row['type']==3) {$row['type']='Ошибка в описании фильма';}
if ($row['type']==4) {$row['type']='Неверный постер';}
if ($inUser->id==275) {$del="(<a href='/admin/index.php?view=components&do=config&id=24&opt=del_bag&bag_id=$row[id]'>x</a>)";}
$result1=$inDB->query("SELECT * from cms_multimedia_names WHERE `id`='$row[film_id]'");
$film_row=$inDB->fetch_assoc($result1);
$result2=$inDB->query("SELECT * from cms_users WHERE `id`='$row[user_id]'");
$user_row=$inDB->fetch_assoc($result2);
echo "<tr><td>$table_color$row[date]</td><td><a href='/admin/index.php?view=components&do=config&id=24&opt=$tip&cat_group=$row[multimedia_group]&file_id=$row[file_id]'>" . $film_row['video_name_rus'] . "</a>(<a href='/multimedia/$row[multimedia_group]/$row[film_id]/$row[file_id]' target='_blank'>на сайте</a>)</td><td><a href='/users/$user_row[nickname]'>$user_row[nickname]</a>($row[ip])</td><td>$table_color" . $row['type'] . "</td><td>$table_color" . $row['description'] . "</td><td>$fix $del<td>$row[admin] $fix_date</td></tr>";
}
echo "</table>";
}
if($opt == 'fix_bag') {
$bag_id = $_REQUEST['bag_id'];
$fixed = $_REQUEST['fixed'];
$date=date("Y-m-d H:i:s");
if ($fixed==1) {$inDB->query("UPDATE cms_multimedia_bags SET `fixed`='$fixed', `fix_date`='$date', `admin`='$inUser->nickname' WHERE id=$bag_id");}
else {$inDB->query("UPDATE cms_multimedia_bags SET `fixed`='$fixed', `fix_date`='$date', `admin`='' WHERE id=$bag_id");}
$inCore->redirect('/admin/index.php?view=components&do=config&id='.$_REQUEST['id'].'&opt=bags');
}
if($opt == 'del_bag') {
$bag_id = $_REQUEST['bag_id'];
$inDB->query("DELETE from cms_multimedia_bags WHERE id=$bag_id");
$inCore->redirect('/admin/index.php?view=components&do=config&id='.$_REQUEST['id'].'&opt=bags');
}
///////////////////////////////КОНЕЦ КОДА FIELD/////////////////////////
=) Наш заказчик нанял, нового специалиста php, который якобы "помогает" нам дорабатывать проект=
+152
switch (count($params)) {
case 0:
return $this->{$method}();
case 1:
return $this->{$method}($params[0]);
case 2:
return $this->{$method}($params[0], $params[1]);
case 3:
return $this->{$method}($params[0], $params[1], $params[2]);
case 4:
return $this->{$method}($params[0], $params[1], $params[2], $params[3]);
case 5:
return $this->{$method}($params[0], $params[1], $params[2], $params[3], $params[4]);
default:
return call_user_func_array(array(&$this, $method), $params);
break;
}
cakephp framework v 1.3