- 1
- 2
foreach (cms::hooks('template_output') as $hook_file)
require($hook_file);
Нашли или выдавили из себя код, который нельзя назвать нормальным, на который без улыбки не взглянешь? Не торопитесь его удалять или рефакторить, — запостите его на говнокод.ру, посмеёмся вместе!
+149
foreach (cms::hooks('template_output') as $hook_file)
require($hook_file);
хуки содержатся в отдельных файлах и вставляются в код напрямую.
+154
/* Формируемый запрос через Ajax */
function MakeSearchQuery() {
searchQuery = "";
if (SearchDataQuery.CityFrom != "") {
searchQuery = "CityFrom=" + SearchDataQuery.CityFrom;
if (SearchDataQuery.Country != "") {
searchQuery += "&Country=" + SearchDataQuery.Country;
if (SearchDataQuery.Station != "" && SearchDataQuery.Station != "&Station=") {
searchQuery += "&Station=" + SearchDataQuery.Station;
}
if (SearchDataQuery.Date != "" && SearchDataQuery.Date != "&Date=") {
searchQuery += "&Date=" + SearchDataQuery.Date;
}
}
}
}
Формируемый Ajax запрос
+151
$.getJSON(tourListUrlDel, searchQuery, function (resp) {
var _resp = resp;
var currentTab = "";
var count = 0;
if (resp == "" || resp == null) {
alert("Ничего не найдено!");
return;
}
else {
$('#searchTable').empty();
MakeTabs("#tabs-1, #tabs-2, #tabs-3, #tabs-4, #tabs-5");
$('#tabs-' + currentTab)//#searchTable
.append('<tr id=tab' + count + '>')
$.each(_resp, function (key, value) {
if (value == "" || value == null) {
return null;
}
count++;
if (count < 50) {
currentTab = 1;
$("#liTab1").show();
}
else if (count > 50 && count < 100) {
currentTab = 2;
$("#liTab2").show();
}
else if (count > 100 && count < 150) {
currentTab = 3;
$("#liTab3").show();
}
else if (count > 150 && count < 200) {
currentTab = 4;
$("#liTab4").show();
}
else {
currentTab = 5;
$("#liTab5").show();
}
$('#tabs-' + currentTab)
.append('<tr id=tab' + count + '>')
$.each(value, function (k, v) {
$('#tab' + count).append('<td>' + v + '</td>');
});
$('#tabs-' + currentTab)
.append('</tr>');
});
table.show('slow');
}
})
.success(function () {
$('#progressbar').hide();
})
.error(function(XMLHttpRequest){
if(XMLHttpRequest.statusText != "abort"){
alert("При попытке отправить сообщение произошла неизвестная ошибка. \n Попробуй еще раз через несколько минут.");
}
})
.fail(function () {
table.hide('slow');
})
};
Заполнение таблицы результатами поиска
+13
TAbstractMessageFrame * SwitchIfNeedReceivePackets = create_switch(
fnc_ext::bind(this,
fnc_ext::compose2(std::greater<WORD>(),
fnc_ext::get_mem(&TThisClass::_totalDataLength),
fnc_ext::compose1(std::bind1st(std::minus<WORD>(), static_cast<WORD>(TByteBuffer::MaxCapacity)),
fnc_ext::compose1(fnc_ext::get_mem_func_ref(&TThisClass::TByteBuffer::length),
fnc_ext::get_mem(&TThisClass::_receivedBuffer))))),
// fnc_ext::get_mem_func(&TThisClass::FreeBufferSpace))),
DataByPackets, DataByLength, "Switch If Need Receive Packets" );
+154
log_info('= Выгрузка метаданных =');
$cnt = $x->metaCurrencies('/gooddata/'.$folder.'/'.$subfolder.'/x/currencies');
$cnt = $x->metaRegions('/gooddata/'.$folder.'/'.$subfolder.'/x/regions');
$cnt = $x->metaCountries('/gooddata/'.$folder.'/'.$subfolder.'/x/countries');
$cnt = $x->metaSources('/gooddata/'.$folder.'/'.$subfolder.'/x/sources');
$cnt = $x->metaGroups('/gooddata/'.$folder.'/'.$subfolder.'/x/groups');
$cnt = $x->metaProviders('/gooddata/'.$folder.'/'.$subfolder.'/x/providers');
$cnt = $x->metaPS('/gooddata/'.$folder.'/'.$subfolder.'/x/paymentsystems');
$cnt = $x->metaProjects('/gooddata/'.$folder.'/'.$subfolder.'/x/projects');
$cnt = $x->metaPayments('/gooddata/'.$folder.'/'.$subfolder.'/x/payments');
$cnt = $x->metaGeotypes('/gooddata/'.$folder.'/'.$subfolder.'/x/geotypes');
$cnt = $x->metaPartners('/gooddata/'.$folder.'/'.$subfolder.'/x/partners');
$cnt = $x->metaEmployees('/gooddata/'.$folder.'/'.$subfolder.'/x/employees');
$cnt = $x->metaForecast('/gooddata/'.$folder.'/'.$subfolder.'/x/forecast');
$cnt = $x->metaClusters('/gooddata/'.$folder.'/'.$subfolder.'/x/clusters');
$cnt = $x->metaPSContr('/gooddata/'.$folder.'/'.$subfolder.'/x/pspartners');
$cnt = $x->metaClustersMatrix('/gooddata/'.$folder.'/'.$subfolder.'/x/clustersmatrix');
$cnt = $x->metaAccounts('/gooddata/'.$folder.'/'.$subfolder.'/x/accounts');
$cnt = $x->metaBalanceType('/gooddata/'.$folder.'/'.$subfolder.'/x/balancetypes');
$cnt = $x->metaBalanceGame('/gooddata/'.$folder.'/'.$subfolder.'/x/balancegame');
$cnt = $x->metaBalancePS('/gooddata/'.$folder.'/'.$subfolder.'/x/balanceps');
$cnt = $x->metaBalancePSContr('/gooddata/'.$folder.'/'.$subfolder.'/x/balancepscontr');
$cnt = $x->metaBalanceBank('/gooddata/'.$folder.'/'.$subfolder.'/x/balancebank');
$cnt = $x->metaBalanceLost('/gooddata/'.$folder.'/'.$subfolder.'/x/balancelost');
$cnt = $x->metaStatuses('/gooddata/'.$folder.'/'.$subfolder.'/x/statuses');
$cnt = $x->metaTypes('/gooddata/'.$folder.'/'.$subfolder.'/x/types');
$cnt = $x->metaSupervisors('/gooddata/'.$folder.'/'.$subfolder.'/x/supervisors');
$cnt = $x->metaGames('/gooddata/'.$folder.'/'.$subfolder.'/x/games');
$cnt = $x->metaProjectStatus('/gooddata/'.$folder.'/'.$subfolder.'/x/projectstatuses');
log_info('= Создание временных папок на Webdav =');
$path = $folder;
$res = simple_request(GOODDATA_WEBDAV.'/'.$path,'MKCOL',array());
$path.= '/'.$subfolder;
$res = simple_request(GOODDATA_WEBDAV.'/'.$path,'MKCOL',array());
$path.= '/x';
$res = simple_request(GOODDATA_WEBDAV.'/'.$path,'MKCOL',array());
log_info('= Создание папок сетов =');
$res = simple_request(GOODDATA_WEBDAV.'/'.$path.'/currencies','MKCOL',array());
$res = simple_request(GOODDATA_WEBDAV.'/'.$path.'/regions','MKCOL',array());
$res = simple_request(GOODDATA_WEBDAV.'/'.$path.'/countries','MKCOL',array());
$res = simple_request(GOODDATA_WEBDAV.'/'.$path.'/sources','MKCOL',array());
$res = simple_request(GOODDATA_WEBDAV.'/'.$path.'/groups','MKCOL',array());
$res = simple_request(GOODDATA_WEBDAV.'/'.$path.'/providers','MKCOL',array());
$res = simple_request(GOODDATA_WEBDAV.'/'.$path.'/paymentsystems','MKCOL',array());
$res = simple_request(GOODDATA_WEBDAV.'/'.$path.'/projects','MKCOL',array());
$res = simple_request(GOODDATA_WEBDAV.'/'.$path.'/payments','MKCOL',array());
$res = simple_request(GOODDATA_WEBDAV.'/'.$path.'/geotypes','MKCOL',array());
$res = simple_request(GOODDATA_WEBDAV.'/'.$path.'/partners','MKCOL',array());
$res = simple_request(GOODDATA_WEBDAV.'/'.$path.'/employees','MKCOL',array());
$res = simple_request(GOODDATA_WEBDAV.'/'.$path.'/forecast','MKCOL',array());
$res = simple_request(GOODDATA_WEBDAV.'/'.$path.'/clusters','MKCOL',array());
$res = simple_request(GOODDATA_WEBDAV.'/'.$path.'/pspartners','MKCOL',array());
$res = simple_request(GOODDATA_WEBDAV.'/'.$path.'/clustersmatrix','MKCOL',array());
$res = simple_request(GOODDATA_WEBDAV.'/'.$path.'/accounts','MKCOL',array());
$res = simple_request(GOODDATA_WEBDAV.'/'.$path.'/balancetypes','MKCOL',array());
$res = simple_request(GOODDATA_WEBDAV.'/'.$path.'/balancegame','MKCOL',array());
$res = simple_request(GOODDATA_WEBDAV.'/'.$path.'/balanceps','MKCOL',array());
$res = simple_request(GOODDATA_WEBDAV.'/'.$path.'/balancepscontr','MKCOL',array());
$res = simple_request(GOODDATA_WEBDAV.'/'.$path.'/balancebank','MKCOL',array());
$res = simple_request(GOODDATA_WEBDAV.'/'.$path.'/balancelost','MKCOL',array());
$res = simple_request(GOODDATA_WEBDAV.'/'.$path.'/types','MKCOL',array());
$res = simple_request(GOODDATA_WEBDAV.'/'.$path.'/statuses','MKCOL',array());
$res = simple_request(GOODDATA_WEBDAV.'/'.$path.'/supervisors','MKCOL',array());
$res = simple_request(GOODDATA_WEBDAV.'/'.$path.'/games','MKCOL',array());
$res = simple_request(GOODDATA_WEBDAV.'/'.$path.'/projectstatuses','MKCOL',array());
log_info('= Выгрузка данных =');
$cnt = $x->exportCurrencies('dataset.currencies','/gooddata/'.$folder.'/'.$subfolder.'/x/currencies');
log_info(' - currencies');
$cnt = $x->exportRegions('dataset.regions','/gooddata/'.$folder.'/'.$subfolder.'/x/regions');
log_info(' - regions');
$cnt = $x->exportCountries('dataset.countries','/gooddata/'.$folder.'/'.$subfolder.'/x/countries');
log_info(' - countries');
$cnt = $x->exportSources('dataset.sources','/gooddata/'.$folder.'/'.$subfolder.'/x/sources');
log_info(' - sources');
//и дальше в таком же духе 600 строк
Цыклы, массивы? Не, не слышал
+131
<td>
<select class="form-control" ng-model="contact.type">
<option value="meat">Работоспособный</option>
<option value="children">Ребенок</option>
<option value="cripple">Пенсионер</option>
<option value="cripple">Инвалид</option>
</select>
</td>
дети цветы жизни. остальные - мясо и калеки
+13
void User::AddFriend(User& newFriend)
{
friends_.push_back(&newFriend);
pDB_->AddFriend(GetName(), newFriend.GetName());
}
//...VS...
void User::AddFriend(User& newFriend)
{
friends_.push_back(&newFriend);
try
{
pDB_->AddFriend(GetName(), newFriend.GetName());
}
catch (...)
{
friends_.pop_back();
throw;
}
}
//...VS...
class VectorInserter//Глобальный безопасный вектороВставлятель.
{
public:
VectorInserter(std::vector<User*>& v, User& u)
: container_(v), commit_(false)
{
container_.push_back(&u);
}
void Commit() throw()
{
commit_ = true;
}
~VectorInserter()
{
if (!commit_) container_.pop_back();
}
private:
std::vector<User*>& container_;
bool commit_;
};
void User::AddFriend(User& newFriend)
{
VectorInserter ins(friends_, &newFriend);
pDB_->AddFriend(GetName(), newFriend.GetName());
// Everything went fine, commit the vector insertion
ins.Commit();
}
+8
template<int ID> struct typeof_access
{
struct id2type; //not defined
};
template<class T, int ID> struct typeof_register : typeof_access
{
// define base's nested class here
struct typeof_access::id2type
{
typedef T type;
};
};
//Type registration function
typeof_register<T, compile-time-constant> register_type(const T&);
//Actually register type by instantiating typeof_register for the correct type
sizeof(register_type(some-type));
//Use the base class to access the type.
typedef typeof_access::id2type::type type;
Igor Chesnokov discovered a method that allows to implement typeof on the VC series of compilers. It uses a bug in the Microsoft compiler that allows a nested class of base to be defined in a class derived from base.
http://www.boost.org/doc/libs/1_54_0/doc/html/typeof/other.html
+148
$try = $db->getRow(
"SELECT * FROM user_{$name}, item_{$name} ".
"WHERE user_{$name}.usr_id=? AND user_{$name}.{$type}_id=? AND user_{$name}.{$type}_id=item_{$name}.{$type}_id",
array($user->usr_id, $id)
);
последствия неправильно спроектированной БД
+139
if ((ObjectType)value == ObjectType.Undefined)
{
return string.Empty;
}
{
return ((ObjectType)value).GetDescriptionAttribute();
}
Как будто не хватает чего-то..