| 1 | "_GetOfficialChanges" |
1 | //SimpleUpdater v7 |
| 2 | global $tempDir, $sequenceDirection, $ignoreCacheExpiration; |
2 | //Read URL from forum and main page |
| 3 | global $officialChanges, $highestOfficialVersion, $downloadOfficialUrl; |
3 | $ReadURL = readurl("http://www.xyplorer.com/xyfc/viewtopic.php?t=4&start=0&sd=d", , , 2); |
| 4 | global $xyver, $log; |
4 | $ReadURL2 = readurl("http://www.xyplorer.com/whatsnew.php", , , 2); |
| 5 | // read the latest version from the web page |
5 | $ReadStrip = readurl("http://www.xyplorer.com/whatsnew.php", , 1, 2); //read with stripped html |
| 6 | global $latestVersion; |
| |
| 7 | sub _GetOfficialVersion; |
| |
| 8 | // read the most recent version for which we have cached change logs |
| |
| 9 | global $forceDownload, $forceReadCache; |
| |
| 10 | $forceDownload = FALSE; $forceReadCache = TRUE; |
| |
| 11 | sub _GetOfficialChangesCaching; |
| |
| 12 | $c = compare($highestOfficialVersion, $latestVersion, v); |
| |
| 13 | if ($c < 0) { |
| |
| 14 | // need to update the cache so it includes the latest version change log |
| |
| 15 | $forceDownload = TRUE; $forceReadCache = FALSE; |
| |
| 16 | sub _GetOfficialChangesCaching; |
| |
| 17 | } |
| |
| 18 | |
| |
| 19 | "_GetOfficialVersion" |
| |
| 20 | global $log; |
| |
| 21 | global $latestVersion; |
| |
| 22 | // read the download.php page for a quick check. This one is not cached. |
| |
| 23 | $html = readurl("http://www.xyplorer.com/download.php", , , 2); |
| |
| 24 | $t = writefile($log, $html, "o"); |
| |
| 25 | $html = regexreplace($html, "(\r\n|\r|\n)", " "); |
| |
| 26 | $latestVersion = regexreplace($html, ".*XYplorer (\d+?[.]\d{2}([.]\d{2,4})?).*", "$1"); |
| |
| 27 | |
6 | |
| 28 | "_GetOfficialChangesCaching" |
| |
| 29 | global $tempDir, $sequenceDirection, $ignoreCacheExpiration; |
| |
| 30 | global $officialChanges, $highestOfficialVersion, $downloadOfficialUrl; |
| |
| 31 | global $xyver, $log; |
| |
| 32 | $officialChanges = ""; |
| |
| 33 | $highestOfficialVersion = ""; |
| |
| 34 | status "Reading changelog for new official version", "progress"; |
| |
| 35 | |
7 | |
| 36 | // read the whatsnew page for release change logs (this is a long page) |
| |
| 37 | global $cache, $url, $html, $forceDownload, $forceReadCache; // _ReadCachedUrl variables |
| |
| 38 | $cache = $tempDir . "whatsnew.html"; |
8 | //Get info from XY's "What's new" page |
| 39 | $url = "http://www.xyplorer.com/whatsnew.php"; |
9 | $whatsnew= strpos($ReadURL2, "What's new in ", ,1); |
| |
10 | $maintenance= strpos($ReadURL2, "Maintenance Release ", ,1); |
| 40 | sub _ReadCachedUrl; |
11 | IF($whatsnew < $maintenance){ |
| 41 | $html = gettoken($html, 2, "stuff content here"); |
| |
| 42 | // prepend changes until we reach a version that is smaller than our current version |
| |
| 43 | $i = 1; |
12 | $newtoken="What's new in "; |
| 44 | while(TRUE) { |
13 | $newrelease= gettoken($ReadURL2, 2, $newtoken); |
| 45 | $i++; |
14 | $version= gettoken($newrelease, 1, "</h3>"); |
| 46 | $text = gettoken($html, $i, "<a name=""v"); |
15 | $log = gettoken($newrelease,1, "<a name="); |
| 47 | if ($text == "") { break; } |
| |
| 48 | $version = gettoken($text, 1, """></a>"); |
16 | $log = gettoken($log,2, "$version"); |
| 49 | if (compare($xyver, $version, v) >= 0) { |
| |
| 50 | break; |
17 | $newver=substr($version,0,-1).".0000"; |
| |
18 | $date= substr(gettoken(gettoken(gettoken(gettoken($ReadStrip, 2, "$version"),2,"Released"),1,"Maint"),1,"What"),1,12); |
| |
19 | $log= substr(gettoken(gettoken(gettoken(gettoken($ReadStrip, 2, "$version"),2,"Released"),1,"Maint"),1,"What"),13); |
| 51 | } |
20 | } |
| |
21 | ELSE{ |
| |
22 | $newtoken="Maintenance Release "; |
| |
23 | $newrelease= gettoken($ReadURL2, 2, $newtoken); |
| 52 | $changes = regexreplace($text, "^.*?(\d.*</a>).*$", ""); |
24 | $version= gettoken($newrelease, 1, "</h3>"); |
| 53 | $changes = regexreplace($changes, "^.*?(<h3.*?</h3>).*$", ""); |
| |
| 54 | $changes = regexreplace($changes, "^.*?(<p.*?</p>).*$", ""); |
25 | $log = gettoken($newrelease,1, "<a name="); |
| 55 | $changes = regexreplace($changes, "^.*?<div.*?>(.*)$", " * $1<br />"); |
| |
| 56 | $changes = regexreplace($changes, "^(.*)</div>$", "$1<br />"); |
26 | $log = gettoken($log,2, "$version"); |
| 57 | $changes = regexreplace($changes, "^[ ]{6}(.*)$", " $1<br />"); |
| |
| 58 | $changes = regexreplace($changes, "^(.*<br\s?/?>)<br\s?/?>.*$", "$1"); |
27 | $newver=$version; |
| |
28 | $date= substr(gettoken(gettoken(gettoken(gettoken($ReadStrip, 2, "$version"),2,"Released"),1,"Maint"),1,"What"),1,12); |
| |
29 | $log= substr(gettoken(gettoken(gettoken(gettoken($ReadStrip, 2, "$version"),2,"Released"),1,"Maint"),1,"What"),13); |
| |
30 | } |
| |
31 | $log= "v$newver - $date<br> $log <br>"; |
| |
32 | |
| |
33 | $offver =$newver; |
| 59 | |
34 | |
| 60 | $text = regexreplace($text, "(\r\n|\r|\n)", " "); |
| |
| 61 | $t = writefile($log, $text, "o", "ta"); |
| |
| 62 | $name = regexreplace($text, ".*?<h3.*?>([^\d]+)\s\d.*</h3>.*", "$1"); |
| |
| 63 | $name = regexreplace($name, "What's new in", "Official Release"); |
| |
| 64 | $t = writefile($log, chr(10).$name, "a", "ta"); |
| |
| 65 | $date = regexreplace($text, ".*<p.*>(.*)</p>.*", "$1"); |
| |
| 66 | $text = gettoken($text, 2, "</p>"); |
| |
| 67 | $text = regexreplace($text, "\s+<div.+?>(.*</div>)\s+", " $1"); |
| |
| 68 | |
35 | |
| 69 | $changes = regexreplace($changes, "(\r\n|\r|\n)", " "); |
| |
| 70 | $changes = replace($changes, " <b>", "* <b>"); |
| |
| 71 | $changes = replace($changes, "</div>", "<br />" . chr(10)); |
| |
| 72 | $changes = replace($changes, "<br />" . chr(10), ""); |
| |
| 73 | $thisChange = |
| |
| 74 | "<!-- entry --><!-- %official% %$version% -->" . chr(10) . |
| |
| 75 | "<h3 class='official'>$name - $version ($date)</h3>" . chr(10) . |
| |
| 76 | "<p class='official code'>$changes</p>" . chr(10); |
| |
| 77 | //$officialChanges; |
| |
| 78 | if($sequenceDirection == 1) { |
| |
| 79 | $officialChanges = $officialChanges . $thisChange; |
| |
| 80 | } else { |
| |
| 81 | $officialChanges = $thisChange . $officialChanges; // lower to higher |
| |
| 82 | } |
| |
| 83 | if (compare($version, $highestOfficialVersion, v) > 0) { |
| |
| 84 | $highestOfficialVersion = $version; |
| |
| 85 | $downloadOfficialUrl = "http://www.xyplorer.com/download/xyplorer_full_noinstall.zip"; |
| |
| 86 | } |
| |
| 87 | } |
| |
| 88 | $t = writefile($log, $officialChanges, "o", "ta"); |
| |
| 89 | |
36 | |
| 90 | |
37 | |