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

More safe search tweaks, a=chris

Chris Pollett [2019-06-11 04:Jun:th]
More safe search tweaks, a=chris
Filename
src/controllers/SettingsController.php
src/models/PhraseModel.php
src/views/SettingsView.php
diff --git a/src/controllers/SettingsController.php b/src/controllers/SettingsController.php
index 5e65710d7..a4467f718 100755
--- a/src/controllers/SettingsController.php
+++ b/src/controllers/SettingsController.php
@@ -104,12 +104,12 @@ class SettingsController extends Controller
         }
         if ($token_okay &&  isset($_REQUEST['perpage'])) {
             $_SESSION['SAFE_SEARCH'] = (isset($_REQUEST['safe_search'])) ?
-                true : false;
+                "true" : "false";
         }
         if (isset($_SESSION['SAFE_SEARCH'])) {
             $data['SAFE_SEARCH'] = $_SESSION['SAFE_SEARCH'];
         } else {
-            $data['SAFE_SEARCH'] = true;
+            $data['SAFE_SEARCH'] = "true";
         }
         $machine_urls = $this->model("machine")->getQueueServerUrls();
         $crawls = $crawl_model->getCrawlList(false, true, $machine_urls,
diff --git a/src/models/PhraseModel.php b/src/models/PhraseModel.php
index be576beec..3d65200b5 100755
--- a/src/models/PhraseModel.php
+++ b/src/models/PhraseModel.php
@@ -784,7 +784,7 @@ class PhraseModel extends ParallelModel
             }
             if (!$found_safe) {
                 $found_metas[] = (!isset($_SESSION['SAFE_SEARCH']) ||
-                    $_SESSION['SAFE_SEARCH']) ? "safe:true" :
+                    $_SESSION['SAFE_SEARCH'] == "true") ? "safe:true" :
                     "safe:all";
             }
         }
@@ -1567,8 +1567,9 @@ class PhraseModel extends ParallelModel
                         $disjunct .= " lang:" . $lang_parts[0];
                     }
                     if (!stristr($disjunct, "safe:")) {
-                        $disjunct .= (empty($_SESSION['SAFE_SEARCH'])) ?
-                            " safe:true" : " safe:" . $_SESSION['SAFE_SEARCH'];
+                        $disjunct .= (!isset($_SESSION['SAFE_SEARCH']) ||
+                            $_SESSION['SAFE_SEARCH'] == "true") ?
+                            " safe:true" : " safe:all";
                     }
                 }
                 $out_query .= $pipe . $disjunct;
diff --git a/src/views/SettingsView.php b/src/views/SettingsView.php
index ab8bcd636..aa458a45e 100755
--- a/src/views/SettingsView.php
+++ b/src/views/SettingsView.php
@@ -89,7 +89,8 @@ class SettingsView extends View
     tl('settings_view_safe_search') ?></b></label></td><td
     class="table-input"><input type="checkbox" id="safe-search"
         name="safe_search" value="true"
-        <?php  if (!empty($data['SAFE_SEARCH'])) {
+        <?php  if (isset($data['SAFE_SEARCH']) &&
+            $data['SAFE_SEARCH'] == 'true') {
             ?>checked='checked'<?php
         } ?> />
 </td></tr>
ViewGit