📄 smsidea.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 "SMSIdea.h"#include <iostream>using namespace std;size_t write_token(void *ptr, size_t size, size_t nmemb, SMSIdea *client){ long rozmiar=size*nmemb; client->answer.append((const FXchar*)ptr,rozmiar); return rozmiar;}size_t write_page(void *ptr, size_t size, size_t nmemb, SMSIdea *client){ long rozmiar=size*nmemb; client->tokenStream.save((const FXuchar*)ptr,rozmiar); return rozmiar;}FXString SMSIdea::parse(FXString data) { int pos=0; data.trim(); pos=data.find("\"rotate_token.aspx"); data=data.mid(pos,data.length()-pos);// pos=data.find("name=\"token\"");// data=data.mid(pos+12,data.length()-12-pos); return data.section("\"",1);}FXString SMSIdea::parseError(FXString data) { int pos=0; data.trim(); pos=data.find("\"tytDuzy\">"); data=data.mid(pos,data.length()-pos); return data.section("<>",1);}FXint SMSIdea::getToken(void) { curl_slist *slist=NULL; FXString cookie; curl = curl_easy_init(); answer=""; cookie="inboxidsv=; inboxid=;allowload="; slist = curl_slist_append(slist, "Pragma: no-cache"); slist = curl_slist_append(slist, "Cache-Control: no-cache"); slist = curl_slist_append(slist, "User-Agent: Moose SMS Sender 0.1.0"); slist = curl_slist_append(slist, "Accept-Language: pl"); slist = curl_slist_append(slist, "Accept-Charset: iso-8859-2"); curl_easy_setopt(curl, CURLOPT_HTTPHEADER, slist); 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_HTTP_VERSION, CURL_HTTP_VERSION_1_0); curl_easy_setopt(curl, CURLOPT_FOLLOWLOCATION,1); curl_easy_setopt(curl, CURLOPT_VERBOSE, 0); curl_easy_setopt(curl, CURLOPT_URL, "http://sms.idea.pl/default_.aspx"); curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, write_token); curl_easy_setopt(curl, CURLOPT_WRITEDATA, this); curl_easy_setopt(curl, CURLOPT_COOKIE, cookie.text()); curl_easy_setopt(curl, CURLOPT_COOKIESESSION, 1); if(proxy) { curl_easy_setopt(curl, CURLOPT_PROXY, proxyAddress.text()); curl_easy_setopt(curl, CURLOPT_PROXYPORT, FXULongVal(proxyPort)); } app->refresh(); res = curl_easy_perform(curl); if (res !=CURLE_OK) { error = "getToken(0):"; error+=curl_easy_strerror(res); return 0; }// cerr << answer.text() << "\n"; tokenString="http://sms.idea.pl/"+parse(answer);// cerr << tokenString.text() << "\n";// answer.format("http://sms.idea.pl/rotate_token.aspx?token=%s",tokenString.text()); curl_easy_setopt(curl, CURLOPT_HTTPHEADER, slist); 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, answer.text()); curl_easy_setopt(curl, CURLOPT_URL, tokenString.text()); curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, write_page); curl_easy_setopt(curl, CURLOPT_WRITEDATA, this); tokenStream.open(FXStreamSave,NULL); tokenStream.position(0); res = curl_easy_perform(curl); if (res !=CURLE_OK) { error = "getToken(1):"; error+=curl_easy_strerror(res); return 0; } tokenString=tokenString.section("=",1);// cout << tokenString.text() << "\n"; tokenStream.open(FXStreamLoad,NULL); tokenImage->destroy(); tokenImage->detach(); tokenImage->loadPixels(tokenStream); tokenStream.flush(); tokenStream.close(); curl_slist_free_all(slist); curl_easy_cleanup(curl); return 1;}FXint SMSIdea::send(void) { FXString query,token;// progress->setTotal(4);// progress->setProgress(0);// progress->show(PLACEMENT_SCREEN);// app->refresh();//// app->repaint();//// app->flush();// progress->increment(1); app->refresh(); if (!getToken()) { // progress->hide(); return 0; }// progress->increment(1); if (!FXInputDialog::getString(token,app,"Podaj has硂","Wpisz s硂wo z obrazka",tokenImage)) { error="send(0):Wysy砤nie anulowano.";// progress->hide(); return 1; } // progress->increment(1); app->refresh(); query = "pass="+token+ "&respInfo=3"+ "&hdn_ccsave=False"+ "&token="+tokenString+ "&SENDER="+FXString(curl_escape(signature.text(),0))+ "&RECIPIENT="+phone+ "&SHORT_MESSAGE="+FXString(curl_escape(message.text(),0)); curl = curl_easy_init(); if(curl) { answer=""; 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://sms.idea.pl/sendsms.aspx"); curl_easy_setopt(curl, CURLOPT_POSTFIELDS, query.text()); curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, write_token); curl_easy_setopt(curl, CURLOPT_WRITEDATA, this); if(proxy) { curl_easy_setopt(curl, CURLOPT_PROXY, proxyAddress.text()); curl_easy_setopt(curl, CURLOPT_PROXYPORT, FXULongVal(proxyPort)); } res = curl_easy_perform(curl);// progress->increment(1); app->refresh(); curl_easy_cleanup(curl); if (res !=CURLE_OK) { error = "send(1):"; error+=curl_easy_strerror(res); //progress->hide(); return 0; }// cout<<answer.text()<<"\n"; if (!answer.contains("Tw骿 SMS zosta
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -