<?php use app\inc\Model; use app\conf\App; include "../header.php"; $postgisdb = $databaseTemplate; \app\models\Database::setDb("postgres"); if (!$_SESSION['screen_name']) { header("location: " . \app\conf\App::$param['userHostName'] . "/user/login/p"); die; } else { $name = Model::toAscii($_SESSION['screen_name'], NULL, "_"); $db = new \app\models\Database(); $dbObj = $db->createdb($name, App::$param['databaseTemplate'], "UTF8"); // databaseTemplate is set in conf/main.php if ($dbObj) { header("location: " . \app\conf\App::$param['userHostName'] . "/user/login/p"); } else { echo "<h2>Sorry, something went wrong. Try again</h2>"; echo "<div><a href='" . \app\conf\App::$param['userHostName'] . "/user/signup' class='btn btn-danger'>Go back</a></div>"; } }
#!/usr/bin/php <?php header("Content-type: text/plain"); include_once "../App.php"; new \app\conf\App(); $database = new \app\models\Database(); $arr = $database->listAllDbs(); $targetDir = \app\conf\App::$param["path"] . "app/tmp/backup"; if (!file_exists($targetDir)) { @mkdir($targetDir); } foreach ($arr['data'] as $db) { if ($db != "template1" and $db != "template0" and $db != "postgres" and $db != "postgis_template" and $db != "mapcentia") { $cmd = "pg_dump -h localhost -p 5432 -U postgres -Fc -b -f '{$targetDir}/{$db}.bak' {$db}"; echo $cmd . "\n"; exec($cmd); //$cmd = "rsync -e 'ssh -i file.pem' -avz {$targetDir}/{$db}.bak ubuntu@us1.mapcentia.com:/home/mh/upload\n"; //echo $cmd; } }