PluginProbe
Bit Form – Contact Form, Payment Forms, Multi Step Forms, Calculator & Custom Form Builder / 2.15.3
Bit Form – Contact Form, Payment Forms, Multi Step Forms, Calculator & Custom Form Builder v2.15.3
3.3.1 V-3.3.0 3.2.2 3.2.1 3.2.0 3.1.4 3.1.3 3.1.2 3.1.1 3.1.0 V3.0.3 V3.0.2 -3.0.1 V_3.0.0 1.1.1 1.1.8 1.2 1.3 1.4 1.4.18 1.5.2 1.9 2.0 2.10.0 2.10.1 All 138 releases
← All changes | includes/Core/Integration/Telegram/FilesApiHelper.php +14 -4 2.10.02.15.3 View file →
@@ -37,9 +37,11 @@
37 37 * @return array $uploadResponse Telegram API response
38 38 */
39 39 public function uploadFiles($apiEndPoint, $data)
40 40 {
41 - $mimeType = mime_content_type("{$this->_basepath}{$data['photo']}");
41 + $filename = $this->getFileNameWithExtension($data['photo']) ?? $data['photo'];
42 + $filePath = "{$this->_basepath}{$filename}";
43 + $mimeType = mime_content_type($filePath);
42 44 $fileType = \explode('/', $mimeType);
43 45
44 46 switch ($fileType[0]) {
45 47 case 'image':
@@ -62,9 +64,9 @@
62 64 break;
63 65 }
64 66 $uploadFileEndpoint = $apiEndPoint . $apiMethod;
65 67
66 - $data[$param] = new \CURLFILE("{$this->_basepath}{$data['photo']}");
68 + $data[$param] = new \CURLFILE($filePath);
67 69 if ('photo' !== $param) {
68 70 unset($data['photo']);
69 71 }
70 72 $curl = curl_init();
@@ -98,9 +100,11 @@
98 100 'caption' => $data['caption']
99 101 ];
100 102
101 103 foreach ($data['media'] as $key => $value) {
102 - $mimeType = mime_content_type("{$this->_basepath}{$value}");
104 + $filename = $this->getFileNameWithExtension($value) ?? $value;
105 + $filePath = "{$this->_basepath}{$filename}";
106 + $mimeType = mime_content_type($filePath);
103 107 $fileType = \explode('/', $mimeType);
104 108 unset($data['media'][$key]);
105 109
106 110 if ('image' === $fileType[0]) {
@@ -119,9 +123,9 @@
119 123 'caption' => $data['caption'],
120 124 'parse_mode' => 'HTML'
121 125 ];
122 126 $nameK = "{$key}.path";
123 - $postFields[$nameK] = new \CURLFILE("{$this->_basepath}{$value}");
127 + $postFields[$nameK] = new \CURLFILE($filePath);
124 128 }
125 129 $postFields['media'] = wp_json_encode($media);
126 130
127 131 if ('media' !== $param) {
@@ -149,6 +153,12 @@
149 153
150 154 $uploadResponse = curl_exec($curl);
151 155 curl_close($curl);
152 156 return $uploadResponse;
157 + }
158 +
159 + private function getFileNameWithExtension($url)
160 + {
161 + $fileName = basename($url);
162 + return false !== strpos($fileName, '.') ? $fileName : null;
153 163 }
154 164 }