Skip to content

Commit 2329d83

Browse files
committed
Added new helper function
Added new helper function to replace file_get_contents with curl.
1 parent ab15571 commit 2329d83

File tree

2 files changed

+15
-1
lines changed

2 files changed

+15
-1
lines changed

app/Functions/externalfiles.php

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
<?php
2+
3+
function external_file_get_contents($url) {
4+
$ch = curl_init();
5+
curl_setopt($ch, CURLOPT_URL, $url);
6+
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
7+
curl_setopt($ch, CURLOPT_HEADER, false);
8+
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
9+
curl_setopt($ch, CURLOPT_USERAGENT, 'Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:80.0) Gecko/20100101 Firefox/80.0');
10+
$data = curl_exec($ch);
11+
curl_close($ch);
12+
return $data;
13+
}

composer.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,8 @@
3131
},
3232
"autoload": {
3333
"files": [
34-
"app/Functions/findfile.php"
34+
"app/Functions/findfile.php",
35+
"app/Functions/externalfiles.php"
3536
],
3637
"psr-4": {
3738
"App\\": "app/",

0 commit comments

Comments
 (0)