From: Banana Date: Sat, 12 Nov 2022 11:38:10 +0000 (+0100) Subject: better navigation X-Git-Tag: v1.0~3 X-Git-Url: http://91.132.146.200/gitweb/?a=commitdiff_plain;h=abf896cff1ab6ffa65d5fb5395dd371b1d037f56;p=scientia.git better navigation --- diff --git a/CHANGELOG b/CHANGELOG index c43ba02..d1ddeba 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,3 +1,2 @@ -0.5 Lykos - - + Initial beta release - + Some PHP syntax stuff +1.0 Lykos - + + Initial release diff --git a/TODO b/TODO new file mode 100644 index 0000000..ebea391 --- /dev/null +++ b/TODO @@ -0,0 +1,2 @@ +- i18n +- ignorewords diff --git a/VERSION b/VERSION index acf27ca..3903967 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -0.5 - Lykos +1.0 - Lykos diff --git a/documentation/scientia.sql.txt b/documentation/scientia.sql.txt index d31a677..3c1ab73 100644 --- a/documentation/scientia.sql.txt +++ b/documentation/scientia.sql.txt @@ -6,5 +6,6 @@ CREATE TABLE `sc_entry` ( `body` text CHARACTER SET utf8mb4 COLLATE utf8mb4_bin NOT NULL, `words` text CHARACTER SET utf8mb4 COLLATE utf8mb4_bin NOT NULL, PRIMARY KEY (`ident`) USING BTREE, - KEY `date` (`date`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin; + KEY `date` (`date`), + FULLTEXT KEY `words` (`words`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci diff --git a/webroot/index.php b/webroot/index.php index acf49c0..18682a6 100644 --- a/webroot/index.php +++ b/webroot/index.php @@ -2,7 +2,7 @@ /** * scientia * - * Copyright 2021 Johannes Keßler + * Copyright 2022 Johannes Keßler * * https://www.bananas-playground.net/projekt/scientia/ * @@ -20,7 +20,7 @@ mb_internal_encoding('UTF-8'); ini_set('error_reporting',-1); // E_ALL & E_STRICT ## check request -$_urlToParse = filter_var($_SERVER['QUERY_STRING'],FILTER_SANITIZE_STRING, FILTER_FLAG_STRIP_LOW); +$_urlToParse = filter_var($_SERVER['QUERY_STRING'],FILTER_UNSAFE_RAW, FILTER_FLAG_STRIP_LOW); if(!empty($_urlToParse)) { # see http://de2.php.net/manual/en/regexp.reference.unicode.php if(preg_match('/[\p{C}\p{M}\p{Sc}\p{Sk}\p{So}\p{Zl}\p{Zp}]/u',$_urlToParse) === 1) { @@ -71,15 +71,15 @@ $TemplateData = array(); if(isset($_GET['y']) && Summoner::validate($_GET['y'], 'digit')) { $_year = trim($_GET['y']); - $_requestDateProvided .= 'y'; + $_requestDateProvided .= 'Y'; } if(isset($_GET['m']) && Summoner::validate($_GET['m'], 'digit')) { $_month = trim($_GET['m']); - $_requestDateProvided .= 'm'; + $_requestDateProvided .= '-m'; } if(isset($_GET['d']) && Summoner::validate($_GET['d'], 'digit')) { $_day = trim($_GET['d']); - $_requestDateProvided .= 'd'; + $_requestDateProvided .= '-d'; } if(isset($_GET['p']) && Summoner::validate($_GET['p'], 'nospace') && $_GET['p'] == "new") { $_view = 'entry'; diff --git a/webroot/lib/entry.class.php b/webroot/lib/entry.class.php index 8ff1e9a..e6ce324 100644 --- a/webroot/lib/entry.class.php +++ b/webroot/lib/entry.class.php @@ -2,7 +2,7 @@ /** * scientia * - * Copyright 2021 Johannes Keßler + * Copyright 2022 Johannes Keßler * * https://www.bananas-playground.net/projekt/scientia/ * @@ -26,7 +26,7 @@ class Entry { * * @var mysqli */ - private $_DB; + private mysqli $_DB; /** * Entry constructor. @@ -129,6 +129,31 @@ class Entry { return $ret; } + /** + * Delete given id from _entry table + * + * @param string $id + * @return bool + */ + public function delete(string $id): bool { + $ret = false; + + if(!empty($id)) { + $queryStr = "DELETE FROM `".DB_PREFIX."_entry` + WHERE `ident` = '".$this->_DB->real_escape_string($id)."'"; + if(QUERY_DEBUG) error_log("[QUERY] ".__METHOD__." query: ".var_export($queryStr,true)); + try { + $this->_DB->query($queryStr); + $ret = true; + } + catch(Exception $e) { + error_log("[ERROR] ".__METHOD__." catch: ".$e->getMessage()); + } + } + + return $ret; + } + /** * Create unique words from the given data * diff --git a/webroot/view/entry/entry.html b/webroot/view/entry/entry.html index 0e956c0..021e146 100644 --- a/webroot/view/entry/entry.html +++ b/webroot/view/entry/entry.html @@ -4,11 +4,18 @@
- + Delete Entry

- -New
+Home +'.$be.' | '; + } +?> + New -<- back

diff --git a/webroot/view/entry/entry.php b/webroot/view/entry/entry.php index 61fac29..704b56a 100644 --- a/webroot/view/entry/entry.php +++ b/webroot/view/entry/entry.php @@ -2,7 +2,7 @@ /** * scientia * - * Copyright 2021 Johannes Keßler + * Copyright 2022 Johannes Keßler * * https://www.bananas-playground.net/projekt/scientia/ * @@ -21,6 +21,7 @@ $Entry = new Entry($DB); $TemplateData['data'] = array(); if(!empty($_id)) { $TemplateData['data'] = $Entry->load($_year,$_month,$_day,$_id); + $TemplateData['data']['breadcrumb'] = array($_year,$_month,$_day); } if(isset($_POST['submitForm']) && isset($_POST['fdata'])) { @@ -28,7 +29,11 @@ if(isset($_POST['submitForm']) && isset($_POST['fdata'])) { if(isset($fdata['entry']) && Summoner::validate($fdata['entry'])) { $_dataToSave = trim($fdata['entry']); - if(!empty($_id)) { + if(!empty($_id) && isset($_POST['deleteEntry']) && $_POST['deleteEntry'] == "yes") { + $do = $Entry->delete($_id); + $_r = '/'; + } + elseif(!empty($_id)) { $do = $Entry->update($_dataToSave,$_id); $_r = '/'.$_year.'/'.$_month.'/'.$_day.'/'.$_id; } diff --git a/webroot/view/list/list.html b/webroot/view/list/list.html index 020835e..20e4436 100644 --- a/webroot/view/list/list.html +++ b/webroot/view/list/list.html @@ -1,13 +1,17 @@

- New + Home | New

$g) { - echo $gk; + foreach($TemplateData['entries'] as $k=>$v) { + $_link = ''; + foreach($v['breadcrumb'] as $be) { + $_link .= '/'.$be; + echo ''.$be.' '; + } ?> diff --git a/webroot/view/list/list.php b/webroot/view/list/list.php index 9e06806..eee4c82 100644 --- a/webroot/view/list/list.php +++ b/webroot/view/list/list.php @@ -23,34 +23,38 @@ $queryLimit = " LIMIT 100"; // why? // mysql knows the dates and validates them. There is no 2020-02-31 // the single date infos come from index.php -$groupByFormat = $_year; +$_groupByFormat = $_year; +$breadcrumb = array('Y'); if(!empty($_requestDateProvided)) { $_intervalStart = ''; $_intervalEnd = ''; - if($_requestDateProvided === 'ymd') { + if($_requestDateProvided === 'Y-m-d') { $queryLimit = ""; - $groupByFormat = $_year.'-'.$_month.'-'.$_day; - $_intervalStart = $groupByFormat; - $_intervalEnd = $groupByFormat; - + $_groupByFormat = $_year.'-'.$_month.'-'.$_day; + $_intervalStart = $_groupByFormat; + $_intervalEnd = $_groupByFormat; + $breadcrumb = array('Y','m','d'); } - elseif ($_requestDateProvided === 'ym') { + elseif ($_requestDateProvided === 'Y-m') { $queryLimit = ""; - $groupByFormat = $_year.'-'.$_month; - $_intervalStart = $groupByFormat.'-01'; + $_groupByFormat = $_year.'-'.$_month; + $_intervalStart = $_groupByFormat.'-01'; $_tDate = new DateTime( $_intervalStart ); $_monthDays = $_tDate->format( 't' ); - $_intervalEnd = $groupByFormat.'-'.$_monthDays; + $_intervalEnd = $_groupByFormat.'-'.$_monthDays; + $breadcrumb = array('Y','m'); } - elseif ($_requestDateProvided === 'y') { - $_intervalStart = $groupByFormat.'-01-01'; - $_intervalEnd = $groupByFormat.'-12-31'; + elseif ($_requestDateProvided === 'Y') { + $_intervalStart = $_groupByFormat.'-01-01'; + $_intervalEnd = $_groupByFormat.'-12-31'; } if(!empty($_intervalStart) && !empty($_intervalEnd)) { $queryStr .= " WHERE `date` >= '".$_intervalStart."' AND `date` <= '".$_intervalEnd."'"; } +} else { + $_requestDateProvided = 'Y'; } $queryStr .= " ORDER BY `created` DESC"; @@ -62,8 +66,13 @@ try { if($query !== false && $query->num_rows > 0) { while(($result = $query->fetch_assoc()) != false) { $_d = new DateTime($result['date']); - $TemplateData['entries'][$_d->format($groupByFormat)][$result['ident']] = $result; - $TemplateData['entries'][$_d->format($groupByFormat)][$result['ident']]['link'] = str_replace('-','/',$result['date']).'/'.$result['ident']; + $_breadcrumb = array(); + foreach($breadcrumb as $_b) { + $_breadcrumb[] = $_d->format($_b); + } + $TemplateData['entries'][$_d->format($_requestDateProvided)]['breadcrumb'] = $_breadcrumb; + $TemplateData['entries'][$_d->format($_requestDateProvided)]['e'][$result['ident']] = $result; + $TemplateData['entries'][$_d->format($_requestDateProvided)]['e'][$result['ident']]['link'] = str_replace('-','/',$result['date']).'/'.$result['ident']; } } }