mirror of
https://github.com/serghey-rodin/vesta.git
synced 2025-08-14 10:37:39 -07:00
Merge branch 'master' of github.com:serghey-rodin/vesta
This commit is contained in:
commit
cd0dbb4671
10 changed files with 301 additions and 272 deletions
|
@ -1,6 +1,8 @@
|
|||
<?php
|
||||
session_start();
|
||||
|
||||
require_once($_SERVER['DOCUMENT_ROOT'].'/inc/i18n.php');
|
||||
|
||||
// Check system settings
|
||||
if ((!isset($_SESSION['VERSION'])) && (!defined('NO_AUTH_REQUIRED'))) {
|
||||
session_destroy();
|
||||
|
@ -14,63 +16,15 @@ if ((!isset($_SESSION['user'])) && (!defined('NO_AUTH_REQUIRED'))) {
|
|||
$_SESSION['request_uri'] = $_SERVER['REQUEST_URI'];
|
||||
header("Location: /login/");
|
||||
exit;
|
||||
|
||||
}
|
||||
|
||||
if (isset($_SESSION['user'])) {
|
||||
require_once($_SERVER['DOCUMENT_ROOT'].'/inc/i18n/'.$_SESSION['language'].'.php');
|
||||
if(!isset($_SESSION['token'])){
|
||||
$token = uniqid(mt_rand(), true);
|
||||
$_SESSION['token'] = $token;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Translates string by a given key in first parameter to current session language. Works like sprintf
|
||||
* @global array $LANG Associative array of language pharses
|
||||
* @return string Translated string
|
||||
* @see _translate()
|
||||
*/
|
||||
function __() {
|
||||
$args = func_get_args();
|
||||
array_unshift($args,$_SESSION['language']);
|
||||
return call_user_func_array("_translate",$args);
|
||||
}
|
||||
|
||||
/**
|
||||
* Translates string to given language in first parameter, key given in second parameter (dynamically loads required language). Works like spritf from second parameter
|
||||
* @global array $LANG Associative array of language pharses
|
||||
* @return string Translated string
|
||||
*/
|
||||
function _translate() {
|
||||
global $LANG;
|
||||
|
||||
$args = func_get_args();
|
||||
$l = $args[0];
|
||||
|
||||
if (!$l) return 'NO LANGUAGE DEFINED';
|
||||
$key = $args[1];
|
||||
|
||||
if (!isset($LANG[$l])) {
|
||||
require_once($_SERVER['DOCUMENT_ROOT'].'/inc/i18n/'.$l.'.php');
|
||||
}
|
||||
|
||||
if (!isset($LANG[$l][$key])) {
|
||||
$text=$key;
|
||||
} else {
|
||||
$text=$LANG[$l][$key];
|
||||
}
|
||||
|
||||
array_shift($args);
|
||||
if (count($args)>1) {
|
||||
$args[0] = $text;
|
||||
return call_user_func_array("sprintf",$args);
|
||||
} else {
|
||||
return $text;
|
||||
}
|
||||
}
|
||||
|
||||
define('VESTA_CMD', '/usr/bin/sudo /usr/local/vesta/bin/');
|
||||
|
||||
$i = 0;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue