Subversion Repositories oidplus

Rev

Rev 597 | Blame | Compare with Previous | Last modification | View Log | RSS feed

  1. <?php
  2.  
  3. /*
  4.  * OIDplus 2.0
  5.  * Copyright 2019 - 2021 Daniel Marschall, ViaThinkSoft
  6.  *
  7.  * Licensed under the Apache License, Version 2.0 (the "License");
  8.  * you may not use this file except in compliance with the License.
  9.  * 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, software
  14.  * distributed under the License is distributed on an "AS IS" BASIS,
  15.  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  16.  * See the License for the specific language governing permissions and
  17.  * limitations under the License.
  18.  */
  19.  
  20. $url = 'https://www.viathinksoft.de/';
  21.  
  22. if (!function_exists("curl_init")) {
  23.         echo '<p><font color="red">CURL not installed!</font></p>';
  24.         die();
  25. }
  26.  
  27. $ch = curl_init();
  28. if (ini_get('curl.cainfo') == '') {
  29.         if (file_exists(__DIR__.'/../vendor/cacert.pem')) {
  30.                 curl_setopt($ch, CURLOPT_CAINFO, __DIR__.'/../vendor/cacert.pem');
  31.                 echo '<p>Loaded fallback CURLOPT_CAINFO from OIDplus</p>';
  32.         }
  33.         else if (file_exists(__DIR__.'/vendor/cacert.pem')) {
  34.                 curl_setopt($ch, CURLOPT_CAINFO, __DIR__.'/vendor/cacert.pem');
  35.                 echo '<p>Loaded fallback CURLOPT_CAINFO from OIDplus</p>';
  36.         } else {
  37.                 echo '<p><font color="red">curl.cainfo is missing and fallback certificates (vendor/cacert.pem) not found</font></p>';
  38.         }
  39. }
  40. curl_setopt($ch, CURLOPT_URL, $url);
  41. curl_setopt($ch, CURLOPT_USERAGENT, 'ViaThinkSoft-OIDplus/2.0');
  42. curl_setopt($ch, CURLOPT_HEADER, TRUE);
  43. curl_setopt($ch, CURLOPT_NOBODY, TRUE); // remove body
  44. curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);
  45. $head = curl_exec($ch);
  46. $httpCode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
  47. curl_close($ch);
  48.  
  49. if ($httpCode != 0) {
  50.         echo '<p><font color="green">CURL to HTTPS works!</font></p>';
  51. } else {
  52.         echo '<p><font color="red">CURL to HTTPS does not work!</font></p>';
  53. }
  54.