Ejemplo n.º 1
0
/*****************************************************************************
 * Function - doGetCGI
 * DESCRIPTION: HTTP GET with URL /get.cgi
 ****************************************************************************/
void WebIfHandler::doGetCGI(HttpRequest& req, HttpResponse& res)
{
  if (req.HasParam("io_status"))
  {
    res.StartHTMLContent();
    
    if (req.GetParam("io_status", "").compare("iob") == 0)
    {
      res << "<h2>IOB</h2><i>Status not implemented!</i>";
    }
    else if (req.GetParam("io_status", "").compare("io351iomodules") == 0)
    {
      for (int i = 0; i < sizeof(m_pIO351IOModules) / sizeof(m_pIO351IOModules[0]); i++)
      {
        if (i)
        {
          res << "<br/>";
        }
        
        res << "<h2>IO351 IO Module #" << (i + 1) << " Status</h2>";
        if (m_pIO351IOModules[i])
          m_pIO351IOModules[i]->webifMakeStatusHtml(res);
        else
          res << "<i>Pointer to IO351 IO Module not set!</i>";
      }
    }
    else
    {
      res << "<b>Unhandled io_status=" << req.GetParam("io_status", "") << "</b>";
    }
  }

  // firmware_update.html
  if (req.HasParam("firmware_update"))
  {
    res.StartHTMLContent();

    if (req.GetParam("firmware_update", "").compare("status") == 0)
    {
      FirmwareUpdateCtrl::GetInstance()->webifMakeStatus(res);
    }
    else
    {
      res << "<b>Unhandled firmware_update=" << req.GetParam("firmware_update", "") << "</b>";
    }
  }
}
Ejemplo n.º 2
0
/*****************************************************************************
 * Function - doPostCGI
 * DESCRIPTION: HTTP POST with URL /post.cgi (HTML form)
 ****************************************************************************/
void WebIfHandler::doPostCGI(const char* szFormID, HttpRequest& req, HttpResponse& res)
{
  if (strcmp(szFormID, "ip_config") == 0)
  {
    res.StartHTMLContent();
    
    res << "<html><head><title>Please wait...</title>";
    res << IPConfigByWeb::getInstance()->webifPostNewConfig(
      req.HasParam("dhcp_enabled"),
      req.GetParam("hostname", "").c_str(),
      req.GetParam("ip_address", "").c_str(),
      req.GetParam("subnet_mask", "").c_str(),
      req.GetParam("default_gateway", "").c_str(),
      req.GetParam("primary_dns", "").c_str(),
      req.GetParam("secondary_dns", "").c_str()
    );
    res << "</head><body><i>Please wait...</i></body></html>";
  }
  else if (strcmp(szFormID, "pw_config") == 0)
  {
    res.SendRedirect(PasswordSetting::getInstance()->webifPostNewConfig(
      req.GetParam("existing_password", "").c_str(),
      req.GetParam("new_password", "").c_str(),
      req.GetParam("repeated_password", "").c_str()
    ).c_str());
  }
  else if (strcmp(szFormID, "iostatus") == 0)
  {
    if (m_pIO351IOModules[0])
      m_pIO351IOModules[0]->webifSetNoOfIOModules(req.GetParam("no_of_io_modules", 0, 10, 0));
    res.SendRedirect("/iostatus.html");
  }
  // firmware_update.html
  else if (strcmp(szFormID, "firmware_update") == 0)
  {
    FirmwareUpdateCtrl::GetInstance()->webifDoPost(req);
    res.SendRedirect("/firmware_update.html");
  }
}