AJAX: Difference between revisions

From MidasWiki
Jump to navigation Jump to search
Line 3: Line 3:
This page will document the MIDAS AJAX functions accessible through special the mhttpd URLs.
This page will document the MIDAS AJAX functions accessible through special the mhttpd URLs.


= Audit of URI encoding =
= Note on URL encoding =


Failed:
All parameter names and parameter values (?name=value) are passed through urlDecode.


* jkey: "?odb=" not encoded
* BUG: value of parameter "format" is not passed through urlDecode (git commit db4602dc2ed63674413f92cc92f49f183bd14225, 21 Aug 2013), this is consistent with mhttpd.js which does not urlEncode the values.
* jgenmsg: "?msg=" not encoded
 
Ok:
 
* jalm
* jmsg


= jset =
= jset =

Revision as of 09:21, 21 August 2013

About

This page will document the MIDAS AJAX functions accessible through special the mhttpd URLs.

Note on URL encoding

All parameter names and parameter values (?name=value) are passed through urlDecode.

  • BUG: value of parameter "format" is not passed through urlDecode (git commit db4602dc2ed63674413f92cc92f49f183bd14225, 21 Aug 2013), this is consistent with mhttpd.js which does not urlEncode the values.

jset

  • JSONP: no
  • parameters:
    • ?pnam=xxx - cookie_cpwd to match value of ODB /Custon/Pwd/xxx. How is this supposed to work??? How to use it???
      if (*getparam("pnam")) {
         sprintf(ppath, "/Custom/Pwd/%s", getparam("pnam"));
         str[0] = 0;
         db_get_value(hDB, 0, ppath, str, &size, TID_STRING, TRUE);
         if (!equal_ustring(cookie_cpwd, str)) {
            show_text_header();
            rsprintf("Invalid password!");
            return;
         }
      }
    • ?odb=ODB path
    • ?value=data
    • ?type=integer - if ODB path does not exist, it is created, with "type" MIDAS TID_xxx data type
    • ?len=integer - when ODB path is created, if "len" is not zero, it is made an array of "len" size, with all values set to "value". Except if "type" is TID_STRING, there is no array created, but "len" is used as the ODB string length.
  • ODB path encoding for arrays:
    • /path/array[i] - write array element [i]
    • /path/array - write array element [0]
    • /path/array[*] - write as many array elements as there are comma-separated values in data
  • example: TBW

jget

TBW

jcopy

TBW

jkey

  • JSONP: no
  • parameters:
    • ?odb=ODB path
  • returns:
   if (equal_ustring(getparam("cmd"), "jkey")) {
      show_text_header();
      if (isparam("odb") && db_find_key(hDB, 0, getparam("odb"), &hkey) == DB_SUCCESS) {
         db_get_key(hDB, hkey, &key);
         rsprintf("%s\n", key.name);
         rsprintf("TID_%s\n", rpc_tid_name(key.type));
         rsprintf("%d\n", key.num_values);
         rsprintf("%d\n", key.item_size);
         rsprintf("%d", key.last_written);
      } else
         rsputs("<DB_NO_KEY>");
      return;
   }
  • example: TBW

jmsg

  • JSONP: no
  • parameters:
    • ?n=number of messages to return
  • returns: output of cm_msg_retrieve()
   if (equal_ustring(getparam("cmd"), "jmsg")) {
      i = 1;
      if (*getparam("n"))
         i = atoi(getparam("n"));
      
      show_text_header();
      cm_msg_retrieve(i, str, sizeof(str));
      rsputs(str);
      return;
   }
  • example: TBW

jgenmsg

  • JSONP: no
  • parameters:
    • ?msg=message text
  • returns: ???
   if (equal_ustring(getparam("cmd"), "jalm")) {
      show_text_header();
      al_get_alarms(str, sizeof(str));
      rsputs(str);
      return;
   }
  • example: TBW

jalm

  • JSONP: no
  • parameters: no
  • returns: text from al_get_alarms()
   if (equal_ustring(getparam("cmd"), "jalm")) {
      show_text_header();
      al_get_alarms(str, sizeof(str));
      rsputs(str);
      return;
   }
  • example: TBW