From 12fe9c56af8a6562ee9c90a341a992a4c4ff5805 Mon Sep 17 00:00:00 2001 From: yvesf Date: Tue, 29 Mar 2011 15:03:26 +0200 Subject: ssl-anleitung und php-proxy --- src/site/resources/ics.php.txt | 62 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 62 insertions(+) create mode 100644 src/site/resources/ics.php.txt (limited to 'src') diff --git a/src/site/resources/ics.php.txt b/src/site/resources/ics.php.txt new file mode 100644 index 0000000..db4140b --- /dev/null +++ b/src/site/resources/ics.php.txt @@ -0,0 +1,62 @@ +. +*/ + + +$proxy_url = "https://dualical.ba-horb.de:8443/dhbwcalendar/ics"; +$curl_handler = curl_init($proxy_url); + +curl_setopt($curl_handler, CURLOPT_RETURNTRANSFER, true); +curl_setopt($curl_handler, CURLOPT_BINARYTRANSFER, true); +curl_setopt($curl_handler, CURLOPT_USERAGENT, $_SERVER['HTTP_USER_AGENT']); +curl_setopt($curl_handler, CURLOPT_WRITEFUNCTION, 'readResponse'); +curl_setopt($curl_handler, CURLOPT_HEADERFUNCTION, 'readHeaders'); +curl_setopt($curl_handler, CURLOPT_SSLVERSION, 3); +curl_setopt($curl_handler, CURLOPT_CAINFO, getcwd() . "/ics_certificate.pem"); +curl_setopt($curl_handler, CURLOPT_SSL_VERIFYPEER, 1); +curl_setopt($curl_handler, CURLOPT_VERBOSE, 0); + +function readResponse(&$curl, $string) { + echo $string; + return strlen($string); +} + +function readHeaders(&$curl, $string) { + $length = strlen($string); + if ($string !== "\r\n") { + header(rtrim($string)); + } + return $length; +} + +$headers = apache_request_headers(); +$client_headers = array(); +foreach ($headers as $header => $value) { + switch($header) { + case 'Host': + break; + default: + $client_headers[] = sprintf('%s: %s', $header, $value); + break; + } +} + +curl_setopt($curl_handler, CURLOPT_HTTPHEADER, $client_headers); +curl_exec($curl_handler); +//echo print_r(curl_getinfo($curl_handler), true); +?> -- cgit v1.2.1