@@ -1648,14 +1648,38 @@ function showSection(sectionId) {
16481648 $ versionFile = __DIR__ . '/../VERSION ' ;
16491649 $ version = file_exists ($ versionFile ) ? trim (file_get_contents ($ versionFile )) : null ;
16501650 if ($ version ):
1651+ // Check for newer version (cached, checks GitHub API once per hour)
1652+ $ latestVersion = null ;
1653+ $ cacheFile = __DIR__ . '/../.version-cache ' ;
1654+ $ cacheMaxAge = 3600 ; // 1 hour
1655+
1656+ if (file_exists ($ cacheFile ) && (time () - filemtime ($ cacheFile )) < $ cacheMaxAge ) {
1657+ $ latestVersion = trim (file_get_contents ($ cacheFile ));
1658+ } else {
1659+ // Fetch latest version from GitHub API
1660+ $ ch = curl_init ('https://api.github.com/repos/kibotu/SlimStorage/releases/latest ' );
1661+ curl_setopt ($ ch , CURLOPT_RETURNTRANSFER , true );
1662+ curl_setopt ($ ch , CURLOPT_USERAGENT , 'SlimStorage ' );
1663+ curl_setopt ($ ch , CURLOPT_TIMEOUT , 5 );
1664+ curl_setopt ($ ch , CURLOPT_CONNECTTIMEOUT , 3 );
1665+ $ response = curl_exec ($ ch );
1666+ $ httpCode = curl_getinfo ($ ch , CURLINFO_HTTP_CODE );
1667+ curl_close ($ ch );
1668+
1669+ if ($ httpCode === 200 && $ response ) {
1670+ $ data = json_decode ($ response , true );
1671+ if (!empty ($ data ['tag_name ' ])) {
1672+ $ latestVersion = $ data ['tag_name ' ];
1673+ @file_put_contents ($ cacheFile , $ latestVersion );
1674+ }
1675+ }
1676+ }
1677+
1678+ $ hasUpdate = $ latestVersion && version_compare (ltrim ($ latestVersion , 'v ' ), ltrim ($ version , 'v ' ), '> ' );
16511679 ?>
1652- <span class="version"><?= htmlspecialchars ($ version ) ?> </span>
1680+ <span class="version"><?= htmlspecialchars ($ version ) ?> <?php if ( $ hasUpdate ): ?> <a href="https://github.com/kibotu/SlimStorage/releases/latest" target="_blank" rel="noopener" style="color: #10b981;">( <?= htmlspecialchars ( $ latestVersion ) ?> available)</a> <?php endif ; ?> < /span>
16531681 <?php endif ; ?>
16541682 <span class="separator">•</span>
1655- <a href="https://github.com/kibotu/SlimStorage" target="_blank" rel="noopener">
1656- GitHub
1657- </a>
1658- <span class="separator">•</span>
16591683 <a href="https://github.com/kibotu/SlimStorage/issues" target="_blank" rel="noopener">
16601684 Report Issue
16611685 </a>
0 commit comments