#!/usr/local/php7.3/bin/php
<?php
$full_path = $argv[1];
$path = $argv[2];
$cmd = `cp -a /home/www/shared/laravel/$full_path/public/* .`;
$cmd = `(cd /home/www/shared/laravel/$full_path; /usr/local/php7.3/bin/php artisan key:generate) &> /home/www/log.txt.1`;
$index = file_get_contents('index.php');
$index = str_replace('__DIR__', "'/home/www/shared/laravel/$full_path/'", $index);
$index = str_replace('/../', "/", $index);
file_put_contents('index.php', $index);
/*
file_put_contents('index.php', <<<OUTPUT
<?php
require('/home/www/shared/laravel/$path/public/index.php');
OUTPUT
);
file_put_contents('.htaccess', <<<OUTPUT
RewriteEngine On
RewriteCond %{HTTP:Authorization} .
RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.php [L]
OUTPUT
);
*/