diff --git a/app/Http/Controllers/AdminController.php b/app/Http/Controllers/AdminController.php index c926956..cce0c96 100755 --- a/app/Http/Controllers/AdminController.php +++ b/app/Http/Controllers/AdminController.php @@ -390,17 +390,19 @@ 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; - $verNrv = 'v' . $verNr; + $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"; $Vgitt = NULL; @@ -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')); diff --git a/resources/views/studio/theme.blade.php b/resources/views/studio/theme.blade.php index 26b4142..d37e909 100644 --- a/resources/views/studio/theme.blade.php +++ b/resources/views/studio/theme.blade.php @@ -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";