Fix start stop bug for Mirror server, a=chris

Chris Pollett [2019-06-12 19:Jun:th]
Fix start stop bug for Mirror server, a=chris
Filename
src/executables/Mirror.php
src/locale/ar/configure.ini
src/locale/bn/configure.ini
src/locale/de/configure.ini
src/locale/en_US/configure.ini
src/locale/es/configure.ini
src/locale/fa/configure.ini
src/locale/fr_FR/configure.ini
src/locale/he/configure.ini
src/locale/hi/configure.ini
src/locale/in_ID/configure.ini
src/locale/it/configure.ini
src/locale/ja/configure.ini
src/locale/kn/configure.ini
src/locale/ko/configure.ini
src/locale/nl/configure.ini
src/locale/pl/configure.ini
src/locale/pt/configure.ini
src/locale/ru/configure.ini
src/locale/te/configure.ini
src/locale/th/configure.ini
src/locale/tr/configure.ini
src/locale/vi_VN/configure.ini
src/locale/zh_CN/configure.ini
src/models/MachineModel.php
src/views/MachinestatusView.php
diff --git a/src/executables/Mirror.php b/src/executables/Mirror.php
index dbecbd4d3..2386b8979 100644
--- a/src/executables/Mirror.php
+++ b/src/executables/Mirror.php
@@ -129,10 +129,10 @@ class Mirror implements CrawlConstants
      */
     public function __construct($name_server)
     {
-        $db_class = C\NS_DATASOURCES . ucfirst(C\DBMS)."Manager";
+        $db_class = C\NS_DATASOURCES . ucfirst(C\DBMS) . "Manager";
         $this->db = new $db_class();
         $this->name_server = $name_server;
-        $this->last_sync_file = C\CRAWL_DIR."/schedules/last_sync.txt";
+        $this->last_sync_file = C\CRAWL_DIR . "/schedules/last_sync.txt";
         if (file_exists($this->last_sync_file)) {
             $this->last_sync = unserialize(
                 file_get_contents($this->last_sync_file));
@@ -142,7 +142,7 @@ class Mirror implements CrawlConstants
         $this->start_sync = $this->last_sync;
         $this->last_notify = $this->last_sync;
         $this->sync_schedule = [];
-        $this->sync_dir = C\CRAWL_DIR."/cache";
+        $this->sync_dir = C\CRAWL_DIR . "/cache";
         $this->parent_url = $name_server;
     }
     /**
@@ -224,9 +224,9 @@ class Mirror implements CrawlConstants
         $write_sync_time = true;
         $request =
             $server.
-            "?c=resource&time=$time&session=$session".
-            "&robot_instance=".C\ROBOT_INSTANCE."&machine_uri=".C\WEB_URI.
-            "&last_sync=".$this->last_sync;
+            "?c=resource&time=$time&session=$session" .
+            "&robot_instance=" . C\ROBOT_INSTANCE . "&machine_uri=" .
+            C\WEB_URI . "&last_sync=" . $this->last_sync;
         if ($this->start_sync <= $this->last_sync &&
             $this->last_sync + C\MIRROR_SYNC_FREQUENCY < $time) {
             $request .= "&a=syncList";
diff --git a/src/locale/ar/configure.ini b/src/locale/ar/configure.ini
index 7251775f7..f74788f6f 100755
--- a/src/locale/ar/configure.ini
+++ b/src/locale/ar/configure.ini
@@ -656,7 +656,7 @@ machinestatus_view_confirm = ""
 machinestatus_view_delete = ""
 machinestatus_view_channel = ""
 machinestatus_view_not_configured = ""
-machinestatus_view_mirrors = "المرايا"
+machinestatus_view_mirror = ""
 machinestatus_view_queue_server = "قائمة انتظار الملقم"
 machinestatus_view_no_queue_server = "آلة قد لا يوجد ملقم قائمة انتظار"
 machinestatus_view_no_fetchers = "آلة قد لا فيتشيرس"
diff --git a/src/locale/bn/configure.ini b/src/locale/bn/configure.ini
index 8f4250274..188996284 100755
--- a/src/locale/bn/configure.ini
+++ b/src/locale/bn/configure.ini
@@ -656,7 +656,7 @@ machinestatus_view_confirm = ""
 machinestatus_view_delete = ""
 machinestatus_view_channel = ""
 machinestatus_view_not_configured = ""
-machinestatus_view_mirrors = ""
+machinestatus_view_mirror = ""
 machinestatus_view_queue_server = ""
 machinestatus_view_no_queue_server = ""
 machinestatus_view_no_fetchers = ""
diff --git a/src/locale/de/configure.ini b/src/locale/de/configure.ini
index 8dacbe0c6..feec3c4d9 100755
--- a/src/locale/de/configure.ini
+++ b/src/locale/de/configure.ini
@@ -656,7 +656,7 @@ machinestatus_view_confirm = ""
 machinestatus_view_delete = ""
 machinestatus_view_channel = ""
 machinestatus_view_not_configured = ""
-machinestatus_view_mirrors = ""
+machinestatus_view_mirror = ""
 machinestatus_view_queue_server = ""
 machinestatus_view_no_queue_server = ""
 machinestatus_view_no_fetchers = ""
diff --git a/src/locale/en_US/configure.ini b/src/locale/en_US/configure.ini
index 52f287c3a..d89baa33a 100644
--- a/src/locale/en_US/configure.ini
+++ b/src/locale/en_US/configure.ini
@@ -656,7 +656,7 @@ machinestatus_view_confirm = "Are you sure you want to delete?"
 machinestatus_view_delete = "Delete"
 machinestatus_view_channel = "Channel:%s"
 machinestatus_view_not_configured = "Machine Not Configured!"
-machinestatus_view_mirrors = "Mirrors"
+machinestatus_view_mirror = "Mirror"
 machinestatus_view_queue_server = "Queue Server"
 machinestatus_view_no_queue_server = "Machine has no queue server"
 machinestatus_view_no_fetchers = "Machine has no fetchers"
diff --git a/src/locale/es/configure.ini b/src/locale/es/configure.ini
index 677bdfddb..29cdeb1ba 100755
--- a/src/locale/es/configure.ini
+++ b/src/locale/es/configure.ini
@@ -656,7 +656,7 @@ machinestatus_view_confirm = ""
 machinestatus_view_delete = ""
 machinestatus_view_channel = ""
 machinestatus_view_not_configured = ""
-machinestatus_view_mirrors = ""
+machinestatus_view_mirror = ""
 machinestatus_view_queue_server = ""
 machinestatus_view_no_queue_server = ""
 machinestatus_view_no_fetchers = ""
diff --git a/src/locale/fa/configure.ini b/src/locale/fa/configure.ini
index 00028569a..e8097a322 100755
--- a/src/locale/fa/configure.ini
+++ b/src/locale/fa/configure.ini
@@ -656,7 +656,7 @@ machinestatus_view_confirm = ""
 machinestatus_view_delete = ""
 machinestatus_view_channel = ""
 machinestatus_view_not_configured = ""
-machinestatus_view_mirrors = "آینه&zwnj;ها"
+machinestatus_view_mirror = ""
 machinestatus_view_queue_server = "صف سرور"
 machinestatus_view_no_queue_server = "دستگاه صف سرور ندارد"
 machinestatus_view_no_fetchers = "دستگاه واکش ندارد"
diff --git a/src/locale/fr_FR/configure.ini b/src/locale/fr_FR/configure.ini
index f88ae70e8..c50d1e91f 100755
--- a/src/locale/fr_FR/configure.ini
+++ b/src/locale/fr_FR/configure.ini
@@ -656,7 +656,7 @@ machinestatus_view_confirm = ""
 machinestatus_view_delete = ""
 machinestatus_view_channel = ""
 machinestatus_view_not_configured = ""
-machinestatus_view_mirrors = ""
+machinestatus_view_mirror = ""
 machinestatus_view_queue_server = ""
 machinestatus_view_no_queue_server = ""
 machinestatus_view_no_fetchers = ""
diff --git a/src/locale/he/configure.ini b/src/locale/he/configure.ini
index 08ad88748..ce330984d 100755
--- a/src/locale/he/configure.ini
+++ b/src/locale/he/configure.ini
@@ -656,7 +656,7 @@ machinestatus_view_confirm = ""
 machinestatus_view_delete = ""
 machinestatus_view_channel = ""
 machinestatus_view_not_configured = ""
-machinestatus_view_mirrors = ""
+machinestatus_view_mirror = ""
 machinestatus_view_queue_server = ""
 machinestatus_view_no_queue_server = ""
 machinestatus_view_no_fetchers = ""
diff --git a/src/locale/hi/configure.ini b/src/locale/hi/configure.ini
index 081a1a326..cb4357143 100755
--- a/src/locale/hi/configure.ini
+++ b/src/locale/hi/configure.ini
@@ -656,7 +656,7 @@ machinestatus_view_confirm = ""
 machinestatus_view_delete = ""
 machinestatus_view_channel = ""
 machinestatus_view_not_configured = ""
-machinestatus_view_mirrors = ""
+machinestatus_view_mirror = ""
 machinestatus_view_queue_server = ""
 machinestatus_view_no_queue_server = ""
 machinestatus_view_no_fetchers = ""
diff --git a/src/locale/in_ID/configure.ini b/src/locale/in_ID/configure.ini
index 31daa9205..f5ad33d62 100755
--- a/src/locale/in_ID/configure.ini
+++ b/src/locale/in_ID/configure.ini
@@ -656,7 +656,7 @@ machinestatus_view_confirm = ""
 machinestatus_view_delete = ""
 machinestatus_view_channel = ""
 machinestatus_view_not_configured = ""
-machinestatus_view_mirrors = ""
+machinestatus_view_mirror = ""
 machinestatus_view_queue_server = ""
 machinestatus_view_no_queue_server = ""
 machinestatus_view_no_fetchers = ""
diff --git a/src/locale/it/configure.ini b/src/locale/it/configure.ini
index 5bc3fa471..81a632e0f 100755
--- a/src/locale/it/configure.ini
+++ b/src/locale/it/configure.ini
@@ -656,7 +656,7 @@ machinestatus_view_confirm = ""
 machinestatus_view_delete = ""
 machinestatus_view_channel = ""
 machinestatus_view_not_configured = ""
-machinestatus_view_mirrors = "Mirror"
+machinestatus_view_mirror = ""
 machinestatus_view_queue_server = "Server di Coda"
 machinestatus_view_no_queue_server = "La Macchina non ha un Server di Coda"
 machinestatus_view_no_fetchers = "La Macchina non ha acquisitori"
diff --git a/src/locale/ja/configure.ini b/src/locale/ja/configure.ini
index 12e817bbb..14a5bb42f 100755
--- a/src/locale/ja/configure.ini
+++ b/src/locale/ja/configure.ini
@@ -656,7 +656,7 @@ machinestatus_view_confirm = ""
 machinestatus_view_delete = ""
 machinestatus_view_channel = ""
 machinestatus_view_not_configured = ""
-machinestatus_view_mirrors = ""
+machinestatus_view_mirror = ""
 machinestatus_view_queue_server = ""
 machinestatus_view_no_queue_server = ""
 machinestatus_view_no_fetchers = ""
diff --git a/src/locale/kn/configure.ini b/src/locale/kn/configure.ini
index 81b15863e..a12053c87 100755
--- a/src/locale/kn/configure.ini
+++ b/src/locale/kn/configure.ini
@@ -656,7 +656,7 @@ machinestatus_view_confirm = ""
 machinestatus_view_delete = ""
 machinestatus_view_channel = ""
 machinestatus_view_not_configured = ""
-machinestatus_view_mirrors = ""
+machinestatus_view_mirror = ""
 machinestatus_view_queue_server = ""
 machinestatus_view_no_queue_server = ""
 machinestatus_view_no_fetchers = ""
diff --git a/src/locale/ko/configure.ini b/src/locale/ko/configure.ini
index 26865a14f..418b025fc 100755
--- a/src/locale/ko/configure.ini
+++ b/src/locale/ko/configure.ini
@@ -656,7 +656,7 @@ machinestatus_view_confirm = ""
 machinestatus_view_delete = ""
 machinestatus_view_channel = ""
 machinestatus_view_not_configured = ""
-machinestatus_view_mirrors = ""
+machinestatus_view_mirror = ""
 machinestatus_view_queue_server = ""
 machinestatus_view_no_queue_server = ""
 machinestatus_view_no_fetchers = ""
diff --git a/src/locale/nl/configure.ini b/src/locale/nl/configure.ini
index f9c06e602..615bbe9e2 100644
--- a/src/locale/nl/configure.ini
+++ b/src/locale/nl/configure.ini
@@ -656,7 +656,7 @@ machinestatus_view_confirm = ""
 machinestatus_view_delete = "verwijderen"
 machinestatus_view_channel = ""
 machinestatus_view_not_configured = "Machine Niet geconfigureerd!"
-machinestatus_view_mirrors = "Spiegels %s"
+machinestatus_view_mirror = ""
 machinestatus_view_queue_server = "Queue Server"
 machinestatus_view_no_queue_server = "Machine heeft geen wachtrij server"
 machinestatus_view_no_fetchers = "Machine heeft geen fetchers"
diff --git a/src/locale/pl/configure.ini b/src/locale/pl/configure.ini
index 69e10b400..88076fd63 100755
--- a/src/locale/pl/configure.ini
+++ b/src/locale/pl/configure.ini
@@ -656,7 +656,7 @@ machinestatus_view_confirm = ""
 machinestatus_view_delete = ""
 machinestatus_view_channel = ""
 machinestatus_view_not_configured = ""
-machinestatus_view_mirrors = ""
+machinestatus_view_mirror = ""
 machinestatus_view_queue_server = ""
 machinestatus_view_no_queue_server = ""
 machinestatus_view_no_fetchers = ""
diff --git a/src/locale/pt/configure.ini b/src/locale/pt/configure.ini
index aeab14bdd..9fe0787be 100755
--- a/src/locale/pt/configure.ini
+++ b/src/locale/pt/configure.ini
@@ -656,7 +656,7 @@ machinestatus_view_confirm = ""
 machinestatus_view_delete = ""
 machinestatus_view_channel = ""
 machinestatus_view_not_configured = ""
-machinestatus_view_mirrors = ""
+machinestatus_view_mirror = ""
 machinestatus_view_queue_server = ""
 machinestatus_view_no_queue_server = ""
 machinestatus_view_no_fetchers = ""
diff --git a/src/locale/ru/configure.ini b/src/locale/ru/configure.ini
index 1e5f6e19c..4d572dd4c 100755
--- a/src/locale/ru/configure.ini
+++ b/src/locale/ru/configure.ini
@@ -656,7 +656,7 @@ machinestatus_view_confirm = ""
 machinestatus_view_delete = ""
 machinestatus_view_channel = ""
 machinestatus_view_not_configured = ""
-machinestatus_view_mirrors = ""
+machinestatus_view_mirror = ""
 machinestatus_view_queue_server = ""
 machinestatus_view_no_queue_server = ""
 machinestatus_view_no_fetchers = ""
diff --git a/src/locale/te/configure.ini b/src/locale/te/configure.ini
index a1dc9f9dc..494b87bd0 100644
--- a/src/locale/te/configure.ini
+++ b/src/locale/te/configure.ini
@@ -656,7 +656,7 @@ machinestatus_view_confirm = ""
 machinestatus_view_delete = ""
 machinestatus_view_channel = ""
 machinestatus_view_not_configured = ""
-machinestatus_view_mirrors = ""
+machinestatus_view_mirror = ""
 machinestatus_view_queue_server = ""
 machinestatus_view_no_queue_server = ""
 machinestatus_view_no_fetchers = ""
diff --git a/src/locale/th/configure.ini b/src/locale/th/configure.ini
index e7d3bb216..286458c01 100755
--- a/src/locale/th/configure.ini
+++ b/src/locale/th/configure.ini
@@ -656,7 +656,7 @@ machinestatus_view_confirm = ""
 machinestatus_view_delete = ""
 machinestatus_view_channel = ""
 machinestatus_view_not_configured = ""
-machinestatus_view_mirrors = ""
+machinestatus_view_mirror = ""
 machinestatus_view_queue_server = ""
 machinestatus_view_no_queue_server = ""
 machinestatus_view_no_fetchers = ""
diff --git a/src/locale/tr/configure.ini b/src/locale/tr/configure.ini
index e516da179..4b9f692c0 100755
--- a/src/locale/tr/configure.ini
+++ b/src/locale/tr/configure.ini
@@ -656,7 +656,7 @@ machinestatus_view_confirm = ""
 machinestatus_view_delete = ""
 machinestatus_view_channel = ""
 machinestatus_view_not_configured = ""
-machinestatus_view_mirrors = ""
+machinestatus_view_mirror = ""
 machinestatus_view_queue_server = ""
 machinestatus_view_no_queue_server = ""
 machinestatus_view_no_fetchers = ""
diff --git a/src/locale/vi_VN/configure.ini b/src/locale/vi_VN/configure.ini
index 36d403efb..a309e6ab8 100755
--- a/src/locale/vi_VN/configure.ini
+++ b/src/locale/vi_VN/configure.ini
@@ -656,7 +656,7 @@ machinestatus_view_confirm = ""
 machinestatus_view_delete = ""
 machinestatus_view_channel = ""
 machinestatus_view_not_configured = ""
-machinestatus_view_mirrors = ""
+machinestatus_view_mirror = ""
 machinestatus_view_queue_server = ""
 machinestatus_view_no_queue_server = ""
 machinestatus_view_no_fetchers = ""
diff --git a/src/locale/zh_CN/configure.ini b/src/locale/zh_CN/configure.ini
index c80f4fb32..c3d2edf30 100755
--- a/src/locale/zh_CN/configure.ini
+++ b/src/locale/zh_CN/configure.ini
@@ -656,7 +656,7 @@ machinestatus_view_confirm = ""
 machinestatus_view_delete = ""
 machinestatus_view_channel = ""
 machinestatus_view_not_configured = ""
-machinestatus_view_mirrors = ""
+machinestatus_view_mirror = ""
 machinestatus_view_queue_server = ""
 machinestatus_view_no_queue_server = ""
 machinestatus_view_no_fetchers = ""
diff --git a/src/models/MachineModel.php b/src/models/MachineModel.php
index b94de1853..2ae9b0551 100644
--- a/src/models/MachineModel.php
+++ b/src/models/MachineModel.php
@@ -386,7 +386,7 @@ class MachineModel extends Model
             }
         }
         if (!empty($row)) {
-            $row["CHANNEL"] = (empty($row["CHANNEL"])) ? 0 : $row["CHANNEL"];
+            $row["CHANNEL"] = (!isset($row["CHANNEL"])) ? 0 : $row["CHANNEL"];
             $url = $row["URL"]. "?c=machine&a=update&time=$time".
                 "&session=$session&action=$action&id=$id".
                 "&type=$type&channel=" . $row["CHANNEL"];
@@ -401,7 +401,7 @@ class MachineModel extends Model
                 $sql = "INSERT INTO ACTIVE_PROCESS VALUES (?, ?, ?)";
                 $db->execute($sql, [$machine_name, $id, $db_type]);
             }
-            if ($type == "mirror") {
+            if ($type == "Mirror") {
                 if ($row["PARENT"]) {
                     $sql = "SELECT URL FROM MACHINE WHERE NAME='".
                         $row["PARENT"] ."'";
diff --git a/src/views/MachinestatusView.php b/src/views/MachinestatusView.php
index 3a5dae34f..42875f895 100644
--- a/src/views/MachinestatusView.php
+++ b/src/views/MachinestatusView.php
@@ -125,10 +125,14 @@ class MachinestatusView extends View
                 ?>' onclick='javascript:return confirm("<?=
                 tl('machinestatus_view_confirm') ?>");' ><?=
                 tl('machinestatus_view_delete') ?></a>]</div>
-            <h3 class="no-margin"><?php e($m['NAME']);?><small
-            style="position:relative;top:-3px;font-weight: normal;">[<?=
-            tl('machinestatus_view_channel', $m['CHANNEL'])
-            ?>] [<?= $m['URL']?>]</small></h3>
+            <h3 class="no-margin"><?php e($m['NAME']);
+            if (empty($m['PARENT'])) {
+                ?><small
+                style="position:relative;top:-3px;font-weight: normal;">[<?=
+                tl('machinestatus_view_channel', $m['CHANNEL'])
+                ?>] [<?= $m['URL']?>]</small><?php
+            } ?>
+            </h3>
             <table class="machine-table">
             <?php
             $on_queue_server = $base_url . "update&amp;name={$m['NAME']}".
@@ -157,18 +161,18 @@ class MachinestatusView extends View
             }
             if (!empty($m['PARENT'])) {
                     $log_url = $base_url . "log&name={$m['NAME']}".
-                        "&type=mirror&id=0;";
+                        "&type=Mirror&id=0;";
                 ?>
                 <tr>
-                <th><?= tl('machinestatus_view_mirrors', $m['PARENT']) ?>
+                <th><?= tl('machinestatus_view_mirror', $m['PARENT']) ?>
                     </th>
                 <td><table><tr><td>#00[<a href="<?php e($log_url);?>"><?=
                     tl('machinestatus_view_log') ?>]</td></tr><tr><td><?php
-                    $caution = isset($m['STATUSES']["mirror"]) && (
-                        !isset($m['STATUSES']["mirror"][-1]) ||
-                        !$m['STATUSES']["mirror"][-1]);
+                    $caution = isset($m['STATUSES'][$m['NAME']]) && (
+                        !isset($m['STATUSES'][$m['NAME']][-1]) ||
+                        !$m['STATUSES'][$m['NAME']][-1]);
                     $this->helper("toggle")->render(
-                        isset($m['STATUSES']["mirror"]),
+                        isset($m['STATUSES'][$m['NAME']]),
                         $on_mirror, $off_mirror, $caution);
                 ?></td></tr></table></td></tr>
                 </table>
ViewGit