From edefd05ec61e291b37ba9d3833ec53b4760fe508 Mon Sep 17 00:00:00 2001 From: Jukka Lampikoski Date: Tue, 10 Mar 2026 14:14:07 +0200 Subject: [PATCH] =?UTF-8?q?Lis=C3=A4=C3=A4=20deploy=5Fdata.php=20-=20alust?= =?UTF-8?q?aa=20data=20tuotantoon?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Väliaikainen skripti joka luo companies.json, users.json, config.json tuotantopalvelimelle. Poistettava käytön jälkeen. Co-Authored-By: Claude Opus 4.6 --- deploy_data.php | 80 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 80 insertions(+) create mode 100644 deploy_data.php diff --git a/deploy_data.php b/deploy_data.php new file mode 100644 index 0000000..5ef2825 --- /dev/null +++ b/deploy_data.php @@ -0,0 +1,80 @@ + "cuitunet", + "nimi" => "CuituNet", + "luotu" => "2026-03-10 08:58:43", + "aktiivinen" => true, + "domains" => ["intra.cuitunet.fi"], + "primary_color" => "#0f3460", + "subtitle" => "Kuituasiakkaiden hallinta" + ] +]; + +// Users (admin / admin123) +$users = [ + [ + "id" => "419d4b0c32b88d91", + "username" => "admin", + "password_hash" => password_hash('admin123', PASSWORD_BCRYPT), + "nimi" => "Ylläpitäjä", + "role" => "admin", + "luotu" => "2026-03-09 22:36:39", + "companies" => ["cuitunet"], + "email" => "", + "signatures" => [ + "846898d4a1cb3a08" => "Jukka Lampikoski\nCuituNet Oy\nasiakaspalvelu@cuitunet.fi" + ] + ] +]; + +// Config +$config = [ + "api_key" => "3de64ed2a3ece1c0f497345e41e8e76d", + "cors_origins" => ["https://cuitunet.fi", "https://www.cuitunet.fi"] +]; + +$flags = JSON_PRETTY_PRINT | JSON_UNESCAPED_UNICODE; + +// Kirjoita vain jos tiedostoa ei ole tai se on tyhjä/default +$files = [ + 'companies.json' => $companies, + 'users.json' => $users, + 'config.json' => $config, + 'reset_tokens.json' => [], + 'login_attempts.json' => (object)[], +]; + +foreach ($files as $filename => $data) { + $path = $dataDir . '/' . $filename; + $existing = file_exists($path) ? json_decode(file_get_contents($path), true) : null; + + // Ylikirjoita jos tyhjä, olematon tai vain default-data + if ($existing === null || $existing === [] || $existing === (object)[] || + (is_array($existing) && count($existing) === 0)) { + file_put_contents($path, json_encode($data, $flags)); + echo "✓ Luotu: $filename\n"; + } else { + echo "⊘ Ohitettu (data olemassa): $filename\n"; + } +} + +// Varmista companies-hakemisto +$compDir = $dataDir . '/companies/cuitunet'; +if (!file_exists($compDir)) { + mkdir($compDir, 0755, true); + echo "✓ Luotu hakemisto: data/companies/cuitunet/\n"; +} + +echo "\nValmis! Admin-tunnus: admin / admin123\n"; +echo "POISTA TÄMÄ TIEDOSTO: rm deploy_data.php\n";