- 1
- 2
- 3
- 4
- 5
<?if($_POST[btn]=="Отправить") $btn="12";?>
<form method="post" action="actn.php">
<button value="12" name="btn" type="submit">Отправить</button>
</form>
<? echo $btn; ?>
Нашли или выдавили из себя код, который нельзя назвать нормальным, на который без улыбки не взглянешь? Не торопитесь его удалять или рефакторить, — запостите его на говнокод.ру, посмеёмся вместе!
+163
<?if($_POST[btn]=="Отправить") $btn="12";?>
<form method="post" action="actn.php">
<button value="12" name="btn" type="submit">Отправить</button>
</form>
<? echo $btn; ?>
+146
// ==UserScript==
// @name dojki-remover
// @namespace A
// @include http://www.dojki.com/*
// @include http://dojki.com/*
// ==/UserScript==
var intervalID = window.setInterval(work, 500);
var max_exicutionz = 9;
function work()
{
d_nested1 = document.getElementsByTagName("iframe")[0];
if (typeof(d_nested1) != "undefined") d_nested1.style.display='none';
d_nested2 = document.getElementsByTagName("iframe")[1];
if (typeof(d_nested2) != "undefined") d_nested2.style.display='none';
d_nested3 = document.getElementsByTagName("iframe")[2];
if (typeof(d_nested3) != "undefined") d_nested3.style.display='none';
if (max_exicutionz <= 0) clearInterval(intervalID);
max_exicutionz--;
}
GreaseMonkey скрипт для скрытия тизеров на порносайте. Дело в том что верхний IFRAME появляется на сайте сразу, но Обезьяна не вызывает выполнение скрипта и приходится ждать непонятно чего. Может кто понимает в чем дело?
+162
if(!$RISK && in_array($USER->GetID(), array("1", "14"))){
$RECCURING = true;
}else{
$RECCURING = false;
}
Подписка на оплату. Магические числа 1 и 14.
+168
function filetypecheck( $filename )
{
$ext = substr(GetFileExt($filename), 1);
if($ext == 'rar'){ $dtype = 'Архив RAR'; }
if($ext == 'zip'){ $dtype = 'Архив ZIP'; }
if($ext == '7z') { $dtype = 'Архив 7zip'; }
if($ext == 'bz2'){ $dtype = 'BZ2'; }
if($ext == 'cab'){ $dtype = 'CAB'; }
if($ext == 'ace'){ $dtype = 'WinACE'; }
if($ext == 'arj'){ $dtype = '<a class=\"cont\" href=\"http://www.tsf.be/\" target=\"_blank\">ARJ</a>'; }
if($ext == 'jar'){ $dtype = '<a class=\"cont\" href=\"http://www.tsf.be/\" target=\"_blank\">JAR</a>'; }
if($ext == 'gzip'){ $dtype = 'GZIP'; }
if($ext == 'tar'){ $dtype = 'TAR'; }
if($ext == 'tgz'){ $dtype = 'TGZ'; }
if($ext == 'gz'){ $dtype = 'GZ'; }
if($ext == 'gif'){ $dtype = 'GIF'; }
if(preg_match('/jpeg|jpe|jpg/i', $ext)){ $dtype = 'JPEG/JPE/JPG'; }
if($ext == 'png'){ $dtype = 'PNG'; }
if($ext == 'bmp'){ $dtype = 'BMP'; }
if($ext == 'txt'){ $dtype = 'TXT'; }
if($ext == 'sql'){ $dtype = 'SQL'; }
if($ext == 'exe'){ $dtype = 'EXE'; }
if($ext == 'swf'){ $dtype = 'SWF'; }
if($ext == 'fla'){ $dtype = 'FLA'; }
if(preg_match('/flv|f4v|f4p|f4a|f4b/i', $ext)){ $dtype = 'Flash Video (FLV)'; }
if($ext == 'wav'){ $dtype = 'WAV'; }
if($ext == 'mp2'){ $dtype = 'MP2'; }
if($ext == 'mp3'){ $dtype = 'MP3'; }
if($ext == 'mp4'){ $dtype = 'MP4'; }
if(preg_match('/ogv|oga|ogx|ogg/i', $ext)){ $dtype = 'Ogg'; }
if($ext == 'mid'){ $dtype = 'MID'; }
if($ext == 'midi'){ $dtype = 'MIDI'; }
if($ext == 'mmf'){ $dtype = 'MMF'; }
if($ext == 'mpeg'){ $dtype = 'MPEG'; }
if($ext == 'mpe'){ $dtype = 'MPE'; }
if($ext == 'mpg'){ $dtype = 'MPG'; }
if($ext == 'mpa'){ $dtype = 'MPA'; }
if($ext == 'avi'){ $dtype = 'AVI'; }
if($ext == 'mpga'){ $dtype = 'MPGA'; }
if(preg_match('/pdf|pds/i', $ext)){ $dtype = 'Документ Adobe PDF'; }
if(preg_match('/xls|xl|xla|xlb|xlc|xld|xlk|xll|xlm|xlt|xlv|xlw/i', $ext)){ $dtype = 'Документ MS-Excel'; }
if(preg_match('/doc|dot|wiz|wzs|docx/i', $ext)){ $dtype = 'Документ MS-Word'; }
if($ext == 'odt'){ $dtype = 'Текстовый документ OpenDocument'; }
if($ext == 'odg'){ $dtype = 'Графический документ OpenDocument'; }
if($ext == 'odp'){ $dtype = 'Документ презентации OpenDocument'; }
if($ext == 'ods'){ $dtype = 'Электронная таблица OpenDocument'; }
if($ext == 'odc'){ $dtype = 'Документ диаграммы OpenDocument'; }
if($ext == 'odi'){ $dtype = 'Документ изображения OpenDocument'; }
if($ext == 'odf'){ $dtype = 'Документ формулы OpenDocument'; }
if($ext == 'odm'){ $dtype = 'Составной текстовый документ OpenDocument'; }
if(preg_match('/pot|ppa|pps|ppt|pwz/i', $ext)){ $dtype = 'Документ MS-Powerpoint'; }
if($ext == 'rtf'){ $dtype = 'RTF'; }
if(empty($dtype)) $dtype = '';
return $dtype;
}
Цикл "Из одной русской CMS". База описаний к расширениям файлов.
+158
class Relay {
protected $_data = array();
protected $_devices;
static protected $_db_fields = array();
function getId() {
return $this->_data['id'];
}
static function load($id) {
if ($id) {
$select = db_select('relay', 'r');
$select->fields('r');
$select->condition('r.id', $id);
$relay = $select->execute()->fetchObject(__CLASS__);
return $relay;
}
}
function save() {
foreach (array_diff(array_keys($this->_data), self::_getPureDbFields('relay')) as $field) {
$this->_data['data'] = $this->_data[$field];
}
if ($this->getId()) {
drupal_write_record('relay', $this->_data, array('id'));
}
else {
drupal_write_record('relay', $this->_data);
}
$this->_saveDevices();
}
protected function _saveDevices() {
if ($this->getId()) {
$delete = db_delete('relay_devices');
$delete->condition('relay_id', $this->getId());
$delete->execute();
foreach ((array)$this->_devices as $device) {
$device = (array) $device;
foreach (array_diff(array_keys($device), self::_getPureDbFields('relay_devices')) as $field) {
$device['data'] = $device[$field];
}
drupal_write_record('relay_devices', $device);
}
}
}
function getDateFrom() {
return $this->_data['date_from'];
}
function getDateDuration(){
return $this->_data['date_duration'];
}
function getDateTo(){
return $this->getDateFrom() + $this->getDateDuration();
}
function getDevices(){
$this->_ensureDevicesLoaded();
return $this->_devices;
}
protected function _ensureDevicesLoaded() {
if (!is_array($this->_devices)) {
$select = db_select('relay_devices', 'rd');
$select->fields('rd');
$select->condition('rd.relay_id', $this->getId());
$query = $select->execute();
$this->_devices = array_map('drupal_unpack', $query->fetchAll());
}
return is_array($this->_devices);
}
function __construct($data = NULL) {
if (is_array($data)) {
foreach ($data as $key => $value) {
$this->_data[$key] = $value;
}
}
elseif (is_string($this->_data['data']) && !empty($this->_data['data'])) {
drupal_unpack($this);
}
}
function __set($name, $value) {
return $this->_data[$name] = $value;
}
function __get($name) {
return $this->_data[$name];
}
static protected function _getPureDbFields($table) {
if (!isset(self::$_db_fields[$table])) {
$schema = drupal_get_schema($table);
$fields = $schema['fields'];
unset($fields['data']);
self::$_db_fields[$table] = array_keys($fields);
}
return self::$_db_fields[$table];
}
}
+159
/**
* Разбор результата в нужном формате
*
* @param mysqli_result $result результат
* @param string $fetch формат
* @return mixed
*/
public function fetch($result, $fetch) {
$fetch = strToLower($fetch);
if ((!$fetch) || ($fetch == 'no')) {
return $result;
}
if ($fetch == 'id') {
return $this->insert_id;
}
if ($fetch == 'ar') {
return $this->affected_rows;
}
$numRows = $result->num_rows;
if ($fetch == 'num') {
return $numRows;
}
if ($fetch == 'row') {
$A = Array();
for ($i = 0; $i < $numRows; $i++) {
$A[] = $result->fetch_row();
}
return $A;
}
if ($fetch == 'assoc') {
$A = Array();
for ($i = 0; $i < $numRows; $i++) {
$A[] = $result->fetch_assoc();
}
return $A;
}
if ($fetch == 'col') {
$A = Array();
for ($i = 0; $i < $numRows; $i++) {
$r = $result->fetch_row();
$A[] = $r[0];
}
return $A;
}
if ($fetch == 'object') {
$A = Array();
for ($i = 0; $i < $numRows; $i++) {
$A[] = $result->fetch_object();
}
return $A;
}
if ($fetch == 'vars') {
$A = Array();
for ($i = 0; $i < $numRows; $i++) {
$r = $result->fetch_row();
$A[$r[0]] = $r[1];
}
return $A;
}
if ($fetch == 'irow') {
return new goDBResultRow($result);
}
if ($fetch == 'iassoc') {
return new goDBResultAssoc($result);
}
if ($fetch == 'icol') {
return new goDBResultCol($result);
}
if ($fetch == 'iobject') {
return new goDBResultObject($result);
}
if ($numRows == 0) {
if (!in_array($fetch, array('rowrow', 'rowassoc', 'rowobject', 'el'))) {
throw new goDBExceptionFetch($fetch);
}
return false;
}
if ($fetch == 'rowrow') {
return $result->fetch_row();
}
if ($fetch == 'rowassoc') {
return $result->fetch_assoc();
}
if ($fetch == 'rowobject') {
return $result->fetch_object();
}
if ($fetch == 'el') {
$r = $result->fetch_row();
return $r[0];
}
throw new goDBExceptionFetch($fetch);
}
http://www.php.ru/forum/viewtopic.php?p=259972
+158
template <typename T> struct Rect : public ICollidable<T> {
T top, left, width, height;
...
Rect(T _top, T _left, T w, T h)
: top(_top)
, left(_left)
, width(w)
, height(h)
{};
...
};
Не расслабляемся: естественный порядок аргументов - это для ламеров!
+163
CTvoid cSG5Exception::Get (CTstatus& Status,
CTsymbol& Error,
CTsymbol& SubError,
string& Description)
{
if (Description.c_str() != NULL) {
Description = m_description;
}
Status = m_status;
Error = m_error;
SubError = m_subError;
}
итолианский с++ панимаш, рагацци.
что они хотели в строках 6-8 сказать кануло в лету.
и вместо 4 человеческих геттеров один бесполезный заху*чили. (бесполезный тем что четыре переменные всегда надо под рукой иметь.)
+75
class AboutProgram extends Frame{
AboutProgram(String s){
super(s);
setBounds(50,50,420,420);
setVisible(true);
setLayout(null);
addWindowListener(new WindowAdapter(){
public void windowClosing(WindowEvent ev){
dispose();
}
});
}
@Override
public void paint(Graphics g){
g.setFont(new Font("Times New Roman",Font.BOLD,30));
g.setColor(new Color(200,10,100));
g.drawString("Java-сапёр\n",150,50);
g.setColor(Color.blue);
g.setFont(new Font("Serif", Font.ITALIC | Font.BOLD, 15));
g.drawString("Автор \t div#[email protected]\n",20,100);
g.drawString("Период написания demo version \t 29.10.2005 - 04.11.2005",20,120);
g.drawString("Правила игры \n ",20,140);
g.drawString("Вы должны пометить все мины флажками \n ",40,160);
g.drawString("Флажок ставится правой кнопкой мыши\n ",40,180);
g.drawString("Открыть отдельное поле можно левой кнопкой мыши\n ",40,200);
g.drawString("Если поле пустое, то открываются все\n ",40,220);
g.drawString("соседние поля, в которых нет мин\n ",40,240);
g.drawString("Цифра в отдельном поле означает, что\n ",40,260);
g.drawString("в соседних клетках соответствующее число мин\n ",40,280);
g.drawString("Игра заканчивается, если\n ",20,300);
g.drawString("1) Все мины помечены флажками\n ",40,320);
g.drawString("2) Вы наткнулись на мину!\n ",40,340);
g.setColor(Color.red);
g.drawString("Помните!\n ",20,360);
g.setColor(Color.blue);
g.drawString("Сапёр ошибается только один раз!\n ",40,380);
}
}
Ну и о программе "избитого" сапера.
+120
public static string GetRedirectUrl(string userName, bool createPersistentCookie)
{
if (userName == null)
{
return null;
}
return GetReturnUrl(true);
}
из рефлектора, класс FormsAuthentication
ахеренная роль у параметров userName и createPersistentCookie