From 314dd4be4c83ba59fd8092da8118f3ce6219dab0 Mon Sep 17 00:00:00 2001
From: David Polakovic
Date: Sat, 9 Sep 2023 00:32:39 +0200
Subject: [PATCH] new index, blog, library, .htaccess
---
.htaccess | 15 ++--
README.txt | 19 +++-
Styles/styles.css | 3 +
blog.php | 190 ++++++++++++++++++++++++++++-----------
blogs/blog-list.html | 1 +
blogs/blog-template.html | 4 +-
clue.php | 111 +++++++++++++++++++++++
cypher.html | 20 +++++
dir.html | 86 ------------------
index.php | 12 ++-
lib.php | 112 +++++++++++++++++++++++
lib.txt | 2 +
rnd.html | 21 -----
rnd.txt | 2 +
test.html | 3 +-
15 files changed, 427 insertions(+), 174 deletions(-)
mode change 100644 => 100755 README.txt
mode change 100755 => 100644 blog.php
create mode 100644 clue.php
create mode 100755 cypher.html
delete mode 100755 dir.html
mode change 100755 => 100644 index.php
create mode 100644 lib.php
create mode 100644 lib.txt
delete mode 100755 rnd.html
create mode 100644 rnd.txt
diff --git a/.htaccess b/.htaccess
index b705e0b..fcc6cd4 100644
--- a/.htaccess
+++ b/.htaccess
@@ -1,16 +1,19 @@
-RewriteEngine on
-#redirect /file.php to /file
+RewriteEngine on
+
RewriteCond %{THE_REQUEST} \s/([^.]+)\.php [NC]
RewriteRule ^ /%1 [NE,L,R]
-# now we will internally map /file to /file.php
RewriteCond %{REQUEST_FILENAME}.php -f
RewriteRule ^(.*)/?$ /$1.php [L]
-RewriteEngine on
-#redirect /file.html to /file
+
RewriteCond %{THE_REQUEST} \s/([^.]+)\.html [NC]
RewriteRule ^ /%1 [NE,L,R]
-# now we will internally map /file to/ file.html
RewriteCond %{REQUEST_FILENAME}.html -f
RewriteRule ^(.*)/?$ /$1.html [L]
+
+RewriteCond %{REQUEST_URI} !^/blogs/ [NC]
+RewriteCond %{REQUEST_FILENAME} !-f
+RewriteCond %{REQUEST_FILENAME} !-d
+RewriteRule ^(.*)$ blogs/$1 [L]
+
diff --git a/README.txt b/README.txt
old mode 100644
new mode 100755
index 7083b7d..32a7542
--- a/README.txt
+++ b/README.txt
@@ -1,9 +1,24 @@
my-website
+A simple website that I run. Check it out on https://dpolakovic.space
Copyright 2023, David Polakovic
ABOUT:
-This is simple website that I run. You can copy it for sure,
-but read the licence first.
+This is my static, old school, 90's, web 1.0 website. I despise the responsiveness,
+mobile design and client side computing. So I made html/php site to occupy little
+piece of cyberspace. Here is description of the files:
+
+.htaccess - hides file extensions in address bar
+index.php - the "About page" with contacts (not much going on here)
+blog.php - here I place my toughts which could be sorted by form (blogs or tweets)
+lib.php - my book library in one table
+gpg.html - page with my email gpg key
+test.html - default test page for troubleshooting new features
+both .txt files are sources for php sites with hand written content.
+blog/pics/ - pictures for blogs
+blogs/blog-list.html - source for tweets and links to blogs for blog.php
+blogs/blog-template.html - default template for new blogs
+Pictures/ - directory with all pictures for sites (except the blogs)
+Styles/* - dir with font I use and CSS style file
LICENSE:
https://www.gnu.org/licenses/gpl-3.0.en.html
diff --git a/Styles/styles.css b/Styles/styles.css
index deab5d7..e8d15bb 100755
--- a/Styles/styles.css
+++ b/Styles/styles.css
@@ -1,3 +1,4 @@
+
/* Styles.css
this is a file for setting visual styles of the web page
I am no webdesigner so the comments are rather simple
@@ -262,3 +263,5 @@ body {
color: inherit;
text-decoration: inherit;
}
+/* styles.css */
+
diff --git a/blog.php b/blog.php
old mode 100755
new mode 100644
index 49345b1..fa574d7
--- a/blog.php
+++ b/blog.php
@@ -28,7 +28,7 @@
@@ -43,79 +43,162 @@
After eating and breathing, expressing opinions on the internet is the
most important human need. Here are some of mine that occupied my mind
- for more than few seconds.
+ for more than few seconds (but not much more). You can sort them to see
+ bigger blogs or smaller, more random "tweets".
';
- }
- }
-
- // function to print file line by line in reverse order
- function printFileReversed($filename)
- {
- $lines = file($filename);
- $reversedLines = array_reverse($lines);
- foreach ($reversedLines as $line)
- {
- echo $line . '
';
- }
- }
-
- // function to print file line by line which has "Edit" in them
- function printFileEdited($filename)
- {
- $file = fopen($filename, "r");
+
+
+ // Function for front page, shows latest 5 entries
+ function printFile($filename) {
+ $lines = file($filename);
+ $count = 0; // counter for lines
+ echo ''; // a container for the lines
+
+ foreach ($lines as $line) {
+ echo $line . '
';
+ $count++;
+
+ // break the loop after displaying 5 lines
+ if ($count >= 5) {
+ break;
+ }
+ }
+
+ echo '
';
+ }
+
+
+ // Prints latest 15 tweets and offers user to see them all
+ function printFileTweets($filename) {
+ $lines = file($filename);
+ $count = 0;
+ echo '';
+
+ foreach ($lines as $line) {
+ // check for word "tweet" in the lines
+ if (strpos($line, 'tweet') !== false) {
+ echo $line . '
'; // Display the line if it contains 'foo'
+ $count++;
+
+ if ($count >= 15) {
+ break; // Break the loop after displaying 15 matching lines
+ }
+ }
+ }
+
+ if ($count >= 15) {
+ // Display a clickable link if there are more than 15 matching lines
+ echo '
Check the rest...';
+ }
+
+ echo '
';
+ }
+
+ // Prints all tweets
+ function printFileAllTweets($filename) {
+ $file = fopen($filename, "r");
+
while (($line = fgets($file)) !== false) {
- if (strpos($line, 'Edited') !== false)
- {
+ // check for word "tweet" in the lines
+ if (strpos($line, 'tweet') !== false) {
echo $line . '
';
- }
- }
- fclose($file);
- }
+ }
+ }
+ fclose($file);
+ }
+
+
+ // Prints latest 15 blogs and offers user to see them all
+ function printFileBlogs($filename) {
+ $lines = file($filename);
+ $count = 0;
+ echo '';
+
+ foreach ($lines as $line) {
+ // check for word "blog-prev" in the lines
+ if (strpos($line, 'blog-prev') !== false) {
+ echo $line . '
'; // Display the line if it contains 'foo'
+ $count++;
+
+ if ($count >= 15) {
+ break; // Break the loop after displaying 15 matching lines
+ }
+ }
+ }
+
+ if ($count >= 15) {
+ // Display a clickable link if there are more than 15 matching lines
+ echo '
Check the rest...';
+ }
+ echo '
';
+ }
+
+
+ // Prints all blogs
+ function printFileAllBlogs($filename) {
+ $file = fopen($filename, "r");
+
+ while (($line = fgets($file)) !== false) {
+ // check for word "blog-prev" in the lines
+ if (strpos($line, 'blog-prev') !== false) {
+ echo $line . '
';
+ }
+ }
+ fclose($file);
+ }
?>
Sort:
- New first
- Old first
- Edited only
+
+ Tweets
+ Blogs
-
-
+
Current value of key: $key
";
- if ($sort == "new")
- {
- printFile("./blogs/blog-list.html");
+ //debug
+ //echo "
Current value of key: $key
";
+
+ // Print file sorted by user input
+
+ // save path to the file into variable...
+ $filename = './blogs/blog-list.html';
+
+ // default - main page
+ if ($sort == "all") {
+ printFile($filename);
+ }
+
+ // show first 15 tweets
+ if ($sort == "tweets") {
+ printFileTweets($filename);
+ }
+
+ // show first 15 blogs
+ if ($sort == "blogs") {
+ printFileBlogs($filename);
}
- if ($sort == "old")
- {
- printFileReversed("./blogs/blog-list.html");
+
+ // show all tweets
+ if ($sort == "tweetsfull") {
+ printFileAllTweets($filename);
+ }
+
+ // show all blogs
+ if ($sort == "blogsfull"){
+ printFileAllBlogs($filename);
}
- if ($sort == "edit")
- {
- printFileEdited("./blogs/blog-list.html");
- }
?>
-
@@ -126,6 +209,7 @@
CC BY-NC-ND 3.0
- this site is free software
+