19 include_once (
"WHAT/Lib.System.php");
25 $rq = pg_exec(
$dbid,
"select paramv.val, application.name, application.machine from paramv, application where paramv.name='VERSION' and paramv.appid=application.id");
29 for ($i = 0; $i < pg_numrows(
$rq); $i++) {
30 $row = pg_fetch_array(
$rq, $i);
31 $tver[$row[
"name"]] = $row[
"val"];
32 $tmachine[$row[
"name"]] = $row[
"machine"];
40 print
"GetDbOldVersion";
42 $rq = pg_exec(
$dbid,
"select param.val, application.name from param, application where param.name='VERSION' and param.key=application.id");
44 for ($i = 0; $i < pg_numrows(
$rq); $i++) {
45 $row = pg_fetch_array(
$rq, $i);
46 $tver[$row[
"name"]] = $row[
"val"];
47 if ($row[
"name"] ==
"USERS") {
48 $tver[
"CORE"] = $row[
"val"];
49 $tver[
"ACCESS"] = $row[
"val"];
50 $tver[
"APPMNG"] = $row[
"val"];
51 $tver[
"AUTHENT"] = $row[
"val"];
62 if (
$dir = @opendir($topdir)) {
63 while ((
$file = readdir(
$dir)) !==
false) {
64 $inifile = $topdir .
"/$file/${file}_init.php";
65 if (@is_file($inifile)) {
67 $fini = fopen($inifile,
"r");
68 while (!feof($fini)) {
69 $line = fgets($fini, 256);
70 if (preg_match(
"/VERSION.*=>[ \t]*\"[ \t]*([0-9\.\-]+)/",
$line, $reg)) {
71 if (isset($reg[1])) $tver[
$file] = $reg[1];
90 if (
$dir = @opendir($topdir)) {
91 while ((
$file = readdir(
$dir)) !==
false) {
92 $inifile = $topdir .
"/$file/${file}.app";
93 if (@is_file($inifile)) {
97 if (isset($app_desc)) {
98 if (isset($app_desc[
"iorder"])) $tiorder[
$file] = $app_desc[
"iorder"];
113 return version_compare($v1, $v2);
118 if (preg_match_all(
'/([0-9]+)/', $ver, $matches)) {
119 $matches = ($matches[0]);
121 $c = count($matches);
123 for ($i = 0; $i < (4 -
$c); $i++) {
127 foreach ($matches as $k => $v) $sva.= sprintf(
"%02d", $v);
128 return floatval($sva);
140 $err = _(
"cannot access to core database service [service='$pgservice_core']");
141 exec(
"PGSERVICE=\"$pgservice_core\" psql -c '\q'",
$out);
161 $err = _(
"cannot access to core database service [service='$pgservice_core']");
162 exec(
"PGSERVICE=\"$pgservice_core\" psql -c '\q'",
$out);
172 foreach ($tvdb as
$appname => & $version) {
178 $ta = array_unique(array_merge(array_keys($tvdb) , array_keys($tvfile)));
179 foreach (
$ta as $k => $v) {
180 if (($tmachine[$v] !=
"") && (gethostbyname($tmachine[$v]) != gethostbyname($_SERVER[
"HOSTNAME"]))) $chk[$v] =
"?";
181 else if ($tvdb[$v] == $tvfile[$v]) {
183 }
else if ($tvdb[$v] ==
"") {
185 }
else if ($tvfile[$v] ==
"") {
187 }
else if (
vercmp($tvdb[$v], $tvfile[$v]) == 1) {
195 "vfile" => $tvfile[$v],
197 "machine" => $tmachine[$v]
214 $dbid = @pg_connect(
"service='$pgservice_core'");
222 foreach ($tvdb as
$appname => & $version) {
228 foreach ($tiorder as $k => $v) {
229 $tapp[$k][
"iorder"] = $v;
231 uasort($tapp,
"cmpapp");
232 foreach ($tapp as $k => $v) {
234 $pattern = preg_quote($k);
236 if (
$dir = @opendir(
"$pubdir/$k")) {
237 while ((
$file = readdir(
$dir)) !==
false) {
238 if (preg_match(
"/{$pattern}_(?:migr|premigr)_([0-9\.]+)$/",
$file, $reg)) {
239 if (($tvdb[$k] !=
"") && (
vercmp($tvdb[$k], $reg[1]) < 0)) $migr[] =
"$pubdir/$k/$file";
243 usort($migr,
"cmpmigr");
246 if (($v[
"chk"] !=
"") && (is_file(
"$pubdir/$k/{$k}_post"))) {
247 if ($v[
"chk"] ==
"I") {
248 $cmd[] =
"$pubdir/$k/{$k}_post " . $v[
"chk"];
253 $cmd[] =
"$pubdir/wsh.php --api=appadmin --method=init --appname=$k";
254 $cmd[] =
"$pubdir/wsh.php --api=appadmin --method=update --appname=$k";
258 $cmd[] =
"$pubdir/wsh.php --api=appadmin --method=update --appname=$k";
262 $cmd[] =
"#$pubdir/wsh.php --api=appadmin --method=delete --appname=$k";
266 $cmd[] =
"#rpm -Uvh $k-" . $v[
"vdb"];
270 if (($v[
"chk"] !=
"") && (is_file(
"$pubdir/$k/{$k}_post"))) {
271 if ($v[
"chk"] ==
"I") {
272 $cmd[] =
"$pubdir/$k/{$k}_post U";
274 if (($v[
"chk"] !=
"R") && ($v[
"chk"] !=
"?")) {
275 if ($v[
"chk"] ==
"D")
$cmd[] =
"#$pubdir/$k/{$k}_post " . $v[
"chk"];
276 else $cmd[] =
"$pubdir/$k/{$k}_post " . $v[
"chk"];
282 if (
$dir = @opendir(
"$pubdir/$k")) {
283 while ((
$file = readdir(
$dir)) !==
false) {
284 if (preg_match(
"/{$pattern}_(?:pmigr|postmigr)_([0-9\.]+)$/",
$file, $reg)) {
286 if (($tvdb[$k] !=
"") && (
vercmp($tvdb[$k], $reg[1]) < 0)) $migr[] =
"$pubdir/$k/$file";
290 usort($migr,
"cmpmigr");
297 $dump[] =
"$pubdir/wstop";
298 $dump[] =
"$pubdir/whattext";
302 $tact[] =
"$pubdir/wsh.php --api=freedom_clean";
303 $tact[] =
"$pubdir/wstart";
305 if (empty(
$_GET[
'httpdrestart']) || (
$_GET[
'httpdrestart'] !=
'no')) {
306 if ($_SERVER[
'HTTP_HOST'] !=
"")
$tact[] =
"sudo $pubdir/admin/shttpd";
307 else $tact[] =
"service httpd restart";
313 if (isset(
$a[
"iorder"]) && isset($b[
"iorder"])) {
314 if (
$a[
"iorder"] > $b[
"iorder"])
return 1;
315 else if (
$a[
"iorder"] < $b[
"iorder"])
return -1;
318 if (isset(
$a[
"iorder"]))
return -1;
319 if (isset($b[
"iorder"]))
return 1;
327 preg_match(
"/_(?:p|post|pre)?migr_(?P<version>[0-9\.]+)$/", $migr_a, $v_a);
328 preg_match(
"/_(?:p|post|pre)?migr_(?P<version>[0-9\.]+)$/", $migr_b, $v_b);
330 return version_compare($v_a[
'version'], $v_b[
'version']);