}
}
+float curl_uri_get_pos;
+float curl_uri_get_exec[URI_GET_CURL_END - URI_GET_CURL + 1];
+string curl_uri_get_cvar[URI_GET_CURL_END - URI_GET_CURL + 1];
+void Curl_URI_Get_Callback(float id, float status, string data)
+{
+ float i;
+ float do_exec;
+ string do_cvar;
+ i = id - URI_GET_CURL;
+ do_exec = curl_uri_get_exec[i];
+ do_cvar = curl_uri_get_cvar[i];
+ if(status != 0)
+ {
+ print("error: status is ", ftos(status), "\n");
+ return;
+ }
+ if(do_exec)
+ localcmd(data);
+ if(do_cvar)
+ cvar_set(do_cvar, data);
+ if(!do_exec && !do_cvar)
+ print(data);
+}
+
void GameCommand(string theCommand)
{
float argc;
return;
}
+ if(argv(0) == "curl")
+ {
+ float do_exec;
+ string do_cvar;
+ float key;
+ float i, j;
+ string url;
+ float buf;
+
+ do_exec = FALSE;
+ do_cvar = string_null;
+ key = -1;
+
+ for(i = 1; i+1 < argc; ++i)
+ {
+ if(argv(i) == "--cvar" && i+2 < argc)
+ {
+ ++i;
+ do_cvar = argv(i);
+ ++i;
+ continue;
+ }
+ if(argv(i) == "--exec")
+ {
+ do_exec = TRUE;
+ ++i;
+ continue;
+ }
+ if(argv(i) == "--key" && i+2 < argc)
+ {
+ ++i;
+ key = stof(argv(i));
+ ++i;
+ continue;
+ }
+ break;
+ }
+
+ // now, argv(i) is the URL
+ // following args may be POST parameters
+ url = argv(i);
+ ++i;
+ buf = buf_create();
+ j = 0;
+ for(; i+1 < argc; i += 2)
+ bufstr_set(buf, ++j, sprintf("%s=%s", uri_escape(argv(i)), uri_escape(argv(i+1))));
+ if(i < argc)
+ bufstr_set(buf, ++j, sprintf("submit=%s", uri_escape(argv(i))));
+
+ if(j == 0) // no args: GET
+ crypto_uri_postbuf(url, URI_GET_CURL + curl_uri_get_pos, string_null, string_null, -1, key);
+ else // with args: POST
+ crypto_uri_postbuf(url, URI_GET_CURL + curl_uri_get_pos, "application/x-www-form-urlencoded", "&", buf, key);
+
+ curl_uri_get_pos = mod(curl_uri_get_pos + 1, URI_GET_CURL_END - URI_GET_CURL + 1);
+
+ buf_del(buf);
+
+ return;
+ }
+
#if 0
if(argv(0) == "tokentest")
{
string crypto_getkeyfp(string serveraddress) = #633; // retrieves the cached host key's CA fingerprint of a server given by IP address
string crypto_getidfp(string serveraddress) = #634; // retrieves the cached host key fingerprint of a server given by IP address
string crypto_getencryptlevel(string serveraddress) = #635; // 0 if never encrypting, 1 supported, 2 requested, 3 required, appended by list of allowed methods in order of preference ("AES128"), preceded by a space each
+float(string url, float id, string content_type, string delim, float buf, float keyid) crypto_uri_postbuf = #513;
//description:
float _Nex_ExtResponseSystem_Queried;
string _Nex_ExtResponseSystem_UpdateTo;
-float URI_GET_DISCARD = 0;
-
-float URI_GET_UPDATENOTIFICATION = 1;
-void UpdateNotification_URI_Get_Callback(float id, float status, string data);
-
void URI_Get_Callback(float id, float status, string data)
{
if (id == URI_GET_DISCARD)
}
else if(id == URI_GET_UPDATENOTIFICATION)
{
- // online ban list
UpdateNotification_URI_Get_Callback(id, status, data);
}
+ else if(id >= URI_GET_CURL && id <= URI_GET_CURL_END)
+ {
+ Curl_URI_Get_Callback(id, status, data);
+ }
else
{
print("Received HTTP request data for an invalid id ", ftos(id), ".\n");
string resolvemod(string m);
string HUD_Panel_GetSettingName(float setting);
+
+float URI_GET_DISCARD = 0;
+
+float URI_GET_UPDATENOTIFICATION = 1;
+void UpdateNotification_URI_Get_Callback(float id, float status, string data);
+
+float URI_GET_CURL = 2;
+float URI_GET_CURL_END = 9;
+void Curl_URI_Get_Callback(float id, float status, string data);
+
+void URI_Get_Callback(float id, float status, string data);