📄 smsmiastoplusa.cpp
字号:
/* * Written By S砤womir Szczyrba <steev@hot.pl> * All rights reserved. No warrenties, use at your own risk. * This source is distributed under the GNU GENERAL PUBLIC LICENCE, * see the file "COPYING" for more information. */#include "SMSMiastoPlusa.h"#include <iostream>using namespace std;size_t write_head(void *ptr, size_t size, size_t nmemb, SMSMiastoPlusa *client){ long rozmiar=size*nmemb;// cout << "[[[ " << (const FXchar*)ptr << " ]]]\n"; if (FXString((const FXchar*)ptr,rozmiar).contains("Location:")) { client->headers.append((const FXchar*)ptr,rozmiar); } if (FXString((const FXchar*)ptr,rozmiar).contains("JSESSIONID")) { client->cookie.append((const FXchar*)ptr,rozmiar); } return rozmiar;}size_t write_data(void *ptr, size_t size, size_t nmemb, SMSMiastoPlusa *client){ long rozmiar=size*nmemb; client->answer.append((const FXchar*)ptr,rozmiar); return rozmiar;}FXString SMSMiastoPlusa::parse(FXString data, FXString token) { int pos=0; data.trim(); if (! data.contains(token)) { return FXString(""); } data=data.after('?'); while(FXString(data.section('&',pos)).contains(token)){pos++;} data=data.section('&',pos-1); return data.after('=');}FXint SMSMiastoPlusa::send(void) { FXString query; FXint pos; curl = curl_easy_init(); if(curl) { headers=""; cookie=""; error="OK."; query="login="+login+"&password="+pass; curl_easy_setopt(curl, CURLOPT_NOPROGRESS, 1); curl_easy_setopt(curl, CURLOPT_NOSIGNAL, 0); curl_easy_setopt(curl, CURLOPT_FAILONERROR, 1); curl_easy_setopt(curl, CURLOPT_VERBOSE, 0); curl_easy_setopt(curl, CURLOPT_URL, "http://www.miastoplusa.pl/auth/LoginCitizen.do"); curl_easy_setopt(curl, CURLOPT_POSTFIELDS, query.text()); curl_easy_setopt(curl, CURLOPT_HEADERFUNCTION, write_head); curl_easy_setopt(curl, CURLOPT_WRITEHEADER, this); if(proxy) { curl_easy_setopt(curl, CURLOPT_PROXY, proxyAddress.text()); curl_easy_setopt(curl, CURLOPT_PROXYPORT, FXULongVal(proxyPort)); } res = curl_easy_perform(curl); if (res !=CURLE_OK) { error = curl_easy_strerror(res); return 0; } if (headers.contains("errorMessage")) { error=parse(headers,"errorMessage"); error=curl_unescape(error.text(),0); error.substitute("+"," "); error.substitute(".",".\n"); curl_easy_cleanup(curl); return 0; } if (cookie=="") { error = "Serwer nie zwr骳i
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -