private function deploy($engine) { global $current_engine_is_thot, $thot_itp_conf; // set engine name (is read by start-mt-server.perl $handle = fopen("/opt/casmacat/engines/deployed", "w"); fwrite($handle, $engine . "\n"); fclose($handle); // restart MT and CAT server exec("/opt/casmacat/admin/scripts/itp-server.sh stop"); exec("/opt/casmacat/admin/scripts/stop-cat-server.sh"); exec("/opt/casmacat/admin/scripts/update-language-setting-in-web-server.perl"); exec("/opt/casmacat/admin/scripts/start-mt-server.perl"); detect_engine(); $this->msg = "CURRENT ENGINE : {$current_engine_is_thot} / {$thot_itp_conf}"; if ($current_engine_is_thot) { exec("/opt/casmacat/admin/scripts/itp-server.sh {$thot_itp_conf} 9999"); } else { exec("/opt/casmacat/admin/scripts/start-cat-server.sh"); } }
{ global $current_engine_is_thot, $thot_itp_conf; $deployed = file("/opt/casmacat/engines/deployed"); $current_engine_is_thot = 0; if (isset($deployed[0])) { if ($handle = opendir("/opt/casmacat/engines/" . rtrim($deployed[0]))) { while (false !== ($file = readdir($handle))) { if (preg_match("/^itp-server.conf.\\d+/", $file, $match)) { $current_engine_is_thot = 1; $thot_itp_conf = "/opt/casmacat/engines/" . rtrim($deployed[0]) . "/{$file}"; } } } } } detect_engine(); // pretty time printing function pretty_time($timestamp) { date_default_timezone_set('UTC'); // hmmmm... if ($timestamp + 12 * 3600 > time()) { return strftime("%T", $timestamp); } if ($timestamp + 5 * 24 * 3600 > time()) { return strftime("%a %H:%M", $timestamp); } if ($timestamp + 180 * 24 * 3600 > time()) { return strftime("%d %b", $timestamp); } return strftime("%d %b %g", $timestamp);