@@ -517,7 +537,7 @@ class User
$stmt->execute();
$query = $stmt->get_result();
Token::delete($token);
- header("Location: /admin/");
+ header("Location: ".WEB_URL."/admin/");
}
else
{
@@ -535,14 +555,17 @@ class User
public static function logout(){
global $mysqli;
session_unset();
- $token = $_COOKIE['token'];
- $time = time();
- Token::delete($token);
- unset($_COOKIE['user']);
- unset($_COOKIE['token']);
- setcookie('user', null, -1, '/');
- setcookie('token', null, -1, '/');
- header("Location: /admin");
+ if (isset($_COOKIE['token']))
+ {
+ $token = $_COOKIE['token'];
+ $time = time();
+ Token::delete($token);
+ unset($_COOKIE['user']);
+ unset($_COOKIE['token']);
+ setcookie('user', null, -1, '/');
+ setcookie('token', null, -1, '/');
+ }
+ header("Location: ".WEB_URL."/admin");
}
/**
@@ -558,7 +581,7 @@ class User
$stmt = $mysqli->prepare("UPDATE users SET permission=? WHERE id=?");
$stmt->bind_param("si", $permission, $id);
$stmt->execute();
- header("Location: /admin/?do=user&id=".$id);
+ header("Location: ".WEB_URL."/admin/?do=user&id=".$id);
}
else{
$message = _("You don't have permission to do that!");
diff --git a/config.php.template b/config.php.template
index c42fc9a..18266b2 100644
--- a/config.php.template
+++ b/config.php.template
@@ -18,13 +18,13 @@ if (!isset($_SESSION['locale'])||isset($_GET['lang']))
$override = ((isset($_GET['lang']))?$_GET['lang']:null);
$best_match = $negotiator->negotiate($override);
$_SESSION['locale'] = $best_match;
- setlocale(LC_ALL, $_SESSION['locale'].".UTF-8");
-
- bindtextdomain("server-status", __DIR__ . "/locale/");
- bind_textdomain_codeset($_SESSION['locale'], "utf-8");
- textdomain("server-status");
}
+setlocale(LC_ALL, $_SESSION['locale'].".UTF-8");
+setlocale(LC_MESSAGES, $_SESSION['locale'].".UTF-8");
+bindtextdomain("server-status", __DIR__ . "/locale/");
+bind_textdomain_codeset("server-status", "utf-8");
+textdomain("server-status");
//Database connection
$mysqli = new mysqli("##server##","##user##","##password##","##database##");
diff --git a/install.php b/install.php
index b76fb07..b355098 100644
--- a/install.php
+++ b/install.php
@@ -1,35 +1,80 @@
-
-negotiate($override);
+ $_SESSION['locale'] = $best_match;
+ setlocale(LC_ALL, $_SESSION['locale'].".UTF-8");
+
+ bindtextdomain("server-status", __DIR__ . "/locale/");
+ bind_textdomain_codeset($_SESSION['locale'], "utf-8");
+ textdomain("server-status");
+}
if (isset($_POST['server']))
{
$mysqli = new mysqli($_POST['server'],$_POST['dbuser'],$_POST['dbpassword'],$_POST['database']);
if ($mysqli->connect_errno) {
- $message = printf(_("Connection failed: %s\n"), $mysqli->connect_error);
+ $message .= sprintf(_("Connection failed: %s\n"), $mysqli->connect_error);
+ }
+
+ if (isset($_POST['url']) && filter_var($_POST['url'], FILTER_VALIDATE_URL) === false)
+ {
+ $message .= _("Please set valid url!");
+ }
+
+ //Ostatní má checky existence ve funkci pro pridani
+ if (0 == strlen(trim($_POST['servername']))){
+ $messages[] = _("server name");
+ }
+
+ if (0 == strlen(trim($_POST['url']))){
+ $messages[] = _("url");
+ }
+
+ if (0 == strlen(trim($_POST['mailer']))){
+ $messages[] = _("mailer name");
+ }
+
+ if (0 == strlen(trim($_POST['mailer_email']))){
+ $messages[] = _("mailer email");
+ }
+
+ if (0 == strlen(trim($_POST['server']))){
+ $messages[] = _("DB server");
+ }
+
+ if (0 == strlen(trim($_POST['database']))){
+ $messages[] = _("DB name");
+ }
+
+ if (0 == strlen(trim($_POST['dbuser']))){
+ $messages[] = _("DB user");
+ }
+
+ if (0 == strlen(trim($_POST['dbpassword'])))
+ {
+ $messages[] = _("DB password");
+ }
+ if (isset($messages))
+ {
+ $message .= _("Please set");
+ $message .= implode(", ", $messages);
}
}
-if (filter_var($_POST['url'], FILTER_VALIDATE_URL) === false)
-{
- $message = _("Please set valid url!");
-}
-
-//Ostatní má checky existence ve funkci pro pridani
-if (0 == strlen(trim($_POST['servername'])) || 0 == strlen(trim($_POST['url'])) || 0 == strlen(trim($_POST['mailer']))
- || 0 == strlen(trim($_POST['mailer_email'])) || 0 == strlen(trim($_POST['server'])) || 0 == strlen(trim($_POST['database']))
- || 0 == strlen(trim($_POST['dbuser'])) || 0 == strlen(trim($_POST['dbpassword'])))
-{
- $message = _("Please enter all data!");
-}
-
-if(isset($_POST['server']) && !isset($message))
+if(isset($_POST['server']) && empty($message))
{
+ define("MAILER_NAME", $_POST['mailer']);
+ define("MAILER_ADDRESS", $_POST['mailer_email']);
define("INSTALL_OVERRIDE", true);
//No need to include config, as we have connection from testing it... :)
@@ -38,22 +83,26 @@ if(isset($_POST['server']) && !isset($message))
$array = explode(";", $sql);
foreach ($array as $value) {
+ if (empty(trim($value)))
+ {
+ continue;
+ }
$q_res = $mysqli->query($value);
if ($q_res === false)
{
- $message = printf(_("Error while creating database. Please check permission for your account or MYSQL version.
Error: %s"), $mysqli->error);
+ $message = sprintf(_("Error while creating database. Please check permission for your account or MYSQL version.
Error: %s"), $mysqli->error);
break;
}
}
- if (!isset($message))
+ if (empty($message))
{
require("classes/constellation.php");
User::add();
}
- if (!isset($message))
+ if (empty($message))
{
//Create config
$config = file_get_contents("config.php.template");
@@ -68,34 +117,37 @@ if(isset($_POST['server']) && !isset($message))
$config = str_replace("##name##", $_POST['servername'], $config);
file_put_contents("config.php", $config);
- unlink("config.php.temlpate");
+ unlink("config.php.template");
unlink("install.sql");
unlink(__FILE__);
- header("Location: /");
+ header("Location: ".WEB_URL);
}
}
-
-if (isset($message))
+Template::render_header(_("Install"));
+?>
+
+
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
+
@@ -67,25 +67,25 @@ class Template{
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
@@ -99,7 +99,7 @@ class Template{
-
+
@@ -152,18 +152,18 @@ class Template{
-
-
-
+
+
+
-
-
- }?>
-
-
+
+
+
+
+