Skip to main content Skip to page footer

Dealing with all-inkl

On my private PC, there is one instance of Apache running, together with one version of PHP. All my PHP-settings are contained in /etc/php.ini, and for crojobs I can rely on my operating system. Web hosters have different requirements, and so they have special ways of dealing with their customer's  often largely divergent requirements.

I try do describe what to do to run Typo3 on all-inkl's servers, as one project I am in charge of is hosted there.

PHP settings

In the past, PHP settings were handled by entries in .htaccess. As of mid 2023, this has changed. You have to create a file called .user.ini within your webroot directory. Mine looks like this:

max_execution_time = 300
memory_limit = 256M

With the default of 128M memory, you get strange errors from Typo3. Unfortunately, Typo3 reports do not complain about this.

Backup

In the FAQ section of all-inkl's KAS, you will find (by looking for backup) a database backup script. Create a directory within your web root, apply all-inkl's password protection (Verzeichnisschutz), enter the database credentials into this script and put it there. If you do not want to call this script manually, you may add it to all-inkl's cronjobs. The credentials to supply for the cronjob are the credentials for the directory, not the credentials for your database.

As my .htaccess file prevents sql files from being downloaded (even if they are gzipped), I had to change the name of the backup template not to contain the string 'sql'.

For file backup, you have to write your own script. It is way more performant to have an archive created on the server than to download zillions of files per FTP client. The directory created for database backup is also a good place for this script. My script looks like this - please excuse the german words:

Backup Script for Files

$gesperrt = array( "." => 1, ".." => 1, '_processed_' =>1, '_temp_' => 1);

$ordnerzahl = 0;
$dateizahl = 0;
$zip = null;

function readadir($dir) {
  global $gesperrt, $zip, $dateizahl, $ordnerzahl;
  if (is_dir($dir)) {  
    $ordnerzahl++;
    $zip->addEmptyDir($dir);
    $objects = scandir($dir);
    foreach ($objects as $object) {  
      if (!isset($gesperrt[$object])) {
        $langname = $dir. DIRECTORY_SEPARATOR .$object;  
        if (is_dir($langname) && !is_link($langname))  {
           readadir($langname);
        } else    {
          if(filesize($langname) > 20000000) {
              echo "**skippe " . $object . ", ";
          }else {
           # echo "zippe " . $object . ", ";
           $zip->addFile($langname);  
           $dateizahl++;
          }
        }
      }  
    }
  }
}

function readatree($tree, $archivname) {
   global $zip, $dateizahl, $ordnerzahl;
   $zip = new ZipArchive;
   $archivname = './' . $archivname;
   if(file_exists($archivname)) {
       unlink($archivname);
   }
   if(($res = $zip->open($archivname, ZIPARCHIVE::CREATE)) != TRUE) {
       echo "<h1>Fehler beim öffnen von $zipfile, Code: $res</h1>\n";
       return;
   }
   $ordnerzahl = 0;
   $dateizahl = 0;
   $alt = getcwd();
   chdir($tree);
   readadir('.');
   $zip->close();
   chdir($alt);
   $zipsize = filesize($archivname);
   echo "<li>$dateizahl Dateien in $ordnerzahl Ordnern in einer Zip-Datei mit $zipsize Bytes.<br />";
   echo '<a href="' . $archivname . '">Download</a></li>';
    
}

echo "<h1>Ihre Sicherungen</h1>\n<ul>\n";
readatree('../fileadmin/ludwig', 'fileadmin.zip');
readatree('../typo3conf/sites', 'sites.zip');
echo "</ul>\n";
?>


 

Running the Scheduler

This brings us - via cron jobs - to the next topic: The scheduler. There is a wrap-around to help executing the Typo3 scheduler as a cron job available at daschmi.de and - quite similiar - at itfoo.de. It also works for Typo3 version 11 and PHP 8.1 When adopting the script you have to change two paths: 

  1. the path to the PHP executable
  2. the path to your document root.

 

Mime Types for Disguised PHP files

Typo3 tries to prevent editors from uploading malicious content. One part of the strategy is filtering of SVG files, another is preventing accidential execution of user-supplied PHP files. As Apache is happy treating a file xx.php.txt like a PHP file despite the final extension, there have provisions to be taken. Unfortunately, these provisions differ from one hoster to the other, so Typo3 can not include a perfect solution into the .htaccess file.

Gladly, Oliver Hader posted a fairly complete list of remedies at Stack Overflow. For all-inkl, the solution is

<FilesMatch "\.(php[0-9,x]*|phtml)\.">
  SetHandler text/plain
</FilesMatch>