🍍 Pineapple BLOGS


Hey there, I am NeoVoid

Homepage: neovoid.is-cool.dev
Mail: neovoid[at]envs[dot]net

I love Linux (who doesnt? :p)

Have a nice day.🍍


This HTML file was generated by portable-php.

Make a Simple Guestbook with php and JS!

Recently I have created guestbook, thought I share my recepie with you, I made it with ChatGPT 3.5 and very little knowledge of JS and PHP.
Enjoy Reading💘


A Simple Guestbook Will Need Html, CSS, JS, and PHP.
You'll need a simple HTML page with CSS styling and use JavaScript to handle the form submission and save the data to a feedback.json file. Since JavaScript running in a browser cannot write directly to the local file system for security reasons, we'll use a server-side script to handle the data storage. For this example, we'll use PHP to write the data to the feedback.json file.

The following code will give user frontend to submit input in website:

<form id="feedbackForm">

   <label for="name">Name:</label>
   <input type="text" id="name" required>

   <label for="website">Website (optional):</label>
   <input type="url" id="website">

   <label for="email">Email:</label>
   <input type="email" id="email" required>

   <label for="message">Message:</label>
   <textarea id="message" required></textarea>

   <button type="submit">Sign My Guestbook!</button>

</form>

Also you need to link js file into html index file.

 <script src="script.js"></script>

This is JavaScript file. It the engine which will make the magick of processing input action happen.

document.getElementById('feedbackForm').addEventListener('submit', function(event) {
    event.preventDefault();

    const name = sanitizeInput(document.getElementById('name').value);
    const website = sanitizeInput(document.getElementById('website').value);
    const email = sanitizeInput(document.getElementById('email').value);
    const message = sanitizeInput(document.getElementById('message').value);
    const dateTime = new Date().toLocaleString();

    const formData = {
        name,
        website,
        email,
        message,
        dateTime
    };

    saveFeedback(formData);
});

function sanitizeInput(input) {
    // Implement input sanitization or use a library for this purpose
    // For this example, we'll simply trim leading and trailing spaces
    return input.trim();
}

function saveFeedback(data) {
    // Use XMLHttpRequest or fetch() to send data to the server
    // In this example, we'll use fetch() to send a POST request to the PHP script
    fetch('save_feedback.php', {
        method: 'POST',
        headers: {
            'Content-Type': 'application/json'
        },
        body: JSON.stringify(data)
    })
    .then(response => response.json())
    .then(result => {
        if (result.success) {
            alert('Success! You are Great! Thanks for your feedback buddy!');
        } else {
            alert('Damn, Something Not Right! Try Again!');
        }
    })
    .catch(error => {
        alert('Oops, Not Quite Right! Try Again!');
        console.error(error);
    });
}

If you noticed I made sure the script have sufficient security features against input injection and XSS vulnerabilties implemented, You can further add your own protective measures for increased security.

The Following php code will store the user input in JSON file.

<?php
// Validate the incoming JSON data to ensure it's properly formatted
$jsonData = json_decode(file_get_contents('php://input'), true);

if (!empty($jsonData)) {
    // Validate individual input fields for potential attacks or injections
    $name = validateInput($jsonData['name']);
    $website = validateInput($jsonData['website']);
    $email = validateInput($jsonData['email']);
    $message = validateInput($jsonData['message']);
    $dateTime = $jsonData['dateTime'];

    // Validate email format using PHP filter_var function
    if (!filter_var($email, FILTER_VALIDATE_EMAIL)) {
        sendErrorResponse('Invalid email format');
        exit;
    }

    // Additional validation for other fields can be added if required
      // Append the data to feedback.json file
    $filename = 'feedback.json';
    $jsonData = json_decode(file_get_contents($filename), true) ?? [];
    $jsonData[] = [
        'name' => $name,
        'website' => $website,
        'email' => $email,
        'message' => $message,
        'dateTime' => $dateTime
    ];

    // Write to the file in a secure manner
    if (file_put_contents($filename, json_encode($jsonData, JSON_PRETTY_PRINT | JSON_UNESCAPED_UNICODE)) !== false) {
        sendSuccessResponse();
    } else {
        sendErrorResponse('Failed to save feedback data');
    }
} else {
    sendErrorResponse('Invalid data received');
}


function validateInput($input) {
    // Implement additional input validation and sanitization here
    // For this example, we'll simply remove leading and trailing spaces
    return trim($input);
}

function sendSuccessResponse() {
    // Send a JSON response back to the client (JavaScript)
    header('Content-Type: application/json');
    echo json_encode(['success' => true]);
}

function sendErrorResponse($message) {
    // Send a JSON response back to the client (JavaScript) in case of error
    header('Content-Type: application/json');
    echo json_encode(['success' => false, 'message' => $message]);
}
?>

Now until this point we have done but if you still insist Lets go two step further and add notification system so you'll be notified via email whenever someone sign your guestbook.

Create notify.sh script

#!/bin/bash

# Read the last entry from feedback.json
last_entry=$(tail -n 8 feedback.json)

# Customize the email notification content here
subject="New Guestbook Entry"
recipient="neovoid@envs.net"

# Send email using mutt
echo -e "$last_entry" | mutt -s "$subject" -- "$recipient"

You'll need some mechanism to watch for changes in feedback.json file and triggers the execution of notify.sh

guestbook_Listener.sh

#!/bin/bash
echo feedback.json | entr notify.sh

entr is the unix program that listens for file changes and execute commands when changes occur to file.

Now you can make this guestbook_Listener.sh file run in the background in various way.
One I used here is with systemd user services.

More on that on Seperate blog of its own.

Till Then Happy Coding!

Better Looking "Indexof" Page

Remember that boring old looking "index of" page?

default apache directory listing
Default apache directory listing

Needless to mention this blinding white screen?

Ever wonder if you can change the way it look?
It turns out you can change it!
After Suddenly stumbling upon this mindblowing article I decided to make one of mine.


I copied every line of code from that article and edited css to my liking to give it my flavour.

Well it was nice looking and all well except the styling didnt continue when navigating to folders.
And asset base needed just to render it was too much.

Now you should consider exploring the comments section of that article. It contains various alternative to same approach.

One of those guy name "Lorenzo" created this Minixed. It uses simple "index.php" file alone.

I adopted it to create my own Notes Server --> https://envs.net/~neovoid/notes/

My Notes/Files server
My Customized Directory Listing

This looks Elegant and Beautiful isnt it?

With Minixed I can have many folders and all sorts of files I want.

Why this neccessary?

This is amazing to know, you can do all sorts of things with just php alone.
And Every day I go little bit closer to find it out.


Note: If you are wondering how to enable Directory listing in your webserver refer to this guide.

Dino: A Game of Chrome!

Chrome Dino is the legendary Easter Egg in Chromium based browsers when you lose the internet connection.
Its a nice simple game to pass the time and alleviate boredom.


Finally I found its source code here and added this game in my FUN category.

I modified css little bit to blend its background color with site's color.
If you want to play this game even online you always access it (in any chromium based browser) with this url chrome://dino

What are the keybinds?


Have fun playing dino!

Eternal Blue Vulnerability Report

by nvpie
Nov 3 2022


html | pdf

Bandit Walkthroughs

url: https://overthewire.org/wargames/bandit/

level 0

--------------------------------------------------------
Learn to use ssh to play this game.
helful commands: man ssh, cat

solution:

level 0 - level 01

--------------------------------------------------------
This level challenges to read file having "-" in its filename.

solution:

level 01 - level 02

--------------------------------------------------------
This level challenges to read file with spaces in its filename.

solution:

level 02 - level 03

--------------------------------------------------------
This level challenges to read hidden file.

soultion:

level 03 - level 04

--------------------------------------------------------
This level challenge us to check unique filetype among many.

solution:
there are 9 files in "inhere" directory named as -file0n
and only one of them is "human-readable"

Means it must be ASCII text document and others are binary.

To check the file type we use file command.
There are two ways to do it
The commands we may need here are: file, for loop

level 04 - level 05

--------------------------------------------------------
The password for the next level is stored in a file somewhere under the inhere directory and has all of the following properties:

human-readable
1033 bytes in size
not executable

bandit6
DXjZPULLxYr17uwoI01bNLQbtFemEgo7

bandit7
HKBPTKQnIay4Fw76bEy8PVxKEDQRKTzs

bandit8
cvX2JJa4CFALtqS87jk27qwqGhBM9plV

bandit9
UsvVyFSfZZWbi6wgC7dAFyFuR6jQQUhR

bandit10
truKLdjsbJ5g7yyJ2X2R0o3a5HQJFuLk

bandit11
IFukwKGsFW8MOq3IRFqrxE1hxTNEbUPR

bandit12
5Te8Y4drgCRfCx8ugdwuEX8KFC6k2EUu

bandit13
8ZjyCRiBWFYkneahHwxCv3wb2a1ORpYL

bandit14
4wcYUJFw0k0XLShlDzztnTBHiqxU3b3e

bandit15
BfMYroe26WYalil77FoDi9qh59eK5xNr

This is the first blog

I've tried doing something different this time.
I used php!
Again this entire website is single html page
and the blogs are simply markdown pages
I didnt even have to install any ssg or run any complex commands

This php script does all the job all i need to do is

This is the source of this program
https://github.com/cadars/portable-php

TicTacToe using javascript (ughh)

No matter how much I despise javascript but how can I resist the idea of showcasing this little game in my website?
Actually I found this game on wappalyzer addon. I was fascinated to see it and started digging its code.
Wappalyzer is handy website useful for finding out the technology stack of any website.
Their browser addon is even more handy. but when the addon dont have anything to show this applet let you play tictactoe to alleviates the boredom.

TicTacToe in Action

Here is the game in embeded in iframe. Similarly its easily accessible from links section.

I put the game in seperate html page (ttt.html), sort out its stylesheet in its own css (css/ttt.css) and its javascript (scripts/game.js).

<iframe src="../fun/ttt.html" width="220" height="120" style="display: block; margin: 25px auto; border:1px solid var(--highlight);"></iframe>

You can embed this game is your site by using above snippet. *Customize the syling elements as your need ofc.


All the source code can be found in my Codeberg Repo!

Honestly I am not a champion in this game but I am persistent in learning although I admit I had hard time winning this game at first but more I played the more I learn to defeat the Ai.

References:

Markdown examples

On top of plain Markdown, Markdown Extra adds support for footnotes, abbreviations, definition lists, tables, class and id attributes, fenced code blocks, and Markdown inside HTML blocks.

Additionally, images are properly enclosed in figure elements (with optional figcaption), and the loading="lazy" attribute is added.


This is bold, italic, this is an internal link, this is not code, press alt.

This is the image alt text
This is the image caption (line begins with a space)
This image is missing

This is a level 2 heading

This is a level 3 heading

  1. This
  2. is
  3. an ordered list

This text is in a blockquote.

This is
    preformatted
  text.
This is a table This column This one is aligned right
This is a cell is aligned 1234.56
This is a cell center 78.90

This sentence has a footnote.1


  1. This is a footnote 

Notes on the Fourth Dimension

by Jon Crabb

Tesseracts
The coloured cubes — known as "Tesseracts" — as depicted in the frontispiece to Hinton's The Fourth Dimension (1904) - Source.

Men of broader intellect know that there is no sharp distinction betwixt the real and the unreal…

— H.P. Lovecraft, The Tomb (1917)

La Belle Époque, a beautiful term for a Beautiful Age, as Light and Understanding replace Fear and Superstition, and Science and Art join hands in unholy matrimony and set out to discover the world anew. Trains become underground worms burrowing through the city, displacing medieval graves in the name of modernity; the Aéro-Club de France sends men into the heavens, amazing the public; Muybridge proves horses fly too and wins a bet; Edison floods the world with light; biologists discover germs and defy Death; botanists grow tropical plants in Parisian glass-houses and affront Nature with hot-house orchids; the phonograph and the cinema fold Time and Space for the masses. And for some reason bicycles become rather popular. The world was getting smaller every day and the discoveries were getting bigger every week. How very diverting it all was…

In the land of Sona-Nyl there is neither time nor space, neither suffering nor death.

— H.P. Lovecraft, The White Ship (1920)

During the period we now call the fin de siècle, worlds collided. Ideas were being killed off as much as being born. And in a sort of Hegelian logic of thesis/antithesis/synthesis, the most interesting ones arose as the offspring of wildly different parents. In particular, the last gasp of Victorian spirituality infused cutting-edge science with a certain sense of old-school mysticism. Theosophy was all the rage; Huysmans dragged Satan into modern Paris; and eccentric poets and scholars met in the British Museum Reading Room under the aegis of the Golden Dawn for a cup of tea and a spot of demonology. As a result of all this, certain commonly-accepted scientific terms we use today came out of quite weird and wonderful ideas being developed at the turn of the century. Such is the case with space, which fascinated mathematicians, philosophers, and artists with its unfathomable possibilities.

Outside of sheltered mathematical circles, the trend began rather innocuously in 1884, when Edwin A. Abbott published the satirical novella Flatland: A Romance of Many Dimensions under the pseudonym A. Square. In the fine tradition of English satire, he creates an alternative world as a sort of nonsense arena to lampoon the social structures of Victorian England. In this two-dimensional world, different classes are made up of different polygons, and the laws concerning sides and angles that maintain that hierarchy are pushed to absurd proportions. Initially, the work was only moderately popular, but it introduced thought experiments on how to visualise higher dimensions to the general public. It also paved the ground for a much more esoteric thinker who would have much more far-reaching effects with his own mystical brand of higher mathematics.

Cover of the first edition of Flatland (1884)
Cover of the first edition of Flatland (1884) - Source: City of London School Archive.

In April 1904, C. H. Hinton published The Fourth Dimension, a popular maths book based on concepts he had been developing since 1880 that sought to establish an additional spatial dimension to the three we know and love. This was not understood to be time as we’re so used to thinking of the fourth dimension nowadays; that idea came a bit later. Hinton was talking about an actual spatial dimension, a new geometry, physically existing, and even possible to see and experience; something that linked us all together and would result in a “New Era of Thought”. (Interestingly, that very same month in a hotel room in Cairo, Aleister Crowley talked to Egyptian Gods and proclaimed a “New Aeon” for mankind. For those of us who amuse ourselves by charting the subcultural backstreets of history, it seems as though a strange synchronicity briefly connected a mystic mathematician and a mathematical mystic — which is quite pleasing.)

Hinton begins his book by briefly relating the history of higher dimensions and non-Euclidean maths up to that point. Surprisingly, for a history of mathematicians, it’s actually quite entertaining. Here is one tale he tells of János Bolyai, a Hungarian mathematician who contributed important early work on non-Euclidean geometry before joining the army:

It is related of him that he was challenged by thirteen officers of his garrison, a thing not unlikely to happen considering how differently he thought from everyone else. He fought them all in succession – making it his only condition that he should be allowed to play on his violin for an interval between meeting each opponent. He disarmed or wounded all his antagonists. It can be easily imagined that a temperament such as his was not one congenial to his military superiors. He was retired in 1833.

Janos Bolyai: Appendix
Janos Bolyai: Appendix. Shelfmark: 545.091. Table of Figures.

Mathematicians have definitely lost their flair. The notion of duelling with violinist mathematicians may seem absurd, but there was a growing unease about the apparently arbitrary nature of "reality" in light of new scientific discoveries. The discoverers appeared renegades. As the nineteenth century progressed, the world was robbed of more and more divine power and started looking worryingly like a ship adrift without its captain. Science at the frontiers threatened certain strongly-held assumptions about the universe. The puzzle of non-Euclidian geometry was even enough of a contemporary issue to appear in Dostoevsky’s Brothers Karamazov when Ivan discusses the ineffability of God:

But you must note this: if God exists and if He really did create the world, then, as we all know, He created it according to the geometry of Euclid and the human mind with the conception of only three dimensions in space. Yet there have been and still are geometricians and philosophers, and even some of the most distinguished, who doubt whether the whole universe, or to speak more widely, the whole of being, was only created in Euclid’s geometry; they even dare to dream that two parallel lines, which according to Euclid can never meet on earth, may meet somewhere in infinity… I have a Euclidian earthly mind, and how could I solve problems that are not of this world?

— Dostoevsky, Brothers Karamzov (1880), Part II, Book V, Chapter 3.

Well Ivan, to quote Hinton, “it is indeed strange, the manner in which we must begin to think about the higher world”. Hinton's solution was a series of coloured cubes that, when mentally assembled in sequence, could be used to visualise a hypercube in the fourth dimension of hyperspace. He provides illustrations and gives instructions on how to make these cubes and uses the word “tesseract” to describe the four-dimensional object.

Diagram from Hinton’s The Fourth Dimension
Diagram from Hinton’s The Fourth Dimension (1904) - Source.

The term “tesseract”, still used today, might be Hinton’s most obvious legacy, but the genesis of the word is slightly cloudy. He first used it in an 1888 book called A New Era of Thought and initially used the spelling tessaract. In Greek, “τεσσάρα”, meaning “four”, transliterates to “tessara” more accurately than “tessera”, and -act likely comes from “ακτίνες” meaning "rays"; so Hinton’s use suggests the four rays from each vertex exhibited in a hypercube and neatly encodes the idea “four” into his four-dimensional polytope. However, in Latin, “tessera” can also mean “cube”, which is a plausible starting point for the new word. As is sometimes the case, there seems to be some confusion over the Greek or Latin etymology, and we’ve ended up with a bastardization. To confuse matters further, by 1904 Hinton was mostly using “tesseract” — I say mostly because the copies of his books I’ve seen aren’t entirely consistent with the spelling, in all likelihood due to a mere oversight in the proof-reading. Regardless, the later spelling won acceptance while the early version died with its first appearance.

Diagram from Hinton’s The Fourth Dimension
Diagram from Hinton’s The Fourth Dimension (1904) - Source.

Hinton also promises that when the visualisation is achieved, his cubes can unlock hidden potential. “When the faculty is acquired — or rather when it is brought into consciousness for it exists in everyone in imperfect form — a new horizon opens. The mind acquires a development of power”. It is clear from Hinton’s writing that he saw the fourth dimension as both physically and psychically real, and that it could explain such phenomena as ghosts, ESP, and synchronicities. In an indication of the spatial and mystical significance he afforded it, Hinton suggested that the soul was “a four-dimensional organism, which expresses its higher physical being in the symmetry of the body, and gives the aims and motives of human existence”. Letters submitted to mathematical journals of the time indicate more than one person achieved a disastrous success and found the process of visualising the fourth dimension profoundly disturbing or dangerously addictive. It was rumoured that some particularly ardent adherents of the cubes had even gone mad.

He had said that the geometry of the dream-place he saw was abnormal, non-Euclidian, and loathsomely redolent of spheres and dimensions apart from ours.

— H. P. Lovecraft, The Call of Cthulhu (1928)

Hinton’s ideas gradually pervaded the cultural milieu over the next thirty years or so — prominently filtering down to the Cubists and Duchamp. The arts were affected by two distinct interpretations of higher dimensionality: on the one hand, the idea as a spatial, geometric concept is readily apparent in early Cubism’s attempts to visualise all sides of an object at once, while on the other hand, it becomes a kind of all-encompassing mystical codeword used to justify avant-garde experimentation. “This painting doesn’t make sense? Ah, well, it does in the fourth dimension…” It becomes part of a language for artists exploring new ideas and new spaces. Guillaume Apollinaire was amongst the first to write about the fourth dimension in the arts with his essay Les peintres cubistes in 1913, which veers from one interpretation to another over the course of two paragraphs and stands as one of the best early statements on the phenomenon:

Until now, the three dimensions of Euclid’s geometry were sufficient to the restiveness felt by great artists yearning for the infinite. The new painters do not propose, any more than did their predecessors, to be geometers. But it may be said that geometry is to the plastic arts what grammar is to the art of the writer. Today, scientists no longer limit themselves to the three dimensions of Euclid. The painters have been led quite naturally, one might say by intuition, to preoccupy themselves with the new possibilities of spatial measurement which, in the language of the modern studios, are designated by the term: the fourth dimension. […] Wishing to attain the proportions of the ideal, to be no longer limited to the human, the young painters offer us works which are more cerebral than sensual. They discard more and more the old art of optical illusion and local proportion, in order to express the grandeur of metaphysical forms. This is why contemporary art, even if it does not directly stem from specific religious beliefs, none the less possesses some of the characteristics of great, that is to say religious art.

Whilst most suited to the visual arts, the fourth dimension also made inroads into literature, with Apollinaire and his calligrammes arguably a manifestation. Gertrude Stein with her strikingly visual, mentally disorienting poetry was also accused of writing under its influence, something she refuted in an interview with the Atlantic Monthly in 1935: “Somebody has said that I myself am striving for a fourth dimension in literature. I am striving for nothing of the sort and I am not striving at all but only gradually growing and becoming steadily more aware of the way things can be felt and known in words.” If nothing else, the refutation at least indicates the idea’s long-lasting presence in artistic circles.

A page from Apollinaire's Calligrammes
A page from Apollinaire's Calligrammes; poèmes de la paix et de la guerre, 1913-1916 (1918) - Source.

Some critics have since tried to back-date higher dimensions in literature to Lewis Carroll and Through the Looking-Glass, although he was, by all accounts, a fairly conservative mathematician who once wrote an article critical of current academic interest in the subject entitled "Euclid and his Modern Rivals" (1873). As a side note, Hinton once invented a game of three-dimensional chess and opined that none of his students could understand it, so perhaps Carroll would have appreciated that.

If anything, the connection between Carroll and hyperspace was the other way round, and the symbolic language employed by Carroll — mirrors, changing proportions, nonsense, topsy-turvy inversions and so on — was picked up by later artists and writers to help prop up their own conceptions of the fourth dimension, which, as we can see, were starting to become a bit of a free for all. Marcel Duchamp, for instance, coined the rather wonderful phrase “Mirrorical return” in a note about the fourth dimension and the Large Glass.

Illustration by Peter Newell
Illustration by Peter Newell from a 1902 edition of Through the Looking-Glass and What Alice Found There - Source.

In the same period that Hinton’s ideas of the fourth dimension were gaining currency among the intellectuals of Europe our “secret sense, our sixth sense” was identified by neurophysiologist Charles Sherrington in 1906. Proprioception, as he called it, is our ability to locate where a body part is when our eyes are closed — in other words, our ability to perceive ourselves in space. And yet the sixth sense means something completely different to us nowadays, associated with another fin-de-siècle obsession: mediumship, the ability to perceive things in the same space but in different dimensions. It is worth noting that in those days, scientists – real, respected, working scientists — apparently looked towards spiritualist mediums for experimental evidence. At the same time, Hinton’s cubes were used in séances as a method of glimpsing the fourth dimension (and hopefully a departed soul or two). Hinton himself published one of his very first articles on the fourth dimension with the sensational subtitle “Ghosts Explained”. In defence of the era’s more eccentric ideas, though, so much was explained or invented in so very few years, that it must have seemed only a matter of time before life’s greatest mysteries were finally solved. In any case, the craze over a mystical fourth dimension began to fade while the sensible sixth sense of proprioception just never really caught on.

A spirit photograph by William Hope
A spirit photograph by William Hope, ca. 1920 - Source.

But are not the dreams of poets and the tales of travellers notoriously false?

– H.P. Lovecraft, “The Street” (1919)

By the late 1920s, Einsteinian Space-Time had more or less replaced the spatial fourth dimension in the minds of the public. It was a cold yet elegant concept that ruthlessly killed off the more romantic idea of strange dimensions and impossible directions. What had once been the playground of spiritualists and artists was all too convincingly explained. As hard science continued to rise in the early decades of the twentieth century, the fin-de-siècle’s more outré ideas continued to decline. Only the Surrealists continued to make reference to it, as an act of rebellion and vindication of the absurd. The idea of a real higher dimension linking us together as One sounded all a bit too dreamy, a bit too old-fashioned for a new century that was picking up speed, especially when such vague and multifarious explanations were trumped by the special theory of relativity. Hinton was as much hyperspace philosopher as scientist and hoped humanity would create a more peaceful and selfless society if only we recognised the unifying implications of the fourth dimension. Instead, the idea was banished to the realms of New Age con-artists, reappearing these days updated and repackaged as the fifth dimension. Its shadow side, however, proved hopelessly alluring to fantasy writers who have seen beyond the veil, and bring back visions of horror from an eldritch land outside of time and space that will haunt our nightmares with its terrible geometry, where tentacles and abominations truly horrible sleep beneath the Pacific Ocean waiting to bring darkness to our world… But still we muddle on through.

What do we know… of the world and the universe about us? Our means of receiving impressions are absurdly few, and our notions of surrounding objects infinitely narrow. We see things only as we are constructed to see them and can gain no idea of their absolute nature. With five feeble senses we pretend to comprehend the boundlessly complex cosmos.

— H.P. Lovecraft, From Beyond (1920)


This essay was originally published by The Public Domain Review under a Creative Commons Attribution-ShareAlike 3.0 license.