Blogposts getagged met “webdevelopment”

Linux: PHP as a standalone application

Geschreven door Erwin A.W. Maas

Run only PHP in Linux (Ubuntu / Zorin and whatever more...)

Most of my websites don't use a database, therefore I do not need Apache or MySQL to edit them on localhost.
Now I know, you can do that by installing Lamp (Xampp), but easier and quicker is it to just run PHP on it's own (provided that you already have downloaded and unpacked PHP to somewhere in your filesystem).

If you do not yet have PHP installed, here's a quick how-to (1 = check if PHP exists and which version, 4 if no PHP installed, 5 = to check the version again and write the configuration to a file for easier upgrade, 6 = get the last version and 8 = remove old version):

  1. php -v
  2. sudo apt update
  3. sudo apt full-upgrade
  4. sudo apt install php
  5. dpkg -l | grep php | tee packages.txt
  6. sudo add-apt-repository ppa:ondrej/php
  7. sudo apt update
  8. sudo apt autoremove

Now you have PHP installed and you can run it either through the terminal or make a bashfile and add a starter to it on the desktop for convenience. In contrary to what most webresources say, you do not need to move your website-files to a specific default location, just point to them in the bashfile. You basically only need 2 lines to get PHP going.
Open a text-editor or IDE, start with an empty new file and write (editing the path/to-part):
#! /usr/bin/bash
php -S localhost:8080 -t /path/to/my/websites/

Save the file as somename.sh and remember the save-path

Now you only have to create a starter which points to the bash-file and let it run in the terminal (check this option)

Terminal-notifications while running PHP

In the Terminal you should be able to read that PHP has started and while working on your websites the terminal will provide all kinds of useful information about the processes that PHP follows as ordered by the pages that you open in the browser.

In your browser go to localhost:8080 and you'll see your websites. Now you can edit them local in whatever application you wish and upload them to the webserver whenever you are happy to share them 😎

More reasons to use adblockers

Geschreven door Erwin A.W. Maas

Hacked by Youtube

More and more people use browsers with build-in adblockers or browser-extensions for blocking ads.

I just noticed that embedded videos are not only being blocked when you use an adblocker but cause 404-errors for every ad that's on it because the ad-blocker makes the browser refuse these requests, this causes 4 failed pageloads per video, I had two videos and I noticed in a request - tracking script (that I wrote and use) that 8 x googleads (doubleclick etc.) were blocked.

My blog started loading slowly and I tracked down the reason: with every pageload 8 errorpages are being requested as well which causes 9 pageviews on every load instead of just 1.

Click "More" (below) to continue reading

…meer

Values and multidimensional arrays

Geschreven door Erwin A.W. Maas

Full-stack webdev in a nutshell:

When you're trying to get some values from an array that you've been building for hours and you feel you're almost there:

foreach ($all as $allkey => $allvalue) {
    for ($getthefuckingvalues = 0;$getthefuckingvalues < 3;$getthefuckingvalues++) {
        echo $allkey . ": " . $allvalue . "<br>";
    }
}

Didn't work: Warning: Array to string conversion in...😡

Away with external scripts and a strong CSP

Geschreven door Erwin A.W. Maas

Results security scan

I have been busy with a strong Content Security Policy the last couple of months and experienced all kinds of issues with 3rd-party scripts like analytics-tools and a consent-manager script that I needed because of these analytics tools.

To keep everything running fine I had to add several things to the CSP that I didn't like, for example 'unsafe-inline' and 'unsafe-eval'.
Next to that one item of the cookie-consent-script just did not load and there was nothing to do about it before the scriptprovider themselves make changes to it so that I can Hash or Nonce it.

So what did I do?

…meer

Get the real last 24 hours with PHP

Geschreven door Erwin A.W. Maas

Getting the last 24 hours

Looking around on the web about this, you mostly see the wrong solutions, so:
If you want to query a database for the last 24 hours in a MySQL-query like:

SELECT * FROM mytable WHERE date BETWEEN '$lastday' AND '$date'

Then using:

$date = date('Y-m-d'); $lastday = date('Y-m-d',strtotime("-1 day"));

will give you today + yesterday all day.

Instead you need to do:

$lastday = date('Y-m-d',strtotime("-1 day + 24 hours"));

So: if you're not sure, check your code!

From arrays to MySQLi

Geschreven door Erwin A.W. Maas

So: no arrays...

One of my hobbies is genealogy.
My familytree consists of around 12.000 people

I like to host my familytree myself, but I have tried every single application and there's not one that suits me.
So I decided to start building one myself.

On localhost I have been working for about two weeks on an array-based (without a database) application and I got very far, but it came to an abrupt end when the webserver ran out of memory on the most important functionality.

So: that was that and on to a MySQLi-based fully self-build familytree!

The web is going nuts

Geschreven door Erwin A.W. Maas

Back after almost 24hrs.

Well: that was an adventure...

Yesterday morning around 09.00 I couldn't see my webpage anymore and thought it was down. But I also couldn't reach control-panel, no FTP, no Webdisk, nothing.
After 24hrs. I received a message that our IP-number was blocked by the server, blocked by your own domain

Well: Ip whitelisted, problem solved.
That's a bit different than being blocked by Facebook over and over and never receiving an answer to any question... 🙄 🤮 🖕

Free webhost & (sub)Domain

Geschreven door Erwin A.W. Maas

Infinityfree: all that you need.

There used to be a time, especially in the beginning 10-15 years of the internet, that you could build a website for free, practically everywhere.

Not everybody has the money to get a domainname and a hosting-account and then I already hear you saying: get a good webhost! There are no good free webhosts!
I have read those reactions many times and on many websites 🖕

I don't agree, ofcourse there will be limitations, but the quality of your website mainly depends on the sourcecode behind it and there are a variety of ways to deal with whatever situation.

…meer

Zelf je stamboom beheren

Geschreven door Erwin A.W. Maas

Zeer leuk om te doen.

(Terug) naar de stamboom beginpagina

Als je je stamboom wilt gaan uitzoeken en deze zelf beheren en mogelijk ook publiceren, dan zijn daar allerlei verschillende mogelijkheden voor. Het enige dat je nodig hebt is iets waarmee je op internet kunt

Er zijn diverse programma's te downloaden die speciaal gemaakt zijn om de gevens in te voeren. Deze programma's kunnen vaak ook mooie overzichten maken.

Het is natuurlijk niet verplicht, maar je kunt je stamboom ook op internet publiceren (en zelfs aanmaken als je dat liever wilt).

❗ Klik hieronder op "...meer" om de uitleg te bekijken.

…meer

Using module headadditions for styling

Geschreven door Erwin A.W. Maas

Why this module ❓

I created this Module because I was looking for a nice Blogscript which was easily customizable. And then I found this script and I loved it immediately.

But for me it was not so easy to customise, pretty complicated for my level of coding-skills and this module "Headadditions" makes it pretty easy to customise the Blog and it's extremely powerful too: anybody can add scripts like analytics or cookieconsent to the Blog, add metatags for SEO and stylesheets to make things look different, more to their likings.

…meer

PHP on localhost made easy

Geschreven door Erwin A.W. Maas

Need only PHP ❓

If you have a website with PHP-files, you can install a webserver-package with PHP, Apache webserver and MySQL. For example: one like Xampp, Wampserver or whatever. This can be a hassle: often you need to change several settings to make everything work.

But what if you only need PHP? Is there an easier way to work on your website offline?

Yes there is, let me explain: you can go to the downloadpage of php.net or if you are on windows even easier: go to the Windows-PHP downloadpage.

…meer

Officiële opening van de Blog!

Geschreven door Erwin A.W. Maas

img alttext

Nou: we kunnen eindelijk aan de slag.
Ik heb ongeveer 2 maanden geleden besloten om alle websites te vernieuwen, dat is al een poosje klaar.

Maar ik wilde ook wat interactieve mogelijkheden gaan aanbieden en heb toen na veel zoeken een leuke Sociale Media gevonden en deze blog (welke ik geweldig vind).

Alleen: er waren problemen achter de schermen, 1 specifieke achtergrondapplicatie werkte niet bij de webhost en ik heb hier lange tijd (2 maanden ongeveer) op moeten wachten, maar dat is nu klaar.
Ik heb grootse plannen met deze blog dus kom af en toe eens kijken 😉

The CSP is ready

Geschreven door Erwin A.W. Maas

That was really an adventure, took me 6 days to make a safe Content Security Policy where all scripts and stylesheets are being loaded

But I learned a lot and it's ready for now (in the future I will try to make more use of nonces instead of hashes)

Means that I can go on with real front-end websitedevelopment, which I love most

CSP: start again after 3 days work

Geschreven door Erwin A.W. Maas

Busy inplementing a strong CSP for the domain: much more work than I expected

Google tagmanager requires a nonce, but that needs mod_unique_id which wasn't installed, but the webhost is very helpful and activated it right away, works fine on Apache-side

Quantcast-choice which generates the cookie-policy application that let's visitors choose to accept or decline, is causing the biggest problem, it breaks the whole website. But now that mod_unique_id is installed I could try use a nonce for that too.

Two of the four scripts are going to use nonces, so why not try that with all the scripts?

So: back to an empty CSP and start all over...

It's not going smooth...

Geschreven door Erwin A.W. Maas

The Social Network needs GD-Library to function, it does under PHP 8.0 but not under PHP 8.2 😟

I have send a message to the webhost about it and received an answer with a question to test it out, so I did (in the testenvironment ofcourse), after that: blank page.

Trying to get back to the old version: blank page, blank page, blank page...

The only way to get it working again was with a fresh install, new database, new datafile etc.

So: back on PHP 8.0 hoping that GD will be fixed for 8.2 soon...

Decision: the Social Media stays

Geschreven door Erwin A.W. Maas

I have been studying the login-part (you have to login anew after 24 minutes not being on the site anymore) and I have come to the conclusion that prolonging the login-session will bring critical security-issues with it: 24 minutes is the default session-time and there are good reasons for that.
This means that installing another Social Media application that dóes keep users logged in for days for example, is less secure than the application that we use now, so changing applications is not an option either.

So: we will stick to this one!

Social network Issues

Geschreven door Erwin A.W. Maas

There are some issues with the Social Network, most of them are minor issues but one is not acceptable:
-when a logged in User leaves the site, the session-cookie will expire in 24 minutes. After that a person has to log in again

Busy working on it, but if this can´t be fixed I am seriously considering installing a completely different social-media script that dóes keep the users logged in for a longer period of time.

Everything must start somewhere

Geschreven door Erwin A.W. Maas

First of all:

I like to be fully open in my website-developments.
With that I mean that I like to develop websites online and start publishing before they're ready

That said: this is my first blogpost on a clean install, much much more to come, so follow this blog to see it develop!