using Http::getData instead file_get_contents

This commit is contained in:
Ibnu Maksum 2023-09-11 14:26:58 +07:00
parent c57bbeace3
commit b5ddf37649
No known key found for this signature in database
GPG Key ID: 7FC82848810579E5
3 changed files with 5 additions and 5 deletions

View File

@ -6,7 +6,7 @@
class Http class Http
{ {
public static function getData($url, $headers) public static function getData($url, $headers = [])
{ {
$ch = curl_init(); $ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url); curl_setopt($ch, CURLOPT_URL, $url);

View File

@ -12,7 +12,7 @@ class Message
global $config; global $config;
run_hook('send_telegram'); #HOOK run_hook('send_telegram'); #HOOK
if (!empty($config['telegram_bot']) && !empty($config['telegram_target_id'])) { if (!empty($config['telegram_bot']) && !empty($config['telegram_target_id'])) {
file_get_contents('https://api.telegram.org/bot' . $config['telegram_bot'] . '/sendMessage?chat_id=' . $config['telegram_target_id'] . '&text=' . urlencode($txt)); Http::getData('https://api.telegram.org/bot' . $config['telegram_bot'] . '/sendMessage?chat_id=' . $config['telegram_target_id'] . '&text=' . urlencode($txt));
} }
} }
@ -24,7 +24,7 @@ class Message
if (!empty($config['sms_url'])) { if (!empty($config['sms_url'])) {
$smsurl = str_replace('[number]', urlencode($phone), $config['sms_url']); $smsurl = str_replace('[number]', urlencode($phone), $config['sms_url']);
$smsurl = str_replace('[text]', urlencode($txt), $smsurl); $smsurl = str_replace('[text]', urlencode($txt), $smsurl);
file_get_contents($smsurl); Http::getData($smsurl);
} }
} }
@ -35,7 +35,7 @@ class Message
if (!empty($config['wa_url'])) { if (!empty($config['wa_url'])) {
$waurl = str_replace('[number]', urlencode($phone), $config['wa_url']); $waurl = str_replace('[number]', urlencode($phone), $config['wa_url']);
$waurl = str_replace('[text]', urlencode($txt), $waurl); $waurl = str_replace('[text]', urlencode($txt), $waurl);
file_get_contents($waurl); Http::getData($waurl);
} }
} }

View File

@ -23,7 +23,7 @@ $cache = File::pathFixer('system/cache/plugin_repository.json');
if (file_exists($cache) && time() - filemtime($cache) < (24 * 60 * 60)) { if (file_exists($cache) && time() - filemtime($cache) < (24 * 60 * 60)) {
$json = json_decode(file_get_contents($cache), true); $json = json_decode(file_get_contents($cache), true);
} else { } else {
$data = file_get_contents($plugin_repository); $data = Http::getData($plugin_repository);
file_put_contents($cache, $data); file_put_contents($cache, $data);
$json = json_decode($data, true); $json = json_decode($data, true);
} }