add update.php
This commit is contained in:
@@ -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**
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
@@ -1,3 +1,5 @@
|
||||
write php
|
||||
write help.txt <command_name>.txt
|
||||
edit commands.md
|
||||
|
||||
if new version: edit new_v in update.php
|
||||
@@ -0,0 +1,2 @@
|
||||
update - looks for updates<br/>
|
||||
usage: update<br/>
|
||||
@@ -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/>
|
||||
Reference in New Issue
Block a user