common.pl 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. #
  2. # This file is part of the LibreOffice project.
  3. #
  4. # This Source Code Form is subject to the terms of the Mozilla Public
  5. # License, v. 2.0. If a copy of the MPL was not distributed with this
  6. # file, You can obtain one at http://mozilla.org/MPL/2.0/.
  7. #
  8. # This file incorporates work covered by the following license notice:
  9. #
  10. # Licensed to the Apache Software Foundation (ASF) under one or more
  11. # contributor license agreements. See the NOTICE file distributed
  12. # with this work for additional information regarding copyright
  13. # ownership. The ASF licenses this file to you under the Apache
  14. # License, Version 2.0 (the "License"); you may not use this file
  15. # except in compliance with the License. You may obtain a copy of
  16. # the License at http://www.apache.org/licenses/LICENSE-2.0 .
  17. #
  18. package common;
  19. $REFRESH_TIME = 5;
  20. sub File_read
  21. {
  22. $sFilename = @_[ 0 ];
  23. @aFileContentList = "";
  24. open( F_CURRPIC, "<" . $sFilename ) || "Could not open file " . $sFilename . " !<BR>\n";
  25. while( <F_CURRPIC> )
  26. {
  27. push( @aFileContentList, $_ );
  28. }
  29. close( F_CURRPIC );
  30. return @aFileContentList;
  31. } ##File_read
  32. sub HTTP_getRequest
  33. {
  34. # post- or get- method ?
  35. if( $ENV{ 'REQUEST_METHOD' } eq 'GET' )
  36. {
  37. # get parameters from querystring (get)
  38. $sRequest = $ENV{ 'QUERY_STRING' }
  39. }
  40. else
  41. {
  42. # get parameters from stdin (post)
  43. read( STDIN, $sRequest, $ENV{ 'CONTENT_LENGTH' } );
  44. }
  45. # process parameters
  46. @aRequestList = split( /&/, $sRequest );
  47. foreach $Feld ( @aRequestList )
  48. {
  49. ( $name, $sValue ) = split( /=/, $Feld );
  50. $sValue =~ tr/+/ /;
  51. $sValue =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg;
  52. $sValue =~ s/<!--(.|\n)*-->//g;
  53. $aRequestMap{ $name } = $sValue;
  54. }
  55. return %aRequestMap;
  56. } ##HTTP_getRequest
  57. 1;