QStorageInfo storage("e:/");
qDebug() << "name:" << storage.name();
qDebug() << "fileSystemType:" << storage.fileSystemType();
qDebug() << "size:" << storage.bytesTotal()/1000/1000 << "MB";
qDebug() << "availableSize:" << storage.bytesAvailable()/1000/1000 << "MB";
#include <QStorageInfo>
#include <QDebug>
std::string text = "hello world";
SHA512_CTX sha_ctx = { 0 };
unsigned char digest[SHA512_DIGEST_LENGTH];
SHA512_Init(&sha_ctx);
SHA512_Update(&sha_ctx, text.data(), text.length());
SHA512_Final(digest, &sha_ctx);
if (RSA_verify(NID_sha512, digest, SHA512_DIGEST_LENGTH, (const unsigned char*)sign.data(), sign.length(), publicRSA) == 1) {
// Успех
}
Есть желание знать все
#include <windows.h>
#include <wininet.h>
#include <fstream>
#include <sstream>
#include <iostream>
#pragma comment(lib,"wininet.lib")
int main(int argc, char* argv[])
{
// инициализируем WinInet
HINTERNET hInternet = ::InternetOpen(TEXT("WinInet Test"), INTERNET_OPEN_TYPE_PRECONFIG, NULL, NULL, 0);
if (hInternet != NULL) {
// открываем HTTP сессию
HINTERNET hConnect = ::InternetConnect(hInternet, TEXT("localhost"), INTERNET_DEFAULT_HTTP_PORT, NULL, NULL,
INTERNET_SERVICE_HTTP, 0, 1u);
if (hConnect != NULL) {
// открываем запрос
HINTERNET hRequest = ::HttpOpenRequest(hConnect, TEXT("POST"), TEXT("test.php"), NULL, NULL, 0, INTERNET_FLAG_KEEP_CONNECTION, 1);
if (hRequest != NULL) {
// посылаем запрос
std::string fileName = "c:\\test.png"; // путь к файлу
char hdrs[] = "Content-Type: multipart/form-data; boundary=---------------------------7d82751e2bc0858";
std::string frmdata = "-----------------------------7d82751e2bc0858\r\n";
// В этой строке "uploadedfile" - название поля формы
frmdata += "Content-Disposition: form-data; name=\"uploadedfile\"; filename=\"" + fileName + "\"\r\nContent-Type: application/octet-stream\r\n\r\n";
std::ostringstream ostrm;
std::ifstream fin(fileName, std::ios::binary);
if (fin) {
ostrm << fin.rdbuf();
frmdata.append(ostrm.str());
frmdata += "\r\n-----------------------------7d82751e2bc0858--\r\n";
BOOL bSend = ::HttpSendRequestA(hRequest, hdrs, strlen(hdrs), &frmdata[0], frmdata.size());
if (bSend) {
std::string res; // В этой переменной будет ответ сервера
for (;;) {
// читаем данные
char szData[1024];
DWORD dwBytesRead;
BOOL bRead = ::InternetReadFile(hRequest, szData, sizeof(szData) - 1, &dwBytesRead);
// выход из цикла при ошибке или завершении
if (bRead == FALSE || dwBytesRead == 0)
break;
// сохраняем результат
szData[dwBytesRead] = 0;
res.append(szData);
}
std::cout << res;
}
}
// закрываем запрос
::InternetCloseHandle(hRequest);
}
// закрываем сессию
::InternetCloseHandle(hConnect);
}
// закрываем WinInet
::InternetCloseHandle(hInternet);
}
return 0;
}
<?php
mb_internal_encoding('UTF-8');
function get_token($curl, $url, $cookie) {
curl_setopt($curl, CURLOPT_URL, $url);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
curl_setopt($curl, CURLOPT_TIMEOUT, 30);
curl_setopt($curl, CURLOPT_COOKIEJAR, $cookie);
curl_setopt($curl, CURLOPT_COOKIEFILE, $cookie);
$response = curl_exec($curl);
if (preg_match('/<meta content="([^"]+)" name="csrf-token"/s', $response, $matches)) {
return $matches[1];
}
}
function auth($curl, $url, $cookie, $post, $csrf_token)
{
$headers = array(
'X-CSRF-Token: '.$csrf_token,
'X-Requested-With: XMLHttpRequest'
);
curl_setopt($curl, CURLOPT_URL, $url);
curl_setopt($curl, CURLOPT_HEADER, true);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
curl_setopt($curl, CURLOPT_FOLLOWLOCATION, true);
curl_setopt($curl, CURLOPT_TIMEOUT, 30);
curl_setopt($curl, CURLOPT_USERAGENT, 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/71.0.3578.98 Safari/537.36');
curl_setopt($curl, CURLOPT_POST, true);
curl_setopt($curl, CURLOPT_POSTFIELDS, $post);
curl_setopt($curl, CURLOPT_COOKIEJAR, $cookie);
curl_setopt($curl, CURLOPT_COOKIEFILE, $cookie);
curl_setopt($curl, CURLOPT_HTTPHEADER, $headers);
return curl_exec($curl);
}
function read_brs( $curl, $url, $last_url, $cookie)
{
curl_setopt($curl, CURLOPT_URL, $url);
curl_setopt($curl, CURLOPT_REFERER, $last_url);
curl_setopt($curl, CURLOPT_HEADER, true);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
curl_setopt($curl, CURLOPT_FOLLOWLOCATION, true);
curl_setopt($curl, CURLOPT_TIMEOUT, 30);
curl_setopt($curl, CURLOPT_POST, 0);
curl_setopt($curl, CURLOPT_USERAGENT, 'Mozilla/5.0 (Windows; U; Windows NT 6.0; ru; rv:1.9.1.3) Gecko/20090824 Firefox/3.5.3');
curl_setopt($curl, CURLOPT_COOKIEJAR, $cookie);
curl_setopt($curl, CURLOPT_COOKIEFILE, $cookie);
return curl_exec($curl);
}
$curl = curl_init();
$cookie_file = realpath("cookie.txt");
$post = "utf8=✓&user[email]=Pogodinaa&user[password]=12345&commit=Войти";
$url = 'http://rating.rucoop.ru/secondary/users/sign_in';
$newUrl = "http://rating.rucoop.ru/secondary/ratings/for_group";
$csrf_token = get_token($curl, 'http://rating.rucoop.ru/secondary/',$cookie_file);
echo auth($curl, $url, $cookie_file, $post, $csrf_token);
echo read_brs($curl, $newUrl, $url, $cookie_file);
?>
SetLayeredWindowAttributes(hWnd, 0, 100, LWA_ALPHA);
hKeyboardHook = SetWindowsHookEx(WH_KEYBOARD_LL, (HOOKPROC)KeyboardEvent, hInstance, NULL);
LRESULT CALLBACK KeyboardEvent(int nCode, WPARAM wParam, LPARAM lParam)
{
if ((nCode == HC_ACTION))
{
KBDLLHOOKSTRUCT* hooked_key = (KBDLLHOOKSTRUCT*)lParam;
if (hooked_key->vkCode == VK_LSHIFT || hooked_key->vkCode == VK_RSHIFT) {
bool shiftPressed = (wParam == WM_KEYDOWN);
LONG oldStyle = GetWindowLong(hWnd, GWL_EXSTYLE);
if (shiftPressed) {
SetWindowLong(hWnd, GWL_EXSTYLE, oldStyle & (~WS_EX_TRANSPARENT));
}
else {
SetWindowLong(hWnd, GWL_EXSTYLE, oldStyle | WS_EX_TRANSPARENT);
}
}
}
return CallNextHookEx(hKeyboardHook, nCode, wParam, lParam);
}
UnhookWindowsHookEx(hKeyboardHook);
<table>
<tr>
<th>ID</th>
<th>Name</th>
<th>Text</th>
<th></th>
</tr>
<tr data-id="1">
<td>1</td>
<td>dasd</td>
<td>123</td>
<td><button>x</button></td>
</tr>
<tr data-id="2">
<td>2</td>
<td>Александр</td>
<td>Текст</td>
<td><button>x</button></td>
</tr>
</table>
$("table button").click(function() {
var row = $(this).closest('tr');
$.post("delete.php",{id: row.data('id')}, function(response){
if (response.success) {
row.remove();
}
}, 'json');
});