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);
$sourceURL = substr($matches[0][0],13);
$replaced = str_replace("https://github.com/", "https://api.github.com/repos/", trim($sourceURL));
$replaced = $replaced . "/releases/latest";
$replaced = str_replace("https://github.com/", "https://raw.githubusercontent.com/", trim($sourceURL));
$replaced = $replaced . "/main/readme.md";
if (strpos($sourceURL, 'github.com')){
ini_set('user_agent', 'Mozilla/4.0 (compatible; MSIE 6.0)');
try{
$jsont = file_get_contents($replaced);
$myObjt = json_decode($jsont);
$Vgitt = $myObjt->tag_name;
$textGit = file_get_contents($replaced);
$patternGit = '/Theme Version:.*/';
preg_match($patternGit, $textGit, $matches, PREG_OFFSET_CAPTURE);
$sourceURLGit = substr($matches[0][0],15);
$Vgitt = 'v' . $sourceURLGit;
$verNrv = 'v' . $verNr;
}catch(Exception $ex){
$themeVe = "error";
@ -410,7 +412,7 @@ class AdminController extends Controller
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'));

View File

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