diff --git a/src/configs/Config.php b/src/configs/Config.php index 0f0bbfd49..25a6ca070 100755 --- a/src/configs/Config.php +++ b/src/configs/Config.php @@ -232,6 +232,9 @@ function initializeBaseUrlAndCurrentWorkingDirectory() } $server_name = isset($_SERVER['SERVER_NAME']) ? $_SERVER['SERVER_NAME'] : "localhost"; + if (strpos($server_name, ":") !== false && $server_name[0] != '[') { + $server_name = "[$server_name]"; //guessing ipv6 address + } $dir_name = $path_info["dirname"]; if ($dir_name == ".") { $dir_name = ""; diff --git a/src/controllers/MachineController.php b/src/controllers/MachineController.php index e63931bc2..2911da6f9 100644 --- a/src/controllers/MachineController.php +++ b/src/controllers/MachineController.php @@ -125,7 +125,7 @@ class MachineController extends Controller implements CrawlConstants L\webdecode($parent)); } CrawlDaemon::start("Mirror"); - } else if ($_REQUEST['Mirror'] == "stop" && + } else if ($_REQUEST['action'] == "stop" && isset($statuses["Mirror"][-1]) ) { CrawlDaemon::stop("Mirror"); } diff --git a/src/controllers/SearchController.php b/src/controllers/SearchController.php index 28e07c43e..69616e7f0 100755 --- a/src/controllers/SearchController.php +++ b/src/controllers/SearchController.php @@ -487,7 +487,11 @@ class SearchController extends Controller implements CrawlConstants $crawl_model = $this->model("crawl"); $this->model("phrase")->current_machine = $current_machine; $crawl_model->current_machine = $current_machine; - $machine_urls = $this->model("machine")->getQueueServerUrls(); + if (C\BASE_URL == C\NAME_SERVER) { + $machine_urls = $this->model("machine")->getQueueServerUrls(); + } else { + $machine_urls = null; + } $current_its = $crawl_model->getCurrentIndexDatabaseName(); $index_timestamp = $this->getIndexTimestamp(); $is_mix = false; @@ -675,7 +679,10 @@ class SearchController extends Controller implements CrawlConstants /** * Used to check if there are any mirrors of the current server. * If so, it tries to distribute the query requests randomly amongst - * the mirrors + * the mirrors and itself. To determine if there are mirrors of the + * current server it looks in a mirror_table.txt file for machines that + * have notified this machine they are mirroring it. + * * @return bool whether or not a mirror of the current site handled it */ public function mirrorHandle() @@ -703,7 +710,7 @@ class SearchController extends Controller implements CrawlConstants // if ==$count, we'll let the current machine handle it if ($rand < $count) { $request = $mirrors[$rand] . "?" . - $_SERVER["QUERY_STRING"]; + $_SERVER["QUERY_STRING"] . "&network=false"; echo FetchUrl::getPage($request); $handled = true; } diff --git a/src/controllers/components/SystemComponent.php b/src/controllers/components/SystemComponent.php index 0852b82bf..3e7f09b16 100755 --- a/src/controllers/components/SystemComponent.php +++ b/src/controllers/components/SystemComponent.php @@ -85,6 +85,9 @@ class SystemComponent extends Component 8 => 8, 16 => 16 ]; + $machine_names = $machine_model->getQueueServerNames(); + $data['PARENT_MACHINES'] = array_combine($machine_names, + $machine_names); $tmp = tl('system_component_select_machine'); if (isset($_REQUEST['channel']) && $_REQUEST['channel'] == -1) { $_REQUEST['num_fetchers'] = 0; diff --git a/src/executables/Mirror.php b/src/executables/Mirror.php index 2386b8979..f8d5ad582 100644 --- a/src/executables/Mirror.php +++ b/src/executables/Mirror.php @@ -183,7 +183,7 @@ class Mirror implements CrawlConstants L\crawlLog("Read File: " . $parent_file . "."); L\crawlLog("Set parent server to: " . $this->parent_url); } else { - L\crawlLog("File: " . $parent_file . " does not exist!"); + L\crawlLog("File: " . $parent_file . " does not exist. "); L\crawlLog("Assuming parent is name server: ". $this->name_server); $this->parent_url = $this->name_server; @@ -283,7 +283,9 @@ class Mirror implements CrawlConstants $server = $this->parent_url; $time = time(); $session = md5($time . C\AUTH_KEY); - if (count($this->sync_schedule) <= 0) return; + if (count($this->sync_schedule) <= 0) { + return; + } $file = array_pop($this->sync_schedule); L\crawlLog("Start syncing {$file['name']}.."); if ($file['is_dir'] ) { @@ -310,9 +312,9 @@ class Mirror implements CrawlConstants } else { $offset = 0; $fh = fopen("$dir/{$file['name']}", "wb"); - $request .= "&l=".self::DOWNLOAD_RANGE; + $request .= "&l=" . self::DOWNLOAD_RANGE; while($offset < $file['size']) { - $data = FetchUrl::getPage($request."&o=$offset", null, + $data = FetchUrl::getPage($request . "&o=$offset", null, true); $old_offset = $offset; $offset += self::DOWNLOAD_RANGE; @@ -324,8 +326,8 @@ class Mirror implements CrawlConstants continue; } fwrite($fh, $data); - L\crawlLog(".. {$file['name']} downloaded bytes $old_offset ". - "to $end_point.."); + L\crawlLog(".. {$file['name']} downloaded bytes ". + "$old_offset to $end_point.."); } L\crawlLog(".. {$file['name']} file copied."); fclose($fh); diff --git a/src/locale/ar/configure.ini b/src/locale/ar/configure.ini index f74788f6f..8aa629fc0 100755 --- a/src/locale/ar/configure.ini +++ b/src/locale/ar/configure.ini @@ -655,6 +655,7 @@ machinestatus_view_log = "سجل" machinestatus_view_confirm = "" machinestatus_view_delete = "" machinestatus_view_channel = "" +machinestatus_view_parent = "" machinestatus_view_not_configured = "" machinestatus_view_mirror = "" machinestatus_view_queue_server = "قائمة انتظار الملقم" diff --git a/src/locale/bn/configure.ini b/src/locale/bn/configure.ini index 188996284..0ebed5ad3 100755 --- a/src/locale/bn/configure.ini +++ b/src/locale/bn/configure.ini @@ -655,6 +655,7 @@ machinestatus_view_log = "" machinestatus_view_confirm = "" machinestatus_view_delete = "" machinestatus_view_channel = "" +machinestatus_view_parent = "" machinestatus_view_not_configured = "" machinestatus_view_mirror = "" machinestatus_view_queue_server = "" diff --git a/src/locale/de/configure.ini b/src/locale/de/configure.ini index feec3c4d9..a4a3f722e 100755 --- a/src/locale/de/configure.ini +++ b/src/locale/de/configure.ini @@ -655,6 +655,7 @@ machinestatus_view_log = "" machinestatus_view_confirm = "" machinestatus_view_delete = "" machinestatus_view_channel = "" +machinestatus_view_parent = "" machinestatus_view_not_configured = "" machinestatus_view_mirror = "" machinestatus_view_queue_server = "" diff --git a/src/locale/en_US/configure.ini b/src/locale/en_US/configure.ini index d89baa33a..4bb612c5f 100644 --- a/src/locale/en_US/configure.ini +++ b/src/locale/en_US/configure.ini @@ -655,6 +655,7 @@ machinestatus_view_log = "Log" machinestatus_view_confirm = "Are you sure you want to delete?" machinestatus_view_delete = "Delete" machinestatus_view_channel = "Channel:%s" +machinestatus_view_parent = "Parent:%s" machinestatus_view_not_configured = "Machine Not Configured!" machinestatus_view_mirror = "Mirror" machinestatus_view_queue_server = "Queue Server" diff --git a/src/locale/es/configure.ini b/src/locale/es/configure.ini index 29cdeb1ba..5b386b6d6 100755 --- a/src/locale/es/configure.ini +++ b/src/locale/es/configure.ini @@ -655,6 +655,7 @@ machinestatus_view_log = "" machinestatus_view_confirm = "" machinestatus_view_delete = "" machinestatus_view_channel = "" +machinestatus_view_parent = "" machinestatus_view_not_configured = "" machinestatus_view_mirror = "" machinestatus_view_queue_server = "" diff --git a/src/locale/fa/configure.ini b/src/locale/fa/configure.ini index e8097a322..573160928 100755 --- a/src/locale/fa/configure.ini +++ b/src/locale/fa/configure.ini @@ -655,6 +655,7 @@ machinestatus_view_log = "گزارش" machinestatus_view_confirm = "" machinestatus_view_delete = "" machinestatus_view_channel = "" +machinestatus_view_parent = "" machinestatus_view_not_configured = "" machinestatus_view_mirror = "" machinestatus_view_queue_server = "صف سرور" diff --git a/src/locale/fr_FR/configure.ini b/src/locale/fr_FR/configure.ini index c50d1e91f..261fb5ae8 100755 --- a/src/locale/fr_FR/configure.ini +++ b/src/locale/fr_FR/configure.ini @@ -655,6 +655,7 @@ machinestatus_view_log = "" machinestatus_view_confirm = "" machinestatus_view_delete = "" machinestatus_view_channel = "" +machinestatus_view_parent = "" machinestatus_view_not_configured = "" machinestatus_view_mirror = "" machinestatus_view_queue_server = "" diff --git a/src/locale/he/configure.ini b/src/locale/he/configure.ini index ce330984d..07241408a 100755 --- a/src/locale/he/configure.ini +++ b/src/locale/he/configure.ini @@ -655,6 +655,7 @@ machinestatus_view_log = "" machinestatus_view_confirm = "" machinestatus_view_delete = "" machinestatus_view_channel = "" +machinestatus_view_parent = "" machinestatus_view_not_configured = "" machinestatus_view_mirror = "" machinestatus_view_queue_server = "" diff --git a/src/locale/hi/configure.ini b/src/locale/hi/configure.ini index cb4357143..845f73738 100755 --- a/src/locale/hi/configure.ini +++ b/src/locale/hi/configure.ini @@ -655,6 +655,7 @@ machinestatus_view_log = "" machinestatus_view_confirm = "" machinestatus_view_delete = "" machinestatus_view_channel = "" +machinestatus_view_parent = "" machinestatus_view_not_configured = "" machinestatus_view_mirror = "" machinestatus_view_queue_server = "" diff --git a/src/locale/in_ID/configure.ini b/src/locale/in_ID/configure.ini index f5ad33d62..19f3c49bc 100755 --- a/src/locale/in_ID/configure.ini +++ b/src/locale/in_ID/configure.ini @@ -655,6 +655,7 @@ machinestatus_view_log = "" machinestatus_view_confirm = "" machinestatus_view_delete = "" machinestatus_view_channel = "" +machinestatus_view_parent = "" machinestatus_view_not_configured = "" machinestatus_view_mirror = "" machinestatus_view_queue_server = "" diff --git a/src/locale/it/configure.ini b/src/locale/it/configure.ini index 81a632e0f..3276dfd4b 100755 --- a/src/locale/it/configure.ini +++ b/src/locale/it/configure.ini @@ -655,6 +655,7 @@ machinestatus_view_log = "Log" machinestatus_view_confirm = "" machinestatus_view_delete = "" machinestatus_view_channel = "" +machinestatus_view_parent = "" machinestatus_view_not_configured = "" machinestatus_view_mirror = "" machinestatus_view_queue_server = "Server di Coda" diff --git a/src/locale/ja/configure.ini b/src/locale/ja/configure.ini index 14a5bb42f..03420f664 100755 --- a/src/locale/ja/configure.ini +++ b/src/locale/ja/configure.ini @@ -655,6 +655,7 @@ machinestatus_view_log = "" machinestatus_view_confirm = "" machinestatus_view_delete = "" machinestatus_view_channel = "" +machinestatus_view_parent = "" machinestatus_view_not_configured = "" machinestatus_view_mirror = "" machinestatus_view_queue_server = "" diff --git a/src/locale/kn/configure.ini b/src/locale/kn/configure.ini index a12053c87..7f83ee2b5 100755 --- a/src/locale/kn/configure.ini +++ b/src/locale/kn/configure.ini @@ -655,6 +655,7 @@ machinestatus_view_log = "" machinestatus_view_confirm = "" machinestatus_view_delete = "" machinestatus_view_channel = "" +machinestatus_view_parent = "" machinestatus_view_not_configured = "" machinestatus_view_mirror = "" machinestatus_view_queue_server = "" diff --git a/src/locale/ko/configure.ini b/src/locale/ko/configure.ini index 418b025fc..fc7fa571a 100755 --- a/src/locale/ko/configure.ini +++ b/src/locale/ko/configure.ini @@ -655,6 +655,7 @@ machinestatus_view_log = "" machinestatus_view_confirm = "" machinestatus_view_delete = "" machinestatus_view_channel = "" +machinestatus_view_parent = "" machinestatus_view_not_configured = "" machinestatus_view_mirror = "" machinestatus_view_queue_server = "" diff --git a/src/locale/nl/configure.ini b/src/locale/nl/configure.ini index 615bbe9e2..e319200aa 100644 --- a/src/locale/nl/configure.ini +++ b/src/locale/nl/configure.ini @@ -655,6 +655,7 @@ machinestatus_view_log = "Inloggen" machinestatus_view_confirm = "" machinestatus_view_delete = "verwijderen" machinestatus_view_channel = "" +machinestatus_view_parent = "" machinestatus_view_not_configured = "Machine Niet geconfigureerd!" machinestatus_view_mirror = "" machinestatus_view_queue_server = "Queue Server" diff --git a/src/locale/pl/configure.ini b/src/locale/pl/configure.ini index 88076fd63..b51c90cf8 100755 --- a/src/locale/pl/configure.ini +++ b/src/locale/pl/configure.ini @@ -655,6 +655,7 @@ machinestatus_view_log = "" machinestatus_view_confirm = "" machinestatus_view_delete = "" machinestatus_view_channel = "" +machinestatus_view_parent = "" machinestatus_view_not_configured = "" machinestatus_view_mirror = "" machinestatus_view_queue_server = "" diff --git a/src/locale/pt/configure.ini b/src/locale/pt/configure.ini index 9fe0787be..9d0096fb2 100755 --- a/src/locale/pt/configure.ini +++ b/src/locale/pt/configure.ini @@ -655,6 +655,7 @@ machinestatus_view_log = "" machinestatus_view_confirm = "" machinestatus_view_delete = "" machinestatus_view_channel = "" +machinestatus_view_parent = "" machinestatus_view_not_configured = "" machinestatus_view_mirror = "" machinestatus_view_queue_server = "" diff --git a/src/locale/ru/configure.ini b/src/locale/ru/configure.ini index 4d572dd4c..0ac8a3d8c 100755 --- a/src/locale/ru/configure.ini +++ b/src/locale/ru/configure.ini @@ -655,6 +655,7 @@ machinestatus_view_log = "" machinestatus_view_confirm = "" machinestatus_view_delete = "" machinestatus_view_channel = "" +machinestatus_view_parent = "" machinestatus_view_not_configured = "" machinestatus_view_mirror = "" machinestatus_view_queue_server = "" diff --git a/src/locale/te/configure.ini b/src/locale/te/configure.ini index 494b87bd0..8f4a70799 100644 --- a/src/locale/te/configure.ini +++ b/src/locale/te/configure.ini @@ -655,6 +655,7 @@ machinestatus_view_log = "" machinestatus_view_confirm = "" machinestatus_view_delete = "" machinestatus_view_channel = "" +machinestatus_view_parent = "" machinestatus_view_not_configured = "" machinestatus_view_mirror = "" machinestatus_view_queue_server = "" diff --git a/src/locale/th/configure.ini b/src/locale/th/configure.ini index 286458c01..182997b57 100755 --- a/src/locale/th/configure.ini +++ b/src/locale/th/configure.ini @@ -655,6 +655,7 @@ machinestatus_view_log = "" machinestatus_view_confirm = "" machinestatus_view_delete = "" machinestatus_view_channel = "" +machinestatus_view_parent = "" machinestatus_view_not_configured = "" machinestatus_view_mirror = "" machinestatus_view_queue_server = "" diff --git a/src/locale/tr/configure.ini b/src/locale/tr/configure.ini index 4b9f692c0..0375e006f 100755 --- a/src/locale/tr/configure.ini +++ b/src/locale/tr/configure.ini @@ -655,6 +655,7 @@ machinestatus_view_log = "" machinestatus_view_confirm = "" machinestatus_view_delete = "" machinestatus_view_channel = "" +machinestatus_view_parent = "" machinestatus_view_not_configured = "" machinestatus_view_mirror = "" machinestatus_view_queue_server = "" diff --git a/src/locale/vi_VN/configure.ini b/src/locale/vi_VN/configure.ini index a309e6ab8..1b5173e17 100755 --- a/src/locale/vi_VN/configure.ini +++ b/src/locale/vi_VN/configure.ini @@ -655,6 +655,7 @@ machinestatus_view_log = "" machinestatus_view_confirm = "" machinestatus_view_delete = "" machinestatus_view_channel = "" +machinestatus_view_parent = "" machinestatus_view_not_configured = "" machinestatus_view_mirror = "" machinestatus_view_queue_server = "" diff --git a/src/locale/zh_CN/configure.ini b/src/locale/zh_CN/configure.ini index c3d2edf30..17165954e 100755 --- a/src/locale/zh_CN/configure.ini +++ b/src/locale/zh_CN/configure.ini @@ -655,6 +655,7 @@ machinestatus_view_log = "" machinestatus_view_confirm = "" machinestatus_view_delete = "" machinestatus_view_channel = "" +machinestatus_view_parent = "" machinestatus_view_not_configured = "" machinestatus_view_mirror = "" machinestatus_view_queue_server = "" diff --git a/src/models/MachineModel.php b/src/models/MachineModel.php index 59088adcd..ef21761a4 100644 --- a/src/models/MachineModel.php +++ b/src/models/MachineModel.php @@ -67,12 +67,28 @@ class MachineModel extends Model return $this->getMachineStatuses($rows); } /** - * Returns urls for all the queue_servers stored in the DB + * Returns a list of the queue_server (not mirrors) names + * + * @return array of machine names + */ + public function getQueueServerNames() + { + $db = $this->db; + $sql = "SELECT NAME FROM MACHINE WHERE PARENT = '' ORDER BY NAME DESC"; + $result = $db->execute($sql); + $names = []; + while ($row = $db->fetchArray($result)) { + $names[] = $row['NAME']; + } + return $names; + } + /** + * Returns urls for all the queue_servers (not mirrors) stored in the DB * * @param string $crawl_time of a crawl to see the machines used in * that crawl * @param int $channel only return QueueServers on this channel - * @return array machine names + * @return array machine urls */ public function getQueueServerUrls($crawl_time = 0, $channel = -1) { @@ -108,7 +124,7 @@ class MachineModel extends Model $row["URL"] = C\BASE_URL; } if (empty($row["PARENT"]) && - (empty($pre_machines) || in_array($row["URL"], $pre_machines))) { + (empty($pre_machines) || in_array($row["URL"], $pre_machines))){ $machines[$crawl_time][$i] = $row["URL"]; $i++; } @@ -413,7 +429,7 @@ class MachineModel extends Model $parent_row["URL"] == "BASE_URL") { $parent_row["URL"] = C\BASE_URL; } - $url .= "&parent=" . webencode($parent_row["URL"]); + $url .= "&parent=" . L\webencode($parent_row["URL"]); } } } diff --git a/src/views/MachinestatusView.php b/src/views/MachinestatusView.php index 42875f895..adb344c8c 100644 --- a/src/views/MachinestatusView.php +++ b/src/views/MachinestatusView.php @@ -125,13 +125,17 @@ 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']); - if (empty($m['PARENT'])) { - ?><small - style="position:relative;top:-3px;font-weight: normal;">[<?= - tl('machinestatus_view_channel', $m['CHANNEL']) - ?>] [<?= $m['URL']?>]</small><?php - } ?> + <h3 class="no-margin"><?php e($m['NAME']); ?><small + style="position:relative;top:-3px;font-weight: normal;"><?php + if (empty($m['CHANNEL'])) { ?> + [<?= + tl('machinestatus_view_channel', $m['CHANNEL']) + ?>]<?php + } else {?> + [<?= + tl('machinestatus_view_parent', $m['PARENT']) + ?>]<?php + }?>[<?= $m['URL']?>]</small> </h3> <table class="machine-table"> <?php @@ -161,18 +165,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_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'][$m['NAME']]) && ( - !isset($m['STATUSES'][$m['NAME']][-1]) || - !$m['STATUSES'][$m['NAME']][-1]); + $caution = isset($m['STATUSES']['Mirror']) && ( + !isset($m['STATUSES']['Mirror'][-1]) || + !$m['STATUSES']['Mirror'][-1]); $this->helper("toggle")->render( - isset($m['STATUSES'][$m['NAME']]), + isset($m['STATUSES']['Mirror']), $on_mirror, $off_mirror, $caution); ?></td></tr></table></td></tr> </table> diff --git a/src/views/elements/ManagemachinesElement.php b/src/views/elements/ManagemachinesElement.php index 80492dfe3..2715927d0 100644 --- a/src/views/elements/ManagemachinesElement.php +++ b/src/views/elements/ManagemachinesElement.php @@ -81,10 +81,9 @@ class ManagemachinesElement extends Element ?></td></tr> <tr id="m1"><th><label for="parent-machine-name"><?= tl('managemachines_element_parent_name')?></label></th> - <td><input type="text" name="parent" id="parent-machine-name" - maxlength="<?= C\NAME_LEN ?>" class="wide-field" /> - </td> - </tr> + <td><?php $this->view->helper("options")->render( + "parent-machine-name", "parent", + $data['PARENT_MACHINES'], 0); ?></td></tr> <tr id="m2"><th><label for="fetcher-number"><?= tl('managemachines_element_num_fetchers')?></label></th><td> <?php $this->view->helper("options")->render("fetcher-number", diff --git a/src/views/layouts/WebLayout.php b/src/views/layouts/WebLayout.php index d9b2ec825..f78b5f95c 100755 --- a/src/views/layouts/WebLayout.php +++ b/src/views/layouts/WebLayout.php @@ -80,7 +80,7 @@ class WebLayout extends Layout <?php } $path_info = C\BASE_URL; $aux_css = false; - if (file_exists(C\APP_DIR.'/css/auxiliary.css')) { + if (file_exists(C\APP_DIR . '/css/auxiliary.css')) { $aux_css = "$path_info?c=resource&a=get&f=css&n=auxiliary.css"; } /* Remember to give complete paths to all link tag hrefs to