Own PHP scripts on Mycloud NAS server (FW 5.18.117)

Only when I had already bought the small Mycloud NAS did I notice that it contains everything necessary (PHP, SQL, web server), but only allows the user a few ready-made apps. I was really very disappointed about it !!!
I only need a few small PHP scripts for everyday use. So what to do?

=> The fastest possible solution is to “inject” your own PHP into the WordPress APP 😉

WordPress offers the possibility of adding your own PHP snippets, there are various plugins for this, e.g. the “XYZ PHP Code” (from ‘xyzscripts.com’). A snippet is then used to simply copy a directory of the “accessible” NAS_DISC storage into a subdirectory of WordPress. Your own script is then under “NAS_HTTP://WordPress/ xxx/…”, but that’s no problem …

1.) Create a directory in which the freely accessible PHP scripts are located. In my case they are in “NAS_DISC://family/jo/fjp_php/”
e.g. “index.php”:

<!DOCTYPE HTML>
<!-- Source of this file: NAS:/family/jo/fjp_php/index.php -->
<html>
    <head><title>JO NAS</title></head>
    <?php echo "PHP-Time: ".time(); ?>
</html>

2.) Install the WordPress APP on the NAS (database user is localhost -> ‘root’ (no password required)).

3.) Install a PHP editor plugin in the WordPress Admin-Page.

4.) Create a snippet which then will copy the free NAS directory to “NAS_HTTP://WordPress/fjp”:

<?php
// flat copy NAS-Dir NAS://'family/jo/fjp_php' to 'NAS_IP://WordPress/fjp'
// Version 1.0: No Dir-Copy and No Remove of old files
$sdir="../../../family/jo/fjp_php";
$tdir="../../WordPress/WordPress/fjp";
$ldir="/WordPress/fjp";
@mkdir($tdir);
$sw=scandir($sdir);
$cnt=0;
foreach($sw as $df){
    if($file=='.'||$file=='..'||is_dir("$sdir/$df")) continue;
    echo "Copy '$df'<br>";
    file_put_contents("$tdir/$df", file_get_contents("$sdir/$df"));
    $cnt++;
}
echo "OK - <a href='$ldir' >Link:$ldir</a><br>";
?>

5.) It is sufficient to run this plugin as a “preview”.

6.) Now “NAS_HTTP://WordPress/fjp” (index.php (or .html)) is ready.

Thats it