sitemap php script

A script like the following can generate automatically your sitemap (in xml format):

<?php
function genera_sitemap($path) {
  $sitemap = '<?xml version="1.0" encoding="UTF-8"?>' . "\n";
  $sitemap .= '<urlset
  xmlns="http://www.sitemaps.org/schemas/sitemap/0.9"
  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  xsi:schemaLocation="http://www.sitemaps.org/schemas/sitemap/0.9
      http://www.sitemaps.org/schemas/sitemap/0.9/sitemap.xsd">' . "\n";

  // Scansiona le directory e sottodirectory del sito
  $dir = './';
  $files = scandir($dir);
  foreach ($files as $file) {
    if ($file != '.' && $file != '..' && strpos($file, '.') !== 0) {
      if (is_dir($dir . $file)) {
        // Scansiona la sottodirectory
        $sitemap .= aggiungi_sottodirectory($dir . $file . '/', $path) . "\n";
      } else {
        // Aggiungi il file alla sitemap
        if (preg_match('/\.php$/', $file) && $file != 'sql-pass.php') {
          $sitemap .= '<url>' . "\n";
          $sitemap .= ' <loc>' . $path . '/' . $file . '</loc>' . "\n";
          $sitemap .= ' <lastmod>' . date('c', filemtime($dir . $file)) . '</lastmod>' . "\n";
          //$sitemap .= ' <changefreq>daily</changefreq>' . "\n";
          $sitemap .= ' <priority>1.0</priority>' . "\n";
          $sitemap .= '</url>' . "\n";
        }
      }
    }
  }

  $sitemap .= '</urlset>' . "\n";

  // Salva la sitemap su file
  $file = 'sitemap.xml';
  $fp = fopen($file, 'w');
  fwrite($fp, $sitemap);
  fclose($fp);
}

function aggiungi_sottodirectory($dir, $path) {
  $sitemap = '';
  $files = scandir($dir);
  foreach ($files as $file) {
    if ($file != '.' && $file != '..' && strpos($file, '.') !== 0) {
      if ($file == 'index.php') {
        $priority = '1.0';}
      elseif (preg_match('/testi/', $file)) {
          $priority = 0.2;
        }
      else {
        $priority = 0.6;
        }
      if (is_dir($dir . $file)) {
        // Scansiona la sottodirectory
        $sitemap .= aggiungi_sottodirectory($dir . $file . '/', $path) . "\n";
      } else {
        // Aggiungi il file alla sitemap
        if (preg_match('/\.php$/', $file)) {
          $sitemap .= '<url>' . "\n";
          $sitemap .= ' <loc>' . $path . substr($dir, 2) . $file . '</loc>' . "\n";
          $sitemap .= ' <lastmod>' . date('c', filemtime($dir . $file)) . '</lastmod>' . "\n";
          //$sitemap .= ' <changefreq>daily</changefreq>' . "\n";
          $sitemap .= ' <priority>' . $priority . '</priority>' . "\n";
          $sitemap .= '</url>' . "\n";
        }
      }
    }
  }
  return $sitemap;
}
?>

You can call it from different websites, with a code like the following (assuming that your script is genera-sitemap-commune.inc:

<?php
$path="https:[your-desired-path]";
include "genera-sitemap-commune.inc";
genera_sitemap($path);
?>

strange behavior in Vivaldi

If you get a pop-up window to unlock Vivaldi profile, and you share your Vivaldi profile between different Linux installation (devices), you could try to copy the folder .local/share/kwalletd from the working installation of Vivaldi to the other ones.

Mega sync with rclone

Be careful: you have to set something like:

rclone sync [your-local-path/to/the-folder-to-sync] [the-rclone-name-of-your-mega-account]:[the-Mega-remote-folder] -l -v
i.g. rclone sync /mnt/my-path/myfolder my-mega:my-mega-remote-folder -l -v

open links in Waterfox (from another app)

It could happen that you cannot open links in Waterfox from another application (such as Thunderbird): blank page and all other tabs crashed.

To solve this issue, you can try adding %u to te Waterfox.desktop file (in .local/share/applications), something like:

Exec=flatpak run net.waterfox.waterfox %u

if you have Waterfox with flatpak

css :hover on a mobile device

There lots of java-scripts to allow an effect such as mouse over on a mobile device (that is without mouse), but there is also a very, very simple solution: to use :active instead of :hover, as in the following example:

@media screen and (max-width: 580px) {
  .tooltip:active .tooltiptext {
  visibility: visible;
  opacity: 1;
}
}

while in desktop screen you can keep
.tooltip:hover .tooltiptext {
  visibility: visible;
  opacity: 1;
}

sync murena on android nextcloud

When you are asked to set a server (opening nextcloud app on android), it’s enough to enter murena.io. Then you will asked for your user and password. (found here:: https://community.e.foundation/t/how-to-sync-nextcloud-notes-with-murena-io/47079)

A problem, if you connect your android device with KDEConnect and you copy your password from your PC, could be to paste it in password field. For security reason your keyboard could not allow you to paste easy. But eventually I managed to paste it without typing it.

router settings

In this case, as in many other, it a good idea to backup your settings. Indeed if you do a hard reset of your router, you loose your settings.
To backup settings you should use a browser (web-like) interface (firefox, or chrome, or an other one) using a url like http://192.168.1.1/ or something similar, and search for “backup” (or “save”) router settings.