viewgit/inc/functions.php:22 Function utf8_encode() is deprecated [8192]

Fix issue with Machine log filter, a=chris

Chris Pollett [2019-01-25 04:Jan:th]
Fix issue with Machine log filter, a=chris
Filename
src/controllers/FetchController.php
src/controllers/MachineController.php
src/executables/Fetcher.php
src/library/FetchUrl.php
diff --git a/src/controllers/FetchController.php b/src/controllers/FetchController.php
index e32b53bd2..88aaddd09 100755
--- a/src/controllers/FetchController.php
+++ b/src/controllers/FetchController.php
@@ -81,19 +81,12 @@ class FetchController extends Controller implements CrawlConstants
          */
         if (!$this->checkRequest()) {
             $this->web_site->header("HTTP/1.0 400 Bad Request");
-            $request = [];
-            echo "BAD REQUEST!\n";
-            foreach(['time', 'session', 'a', 'c'] as $part) {
-                if (!empty($_REQUEST[$part])) {
-                    echo $_REQUEST[$part] . "\n";
-                }
-            }
             return;
         }
         $activity = $_REQUEST['a'];
         $channel = $this->getChannel();
         $this->crawl_status_file_name =
-                C\CRAWL_DIR . "/schedules/{$channel}-crawl_status.txt";
+            C\CRAWL_DIR . "/schedules/{$channel}-crawl_status.txt";
         $robot_table_name = C\CRAWL_DIR . "/{$channel}-" .
             self::robot_table_name;
         $robot_table = [];
@@ -155,7 +148,7 @@ class FetchController extends Controller implements CrawlConstants
             $this->checkRestart(self::WEB_CRAWL);
             $info = [];
             $info[self::STATUS] = self::NO_DATA_STATE;
-            $data['MESSAGE'] = base64_encode(serialize($info))."\n";
+            $data['MESSAGE'] = base64_encode(serialize($info)) . "\n";
         }
         $this->displayView($view, $data);
     }
diff --git a/src/controllers/MachineController.php b/src/controllers/MachineController.php
index a01b42ea6..ce8607316 100644
--- a/src/controllers/MachineController.php
+++ b/src/controllers/MachineController.php
@@ -212,7 +212,7 @@ class MachineController extends Controller implements CrawlConstants
                 $log_data = fread($fh, $len);
                 fclose($fh);
             }
-            if ($filter = "" && strlen($log_data) > 0) {
+            if ($filter != "" && strlen($log_data) > 0) {
                 $log_lines = explode("\n", $log_data);
                 $out_lines = [];
                 foreach ($log_lines as $line) {
diff --git a/src/executables/Fetcher.php b/src/executables/Fetcher.php
index fe092abbc..5e0d0d165 100755
--- a/src/executables/Fetcher.php
+++ b/src/executables/Fetcher.php
@@ -1153,7 +1153,7 @@ class Fetcher implements CrawlConstants
             "&machine_uri=" . C\WEB_URI . "&crawl_time=" . $this->crawl_time .
             "&check_crawl_time=" . $this->check_crawl_time;
         $info_string = FetchUrl::getPage($request, null, true);
-        L\crawlLog("Making schedule request: ". $request);
+        L\crawlLog("Making schedule request: " . $request);
         if ($info_string === false) {
             L\crawlLog("The request failed!!!!");
             return false;
diff --git a/src/library/FetchUrl.php b/src/library/FetchUrl.php
index eb69ac21d..df3a4fd4a 100755
--- a/src/library/FetchUrl.php
+++ b/src/library/FetchUrl.php
@@ -803,6 +803,7 @@ class FetchUrl implements CrawlConstants
                     curl_close($agent_host);
                 }
             }
+            $host =  ($post_data) ? "POST " . $host : "GET " . $host;
             if (empty($agents[$host])) {
                 $agents[$host] = curl_init();
             }
@@ -816,12 +817,12 @@ class FetchUrl implements CrawlConstants
         curl_setopt($agents[$host], CURLOPT_FOLLOWLOCATION, true);
         /* curl http2 can cause problems when compiled against an older version
            of openssl. This seems to mainly affect posting data, so for
-           now we use HTTP/1.1.
+           now we use HTTP/1.1 to post.
          */
-        /*if ($post_data == null) {
+        if ($post_data == null) {
             curl_setopt($agents[$host], CURLOPT_HTTP_VERSION,
                 CURL_HTTP_VERSION_2_0);
-        }*/
+        }
         // these next two lines should probably be modified for better security
         curl_setopt($agents[$host], CURLOPT_SSL_VERIFYHOST, 0);
         curl_setopt($agents[$host], CURLOPT_SSL_VERIFYPEER, false);
ViewGit