Fixed GitHub API rate limit

For Theme Updater
This commit is contained in:
Julian Prieber 2022-09-13 21:04:17 +02:00
parent 1c6f9d1746
commit 4c8f8283d9
2 changed files with 16 additions and 12 deletions

View File

@ -390,16 +390,18 @@ class AdminController extends Controller
preg_match($pattern, $text, $matches, PREG_OFFSET_CAPTURE); preg_match($pattern, $text, $matches, PREG_OFFSET_CAPTURE);
$sourceURL = substr($matches[0][0],13); $sourceURL = substr($matches[0][0],13);
$replaced = str_replace("https://github.com/", "https://api.github.com/repos/", trim($sourceURL)); $replaced = str_replace("https://github.com/", "https://raw.githubusercontent.com/", trim($sourceURL));
$replaced = $replaced . "/releases/latest"; $replaced = $replaced . "/main/readme.md";
if (strpos($sourceURL, 'github.com')){ if (strpos($sourceURL, 'github.com')){
ini_set('user_agent', 'Mozilla/4.0 (compatible; MSIE 6.0)'); ini_set('user_agent', 'Mozilla/4.0 (compatible; MSIE 6.0)');
try{ try{
$jsont = file_get_contents($replaced); $textGit = file_get_contents($replaced);
$myObjt = json_decode($jsont); $patternGit = '/Theme Version:.*/';
$Vgitt = $myObjt->tag_name; preg_match($patternGit, $textGit, $matches, PREG_OFFSET_CAPTURE);
$sourceURLGit = substr($matches[0][0],15);
$Vgitt = 'v' . $sourceURLGit;
$verNrv = 'v' . $verNr; $verNrv = 'v' . $verNr;
}catch(Exception $ex){ }catch(Exception $ex){
$themeVe = "error"; $themeVe = "error";
@ -410,7 +412,7 @@ class AdminController extends Controller
if(trim($Vgitt) > trim($verNrv)){ if(trim($Vgitt) > trim($verNrv)){
$fileUrl = trim($sourceURL) . '/archive/refs/tags/' . trim($verNrv) . '.zip'; $fileUrl = trim($sourceURL) . '/archive/refs/tags/' . trim($Vgitt) . '.zip';
file_put_contents(base_path('themes/theme.zip'), fopen($fileUrl, 'r')); file_put_contents(base_path('themes/theme.zip'), fopen($fileUrl, 'r'));

View File

@ -156,16 +156,18 @@ table, th, td {
preg_match($pattern, $text, $matches, PREG_OFFSET_CAPTURE); preg_match($pattern, $text, $matches, PREG_OFFSET_CAPTURE);
$sourceURL = substr($matches[0][0],13); $sourceURL = substr($matches[0][0],13);
$replaced = str_replace("https://github.com/", "https://api.github.com/repos/", trim($sourceURL)); $replaced = str_replace("https://github.com/", "https://raw.githubusercontent.com/", trim($sourceURL));
$replaced = $replaced . "/releases/latest"; $replaced = $replaced . "/main/readme.md";
if (strpos($sourceURL, 'github.com')){ if (strpos($sourceURL, 'github.com')){
ini_set('user_agent', 'Mozilla/4.0 (compatible; MSIE 6.0)'); ini_set('user_agent', 'Mozilla/4.0 (compatible; MSIE 6.0)');
try{ try{
$jsont = file_get_contents($replaced); $textGit = file_get_contents($replaced);
$myObjt = json_decode($jsont); $patternGit = '/Theme Version:.*/';
$Vgitt = $myObjt->tag_name; preg_match($patternGit, $textGit, $matches, PREG_OFFSET_CAPTURE);
$sourceURLGit = substr($matches[0][0],15);
$Vgitt = 'v' . $sourceURLGit;
$verNrv = 'v' . $verNr; $verNrv = 'v' . $verNr;
}catch(Exception $ex){ }catch(Exception $ex){
$themeVe = "error"; $themeVe = "error";