#define _USER_AGENT_CURL_APPS "Mozilla/5.0 (Windows; U; Windows NT 5.1; it-CH; rv:1.7.12) Gecko/20050919 Firefox/1.0.7"
/* Warning get local file contents or remote file contents by curl */
{
if (fullFileName.contains("https://", Qt::CaseInsensitive)) {
inside = "No build support to https protocoll";
return inside;
}
if ( this->IsNetFile( fullFileName ) )
{
file_put_contents(www_net_file,""); /* remove last action if exist */
if ( fullFileName.contains("webdav://", Qt::CaseInsensitive )) {
#ifndef GRABCONFIGPASS
#define GRABCONFIGPASS
#endif
}
char *localfile = append( qt2char( cachedir ) , c_www_net_file );
char *cookiefile = append( qt2char( cachedir ) , c_www_cookie_file );
char *url = qt2char( fullFileName );
CURL *curl_handle;
FILE *outfile;
curl_global_init(CURL_GLOBAL_ALL);
curl_global_init(CURL_GLOBAL_ALL);
curl_handle = curl_easy_init();
outfile = fopen(localfile, "w");
if (outfile!=NULL) {
/* CURLOPT_COOKIE and must have CURLOPT_COOKIEJAR char * (file to write same as php) */
curl_easy_setopt(curl_handle, CURLOPT_URL, url);
curl_easy_setopt(curl_handle, CURLOPT_VERBOSE, TRUE);
curl_easy_setopt(curl_handle, CURLOPT_COOKIEJAR, cookiefile );
curl_easy_setopt(curl_handle, CURLOPT_FOLLOWLOCATION , 1);
curl_easy_setopt(curl_handle, CURLOPT_MAXREDIRS , 5);
curl_easy_setopt(curl_handle, CURLOPT_TIMEOUT , timeoutsec );
curl_easy_setopt(curl_handle, CURLOPT_USERAGENT, c_user_agent );
curl_easy_setopt(curl_handle, CURLOPT_FILE, outfile);
if (curl_easy_perform(curl_handle)==CURLE_OK) {
fclose(outfile);
QFile filecurl
(www_net_file
);
if (filecurl.size() > 5) {
curlerrormsg = "ok_success";
} else {
curlerrormsg
= "Error time out to get remote file"+QString( "%1" ).
arg( getExactTime
() );
}
} else {
curlerrormsg
= "Error time out to get remote file"+QString( "%1" ).
arg( getExactTime
() );
file_put_contents(www_net_file,"");
}
}
/* return grab result from local file */
return file_get_contents(www_net_file);
}
/* ok is a fake normal local file init ..... */
QFile file(fullFileName
);
if (file.exists()) {
inside =file.readAll();
file.close();
errormsg = "ok_success";
} else {
inside = "no_open_file";
}
} else {
inside = "no_file";
}
return inside;
}
#define _USER_AGENT_CURL_APPS "Mozilla/5.0 (Windows; U; Windows NT 5.1; it-CH; rv:1.7.12) Gecko/20050919 Firefox/1.0.7"
/* Warning get local file contents or remote file contents by curl */
QString Config::file_get_contents(QString fullFileName)
{
QString inside = "";
if (fullFileName.contains("https://", Qt::CaseInsensitive)) {
inside = "No build support to https protocoll";
return inside;
}
if ( this->IsNetFile( fullFileName ) )
{
file_put_contents(www_net_file,""); /* remove last action if exist */
if ( fullFileName.contains("webdav://", Qt::CaseInsensitive )) {
#ifndef GRABCONFIGPASS
#define GRABCONFIGPASS
#endif
}
char *localfile = append( qt2char( cachedir ) , c_www_net_file );
char *cookiefile = append( qt2char( cachedir ) , c_www_cookie_file );
char *url = qt2char( fullFileName );
CURL *curl_handle;
FILE *outfile;
curl_global_init(CURL_GLOBAL_ALL);
curl_global_init(CURL_GLOBAL_ALL);
curl_handle = curl_easy_init();
outfile = fopen(localfile, "w");
if (outfile!=NULL) {
/* CURLOPT_COOKIE and must have CURLOPT_COOKIEJAR char * (file to write same as php) */
curl_easy_setopt(curl_handle, CURLOPT_URL, url);
curl_easy_setopt(curl_handle, CURLOPT_VERBOSE, TRUE);
curl_easy_setopt(curl_handle, CURLOPT_COOKIEJAR, cookiefile );
curl_easy_setopt(curl_handle, CURLOPT_FOLLOWLOCATION , 1);
curl_easy_setopt(curl_handle, CURLOPT_MAXREDIRS , 5);
curl_easy_setopt(curl_handle, CURLOPT_TIMEOUT , timeoutsec );
curl_easy_setopt(curl_handle, CURLOPT_USERAGENT, c_user_agent );
curl_easy_setopt(curl_handle, CURLOPT_FILE, outfile);
if (curl_easy_perform(curl_handle)==CURLE_OK) {
fclose(outfile);
QFile filecurl(www_net_file);
if (filecurl.size() > 5) {
curlerrormsg = "ok_success";
} else {
curlerrormsg = "Error time out to get remote file"+QString( "%1" ).arg( getExactTime() );
}
} else {
curlerrormsg = "Error time out to get remote file"+QString( "%1" ).arg( getExactTime() );
file_put_contents(www_net_file,"");
}
}
/* return grab result from local file */
return file_get_contents(www_net_file);
}
/* ok is a fake normal local file init ..... */
QFile file(fullFileName);
if (file.exists()) {
if (file.open(QFile::ReadOnly | QFile::Text)) {
inside =file.readAll();
file.close();
errormsg = "ok_success";
} else {
inside = "no_open_file";
}
} else {
inside = "no_file";
}
return inside;
}
To copy to clipboard, switch view to plain text mode
Bookmarks