version x.x - Seven Portals (tba)
+ Now including update instructions
+ + Fixed the search for words. See update instructions how to correct your data
version 2.3 - Guardian of Steel (2019-12-30)
-If you are updating from a previous version:
+If you are updating from a previous version make sure every update info from the version
+your are updating from is done.
-2.3 -> x.x
\ No newline at end of file
+x.x
++ Run (after authentication) at /index.php?p=stats the "Search index update" to make the
+search work again correctly. At success, there is no confirmation. To validate you can now search
+for single words case-insensitive.
\ No newline at end of file
If successful you can now manage your items. Edit buttons are visible now.
Moderation and more overview can be access from the stats overview page.
-HowToAdd a new link:
+# HowToAdd a new link:
There is no special "add a new link" option. Just paste the link into the search bar.
If the link is already in your database the edit option will be shown.
If not the add field will be shown and the possibility to safe the new link.
-Usage of the email-importer can be found in the email-importer.txt file
\ No newline at end of file
+Usage of the email-importer can be found in the email-importer.txt file.
+
+# Search
+The search is based on the link, description, tags and categories.
+Technology behind is a mysql fulltext search in BOOLEAN MODE: https://dev.mysql.com/doc/refman/8.0/en/fulltext-boolean.html
+Which means you can use special operators like +- or *
\ No newline at end of file
# time settings
date_default_timezone_set('Europe/Berlin');
-define('DEBUG',false);
+define('DEBUG',true);
## check request
$_urlToParse = filter_var($_SERVER['QUERY_STRING'],FILTER_SANITIZE_STRING, FILTER_FLAG_STRIP_LOW);
$newdata['search'] .= ' '.implode(" ",$newdata['tagArr']);
$newdata['search'] .= ' '.implode(" ",$newdata['catArr']);
$newdata['search'] = trim($newdata['search']);
+ $newdata['search'] = strtolower($newdata['search']);
if(DEBUG === true) var_dump($newdata);
$this->load($this->_data['hash']);
}
- /**
- * create a new link with the given data
- * @param array $data
- * @return boolean|int
- */
+ /**
+ * create a new link with the given data
+ * @param array $data
+ * @param bool $returnId
+ * @return boolean|int
+ */
public function create($data, $returnId = false) {
$ret = false;
$tagArr = Summoner::prepareTagOrCategoryStr($data['tag']);
$search = $data['title'];
- $search .= ' ' . $data['description'];
- $search .= ' ' . implode(" ", $tagArr);
- $search .= ' ' . implode(" ", $catArr);
+ $search .= ' '.$data['description'];
+ $search .= ' '.implode(" ", $tagArr);
+ $search .= ' '.implode(" ", $catArr);
+ $search = trim($search);
+ $search = strtolower($search);
$this->DB->begin_transaction(MYSQLI_TRANS_START_READ_WRITE);
MATCH (`search`) AGAINST ('".$this->DB->real_escape_string($searchStr)."' IN BOOLEAN MODE) AS score
FROM `".DB_PREFIX."_link` AS t
WHERE MATCH (`search`) AGAINST ('".$this->DB->real_escape_string($searchStr)."' IN BOOLEAN MODE)";
- $queryStr .= " WHERE ".$this->_decideLinkTypeForQuery();
+ $queryStr .= " AND ".$this->_decideLinkTypeForQuery();
$queryStr .= " ORDER BY score DESC";
$query = $this->DB->query($queryStr);
* for simpler management we have the search data in a separate column
* it is not fancy or even technical nice but it damn works
*/
- private function _updateSearchIndex() {
+ public function updateSearchIndex() {
+ $ret = false;
+
$allLinks = array();
$queryStr = "SELECT hash FROM `".DB_PREFIX."_link`";
$query = $this->DB->query($queryStr);
$searchStr = $l['title'];
$searchStr .= ' '.$l['description'];
- foreach($l['tags'] as $t) {
- $searchStr .= ' '.$t['tag'];
- }
- foreach($l['categories'] as $c) {
- $searchStr .= ' '.$c['category'];
- }
+ $searchStr .= ' '.implode(' ',$l['tags']);
+ $searchStr .= ' '.implode(' ',$l['categories']);
+ $searchStr = trim($searchStr);
+ $searchStr = strtolower($searchStr);
# now update the search string
$queryStr = "UPDATE `".DB_PREFIX."_link`
unset($LinkObj,$l,$searchStr,$t,$c,$queryStr);
}
+
+ $ret = true;
}
+
+ return $ret;
}
/**
# search or new one.
if(isset($_POST['data']) && !empty($_POST['data']) && isset($_POST['submitsearch']) && $honeypotCheck === false) {
$searchValue = trim($_POST['data']['searchfield']);
+ $searchValue = strtolower($searchValue);
$isUrl = Summoner::validate($searchValue,'url');
if($isUrl === true) {
# search for URL
$search .= ' '.implode(" ",$tagArr);
$search .= ' '.implode(" ",$catArr);
$search .= trim($search);
+ $search = strtolower($search);
$DB->begin_transaction(MYSQLI_TRANS_START_READ_WRITE);
exit();
}
+if(isset($_POST['statsUpdateSearchIndex'])) {
+
+ if($Management->updateSearchIndex() === true) {
+ $TemplateData['refresh'] = 'index.php?p=stats';
+ }
+ else {
+ $submitFeedback['message'] = 'Something went wrong while search index update';
+ $submitFeedback['status'] = 'error';
+ }
+}
+
+
+
$linkAmount = $Management->linkAmount();
$tagAmount = $Management->tagAmount();
$categoryAmount = $Management->categoryAmount();
<form method="post">
<input type="submit" class="button is-info is-small" value="Create backup" name="statsCreateDBBackup">
</form>
+ </div>
+ <div class="column is-one-quarter">
+ <h4 class="is-size-4">Search index</h4>
+ <p>Update search index</p>
+ <form method="post">
+ <input type="submit" class="button is-info is-small" value="Update index" name="statsUpdateSearchIndex">
+ </form>
</div>
<?php } ?>
</div>