fixed app update, check old version from db

This commit is contained in:
2026-02-13 13:03:37 +07:00
parent 98c44d71f8
commit 3e26d1bfaf
+4 -2
View File
@@ -23,7 +23,9 @@ final class Update {
public function __construct($db = null){ public function __construct($db = null){
if (is_resource($db)) { $this->__linkdb = $db; } if (is_resource($db)) { $this->__linkdb = $db; }
else { $this->__linkdb = new \siaupheng\fonia3\DB\MySQL(); } else { $this->__linkdb = new \siaupheng\fonia3\DB\MySQL(); }
$this->__web_app = $_SESSION['__WEB_APP']; $this->__web_app = $_SESSION['__WEB_APP'];
$this->__linkdb->Query("SELECT GIT_SHA1,GIT_DATE FROM app_config WHERE REG_ID='".$this->__web_app['APP_CODE']."' LIMIT 1");
if ($this->__linkdb->Next()) $this->__web_app = array_merge($this->__web_app, $this->__linkdb->AllRow());
} }
public function check_update() { public function check_update() {
@@ -59,7 +61,7 @@ final class Update {
$_branch = "main"; $_branch = "main";
if (isset($_target)) { if (isset($_target)) {
chdir($_target); chdir($_target);
$output = shell_exec("cd {$_target} && git pull origin {$_branch} 2>&1"); $output = shell_exec("cd {$_target} && git reset --hard HEAD && git pull origin {$_branch} 2>&1");
$this->__linkdb->Query("UPDATE app_config SET GIT_SHA1='".$new_sha1."',GIT_DATE='".$new_date."' WHERE REG_ID='".$this->__web_app['APP_CODE']."' LIMIT 1"); $this->__linkdb->Query("UPDATE app_config SET GIT_SHA1='".$new_sha1."',GIT_DATE='".$new_date."' WHERE REG_ID='".$this->__web_app['APP_CODE']."' LIMIT 1");
return ['status'=>true,'message'=>$output]; return ['status'=>true,'message'=>$output];
} else return ['status'=>false,'message'=>"Tanpa REAL_PATH !"]; } else return ['status'=>false,'message'=>"Tanpa REAL_PATH !"];