58 lines
1.9 KiB
PHP
58 lines
1.9 KiB
PHP
<!DOCTYPE html>
|
|
<html>
|
|
<head>
|
|
<title>更新打包機Slot資源</title>
|
|
</head>
|
|
<body>
|
|
|
|
<h1>更新打包機Slot資源</h1>
|
|
<form action="." method="post">
|
|
SlotID: <input type="test" name="SlotID" value="<?php echo $_POST["SlotID"] ?? ""; ?>">
|
|
<input type="hidden" name="action" value="SlotUpdate">
|
|
<input type="submit" name="action" value="更新">
|
|
<input type="submit" name="action" value="顯示Log">
|
|
</form>
|
|
<p>PS: <b>更新</b>一次會強制刷新正在使用的碰友們的網頁🥳</p>
|
|
|
|
</body>
|
|
</html>
|
|
|
|
<?php
|
|
if (!$_POST) {
|
|
return;
|
|
}
|
|
$result = "";
|
|
$print = "";
|
|
if ($_POST["action"] === "更新") {
|
|
$SlotID = $_POST["SlotID"] ?? "";
|
|
if(!$SlotID) {
|
|
echo "請輸入SlotID";
|
|
return;
|
|
}
|
|
//將上面的class檔include進來
|
|
include_once("ssh2.php");
|
|
//初始化class
|
|
$shell = new ssh2("192.168.5.45");
|
|
$shell->authPassword("catantech","catan9595");
|
|
//執行指令
|
|
$result .= "<br>" . $shell->cmdExec(". ~/Desktop/Casino-Core-Type2/gamegitpull.sh " . $SlotID);
|
|
$result .= "<br>" . $shell->cmdExec('cd ~/Desktop/Casino-Core-Type2/assets/Game/Game_' . $SlotID . '/;git log -3 --pretty=format:"%h - %an, %s : %ad" --date=format:"%Y-%m-%d %H:%M:%S"');
|
|
$print = str_replace("\n", '<br>', $result);
|
|
} else if ($_POST["action"] === "顯示Log") {
|
|
$SlotID = $_POST["SlotID"] ?? "";
|
|
if(!$SlotID) {
|
|
echo "請輸入SlotID";
|
|
return;
|
|
}
|
|
//將上面的class檔include進來
|
|
include_once("ssh2.php");
|
|
//初始化class
|
|
$shell = new ssh2("192.168.5.45");
|
|
$shell->authPassword("catantech","catan9595");
|
|
//執行指令
|
|
$result .= "<br>" . $shell->cmdExec('cd ~/Desktop/Casino-Core-Type2/assets/Game/Game_' . $SlotID . '/;git log -3 --pretty=format:"%h - %an, %s : %ad" --date=format:"%Y-%m-%d %H:%M:%S"');
|
|
$print = str_replace("\n", '<br>', $result);
|
|
}
|
|
//印出指令執行結果
|
|
echo $print;
|
|
?>
|