-0.5 Lykos -
- + Initial beta release
- + Some PHP syntax stuff
+1.0 Lykos -
+ + Initial release
--- /dev/null
+- i18n
+- ignorewords
-0.5 - Lykos
+1.0 - Lykos
`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
/**
* scientia
*
- * Copyright 2021 Johannes Keßler
+ * Copyright 2022 Johannes Keßler
*
* https://www.bananas-playground.net/projekt/scientia/
*
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) {
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';
/**
* scientia
*
- * Copyright 2021 Johannes Keßler
+ * Copyright 2022 Johannes Keßler
*
* https://www.bananas-playground.net/projekt/scientia/
*
*
* @var mysqli
*/
- private $_DB;
+ private mysqli $_DB;
/**
* Entry constructor.
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
*
<form method="post">
<textarea rows="25" placeholder="write here" name="fdata[entry]"><?php echo Summoner::ifset($TemplateData['data'],'body'); ?></textarea>
<input type="submit" name="submitForm" value="Save">
-
+ <input type="checkbox" name="deleteEntry" value="yes" /> <small style="color: indianred">Delete Entry</small>
</form>
<p>
-<?php if(!empty($TemplateData['data'])) { ?>
-<a href="<?php echo PATH_WEBROOT; ?>/new">New</a><br />
+<a href="<?php echo PATH_WEBROOT; ?>">Home</a>
+<?php if(!empty($TemplateData['data'])) {
+ echo ' | ';
+ $_link = '';
+ foreach($TemplateData['data']['breadcrumb'] as $be) {
+ $_link .= '/'.$be;
+ echo '<a href="'.PATH_WEBROOT.$_link.'">'.$be.'</a> | ';
+ }
+?>
+ <a href="<?php echo PATH_WEBROOT; ?>/new">New</a>
<?php } ?>
-<a href="<?php echo PATH_WEBROOT; ?>"><- back</a>
</p>
/**
* scientia
*
- * Copyright 2021 Johannes Keßler
+ * Copyright 2022 Johannes Keßler
*
* https://www.bananas-playground.net/projekt/scientia/
*
$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'])) {
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;
}
<p>
- <a href="<?php echo PATH_WEBROOT; ?>/new">New</a>
+ <a href="<?php echo PATH_WEBROOT; ?>/">Home</a> | <a href="<?php echo PATH_WEBROOT; ?>/new">New</a>
</p>
<?php if(!empty($TemplateData['entries'])) { ?>
<?php
- foreach($TemplateData['entries'] as $gk=>$g) {
- echo $gk;
+ foreach($TemplateData['entries'] as $k=>$v) {
+ $_link = '';
+ foreach($v['breadcrumb'] as $be) {
+ $_link .= '/'.$be;
+ echo '<a href="'.PATH_WEBROOT.$_link.'">'.$be.'</a> ';
+ }
?>
<ul>
- <?php foreach($g as $e) { ?>
+ <?php foreach($v['e'] as $e) { ?>
<li><a href="<?php echo PATH_WEBROOT; ?>/<?php echo $e['link']; ?>"><?php echo $e['ident']; ?></a> <?php echo $e['date']; ?> <?php echo htmlspecialchars($e['body'],ENT_HTML5); ?></li>
<?php } ?>
</ul>
// 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";
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'];
}
}
}