inventory.cgi 1022 B

123456789101112131415161718192021222324252627282930313233343536373839
  1. #!/usr/bin/perl -w
  2. use strict;
  3. use MyCGI;
  4. use OpenSim::Config;
  5. use OpenSim::InventoryServer;
  6. use Carp;
  7. my $request_uri = $ENV{REQUEST_URI} || Carp::croak($OpenSim::Config::SYS_MSG{FATAL});
  8. my $request_method = "";
  9. if ($request_uri =~ /([^\/]+)\/$/) {
  10. $request_method = $1;
  11. } else {
  12. &MyCGI::outputXml("utf-8", $OpenSim::Config::SYS_MSG{FATAL});
  13. }
  14. my $param = &MyCGI::getParam();
  15. my $post_data = $param->{'POSTDATA'};
  16. &OpenSim::Utility::Log("inv", "request", $request_uri, $post_data);
  17. my $response = "";
  18. eval {
  19. $response = &handleRequest($request_method, $post_data);
  20. };
  21. if ($@) {
  22. $response = "<ERROR>$@</ERROR>";
  23. }
  24. &OpenSim::Utility::Log("inv", "response", $response);
  25. &MyCGI::outputXml("utf-8", $response);
  26. sub handleRequest {
  27. my ($methodname, $post_data) = @_;
  28. my $handler_list = &OpenSim::InventoryServer::getHandlerList();
  29. if (!$handler_list->{$methodname}) {
  30. Carp::croak("unknown method name");
  31. } else {
  32. my $handler = $handler_list->{$methodname};
  33. return $handler->($post_data);
  34. }
  35. }