Verzeichnisstruktur phpBB-3.3.15


Veröffentlicht
28.08.2024

So funktioniert es


Auf das letzte Element klicken. Dies geht jeweils ein Schritt zurück

Auf das Icon klicken, dies öffnet das Verzeichnis. Nochmal klicken schließt das Verzeichnis.
Auf den Verzeichnisnamen klicken, dies zeigt nur das Verzeichnis mit Inhalt an

(Beispiel Datei-Icons)

Auf das Icon klicken um den Quellcode anzuzeigen

Curl.php

Zuletzt modifiziert: 02.04.2025, 15:04 - Dateigröße: 2.08 KiB


01  <?php
02   
03  /**
04  * @package   s9e\TextFormatter
05  * @copyright Copyright (c) 2010-2022 The s9e authors
06  * @license   http://www.opensource.org/licenses/mit-license.php The MIT License
07  */
08  namespace s9e\TextFormatter\Utils\Http\Clients;
09   
10  use s9e\TextFormatter\Utils\Http\Client;
11   
12  class Curl extends Client
13  {
14      /**
15      * @var resource cURL handle, shared across instances
16      */
17      protected static $handle;
18   
19      /**
20      * {@inheritdoc}
21      */
22      public function get($url, array $options = [])
23      {
24          $options += ['headers' => []];
25   
26          $handle = $this->getHandle();
27          curl_setopt($handle, CURLOPT_HEADER,     !empty($options['returnHeaders']));
28          curl_setopt($handle, CURLOPT_HTTPGET,    true);
29          curl_setopt($handle, CURLOPT_HTTPHEADER, $options['headers']);
30          curl_setopt($handle, CURLOPT_URL,        $url);
31   
32          return curl_exec($handle);
33      }
34   
35      /**
36      * {@inheritdoc}
37      */
38      public function post($url, array $options = [], $body = '')
39      {
40          $options             += ['headers' => []];
41          $options['headers'][] = 'Content-Length: ' . strlen($body);
42   
43          $handle = $this->getHandle();
44          curl_setopt($handle, CURLOPT_HEADER,     !empty($options['returnHeaders']));
45          curl_setopt($handle, CURLOPT_HTTPHEADER, $options['headers']);
46          curl_setopt($handle, CURLOPT_POST,       true);
47          curl_setopt($handle, CURLOPT_POSTFIELDS, $body);
48          curl_setopt($handle, CURLOPT_URL,        $url);
49   
50          return curl_exec($handle);
51      }
52   
53      /**
54      * Return a globally cached cURL handle, configured for current instance
55      *
56      * @return resource
57      */
58      protected function getHandle()
59      {
60          if (!isset(self::$handle))
61          {
62              self::$handle = $this->getNewHandle();
63          }
64   
65          curl_setopt(self::$handle, CURLOPT_SSL_VERIFYPEER, $this->sslVerifyPeer);
66          curl_setopt(self::$handle, CURLOPT_TIMEOUT,        $this->timeout);
67   
68          return self::$handle;
69      }
70   
71      /**
72      * Create and return a new cURL handle
73      *
74      * @return resource
75      */
76      protected function getNewHandle()
77      {
78          $handle = curl_init();
79          curl_setopt($handle, CURLOPT_ENCODING,       '');
80          curl_setopt($handle, CURLOPT_FAILONERROR,    true);
81          curl_setopt($handle, CURLOPT_FOLLOWLOCATION, true);
82          curl_setopt($handle, CURLOPT_RETURNTRANSFER, true);
83   
84          return $handle;
85      }
86  }