add update.php

This commit is contained in:
2024-10-14 23:25:38 +08:00
parent 35a87777ce
commit 56963a9710
5 changed files with 30 additions and 1 deletions
+1
View File
@@ -9,5 +9,6 @@
- pwd - shows the working directory
- rm - deletes a file or directory
- touch - creates a new file
- update - looks for updates
**Try to do type help [command] in the terminal to show more details**
+23
View File
@@ -0,0 +1,23 @@
<?php
function func($commands)
{
$now_v = "v1.5";
if (sizeof($commands) == 1) {
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, 'https://api.github.com/repos/hanyixuanten/browser-terminal/releases/latest');
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, ['User-Agent: PHP']);
$response = json_decode(curl_exec($ch), true);
curl_close($ch);
$latest_v = $response['tag_name'];
if ($latest_v == $now_v) {
file_put_contents("recent.txt", "This is the latest version.<br/>", FILE_APPEND);
} else {
file_put_contents("recent.txt", "There is a new version $latest_v, you are using $now_v <br/>", FILE_APPEND);
file_put_contents("recent.txt", "<a href='https://api.github.com/repos/hanyixuanten/browser-terminal/zipball/$latest_v' style='color: white;'>Download zip</a> <br/>", FILE_APPEND);
file_put_contents("recent.txt", "<a href='https://api.github.com/repos/hanyixuanten/browser-terminal/tarball/$latest_v' style='color: white;'>tar.gz</a> <br/>", FILE_APPEND);
}
} else {
file_put_contents("recent.txt", "Invalid number of arguments.<br/>", FILE_APPEND);
}
}
+2
View File
@@ -1,3 +1,5 @@
write php
write help.txt <command_name>.txt
edit commands.md
if new version: edit new_v in update.php
+2
View File
@@ -0,0 +1,2 @@
update - looks for updates<br/>
usage: update<br/>
+1
View File
@@ -7,4 +7,5 @@ mkdir - creates a new directory<br/>
pwd - shows the working directory<br/>
rm - deletes a file or directory<br/>
touch - creates a new file<br/>
update - looks for updates<br/>
type help [command] to show more details<br/>