Linux multi-monitor fullscreen support
[ryzomcore.git] / web / public_php / setup / header.php
blob11d64213a2c0057651709b1fe0b4d5f19e1178e6
1 <?php
3 $NEL_SETUP_SESSION = true;
4 if (file_exists( '../config.php')) {
5 session_start();
6 if ((!isset($_SESSION['nelSetupAuthenticated'])) || $_SESSION['nelSetupAuthenticated'] != 1) {
7 if (basename($_SERVER["SCRIPT_NAME"]) != "auth.php") {
8 header("Cache-Control: max-age=1");
9 header('Location: auth.php', true, 303);
10 throw new SystemExit();
13 } else if (basename($_SERVER["SCRIPT_NAME"]) != "install.php") {
14 header("Cache-Control: max-age=1");
15 header('Location: install.php', true, 303);
16 throw new SystemExit();
19 ?><!DOCTYPE html>
20 <html lang="en">
21 <head>
22 <meta charset="utf-8">
23 <meta http-equiv="X-UA-Compatible" content="IE=edge">
24 <meta name="viewport" content="width=device-width, initial-scale=1">
25 <title>Ryzom Core | <?php print(htmlentities($pageTitle)); ?></title>
26 <link href="css/bootstrap.min.css" rel="stylesheet">
27 </head>
29 <?php
30 function printalert($type, $message) {
31 print '<div class="alert alert-' . $type . '" role="alert">';
32 print $message;
33 print '</div>';
35 function is__writable($path) {
36 if ($path[strlen($path) - 1] == '/' || $path[strlen($path) - 1] == '\\') {
37 return is__writable($path.uniqid(mt_rand()).'.tmp');
40 if (file_exists($path)) {
41 if (!($f = @fopen($path, 'r+'))) {
42 return false;
44 fclose($f);
45 return true;
48 if (!($f = @fopen($path, 'w'))) {
49 return false;
51 fclose($f);
52 unlink($path);
53 return true;
55 function validate_writable($continue, $path) {
56 if (!is__writable($path)) {
57 printalert("danger", "Failed to get write permissions on " . htmlentities($path));
58 return false;
60 return $continue;
62 function create_use_database($continue_r, $con, $database) {
63 $continue = $continue_r;
64 if ($continue) {
65 $sql = "CREATE DATABASE `" . mysqli_real_escape_string($con, $database) . "` DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;";
66 if (mysqli_query($con, $sql)) {
67 printalert("success", "Database <em>" . $database . "</em> created");
68 } else {
69 printalert("danger", "Error creating <em>" . $database . "</em> database: " . mysqli_error($con));
70 $continue = false;
73 if ($continue) {
74 $sql = "USE `" . mysqli_real_escape_string($con, $database) . "`;";
75 if (mysqli_query($con, $sql)) {
76 printalert("success", "Database <em>" . $database . "</em> selected");
77 } else {
78 printalert("danger", "Error selecting <em>" . $database . "</em> database: " . mysqli_error($con));
79 $continue = false;
82 return $continue;
84 function update_database_structure($continue_r, $con, $file) {
85 $continue = $continue_r;
86 global $PRIVATE_PHP_PATH;
87 if ($continue) {
88 $sql = file_get_contents($PRIVATE_PHP_PATH . "/setup/sql/" . $file);
89 if (!$sql) {
90 printalert("danger", "Cannot read <em>" . $file . "</em>");
91 $continue = false;
92 } else {
93 if (mysqli_multi_query($con, $sql)) {
94 printalert("success", "Database structure updated using <em>" . $file . "</em>");
95 while (mysqli_more_results($con) && mysqli_next_result($con)) {
96 // no-op
98 } else {
99 printalert("danger", "Error updating database using <em>" . $file . "</em>: " . mysqli_error($con));
100 $continue = false;
104 return $continue;
108 <body>
109 <div style="margin-left: auto; margin-right: auto; padding-left: 24px; padding-right: 24px; padding-bottom: 24px; max-width: 1024px;">
111 <div class="page-header">
112 <h1>Ryzom Core <small><?php print(htmlentities($pageTitle)); ?></small></h1>
113 </div>
115 <?php
117 $continue = true;
119 // Change to root directory
120 if (!chdir("../")) {
121 printalert("danger", "Cannot change to public PHP root directory");
122 $continue = false;
127 <!-- --------------------------------------------------------------- -->