- 1
Немного богословия.
Нашли или выдавили из себя код, который нельзя назвать нормальным, на который без улыбки не взглянешь? Не торопитесь его удалять или рефакторить, — запостите его на говнокод.ру, посмеёмся вместе!
+1
Немного богословия.
In the beginning was the word; and version of this Word was 1.0
−1
<?php
header ('Access-Control-Allow-Origin: *');//Разрешили кроссдоменные запросы
$mysql_host = "хост";
$mysql_database = "Бд";
$mysql_user = "Юзернейм";
$mysql_password = "пОроль";
$link = mysql_connect($mysql_host, $mysql_user, $mysql_password) or die("Ошибка при подключении MySQL" );
mysql_select_db($mysql_database, $link) or die ('Ошибка при подключении к БД');
if (isset($_POST['login'])) { $login = $_POST['login']; if ($login == '') { unset($login);} }
if (isset($_POST['password'])) { $password=$_POST['password']; if ($password =='') { unset($password);} }
if (isset($_POST['email'])) { $email=$_POST['email']; if ($email =='') { unset($email);} }
if (isset($_POST['silvercoin'])) { $silvercoin=$_POST['silvercoin']; if ($silvercoin =='') { unset($silvercoin);} }
if (isset($_POST['goldcoin'])) { $goldcoin=$_POST['goldcoin']; if ($goldcoin =='') { unset($goldcoin);} }
if (empty($login) or empty($password) or empty($email))
{
echo ("Вы ввели не всю информацию, заполните все поля!");
exit();
}
$login = stripslashes($login);
$login = htmlspecialchars($login);
$password = stripslashes($password);
$password = htmlspecialchars($password);
$email = stripslashes($email);
$email = htmlspecialchars($email);
$silvercoin = stripslashes($silvercoin);
$silvercoin = htmlspecialchars($silvercoin);
$goldcoin = stripslashes($goldcoin);
$goldcoin = htmlspecialchars($goldcoin);
$login = trim($login);
$password = trim($password);
$email = trim($email);
$silvercoin = trim($silvercoin);
$goldcoin = trim($goldcoin);
$q1 = mysql_query("SELECT login FROM `accounts` WHERE `login`='".$login."'");
$loginb = mysql_fetch_array($q1);
$loginbd=$loginb['login'];
if($loginbd == $login){
echo("Извините, введённый вами логин уже зарегистрирован.");
exit();
}
else
$result2 = mysql_query ("INSERT INTO accounts (login,password,email) VALUES('$login','$password','$email')");
if ($result2=='TRUE')
{
echo "Вы успешно зарегистрированы!";
}
else {
echo "Ошибка! Вы не зарегистрированы.";
}
?>
Использование бредо-заголовок в 2 строке
Использование Инструмента в 2к21, который в PHP5.5.0 20 июня 2013 Объявлен как устаревший, а в PHP 7.0.0 удален
Нет задающей кодировки подключения к БД
Глупая, дешевая валидация данных начиная с 12 и заканчивая 46 строкой
SQL-injection привет!
46 строка - невероятно проверять boolean тип
37 - 39 строка - юзер не найден - лови ошибку!
Чуть не забыл... скрипт не в кодировке UTF-8 no BOM
https://php.ru/forum/threads/pomogite-ispravit-oshibku-cannot-modify-header-information-headers-already-sent-by.90359/
Привет 2010 году !
+3
Как известно, язык C# придумал Андерс Хейлсберг. В связи с этим, на первых порах его жутко атаковали журналисты, в попытке снять интервью.
Делали они это столь навячиво, что обычно вежливый и корректный Хейлсберг стал грубым и несдержанным. Он избегал журналистов, но они не отставали.
Однажды его подстерегли в метро - он едва смог вырваться из назойливой толпы, - затем его почти сразу прижали в переулке.
-Господин Хейлсберг, пару слов для издания КомпНьюс...
-Пошли на хуй, - прошептал Андерс, ускорив шаг. В ту же минуту его затерла толпа и на него упал яркий свет.
-Прямой эфир!
Андерс замялся. Уйти из кадра было бы несложно, но это могло сказаться на репутации. Кинооператор уже наставил камеру.
Из толпы вышел наиболее задиристый человек с микрофоном.
-Скажите, господин Хейлсберг, почему Вы добавили в это говно столько сахара? Почему не сделали его ванильным - как Делфи?
-Потому, что глупо добавлять ванилин в говно, которое будут пробовать на вкус, огрызнулся Хейлсберг, и, тяжко размахнувшись, ударил по объективу дипломатом.
+1
// https://quuxplusone.github.io/blog/2021/01/13/conversion-operator-lookup/
struct A {
using T = T1;
using U = U1;
operator U1 T1::*();
operator U1 T2::*();
operator U2 T1::*();
operator U2 T2::*();
};
inline auto which(U1 T1::*) { return "gcc"; }
inline auto which(U1 T2::*) { return "icc"; }
inline auto which(U2 T1::*) { return "msvc"; }
inline auto which(U2 T2::*) { return "clang"; }
int main() {
A a;
using T = T2;
using U = U2;
puts(which(a.operator U T::*()));
}
> As of this writing (but perhaps not for very much longer!) the four mainstream compilers on Godbolt Compiler Explorer give four different answers for this simple C++ program:
> According to the current draft standard, it sounds like the conforming answer is “they should both be looked up in the scope of A”; i.e., GCC’s answer is correct and the others are wrong in three different ways.
Какой багор )))
−1
<?php
if($theme_options->get( 'header_type' ) == 2) {
include('catalog/view/theme/'.$config->get('config_template').'/template/common/header/header_02.tpl');
} elseif($theme_options->get( 'header_type' ) == 3) {
include('catalog/view/theme/'.$config->get('config_template').'/template/common/header/header_03.tpl');
} elseif($theme_options->get( 'header_type' ) == 4) {
include('catalog/view/theme/'.$config->get('config_template').'/template/common/header/header_04.tpl');
} elseif($theme_options->get( 'header_type' ) == 5) {
include('catalog/view/theme/'.$config->get('config_template').'/template/common/header/header_05.tpl');
} elseif($theme_options->get( 'header_type' ) == 6) {
include('catalog/view/theme/'.$config->get('config_template').'/template/common/header/header_06.tpl');
} elseif($theme_options->get( 'header_type' ) == 7) {
include('catalog/view/theme/'.$config->get('config_template').'/template/common/header/header_07.tpl');
} elseif($theme_options->get( 'header_type' ) == 8) {
include('catalog/view/theme/'.$config->get('config_template').'/template/common/header/header_08.tpl');
} elseif($theme_options->get( 'header_type' ) == 9) {
include('catalog/view/theme/'.$config->get('config_template').'/template/common/header/header_09.tpl');
} elseif($theme_options->get( 'header_type' ) == 10) {
include('catalog/view/theme/'.$config->get('config_template').'/template/common/header/header_10.tpl');
} elseif($theme_options->get( 'header_type' ) == 11) {
include('catalog/view/theme/'.$config->get('config_template').'/template/common/header/header_11.tpl');
} elseif($theme_options->get( 'header_type' ) == 12) {
include('catalog/view/theme/'.$config->get('config_template').'/template/common/header/header_12.tpl');
} elseif($theme_options->get( 'header_type' ) == 13) {
include('catalog/view/theme/'.$config->get('config_template').'/template/common/header/header_13.tpl');
} elseif($theme_options->get( 'header_type' ) == 14) {
include('catalog/view/theme/'.$config->get('config_template').'/template/common/header/header_14.tpl');
} elseif($theme_options->get( 'header_type' ) == 15) {
include('catalog/view/theme/'.$config->get('config_template').'/template/common/header/header_15.tpl');
} elseif($theme_options->get( 'header_type' ) == 16) {
include('catalog/view/theme/'.$config->get('config_template').'/template/common/header/header_16.tpl');
} elseif($theme_options->get( 'header_type' ) == 17) {
include('catalog/view/theme/'.$config->get('config_template').'/template/common/header/header_17.tpl');
} elseif($theme_options->get( 'header_type' ) == 18) {
include('catalog/view/theme/'.$config->get('config_template').'/template/common/header/header_18.tpl');
} elseif($theme_options->get( 'header_type' ) == 19) {
include('catalog/view/theme/'.$config->get('config_template').'/template/common/header/header_19.tpl');
} elseif($theme_options->get( 'header_type' ) == 20) {
include('catalog/view/theme/'.$config->get('config_template').'/template/common/header/header_20.tpl');
} elseif($theme_options->get( 'header_type' ) == 21) {
include('catalog/view/theme/'.$config->get('config_template').'/template/common/header/header_21.tpl');
} elseif($theme_options->get( 'header_type' ) == 22) {
include('catalog/view/theme/'.$config->get('config_template').'/template/common/header/header_22.tpl');
} elseif($theme_options->get( 'header_type' ) == 23) {
include('catalog/view/theme/'.$config->get('config_template').'/template/common/header/header_23.tpl');
} elseif($theme_options->get( 'header_type' ) == 24) {
include('catalog/view/theme/'.$config->get('config_template').'/template/common/header/header_24.tpl');
} elseif($theme_options->get( 'header_type' ) == 25) {
include('catalog/view/theme/'.$config->get('config_template').'/template/common/header/header_25.tpl');
} elseif($theme_options->get( 'header_type' ) == 26) {
include('catalog/view/theme/'.$config->get('config_template').'/template/common/header/header_26.tpl');
} elseif($theme_options->get( 'header_type' ) == 27) {
include('catalog/view/theme/'.$config->get('config_template').'/template/common/header/header_27.tpl');
} else {
include('catalog/view/theme/'.$config->get('config_template').'/template/common/header/header_01.tpl');
}
?>
+1
void testToken(const char *value, size_t tokenExpected)
{
antlr4::ANTLRInputStream input(value);
typescript::TypeScriptLexerANTLR lexer(&input);
auto tokens = lexer.getAllTokens();
printTokens(lexer, tokens);
auto token = tokens.front().get();
std::ostringstream stringStream;
stringStream << "Expecting: [" << lexer.getTokenNames()[tokenExpected] << "] \"" << value << "\" but get: [" << lexer.getTokenNames()[token->getType()] << "] \"" << token->getText() << "\".";
auto msg = stringStream.str();
ASSERT_EQUAL_MSG(token->getType(), tokenExpected, msg);
ASSERT_THROW_MSG(token->getText().compare(value) == 0, msg);
}
void testOctalIntegerLiteral()
{
testToken("01", l::OctalIntegerLiteral);
}
Мой расказ о том как жизни было нехрен делать и я начал писать копилятор для TypeScript. как это "пинание х..я" кончиться я не знаю. но вот начал с простого. собрал минимум для разработки это LLVM и ANTLR4. И уже написал свой первый (ну не совсем) lexer.
вот тут можно посмотреть на убогость говнокода.
https://github.com/ASDAlexander77/TypeScriptCompiler
0
IT Оффтоп #78
#49: https://govnokod.ru/26750 https://govnokod.xyz/_26750
#49: https://govnokod.ru/26776 https://govnokod.xyz/_26776
#50: https://govnokod.ru/26804 https://govnokod.xyz/_26804
#51: https://govnokod.ru/26809 https://govnokod.xyz/_26809
#52: https://govnokod.ru/26817 https://govnokod.xyz/_26817
#53: https://govnokod.ru/26833 https://govnokod.xyz/_26833
#54: https://govnokod.ru/26840 https://govnokod.xyz/_26840
#55: https://govnokod.ru/26844 https://govnokod.xyz/_26844
#56: https://govnokod.ru/26862 https://govnokod.xyz/_26862
#57: https://govnokod.ru/26890 https://govnokod.xyz/_26890
#58: https://govnokod.ru/26916 https://govnokod.xyz/_26916
#59: https://govnokod.ru/26934 https://govnokod.xyz/_26934
#60: https://govnokod.ru/26949 https://govnokod.xyz/_26949
#61: https://govnokod.ru/26980 https://govnokod.xyz/_26980
#62: https://govnokod.ru/26999 https://govnokod.xyz/_26999
#63: https://govnokod.ru/27004 https://govnokod.xyz/_27004
#64: https://govnokod.ru/27020 https://govnokod.xyz/_27020
#65: https://govnokod.ru/27027 https://govnokod.xyz/_27027
#66: https://govnokod.ru/27040 https://govnokod.xyz/_27040
#67: https://govnokod.ru/27049 https://govnokod.xyz/_27049
#68: https://govnokod.ru/27061 https://govnokod.xyz/_27061
#69: https://govnokod.ru/27071 https://govnokod.xyz/_27071
#70: https://govnokod.ru/27097 https://govnokod.xyz/_27097
#71: https://govnokod.ru/27115 https://govnokod.xyz/_27115
#72: https://govnokod.ru/27120 https://govnokod.xyz/_27120
#73: https://govnokod.ru/27136 https://govnokod.xyz/_27136
#74: https://govnokod.ru/27160 https://govnokod.xyz/_27160
#75: https://govnokod.ru/27166 https://govnokod.xyz/_27166
#76: https://govnokod.ru/27168 https://govnokod.xyz/_27168
#77: https://govnokod.ru/27186 https://govnokod.xyz/_27186
0
format PE64 GUI 5.0
include 'win64a.inc'
entry $
xor rdi,rdi
push rdi
push rdi
push rdi;$400000
push rdi
push rdi
mov rax,CW_USEDEFAULT
push rax
push rax
push rax
push rax
push rdi
push rdi
push rdi
push rdi
mov r9,WS_VISIBLE+WS_OVERLAPPEDWINDOW
mov r8,_title
mov rdx,_class
mov rcx,rdi
call [CreateWindowEx]
mov r8,WindowProc
mov rdx,-4
mov rcx,rax
call [SetWindowLongPtrA]
mov qword[_title],rax
pop rdi
mov rsi,rsp
xor rbx,rbx
mov bl,40
@@:sub rsp,rbx
xor r9,r9
xor r8,r8
xor rdx,rdx
mov rcx,rsi
call [GetMessage]
mov rcx,rsi
call [DispatchMessage]
add rsp,rbx
jmp @b
WindowProc:
push r9
cmp rdx,WM_CLOSE
je app_close
defwndproc:
push rdi
push rdi
push rdi
push rdi
mov r9,r8
mov r8,rdx
mov rdx,rcx
mov rcx,qword[_title]
call [CallWindowProc]
pop rdi
pop rdi
pop rdi
pop rdi
pop rdi
ret
app_close:
call [exit]
_title db '1KBytex64',0
_class db '#32770',0
data import
library\
user32,'USER32.DLL',\
msvcrt,'msvcrt.dll'
include 'api\user32.inc'
import msvcrt,\
exit,'_exit'
end data
Ничего интересного, просто извращённый 1KBytex64
−4
format pe console
include 'win32ax.inc'
macro call1 f,p1{
mov ebx,p1
call f}
macro call2 f,p1,p2{
mov ecx,p2
call1 f,p1}
macro call3 f,p1,p2,p3{
mov edx,p3
call2 f,p1,p2}
.data
lead_time dd ?
handle_input dd ?
handle_output dd ?
byte_read_write dd ?
.code
string db 'govnokod.ru ',13,10,0
array_procs dd __strlen,_strlen,strlen,0
putdword:;ebx-handle,ecx-byte
mov eax,esp
mov esi,eax
sub esp,16
xchg eax,ecx
mov edi,10
@@:xor edx,edx
div edi
add dl,'0'
dec ecx
mov [ecx],dl
test eax,eax
jnz @b
sub esi,ecx
mov edx,esi
invoke WriteFile,ebx,ecx,edx,byte_read_write,0
add esp,16
ret
align 4
strlen:;ebx-array of char
mov eax,12
ret
align 4
_strlen:;ebx-array of char
clc
xor ecx,ecx
dec ecx
mov edi,ebx
xor al,al
repne scasb
not ecx
dec ecx
mov eax,ecx
ret
align 4
__strlen:;ebx-array of char
xor eax,eax
dec eax
@@:inc eax
cmp byte[ebx+eax],0
jne @b
ret
start:
invoke GetStdHandle,STD_INPUT_HANDLE
mov [handle_input],eax
invoke GetStdHandle,STD_OUTPUT_HANDLE
mov [handle_output],eax
mov ebp,array_procs
next_step:
call [GetTickCount]
mov [lead_time],eax
xor ecx,
@@:push ecx
mov ebx,string
call dword[ebp]
pop ecx
loop @b
push eax
call [GetTickCount]
sub eax,[lead_time]
mov ecx,1000
xor edx,edx
div ecx
push edx
call2 putdword,[handle_output],eax
invoke WriteFile,ebx,string+8,1,byte_read_write,0
pop ecx
call2 putdword,[handle_output],ecx
invoke WriteFile,ebx,string+11,1,byte_read_write,0
pop ecx
call2 putdword,[handle_output],ecx
invoke WriteFile,[handle_output],string+12,2,byte_read_write,0
add ebp,4
cmp dword[ebp],0
jne next_step
call [GetTickCount]
mov [lead_time],eax
invoke SetConsoleMode,[handle_input],0
invoke ReadFile,[handle_input],byte_read_write,1,byte_read_write,0
invoke ExitProcess,0
.end start
Поговнокодим однако.
Зачем в процессоре занимают место команды типа repne scasb и прочее, если простые аналоги быстрее компактнее и проще встраивать в алгоритм без отдельной подпрограммы да и регистров в разы меньше требуется. Пустая подпрограмма для понимания сколько времени занимает лишний код. Есть предположение что раньше на заре развития они работали шустрее, но это только предположение.
−1
includelib C:\Irvine\User32.Lib
includelib C:\Irvine\Kernel32.Lib
includelib D:\masm32\lib\Irvine32.lib
include \masm32\include\Irvine32.inc
.data
data_1 dword 45
data_2 dword 29
msg byte ?
.code
main PROC
xor ebx, ebx
xor eax, eax
xor edx, edx
xor esi, esi
mov cl ,31
mov eax, data_1
mov esi , data_2
lm:
shl esi, 1
jnc one
cmp msg, 1
je two
shl eax, cl
mov msg, 1
mov ebx, data_1
jmp one
two:
shl ebx, cl
mov msg, 0
add eax, ebx
add edx , eax
mov eax, data_1
one:
loop lm
mov eax , edx
call WriteInt
Call CrLf
exit
main ENDP
END main
Hey, Mr. Tambourine Man, play a song for me
I'm not sleepy and there is no place I'm going to
Hey, Mr. Tambourine Man, play a song for me
In the jingle jangle morning I'll come following you
Though I know that evening's empire has returned into sand
Vanished from my hand
Left me blindly here to stand, but still not sleeping
My weariness amazes me, I'm branded on my feet
I have no one to meet
And the ancient empty street's too dead for dreaming
Hey, Mr. Tambourine Man, play a song for me
I'm not sleepy and there is no place I'm going to
Hey, Mr. Tambourine Man, play a song for me
In the jingle jangle morning I'll come following you
Take me on a trip upon your magic swirling ship
My senses have been stripped
My hands can't feel to grip
My toes too numb to step
Wait only for my boot heels to be wandering
I'm ready to go anywhere, I'm ready for to fade
Into my own parade
Cast your dancing spell my way, I promise to go under it
Hey, Mr. Tambourine Man, play a song for me
I'm not sleepy and there is no place I'm going to
Hey, Mr. Tambourine Man, play a song for me
In the jingle jangle morning I'll come following you