source: branches/camp/camp-2_5-E/data/class/SC_Response.php @ 19341

Revision 19341, 3.5 KB checked in by Yammy, 16 years ago (diff)

LC_Page.php の getToken(), isValidToken() を
SC_Helper_Session_Ex に移行

Line 
1<?php
2class SC_Response{
3
4    /**
5     *
6     * @var HTTP_Response
7     */
8    var $http;
9    /**
10     * コンテンツタイプ
11     * Enter description here ...
12     * @var unknown_type
13     */
14    var $contentType;
15    var $body;
16    var $statuscode;
17    var $header = array();
18
19    var $statusTexts = array(
20    '100' => 'Continue',
21    '101' => 'Switching Protocols',
22    '200' => 'OK',
23    '201' => 'Created',
24    '202' => 'Accepted',
25    '203' => 'Non-Authoritative Information',
26    '204' => 'No Content',
27    '205' => 'Reset Content',
28    '206' => 'Partial Content',
29    '300' => 'Multiple Choices',
30    '301' => 'Moved Permanently',
31    '302' => 'Found',
32    '303' => 'See Other',
33    '304' => 'Not Modified',
34    '305' => 'Use Proxy',
35    '306' => '(Unused)',
36    '307' => 'Temporary Redirect',
37    '400' => 'Bad Request',
38    '401' => 'Unauthorized',
39    '402' => 'Payment Required',
40    '403' => 'Forbidden',
41    '404' => 'Not Found',
42    '405' => 'Method Not Allowed',
43    '406' => 'Not Acceptable',
44    '407' => 'Proxy Authentication Required',
45    '408' => 'Request Timeout',
46    '409' => 'Conflict',
47    '410' => 'Gone',
48    '411' => 'Length Required',
49    '412' => 'Precondition Failed',
50    '413' => 'Request Entity Too Large',
51    '414' => 'Request-URI Too Long',
52    '415' => 'Unsupported Media Type',
53    '416' => 'Requested Range Not Satisfiable',
54    '417' => 'Expectation Failed',
55    '500' => 'Internal Server Error',
56    '501' => 'Not Implemented',
57    '502' => 'Bad Gateway',
58    '503' => 'Service Unavailable',
59    '504' => 'Gateway Timeout',
60    '505' => 'HTTP Version Not Supported',
61    );
62
63
64    /**
65     *
66     * Enter description here ...
67     */
68    var $encoding;
69
70    function SC_Response(){
71    }
72
73    function response(){
74        $this->sendHeader();
75        echo $this->body;
76    }
77
78    function sendHeader(){
79        // HTTPのヘッダ
80        //        header('HTTP/1.1 '.$this->statuscode.' '.$this->statusTexts[$this->statuscode]);
81        foreach ($this->header as $name => $head){
82            header($name.': '.$head);
83        }
84    }
85
86
87    function setContentType(String $contentType){
88        $this->header['Content-Type'] = $contentType;
89    }
90
91    function setResposeBody(String $body){
92        $this->body = $body;
93    }
94
95    /* function addDateHdeader(String $name, $date){
96     *
97     * }
98     */
99
100    function addHeader(String $name, $value){
101        $this->header[$name] = $value;
102    }
103
104    function containsHeader(String $name){
105        return isset($this->header[$name]);
106    }
107
108    function sendError( $errorcode){
109        header('HTTP/1.1 '.$errorcode.' '.$this->statusTexts[$errorcode]);
110    }
111
112    function sendRedirect(String $location){
113        if (preg_match("/(" . preg_quote(SITE_URL, '/')
114                          . "|" . preg_quote(SSL_URL, '/') . ")/", $location)) {
115
116            $netURL = new Net_URL($location);
117            if (!empty($_SERVER['QUERY_STRING'])) {
118                $netURL->addRawQueryString($_SERVER['QUERY_STRING']);
119            }
120
121            $session = SC_SessionFactory::getInstance();
122            if (SC_MobileUserAgent::isMobile() || $session->useCookie() == false) {
123                $netURL->addQueryString(session_name(), session_id());
124            }
125
126            $netURL->addQueryString(TRANSACTION_ID_NAME, SC_Helper_Session_Ex::getToken());
127            header("Location: " . $netURL->getURL());
128            exit;
129        }
130        return false;
131    }
132
133    function setHeader(Array $headers){
134        $this->header = $headers;
135    }
136
137    function setStatus( $sc = 202){
138        $this->statuscode = $sc;
139    }
140
141}
Note: See TracBrowser for help on using the repository browser.