diff --git a/testbin/2c-ajax-tag.php b/testbin/2c-ajax-tag.php deleted file mode 100644 index 7ac580b..0000000 --- a/testbin/2c-ajax-tag.php +++ /dev/null @@ -1,35 +0,0 @@ - 0, - "message" => "Invalid request" - ]); - break; - - // GET TAGS FOR POST - case "get": - $tags = $tagDB->getAll($_POST['post_id']); - echo json_encode([ - "status" => is_array($tags) ? 1 : 0, - "message" => $tags - ]); - break; - - // SAVE TAGS - case "save": - $pass = $tagDB->reTag($_POST['post_id'], json_decode($_POST['tags'])); - echo json_encode([ - "status" => $pass ? 1 : 0, - "message" => $pass ? "OK" : $tagDB->error - ]); - break; -} -?> \ No newline at end of file diff --git a/testbin/3a-my-post.php b/testbin/3a-my-post.php deleted file mode 100644 index 85c8583..0000000 --- a/testbin/3a-my-post.php +++ /dev/null @@ -1,54 +0,0 @@ -getAll($postID); - -// HTML ?> - - - - Simple Tag Demo - - - - - -

- Lord of the Minks -

-

- The undone complaint collapses past an east estate. The insulting nurse flames the era. A willed hierarchy surfaces. - A tentative wife bites the consenting fence. -

- - -
-

MANAGE TAGS

- - -
%s
", $t); - } - } - ?>
- - - - - - - - - - \ No newline at end of file diff --git a/testbin/README.txt b/testbin/README.txt deleted file mode 100644 index 3da2823..0000000 --- a/testbin/README.txt +++ /dev/null @@ -1,29 +0,0 @@ -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= -LICENSE -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= - -Copyright 2019 by Code Boxx - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all -copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -SOFTWARE. - - -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= -MORE -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= -Please visit https://code-boxx.com/ for more! \ No newline at end of file diff --git a/testbin/lib/2a-config.php b/testbin/lib/2a-config.php deleted file mode 100644 index 1c22c57..0000000 --- a/testbin/lib/2a-config.php +++ /dev/null @@ -1,14 +0,0 @@ - \ No newline at end of file diff --git a/testbin/lib/2b-lib-tag.php b/testbin/lib/2b-lib-tag.php deleted file mode 100644 index 1fe06ca..0000000 --- a/testbin/lib/2b-lib-tag.php +++ /dev/null @@ -1,179 +0,0 @@ -pdo = new PDO( - $str, DB_USER, DB_PASSWORD, [ - PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION, - PDO::ATTR_DEFAULT_FETCH_MODE => PDO::FETCH_ASSOC, - PDO::ATTR_EMULATE_PREPARES => false - ] - ); - } // ERROR - CRITICAL STOP - THROW ERROR MESSAGE - catch (Exception $ex) { - print_r($ex); - die(); - } - } - - function __destruct() { - // __destruct() : close connection when done - - if ($this->stmt !== null) { - $this->stmt = null; - } - if ($this->pdo !== null) { - $this->pdo = null; - } - } - - function exec($sql, $data = null) { - // exec() : run insert, replace, update, delete query - // PARAM $sql : SQL query - // $data : array of data - - try { - $this->stmt = $this->pdo->prepare($sql); - $this->stmt->execute($data); - $this->lastID = $this->pdo->lastInsertId(); - } catch (Exception $ex) { - $this->error = $ex; - return false; - } - $this->stmt = null; - return true; - } - - function start() { - // start() : auto-commit off - - $this->pdo->beginTransaction(); - } - - function end($commit = 1) { - // end() : commit or roll back? - - if ($commit) { - $this->pdo->commit(); - } else { - $this->pdo->rollBack(); - } - } - - function fetchAll($sql, $cond = null, $key = null, $value = null) { - // fetchAll() : perform select query (multiple rows expected) - // PARAM $sql : SQL query - // $cond : array of conditions - // $key : sort in this $key=>data order, optional - // $value : $key must be provided. If string provided, sort in $key=>$value order. If function provided, will be a custom sort. - - $result = []; - try { - $this->stmt = $this->pdo->prepare($sql); - $this->stmt->execute($cond); - // Sort in given order - if (isset($key)) { - if (isset($value)) { - if (is_callable($value)) { - while ($row = $this->stmt->fetch(PDO::FETCH_NAMED)) { - $result[$row[$key]] = $value($row); - } - } else { - while ($row = $this->stmt->fetch(PDO::FETCH_NAMED)) { - $result[$row[$key]] = $row[$value]; - } - } - } else { - while ($row = $this->stmt->fetch(PDO::FETCH_NAMED)) { - $result[$row[$key]] = $row; - } - } - } // No key-value sort order - else { - $result = $this->stmt->fetchAll(); - } - } catch (Exception $ex) { - $this->error = $ex; - return false; - } - // Return result - $this->stmt = null; - return count($result) == 0 ? false : $result; - } - - function fetchCol($sql, $cond = null) { - // fetchCol() : yet another version of fetch that returns a flat array - // I.E. Good for one column SELECT `col` FROM `table` - - $this->stmt = $this->pdo->prepare($sql); - $this->stmt->execute($cond); - $result = $this->stmt->fetchAll(PDO::FETCH_COLUMN, 0); - return count($result) == 0 ? false : $result; - } - - /* [TAG FUNCTIONS] */ - function getAll($id) { - // get all tags for the given post ID - - $sql = "SELECT * FROM `tags` WHERE `post_id`=?"; - return $this->fetchCol("SELECT `tag` FROM `tags` WHERE `post_id`=?", [$id]); - } - - function search($tag) { - // search() : search for posts with the given tag - - return $this->fetchAll( - "SELECT p.* FROM `tags` t LEFT JOIN posts `p` USING (`post_id`) WHERE t.`tag`=?", - [$tag], - "post_id" - ); - } - - function reTag($id, $tags = null) { - // reTag() : replace tags for the given post ID - // PARAM $id : post ID - // $tags : array of tags - - // Auto-commit off - $this->start(); - - // Remove old tags first - $pass = $this->exec( - "DELETE FROM `tags` WHERE `post_id`=?", [$id] - ); - - // Add new tags - If any - // Might be a good idea to limit the total number of tags... - if ($pass && is_array($tags) && count($tags) > 0) { - $sql = "INSERT INTO `tags` (`post_id`, `tag`) VALUES "; - $data = []; - foreach ($tags as $t) { - $sql .= "(?,?),"; - $data[] = $id; - $data[] = $t; - } - $sql = substr($sql, 0, -1); - $pass = $this->exec($sql, $data); - } - - // End - commit or rollback - $this->end($pass); - return $pass; - } -} - -?> \ No newline at end of file diff --git a/testbin/public/3b-tag.js b/testbin/public/3b-tag.js deleted file mode 100644 index 8398b84..0000000 --- a/testbin/public/3b-tag.js +++ /dev/null @@ -1,97 +0,0 @@ -var tag = { - list: [], // Existing list of tags - add: function (evt) { - // tag.add() : press comma or enter to add tag - - if (evt.key == "," || evt.key == "Enter") { - // Input check - var tagged = evt.key == "," ? this.value.slice(0, -1) : this.value, - error = ""; - - // Freaking joker empty input - if (tagged == "") { - error = "Please enter a valid tag"; - } - - // Check if already in tags list - if (error == "") { - if (tag.list.indexOf(tagged) != -1) { - error = tagged + " is already defined"; - } - } - - // OK - Create new tag - if (error == "") { - var newTag = document.createElement("div"); - newTag.classList.add("tag"); - newTag.innerHTML = tagged; - newTag.addEventListener("click", tag.remove); - document.getElementById("tag_list").appendChild(newTag); - tag.list.push(tagged); - this.value = ""; - } - - // Not OK - Show error message - else { - this.value = tagged; - alert(error); - } - } - }, - - remove: function () { - // tag.remove() : remove tag - - // Remove tag from list array first - // var pos = tag.list.indexOf(this.innerHTML); - tag.list.splice(tag.list.indexOf(this.innerHTML), 1); - - // Remove HTML tag - document.getElementById("tag_list").removeChild(this); - }, - - save: function () { - // tag.save() : save the tags - - // DATA - var data = new FormData(); - data.append('req', 'save'); - data.append('post_id', document.getElementById('post_id').value); - data.append('tags', JSON.stringify(tag.list)); - - // AJAX - var xhr = new XMLHttpRequest(); - xhr.open('POST', "2c-ajax-tag.php", true); - xhr.onload = function () { - var res = JSON.parse(this.response); - // OK - if (res.status == 1) { - alert("Save OK"); - } else { - alert(res.message); - } - }; - xhr.send(data); - return false; - } -}; - -// INIT ON WINDOW LOAD -window.addEventListener("load", function () { - // Get list of existing tags - var all = document.querySelectorAll("#tag_list div.tag"); - if (all.length > 0) { - for (var t of all) { - tag.list.push(t.innerHTML); - // Attach remove listener to tags - t.addEventListener("click", tag.remove); - } - } - - // Attach comma listener to input field - document.getElementById("tag_in").addEventListener("keyup", tag.add); - - // Enable controls - document.getElementById("tag_in").disabled = false; - document.getElementById("tag_save").disabled = false; -}); \ No newline at end of file diff --git a/testbin/public/3c-tag.css b/testbin/public/3c-tag.css deleted file mode 100644 index ca256bc..0000000 --- a/testbin/public/3c-tag.css +++ /dev/null @@ -1,63 +0,0 @@ -/* [TAGS LIST] */ -#tag_dock { - max-width: 400px; - padding: 20px; - background: #f7f7f7; -} - -#tag_dock h3 { - margin: 0 0 3px 0; - color: #bf4646; -} - -#tag_list { - width: 100%; - display: flex; - flex-direction: row; - flex-wrap: wrap; -} - -#tag_list div.tag { - box-sizing: border-box; - font-size: 0.9em; - width: 30%; - margin: 3px; - padding: 5px; - border: 1px solid #aaa; - background: #e8f2ff; -} - -#tag_list div:hover { - background: #ffe8e8; - cursor: pointer; -} - -/* [TAGS FORM] */ -#tag_dock label, #tag_dock input { - box-sizing: border-box; - display: block; - width: 100%; - margin-top: 8px; -} - -#tag_dock label { - font-size: 0.9em; - color: #888; -} - -#tag_dock input { - padding: 8px; - font-size: 1em; -} - -#tag_dock input[type=button] { - background: #2f75b7; - color: #fff; - cursor: pointer; - border: 0; -} - -/* [DOES NOT MATTER] */ -html, body { - font-family: arial, sans-serif; -} \ No newline at end of file diff --git a/testbin/sql/1a-tags.sql b/testbin/sql/1a-tags.sql deleted file mode 100644 index 43bebdb..0000000 --- a/testbin/sql/1a-tags.sql +++ /dev/null @@ -1,10 +0,0 @@ -CREATE TABLE `tags` -( - `post_id` int(11) NOT NULL, - `tag` varchar(32) NOT NULL -) ENGINE = InnoDB - DEFAULT CHARSET = latin1; - -ALTER TABLE `tags` - ADD PRIMARY KEY (`post_id`, `tag`); -COMMIT; \ No newline at end of file diff --git a/testbin/sql/1b-posts.sql b/testbin/sql/1b-posts.sql deleted file mode 100644 index 5ac0d13..0000000 --- a/testbin/sql/1b-posts.sql +++ /dev/null @@ -1,25 +0,0 @@ -CREATE TABLE `posts` -( - `post_id` int(11) NOT NULL, - `post_title` text NOT NULL, - `post_txt` text NOT NULL -) ENGINE = InnoDB - DEFAULT CHARSET = latin1; - -INSERT INTO `posts` (`post_id`, `post_title`, `post_txt`) -VALUES (1, 'Stream of Rainbow', - 'Can the predecessor hope the diesel? The unknown bombs whatever buried manpower. The crucial boy tenders a developed blurb. A top law clicks before a release. Why does our employee monitor the many lawyer? An ear fumes.'), - (2, 'Misty in the Wings', - 'When will a competing helmet react in a noise? A paragraph acts above the agenda! A kept delight repairs a controlling crush. Can the procedure vanish? The documented rectangle inconveniences a hysterical luggage. The learned tobacco screams.'), - (3, 'Lord of the Minks', - 'The undone complaint collapses past an east estate. The insulting nurse flames the era. A willed hierarchy surfaces. A tentative wife bites the consenting fence.'), - (4, 'Ice in the Scent', - 'A futile pump bangs against the cider. A night stomachs a wizard. How does the mania originate? Can a reject wreck a taking battle?'); - -ALTER TABLE `posts` - ADD PRIMARY KEY (`post_id`); - -ALTER TABLE `posts` - MODIFY `post_id` int(11) NOT NULL AUTO_INCREMENT, - AUTO_INCREMENT = 5; -COMMIT; \ No newline at end of file diff --git a/theme/bulma/main.php b/theme/bulma/main.php index 86db549..3fd1d6c 100644 --- a/theme/bulma/main.php +++ b/theme/bulma/main.php @@ -353,7 +353,7 @@
+ value="" />