xref: /aoo41x/main/sd/res/webview/common.pl (revision bb113e63)
1# *************************************************************
2#
3#  Licensed to the Apache Software Foundation (ASF) under one
4#  or more contributor license agreements.  See the NOTICE file
5#  distributed with this work for additional information
6#  regarding copyright ownership.  The ASF licenses this file
7#  to you under the Apache License, Version 2.0 (the
8#  "License"); you may not use this file except in compliance
9#  with the License.  You may obtain a copy of the License at
10#
11#    http://www.apache.org/licenses/LICENSE-2.0
12#
13#  Unless required by applicable law or agreed to in writing,
14#  software distributed under the License is distributed on an
15#  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16#  KIND, either express or implied.  See the License for the
17#  specific language governing permissions and limitations
18#  under the License.
19#
20# *************************************************************
21package common;
22
23$REFRESH_TIME = 5;
24
25sub File_read
26{
27    $sFilename = @_[ 0 ];
28
29    @aFileContentList = "";
30    open( F_CURRPIC, "<" . $sFilename ) || "Could not open file " . $sFilename . " !<BR>\n";
31    while( <F_CURRPIC> )
32    {
33        push( @aFileContentList, $_ );
34    }
35    close( F_CURRPIC );
36
37    return @aFileContentList;
38}   ##File_read
39
40
41sub HTTP_getRequest
42{
43    # post- or get- method ?
44    if( $ENV{ 'REQUEST_METHOD' } eq 'GET' )
45    {
46        # get parameters from querystring (get)
47        $sRequest = $ENV{ 'QUERY_STRING' }
48    }
49    else
50    {
51        # get parameters from stdin (post)
52        read( STDIN, $sRequest, $ENV{ 'CONTENT_LENGTH' } );
53    }
54    # process parameters
55    @aRequestList = split( /&/, $sRequest );
56    foreach $Feld ( @aRequestList )
57    {
58        ( $name, $sValue ) = split( /=/, $Feld );
59        $sValue =~ tr/+/ /;
60        $sValue =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg;
61        $sValue =~ s/<!--(.|\n)*-->//g;
62        $aRequestMap{ $name } = $sValue;
63    }
64
65    return %aRequestMap;
66}   ##HTTP_getRequest
67
681;
69