- 1
- 2
- 3
- 4
- 5
- 6
- 7
$upload_dir = ABSPATH;
$upload_dir .= str_replace(ABSPATH, '', trim( get_option( 'upload_path' ) ) );
if ( empty( $upload_dir ) )
$upload_dir = WP_CONTENT_DIR . '/uploads';
//.....
Нашли или выдавили из себя код, который нельзя назвать нормальным, на который без улыбки не взглянешь? Не торопитесь его удалять или рефакторить, — запостите его на говнокод.ру, посмеёмся вместе!
+144.5
$upload_dir = ABSPATH;
$upload_dir .= str_replace(ABSPATH, '', trim( get_option( 'upload_path' ) ) );
if ( empty( $upload_dir ) )
$upload_dir = WP_CONTENT_DIR . '/uploads';
//.....
плагин WP Post Thumbnail v 0.1.8
+151
#include "stdafx.h"
class CTest
{
private:
virtual void Print()
{
_tprintf( _T("He he ;)\n"));
}
};
class CX
{
public:
virtual void BlaBla();
};
int _tmain(int argc, _TCHAR* argv[])
{
CTest t;
//error C2248: 'CTest::Print' : cannot access private member declared in class 'test'
//t.Print();
//It works
((void (*)(void))((int*)(*(int*)&t))[0])();
//It works, too
((CX*)&t)->BlaBla();
return 0;
}
−114
ggaa
awqe
asd
adfa
asdasdasdas
+151.1
$this->oPostTest->recipients = trim($this->oPostTest->recipients);
$this->oPostTest->recipients = trim($this->oPostTest->recipients, ';');
$this->oPostTest->recipients = str_replace(' ', ';', $this->oPostTest->recipients);
$this->oPostTest->recipients = str_replace(';;', ';', $this->oPostTest->recipients);
такая вот загагулина )
+81.3
private final String zeroValueString="0";
private final String sevenValueString="7";
Если б можно, то ещё б и hundredElevenValueString = "111"; впиндюрили бы
+155
void SimpleTest::testTrivial() {
wxTst::TempInteractive interactive;
wxTst::ModalDialogTimer timer(wxID_OK);
// *** Loop up top level containers ***
CPPUNIT_ASSERT_MESSAGE ("Application top window invalid",
wxTheApp->GetTopWindow () != NULL);
wxMDIParentFrame *topFrame =
dynamic_cast< wxMDIParentFrame * >(wxTheApp->GetTopWindow ());
CPPUNIT_ASSERT_MESSAGE ("Top window is not an MDI Parent frame",
topFrame != NULL);
wxMenuBar *menuBar = topFrame->GetMenuBar ();
CPPUNIT_ASSERT_MESSAGE ("Menubar not found", menuBar != NULL);
// interactive.ShowCurrentGui (_T(__FILE__), __LINE__);
// *** Check menu item ***
int platformMenuItemId = menuBar->FindMenuItem (_("Advanced"),
MC _T("Platform Specific Example"));
CPPUNIT_ASSERT_MESSAGE ("Menu item ID 'platformMenuItem' not found",
platformMenuItemId != wxNOT_FOUND);
wxMenuItem *platformMenuItem = menuBar->FindItem (
platformMenuItemId);
CPPUNIT_ASSERT_MESSAGE ("Menu item 'platformMenuItem' not found",
platformMenuItem != NULL);
wxTst::EventSimulationHelper::SelectMenuItem (
platformMenuItemId, topFrame);
wxTst::WxGuiTestHelper::FlushEventQueue ();
wxWindow* wdw = topFrame->FindWindow(_T("platform_child"));
if (wdw == NULL)
wdw = wxWindow::FindWindowByName(_T("platform_child"));
CPPUNIT_ASSERT_MESSAGE("First Child not found", wdw != NULL);
wxMDIChildFrame* child1 = dynamic_cast<wxMDIChildFrame*>(wdw);
CPPUNIT_ASSERT_MESSAGE("Window isn't an MDI Child", child1 != NULL);
wxTst::WxGuiTestHelper::FlushEventQueue ();
interactive.ShowCurrentGui (_T(__FILE__), __LINE__);
wxTst::EventSimulationHelper::SelectMenuItem (
platformMenuItemId, topFrame);
wxTst::WxGuiTestHelper::FlushEventQueue ();
// interactive.ShowCurrentGui (_T(__FILE__), __LINE__);
wxMDIChildFrame* child2 = topFrame->GetActiveChild();
CPPUNIT_ASSERT_MESSAGE("Second child not found", child2 != NULL);
CPPUNIT_ASSERT_MESSAGE("Second child same as first ", child2 != child1);
child2->Close();
int derived_toolMenuItemId = menuBar->FindMenuItem (_("Advanced"),
MC _T("Custom Class Example"));
CPPUNIT_ASSERT_MESSAGE ("Menu item ID 'derived_toolMenuItem' not found",
derived_toolMenuItemId != wxNOT_FOUND);
wxMenuItem *derived_toolMenuItem = menuBar->FindItem (
derived_toolMenuItemId);
CPPUNIT_ASSERT_MESSAGE ("Menu item 'derived_toolMenuItem' not found",
derived_toolMenuItem != NULL);
wxTst::EventSimulationHelper::SelectMenuItem (
derived_toolMenuItemId, topFrame);
wxTst::WxGuiTestHelper::FlushEventQueue ();
wxWindow *custom_child =
wxWindow::FindWindowByName (_T("custom_class_child"));
CPPUNIT_ASSERT_MESSAGE ("Container window for button 'wxID_OK' not found",
custom_child != NULL);
// interactive.ShowCurrentGui (_T(__FILE__), __LINE__);
wxWindow *wxID_OKWdw4 = custom_child->FindWindow (XRCID("wxID_OK"));
CPPUNIT_ASSERT_MESSAGE ("Window for button 'wxID_OK' not found",
wxID_OKWdw4 != NULL);
wxTst::EventSimulationHelper::ClickButton (wxID_OKWdw4->GetId (),
wxID_OKWdw4);
wxTst::WxGuiTestHelper::FlushEventQueue ();
CPPUNIT_ASSERT_MESSAGE("OK Button didn't hide Mac Specific Dialog",
custom_child->IsShown() == false);
}
Источник: метод примера из wxGuiTesting
+133.4
// parse from the uninstall, the actuall installation path
try {
int jarLoc = uninstallDir.indexOf("-jar");
String s = uninstallDir.substring(jarLoc + 5);
// turn it into a normalized file
int uniLoc = s.indexOf("uninstaller");
s = s.substring(1,uniLoc);
s = s.replace("\\", "/");
if(s.endsWith("/"))
s = s.substring(0,s.length()-1);
File f = new File(s);
if(!f.exists()) {
throw new Exception("installation directory does not exist: " + s);
}
return f;
}
catch(Exception e) {
throw new Exception("installation directory could not be parsed from: " + uninstallDir);
}
Typical code of one highly paid "tech expert" from USA
Exception handling makes me cry, this guy doesn't even now about any other exception classes
+34.7
} else {
$json_array = array('error' => $this->log_error('busy', true));
}
} else {
$json_array = array('error' => $this->log_error('busy', true));
}
} else {
$json_array = array('error' => $this->log_error('busy', true));
}
} else {
$json_array = array('error' => $this->log_error('busy', true));
}
} else {
$json_array = array('error' => $this->log_error('bad_symbols', false));
}
} else {
$json_array = array('error' => $this->log_error('check_error', false));
// 'errorStr' => $this->validation->error_string
}
Кусок метода в контроллере регистрации пользователя на одном из наших проектов. Вверху хренова гора ифов а внизу во такое вот счастье. "Авторская" табуляция сохранена
+28
$query = "update users set password = '{$cnf['userpass']}', email = '{$cnf['useremail']}' where login = 'root'";
if (mysql_query($query, $link) === false) {
throw new Exception(mysql_error($link));
}
mysql_close($link);
удалить)
+28.5
function DelFilterEx($arName, $varName, $session=true, $FilterLogic="FILTER_logic")
{
global $strError, $$FilterLogic;
if ($session) unset($_SESSION["SESS_ADMIN"][$varName]);
for($i=0; $i<count($arName); $i++)
{
$name = $arName[$i];
$bdays = $name."_DAYS_TO_BACK";
global $$name, $$bdays;
$$name = "";
$$bdays = "";
}
$$FilterLogic = "and";
}
Голова недодумала и пришла к переменным переменным